Skip to content

Instantly share code, notes, and snippets.

@newacct
newacct / rfc4231.js
Created February 3, 2011 07:09 — forked from cjc/rfc4231.js
var crypto = require("crypto"),
assert = require("assert");
var hexstr2bytearray = function(str) {
var bytestrs = [];
for(var i=0;i<str.length;i+=2) {
bytestrs.push(parseInt(str.substr(i,2), 16));
}
return bytestrs;
}
def colour_shade(colour,shade,scale=10)
# default the scale to 100 if it is greater...
scale = 100 if scale > 100
# if the shade is out of the range of scale then reset shade to scale...
if shade > 0
shade = scale if shade > scale
else
shade = scale * -1 if shade < scale * -1
end
@newacct
newacct / find_mac.rb
Created February 3, 2011 07:02 — forked from rkh/find_mac.rb
require "rubygems"
require "snmp"
mac = ARGV.shift.dup
unless mac.gsub! /^(..)[-: ]?(..)[-: ]?(..)[-: ]?(..)[-: ]?(..)[-: ]?(..)[-: ]?$/, '\1 \2 \3 \4 \5 \6'
puts "illegal mac"
exit
end
mac = mac.split(" ").collect { |x| x.hex }.join "."
Then /^I should be editing "([^\"]*)"$/ do |login|
URI.parse(current_url).path.should == edit_user_path(User.find_by_login(login))
end
Then /^I should be viewing "([^\"]*)"$/ do |login|
URI.parse(current_url).path.should == user_path(User.find_by_login(login))
end