Skip to content

Instantly share code, notes, and snippets.

@tgvashworth
tgvashworth / shim.html
Created February 28, 2012 08:58
navigator.getUserMedia shim - navigator.getMedia. Normalises & detects object & string option styles.
<!DOCTYPE html>
<video id="video" autoplay>
<source type="video/webm" src="http://miketaylr.com/misc/dontstop.webm">
</video>
<script src="userMedia.js"></script>
<script>
// Tell em how it is
if(!navigator.getUserMedia) {
console.log("Don't think you got it, sonny.");
@tgvashworth
tgvashworth / extensio-api-ui.js
Created July 3, 2012 11:11
extensio UI API
/*
Trying to figure out the API for creating a toolbar button
How do it in each browser:
Chrome
manifest && chrome.browserAction...
Firefox
widget.Widget({...})
Safari
Info.plist
@tgvashworth
tgvashworth / gist:3039290
Created July 3, 2012 11:51
extensio configuration
How to configure xio?
Example Chrome extension:
.
├── manifest.json
├── main.html
├── index.js
├── xio.js
├── libs
│ ├── jquery.js
@tgvashworth
tgvashworth / gist:3060821
Created July 6, 2012 15:19
Tiny GitHub feed for your site
$ () ->
# Github Activity Stream
# Requires jQuery!
# To get going just edit this config to match your username and
# how many items you'd like to display.
# The container element should be a <ul> or <ol>
# Enjoy!
config =
@tgvashworth
tgvashworth / gist:3158776
Created July 22, 2012 07:24
Javascript app hosting on S3
I came up with a technique for hosting Javascript apps on Amazon's S3 that can use the request URI (path) as any app with a server side could. This enables a 'fake' directory structure that is actually just one page on S3. I built [schemist](http://schemist.phuu.net) using this technique.
## The basic concept
At it's core, the idea is as simple as using S3's static website hosting tools to force all requests to go to one page. This is as simple as setting up a bucket as a website and pointing the index and 404 pages to the same file (could be index.html or anything else). Because the request URI is kept when the 404 page is served, you can process it using Javascript and serve any content you like, faking a directory structure. This means pretty urls are very easy, and still enables query strings and page identifiers. In combo with the History API, it's pretty damn cool.
## How to do it
Let's say you're wanting to set up a site for your awesome new startup, (Bog Roll Club)[http://bogrollclub.com]. You're
@tgvashworth
tgvashworth / gist:3532070
Created August 30, 2012 16:14
Asynchronous Basehold.it code
<script>
(function(d,t){
var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.href='//basehold.it/24';
g.rel='stylesheet';
s.parentNode.insertBefore(g,s)
}(document,'link'));
</script>
@tgvashworth
tgvashworth / gist:3559121
Created August 31, 2012 21:15
Watch the app.net global stream for annotations
/*
Note: this was hacked together _very_ fast. It's probably wrong, stupid,
broken, idiotic and generally useless.
To use: stick this in app.js & npm install request
*/
var request = require('request')
, url = require('url')
console.log("Hello, test");
@tgvashworth
tgvashworth / gist:4020664
Created November 5, 2012 21:59
Angular & Ace

I'm building an app using Angular that involves using the Ace editor. What I'd like to do is be able to create and editor & control a select few element of Ace's API in an Angular-like way. ie:

<div ng-controller="AceCtrl">
  <ace-editor mode="html" ng-model="code" ng-change="do_stuff()"></ace-editor>
</div>

And have that construct an Ace instance with observable properties.

@tgvashworth
tgvashworth / gist:4582024
Created January 20, 2013 21:50
nick cdnjs
var https = require('https');
var find_by = function (key, search, array) {
var matches = [];
array.some(function (item) {
if( item[key] ) {
if( (''+item[key]).toLowerCase().indexOf(search) !== -1 ) {
matches.push(item);
}
}