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
module Enumerable | |
# Skip the first n elements and return | |
# an Enumerator for the rest, or pass them | |
# in succession to the block, if given. | |
def skip n | |
if block_given? | |
each do |x| | |
if n > 0 | |
n -= 1 | |
else |
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
module RegexpBuilder | |
module RegexpExt | |
class Builder | |
class RegexpSource | |
def initialize x | |
@src = if x.is_a? self.class | |
x.to_s | |
else | |
x | |
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
/* Programmed in 2009 by Jedediah Smith | |
* For benevolent use only. | |
* | |
* Using Visual C 2005 or later, build with: | |
* | |
* cl devdays.c /D _CONSOLE /link user32.lib /SUBSYSTEM:CONSOLE | |
* | |
* Run: | |
* | |
* devdays.exe HHMM "DevDays will resume in %s" |
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
#!/usr/bin/ruby | |
host = `hostname`.chomp | |
user = ENV['USER'] || '???' | |
pwd = Dir.pwd | |
term = ENV['TERM'] || '' | |
x = '' | |
x << "\e]0;#{pwd}\a" if term =~ /xterm|rxvt/ # set window title | |
x << "\e[1;36;44m #{user}@#{host} \e[1;33;44m#{pwd} " |
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
/* | |
* This is the CSS found in embedded gists from Github. | |
* The descriptions are Ruby specific but other languages | |
* likely use similar schemes. | |
*/ | |
.gist /* entire embedded box */ | |
#gist-? /* specific .gist box, ? is numeric gist id */ | |
.gist-file /* one file */ | |
.gist-data /* code box */ |
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 Object | |
def to_ast; self; end | |
end | |
module DAL | |
class Call | |
attr_accessor :message, :name, :args, :block | |
def initialize context, name, *args, &block | |
@context = context | |
@name = name |
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 'gserver' | |
def listen port=9999, &block | |
Class.new GServer do | |
define_method :serve, &block | |
end.new(port).start | |
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
loop { puts eval(gets).inspect } |
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
module AutoBang | |
def method_missing meth, *args, &block | |
if meth =~ /^(.*)!$/ and respond_to?(m = $1) | |
replace send(m, *args, &block) | |
else | |
super | |
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
def delete | |
text = "Enter the name of the record you want to delete" | |
loop do | |
action, record = input :text => text, | |
:buttons => {:delete => "Delete", :cancel => "Cancel"} | |
break if action == :cancel | |
if record_exist? record | |
delete_record record if dialog :text => "Really delete #{record}?", |
NewerOlder