Skip to content

Instantly share code, notes, and snippets.

View ELLIOTTCABLE's full-sized avatar
🐫

ELLIOTTCABLE

🐫
View GitHub Profile
@ELLIOTTCABLE
ELLIOTTCABLE / attr_splat_examples.rb
Created October 10, 2008 01:26
a fork of a fork!
require 'attr_splat'
class Class
class self.singleton
# We don't do this by default, just to be safe. It's perfectly acceptable,
# as attr_*'s API is fully backwards compatible.
#
# Now every example below, attr_splat could safely be replaced with
# attr_accessor
alias_method :attr_accessor, :attr_splat
class Foo
def initialize &block
p instance_eval &block if block_given? # !> `&' interpreted as argument prefix
end
def const_missing const
"foobar"
end
end
Foo.new {self} # => #<Foo:0x27204>
#!/bin/env ruby
############################################################################
# textilewc: Count words in a Textile file, if somewhat crudely.
# By Tammy Cravit, [email protected]
#
# $Revision$ $Date$
#
# If a single file is provided on the command line, it displays the number
# of words in the file. If multiple files are given on the command line, it
# generates a listing similar to the output of wc(1), except that directories
# ---- -- ---- stringray.rb ---- -- ----
module StringRay
VERSION = 2
# Splits a string into words. Not using the obvious names (+#split+, +#words+)
# because I want compatibility for inclusion into +String+.
def enumerate
ray = []
self.each_byte do |byte|
"1.8.6"
"2008-03-03"
user system total real
block 35.650000 0.050000 35.700000 ( 35.717756)
symbol106.290000 3.940000 110.230000 (111.735975)
"1.8.6"
"2008-03-03"
user system total real
block 35.230000 0.020000 35.250000 ( 35.282963)
require 'benchmark'
TIMES = 10_000_000
:foo # Anal-retentivity
def thrice_yield
3.times { yield }
end
def thrice_block &block
3.times &block
find . -name ".git" -exec rm -rf {} \;
# Translation note:
# init() will not be needed. Our input is already ready to be read. (Alliteration :D)
# Translated from http://compilers.iecc.com/crenshaw/tutor1.txt
TAB = "\t"
class scanner:
def __init__(self):
self.input = list(raw_input())
It is more than a pastie clone - it's a versioned pastie! Through the eversexy git! <3
This is my gist.
There are many like it, but this one is mine.
It is my life.
I must master it as I must master my life.
Without me, gist is sad.
Without gist, I am sad.