Skip to content

Instantly share code, notes, and snippets.

View interstateone's full-sized avatar
👋

Brandon Evans interstateone

👋
View GitHub Profile
@interstateone
interstateone / TumblrHTML5Audio.js
Created June 20, 2012 18:00
Load Tumblr audio posts using a HTML5 audio element and display using kolber's audio.js
// Load Tumblr audio posts using a HTML5 audio element and display using kolber's audio.js
//
// Requirements:
// audio.js (http://kolber.github.com/audiojs/)
//
// Usage:
// I'm assuming that you've got audio.min.js loaded in the page already
// I just have it prepended in the same file before this code
// Comments should help you through it, ask me questions at @interstateone
@interstateone
interstateone / form.coffee
Created July 10, 2012 16:58
Using backbone-forms with CoffeeScript class syntax
define (require) ->
# Vendor Libs
$ = require 'jquery'
_ = require 'underscore'
Backbone = require 'backbone'
require 'backbone-forms'
require 'backbone-forms-bootstrap'
@interstateone
interstateone / restart-xbmc.sh
Created December 20, 2012 17:41
Restart XBMC.app on network
# Copy to remote home folder and run with `ssh atv 'bash ~/restart-xbmc.sh'`
JOB=`ps A | grep '/XBMC$' | awk '{print $1}'`
if [ "$JOB" ]; then
kill -9 $JOB
fi
/Applications/XBMC.app/Contents/MacOS/XBMC &> /dev/null
disown %1
exit
@interstateone
interstateone / precompile.rake
Created July 3, 2013 23:01
Precompiling assets on Heroku with require.js
namespace :assets do
def invoke_or_reboot_rake_task(task)
Rake::Task[task].invoke
end
task :test_node do
begin
`node -v`
rescue Errno::ENOENT
@interstateone
interstateone / tumblr-feed.js
Created September 28, 2013 17:41
Grab the latest n posts from a tumblr site to embed in another page.
// Docs for the Tumblr API v1 are here: http://www.tumblr.com/docs/en/api/v1#api_read
// Requires jQuery
// Create a function that will fetch n latest Tumblr posts and format them for placement into a page
var fetchLatestTumblrPost = function() {
// Fetch the feed with Tumblr API v1
$.getJSON("http://blog.brandonevans.ca/api/read/json?num=1&callback=?", function(data) {
// For each post in the returned data
@interstateone
interstateone / pot_led.pde
Created November 13, 2013 02:28
A little Arduino sketch that maps a potentiometer value to a row of LEDs
int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
int mappedValue = 0;
void setup() {
// declare the LED pins as OUTPUTs:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
@interstateone
interstateone / iOS7JSCTest.m
Created December 4, 2013 19:12
A documented example of how a user might script a UIKit UI.
//
// ViewController.m
// PencilCaseJSDemo
//
// Created by Brandon on 12/3/2013.
// Copyright (c) 2013 Robots and Pencils. All rights reserved.
//
#import "ViewController.h"
@import JavaScriptCore;
@interstateone
interstateone / partial.m
Last active August 29, 2015 14:01
A little demo of partial application for variadic blocks
#import <Foundation/Foundation.h>
#define apply(block, a) (^{ \
switch (a.count) { \
case 1: return block(a[0], nil); \
case 2: return block(a[0], a[1], nil); \
case 3: return block(a[0], a[1], a[2], nil); \
case 4: return block(a[0], a[1], a[2], a[3], nil); \
case 5: return block(a[0], a[1], a[2], a[3], a[4], nil); \
@interstateone
interstateone / ProtocolMethodDescriptions.m
Last active August 29, 2015 14:07
Comparing the output of protocol_getMethodDescription and _protocol_getMethodTypeEncoding
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
const char *_protocol_getMethodTypeEncoding(Protocol *, SEL, BOOL isRequiredMethod, BOOL isInstanceMethod);
@protocol Tester <NSObject>
@required
- (BOOL)testDictionary:(NSDictionary *)dictionary error:(NSError **)error;
@end

Keybase proof

I hereby claim:

  • I am interstateone on github.
  • I am interstateone (https://keybase.io/interstateone) on keybase.
  • I have a public key whose fingerprint is 19D4 73C0 B135 D181 1C00 D54A D58A 4B8D B64F 8E93

To claim this, I am signing this object: