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 | |
# Slop version 3 | |
require 'slop' | |
opts = Slop.new do | |
on :n, :name=, 'Your name', matches: /\A[a-zA-Z0-9]+\z/, required: true | |
on :p, :password, 'Your login password' | |
on :debug |
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
object rls { | |
def main(args: Array[String]) { | |
for { | |
file <- (new java.io.File(args(0))).listFiles | |
if file.isFile | |
fname = file.getName | |
if !fname.startsWith(".") | |
} println(fname) | |
} | |
} |
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 'slop' | |
optspec = <<-SPEC | |
ruby foo.rb [options] | |
--- | |
n,name= Set your name | |
a,age= Set your age | |
v,verbose Enable verbose mode | |
debug Enable debug mode | |
SPEC |
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 | |
module Project | |
module OptionAccess | |
class << self | |
attr_accessor :options | |
end | |
self.options ||= {} |
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 | |
module Foo | |
def clear | |
'clearing!' | |
end | |
end | |
something = Object.new | |
something.extend(Foo) |
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 'rack' | |
class Blawg | |
include Kent | |
def index | |
@posts = Post.all | |
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 'net/http' | |
require 'mechanize' | |
text = ARGV or abort "textagon <text>" | |
text = text.join(' ').split('-').map(&:strip).join("\n") | |
client = Mechanize.new | |
client.get('http://textagon.com/create/') do |page| |
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 | |
# STOP DOING THIS | |
items = [ | |
['one', 'foo', 'bar', 'baz'], | |
['two', 'hello', 'there', 'etc'], | |
['three', 'more', 'crap', 'yep'] | |
] |
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 | |
# C'MON | |
id = 4 | |
username = begin | |
if (1..10).include?(id) | |
'admin' | |
elsif id < 15 |
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 | |
# Don't do this, but this is how it works.. | |
def something(object, arg) | |
{ | |
'foo' => proc { |arg| puts "ermm #{arg} .. " }, | |
:foo => proc { |arg| puts "herp #{arg} .. " }, | |
Class => proc { |arg| puts "derp #{arg} .. " }, | |
nil => proc { |arg| puts "nil. #{arg} .. " }, |