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/bash | |
# | |
# DESCRIPTION: | |
# | |
# Set the bash prompt according to: | |
# * the ruby version | |
# * the branch/status of the current git repository | |
# * the branch of the current subversion repository | |
# * the return value of the previous command | |
# |
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/bash | |
# | |
# DESCRIPTION: | |
# | |
# Set the bash prompt according to: | |
# * the branch/status of the current git/svn repository | |
# * the return value of the previous command | |
# * the current rvm ruby version and gemset (or plain ruby, check parse_ruby_version function) | |
# | |
# USAGE: |
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
class Photo | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
referenced_in :stream | |
set_callback(:destroy, :after) do |document| | |
document.update_stream | |
end | |
def update_stream |
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
class Stream | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
field :original_photo_id | |
field :locked, type: Boolean, default: false | |
field :popular, type: Boolean, default: false | |
field :popular_order | |
field :photos_count | |
field :title |
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
Show hidden characters
# Edit file: /path/to/SublimeText2/Packages/Ruby/Ruby.sublime-build | |
{ | |
"cmd": ["/home/edgar/.rvm/rubies/ruby-1.9.2-p290/bin/ruby", "-cw", "$file"], | |
"file_regex": "^(...*?):([0-9]*):?([0-9]*)", | |
"selector": "source.ruby" | |
} |
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
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
ARGV.reject! { |path| !File.file?(path) } | |
(puts DATA.read.gsub("$0", File.basename($0)); exit 1) if ARGV.empty? | |
ARGV.each do |path| | |
ls = IO.readlines(path) | |
ix = ls[0] !~ /^#!/ ? 0 : 1 | |
next if ls[ix] =~ /#.*?coding\s*[:=]\s*\S/ |
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
#!/usr/bin/env node | |
// | |
// nicerest -- pipe your REST API `curl` calls through this for nicer output | |
// | |
// $ curl -is http://search.twitter.com/search.json?q=node.js | nicerest | |
// | |
var stdin = process.openStdin(); | |
var EventEmitter = require('events').EventEmitter; |
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
h1. Sublime Text 2 - Useful Shortcuts (Mac OS X) | |
h2. General | |
| *⌘T* | go to file | | |
| *⌘⌃P* | go to project | | |
| *⌘R* | go to methods | | |
| *⌃G* | go to line | | |
| *⌘KB* | toggle side bar | | |
| *⌘⇧P* | command prompt | |
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
# RSpec matcher to spec delegations. | |
# | |
# Usage: | |
# | |
# describe Post do | |
# it { should delegate(:name).to(:author).with_prefix } # post.author_name | |
# it { should delegate(:month).to(:created_at) } | |
# it { should delegate(:year).to(:created_at) } | |
# 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
# lvalue slicing of Hashes | |
# hash = {foo: 1, bar: 2, baz: 3} | |
# hash[:foo, :bar] == [1, 2] | |
# | |
# hash[:foo, 3] = 6,7 | |
# hash == {foo: 6, bar: 2, baz: 3, 3 => 7} | |
# | |
# strange enough, I haven't noticed any slowdown on rails startup. | |
class Hash | |
alias oldbracket [] |
OlderNewer