This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __FILE__ == $0 | |
puts "Run with: watchr #{__FILE__}. \n\nRequired gems: watchr rev" | |
exit 1 | |
end | |
# -------------------------------------------------- | |
# Convenience Methods | |
# -------------------------------------------------- | |
def run(cmd) | |
puts(cmd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __FILE__ == $0 | |
puts "Run with: watchr #{__FILE__}. \n\nRequired gems: watchr rev" | |
exit 1 | |
end | |
# -------------------------------------------------- | |
# Convenience Methods | |
# -------------------------------------------------- | |
def run(cmd) | |
puts(cmd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<markdown> | |
## Head1 | |
* List1 | |
* List 2 | |
* List 3 | |
#!ruby | |
def say | |
puts "Hello world!!!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails 3.x | |
snippet vale | |
validate ${1:method_name} | |
snippet vals | |
validates ${1:column} | |
snippet valsp | |
validates ${1:column}, :presence => ${$1:true} | |
# RSpec 2.x | |
snippet desc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cap web:deploy:desable & cap web:deploy:enable | |
server { | |
... | |
if (-f $document_root/system/maintenance.html) { set $maintenance 1; } | |
if ($request_uri ~* (jpg|jpeg|gif|js|css)$) { set $maintenance 0; } | |
if ($maintenance) { rewrite ^(.*)$ /system/maintenance.html; break; } | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git-timesheet | |
#!/usr/bin/env ruby | |
email = `git config --get user.email` | |
history = `git log --date=iso --since="1 week ago" --format="%ad %s" --no-merges --simplify-merges --reverse --committer=#{email}` | |
history.split(/\n/).group_by { |event| event[0,10] }.sort.reverse.each do |date, commits| | |
puts "#{date}\n#{"=" * 10 }"; puts commits.map { |commit| commit[10, 1024] }.sort; puts | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Then in your features you'll only need to call the `login_as` or `logout` | |
# methods. More info here: http://wiki.github.com/hassox/warden/testing | |
feature "Home page" do | |
background do | |
@user = User.create(...) # Or use fixtures, factories or whatever, even a | |
# stub user | |
login_as @user | |
visit home_page |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pg = require("pg"); | |
pg.connect('pg://postgres:password@localhost:5432/postgres', function(err, client) { | |
if (err) { console.log(err) ; } else { | |
client.query("select tablename from pg_tables;", function(err, result) { | |
if (err) {console.log(err)} else | |
{ for (var i=0; i < result.rows.length; i++) { console.log(result.rows[i].tablename) } | |
} | |
}); | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==begin | |
def self.options_for_select(story) | |
options = [] | |
options << ["",""] if story.story_type_id.nil? | |
all.map{|story_type| options<<[story_type.title,story_type.id]} | |
options | |
end | |
==end | |
irb(main):021:0> [1,2,5].inject( true ? [nil] : [] ){|a, b| a + [b, 1]} |