Skip to content

Instantly share code, notes, and snippets.

require "mechanize"
a = Mechanize.new
loop do
d=a.get("http://www.tickets.london2012.com/browse?form=search&tab=oly&sport=8199&event&venue=loc_2&fromDate&toDate&morning=1&afternoon=1&evening=1&show_available_events=1")
if d.body =~ /Woman's/
loop do
`growlnotify -m "Woomenz valleyballz tickets naow" -t "NAOW! "` # -s if you wanna to have it sticky
`afplay /System/Library/Sounds/Purr.aiff`
#osx
λ gcc -o main main.c
λ ./main
-32
32
0
require("timeout")
t=Thread.new(codeStr) do |code|
$SAFE=4
Timeout::timeout(5) {eval code} rescue nil
end
httperf --uri=/ --port=3000 --server=localhost --num-conns=20 --num-calls=1000
httperf --client=0/1 --server=localhost --port=3000 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=20 --num-calls=1000
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 1
Total: connections 20 requests 20000 replies 20000 test-duration 20.457 s
Connection rate: 1.0 conn/s (1022.8 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 972.1 avg 1022.8 max 1142.0 median 1017.5 stddev 41.6
Connection time [ms]: connect 0.2
RSpec::Matchers.define :be_a_multiple_of do |expected|
match do |actual|
actual % expected == 0
end
end
require 'rubygems'
require 'randexp'
prefix = "DAWID"
regexp = /\d\w\d\w/
size = 10
results = (1..size).map{|i| "#{prefix}#{regexp.gen}" }
foo(_, []) -> []
foo(F, [H | T]) -> foo(F(H), T)
bar(X) ->
case X of
ok -> fire_bomb()
_ -> crack_error()
end
moo() ->
@JakubOboza
JakubOboza / mech.rb
Created May 16, 2012 15:54
one line google search
require 'mechanize'; Mechanize.new.get('http://google.com/') do |p|; sr = p.form_with(:name => 'f') do |s|; s.q = ARGV[0]; end.submit; sr.links.each do |l|; puts l.text + ":" + l.href; end; end;
@JakubOboza
JakubOboza / gist:2710870
Created May 16, 2012 14:43
config DSL example
class Icinga
@@config = {}
def self.config(&block)
self.instance_eval &block
end
def self.cmd_file(file_path)
@@config[:file_path] = file_path
App.Collections.EntriesList = Backbone.Collection.extend({
model: App.Models.Entry
});