Skip to content

Instantly share code, notes, and snippets.

View ryan-blunden's full-sized avatar

Ryan Blunden ryan-blunden

  • Brisbane, Australia
View GitHub Profile
@ryan-blunden
ryan-blunden / gist:3172439
Created July 24, 2012 20:29
Exit script if not run with sudo
#Exit if not run with sudo
if [[ $UID != 0 ]]
then
echo "This command requires sudo"
exit 1
fi
@ryan-blunden
ryan-blunden / 3g
Created October 1, 2012 19:07
Limit connection speed to 3G speeds
if [ $1 == 'start' ]; then
ipfw pipe 1 config bw 30Kbit/s delay 350ms
ipfw add 1 pipe 1 src-port 80
ipfw add 2 pipe 1 dst-port 80
elif [ $1 == 'stop' ]; then
sudo ipfw delete 1
sudo ipfw delete 2
fi
@ryan-blunden
ryan-blunden / getscript.js
Created October 21, 2012 16:49
Get Script
function getScript(src, callback) {
var script = document.createElement('script');
script.src = src + '?nc=' + new Date().getTime();
var done = false;
script.onload = script.onreadystatechange = function () {
if (!done && (!this.readyState
|| this.readyState === 'loaded'
|| this.readyState === 'complete')
@ryan-blunden
ryan-blunden / jshint_staged_files.py
Created January 4, 2013 23:32
Run jshint over JavaScript files currently staged.
#!/usr/bin/env python
import subprocess
"""
Checked staged JavaScript files for jshint errors
"""
def jshint():
errors = []
@ryan-blunden
ryan-blunden / svn_revert_all
Created February 27, 2013 17:51
Revert all changes in a Subversion repository
#!/bin/bash
svin revert --recursive . && svn status | grep ^\? | awk '{print $2}' | xargs rm -rf
@ryan-blunden
ryan-blunden / twitter_scraper_server.js
Last active December 20, 2015 16:29
Experimenting with jsdom and screen scraping. Scrape a user's tweets via a simple Node.js Express app.
#!/usr/bin/env node
var jsdom = require('jsdom');
var express = require('express');
var app = express();
app.get('/user/:username/timeline/', function (req, res) {
console.log('Get timeline for: ' + req.params.username);
jsdom.env(
'http://www.twitter.com/' + req.params.username,
@ryan-blunden
ryan-blunden / compile_underscore_templates.js
Last active December 21, 2015 06:18
Pre-compile your client-side underscore templates to individual AMD modules using Node.js.
/*
Underscore Template AMD Compiler
Ryan Blunden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@ryan-blunden
ryan-blunden / django-admin-theme.css
Last active December 29, 2015 05:39
Super light-weight customization of the default Django admin styles for a more modern and better looking admin.
/*
Django Admin Theme
Ryan Blunden
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@ryan-blunden
ryan-blunden / base_site.html
Created November 24, 2013 05:36
Simple extension of Django admin base_template.html so you can change the title displayed on the login and header, as well as adding custom JavaScript and CSS files for extra functionality and styling.
{% extends "admin/base.html" %}
{% load i18n %}
{# Customize the branding in the login form #}
{% block title %}{{ title }} | {% trans 'Site Name Admin' %}{% endblock %}
{% block extrastyle %}
<link rel="stylesheet" href="{{ STATIC_URL }}css/django-admin-theme.css" media="screen"/>
{% endblock %}
@ryan-blunden
ryan-blunden / gist:8607985
Created January 24, 2014 22:21
Install the Darcula theme for Xcode
mkdir -p ~/Library/Developer/Xcode/UserData/FontAndColorThemes &&
cd ~/Library/Developer/Xcode/UserData/FontAndColorThemes &&
curl -O https://raw.github.com/meap/Darcula-Xcode-Theme/master/Darcula.dvtcolortheme