Skip to content

Instantly share code, notes, and snippets.

View nickyp's full-sized avatar
🛁
Editing my status

Nicky Peeters nickyp

🛁
Editing my status
  • Amsterdam, Netherlands
View GitHub Profile
@nickyp
nickyp / org.mongodb.mongod.plist
Created October 14, 2013 15:20
LaunchAgent file for mongodb distro from mongodb.org
<?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 July 17, 2013 14:48
Killswitch Engage
Process.kill "SIGUSR1", $$ # kills Torquebox & Passenger
exit(false) # only kills Webbrick
@nickyp
nickyp / billing.rb
Last active December 11, 2015 08:28 — forked from vtim/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 November 9, 2012 14:05
Map "Escape, Backspace" to Delete Word Backward in Sublime Text 2
// 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 August 14, 2012 08:06
Rails logline: benchmark meta info
Completed 200 OK in 12ms (Views: 0.0ms | ActiveRecord: 0.0ms)
@nickyp
nickyp / rest_client.rb
Created August 8, 2012 13:09
Rest client stripped from an ancient Rails project ^_^
require 'net/http'
require 'uri'
require 'benchmark'
class Time
def to_Iso8601GmtDate
ConvertibleAttributes::Iso8601GmtDate.call(self)
end
end
@nickyp
nickyp / gist:2112612
Created March 19, 2012 13:41
default parameter references another parameter
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 February 29, 2012 07:52
NSFileHandle seekToEndOfFile
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 February 24, 2012 11:56 — forked from lukeredpath/ExampleClass.m
Macro for creating your "shared instance" using GCD
@implementation MySharedThing
+ (id)sharedInstance
{
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{
return [[self alloc] init];
});
}
@end
@nickyp
nickyp / org.mongodb.mongod.plist
Created September 26, 2011 16:00
LaunchDaemon plist for mongodb (brew install)
<?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>