Skip to content

Instantly share code, notes, and snippets.

View jaychoo's full-sized avatar
☢️

Jay Choo jaychoo

☢️
  • New York, NY
View GitHub Profile
var http = require('http');
function fibonacci(n) {
if (n < 2)
return 1;
else
return fibonacci(n-2) + fibonacci(n-1);
}
http.createServer(function (req, res) {
import SocketServer
import SimpleHTTPServer
PORT = 1339
def fibonacci (n):
if n < 2:
return 1
else:
return fibonacci(n - 2) + fibonacci(n - 1)
@t-mart
t-mart / setup.ubuntu.solarize.sh
Created October 12, 2011 03:24
Set up Ubuntu for Solarize
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_background" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "#070736364242:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#EEEEE8E8D5D5:#00002B2B3636:#CBCB4B4B1616:#58586E6E7575:#65657B7B8383:#838394949696:#6C6C7171C4C4:#9393A1A1A1A1:#FDFDF6F6E3E3"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "#00002B2B3636"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "#65657B7B8383"
@Gunio
Gunio / Parsing JSON in python
Created October 18, 2011 05:25
Parsing JSON in python
import requests
import simplejson
r = requests.get('https://github.com/timeline.json')
c = r.content
j = simplejson.loads(c)
for item in j:
print item['repository']['name']
@Gunio
Gunio / Parsing HTML in Python
Created October 18, 2011 18:33
Parsing HTML in Python with LXML
import requests
import lxml
from lxml import html
r = requests.get('http://gun.io')
tree = lxml.html.fromstring(r.content)
elements = tree.get_element_by_id('frontsubtext')
for el in elements:
print el.text_content()
@Gunio
Gunio / Simple Django View Response
Created October 18, 2011 19:11
Simple Django View Response
from django.shortcuts import render_to_response
def home(request, input="No input supplied"):
output = input.upper()
return render_to_response('home.html', {'output': output})
@Gunio
Gunio / Django Relative Template Directory
Created October 18, 2011 19:25
Django Relative Template Directory
import os
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)
@Gunio
Gunio / Simple Django URLs
Created October 18, 2011 20:02
Simple Django URLs
from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('',
url(r'^(?P<input>[^/]+)$', 'UppercaseMaker.upper.views.home'),
)
@methane
methane / gist:2185380
Created March 24, 2012 17:28
Tornado Example: Delegating an blocking task to a worker thread pool from an asynchronous request handler
from time import sleep
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application, asynchronous, RequestHandler
from multiprocessing.pool import ThreadPool
_workers = ThreadPool(10)
def run_background(func, callback, args=(), kwds={}):
def _callback(result):
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 5, 2026 11:33
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname