Skip to content

Instantly share code, notes, and snippets.

Avatar

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: gist.github.com/gists/269075

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.

Editing

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
{
public:
int data;
Node *next;
View CreditCardNumberGenerator.java
import java.util.Random;
/**
* A credit card number generator.
*
* @author Josef Galea
*/
public class CreditCardNumberGenerator {
private Random random = new Random(System.currentTimeMillis());
@stanzheng
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>
<html>
<head>
<title>Force-Directed Layout</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?1.29.1"></script>
<style type="text/css">
circle {
@stanzheng
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
#/usr/bin/sh
#instructions from https://www.digitalocean.com/community/articles/how-to-install-an-upstream-version-of-node-js-on-ubuntu-12-04
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
http://pastebin.com/zjh0ZyUh
AWS Cheat Sheat
===============
Install
-------
@stanzheng
stanzheng / gist:8489645
Created Jan 18, 2014
center google card
View gist:8489645
<article class="photo">
<img src="https://mirror-api-playground.appspot.com/links/filoli-spring-fling.jpg" style=" width:50%;
height:50%;
background:url(logo.png) center center no-repeat;">
<div class="overlay-gradient-tall-dark"></div>
<section>
<p class="text-auto-size">Spring Fling Fundraiser at Filoli</p>
</section>
</article>