This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
START = 1 | |
FINISH = 1_000_000 | |
HALF = FINISH / 2 | |
Benchmark.ips do |x| | |
x.report('lazy') do | |
(START..FINISH).lazy.include?(HALF) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pointless implementation of cal(1). | |
# | |
# Author :: Jon-Michael Deldin <[email protected]> | |
# Date :: 2011-06-27 | |
# | |
class Calendar | |
# width of calendar in spaces | |
WIDTH = 20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
Cart = Struct.new(:items) | |
N = 10_000 | |
query = -> { Array.new(N).map { |a| Cart.new(%w(foo bar baz)) } } | |
Benchmark.ips do |x| | |
x.report('each') do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun jm/fix-sql-case (start end) | |
"Uppercase SQL keywords" | |
(interactive "r") | |
(save-restriction | |
(narrow-to-region start end) | |
(goto-char 1) | |
(let ((case-fold-search nil)) | |
(while (search-forward-regexp | |
(mapconcat 'downcase (mapcar 'symbol-name '(select from inner outer left join where and in group by into on)) "\\|") | |
nil t) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% gem install perftools.rb | |
% CPUPROFILE_REALTIME=1 CPUPROFILE_METHODS=1 CPUPROFILE=/tmp/profile RUBYOPT="-r`gem which perftools | tail -1`" ruby /tmp/z.rb && pprof.rb --pdf /tmp/profile > /tmp/profile.pdf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# | |
# Find really old code. | |
# | |
# Author: Jon-Michael Deldin | |
# Date: 2013-12-13 | |
# | |
# Usage: | |
# oldies [DIR] | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function()%7Bvar table%3D%24(%27.faults%27)%3Bvar f%3Dfunction(tr)%7Breturn parseInt(%24(tr).find(%27.count%27).text().trim())%3B%7D%3Bvar thead%3Dtable.find(%27tr:first%27)%3Bthead.remove()%3Btable.html(table.find(%27tr%27).sort(function(x,y)%7Breturn f(x)<f(y)%3F1:f(x)>f(y)%3F-1:0%3B%7D))%3Btable.prepend(thead)%3B%7D)()%3B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aspell list < $(find . -name '*.md') | sort | tr '[A-Z]' '[a-z]' | uniq -c | sort -rn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Jon-Michael Deldin | |
## Pattern Recognition | |
## Edge Detection | |
## Spring 2013 | |
## | |
## | |
## USAGE | |
## ------ | |
## Rscript edges.R | |
## |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rehearsal ---------------------------------------------------------------- | |
array: rotating and dropping 0.050000 0.000000 0.050000 ( 0.055791) | |
set: difference 8.480000 0.020000 8.500000 ( 8.500697) | |
set: dup and delete 8.890000 0.020000 8.910000 ( 8.908871) | |
------------------------------------------------------ total: 17.460000sec | |
user system total real | |
array: rotating and dropping 0.060000 0.000000 0.060000 ( 0.056425) | |
set: difference 8.830000 0.010000 8.840000 ( 8.842558) | |
set: dup and delete 8.940000 0.030000 8.970000 ( 8.969234) |