Skip to content

Instantly share code, notes, and snippets.

View Miserlou's full-sized avatar

Rich Jones Miserlou

View GitHub Profile
@Miserlou
Miserlou / gist:1294412
Created October 18, 2011 01:41
Posting JSON in Python without Requests Library
1 import urllib2
2 import json
221 def basic_authorization(user, password):
222 s = user + ":" + password
223 return "Basic " + s.encode("base64").rstrip()
224
225 def submit_pull_request(user, repo):
226 auth = (settings.username, settings.password)
227 url = 'https://api.github.com/repos/' + user + '/' + repo + '/pulls'
@Miserlou
Miserlou / gist:1407812
Created November 30, 2011 03:09
Google Analytics Example
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
@Miserlou
Miserlou / etcinit.dhttp-proxy.sh
Created January 12, 2012 04:11
/etc/init.d/http-proxy
#!/bin/bash
DIR=/var/www/YOUR_APP_NAME
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NODE_PATH=/usr/local/lib/node_modules
case $1 in
start)
nohup "node" "$DIR/proxy.js" 1>>"$DIR/logs/proxy.log" 2>&1 &
echo $! > "$DIR/pids/proxy.pid";
;;
@Miserlou
Miserlou / proxy.js
Created January 12, 2012 04:14
proxy.js
/*
node-http-proxy
with websockets from socketio
*/
var util = require('util'),
colors = require('colors'),
websocket = require('../../vendor/websocket'),
httpProxy = require('../../lib/node-http-proxy');
@Miserlou
Miserlou / etc init.d nodeapp.sh
Created January 12, 2012 04:22
/etc/init.d/nodeapp
#!/bin/bash
DIR=/var/www/YOUR_NODE_APP_GOES_HERE
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NODE_PATH=/usr/local/lib/node_modules
NODE=/usr/local/bin/node
test -x $NODE || exit 0
function start_app {
NODE_ENV=production nohup "$NODE" "$DIR/YOUR_APP_SERVER_FILE.js" 1>>"$DIR/logs/YOUR_APP_NAME.log" 2>&1 &
@Miserlou
Miserlou / Monit Node.sh
Created January 12, 2012 04:29
Monit Node
#!monit
set logfile /var/log/monit.log
check process nodejs with pidfile "/var/www/NODEAPP/YOUR_APP.pid"
start program = "/etc/init.d/node_app start"
stop program = "/etc/init.d/node_app stop"
if failed port 8080 protocol HTTP
request /
with timeout 10 seconds
then restart
@Miserlou
Miserlou / blackout.html
Created January 12, 2012 08:08
SOPA Blackout Script
<script type="text/javascript" src="https://github.com/Miserlou/Blaccupy/raw/master/blaccupy.js"></script>
@Miserlou
Miserlou / blackout.html
Created January 12, 2012 08:10
SOPA Blackout Script
<script type="text/javascript" src="https://github.com/Miserlou/Blaccupy/raw/master/blaccupy.js"></script>
"iPhone developer needed for amazing new application. Send me your resume."