Skip to content

Instantly share code, notes, and snippets.

View inem's full-sized avatar
🌰
In progress

Ivan Nemytchenko inem

🌰
In progress
View GitHub Profile
# 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
//
// 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;

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
# Newbie Programmer
def factorial(x)
if x == 0
return 1
else
return x * factorial(x - 1)
end
end
puts factorial(6)
puts factorial(0)
@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(" ")
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 / 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
@inem
inem / license
Created January 29, 2010 07:35 — 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 / deploy.rake
Created January 17, 2010 14:16 — forked from Sutto/deploy.rake
namespace :deploy do
def config(key)
(@config ||= YAML.load_file("config/deploy.yml").symbolize_keys)[key.to_sym]
end
# Hooks as needed
task :local_before do
end