This file contains 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
ruby-install -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p545/railsexpress/01-fix-make-clean.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p545/railsexpress/02-railsbench-gc.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p545/railsexpress/03-display-more-detailed-stack-trace.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p545/railsexpress/04-fork-support-for-gc-logging.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p545/railsexpress/05-track-live-dataset-size.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p545/railsexpress/06-webrick_204_304_keep_alive_fix.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p545/railsexpress/07-export-a-few-more-symbols-for-ruby-prof.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p545/railsexpress/08-thread-variables.patch -p https://raw |
This file contains 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
begin | |
raise "flunk!" | |
rescue => e | |
puts "Error was #{e.message}" # Error was flunk! | |
puts "Error was #{e}" # Error was flunk! | |
puts "Error was #{e.inspect}" # Error was #<RuntimeError: flunk!> | |
end |
This file contains 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
# based on https://github.com/baweaver/streamable | |
# Toying around with alternatives to nested method calls | |
# i.e. foo(bar(baz)) | |
# and method chaining | |
# i.e. baz.bar.foo | |
def stream(data, *methods) | |
methods.reduce(data) do |d, m| | |
case m |
This file contains 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
def percentile(arr, pcent) | |
sorted = arr.sort | |
# http://en.wikipedia.org/wiki/Percentile#Linear_interpolation_between_closest_ranks | |
percent_ranks = (1..arr.length).map { |i| (100.0 / sorted.length) * ( i - 0.5) } | |
if pcent < percent_ranks.first | |
sorted[0] | |
elsif pcent > percent_ranks.last | |
sorted.last |
This file contains 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 | |
# file: ~/bin/c | |
# | |
# usage: highlight lines and pipe them to stdout in your editor. nothing | |
# changes except they are copied to your paste buffer. should be modified to | |
# work with linux using xclip | |
$VERBOSE=nil | |
STDOUT.sync = true |
This file contains 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
brew install opam libffi libreadline-dev | |
git clone git@github.com:technomancy/grenchman.git grenchman | |
cd grenchman | |
opam init (choose y to update .bash_profile or similar) | |
[open new shell] | |
opam install ocamlfind core async ctypes | |
ocamlbuild -use-ocamlfind -lflags -cclib,-lreadline grench.native | |
ln -s $PWD/grench.native ~/bin/grench | |
grench lein test |
This file contains 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
;; Converts a midje test file into a clojure.test test file | |
;; Adapted from https://github.com/circleci/translate-midje/blob/master/translate_midje.clj | |
;; | |
;; Usage: | |
;; 1. Add [bultitude "0.2.6"] to project.clj | |
;; 2. Load this file into repl | |
;; 3. (require 'circleci.translate-midje) | |
;; 3. (circleci.translate-midje/test-rewrite "test/yourproject/test/foo_test.clj") | |
;; | |
;; It won't do everything perfectly (namely, it doesn't translate the 'provided' macro) |
This file contains 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
;; gorilla-repl.fileformat = 1 | |
;; ** | |
;;; # "SECRETS"* of Clojure development | |
;;; | |
;;; \* one or more tips may not be a secret to you! | |
;;; | |
;;; For months after getting started with Clojure, I understood how to write functions, but not how to **develop programs**. I did have a good grasp of the processes, idioms, and ways to structure larger code bases. As a result, I largely developed programs the same way I did with Ruby: using TDD with lots of implicit state strewn throughout my programs. | |
;;; | |
;;; I'm still learning, but I want to share a few of the key ideas I wish I had known when I first started out. |
This file contains 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 "openssl" | |
require "net/smtp" | |
Net::SMTP.class_eval do | |
private | |
def do_start(helodomain, user, secret, authtype) | |
raise IOError, 'SMTP session already started' if @started | |
check_auth_args user, secret, authtype if user or secret | |
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) } |
This file contains 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
class Foo | |
def bar | |
puts "Hello, world!" | |
end | |
end |
OlderNewer