Skip to content

Instantly share code, notes, and snippets.

class Company
def zipcode
Zipcode.parse(get_attribute(:zipcode), self.country)
end
end
# example zipcode interface
class Zipcode
def self.parse(zipcode, country)
Object.const_get("Zipcode::#{country.upcase}").new(zipcode)
[jzellman@fozzie ~]$ ping -c 20 steadfast.net
PING steadfast.net (67.202.100.2): 56 data bytes
64 bytes from 67.202.100.2: icmp_seq=0 ttl=55 time=15.890 ms
64 bytes from 67.202.100.2: icmp_seq=1 ttl=55 time=14.084 ms
64 bytes from 67.202.100.2: icmp_seq=2 ttl=55 time=11.348 ms
64 bytes from 67.202.100.2: icmp_seq=3 ttl=55 time=12.152 ms
64 bytes from 67.202.100.2: icmp_seq=4 ttl=55 time=13.201 ms
64 bytes from 67.202.100.2: icmp_seq=5 ttl=55 time=12.352 ms
64 bytes from 67.202.100.2: icmp_seq=6 ttl=55 time=13.464 ms
64 bytes from 67.202.100.2: icmp_seq=7 ttl=55 time=11.204 ms
from sauce import application, get, post, delete, put, urls
import web
@get("/")
def index():
return "Hello from /6"
@get("/login")
def login():
raise web.seeother("/")
"""
Simple preforking echo server in Python.
Python port of http://tomayko.com/writings/unicorn-is-unix.
"""
import os
import sys
import socket
class ApplicationController < ActionController::Base
def rescue_action(exception)
# Why do I need the :: in front of ActionController?
if exception.is_a? ::ActionController::UnknownAction
redirect_to :controller => "account", :action => "login"
else
...
end
end
end
<h1>Listing people</h1>
<table>
<tr>
<th><%= sorted_people_url("First name", "first_name") -%></th>
<th><%= sorted_people_url("Last name", "last_name") -%></th>
<th><%= sorted_people_url("Personal Email", "email") -%></th>
<th><%= sorted_people_url("Age", "age") -%></th>
</tr>
class IncomingTicketHandler
require 'rubygems'
require 'tmail'
def self.receive(email)
ticket = Ticket.new
ticket.title = email.subject
ticket.body = email.body
ticket.assignedTo = email.to
ticket.creator = email.from
#installing sqlite3-ruby on FreeBSD 8 with custom ruby install
gem install sqlite3-ruby -- --with-sqlite3-include=/usr/local/include/ --with-sqlite3-lib=/usr/local/lib
function current_branch(){
BR=$(git symbolic-ref HEAD 2>/dev/null | awk -F/ '{ print "<" $3 ">" } ') || { echo "$@" ; exit ; }
echo " $BR"
}
export PS1='\[\e[32;1m\]\u@\h \[\e[34;1m\]\w\[\e[36;1m\]$(current_branch)\[\e[0;30m\]\[\e[0m\]$ '
#!/usr/bin/env ruby
# save as vuln2csv and run
# ./vuln2csv < infile.txt > outfile.csv
require 'rubygems'
require 'fastercsv'
class CVERow
def initialize(line)
# not assuming " is text delimiter