Categories
advice and tips kids

Made same mistake again: stocked up too much new born and size 1 diapers

Reading Time: < 1 minute

When we were expecting the second baby, we vaguely recall the baby quickly grew out of the “new born” size diaper, so we did not stock up this time. When the baby came home with us, we already had a box of 88 pieces of Huggies natural, and being a person like to stock up things, I bought two 88 pieces Pampers new born. In about a month, our baby grew to 10 lbs, which is the upper limit of new born, and we still had about 40 pieces left.

Now baby is about 2 months old, and approaching 14 lbs (13 lbs 6 oz as of 2 month check-up), we still have a box of 92 pieces unopened. We bought a box (192 pieces) of Huggies little snugglers size 1 from Sams’ club before the baby was born. And a friend brought in 92 pieces Huggies, another friend gave us the “diaper cake” which probably had 50 pieces.

So here is our mistake again: stocked up too much new born and size 1 diapers. The good thing is we can always give it to friends who are expecting new baby 🙂

Categories
Fun kids

New problem with new baby

Reading Time: < 1 minute

We had a new baby girl about 2 months ago. One problem we anticipated did not show up as I feared: the feeling of being neglected for my older daughter, as new baby usually gets more attention. That’s good. When I think about it, I heard so many warnings from my friends and tried to spend some quality time with serenity.

But another unexpected problem arose. The financial one. Between the medical bills related to new baby, the home helper to help out my wife, and rising child care cost from Serenity’s school, and at the same time my stagnant take home pay, I suddenly found out I am not on a sound financial footing. I am doing some maneuvers, such as consolidating checking accts., refinance mortgage, etc.

I hope to get through this school year, because in next fall my elder daughter will start kindergarten at local public school. No more child are cost for her, if any 🙂

Categories
iPhone app

Why new Apple smart watch is not called iWatch?

Reading Time: < 1 minute

Here is my theory. Years ago I heard people in China mentioned “Apple Phone” (苹果手机), for iPhone. This is particularly true for older generation as their grasp of English is not as good as younger generation. So this time they decided just go with Apple Watch 苹果手表.

Note this is also their fourth main product category innovation since year 2000 : iPod, iPhone and iPad. If they stick with iWatch, the name will be too predicable. But this is secondary compared to the reason above, which is use their Apple logo, and name. Both are well known all over the world.

PS, saw this disturbing video about people lining up at Apple store for iPhone just for resell.

Categories
iPhone app

Calling restful POST PUT and DELETE methods in AFNetworking 2.0

Reading Time: 2 minutes

(Note 12-03-2015): for a more deep understanding of REST API and iOS usage of it, see this blog post by Mugunth Kumar. Very well written piece on REST. My tutorial below is meant to get hands dirty quickly on iOS web service calls 🙂

(Original 09-03-2014) Some example code here. For GET methods and AFNetworking 2.0 using a php web service, raywenderlich.com has an excellent tutorial. One problem I saw when I did this exercise is the service was expecting “application/json” for “Content-Type” (note the default is text/html, if we don’t specify in request serializer).


// POST method
-(IBAction)addBook:(id)sender
{
    // 1, note this is the base URL, typically it's the end point of REST web service
    NSURL *baseURL = [NSURL URLWithString:BaseURLString];
    NSDictionary *parameters = @{@"title": @"One Flew Over the Cuckoo's Nest",
                                 @"author": @"Ken Kesey",
                                 @"read": @false};
    
    // 2
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    
    [manager POST:@"/book" parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        self.title = @"Book added";
        _textView.text = [[NSString alloc] initWithFormat:@"Response JSON: %@", (NSDictionary *)responseObject];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"\n============== ERROR ====\n%@",error.userInfo);
        
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error adding book"
                                                                message:[error localizedDescription]
                                                               delegate:nil
                                                      cancelButtonTitle:@"Ok"
                                                      otherButtonTitles:nil];
        [alertView show];
    }];
}

- (void)setupForRemoveAndUpdateBook:(AFHTTPSessionManager **)manager_p bookIdString_p:(NSString **)bookIdString_p
{
    NSURL *baseURL = [NSURL URLWithString:BaseURLString];
    
    [_textField resignFirstResponder];
    
    int bookId = [_textField.text intValue];
    
    *bookIdString_p = [NSString stringWithFormat:@"/book/%i", bookId];
    
    *manager_p = [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL];
    (*manager_p).requestSerializer = [AFJSONRequestSerializer serializer];
    (*manager_p).responseSerializer = [AFJSONResponseSerializer serializer];
}

