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
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]} | |
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
#!/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 |
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 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> |
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 'isaac' | |
config do |c| | |
c.nick = "Awesome_Isaac" | |
c.server = "irc.freenode.net" | |
c.port = 6667 | |
end | |
on :connect do | |
join "#Awesome_Channel" |
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
http://github.com/ichverstehe/soma/tree/master |
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
# 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 | |
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
incoming do | |
play "hello-world" | |
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
# 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' |
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 '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" |
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 '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| |