Skip to content

Instantly share code, notes, and snippets.

// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@sriprasanna
sriprasanna / test_nothing.rb
Created October 22, 2012 19:49
How to test a ruby method that does nothing
require "rubygems"
require "rspec"
class TestNothing
def do_nothing
end
def return_nil
nil
end

Sample Project

Starting from:

lein new foo
cd foo

Say I have a random JAR file that is not available in any repository:

touch README.md

sudo apt-get update
sudo apt-get install --yes apt-file && apt-file update
sudo apt-get install --yes python-software-properties
sudo apt-add-repository --yes ppa:longsleep/couchdb
sudo apt-get update
sudo apt-get --purge --yes remove libcurl3
sudo apt-get clean
sudo apt-get --print-uris --yes install libcurl3 couchdb imagemagick openjdk-7-jdk ruby1.8 thin openssh-server rubygems1.8 libxslt-dev libxml2-dev libzip2 libzip-dev build-essential | grep ^\' | cut -d\' -f2 > dependencies.txt
mkdir debs && cd debs
wget -nc -i ../dependencies.txt
@sriprasanna
sriprasanna / gist:2465475
Created April 22, 2012 17:24
Reddit ranking algorithm in Ruby
#!/Users/dustyeike/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
require "rubygems"
require "test/unit"
require "date"
EPOCH = Date.new(1970, 1, 1)
#
# Returns the number of seconds from the epoch to date
def epoch_seconds date
@sriprasanna
sriprasanna / game-of-life.md
Last active April 14, 2021 09:12
Kata - Game of life

Conway's Game of Life - Challenge

The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.

Gospers Glider gun

The game is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves. It is Turing complete and can simulate a universal constructor or any other Turing machine.

Source : Wikipedia

{
"Parameters": {
"inputName": {
"Type": "String",
"MinLength": 1
}
},
"Outputs": {
"outputName": {
"Value": {