// DELETE method
- (void)remove_book
{
    NSString *bookIdString;
    AFHTTPSessionManager *manager;
    [self setupForRemoveAndUpdateBook:&manager bookIdString_p:&bookIdString];
    
    [manager DELETE:bookIdString parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        self.title = @"Book deleted";
        _textView.text = [[NSString alloc] initWithFormat:@"Response JSON: %@", (NSDictionary *)responseObject];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"\n============== ERROR ====\n%@",error.userInfo);
        
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error deleting book"
                                                            message:[error localizedDescription]
                                                           delegate:nil
                                                  cancelButtonTitle:@"Ok"
                                                  otherButtonTitles:nil];
        [alertView show];
    }];
}

-(IBAction)removeBook:(id)sender
{
    [self clear:nil];

    if (_textField.text == NULL || _textField.text.length==0) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Book ID required"
                                                            message:@"Please input the book ID"
                                                           delegate:nil
                                                  cancelButtonTitle:@"Ok"
                                                  otherButtonTitles:nil];
        [alertView show];
    }
    else {
        [self remove_book];
    }
}

// PUT method
- (void)update_book
{
    NSString *bookIdString;
    AFHTTPSessionManager *manager;
    [self setupForRemoveAndUpdateBook:&manager bookIdString_p:&bookIdString];
    
    NSDictionary *parameters = @{@"read": @true};
    
    [manager PUT:bookIdString parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        self.title = @"Book updated";
        _textView.text = [[NSString alloc] initWithFormat:@"Response JSON: %@", (NSDictionary *)responseObject];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"\n============== ERROR ====\n%@",error.userInfo);
        
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error updating book"
                                                            message:[error localizedDescription]
                                                           delegate:nil
                                                  cancelButtonTitle:@"Ok"
                                                  otherButtonTitles:nil];
        [alertView show];
    }];
}

-(IBAction)updateBook:(id)sender
{
    [self clear:nil];

    if (_textField.text == NULL || _textField.text.length==0) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Book ID required"
                                                            message:@"Please input the book ID"
                                                           delegate:nil
                                                  cancelButtonTitle:@"Ok"
                                                  otherButtonTitles:nil];
        [alertView show];
    }
    else {
        [self update_book];
    }
}

Categories
kids

Baby car seat and travel system, more about indoor playground

Reading Time: 2 minutes

We got this Graco travel system from Wal-Mart long before our second baby was born. Btw, there is a promotion ($25 rebate) going on for this product. I recall we bought the same car seat for our elder daughter when she was new born, we still have the base which we are using again, but I forgot how we install the car seat at that time (note I also wrote a blog post on this topic 4 years ago).

We also went to the St. Louis Outlet Mall (formerly the Mills), and Serenity got to play in the big indoor playground. Sometimes she just runs around.

photo 1

photo 2

photo 3

photo 4

This is the best indoor playground in St. Louis, in my opinion.

Categories
iPhone app

iOS Objective-C interview questions

Reading Time: < 1 minute

I just throw some technical questions out here. Note Ray Wenderlich has a series on this. BlackPixel has an article too.

life cycle of UIViewController;

NSString property copy or retain?

frame vs bounds

category vs subclass

What is protocol (Apple doc; Ry’s Objective-C tutorial)? Create a protocol for List, and how to implement the “add” method for linked list (stackoverflow)?

block (how to avoid memory issue);

To be continued…

Categories
kids

Stock up some diapers from Target.com

Reading Time: 2 minutes

Target is offering $20 gift cards for 2 giant packs of Pamper or Huggies diapers. With the expiring $10 off $40 store pick up offer from target.com, that makes 2 giant packs from about $70 to $40. With Target red cards, there is 5% discount as well. Personally I picked up Huggies little snuggler size 2 (12 to $18 lbs).

This is better deal than a similar deal I got from target recently, in which they offer $10 GC for 2 super packs Pampers new born diaper, which costs $50 before tax.

Sam’s Club: I bought a “super giant” Huggies’ size 1 snug and dry pack from them, which has 192 pieces, and they offered $6 off about $40 original price. From this article at babycenter it appears “little snugglers” is better than “snug and dry”.

Of course, the risk of stocking up diapers is overstock 🙂 From personal experience, size 2 is a safe bet, because infant usually slows weight growth after couple months. That’s why I don’t want to stock a lot new born and size 1.

