Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mojodna
mojodna / jsonpretty.txt
Created February 20, 2009 19:54 — forked from nicksieger/jsonpretty.txt
nicksieger's jsonpretty example with syntax highlighting
jsonpretty: A command-line JSON pretty-printer.
Get it: gem install jsonpretty
Source: http://github.com/nicksieger/jsonpretty
Example:
$ curl -i http://github.com/api/v1/json/nicksieger | jsonpretty | pygmentize -l js
HTTP/1.1 200 OK
Server: nginx/0.6.26
# ~/.bashrc
# tab-completion for git subcommands
# (this is for git installed via MacPorts: `sudo port install git-core +svn`)
source /opt/local/share/doc/git-core/contrib/completion/git-completion.bash
# git status with a dirty flag
function __git_status_flag {
git_status="$(git status 2> /dev/null)"
remote_pattern="^# Your branch is (.*) of"
@mojodna
mojodna / dnsmasq.conf
Created April 3, 2009 18:54
dhcp for xen
# Configuration file for dnsmasq.
#
# Format is one option per line, legal options are the same
# as the long options legal on the command line. See
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
# The following two options make you a better netizen, since they
# tell dnsmasq to filter out queries which the public DNS cannot
# answer, and which load the servers (especially the root servers)
# uneccessarily. If you have a dial-on-demand link they also stop
@mojodna
mojodna / xen-tools.conf
Created April 3, 2009 18:55
customized xen-tools config (sensible defaults)
##
# /etc/xen-tools/xen-tools.conf
##
#
# This is the global configuration file for the scripts included
# within the xen-tools package.
#
# For more details please see:
#
# http://xen-tools.org/
#!/usr/bin/env ruby -rubygems
require 'oauth'
require 'optparse'
options = {}
option_parser = OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options] <query>"
// accessing application-specific preferences
SharedPreferences prefs = getPreferences(MODE_PRIVATE);
Log.i("prefs", "Preferences: " + prefs.getAll().toString());
Editor editor = prefs.edit();
editor.putString("test", "value");
editor.commit();
# Updating Ruby OAuth Consumers to 1.0a
In response to April's [OAuth Security Advisory](http://oauth.net/advisories/2009-1), the OAuth community has penned a [new draft of the specification](http://oauth.googlecode.com/svn/spec/core/1.0a/drafts/3/oauth-core-1_0a.html), titled 1.0a (currently in draft 3). This makes a number of changes to the flow:
1. providing an `oauth_callback` is now part of the Request Token stage (if the client cannot accept callbacks, the value MUST be _oob_)
2. `oauth_callback_confirmed` MUST be present (and _true_) when the SP issues a Request Token to the client
3. an `oauth_verifier` parameter is provided to the callback URL (or displayed if no callback URL was configured) and MUST be included when exchanging the Request Token for an Access Token
Code that once looked like this:
sqlite> .schema tracks
CREATE TABLE tracks (_id INTEGER PRIMARY KEY AUTOINCREMENT, name STRING, description STRING, category STRING, startid INTEGER, stopid INTEGER, starttime INTEGER, stoptime INTEGER, numpoints INTEGER, totaldistance FLOAT, totaltime INTEGER, movingtime INTEGER, minlat INTEGER, maxlat INTEGER, minlon INTEGER, maxlon INTEGER, avgspeed FLOAT, avgmovingspeed FLOAT, maxspeed FLOAT, minelevation FLOAT, maxelevation FLOAT, elevationgain FLOAT, mingrade FLOAT, maxgrade FLOAT, mapid STRING);
sqlite> .schema trackpoints
CREATE TABLE trackpoints (_id INTEGER PRIMARY KEY AUTOINCREMENT, trackid INTEGER, longitude INTEGER, latitude INTEGER, time INTEGER, elevation FLOAT, accuracy FLOAT, speed FLOAT, bearing FLOAT);
sqlite> .schema waypoints
CREATE TABLE waypoints (_id INTEGER PRIMARY KEY AUTOINCREMENT, name STRING, description STRING, category STRING, icon STRING, trackid INTEGER, type INTEGER, length FLOAT, duration INTEGER, starttime INTEGER, startid INTEGER, stopid INTEGER, longitude INTEGER, latit
from TileCache.Layer import Layer, Tile
Tile(Layer("foo", spherical_mercator=True, tms_type="google"), 607, 754, 11).bounds()
# y values are inverted
# nik2img.py tilecache/osm.xml mercator.png --srs 900913 -e -8159805.6428374983 5283327.3949249983 -8140237.7635999992 5263759.5156874992 -v -d 256 256
EM.run {
# ... other EM stuff ...
Thin::Server.start {
run Sinatra.application
}
}