Skip to content

Instantly share code, notes, and snippets.

Avatar

Shane Harter shaneharter

View GitHub Profile
@shaneharter
shaneharter / backbone_pushstate_router.js
Last active Aug 29, 2015 — forked from wololodev/backbone_pushstate_router.js
Play nice with Backbone.history.root when attaching pushstate click handler
View backbone_pushstate_router.js
// Only need this for pushState enabled browsers
if (Backbone.history && Backbone.history._hasPushState) {
var $document = $(window.document);
var openLinkInTab = false;
// Links like <a href="some/thing/here"> are relative to the page.
// We want to run these links thru the router
var is_relative_to_page = function(href) {
return href.match(/^\/|(http:|https:|ftp:|mailto:|javascript:)/) === null;
};
View gist:bc7d33a513728f5bf44c
<?php
/**
* An immutable value object.
*/
final class ImmutableObject
{
private $state = array();
View gist:b50a48530666f211cd56
with make_temp_dir(listing_id) as tmpdir:
logger.console('Downloading assets for %s to %s' % (listing_id, tmpdir))
photoset = photos.Photoset(filenames, tmpdir, limit=MAXIMUM_PHOTOS, subprocessor=logged_popen)
photoset.load()
if photoset.count() < MINIMUM_PHOTOS:
raise RuntimeWarning('Too few conforming photos')
photoset.process()
View gist:2084244
<?php
function shutdown_function()
{
$error = error_get_last();
if (is_array($error) && isset($error['type']) == false)
return;
switch($error['type'])
{
View bashrc
function bashrc() {
# If $script variable exists, use it as filename to append. If not, use $1
if [ -z "$script" ]
then fname="$1"
else fname="$script"
fi
if [ -z "$fname" ]
then return 1
fi
@shaneharter
shaneharter / stomp_test.php
Created Jul 3, 2012
stomp client test script
View stomp_test.php
<?php
/**
* Test Stomp Throughput
* @author Shane Harter
*/
require 'stomp/Stomp.php';
$start = microtime(true);
View repowatcher.py
import requests
import smtplib
from email.mime.text import MIMEText
API = "api.github.com"
TOKEN = ""
WHITELIST = './whitelist'
EMAIL_LIST = ['sharter@trulia.com']
SMTP_SERVER = 'mail.trulia.com'
def uri(uri):
View tap.js
Object.defineProperty(Object.prototype, 'tap', {
value: function(fun){
fun.call( this );
return this;
},
enumerable: false
});
// Usage:
// a = [];
View gist:4332807
<?php
ini_set('display_errors', 1);
require_once 'include/local.conf';
require_once (COMMON_INCLUDE_PATH.'email/EmailTypes.php');
$mutex = sem_get(ftok(__file__, 'D'), 1, 0666, 1);
register_shutdown_function(function() use($mutex) {
@sem_release($mutex);
});
@shaneharter
shaneharter / sqrt.go
Created May 13, 2013
Gotour: Newtonian square roots in Go
View sqrt.go
package main
import (
"fmt"
"math"
)
const min_delta = 0.000000000001
func Sqrt(x float64) float64 {
You can’t perform that action at this time.