Skip to content

Instantly share code, notes, and snippets.

View rnagle's full-sized avatar

Ryan Nagle rnagle

View GitHub Profile
@rnagle
rnagle / ferrari.py
Created March 15, 2011 00:26
Nick's Ferrari
# Nick's Ferrari
from urllib import urlopen
f = urlopen('http://www.textfiles.com/art/ferrari.art')
ferrari = f.read()
print ''
print ferrari
@rnagle
rnagle / chartbeat.js
Created December 7, 2011 21:34
Chartbeat.js
var Chartbeat = function(opts) {
if (!opts)
throw new Error("Chartbeat: Please specify an api key and host!");
if (!opts.api_key)
throw new Error("Chartbeat: Please specify an api key!");
if (!opts.host)
throw new Error("Chartbeat: Please specify a host!");
this.creds = {
@rnagle
rnagle / otf_get_attachment_image_src.php
Created April 12, 2012 12:46
WordPress: Generate thumbnails on-the-fly
<?php
/*
* Check for thumb of $size and generate it if it doesn't exist.
*
* @param int $post_id Post ID for which you want to retrieve thumbnail
* @param string $size Name of thumbnail size to check for; same as
* the slug used to add custom thumb sizes with add_image_size().
* @return array An array containing: array( 0 => url, 1 => width, 2 => height )
*
@rnagle
rnagle / simple_carousel.js
Created October 1, 2012 19:03
Simple Carousel
_____ ___ _ __ __
|_ _| __| /_\ | \/ |
| | | _| / _ \| |\/| |
|_|_|___/_/_\_\_| |_|
|_ _| _ \_ _| _ )
| | | /| || _ \
|_| |_|_\___|___/
/_\ | _ \ _ \/ __|
/ _ \| _/ _/\__ \
/_/ \_\_| |_| |___/
@rnagle
rnagle / gist:3948066
Created October 24, 2012 18:55
Freezer
#!/bin/bash
#
# Create a local copy of a website, suitable
# for upload to S3 as a static archive.
#
# Provide the domain name you wish to archive
# as the first argument.
#
# For example:
@rnagle
rnagle / gist:3966178
Created October 27, 2012 20:48
S3 Utils
import os
from boto import connect_s3
from boto.exception import S3ResponseError
from boto.s3.key import Key
from config import AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID, S3_BUCKET
bucket_name = S3_BUCKET
conn = connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
@rnagle
rnagle / gist:3990130
Created October 31, 2012 21:46
Experiment with Casper.js
var clients = Array(10),
url = 'http://localhost:5000/';
var on = function(resource) {
if (resource.url.match('data.json'))
this.echo("[update] Received: " + resource.url, 'INFO');
};
var start = function() {
if (this.resourceExists('data.json')) {
@rnagle
rnagle / ObligationDebtChartView.js
Created March 7, 2014 19:16
ObligationDebtChartView.js
var ObligationDebtChartView = ChartView.extend({
constructor: function(options) {
ChartView.apply(this, arguments);
this.create_tooltip();
this.$chart_container.attr('id', 'debt-chart-container');
return this;
},
draw: function() {
@rnagle
rnagle / ChartView.js
Created March 7, 2014 19:17
ChartView.js
/**
* Original author: David Eads (https://github.com/eads)
*
* Wrap D3 charting components in a simple Backbone view interface
*
* Provides a redrawing path, data sync, and fallback for non-d3 browsers.
*
* Views that extend ChartView should implement their own "draw" function and go to work.
*
* var collection = new Backbone.Collection([ ["Maria", 33], ["Heather", 29] ]);