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
# for when I acccidentally try to val foo = bar something. | |
def val x | |
x | |
end | |
val foo = 1 + 2 | |
puts "#{foo}" # ==> 3 | |
# Yeah, just jam that into Kernel like everybody else. why not? |
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
;;; positional partial for giggles | |
;;; use #(foo %1 %2) instead | |
(defn- placeholder-indices | |
([template] | |
(placeholder-indices '_ template)) | |
([placeholder-sym template] | |
(->> template | |
(map vector (range)) | |
(filter (comp (partial = placeholder-sym) last)) |
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
(ns trace | |
(:use clojure.pprint)) | |
(def *ignore* | |
'#{def quote var try fn* monitor-enter monitor-exit}) | |
(defmulti trace-special-form (fn [form] (first form))) | |
(defn- trace-bindings [bindings] | |
(vec (apply concat |
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
(defn serial-processor | |
"Given BlockingQueue q, returns a map of two functions, :process and :stop. | |
:process takes a constant function (presumably for side effects) and | |
adds it to the queue, where it is invoked serially with respect to | |
other functions added via :process. | |
:stop takes a non-function value to return, blocks on the completion | |
of remaining process functions, and returns the value." | |
[^java.util.concurrent.BlockingQueue q] |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
# Capture stdout and stderr in a named file (while still writing to current stdout and stderr) for a block then restore old behaviour | |
def capture_output(file) | |
read, write = IO.pipe | |
pid = fork | |
unless pid | |
write.close | |
$stdin.reopen(read) |
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 ruby19 | |
# | |
ses = %w{ | |
/stornext/snfs1/next-gen/solid/results/solid0301/0301_20091103_1_SP/AWG_TCGA_GBM_02_T_000sA_01003244545_1/results.F1B1 | |
/stornext/snfs1/next-gen/solid/results/solid0301/0301_20091103_1_SP/AWG_TCGA_GBM_02_T_000sA_01003244545_2/results.F1B1 | |
/stornext/snfs1/next-gen/solid/results/solid0301/0301_20091103_1_SP/ANG_HSAP_NG_003sA_01003244545_3/results.F1B1 | |
/stornext/snfs1/next-gen/solid/results/solid0301/0301_20091103_1_SP/ANG_HSAP_NG_003sA_01003244545_4/results.F1B1 | |
/stornext/snfs4/next-gen/solid/results/solid0446/0446_20091125_1_SL/AWG_TCGA_OVA_01_T_000sA_01003244597_1/results.F1B1 | |
} |
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/ruby | |
RLSP_VERSION = "1.4.1" | |
class Lambda | |
attr_accessor :args, :body | |
def initialize(args=[],body="") | |
@args = (args.class == Array) ? args : [args] | |
@body = body | |
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
raise 'Must run as root' if Process.euid != 0 | |
p1 = Process.fork { | |
# p1 is now running independent of, and parallel to the calling process | |
Process.setsid | |
p2 = Process.fork { | |
# p2 is now running independent of, and parallel to p1 | |
$0 = 'mydaemon' | |
pidfile = File.new('/var/run/mydaemon.pid', 'w') | |
pidfile.chmod( 0644 ) | |
pidfile.puts "#{Process.pid}" |
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 | |
# | |
# forking supervisor - forks workers and replaces dead workers. | |
# start it in one console, send signals to it from another console. | |
# | |
require 'rubygems' | |
require 'daemons/daemonize' | |