Skip to content

Instantly share code, notes, and snippets.

View carsonmcdonald's full-sized avatar

Carson McDonald carsonmcdonald

View GitHub Profile
@carsonmcdonald
carsonmcdonald / gist:735780
Created December 10, 2010 04:24
Lucky 13 - Java
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Scanner;
public class Lucky
{
public static int winnings(int bet) throws Exception
{
return "13".equals(new Scanner(((InputStream) new URL("http://roulette.engineyard.com/").getContent())).findInLine("\\d+")) ? bet * 35 : 0;
@carsonmcdonald
carsonmcdonald / gist:911761
Created April 9, 2011 20:48
node.js SPDY proxy
var tls = require('tls');
var fs = require('fs');
var Buffer = require('buffer').Buffer;
var zlib = require('zlib');
var BufferList = require('bufferlist');
var Binary = require('bufferlist/binary');
var Put = require('put');
var http = require('http');
var options =
@carsonmcdonald
carsonmcdonald / revspdynpn.sh
Created April 27, 2011 14:52
How to set up ruby, eventmachine and spdy to use NPN
#
# Get development tools installed
#
sudo yum install -y git cvs zlib-devel
sudo yum groupinstall -y "Development Tools"
#
# Install RVM
#
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
@carsonmcdonald
carsonmcdonald / gist:956349
Created May 5, 2011 01:19
Adding page load time tracking to Yoast's Google Analytics plugin
function gapagespeed($push)
{
$push[] = "'_trackPageLoadTime'";
return $push;
}
add_filter( 'yoast-ga-push-after-pageview', 'gapagespeed' );
@carsonmcdonald
carsonmcdonald / ALL_BUILD.out
Created May 31, 2012 03:17
Results of xcodebuild -project mruby.xcodeproj -target ALL_BUILD clean build and xcodebuild -project mruby.xcodeproj -target mruby clean build
=== CLEAN AGGREGATE TARGET ZERO_CHECK OF PROJECT mruby WITH THE DEFAULT CONFIGURATION (Debug) ===
Check dependencies
Clean.Remove clean build/mruby.build/Debug/ZERO_CHECK.build
builtin-rm -rf /tmp/mruby/build/mruby.build/Debug/ZERO_CHECK.build
=== CLEAN NATIVE TARGET xpcat OF PROJECT mruby WITH THE DEFAULT CONFIGURATION (Debug) ===
Check dependencies
@carsonmcdonald
carsonmcdonald / app.js
Created September 2, 2012 01:59
Use S3 CORS FileAPI uploader
function createCORSRequest(method, url)
{
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr)
{
xhr.open(method, url, true);
}
else if (typeof XDomainRequest != "undefined")
{
xhr = new XDomainRequest();
set -g default-terminal "screen-256color"
set -g history-limit 20000
# Set the prefix to ^A.
unbind C-b
set -g prefix ^A
bind a send-prefix
# Bind appropriate commands similar to screen.
# lockscreen ^X x
@carsonmcdonald
carsonmcdonald / example.rb
Created September 20, 2012 02:52
mruby proc call example
class Bar
def initialize(name)
@name = name
@x = 0
@y = 0
end
def name
@name
end
#import "EmailShareType.h"
@implementation EmailShareType
{
UIViewController *pvController;
}
- (void)share:(UIViewController *)parentViewController
{
pvController = parentViewController;
@carsonmcdonald
carsonmcdonald / gist:4428542
Created January 1, 2013 16:49
CouchDB map function used to count #code2012 entires.
{
map: function (doc)
{
if(doc.text.indexOf("RT ") != -1 || doc.text.indexOf("RT:") != -1 ||
doc.text.indexOf("rt ") != -1 || doc.text.indexOf("rt:") != -1)
{
return;
}
function pre_replacements(obj)