Skip to content

Instantly share code, notes, and snippets.

View leejarvis's full-sized avatar

Lee Jarvis leejarvis

View GitHub Profile
#!/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
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)
}
}
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
#!/usr/bin/env ruby
module Project
module OptionAccess
class << self
attr_accessor :options
end
self.options ||= {}
#!/usr/bin/env ruby
module Foo
def clear
'clearing!'
end
end
something = Object.new
something.extend(Foo)
#!/usr/bin/env ruby
require 'rack'
class Blawg
include Kent
def index
@posts = Post.all
end
#!/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|
#!/usr/bin/env ruby
# STOP DOING THIS
items = [
['one', 'foo', 'bar', 'baz'],
['two', 'hello', 'there', 'etc'],
['three', 'more', 'crap', 'yep']
]
@leejarvis
leejarvis / blah
Created September 20, 2011 22:14
#!/usr/bin/env ruby
# C'MON
id = 4
username = begin
if (1..10).include?(id)
'admin'
elsif id < 15
@leejarvis
leejarvis / blah
Created September 20, 2011 00:31
#!/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} .. " },