Skip to content

Instantly share code, notes, and snippets.

View neilmock's full-sized avatar

Neil Mock neilmock

View GitHub Profile
require "stateful"
class Folder < ActiveRecord::Base
include Stateful
# ...
stateful do
state :active
state :inactive
@neilmock
neilmock / gist:825842
Created February 14, 2011 13:04
roulette!
(ns roulette.core)
(defn spin []
(int (rand 38)))
(def *bankroll* (atom 1000))
(defn dobet
[bets]
(let [winner (spin)]
EMACS = [
1,
2,
3,
]
EVERYONE_ELSE = [
1,
2,
3,
@neilmock
neilmock / hack
Created August 7, 2010 23:07 — forked from ymendel/hack
#!/bin/sh
BRANCHES=`git branch`
if [ $? != 0 ]; then
exit
fi
GIT_SVN=0
git branch -r | grep 'git-svn' > /dev/null
if [ $? = 0 ]; then
GIT_SVN=1
from redis import Redis
r = Redis()
r.publish("greeting", "Neil")

Python

Python is an interpreted, dynamically typed, object-oriented programming language. It is open-source, and was originally released in 1991 by Guido van Rossum.

Language Overview

Here's a sample Python method to get started with syntax:

Ruby

Ruby is a dynamic, truly object-oriented language (everything is an object) that is also influenced in many ways from concepts found in functional programming. It open source, and was first released in 1995 by Yukihiro “matz” Matsumoto. The most current version is 1.9.1.

Language Overview

Here's a sample Ruby method to get started with syntax:

#!/bin/bash
sudo su -
#
# Audio: fix ubuntu 9.04 broken sound
#
apt-get install build-essential xmlto libncurses5-dev
export ALSA="1.0.20"
;; pass in a vector, get a querystring
(defn build-querystring [params]
(let [qpairs (map #(str-join "=" (str %)) params)]
(apply str (interpose "&" qpairs))))
(defn blah1 [& params] (apply hash-map params))
(defn blah2 [& params] (blah1 params))
;; user> (blah1)
;; {}
;; user> (blah2)
;; No value supplied for key: null
;; [Thrown class java.lang.IllegalArgumentException]