Skip to content

Instantly share code, notes, and snippets.

View will's full-sized avatar
🆒
ه҈ͣفͤ҈ͥ҉ͦ҈ͧ҉ͨ҈ͩ҉ͪ҈ͫ҉ͬ҈ͭ҉ͮ҈ͯ҉ͨ҈ͬ҉ͧ҈ͣ҉ͨ҈ͧ҉ͯ҈ͮ҉ͭ҈ͤ҉ͦ҈ͥ҉ͧ҈ͩ҉ͭ҈ͨ҉ͣ҈ͪ҉ͧ҈ͭ҉ͩ҈ͤ҉ͮ҈ͯ҉ͬ҈

Will Leinweber will

🆒
ه҈ͣفͤ҈ͥ҉ͦ҈ͧ҉ͨ҈ͩ҉ͪ҈ͫ҉ͬ҈ͭ҉ͮ҈ͯ҉ͨ҈ͬ҉ͧ҈ͣ҉ͨ҈ͧ҉ͯ҈ͮ҉ͭ҈ͤ҉ͦ҈ͥ҉ͧ҈ͩ҉ͭ҈ͨ҉ͣ҈ͪ҉ͧ҈ͭ҉ͩ҈ͤ҉ͮ҈ͯ҉ͬ҈
View GitHub Profile
require "benchmark"
STR = "8675309".cstr
lib LibC
fun atoi(str : UInt8*) : Int32
end
def crystal
@will
will / a.md
Last active August 29, 2015 14:23
5 Rails CVEs
@will
will / dsort.cr
Last active August 29, 2015 14:25 — forked from glurp/dsort.cr
final comparaison between libc.qsort, qsort and dsort in crystal
################################ Crystall scripts
def chrono(text)
s=Time.now
yield
e=Time.now
d=(e.to_f-s.to_f)*1000
if d>1
puts "#{text} : #{d} ms"
else
@will
will / results
Last active August 29, 2015 14:28
more postgres time benchmarks
/tmp ➤ crystal build timebm.cr --release
/tmp ➤ ./timebm
2015-05-01 20:10:01 UTC
2015-05-01 20:10:01 UTC
2015-05-01 20:10:01 UTC
text 18636833.84 (± 1002412.33) 10.69× slower
binary span 60320068.97 (± 4530921.68) 3.30× slower
binary int 199241301.90 (± 17951824.75) fastest
def method_stack
@method_stack ||= []
end
def method_missing(sym, *args)
method_stack << [sym, args]
self
end
#!/usr/bin/env ruby
# datamapper woes
# Case one: adding an object to an association using << blows up
# Case two: setting an association with a new array doesn't clear
# out the old one, it just combines them
# output:
# line 49: post.tags << t1 # => #<DataMapper::Associations::ImmutableAssociationError: You can not modify this association>
# line 74: book.authors == [ a1 ] # => true
#!/usr/bin/ruby
require "rubygems"
require "scrapi"
url =
"https://ui2web1.apps.uillinois.edu/BANPROD1/bwckschd.p_disp_detail_sched?term_in=120091&crn_in=43437"
seats = Scraper.define do
array :numbers
process "td.dddefault", :numbers=>:text
# will leinweber's lib/helpers.rb for webby
def first_post
all_posts.first
end
def next_post(post)
all_posts[ all_posts.rindex(post) - 1 ]
end
@will
will / response.txt
Created February 20, 2009 22:21 — forked from jseifer/gist:67727
On Feb 20, 2009, at 4:24 PM, "Olusegun A.A" <xxxxxx@gmail.com> wrote:
** CRAIGSLIST ADVISORY --- AVOID SCAMS BY DEALING LOCALLY
** Avoid: wiring money, cross-border deals, work-at-home
** Beware: cashier checks, money orders, escrow, shipping
** More Info: http://www.craigslist.org/about/scams.html
Hello,
Do you still have this item available for sale at the moment? Get back asap.
# so ugly, but it makes rails treat CouchRest::Documents correctly
class Hash
class << self
alias :old_trip_equal :===
def ===(other)
return false if other.class.ancestors.include?(CouchRest::Document)
old_trip_equal other
end
end