Skip to content

Instantly share code, notes, and snippets.

View raws's full-sized avatar
🥯
dabbling in pumpernickel

Ross Paffett raws

🥯
dabbling in pumpernickel
View GitHub Profile
proc checkbox {args} {
set choice [expr {int(rand()*[llength $args])}];
for {set i 0} {$i < [llength $args]} {incr i} {
if {$i == $choice} {
lset args $i [format {[x] %s} [lindex $args $i]]
} else {
lset args $i [format {[ ] %s} [lindex $args $i]]
}
};
puts [join $args { }];
proc lo5 {who} {
upvar #0 sender sender;
set blank { };
set prefix [string range $blank 0 [string length $sender(nick)]];
puts "$sender(nick) \\o/ \\o/ $who";
puts "$prefix \\\\_ _//";
puts "$prefix /\\ /\\";
}
@raws
raws / array#pick.rb
Created August 31, 2009 04:22
An instance method for Ruby's Array class which picks a number of elements from the array at random
class Array
# Pick +number+ random elements out of the array. If +number+ is
# greater than the size of the array, this method will simply return
# the array itself, sorted randomly.
def pick(number)
sort_by { rand }.slice(0...number)
end
end
# Global Away.scpt
#
# This Colloquy plugin takes over the "/away" command and sets your away and
# back status for all connections at once.
#
# Version: 1.0 (8 September 2009)
# Author: Ross Paffett (ross@rosspaffett.com)
# License: Distributed under the same terms as Colloquy.
using terms from application "Colloquy"
class CommandsController < ApplicationController
before_filter :authorize, :except => [ :index, :show ]
def index
@commands = Command.all(:order => "name")
end
def new
@command = Command.new(params[:command])
end
exit if ARGV.empty?
require 'timeout'
# Upload files to Hey.
uploaded = Array.new
ARGV.each do |f|
next unless File.exists?(f)
type = case File.extname(f).downcase
when '.jpg', '.jpeg' then 'image/jpeg'
module Wheaties
module Commands
module Channel
def on_join
channel = response.args.first
if response.sender.nick == connection.nick
broadcast(:who, channel)
log(:info, "Joined", channel)
end
module Wheaties
class Connection < EventMachine::Protocols::LineAndTextProtocol
attr_reader :nick, :user, :real, :channels
class << self
def instance
@@instance
end
end
module Wheaties
class User
include Comparable
attr_reader :hostmask, :modes
def initialize(args)
if args.is_a?(Hostmask)
@hostmask = args
@modes = Set.new
result = ["line one"]
result << "line two"
result << "line three"