Skip to content

Instantly share code, notes, and snippets.

View arnaudsj's full-sized avatar

Sébastien Arnaud arnaudsj

View GitHub Profile
Ruby 1.8.6 w/o C extension
==========================
user system total real
single object inserts: 3.450000 0.160000 3.610000 ( 3.779446)
multiple object insert: 2.190000 0.020000 2.210000 ( 2.223418)
find_one: 0.070000 0.000000 0.070000 ( 0.087103)
Ruby 1.8.6 w/ C extension
=========================
user system total real
#!/usr/bin/env python2.6
# -*- coding: utf-8 -*-
"""
Code snippet that shows how to convert a utf-8 encoded string to an XML decimal entity string
"""
from xml.sax import saxutils
import codecs
if __name__ == "__main__":
#!/usr/bin/env python
#
# Jamie Kirkpatrick, November 2009. <jkp@kirkconsulting.co.uk>
# Released under the BSD license.
#
"""
Experimental code to add asyncronous functionality to WSGI applications
running under the Tornado webserver. Uses greenlet to spin micro-threads
which can be suspended and resumed within a single thread as required.
import logging
import random
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@arnaudsj
arnaudsj / phonegap-sc.rb
Created November 28, 2010 03:00 — forked from wagenet/phonegap-sc.rb
PhoneGap with SproutCore
#######################
#### DOCUMENTATION ####
#######################
#
# Run as:
#
# ruby phonegap-sc.rb APP_NAME
# ruby phonegap-sc.rb APP_NAME PROJECT_PATH
# ruby phonegap-sc.rb APP_NAME PROJECT_PATH OUTPUT_PATH
#
@arnaudsj
arnaudsj / Couchapp command for TextMate
Created January 10, 2011 01:03
Add this as a command of a new bundle and set a shortcut (I use command+P)
if [ -f "${TM_PROJECT_DIRECTORY}/.couchapprc" ]; then
/usr/local/Cellar/python/2.7/bin/couchapp push
fi
@arnaudsj
arnaudsj / gist:1004483
Created June 2, 2011 13:57
Titanium SDK 1.7.0.RC1 updated build script for universal build with simulator type passed
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Build and Launch iPhone Application in Simulator or install
# the application on the device via iTunes
#
import os, sys, uuid, subprocess, shutil, signal, string, traceback, imp
import platform, time, re, run, glob, codecs, hashlib, datetime, plistlib
from compiler import Compiler
@arnaudsj
arnaudsj / r.py
Created August 10, 2012 03:30
starCluster R plugin for doRedis implementation
from starcluster.clustersetup import ClusterSetup
from starcluster.logger import log
class doRedis(ClusterSetup):
def __init__(self):
pass
def run(self, nodes, master, user, user_shell, volumes):
redis_master_ip = master.private_ip_address
command = """su - arnaudsj -c "nohup R --slave -e 'require(multicore);require(doRedis);startLocalWorkers(n=multicore:::detectCores(),host=\\\"%s\\\",queue=\\\"jobs\\\", port=6379)' > /dev/null 2>&1 &" """ % redis_master_ip
@arnaudsj
arnaudsj / lein-wtf.sh
Created March 19, 2014 02:24
When things seem to go south in your Clojure projects... (would have saved me hours today...)
#!/bin/bash
rm -Rf ~/.m2
rm -Rf ~/.lein
rm -Rf ./target
lein self-install
lein clean
lein version