This file contains 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
stargate:rb mchung$ cat binding.rb | |
# Return bindings | |
def f | |
a = 42 | |
b = "foo" | |
binding | |
end | |
f_vars = f() |
This file contains 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
# libxml-ruby segfault | |
require 'rubygems' | |
require 'xml' | |
def try(&block) | |
begin | |
yield if block_given? | |
rescue | |
puts "err: #{$!}" |
This file contains 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
document.write("oh hai") |
This file contains 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 Selfoo | |
# bar # Why doesn't this work? | |
def self.foo | |
puts "foo" | |
end | |
class << self | |
# puts foo # Why doesn't this work? |
This file contains 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
inputs = args | |
spec = Gisting::Spec.new | |
inputs.each do |file_input| | |
input = spec.add_input | |
input.file_pattern = file_input | |
input.map do |map_input| | |
# 2722 mailbox 2006-05-23 00:08:39 | |
# 217 - 2006-05-23 15:41:48 | |
# 1326 www.crazyradiodeals.com 2006-05-23 18:00:30 | |
# 2722 mailbox 2006-05-23 00:08:39 |
This file contains 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 'rubygems' | |
require 'net/ldap' | |
# sudo gem install ruby-net-ldap | |
HOSTNAME = "foo.local" | |
BASENAME = "dc=openrain,dc=com" | |
PORT = 389 | |
puts "What's your username" | |
username = STDIN.readline.chomp |
This file contains 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 UsersController < ApplicationController | |
include Clearance::App::Controllers::UsersController | |
# Override and add in a check for invitation code | |
def create | |
@user = User.new params[:user] | |
invite_code = params[:invite_code] | |
@invite = Invite.find_redeemable(invite_code) | |
if invite_code && @invite |
This file contains 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_helper' | |
module Clearance | |
module Shoulda | |
def should_create_user_successfully | |
# Don't need this test. | |
end | |
end | |
end |
This file contains 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 'digest/sha1' | |
class Invite < ActiveRecord::Base | |
validates_presence_of :email, :on => :save, :message => "can't be blank" | |
validates_uniqueness_of :email, :on => :save, :message => "is already registered" | |
named_scope :unsent_invitations, :conditions => {:redeemed_at => nil, :invite_code => nil} | |
def invited? |
This file contains 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 'rubygems' | |
require 'sinatra' | |
require 'redis' | |
# To use, simply start your Redis server and boot this | |
# example app with: | |
# ruby example_note_keeping_app.rb | |
# | |
# Point your browser to http://localhost:4567 and enjoy! | |
# |
OlderNewer