Skip to content

Instantly share code, notes, and snippets.

View imjasonh's full-sized avatar
🏠
Working from home

Jason Hall imjasonh

🏠
Working from home
View GitHub Profile
@imjasonh
imjasonh / timerange.html
Created January 24, 2012 06:52
HTML abomination to select a time range [0, 23]
<html>
<head>
<script type="text/javascript">
function get(id) {
return document.getElementById(id);
}
function updateLower() {
var value = get('lower').valueAsNumber;
get('upper').min = value + 1;
@imjasonh
imjasonh / foursquare.v2.json
Created February 16, 2012 15:09
Discovery document for Foursquare API
{
"kind": "discovery#restDescription",
"id": "foursquare:v2",
"name": "foursquare",
"version": "v2",
"title": "Foursquare API",
"description": "Is awesome.",
"icons": {
"x16": "https://playfoursquare.s3.amazonaws.com/press/logo/icon-16x16.png"
},
@imjasonh
imjasonh / background.html
Created February 21, 2012 17:37
Dart Chrome extension
<html><head>
<script type="application/dart">
main() {
print('hello world');
}
</script>
<script type='text/javascript'>
if (navigator.webkitStartDart) {
navigator.webkitStartDart();
}
public class MyEntryPoint implements EntryPoint {
public void onModuleLoad() {
jsniAlert();
jsniAlertParam("Hello");
jsniAlertParam("World");
}
private static final native void jsniAlert() /*-{
$wnd.alert("Called JSNI alert");
public class MyEntryPoint implements EntryPoint {
public void onModuleLoad() {
doJsni();
}
private static void staticMethod(int num) {
Window.alert("Static method called " + num);
}
private void instanceMethod(String str) {
@imjasonh
imjasonh / pubsub.go
Created September 6, 2012 04:34
Simple HTTP server that enqueues subscribers and sends published messages to the oldest subscriber (and enqueues messages in case there are no subscribers)
package main
import (
"io"
"log"
"net/http"
)
const (
buffSize = 100
@imjasonh
imjasonh / main.go
Created December 12, 2012 18:26
Script to copy your GitHub Downloads to Google Cloud Storage
/*
First go to https://code.google.com/apis/console, create a project, enable Cloud Storage in the "Services"
tab. Enable billing and create a bucket via the online browser. Then, run this script.
Usage:
$ go build main.go -o copy_downloads && chmod +x copy_downloads && ./copy_downloads \
--repo=SomeGitHubUser/AndARepo
--bucket=google-storage-bucket-that-i-own
(Alternately, the build script is available at http://www.imjasonh.com/copy_downloads)
@imjasonh
imjasonh / mustlogin.go
Created December 19, 2012 15:12
Recipe to require that a user log in before reaching an http Handler func, without specifying it in app.yaml (similar to Python App Engine's @login_required decorator)
package mustlogin
import (
"appengine"
"appengine/user"
"fmt"
"net/http"
)
func init() {
@imjasonh
imjasonh / mustoauth.go
Last active December 10, 2015 00:09
Recipe to require that a user log in and go through an OAuth flow before reaching an http Handler func. This is similar to google-api-python-client's OAuth2Decorator (https://developers.google.com/api-client-library/python/platforms/google_app_engine#Decorators) This is based on the mustlogin.go gist here: https://gist.github.com/4337383
package mustoauth
import (
"appengine"
"appengine/datastore"
"appengine/memcache"
"appengine/urlfetch"
"appengine/user"
"encoding/json"
"fmt"
@imjasonh
imjasonh / perler.go
Last active December 15, 2015 17:29
Go script to read a png image like those found at http://scrollboss.illmosis.net/sprites.php?g=xmen-konamiarc to figure out how to make one with Perler beads (WIP)
package main
import (
"flag"
"fmt"
"image"
"image/color"
"image/png"
"log"
"math"