Google Authenticator stopped working after I upgraded iphone to iOS5. It crushed right after invocations. My co-worker told me about this, so I was at least mentally prepared.
Actually, it is pretty troublesome as you’ll lose access to Google accounts. Before you’re upgrading to iOS5, here’s what you should do:
- turn-off 2-factor authenticator
- upgrade your iPhone to iOS5
- uninstall Authenticator
- install Authenticator from App Store.
- configure Authenticator
It sounds pretty dumb, but worked.
Setup a periodic http ping program.
- currently runs under
screen. - writes timestamp and {0,1} value to STDOUT and it is redirected to
~/src/pinger/data. - writes log every 30 seconds.
- It fetches
http://www.yahoo.com.
TODO: - flush STDOUT every output.
iPhone application starts with UIApplicationMain() called in main().
It does a couple of things under the hood. It instantiates a UIApplication. It also loads a main nib file specified in .plist file. In my case it is MainWindow in .plist file and it loads MainWindow.xib file.
Each application works differently. In Cocoa, these application specific behaviors are implemented using UIApplicationDelegate instance instead of subclassing UIApplication. In other words, UIApplication and your UIApplicationDelegate protocol-supported class works together to implement your application’s behavior.
Let’s look into MainWindow.xib.
XIB file has two types of objects. They are not quite noticeable in default UI, but by expanding the view by clicking a little triangle below, it is more understandable:

The objects above the line are Placeholders. They are objects that already created somewhere in a program, and XIB connects them to references in XIB.
Other objects are instantiated by XIB. Application Delegate is one of these objects created by XIB. My Application Delegate has two outlets: viewController and window. Outlets are set up by XIB: these objects are instantiated by XIB (because they are Objects in the XIB file) and you can refer them via these member variables.
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *viewController;
Application does the final step. It shows window and sets what to be shown on the window.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
I’m getting better with Git and I use git branches more. I often found myself working on a wrong branch especially I worked on a code longer than a day. You can easily forget which branch you were working on. I thought it would be nice to show branch in command line prompt.
I found Jon Maddox’s “Show Your GIT Branch Name In Your Prompt” which does the job for me. As I don’t use his prompt as it is, I needed to understand what it does. I’ve discovered a few things I didn’t know, so I recorded how I got the prompt I wanted.
I put following code in my .bashrc.
function git_branch {
git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/:\1/'
}
PS1="\u@\h[\w\$(git_branch)]$ "
The code renders a prompt with branch name for git managed directories. It doesn’t show branch information if it is not in a git directory.
gaku@spektr[~]$ cd ~/src/sinatra
gaku@spektr[~/src/sinatra:master]$
$(<command>) bash notation.
The first thing to know is $(<command>) in bash. This captures the output of specified command. You can create a dynamic prompt by having this in PS1 variable. Note that you need to escape $(<command>) with ‘\’. Otherwise, the command is executed immediately when the script is executed (i.e. when you log in), and it fixes the prompt content and you get a static prompt.
Capturing the branch name
I uses git_branch bash function. This contains git branch command piped to sed. Jon Maddox’s command line outputs branch name in a clever way.
git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/:\1/'
If git branch command is executed outside of a git managed directory, it shows an error in stderr. However, this command line redirect stderr to /dev/null, so there is no output.
If the current directory is a git managed directory, git branch returns something like this:
master
* translation
The current branch has * at the beginning of the line. The sed command in the pipeline drops lines not starting with * and trim * and a space. The rest of the line is captured with \1 and a ‘:’ is prepended to it. So, the resulting output from git_branch bash function is :branchname.
Output from git_branch is used in PS1 to form the final command line prompt.
For existing Xcode project, Xcode doesn’t provide a UI for creating a git repository. You just need to go to the xcode directory and create git repository from a command line.