Last but not least, when placing order at Target.com, make sure entering a valid email address to receive the free Gift Card, it appears their web page does not check that. I had to call their customer service to get the $10 GC as I forgot to put it my own email there.

PS, I picked up the huggies size 2 order this morning at 8 am. Because this is the last day of tax free holiday this year, there is quite a crowd and the Guest Service lady complained about this “flexible fulfillment” promotion (pick up in store), and the tax holiday thing. I waited for about 10 minutes before they got the items from their warehouse. Anyway, it appears Target is getting some disgruntled workers. And a related question, if a store is full of deal seekers, and not many people willing to spend, that also signals trouble, right?

Categories
advice and tips

Got suspicious call from Chase Fraud Service

Reading Time: < 1 minute

Twice

The first time, call originated from this number 1 844 540 4033, the guy not even verified my name, and told my Southwest Air Credit Card is stolen, then started reading about those “fraudulent” charges. At the end, I asked the last 4 digits of my card number, that does not match; and I asked the first name, does not match, and so on. So I told him I would hang up and call Chase directly.

The second time, they are coming back with a similar message, with this call back number 1 800 955 9060.

This itself (the phone calls) appears more like fraud, I am thinking they are trying to get more information from me. To have a peace of mind, I did verified my credit report via annualcreditreport.com (free for everyone, 3 reports for one year), and I could not find the card number mentioned by the suspicious caller.

Just trying to add some burden as we are having a baby girl lately. Those cheaters.

Categories
iPhone app Software development

Update sqlite database during iOS app update

Reading Time: 2 minutes

We all know updating sqlite database on an existing iOS app could be tricky, esp. with any schema (table) changes. In the good old days when I was developing in-house app, I found out the app would crash when I added a column to the sqlite database, after merely updating the app. The problem was, the old database won’t get updated if we don’t explicitly do it during app start-up (after app update). So what did I tell my user to do? Delete the app, and re-install the app. Not the most user-friendly way, and what if the user has some data on it that he/she wants to keep? What if this app have many users?

I had this updating issue in my mind for a while, because one of my apps needs to refresh its data. There are a few ways to do it: 1) Use a web service to get the data; 2) Just update the sqlite database. The former has some limitations: we could get data via web service, but note we still need to manipulate the database if we need to add a column or table (this is same for both approaches). The latter is faster in terms of development. So I decided to do it. I did some research on stackoverflow and found this post as my reference. Here is my implementation, if you are interested. The following is done in viewDidLoad.

Categories
advice and tips

How much should we tell Facebook, LinkedIn?

Reading Time: 2 minutes

Dos and Don’ts in the social media age

Recently the Facebook “lab rats” testing for its “news feed” is the news (see this one at Guardian). I gave it some more thought and since I’ve thought about this privacy thing before, I’d like to share some of my thoughts.

We all knew (hopefully heard about) a few years ago, people complained employers in the Facebook (or linkedIn), and got fired. So if one does not plan to move on, my suggestion is not to say negative things about employers publicly. Because although Facebook and other social media appears not necessarily public, they are actually public as soon as it’s went up in the air.

The more worrisome thing for me is, though, is with the big data (data scientists) Facebook and LinkedIn got, they have already affected how we interact with friends, reading news, and how to look for new jobs. And in the process they could manipulate how we think (Facebook appears already did this). So there is the danger of intersection of social media, psychology and data science. Should we worry about all this?

I don’t know. I am not a pessimist, but I think to be careful, or use another proverb: trust but verify. The technology usually will brings positive changes to society, but just like iPad, we should be careful don’t let iPad to our baby sitter 🙂

PS, I happened to read some unpleasant reviews on my former employer at glassdoor.com made by some former coworkers. I don’t think that’s a good idea either. I think those can be address at exit interview, or survey, but not at a public places like glassdoor.com. I don’t have personal opinion about this website (for/against), I just felt some of the comments went to extreme: too good to be true, or too bad to be true.

Another reason which I think is more relevant to those kinds of comments, is people felt frustrated (due to various reasons). And they felt relieved when they left for new jobs, and they wanted to say whatever they like. Wrong. Two reasons: 1) We don’t want to comment others purely out of our own frustrations; 2) We don’t want to bad mouth others if all at possible.

Oh, boy, now we are talking about human psychology 🙂

PS 2: came across this article “Facebook – the big tobacco in social media”, thought it’s interesting read.