Skip to content

Instantly share code, notes, and snippets.

View inem's full-sized avatar

Ivan Nemytchenko inem

View GitHub Profile
@inem
inem / license
Created January 29, 2010 09:30 — forked from defunkt/license
#!/bin/sh -e
# Usage: license
# Prints an MIT license appropriate for totin' around.
#
# $ license > COPYING
#!/bin/sh
echo "Copyright (c) `date +%Y` Chris Wanstrath
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@inem
inem / license
Created January 29, 2010 09:30 — forked from defunkt/license
#!/bin/sh -e
# Usage: license
# Prints an MIT license appropriate for totin' around.
#
# $ license > COPYING
#!/bin/sh
echo "Copyright (c) `date +%Y` Chris Wanstrath
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
var A_reduce = [].reduce;
Array.prototype.reduce = function reduce (callback, initialValue) {
var operator = callback;
return typeof operator == 'string' && /^[ +*/%-><!&|^?,.]/.test(operator)
? eval(this.join(operator))
: A_reduce.apply(this, arguments)
};
[1,2,3,4].reduce('+') // 10
[1,2,3,4].reduce('*') // 24
@inem
inem / to_sh.rb
Created February 10, 2010 06:37 — forked from nex3/to_sh.rb
require 'parse_tree'
require 'ruby2ruby'
require 'parse_tree_extensions'
require 'shellwords'
class Proc
def to_sh
ruby = `which ruby`.strip
command = Shellwords.shellescape(to_ruby.gsub(/\Aproc \{(.*)\}\Z/m, '\1').strip)
paths = $LOAD_PATH.map {|p| Shellwords.shellescape("-I" + p)}.join(" ")
# Newbie Programmer
def factorial(x)
if x == 0
return 1
else
return x * factorial(x - 1)
end
end
puts factorial(6)
puts factorial(0)

Rails Dev Stack on Snow Leopard

(from a scratch install). Kinda, I imported my user home (~) from a Time Machine backup.

Homebrew

sudo mkdir /usr/local
sudo chown -R `whoami` /usr/local
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
//
// JS Prompt - a Talker plugin <http://talkerapp.com>
//
// to activate/deactivate the js prompt: /prompt
// to share variables amongst users: this.foo = 1;
//
plugin.usage = '/prompt';
plugin.command = 'prompt';
plugin.evalMode = false;
# generate random sequence
#SecureRandom also has methods for: base64, hex, bytes, random_number
#see: http://api.rubyonrails.org/classes/ActiveSupport/SecureRandom.html
require 'active_support/secure_random'
ActiveSupport::SecureRandom.hex(16)
# outputs: 6dc19d21e958e04645cddadb96e9c927
@inem
inem / _maps.sass
Created March 18, 2010 05:38 — forked from Sutto/_maps.sass
.gmap.map-preview
:width 540px
:height 400px
:margin 5px auto
:border 5px solid #DDD
:background #F1F1F1 url('/images/map-placeholder.jpg') center center no-repeat
@inem
inem / .irbrc.rb
Created April 6, 2010 09:01 — forked from dekart/.irbrc.rb
# Put this content to ~/.irbrc file (no extension)
require "rubygems"
begin
require "ap"
rescue LoadError => err
puts "Cannot find awesome_print gem. Please run 'gem install awesome_print' to install it."
end