Skip to content

Instantly share code, notes, and snippets.

View NickWoodhams's full-sized avatar

Nick Woodhams NickWoodhams

View GitHub Profile
@NickWoodhams
NickWoodhams / select2ify.js
Created December 13, 2012 20:35
Activate the Select2 Library on any webpage with this Javascript Bookmarklet
function loadJSInclude(scriptPath, callback)
{
var scriptNode = document.createElement('SCRIPT');
scriptNode.type = 'text/javascript';
scriptNode.src = scriptPath;
var headNode = document.getElementsByTagName('HEAD');
if (headNode[0] !== null)
headNode[0].appendChild(scriptNode);
@NickWoodhams
NickWoodhams / uwsgi.conf
Created January 17, 2013 00:14
my uWSGI Emperor Init (Upstart script)
# Emperor uWSGI script
description "uWSGI Emperor"
start on runlevel [2345]
stop on runlevel [06]
respawn
exec /usr/bin/uwsgi --master --enable-threads --emperor /etc/uwsgi/apps-enabled --die-on-term --uid www-data --gid www-data --logto /var/log/uwsgi/emperor.log
@NickWoodhams
NickWoodhams / zebraprint.sh
Created January 29, 2013 22:07
Print a UPS Label GIF on a Zebra 2844 @203 PPI
#!/bin/sh
filename=$1
echo "Begin processing file:" $filename
dimensions=$(identify -format '%w %h' $filename)
IFS=' ' read -a array <<< "$dimensions"
width=${array[0]}
height=${array[1]}
@NickWoodhams
NickWoodhams / app.py
Created June 3, 2013 08:26
Flask Github post-receive hook
@app.route('/post-receive-hook', methods=['GET', 'POST'])
def post_receive_hook():
if request.method == "POST" and request.form['payload']:
payload = json.loads(request.form['payload'])
pprint(payload)
output = subprocess.Popen('sh /home/user/post-receive-script.sh'.split(), stdout=subprocess.PIPE).communicate()[0]
print output # for debugging
return "Hi!"
else:
abort(404)
@NickWoodhams
NickWoodhams / ndissite
Created June 10, 2013 15:14
Nginx and Uwsgi helpers for enabling sites/apps by automatically creating symlinks
#!/bin/bash
if [ "$1" ]; then
#site argument is set
if [ -L /etc/nginx/sites-enabled/$1 ]; then
#symbolic link does not exist, enable the site
echo "Disabling nginx site $1!"
sudo rm /etc/nginx/sites-enabled/$1
sudo service nginx restart
else
#symbolic link exists, give the user a message
@NickWoodhams
NickWoodhams / embed-button.js
Last active December 18, 2015 16:29
API Xchange Embed Button
<script id="apixchange-embed-script" src="//apixchange.com/static/js/embed-button.js"></script>
@NickWoodhams
NickWoodhams / embed-button.html
Created June 19, 2013 03:17
API Xchange HTML Button Embed
<a href="https://apixchange.com"><img alt="API Xchange" src="https://apixchange.com/static/img/embed-button.png"></a>
@NickWoodhams
NickWoodhams / gist:5811459
Created June 19, 2013 03:20
HTML + CSS API Xchange Button Embed
<style>
.apixchange-embed-button {
font-family: "Lato", sans-serif;
display: inline-block;
border: 2px solid #eee;
border-radius: 5px;
background: #FFF;
width: 227px;
white-space: nowrap;
}
@NickWoodhams
NickWoodhams / uwsgi.conf
Created June 23, 2013 07:14
UWSGI Emperor Init Script
description "uWSGI"
start on runlevel [2345]
stop on runlevel [06]
respawn
env UWSGI=/usr/bin/uwsgi
env LOGTO=/var/log/uwsgi/emperor.log
exec $UWSGI --master --emperor /etc/uwsgi/apps-enabled --die-on-term --uid www-data --gid www-data --logto $LOGTO
@NickWoodhams
NickWoodhams / script.js
Created July 8, 2013 18:27
Flask Toolip sample library for Bootstrap
$(document).ready(function(){
$('.close').click(function(){
$(this).closest('.popover').remove();
});
});