Skip to content

Instantly share code, notes, and snippets.

View avescodes's full-sized avatar

Avery Quinn avescodes

View GitHub Profile
drwxr-sr-x 172 root csstaff 4096 Aug 17 17:13 .
drwxr-sr-x 6 root csstaff 4096 Dec 13 2007 ..
drwxr-sr-x 7 aalab csstaff 4096 Mar 8 2007 aalab
drwxr-sr-x 10 action csstaff 4096 Jul 9 2003 action
drwxr-xr-x 12 amarsh csstaff 4096 Oct 5 15:14 amarsh
drwxr-sr-x 36 arnason csstaff 4096 Jun 9 16:13 arnason
drwxr-sr-x 30 bate csstaff 4096 Aug 5 13:43 bate
drwxr-xr-x 27 ckemke csstaff 4096 Oct 7 13:48 ckemke
drwxr-sr-x 14 comp1020 csstaff 4096 Jul 8 2002 comp1020
drwxr-sr-x 18 comp1270 csstaff 4096 Apr 1 2009 comp1270
#!/usr/bin/env ruby
# Open up the String class and give it an alpha? check
class String
def alpha?
self =~ /^[A-Za-z]$/
end
end
# Run across each alpha character in string and tally letter occurances
# This returns something like [ 1, 2, <24 0's>] for "ABB"
A B C D E
A
B 16
C 15 4
D 8 7 8
E 10 3 6 11
SBox = Hash[ (0..15).to_a.zip( %w[E 2 1 3 D 9 0 6 F 4 5 A 8 C 7 B].map {|n| n.to_i(16)}) ]
# Find all pairs x and x* in delta(x')
def delta_x(xor)
(0..15).map {|x|[x, (0..15).select { |x_star| x ^ x_star == xor }[0]] }
end
# Let's also make iterating over every index [x,y] easier...
class Array
def each_xy
#!/usr/bin/env ruby
filename = ARGV.shift
lines = []
File.open(filename, 'r') do |f| # open file for update
lines = f.readlines # read into array of lines
lines.each do |it| # modify lines
it.gsub!(/;.*/, '')
end
end
#!/usr/bin/env ruby
require 'rubygems'
require 'active_resource'
the_day_before_yesterday = (Date.today.cwday == 1 ? 4 : 2).days.ago.strftime("%b %d %Y")
puts `cd ~/panda && git log --color --author="$GIT_AUTHOR_NAME" --after="#{the_day_before_yesterday}"`
def three_amigos_please
0.upto(128) do |i|
0.upto(128) do |j|
0.upto(128) do |k|
if i != j and j != k and i != k
yield ("0"*128).split('').map {|n| [i,j,k].include?(n) ? "1" : "0" }.join('')
end
end
end
end
def register_for_muc_callbacks(client)
params = {:muc => client}
client.on_join {|time,nick| respond_to(:join, params.merge!(:time=>time,:nick=>nick))}
client.on_leave {|time,nick| respond_to(:leave, params.merge!(:time=>time,:nick=>nick))}
client.on_message {|time,nick,text| respond_to(:message, params.merge!(:time=>time,:nick=>nick,:text=>text))}
client.on_private_message {|time,nick,text| respond_to(:private_message, params.merge!(:time=>time,:nick=>nick,:text=>text))}
client.on_room_message {|time,text| respond_to(:room_message, params.merge!(:time => time, :text => text))}
client.on_self_leave {|time| respond_to(:self_leave, params.merge!(:time => time)) }
client.on_subject {|time,nick,subject| respond_to(:subject, params.merge!(:time => time, :nick => nickname, :subject => subject))}
end
Botfly.login(jabber_id,pass) do
on.message.nick(/Jim/).some_matcher(condition) do
# do actual message response, includes access to message contents, nick, time sent
end
join("omg_awesome_room").as(resource) do
on.join.room_status(/something/) do
# Likewise, but now we are in the context of a multi-user chat
# No shitting you, the way I'm building it you could literally spawn another room join, add a new responder, or even create an entirely new bot.
end
end
// ==UserScript==
// @name Scrumworks Story Text Fix
// @namespace http://cdebiz005:8080/
// @description Darken that fricken text up
// @include http://cdebiz005:8080/*
// // ==/UserScript==
(function () {
// Some JS I stole from the internet
function addGlobalStyle(css) {