Skip to content

Instantly share code, notes, and snippets.

View balinterdi's full-sized avatar
👌
Enjoying life, including work.

Balint Erdi balinterdi

👌
Enjoying life, including work.
View GitHub Profile
@balinterdi
balinterdi / group_by_reducers.clj
Created December 7, 2012 09:15
Implement group-by with reducers
(ns group-by-reducers.core
(:require [clojure.core.reducers :as r :only [fold reduce map]])
(:require [criterium.core :as c]))
(defn group-by-naive [f coll]
(reduce
(fn [groups a]
(assoc groups (f a) (conj (get groups a []) a)))
{}
coll))
@balinterdi
balinterdi / rails_startup_times
Created November 22, 2012 14:56
Rails startup times
# 1.9.3-p194-perf - GC tweaks
✓ ~/code/sspinc/cartman » time bundle exec rake environment
bundle exec rake environment 5.16s user 1.60s system 95% cpu 7.067 total
✓ ~/code/sspinc/cartman » time bundle exec rake environment
bundle exec rake environment 5.23s user 1.57s system 95% cpu 7.113 total
# 1.9.3-p194-perf - No GC tweaks
✓ ~/code/sspinc/cartman » time bundle exec rake environment
bundle exec rake environment 6.60s user 1.44s system 98% cpu 8.157 total
» time bundle exec rake environment
@balinterdi
balinterdi / ruby_call_class.rb
Created November 5, 2012 16:00
New syntax for calling Class objects in Ruby
# encoding: utf-8
class Greeter
def self.call(language)
new(language)
end
def initialize(language)
@language = language
end
@balinterdi
balinterdi / .gitignore
Created November 3, 2012 21:39
Solutions to the 4clojure.com problems
repl-port
@balinterdi
balinterdi / subset_sum.clj
Created August 15, 2012 11:56
Subset sum
(def sum-of-pos-elements (memoize (fn [xs] (apply + (filter #(>= % 0) xs)))))
(def sum-of-neg-elements (memoize (fn [xs] (apply + (filter #(< % 0) xs)))))
(defn subset-sum
"Returns the indexes of elements in xs whose sum is s"
([xs s]
(subset-sum xs (dec (count xs)) s))
([xs i s]
"Returns the indexes of elements x0...xi (in xs) whose sum is s"
(let [sol (subset-sum xs i s [])]
@balinterdi
balinterdi / clj
Created July 19, 2012 17:28
my current Clojure repl launcher
#!/bin/sh
clj_base="${HOME}/code/clojure";
java -cp .:${clj_base}/lib/jline-0.9.94.jar:${clj_base}/clojure/target/clojure-1.5.0-master-SNAPSHOT.jar:${clj_base}/criterium-0.2.2-SNAPSHOT-standalone.jar:${clj_base}/clojurescript jline.ConsoleRunner clojure.main "$@"
render partial: 'avatar', locals: { mood: 'depressed' } # works fine
render 'avatar', locals: { mood: 'depressed' } # undefined local variable or method 'mood' (in the partial)
diff --git a/src/MacVim/mvim b/src/MacVim/mvim
index 653cf78..5e6b0d7 100755
--- a/src/MacVim/mvim
+++ b/src/MacVim/mvim
@@ -13,6 +13,11 @@
# or by un-commenting and editing the following line:
# VIM_APP_DIR=/Applications
+tabs=true
+if [ "$1" = "-f" ]; then
require 'forwardable'
class X
def foo
puts "foo!"
end
alias_method :bar, :foo
end
class Y < X