Skip to content

Instantly share code, notes, and snippets.

View calvinchengx's full-sized avatar
:octocat:
Focusing

Calvin Cheng calvinchengx

:octocat:
Focusing
View GitHub Profile
@calvinchengx
calvinchengx / gist:3231775
Created August 2, 2012 00:11
pip install numpy in virtualenv - mac osx
calvin$ mkvirtualenv -p python2.7 --no-site-packages senatus2
Running virtualenv with interpreter /opt/local/bin/python2.7
The --no-site-packages flag is deprecated; it is now the default behavior.
New python executable in senatus2/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /Users/calvin/.virtualenvs/senatus2/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/calvin/.virtualenvs/senatus2/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/calvin/.virtualenvs/senatus2/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/calvin/.virtualenvs/senatus2/bin/postactivate
@calvinchengx
calvinchengx / gist:3231884
Created August 2, 2012 00:25
sudo port -v install g95
Jeans-MacBook-Air.local ttys005 Thu Aug 02 08:24:11 |~|
calvin$ sudo port -v install g95
---> Computing dependencies for g95..
---> Dependencies to be installed: libtool
---> Fetching archive for libtool
---> libtool-2.4.2_2.darwin_11.x86_64.tbz2 doesn't seem to exist in /opt/local/var/macports/incoming/verified
---> Attempting to fetch libtool-2.4.2_2.darwin_11.x86_64.tbz2 from http://packages.macports.org/libtool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 512k 100 512k 0 0 75202 0 0:00:06 0:00:06 --:--:-- 94992
@calvinchengx
calvinchengx / gist:3987171
Created October 31, 2012 13:59
pseudo code for js level map projection transform
// Google.v3 uses EPSG:900913 as projection, so we have to
// transform our coordinates
mapProjection = map.getProjectionObject()
map.setCenter(new OpenLayers.LonLat(map_center_lon, map_center_lat).transform(defaultProjection, mapProjection), map_zoom)
@calvinchengx
calvinchengx / pyrefactors.py
Created November 14, 2012 02:53 — forked from geeknam/pyrefactors.py
Python refactors
"""
Use setattr
"""
# Normal
item.price = self.request['price']
item.quantity = self.request['quantity']
item.shipping = self.request['shipping']
item.save()
@calvinchengx
calvinchengx / gist:4212645
Created December 5, 2012 05:35
new project
cd ~/work
mkvirtualenv -p python2.7 --no-site-packages --distribute pythonio
pip install -e git+git://github.com/django/django.git#egg=django
django-admin.py startproject pythonio
cd pythonio
git init
git remote add origin ssh://[email protected]/pythonio/pythonio.git
#include <string>
struct World
{
void set(std::string msg) { mMsg = msg; }
std::string greet() { return mMsg; }
std::string mMsg;
};
#include <boost/python.hpp>
@calvinchengx
calvinchengx / gist:4950345
Created February 14, 2013 03:18
yeoman experiments
cd ~
mkdir ~/work/yeoman-test
nodeenv yeoman-test
source yeoman-test/bin/activate
cd ~/work/yeoman-test
npm install -g yeoman
yeoman init angular
[?] Would you like to include Twitter Bootstrap? (Y/n) Y
[?] If so, would you like to use Twitter Bootstrap for Compass (as opposed to vanilla CSS)? (Y/n) n
package main
import (
"labix.org/v2/mgo"
"html/template"
"net/http"
"log"
"./signup"
)
package main
import (
"net/http"
)
func sign(w http.ResponseWriter, req *http.Request) {
if req.Method != "POST" {
http.NotFound(w, req)
import sys
import gevent
from gevent import monkey
monkey.patch_all()
import grequests
import urllib2