Skip to content

Instantly share code, notes, and snippets.

View xrd's full-sized avatar
🎯
Focusing

Chris Dawson xrd

🎯
Focusing
View GitHub Profile
var pg = require('pg');
var sys = require( 'sys' );
var cs = "postgres://blarg:blarg@localhost/blarg-upload-development";
try {
pg.connect( cs, function( err, client ) {
var filename = "foobar";
var directoryId = 12345;
try {
client.query("INSERT INTO uploads(filename, directory_id) VALUES($1, $2)", [filename, directoryId]);
Started POST "/events/253/invite" for 64.134.224.28 at Wed Mar 23 16:44:33 +0000 2011
ActionController::RoutingError (No route matches "/events/253/invite"):
woven@woven-staging:~/Outreach/live-manager$ rake routes | grep invite
invite_event POST /events/:id/invite(.:format) {:action=>"invite", :controller=>"events"}
woven@woven-staging:~/Outreach/live-manager$ ls app/controllers/events_controller.rb
app/controllers/events_controller.rb
woven@woven-staging:~/Outreach/live-manager$ grep "def invite" app/controllers/events_controller.rb
def invite
@xrd
xrd / gist:955618
Created May 4, 2011 17:27
Angular+Sencha Experiment
<!doctype html>
<html xmlns:ng="http://angularjs.org" xmlns:sencha="http://sencha.com">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
<script src="http://vivoh.com/sencha/sencha-touch.js" ng:autobind></script>
<link href="http://vivoh.com/sencha/resources/css/sencha-touch.css" rel="styleshet" type="text/css"/>
<script src="http://code.angularjs.org/angular-0.9.15.min.js" ng:autobind></script>
<script type="text/javascript">
<Sencha:Application name="MyApp">
<Sencha:Panel fullscreen="true" html="Hello World!">
<Sencha:Panel>
</Sencha:Application>
python prettyqr.py foo.png
/home/oem/Tixfu/qr/lib/prettyqr/prettyqr/logos.py:34: Warning: 'with' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
File "prettyqr.py", line 5, in <module>
from prettyqr.logos import clear_logo_space, get_svg_logo
File "/home/oem/Tixfu/qr/lib/prettyqr/prettyqr/logos.py", line 34
with open(filename) as logo_svg:
python ./prettyqr.py --options "Some text or url" foo.png
/home/oem/Tixfu/qr/lib/prettyqr/prettyqr/logos.py:34: Warning: 'with' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
File "./prettyqr.py", line 5, in <module>
from prettyqr.logos import clear_logo_space, get_svg_logo
File "/home/oem/Tixfu/qr/lib/prettyqr/prettyqr/logos.py", line 34
with open(filename) as logo_svg:
@xrd
xrd / gist:1040286
Created June 22, 2011 15:06
Monit for Wowza
We couldn’t find that file to show.
public void jrAuthenticationDidSucceedForUser(JRDictionary authInfo,
String provider) {
// {stat=ok, profile={googleUserId=123456, name={givenName=Chris, familyName=Dawson, formatted=Chris Dawson}, [email protected], displayName=zoinks, preferredUsername=zoinks, url=https://www.google.com/profiles/123456, providerName=Google, identifier=https://www.google.com/profiles/123456, [email protected]}}
String status = authInfo.getAsString( "stat" );
if( 0 == status.compareTo("ok") ) {
email = authInfo.getAsDictionary("profile").getAsString( "email");
showNotAssociatedView();
}
else {
showError( "Unable to login");
@xrd
xrd / Activity.java
Created August 3, 2011 19:56
JREngage callback
public void jrAuthenticationDidReachTokenUrl(String tokenUrl,
HttpResponseHeaders response,
String tokenUrlPayload,
String provider) {
String cookies = response.getHeaderField("Set-Cookie");
sessionToken = cookies;
}
public void onActivityResult( int requestCode, int resultCode, Intent intent ) {
RestClient client = new RestClient(SERVICE_URL);
(ns foobar.core
(:use [compojure.core :only (GET POST defroutes)]]
(:require (compojure handler route)
[ring.util.response :as response]
[ring.adapter.jetty :as jetty]))
(defonce mapping (ref {}))
(defonce counter (atom 0 ))