Skip to content

Instantly share code, notes, and snippets.

View vangberg's full-sized avatar

Harry Vangberg vangberg

View GitHub Profile
h = {:a => [1,2,3], :b => [1,2,3]}
h.each do |k,v|
v.shift
v.each do |n|
p n
end
end
=> {:a=>[2, 3], :b=>[2, 3]}
@vangberg
vangberg / todo
Created September 7, 2008 19:37
Best To-Do List. Ever.
#!/bin/sh
# Best To-Do List. Ever.
#
# Usage:
# 1. Add a new item to list: `todo This needs to be fixed`
# 2. Edit the to-do list: `todo -e`
# 3. Show the current to-do's: `todo`
if [[ $1 ]]; then
if [ $1 = "-e" ]; then
class K
def foo(&b)
instance_eval &b
p bar
end
end
k = K.new
k.foo { bar = "smoking, subtle form of suicide" }
=> NameError: undefined local variable or method `bar' for #<C:0xb7f04260>
require 'isaac'
config do |c|
c.nick = "Awesome_Isaac"
c.server = "irc.freenode.net"
c.port = 6667
end
on :connect do
join "#Awesome_Channel"
http://github.com/ichverstehe/soma/tree/master
# The simplest thing that could possibly work. Will probably overwrite files if someone uploads
# a file that has the same file name as an already uploaded file. Requires the columns 'size' and
# 'content_type', see the 'store_file' method. You could obviously just remove those calls
# if you don't want to store the file size and the content type in the database.
#
# If you need a fancy name (in the spirit of 'paperclip' and 'attachment_fu'), you can call this code
# 'fucking_simple_fu' so that you can refer to this code and look like a cool kid on teh block.
class Attachment < ActiveRecord::Base
after_create :store_file
incoming do
play "hello-world"
end
# Grass.new takes two arguments: 1. a dataset consisting of an array of arrays:
#
# [["Label", 10], ["Second label", 78]]
#
# the second argument is optional, and should be a hash of desired options:
#
# :width - specify a CSS width, e.g. '100px' or '70%'
# :height - specify a CSS height, e.g. '200px' or '60%'
# :color - color of the bars, e.g. '#224488'
# :text_color - color of label when placed inside a bar, e.g. '#DDDDDD'
require 'socket'
server = "irc.freenode.net"
channel = "#awesome_channel"
s = TCPSocket.open("irc.freenode.net", 6667)
s.puts "NICK simplebot"
s.puts "USER simple simple simple :simple"
s.puts "JOIN #{channel}"
s.puts "PRIVMSG #{channel} :foo bar"
require 'rubygems'
require 'addressable/uri'
require 'socket'
class IRC
def self.shoot(uri, options={}, &block)
raise ArgumentError unless block_given?
uri = Addressable::URI.parse(uri)
irc = new(uri.host, uri.port, options.delete(:as)) do |irc|