Skip to content

Instantly share code, notes, and snippets.

# create remote tracking branch
git branch --track feature1 origin/master
@happyrobots
happyrobots / kill-port.sh
Created July 23, 2011 05:18
kill process occupying on port
lsof -w -n -i tcp:3000
fuser -n tcp 3000
netstat -anp|grep :3000[[:blank:]]
kill -9 pidnumber
http://user-contributions.org/wikis/userwiki/index.php?title=Bash-to-Ruby
http://www.grymoire.com/Unix/Sed.html
http://www.thegeekstuff.com/2009/12/unix-sed-tutorial-6-examples-for-sed-branching-operation/
http://www.catonmat.net/blog/sed-one-liners-explained-part-one/
http://www.catonmat.net/blog/awk-one-liners-explained-part-one/
http://sed.sourceforge.net/local/docs/emulating_unix.txt
http://www.eng.cam.ac.uk/help/tpl/unix/sed.html
Ruby:
File.read('somefile.txt').split("\n").join(" ")
describe "something", :focus => true do
it 'does something'
end
rspec spec/something.rb:8
rspec spec/something.rb -t focus
rspec spec/something.rb -e 'example name'
@happyrobots
happyrobots / configuration_with_class.rb
Created September 22, 2011 20:36
Configuration Patterns
module MyCoolModule
class Configuration
attr_accessor :my_value
def initialize
# set defaults
end
end
def self.configure
:read !pbpaste
bash$ pbpaste | vim -
"*P
@happyrobots
happyrobots / pretty_generate.rb
Created November 3, 2011 02:07
JSON Pretty Generate
require 'JSON'
puts JSON.pretty_generate(JSON.parse('{"array":[1,2,3,{"sample":"hash"}],"foo":"bar"}'))
{
"array": [
1,
2,
3,
{
git branch -m old_branch new_branch
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
heroku_status_url = "https://status.heroku.com"
doc = Nokogiri::HTML(open(heroku_status_url))
problems, problem_types = [], { "app" => "App Operations", "tools" => "Tools" }
#define SuperRandom (arc4random() % ((unsigned)RAND_MAX + 1))
float objectiveFunction(NSArray *vector) {
float result = 0.0;
for (id element in vector) {
result += [element floatValue];
}
return result;
}