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 Integer | |
def even? | |
self % 2 == 0 | |
end | |
end | |
highest, num = 0, 0 | |
(1..1_000_000).each { |i| | |
original, count = i, 0 |
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 CommentsController < ApplicationController | |
before_filter :find_post | |
before_filter :authenticate, :only => :destory | |
def new | |
@comment = @post.comments.build | |
end | |
def create | |
@comment = @post.comments.build(params[:comment]) |
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
def random_password | |
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a | |
chars.sort_by { rand }[0,7].join | |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'net/http' | |
require 'uri' | |
require 'hpricot' | |
html = Hpricot Net::HTTP.get URI.parse('http://bash.org/?random') | |
quote = (html/"p.qt").first.inner_html | |
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 Example | |
def public | |
puts "Public Method" | |
end | |
private | |
def private | |
puts "Private methods go below the private tag" | |
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
# -*- ruby -*- | |
#-- | |
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. | |
# All rights reserved. | |
# See LICENSE.txt for permissions. | |
#++ | |
require 'rubygems/rubygems_version' | |
require 'rubygems/defaults' | |
require 'thread' |
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
# -*- ruby -*- | |
#-- | |
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. | |
# All rights reserved. | |
# See LICENSE.txt for permissions. | |
#++ | |
require 'rubygems/rubygems_version' | |
require 'rubygems/defaults' | |
require 'thread' |
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
total 56 | |
drwxrwxr-x 9 root admin 306 Dec 17 15:23 . | |
drwxrwxr-x 3 root admin 102 Jan 14 2008 .. | |
drwxr-xr-x 10 root admin 340 Feb 14 2008 osx | |
drwxr-xr-x 3 root admin 102 Oct 21 14:54 rbconfig | |
drwxr-xr-x 47 root admin 1598 Dec 17 15:23 rubygems | |
-rw-r--r-- 1 root admin 22155 Dec 17 15:23 rubygems.rb | |
drwxrwxr-x 12 root admin 408 Nov 25 2007 svn | |
-rw-r--r-- 1 root admin 268 Oct 21 14:54 ubygems.rb | |
drwxrwxr-x 4 root admin 136 Aug 23 18:10 universal-darwin9.0 |
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
# This file allows for the running of rubygems with a nice | |
# command line look-and-feel: ruby -rubygems foo.rb | |
#-- | |
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. | |
# All rights reserved. | |
# See LICENSE.txt for permissions. | |
#++ | |
require 'rubygems' |
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
total 24 | |
drwxr-xr-x 6 root wheel 204 Jul 20 23:59 . | |
drwxr-xr-x 107 root wheel 3638 Jul 17 2008 .. | |
lrwxr-xr-x 1 root wheel 24 Jul 20 23:59 Headers -> Versions/Current/Headers | |
lrwxr-xr-x 1 root wheel 26 Feb 21 2008 Resources -> Versions/Current/Resources | |
lrwxr-xr-x 1 root wheel 21 Feb 21 2008 Ruby -> Versions/Current/Ruby | |
drwxr-xr-x 4 root wheel 136 Feb 21 2008 Versions |
OlderNewer