Skip to content

Instantly share code, notes, and snippets.


Stanley Zheng stanzheng

View GitHub Profile
View README.rdoc

Rails 2.3.5 on App Engine (DataMapper)

Do not use rvm (or install and run from JRuby). The google-appengine gem must install into your system MRI. The appengine-sdk gem includes a complete Java app server. We bootstrap Java from MRI, then your app runs inside a servlet container (with access to all the APIs) using the version of JRuby installed into each app.

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.x calls to rubygems, and now we have it working. Rails 2.3.x currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

See the TInyDS version also:

Install the Development Environment

View gist:5185170

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.


Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+ insert line after
View gist:5355138
#include <iostream>
using namespace std;
class Node
int data;
Node *next;
import java.util.Random;
* A credit card number generator.
* @author Josef Galea
public class CreditCardNumberGenerator {
private Random random = new Random(System.currentTimeMillis());
stanzheng / gist:6046460
Last active Dec 20, 2015
Multiplication table using vectors with C++
View gist:6046460
// multiplication table
// enter two dimensions and the factor
// 3 3 would be a 3x4 grid multiplication grid
1 2 3 4
2 4 6 8
3 6 9 12
View The while loop that could
#include <iostream>
int main(int argc, char** argv)
int x = 10;
while ( x-->0) // x goes to 0
std::cout << x << "\n";
/* output is
View index.html
<!DOCTYPE html>
<title>Force-Directed Layout</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<style type="text/css">
circle {
stanzheng / gist:7724448
Last active Jun 15, 2016
Install Node and NPM on Precise 64 12.04 LTS from source. Other uses, use binary
View gist:7724448
#instructions from
sudo apt-get -y update
sudo apt-get -y install build-essential
sudo apt-get -y install curl
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
View gist:8080432
#copy pasted from this pastebin
AWS Cheat Sheat
stanzheng / gist:8489645
Created Jan 18, 2014
center google card
View gist:8489645
<article class="photo">
<img src="" style=" width:50%;
background:url(logo.png) center center no-repeat;">
<div class="overlay-gradient-tall-dark"></div>
<p class="text-auto-size">Spring Fling Fundraiser at Filoli</p>