Skip to content

Instantly share code, notes, and snippets.

@ghoseb
ghoseb / factorial.py
Created November 14, 2008 18:58
The evolution of a Python Programmer
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
@MyArtChannel
MyArtChannel / development.rb
Created April 25, 2011 20:42
Use Pry as IRB replacement in rails 3 console
# Add this to the end of your development.rb and add
#
# gem 'pry'
#
# to your Gemfile and run bundle to install.
silence_warnings do
begin
require 'pry'
IRB = Pry
@napcs
napcs / README.md
Created May 6, 2011 04:10
Deploying Rails to Linode

Deploying Rails to Linode

Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com here.

Initial setup

@schleg
schleg / 01. Gemfile
Created May 26, 2011 17:26
Setup for Devise + Omniauth
gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'
@shazron
shazron / gist:1009688
Created June 6, 2011 03:27
NativeControls PhoneGap example
window.plugins.nativeControls.createTabBar();
window.plugins.nativeControls.createTabBarItem("home-tab", "Home", "home-icon", {
onSelect: function() {
alert("home");
}
});
window.plugins.nativeControls.showTabBar({position:"bottom"});
window.plugins.nativeControls.showTabBarItems("home-tab");
@postnati
postnati / gist:1075624
Created July 11, 2011 09:51
PhoneGap Watchr
watch /src\/.*\.haml/ do |md| `thor convert:haml` end
watch /src\/.*\.rb/ do |md| `thor convert:haml` end
watch /src\/.*\.scss/ do |md| `thor convert:sass` end
watch /src\/.*\.sass/ do |md| `thor convert:sass` end
watch /src\/.*\.coffee/ do |md| `thor convert:coffee` end
@jasonmorganson
jasonmorganson / Node.build-system
Created July 18, 2011 13:48
Node build "system" for Sublime Text 2
{
"cmd": ["killall node >> /dev/null; node ${file}"],
"selector": "source.javascript",
"path": "/usr/bin",
"shell": true
}
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@liesen
liesen / SpotifyViewsDemo.html
Created December 1, 2011 16:38
Spotify Apps API example
<!DOCTYPE html>
<html>
<head>
<title>API</title>
<link rel="stylesheet" href="sp://import/css/adam.css">
<style>
body {
-webkit-box-orient: vertical;
display: -webkit-box;