Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<meta charset=utf-8 />
<title></title>
#yolo
@tgvashworth
tgvashworth / gist:10789694
Created April 15, 2014 23:43
om and core-async
(ns om-do.core
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[cljs.core.async :refer [put! <! >! chan timeout alts!]]))
(enable-console-print!)
(def app-state
(atom {}))
@tgvashworth
tgvashworth / gist:32ab6737141d989ea280
Created September 1, 2014 19:32
take vs alts priority
(go
(let [v (<! c)]
(println "take got" v)))
(go
(let [[v c] (alts! [c c2])]
(println "alts got" v)))
(>!! c 1)
; => alts got 1
I want a box that contains some text and an image or icon.
The icon should sit just to the right of the text, unless the text+image fills the width of the box.
The text should then finish with ellipsis, but the icon should stay in a fixed position.
The surrounding box should fill multiple fixed-width containers.
+-------------------+
| + |
$ ./run some-file-to-run.js
@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