Skip to content

Instantly share code, notes, and snippets.

View maggix's full-sized avatar

Giovanni Maggini maggix

  • Rotterdam, The Netherlands
View GitHub Profile
@maggix
maggix / foreach_addDate.sh
Last active August 29, 2015 14:04
Mac scripts
#!/bin/bash
for image in `find . -iname "*.jpg" -o -iname ".jpeg"`
do
convert "$image" -font Arial -pointsize 82 -fill red -annotate +100+100 %[exif:DateTimeOriginal] "$image"
done
@maggix
maggix / Databases.md
Last active August 29, 2015 14:02
My development notes

#Mongo

###Install

brew install mongo

###Run as process (not as service)

To have launchd start mongodb at login:

ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

@maggix
maggix / demo.m
Created June 2, 2014 21:11
A basic NSURLRequest
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.yourserver.com/yourRestServer.php"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:100];
[request setHTTPMethod:@"GET"];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if(!error)
{
@try {
__autoreleasing NSError *parsingError = [[NSError alloc] init];
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&parsingError];
NSLog(@"NSJSONSerialization Dict: %@", dict);

I wanted a way to scale up and down the dynos in Heroku based on time of day. To do so, I added the scheduler add-on to heroku heroku addons:add scheduler

In my Rails app, I added the scale_dynos.rake file in /lib/tasks/ and the following line to the Gemfile: gem 'heroku-api', '~> 0.3.17', :require => false

Now I can run heroku run rake scale_dynos:up (and down) through the command line, as well as scheduling the command rake scale_dynos:up in the Scheduler add-on. a