Skip to content

Instantly share code, notes, and snippets.

Verifying my Blockstack ID is secured with the address 17iQGorAodsKtNGZqxYkfohDJwY2gF5NEF https://explorer.blockstack.org/address/17iQGorAodsKtNGZqxYkfohDJwY2gF5NEF
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn app server
# Description: starts unicorn using start-stop-daemon
@gregmoreno
gregmoreno / gist:5645149
Created May 24, 2013 17:33
Bash script to run zeus commands in new sessions#!/bin/bash
function tab() {
local args="$@"
osascript &>/dev/null <<EOF
tell application "iTerm"
tell current terminal
launch session "Default Session"
tell the last session
write text "$args"
end tell
@gregmoreno
gregmoreno / sometimes_ask.rb
Created October 18, 2012 21:13
Sometimes ask
require "rspec"
class Train
attr_reader :carriages, :percent_reserved_barrier
def initialize(carriages)
@carriages = carriages
@percent_reserved_barrier = 70
end
@gregmoreno
gregmoreno / tell_dont_ask-01.rb
Created October 18, 2012 19:19
Tell dont ask
require "rspec"
class Buyer
attr_accessor :cart, :money
def initialize
@cart = []
@money = 0
end
--- 1/method_missing_gotcha-01.rb
+++ 2/method_missing_gotcha-02.rb
@@ -9,6 +9,8 @@ class RadioActive
def method_missing(name, *args)
if name.to_s =~ /^to_(\w+)$/
to_format($1)
+ else
+ super
end
end
@gregmoreno
gregmoreno / chat.coffee
Created July 19, 2012 22:55
Simple chat server using nodejs and coffeescript
net = require 'net'
server = net.createServer()
broadcast = (client, data) ->
client.write(data) if client.writable
for_others = (everyone, me, func) ->
func(other) for other in everyone when me != other
remove_me = (everyone, me) ->
@gregmoreno
gregmoreno / gist:974122
Created May 16, 2011 09:07
Initialize a hash
>> h = Hash[ 'a', 1, 'b', 2 ]
=> {["a", 1]=>["b", 2]}
>> h = Hash[ [ ['a', 1], ['b', 2] ] ]
=> {"a"=>1, "b"=>2}
>> h = Hash[ 'a' => 1, 'b' => 2 ]
=> {"a"=>1, "b"=>2}
>> h = { 'a' => 1, 'b' => 2 }
@gregmoreno
gregmoreno / gist:974102
Created May 16, 2011 08:38
Search for a string within a string
>> s = 'hello world'
=> "hello world"
>> s =~ /wor/
=> 6
>> s =~ /wok/
=> nil
>> s.scan(/wor/)
=> ["wor"]
development:
adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %>
database: db/development.sqlite3
pool: 5
timeout: 5000
production:
adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %>
database: /home/greg/dev/railsjam/db/development.sqlite3
pool: 5