

Category Archives: Chatter
Taking things literally
I’m a thief. I take things literally.
Tags Cloud August 2015
Mr Robot: 2:22
OK, this is creepy.
This evening I had some left over food in the fridge that I was going to reheat for dinner. As I was carrying it from the fridge to the microwave I considered how long I should reheat it for. I was thinking two minutes, but thought maybe that’s not quite enough, so a little over two minutes, that is: 2:22. That’s what I decided. Then, I put the food in the microwave and accidentally unconsciously pressed start twice, i.e. two minutes. I realised the mistake I made, but didn’t concern myself to fix it. Two minutes would be about enough (it was).
Shortly after my reheated dinner I started watching my weekly Mr Robot. About 14 minutes in to this week’s episode (7) the main character Elliot used his microwave:
You can’t make this shit up.
Delete until next character occurrence in Vim
In vim, to search for next ‘>’ use: f>
To delete until next ‘”‘ use: df”
To delete an *ML attribute, e.g. use: df”.
BRACELETS recycling plastic bottles
Today I saw DIY crafts: BRACELETS recycling plastic bottles – Innova Crafts which was kinda clever…
Animated Data Visualization Of World War II Fatalities
Today I watched Animated Data Visualization Of World War II Fatalities Is Shocking.
ProgClub web statistics for May 2015
How to iteratively create PhoneGap contacts
I started a new project today to load the contacts from my personal database into my iPhone.
cd ~/Documents/pcrepo/aman-importer phonegap create phonegap-test cd phonegap-test phonegap platform add ios phonegap plugin add org.apache.cordova.contacts
There is documentation for the Contacts API.
The trouble I got into was iteratively creating contacts.
Code like this doesn’t work:
for ( var i in contact_data_list ) {
var contact_data = contact_data_list[ i ];
var contact = navigator.contacts.create();
var name = new ContactName();
name.givenName = contact_data.first_name;
name.familyName = contact_data.last_name;
contact.name = name;
contact.save(
function() { alert( 'saved!' ); },
function() { alert( 'failed!' ); }
);
}
The behavior is that contact.save fails and neither of the success or failure callbacks are invoked.
The way to iterate over the input data is like this:
var index = 0;
var saver = function() {
if ( index === contact_data_list.length ) {
// we're finished enumerating the array, we can report and exit:
navigator.contacts.find( ['*'], report_contacts );
return;
}
var contact_data = contact_data_list[ index++ ];
var contact = navigator.contacts.create();
var name = new ContactName();
name.givenName = contact_data.first_name;
name.familyName = contact_data.last_name;
contact.name = name;
contact.save(
saver,
function() { alert( 'failed!' ); }
);
};
saver();
You can see it for real over here…
The Universe and Stuff
The age of the universe is 13.798 billion years.
The size of the universe is unknown, it may be infinite.
A galaxy is a massive gravitationally bound system. There are probably more than 170 billion galaxies in the observable universe.


