Skip to content

Instantly share code, notes, and snippets.

View JoshuaGross's full-sized avatar

Joshua Gross JoshuaGross

View GitHub Profile
@remy
remy / gist:350433
Created March 31, 2010 14:58
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@defunkt
defunkt / clients.md
Created April 18, 2010 14:09
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@indexzero
indexzero / base64.js
Created November 27, 2010 23:38
An extremely simple implementation of base64 encoding / decoding using node.js Buffers
//
// Super simple base64 encoding / decoding with node.js
//
var base64 = exports = {
encode: function (unencoded) {
return new Buffer(unencoded).toString('base64');
},
decode: function (encoded) {
return new Buffer(encoded, 'base64').toString('utf8');
@jehiah
jehiah / simple_args_parsing.sh
Created March 4, 2011 16:56
a simple way to parse shell script arguments
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
@jsundram
jsundram / cull.py
Last active April 5, 2023 15:22
Check if lat long is inside the bounds of the continental US (box model, not shape)
# http://en.wikipedia.org/wiki/Extreme_points_of_the_United_States#Westernmost
top = 49.3457868 # north lat
left = -124.7844079 # west long
right = -66.9513812 # east long
bottom = 24.7433195 # south lat
def cull(latlngs):
""" Accepts a list of lat/lng tuples.
returns the list of tuples that are within the bounding box for the US.
NB. THESE ARE NOT NECESSARILY WITHIN THE US BORDERS!
@kscottz
kscottz / gist:1284737
Created October 13, 2011 16:40
Every OpenCV Function in the Python Bindings for OpenCV 2.3.1
[('ADAPTIVE_THRESH_GAUSSIAN_C', 1L)
('ADAPTIVE_THRESH_MEAN_C', 0L)
('ANN_MLP', <built-in function ANN_MLP>)
('ANN_MLP_GAUSSIAN', 2L)
('ANN_MLP_IDENTITY', 0L)
('ANN_MLP_NO_INPUT_SCALE', 2L)
('ANN_MLP_NO_OUTPUT_SCALE', 4L)
('ANN_MLP_SIGMOID_SYM', 1L)
('ANN_MLP_TRAIN_PARAMS_BACKPROP', 0L)
('ANN_MLP_TRAIN_PARAMS_RPROP', 1L)
@kirbysayshi
kirbysayshi / LICENSE
Last active March 19, 2024 07:25
Hierarchical Spatial Hash Grid: extremely efficient spatial hashing for collision detection between objects of any size! This is an implementation in JS as described in http://www10.informatik.uni-erlangen.de/~schornbaum/hierarchical_hash_grids.pdf
Copyright 2012 Andrew Petersen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR O
@jpoehls
jpoehls / main.js
Created February 17, 2012 16:33
Benchmark.js deferred
var Benchmark = require('benchmark');
var request = require('request');
var suite = new Benchmark.Suite;
// add tests
suite.add('Calling cow api', {
defer: true,
fn: function(deferred) {
request({
@robbyt
robbyt / boto-etag.py
Created February 23, 2012 23:14
boto etag hash auto verification
import boto
s3 = boto.connect_s3()
bucket = s3.get_bucket('robs-super-bucket')
d = bucket.new_key()
file1 = open('testfile.txt', 'r')
file2 = open('otherfile.txt', 'r')
# build the hash from file1
@ashee
ashee / aws-bash.sh
Created March 14, 2012 17:28
Bash script to make AWS REST calls
#!/bin/bash
KEY='<get from AWS>'
ASSOC_ID='<get from AWS>'
TS=$(date -u "+%Y-%m-%dT%H:%M:%SZ" | sed 's/:/%3A/g')
RPARMS="AWSAccessKeyId=$KEY&AssociateTag=$ASSOC_ID&ItemId=0679722769&Operation=ItemLookup&ResponseGroup=ItemAttributes%2COffers%2CImages%2CReviews&Service=AWSECommerceService&Timestamp=$TS&Version=2009-01-06"
read -r -d '' REQ <<EOF
GET