Fixing Postgres “invalid primary checkpoint record” in OSX

I recently upgraded my mid 2009 Macbook Pro with double the ram (8gb) and a new SSD. After I restored my machine via backup from Time Machine, I was running into an issue trying to start Postgres up.

This is what showed up in the log:

LOG: database system was interrupted; last known up at 2012-06-14 11:55:12 PDT
LOG: unexpected pageaddr 0/2BBE000 in log file 0, segment 4, offset 12312576
LOG: invalid primary checkpoint record
LOG: invalid secondary checkpoint record
PANIC: could not locate a valid checkpoint record
LOG: startup process (PID 2753) was terminated by signal 6: Abort trap
LOG: aborting startup due to startup process failure

After a quick googling, turns out all you need to do to fix this is reset the transaction log. Since this is just my development machine and the data doesn’t matter too much to me, I have no problems forcing a reset. This can be accomplished with pg_resetxlog.

pg_resetxlog -f /usr/local/var/postgres

Commenting with a hotkey in VIM

Sometimes commenting a block of code via regex in VIM can be a bit tedious and verbose at times.

Typing  something like :3,7s/^/#/ is annoying.

There are a couple of ways to get around this. First way would be to add a simple macro with a hotkey.

This will map - to comment and _ to uncomment.

The issue with this is it’s hardcoded to one file type. A better thing to do would set the comment type by file type.

Heres an example that enables – and _ to comment on ruby and vim files.

There are also some plugins out there that accomplishes all this for a wider range of file types. I generally only edit a few kinds of files, so the solution above works well for me.

Keep is really simple

Less bloat, fewer features, and less moving parts. These are all things that I think the KISS principle encompasses. Bloated software is expensive, buggy, unstable and tends to not be very user-friendly. All this is caused because you aren’t able to focus 100% on specific parts because there’s a hurricane of other things going on.

You know why Google got to be the best search engine and still is today? They had a laser focus on search. They made it the absolute best.

Do the same with your own products. Pick out a few features to really nail down and get right, release them to the wild then iterate.

Focus and iterate.

Another employee, a programmer, thought his online chats were eating into his work time. So he tested the theory: He looked at how long he spent chatting during certain periods, then looked at how much code he wrote during those times. But in fact, the more he talked, the more code he wrote. Gabbing online with colleagues and customers helped his work.

Sync files with lftp

LFTP is a nifty tool that is kind of like rsync, but uses ftp instead. I use it to automatically sync files from my seedbox to my home server with this script. It runs every 5 minutes in a cron job.

https://gist.github.com/2306690

  • —delete will delete any local files when they get deleted on the remote server
  • —only-missing will only transfer files that are missing from the local machine
Link

When I first open sourced my Assembla Timer app, Assembla reached out and contacted me about it and wanted to write a blog post about it:

Assembla Timer is a handy third-party Mac application that tracks time spent on tasks. You can time your work on a digital stop watch and then post the time to an Assembla project, or directly to a specific ticket.Until recently, Assembla Timer was $0.99 in Apple’s App Store, but the app’s creator,Adam Bronte, has decided to make it free and open source. The source code for the app is availablehereand a compiled version ready for install is availablehere.I installed the application, and the setup was a breeze. You simply enter your Assembla username and password, then click the ‘Start’ button to begin counting off time. You can stop and start as many times as you like – the app keeps a cumulative sum. When you’re done working, type in a description of the work completed and select an Assembla project workspace. You can also associate the time with a specific ticket. When you click ‘Save’ your information is stored in your Assembla project.Those familiar with Assembla’s time tracking capabilities know that there is a field on every ticket for “Worked Hours,” and a “Time Expenditure” tab on each ticket shows the total hours worked for a task. Assembla’s optional Time tool shows time worked across all tasks. The Time tool provides filterable reporting and is exportable for accounting and billing purposes. The Assembla Timer app makes it easier to feed accurate timing information into these reports.Assembla Timer is simple to use and allows you to focus on your work while a lightweight desktop application takes care of recording and posting your time to Assembla.

I’m glad the app may get some use out of it now. I’d like to thank Adam Feber for reaching out and writing the blog post. 

Link

Angry Birds was Rovio’s52nd game. They spent eight years and almost went bankrupt before finally creating their massive hit. Pinterest is one of the fastest growing websites in history, but struggled for a long time. Pinterest’s CEO recentlysaidthat they had “catastrophically small numbers” in their first year after launch, and that if he had listened to popular startup advice he probably would have quit.You tend to hear about startups when they are successful but not when they are struggling. This creates a systematically distorted perception that companies succeed overnight. Almost always, when you learn the backstory, you find that behind every “overnight success” is a story of entrepreneurs toiling away for years, with very few people except themselves and perhaps a few friends, users, and investors supporting them.Startups are hard, but they can also go from difficult to great incredibly quickly. You just need to survive long enough and keep going so you can create your 52nd game.

Whether is a successful business, website, app, etc, more than likely, it’s not their first rodeo. Just keep on truckin.

Try and try again

Get Hacker News in email form

Since I made Daily Hacker News a while ago, I rarely actually visit the front page. I’m either reading the comments or clicking directly through to the article. I all the top Hack News stories in a consolidated email delivered to me. It’s been a serious productivity booster. I’m no longer constantly checking back for new stories, comments, etc. I only check it once at the end of the day. 

Check out Daily Hack News

Get a third monitor on your laptop

When I first set out on getting a 3rd screen for my early 2011 gen Macbook Pro, I was looking at the Apple Thunderbolt Displays. Sexy monitor, thunderbolt support, and on par in terms of price of other 27” monitors with the same resolution. I came very close to getting one until I found out you can’t plug another monitor into it. You can only plug another Thunderbolt Display to have a 2nd external monitor. 

Thats where the eVGA Plus+ 19 comes in. This nifty device is basically a little display adapter that goes through USB. In theory, you can have as many of these devices as you have USB ports. 

I chose the eVGA flavor of this device for a few reasons:

  1. Price – At $60 it’s a good deal
  2. OSX support – It has drivers for OSX and supports Lion
  3. 1920×1200 resolution – A lot of these adapters only go up to 1920×1080 or lesss

After plugging the device and installing drivers, I now have a 3rd monitor for my MBP!

If you do end up getting one of these, it’s good to keep in mind that this is going over USB, don’t expect to do any gaming or what not. Just moving windows around on the monitor is a little laggy, but it plays video fine. 

There are also other solutions like the Matrox DualHead2Go . These devices take two monitor inputs and basically combines them so the computer thinks it’s one giant monitor. It’s way more expensive and personally, I like my computer to recognize each separate monitor for fullscreen apps and what not so I didn’t go for this solution.