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 September 26, 2011 15:39
LaunchDaemon file for Mongodb (when installed with MacPorts)
<?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>/opt/mongodb/bin/mongod</string>
@nickyp
nickyp / gist:1231577
Created September 21, 2011 08:35 — forked from tvandervossen/gist:1231476
Mobile Safari viewport sizes on iOS 4.3 and 5
iPad
1024 × 690 In landscape on iOS 4.3
1024 × 672 In landscape on iOS 5
768 × 946 In portrait on iOS 4.3
768 × 928 In portrait on iOS 5
1024 × 660 Always showing bookmarks bar in landscape on iOS 4.3
1024 × 644 Always showing bookmarks bar in landscape on iOS 5
768 × 916 Always showing bookmarks bar in portrait on iOS 4.3
@nickyp
nickyp / rspec-syntax-cheat-sheet.rb
Created August 30, 2011 08:38 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@nickyp
nickyp / gist:1101395
Created July 23, 2011 13:01
homebrew-postgresql
If this is your first install, create a database with:
initdb /usr/local/var/postgres
If this is your first install, automatically load on login with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
If this is an upgrade and you already have the org.postgresql.postgres.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
@nickyp
nickyp / validate_ip_address.rb
Created July 12, 2011 15:46
validate_ip_address
def validate_ip_address
valid_ip_address = begin; IP.new(self.ip_address); rescue; end
unless ignore_nil{ valid_ip_address.is_a?(IP::V4) }
if target == "appliance"
self.errors.add_to_base I18n.t(:invalid_ipv4, :scope =>
TRANSLATE_BASE_SCOPE, :ip_address => self.ip_address)
else
self.errors.add(:ip_address, I18n.t(:invalid_ipv4, :scope =>
TRANSLATE_BASE_SCOPE, :ip_address => self.ip_address))
end
@nickyp
nickyp / database-yaml-per-git-sha.yaml
Created July 12, 2011 15:32
database-yaml-per-git-sha
database: <%= File.basename(RAILS_ROOT) %>_<%= `git symbolic-ref
HEAD`.match(/.*\/(.*)\n/)[1] %>
@nickyp
nickyp / gist:948217
Created April 29, 2011 12:08
forcing screen to use .bash_profile when starting
# in ~/.screenrc
# .bash_profile is only sourced for login shells, opening a screen does not source it
shell -$BASH
@nickyp
nickyp / gist:890331
Created March 28, 2011 11:46
LaunchCtl to Major Tom
#!/bin/bash
launchctl list
launchtl load /Library/LaunchDaemons/org.redis.redis-server.plist
launchctl reload /Library/LaunchDaemons/org.redis.redis-server.plist
launchctl stop /Library/LaunchDaemons/org.redis.redis-server.plist
launchctl restart /Library/LaunchDaemons/org.redis.redis-server.plist
launchctl unload -w org.darwinports.postgresql84 sudo launchctl load -w org.darwinports.postgresql84
launchctl unload -w org.darwinports.postgresql84 sudo launchctl load -w org.darwinports.postgresql84
@nickyp
nickyp / self_signed_cert.rb
Last active September 4, 2023 23:46
create a self-signed certificate using ruby-openssl
We couldn’t find that file to show.
@nickyp
nickyp / gist:826228
Created February 14, 2011 17:41
rescue_record_invalid
def rescue_record_invalid(e)
logger.info(e)
message = e.record.errors.map {|error|
"#{t('activerecord.attributes.' + error[0])} #{error[1]}"
}.join("\n")
respond_to do |format|
format.xml {
render :status => :unprocessable_entity,