Skip to content

Instantly share code, notes, and snippets.

View lemonlatte's full-sized avatar

Jim Yeh lemonlatte

  • Taipei, Taiwan
  • 12:08 (UTC +08:00)
View GitHub Profile
@lemonlatte
lemonlatte / gist:4230356
Created December 7, 2012 02:55
virt-install ubuntu 12.04 precise with XEN
qemu-img create -f qcow2 /var/lib/xen/images/node1.img 10G
virt-install --connect xen:/// \
--arch=x86_64 \
--accelerate \
--name node1 \
--ram=512 \
--vcpus=1 \
--os-type=Linux \
--os-variant=ubuntuprecise \
MongoDB upstart scripts for Ubuntu.
Run following commands after installing upstart scripts:
ln -s /lib/init/upstart-job /etc/init.d/mongoconf
ln -s /lib/init/upstart-job /etc/init.d/mongodb
ln -s /lib/init/upstart-job /etc/init.d/mongos
To start services use:
# Stolen from http://paste.pocoo.org/show/224441/
from pymongo.cursor import Cursor
from pymongo.connection import Connection
from pymongo.errors import AutoReconnect
from time import sleep
def reconnect(f):
def f_retry(*args, **kwargs):
### Import of the Python Rados library classes
### https://github.com/ceph/ceph/blob/master/src/pybind/rados.py
from rados import Rados,ObjectIterator
### Initialize Rados class
cluster = Rados()
### /etc/ceph/ceph.conf file is readen
cluster.conf_read_file()
print "Configuration file successfully loaded [OK]"
### Connection to the RADOS cluster
var myApp = angular.module('myApp').config(function($httpProvider) {
$httpProvider.defaults.headers.post['X-CSRFToken'] = $('input[name=csrfmiddlewaretoken]').val();
});
from gevent import monkey; monkey.patch_all()
import gevent
import gevent.greenlet
from functools import partial
from random import random
import urllib
import urllib2
def on_exception(fun, greenlet):
$.ajax({
url: "/static/js/test.ipa",
xhrFields: {
onprogress: function(e) {
if (e.lengthComputable) {
console.log("Loaded " + Number( (e.loaded / e.total * 100)) + "%");
}
else {
console.log("Length not computable.");
}
# -*- coding: utf-8 -*-
import encodings.utf_8
import math
import urllib, urllib2
import random
import re
from xml.dom import minidom
from LevenshteinDistance import LevenshteinDistance
from grabber import LyricProviderBase
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"

Port Forwarding in Mavericks


Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

####1. anchor file Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like: