Recently I needed to get the number of days i’d worked on a project. I decided to use my Git commit history to do this. After a bit of tinkering around I came up with this solution.
There’s probably a better way to do this, but this is what I came up with:
- Get the dates of all commits from now till the 1st of May 2012
- Pull out the first 10 characters (Tue May 22, for example)
- Filter by uniqueness
- Count the number of lines returned.
git log --pretty=format:"%ad" --after="1 May 2012" | cut -c -10 | uniq | wc -l
(Note you’ll probably need to change the code to pull out only your commits, on this repository i’m the only committer.)
Posted in Uncategorized
New little ‘app’ that I made with a few minutes spare this evening: Access the bluetooth pane of Settings.app on your iPhone / iPod Touch / iPad running iOS5 with two clicks directly from the home screen without having to traverse the unwieldy Settings.app.
- Open Safari and navigate here.
- Select the icon in the bottom toolbar three from the left – the box with an arrow.
- Select Add to Home Screen.
- Click Add at the top right.
Now all you have to do to open Bluetooth is open the app on your home screen and click the image in the center of the screen. Easy!
On the technical side of things I tried to get this working so when you select it on the homescreen it opens it directly without any user interaction (giving one-press access to Bluetooth). Seemingly this isn’t possible. I may be wrong – anyone with any ideas on this let me know!
I needed a Hunspell wrapper for PHP yesterday, as we’re looking at replacing the Google Spellchecking API with a hosted solution. After a bit of searching on Google I couldn’t find one that fitted the needs of our current project.
So i’ve created a simple one (fork on github).
It supports input & output in UTF-8 (as we’re using this for parsing Arabic), and can output in two modes:
- a standard PHP array keyed on the misspelled word, or
- It can mimic the Google Spellchecking API, which means it can be a direct drop-in replacement for this service.
The second method is useful for us, as it means we can simply redirect the spellchecking endpoints and get the new hosted solution without changing any parsing code.
I took a photo the other day on top of the Mountbatten building, and a number of people have asked for the full high-resolution version of the photo.
It was taken with my iPhone 4, so the quality isn’t fantastic, but here it is -
Mostly for my own future benefit here, but others may find it useful. One of the most annoying things with OSX + network shares is the fact it dumps its .DS_Store’s all over the place. Thankfully it’s fairly easy to get rid of them.
Step 1, disable OSX from dumping these in network shares to start with, by using Secrets. Find the setting called “Use .DS_Stores on network” and disable it.
Step 2, Stick this in a file on the remote server, and make it executable (
chmod +x filename):
find . -name *.DS_Store -printf \"%p\"\ \ | xargs rm
Save the file in the parent folder to the ones that contain the .DS_Store files. For example I have this file stored in /var/media. This will locate all .DS_Stores in this folder and all subsequent subfolders, and remove them leaving the rest of your files and folders untouched.
You could also edit the first argument of the find command so that it looks in a specific folder, but for ease of use (and portability) i’ve just set it to the current directory (.).
This probably isn’t the most elegant solution, but it works!