Choosing a datastore on node.js

After two days of faffing with every mongodb and couchdb driver, wrapper and module available, I can finally recommend mongoq. https://github.com/zzdhidden/mongoq

I'm now reading and writing data on mongohq with ease.

The whole landscape seems to be changing very quickly with node though, so I'm sure this preference will change shortly.

Comments (0)
Posted by Effisfor 

Choosing a datastore on node.js

After two days of faffing with every mongodb and couchdb driver, wrapper and module available, I can finally recommend mongoq. https://github.com/zzdhidden/mongoq

I'm now reading and writing data on mongohq with ease.

The whole landscape seems to be changing very quickly with node though, so I'm sure this preference will change shortly.

Comments (0)
Posted by Effisfor 

Choosing a datastore on node.js

After two days of faffing with every mongodb and couchdb driver, wrapper and module available, I can finally recommend mongoq. https://github.com/zzdhidden/mongoq

I'm now reading and writing data on mongohq with ease.

The whole landscape seems to be changing very quickly with node though, so I'm sure this preference will change shortly.

Comments (0)
Posted by Effisfor 

Changing vimeo width on Tumblr

I saw a couple of scripts, none of them worked, so here's a very simple thing that worked for me:

 

 

Comments (0)
Posted by Effisfor 

Setting GPS data with AVFoundation/ALAssets

If, like me, you've been banging your head against the brick wall that is the iOS ALAssetsLibrary writeImageToSavedPhotosAlbum:metadata:completionBlock: in an attempt to get it to save GPS data, then enjoy this soothing compress:

CFDictionaryRef metaDict = CMCopyDictionaryOfAttachments(NULL, imageDataSampleBuffer, kCMAttachmentMode_ShouldPropagate);
CFMutableDictionaryRef mutable = CFDictionaryCreateMutableCopy(NULL, 0, metaDict);

NSDictionary *gpsDict = [NSDictionary
  dictionaryWithObjectsAndKeys:
  [NSNumber numberWithFloat:self.currentLocation.coordinate.latitude], kCGImagePropertyGPSLatitude,
  @"N", kCGImagePropertyGPSLatitudeRef,
  [NSNumber numberWithFloat:self.currentLocation.coordinate.longitude], kCGImagePropertyGPSLongitude,
  @"E", kCGImagePropertyGPSLongitudeRef,
  @"04:30:51.71", kCGImagePropertyGPSTimeStamp,
  nil];

CFDictionarySetValue(mutable, kCGImagePropertyGPSDictionary, gpsDict);

//  Get the image
NSData *imageData = [AVCaptureStillImageOutput  jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];

//  Get the assets library
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageToSavedPhotosAlbum:[image CGImage] metadata:mutable completionBlock:captureComplete];

This should live in the completionHandler of the captureStillImageAsynchronouslyFromConnection method of your AVCaptureConnection object. self.currentLocation is just a CLLocation and GPSTimestamp (A UTC timestamp) and Lat/Lng Ref are hardcoded here for simplicity's sake. And who dislikes simplicity?

Comments (0)
Posted by email 

You cannot programatically 'Like' something using the Graph API on Facebook

I'm going to repeat that because type is cheap:

You cannot programatically Like something using the Graph API on Facebook.

You may be attempting this because it seems completely rational; you may even have seen this working on big sites, y'know, custom Like buttons. You are wrong.
It's not that these sites have a special relationship with Facebook, or that Facebook are worried that you'll make an Add To Cart button that actually
makes your visitors Like Equestrian Pornography websites, it is actually because you are an alien*. And wrong.

Sorry.

*Evidence that you are an alien.
http://forum.developers.facebook.com/viewtopic.php?pid=235590

Comments (0)
Posted by Effisfor 

CSS Positioning awry with new HTML spec

This is just sheer ignorance on my part [again]. If you have suddenly noticed all your CSS relative or absolute positions are slightly off, take a look to see if you've changed the HTML spec of the page. I changed mine to match the recommended Facebook spec and all my positions went askew by 5 pixels.

Comments (0)
Posted by Effisfor 

jQuery UI + Droppable Drop Event

My Droppable 'Drop' Event wouldn't fire. Pooh.

I had an image in my drop area div.

I removed it and it now fires the event. Yippee.

All other events fired as you'd expect, so I think this is a bug.

Moral of this woeful little tale: Keep your images in the background of your div, or get hacking.

Comments (2)
Posted by Effisfor 

Postgres with Rails

I needed to get my Rails app running with a Postgres DB today (so I could take advantage of the excellent Texticle) , but found it a little trickier than expected.

Here's what I had to do (using Ubuntu Karmic)

1/ Install Postgres

This is as easy as sudo apt-get install postgresql for Ubuntu folk.

2/ Make a yourself a superuser

By default, Postgres uses 'ident sameuser' so you don't need a password when connecting from the same machine. I did:

sudo -u postgres createuser --superuser $USER
sudo -u postgres psql

which will take you to the psql command line. Set yourself a password with:

postgres=# \password $USER

This password is used (I think) when connecting to the DB remotely. The only time I've had to use it is to do a db:pull with taps.

3/ Install the postgres and postgres-pr gem

I'll be honest. I don't remember if both are necessary (I could have sworn it was just postgres), but I've got both installed so it can't hurt to have both.

They required some dependencies which were resolved by installing libpq-dev. On Ubuntu, this is:

sudo aptitude install libpq-dev

Now you're free to do

gem install postgres
gem install postgres-pr

4/ Set your database.yml

Finally, set the config/database.yml file in your Rails app to mimic:

development:
  adapter: postgresql
  database: db_name
  pool: 5
  timeout: 5000

No need for a username/password because of step 2.

Fin.

Comments (0)
Posted by email 

Fun and games with repeating jQuery animations

If you've ever been tempted to start new animations in a jQuery callback closure, then don't. Bad things happen.

Exhibit A:

$('div.one').animate({'opacity':0}, 200, 'linear', function(){
  $('div.one').css('display', 'none');
  $('div.two').animate({'opacity':1});
});

So far so good. All's fine and dandy with this first animation on div.two, but if you later try to animate div.two a second time, weird stuff starts happening in which this first animation repeats itself several times after your new animation finished. Very annoying and hard to track down as (as far as I'm aware) there's nothing 'wrong' with doing things this way. I'm not sure if this bug always crops up, but it certainly did for me today. You might be lucky.

I'm now achieving the same thing with...

$('div.one').animate({'opacity':0}, 200, 'linear, function(){$(this).css('display', 'none')}');
$('div.two').delay(200).animate({'opacity':1});

...where I use jQuery's lovely new delay method to get things happening in the right order. Huzzah!

Comments (0)
Posted by email