Skip to content
View DBHelper.java
package com.example.test;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public final class DBHelper extends SQLiteOpenHelper {
public static final String TAG = "DbAdapter";
public static final String DATABASE_FILE_NAME = "test.db";
View Util.java
package com.example.test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.json.JSONArray;
import android.util.Log;
View oauth_util.rb
require 'rubygems'
require 'oauth'
require 'awesome_print'
require 'uri'
# Usage:
# 1) Get consumer key/secret from https://dev.twitter.com/apps
# 2) Run ruby oauth_util.rb https://api.twitter.com/statuses/home_timeline.json
# 3) Authorize as instructed
# 4) $$$
View config.ru
require 'router'
use Rack::Static, :urls => ['/css', '/js'], :root => "static"
run Router.new
View index.html
<!DOCTYPE html>
<html>
<body>
<a href="/edit/1" class="js-nav">edit</a><br/>
<a href="/1" class="js-nav">1</a><br/>
<a href="/" class="js-nav">default</a><br/>
<a href="#" class="create">create</a>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
var views = {};
View debug.sh
# A collection of web server debug utils
# Described in http://erikeldridge.com/blog/unix
# Inspired by the work of @Pufferfish
apache_access_log=/var/log/apache2/access_log
rails_root=/usr/local/project
rails_prod_log=$rails_root/log/production.log
function tail_apache_access_log() {
tail -f $apache_access_log
View app_init.sh
echo -e "\n$0: Creating project\n"
app_name=`heroku apps:create | ruby -e 'ARGF.read =~ /([\w-]+)\.herokuapp/; puts $1'`
git clone git@heroku.com:$app_name.git
cd $app_name
echo -e "\n$0: Creating .rvmrc\n"
echo "rvm ruby-1.8.7-p330" > .rvmrc
rvm rvmrc load
View gist:1005906
/**
* @param {number} toothCount is the number of teeth in the barracuda's mouth (required)
* @param {number} weight is the weight of the barracuda
* @param {number} length is the length of the barracuda
*/
function barracuda(toothCount, weight, length){
//...
}
View log1.js
/**
* Cross-browser logging utils
*
* This fn differs from something like the jQuery log plugin in that
* it returns console.log, if avail, instead of calling it. This allows
* us to call it in file with the log statement, which means that the
* line # and file name displayed are more helpful. This isn't supposed
* to be a logging framework like blackbird or log4javascript.
*
* Usage: var msg = 'foo'; log(msg).call(console, msg)
View toolkit.markdown

Tips & Tools

Ack

  • Use less for paging, but still provide ack's nice colored output and per-file grouping, by adding this to .ackrc: --pager=less -r -E

JS

  • inheritance patterns: prototypal/classical/pseudo-classical/hacked-classical/functional
  • class frameworks:
Something went wrong with that request. Please try again.