Freitag, 30. August 2013

Riak build failure: 'get-deps' failed

When trying to build Riak on Mac OS X, you might encounter a failure when make is trying to build the dependencies:

ERROR: 'get-deps' failed while processing


The cause (at least for me) was that accessing github via the git:// protocol doesn't work from our corporate network.

Workaround: build at home, where the git: protocol isn't blocked by the firewall.

Freitag, 23. August 2013

Quoting with awk

Getting awk to print certain special characters (e.g. the single quote ') can be cumbersome. This is frustrating especially when you want to generate SQL statements, where the single quote is used as the string delimiter.

One way to overcome this is to use escape sequences with (octal) ASCII codes:

awk '{print "\047" $1 "\047,\047" $2 "\047";}'

This will convert a list like

Doe John
Mustermann Max

into

'Doe','John'
'Mustermann','Max'


UPDATE
Alternatively, you can use \x with hexadecimal ASCII codes:

awk '{print "\x27" $1 "\x27,\x27" $2 "\x27";}'

Montag, 19. August 2013

Finding files with find

find is the Swiss Army Knife tool for quickly finding files from the command line, but its syntax is somewhat unusual. Here are some quick examples:

  •  list all files with ls that were modified within the last 15 days:

     find ./ -type f -mtime -15 | xargs ls -l  

  •  list all files whose name contains "test":

     find ./ -type f -name "*test"   

  •  grep for OUR in all files modified within the last 15 days

     find ./ -type f -mtime -15|xargs grep OUR   

Donnerstag, 15. August 2013

Delete all photos from iPhone 4S

When ordering my new iPhone 4S about 2 years ago, I thought 16 GB would surely be enough - boy, what a mistake.

Since my photo collection (> 2600 photos and a couple dozen videos) was about 9.5 GB in size, I decided to remove all of them and re-import only the most important ones. Sadly, the photo app doesn't have a "Remove all" button, but as usual, the Internet provided a quick solution:
  • connect iPhone to Mac
  • open Preview
  • File -> Import from iPhone
  • Select all (Cmd+A)
  • click the "Delete" button in the lower left corner

(see https://discussions.apple.com/thread/3777283?start=0&tstart=0 for alternative approaches)