Skip to content

Instantly share code, notes, and snippets.

View jlongster's full-sized avatar
💭
Workin on my app

James Long jlongster

💭
Workin on my app
View GitHub Profile
sdfsdf sdfsd f
dsfsdfdsf
### Parsing
import sys
import uuid
import os
import subprocess
from os.path import join
from send import send_files
#define READ_BYTES(var, type) \
do { \
var = 0; \
type n; \
int count = sizeof(type); \
int last_bit = (count-1)*8; \
int i; \
\
fread(&n, sizeof(type), 1, f); \
@jlongster
jlongster / gist:804336
Created January 31, 2011 16:46
unicode printing
## test.py
key = u"things"
val = u"幾內亞比索"
print u"%s: %s" % (key, val)
## test2.py
from contextlib import closing
#!/bin/sh
exec 2>&1
root="/sites/dev.mozilla.james.local"
master_dir="$root/master"
branch_dir="$root/branches"
if ! [ -d "$master_dir" ]; then
echo "master repo not available" && exit 1
@jlongster
jlongster / mac_paste.zsh
Created September 9, 2011 16:26
ZLE widget for pasting on OSX
#!/bin/zsh
# Implements pasting at the terminal level on OS X
function mac_paste () {
left=$BUFFER[0,CURSOR]
right=$BUFFER[$((CURSOR+1)),${#BUFFER}]
content=`pbpaste`
BUFFER="$left$content$right"
CURSOR=$((${#left}+${#content}))
@jlongster
jlongster / gist:1237914
Created September 23, 2011 17:12
pulse client
var amqp = require('amqp');
var conn = amqp.createConnection({host: 'pulse.mozilla.org',
login: 'public',
password: 'public'});
conn.on('error', function(e) {
console.log('error: ' + e);
});
@jlongster
jlongster / gist:1245398
Created September 27, 2011 15:34
PHP MADNESS
$url_parts = explode('/', trim($_SERVER['REDIRECT_URL'], '/'));
if ($url_parts[0] != $lang) {
// Bug 619404 Quickly redirect homepage
if ($_SERVER['REQUEST_URI'] == '/') {
$_SERVER['REQUEST_URI'] = '/firefox/';
}
$parsed_url = parse_url($_SERVER['REQUEST_URI']);
// This matches both / and /firefox because of the above code
@jlongster
jlongster / gist:1288142
Created October 14, 2011 20:00
Bugzilla jsonrpc
function jsonrpc(user, method, params, http_method, cont) {
if(_.isFunction(http_method)) {
cont = http_method;
http_method = 'GET';
}
var request;
var opts = {
@jlongster
jlongster / gist:1576001
Created January 7, 2012 20:51
Beginning of Outlet compiler in Outlet (compiles to js and lua)
(require (reader "./ext/Parser")
(util "util")
(ast "./ast")
(grammar "./grammar"))
;; util
(define (assert v msg)
(if (not v)
(throw msg)))