Skip to content

Instantly share code, notes, and snippets.

Avatar

Rich Jones Miserlou

View GitHub Profile
@Miserlou
Miserlou / gist:1294412
Created Oct 18, 2011
Posting JSON in Python without Requests Library
View gist:1294412
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 Nov 30, 2011
Google Analytics Example
View gist:1407812
<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;
View etcinit.dhttp-proxy.sh
#!/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";
;;
View 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');
View etc init.d nodeapp.sh
#!/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 &
View Monit Node.sh
#!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 Jan 12, 2012
SOPA Blackout Script
View blackout.html
<script type="text/javascript" src="https://github.com/Miserlou/Blaccupy/raw/master/blaccupy.js"></script>
@Miserlou
Miserlou / blackout.html
Created Jan 12, 2012
SOPA Blackout Script
View blackout.html
<script type="text/javascript" src="https://github.com/Miserlou/Blaccupy/raw/master/blaccupy.js"></script>
View gist:1793381
"iPhone developer needed for amazing new application. Send me your resume."