Skip to content

Instantly share code, notes, and snippets.

View actsasbuffoon's full-sized avatar

Michael Tomer actsasbuffoon

  • Maestro
  • Boston, MA
View GitHub Profile
@actsasbuffoon
actsasbuffoon / drop.rb
Created October 4, 2011 20:00
Simple game made with Ruby-Processing
# Drop
class Player
attr_accessor :health, :x, :y, :width, :height
def initialize(args = {})
args.each_pair {|k, v| send "#{k}=", v}
end
@actsasbuffoon
actsasbuffoon / drop.rb
Created October 4, 2011 19:51
Simple game made with Ruby-Processing
# Drop
class Player
attr_accessor :health, :x, :y, :width, :height
def initialize(args = {})
args.each_pair {|k, v| send "#{k}=", v}
end
@actsasbuffoon
actsasbuffoon / maze.rb
Created October 4, 2011 19:50
Maze generator inspired by Jamis Buck's presentation on algorithms
# Attempt1
require 'rubygems'
Gem.clear_paths
ENV['GEM_HOME'] = `echo $GEM_HOME`
ENV['GEM_PATH'] = `echo $GEM_PATH`
require 'awesome_print'
class Array
def random
self[rand length]
@actsasbuffoon
actsasbuffoon / csv_date_irb.rb
Created March 19, 2011 17:24
A strange issue with Date and the CSV stdlib.
ruby-1.9.2-p180 :001 > require 'Date'
=> true
# The date parses as it should.
ruby-1.9.2-p180 :002 > Date.parse '1/2/1903'
=> #<Date: 1903-02-01 (4832293/2,0,2299161)>
# Requiring the CSV stdlib causes a whole mess of conflicts with Date.
ruby-1.9.2-p180 :003 > require 'csv'
/Users/michaeltomer/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/date.rb:236: warning: already initialized constant MONTHNAMES
@actsasbuffoon
actsasbuffoon / simple_editor.js
Created January 31, 2011 20:25
A very simple jQuery based textarea editor
// This is shamelessly copied from http://stackoverflow.com/questions/263743/how-to-get-cursor-position-in-textarea#answer-3373056
function getInputSelection(el) {
var start = 0, end = 0, normalizedValue, range, textInputRange, len, endRange;
if (typeof el.selectionStart == "number" && typeof el.selectionEnd == "number") {
start = el.selectionStart;
end = el.selectionEnd;
}
else {
range = document.selection.createRange();
if (range && range.parentElement() == el) {
$('input[type=submit]').each(function(i, eo) {
var btn, cls, elem, icon, text;
elem = $(eo);
text = elem.attr('value');
cls = elem.attr('class');
if (/icon_(.+)/i.test(cls)) {
icon = cls.replace(/^icon_/, '');
elem.after(("<a href='javascript:void(0)' class='button'><img alt='icon' class='icon' src='/images/icons/" + (icon) + ".png' />" + (text) + "</a>"));
btn = elem.next();
btn.click(function(b) {
$('input[type=submit]').each (i, eo) ->
elem = $(eo)
text = elem.attr 'value'
cls = elem.attr('class')
if /icon_(.+)/i.test(cls)
icon = cls.replace(/^icon_/, '')
elem.after "<a href='javascript:void(0)' class='button'><img alt='icon' class='icon' src='/images/icons/#{icon}.png' />#{text}</a>"
btn = elem.next()
btn.click (b) ->
elem.click()
require 'rubygems'
require 'mongo'
def rand_string(ary, len = 16)
r = []
len.times {r << ary[rand ary.length]}
r.join("")
end
class PeriodicUpdater
require 'rubygems'
require 'metaid'
class Video
attr_reader :unreachable
def initialize
@unreachable = 'cant read this'
end
def aireplay(essid,iface)
system("aireplay-ng -3 -e #{essid} #{iface}")
end
def airmon(iface,channel)
system ("airmon-ng start #{iface} #{channel}")
end
def airodump(iface)
system("airodump-ng --ivs #{iface}")