Skip to content

Instantly share code, notes, and snippets.

View aemkei's full-sized avatar

Martin Kleppe aemkei

View GitHub Profile
function memoizer(memo, fundamental) {
var shell = function (n) {
var result = memo[n];
if (typeof result !== 'number') {
result = fundamental(shell, n);
memo[n] = result;
}
return result;
};
return shell;
function schedule(functions, context){
setTimeout(function(){
var process = functions.shift();
process.call(context);
if (functions.length > 0){
setTimeout(arguments.callee, 100);
}
}, 100);
$ ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d\ -f2
alias ip="ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d\ -f2"
@aemkei
aemkei / Selenuim for Rails 2.2
Created April 21, 2009 16:36 — forked from ubilabs/Selenuim for Rails 2.2
Selenium for Rails 2.2
# Install Selenium as a plugin:
script/plugin install http://svn.openqa.org/svn/selenium-on-rails/stable/selenium-on-rails/
# Copy configuration file:
cp vendor/plugins/selenium-on-rails/selenium.yml.example config/selenium.yml
# Be sure to setup your browsers. Add this to run Firefox with a clean profile:
# /Applications/Firefox.app/Contents/MacOS/firefox-bin -P selenium
# Optional: Install ThoughtBot Shoulda gem:
# show a colores list of all your commits
alias timelog='git log --pretty=format:"%Cgreen%ad%Creset: %s%d" --date=local --author=YOUR_NAME_HERE --since="1 weeks ago"'
@aemkei
aemkei / export_png_8_with_alpha.textile
Created May 19, 2009 15:53
Export PNG8 With Alpha

Choose your colors:

  • Open original file in Photoshop
  • Select relevant areas (“Marquee”)
  • Choose: Selection > Save Selection…
  • Enter name eg: “Colors” and hit “Save”

Remove transparent areas:

  • Select layer alpha (“CMD+Click” on layer)
# replace 123 with you line number
git blame --porcelain -L123,123 folder/file.ext | grep summary
# replace 123 with line number
git blame --porcelain -L123,123 folder/file.ext | grep summary
git clone git://github.com/dchelimsky/rspec.git
cd rspec
git checkout 1.1.8
rake gem
rake install_gem
@aemkei
aemkei / PastryKit.js
Created December 16, 2009 11:17 — forked from collin/gist:257557
PastryKit - Apple iPhone Webdev Library
const PKSupportsTouches = ("createTouch" in document);
const PKStartEvent = PKSupportsTouches ? "touchstart" : "mousedown";
const PKMoveEvent = PKSupportsTouches ? "touchmove" : "mousemove";
const PKEndEvent = PKSupportsTouches ? "touchend" : "mouseup";
function PKUtils() {}
PKUtils.assetsPath = "";
PKUtils.t = function (b, a) {
return "translate3d(" + b + "px, " + a + "px, 0)"
};