Skip to content

Instantly share code, notes, and snippets.

View qwo's full-sized avatar

Stanley Zheng qwo

View GitHub Profile

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

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
#include <iostream>
using namespace std;
class Node
{
public:
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());
@qwo
qwo / gist:6046460
Last active December 20, 2015 01:08
Multiplication table using vectors with C++
// 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
*/
@qwo
qwo / The while loop that could
Last active December 20, 2015 21:38
Evil Confusing Gist
#include <iostream>
int main(int argc, char** argv)
{
int x = 10;
while ( x-->0) // x goes to 0
{
std::cout << x << "\n";
}
}
/* output is
@qwo
qwo / index.html
Created November 4, 2013 20:39 — forked from mbostock/.block
<!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 {
@qwo
qwo / gist:7724448
Last active June 15, 2016 21:39
Install Node and NPM on Precise 64 12.04 LTS from source. Other uses, use binary
#/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
@qwo
qwo / gist:8080432
Created December 22, 2013 09:53
homebrew ec2
#copy pasted from this pastebin
http://pastebin.com/zjh0ZyUh
AWS Cheat Sheat
===============
Install
-------
@qwo
qwo / gist:8489645
Created January 18, 2014 12:14
center google card
<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>