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 | |
APP_PATH=/home/applicake/app | |
# Production environment | |
export RAILS_ENV="production" | |
export PATH="/opt/ruby/bin:$PATH" | |
exit_with_error() { |
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
require 'date' | |
class Month | |
attr_accessor :year, :month | |
def initialize(year, month) | |
self.year = year | |
self.month = month | |
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
class Fixnum | |
def to_proc | |
lambda { |x| x + self } | |
end | |
end | |
p [1, 2, 3].map(&2) | |
# => [3, 4, 5] |
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
function Dog() { | |
this.url = '/dogs'; | |
this.fetch = function(callback) { | |
var self = this; | |
$.getJSON(this.url, function(attributes) { | |
self.attributes = attributes; | |
callback(attributes); | |
}); | |
} |
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
[ | |
{ | |
"body":"test1" | |
} | |
] |
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
require 'socket' | |
@socket = TCPSocket.new('127.0.0.1', 6379) | |
@socket.write("PING\r\n") | |
puts @socket.gets # => "+PONG" | |
@socket.close |
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
require 'open-uri' | |
def link_valid?(url) | |
open(url) | |
true | |
rescue | |
false | |
end | |
def validate_urls(urls) |
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
# list all registered hosts | |
dscl localhost -list /Local/Default/Hosts | |
# register a new host named "test.local" | |
dscl localhost -create /Local/Default/Hosts/test.local IPAddress 127.0.0.1 | |
# remove the test.local host | |
dscl localhost -delete /Local/Default/Hosts/test.local |
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
cache |
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
require 'test/unit' | |
module RoleManagement | |
@@available_roles ||= [] | |
def available_roles | |
@@available_roles | |
end | |
def roles |