Skip to content

Instantly share code, notes, and snippets.

Avatar
📺

Nicky Peeters nickyp

📺
  • Amsterdam, Netherlands
View GitHub Profile
@nickyp
nickyp / org.mongodb.mongod.plist
Created Oct 14, 2013
LaunchAgent file for mongodb distro from mongodb.org
View org.mongodb.mongod.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.mongodb.mongod</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mongodb-osx-x86_64-2.4.6/bin/mongod</string>
<string>run</string>
@nickyp
nickyp / killswitch.rb
Created Jul 17, 2013
Killswitch Engage
View killswitch.rb
Process.kill "SIGUSR1", $$ # kills Torquebox & Passenger
exit(false) # only kills Webbrick
View billing.rb
#!/usr/bin/env ruby
require 'date'
re_line1 = /^\[b([\d,]+)h\](.*)/
re_line2 = /^scheduled (.*)/
total_hours = 0.0
STDIN.each_slice(3) { |entry| # iterate per 3 lines
hours_and_description, schedule = entry[0], entry[1]
@nickyp
nickyp / gist:4045823
Created Nov 9, 2012
Map "Escape, Backspace" to Delete Word Backward in Sublime Text 2
View gist:4045823
// Maps Emacs style "Escape, Backspace" to Delete Word Backward
{ "keys": ["escape", "backspace"], "command": "delete_word", "args": { "forward": false, "sub_words": true } }
@nickyp
nickyp / gist:3347372
Created Aug 14, 2012
Rails logline: benchmark meta info
View gist:3347372
Completed 200 OK in 12ms (Views: 0.0ms | ActiveRecord: 0.0ms)
@nickyp
nickyp / rest_client.rb
Created Aug 8, 2012
Rest client stripped from an ancient Rails project ^_^
View rest_client.rb
require 'net/http'
require 'uri'
require 'benchmark'
class Time
def to_Iso8601GmtDate
ConvertibleAttributes::Iso8601GmtDate.call(self)
end
end
@nickyp
nickyp / gist:2112612
Created Mar 19, 2012
default parameter references another parameter
View gist:2112612
foo = {:foo => "bar", :olaf => "polaf"}
bar = 2
def olaf(one, two = one[:foo])
puts "#{one} - #{two}\n"
end
olaf(foo)
olaf(foo, bar)
@nickyp
nickyp / gist:1938968
Created Feb 29, 2012
NSFileHandle seekToEndOfFile
View gist:1938968
NSFileHandle *aFileHandle;
NSString *aFile;
aFile = [NSString stringWithString:@"Your File Path"]; //setting the file to write to
aFile = [logFile stringByExpandingTildeInPath];
aFileHandle = [NSFileHandle fileHandleForWritingAtPath:aFile]; //telling aFilehandle what file write to
[aFileHandle truncateFileAtOffset:[aFileHandle seekToEndOfFile]]; //setting aFileHandle to write at the end of the file
[aFileHandle writeData:[toBeWritten dataUsingEncoding:nil]]; //actually write the data
@nickyp
nickyp / ExampleClass.m
Created Feb 24, 2012 — forked from lukeredpath/ExampleClass.m
Macro for creating your "shared instance" using GCD
View ExampleClass.m
@implementation MySharedThing
+ (id)sharedInstance
{
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{
return [[self alloc] init];
});
}
@end
@nickyp
nickyp / org.mongodb.mongod.plist
Created Sep 26, 2011
LaunchDaemon plist for mongodb (brew install)
View org.mongodb.mongod.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.mongodb.mongod</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/Cellar/mongodb/2.0.0-x86_64/bin/mongod</string>
<string>run</string>
You can’t perform that action at this time.