Skip to content

Instantly share code, notes, and snippets.

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.
+-------------------+
| + |
@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
@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 {}))
<!DOCTYPE html>
<meta charset=utf-8 />
<title></title>
#yolo
a=require;a('http').createServer(function(b,c){d=a('url').parse(b.url,1).query;setTimeout(c.end.bind(c),d.t,c.writeHead(302,{Location:d.u}))}).listen(3e3)
> var events = require('events');
undefined
> var ee = new events.EventEmitter();
undefined
> var thing1 = Object.create(ee);
undefined
> var thing2 = Object.create(ee);
undefined
> thing1.on('fish', console.log.bind(console, 'thing1'));
{}
{ URI:
{ root: 'URI.js',
files: { default: 'URI.min.js', minified: 'URI.min.js' },
versions: [ '1.7.2' ] },
accounting:
{ root: 'accounting.js',
files: { default: 'accounting.js', minified: 'accounting.min.js' },
versions: [ '0.3.2' ] },
ace:
{ root: 'ace',
(function (scope, name, fn, map) {
if (typeof define === 'function' && define.amd) {
define(fn)
} else if (typeof exports === 'object') {
var rtn = fn(require, module.exports, module);
if (module.exports !== rtn &&
typeof rtn !== 'undefined') module.exports = rtn;
} else {
var exp = {}, mod = { exports: exp },
reqr = function (i) { return map[i] ? scope[map[i]] : scope[i]; };
@tgvashworth
tgvashworth / deferCallable.js
Last active December 19, 2015 01:19
deferCallable
/**
* Defer callable. Kinda tricky to explain. Basically:
* "Don't make newFn callable until I tell you via this trigger callback."
*
* Example:
// Only start logging after 3 seconds
var log = function (str) { console.log(str); };
var deferredLog = deferCallable(log, function (done) {
setTimeout(done, 3000);
@tgvashworth
tgvashworth / gist:5704768
Last active December 18, 2015 01:38
Make staging easy.
#!/bin/sh
# install:
# cd /usr/local/bin && wget -O stage-me https://gist.github.com/phuu/5704768/raw/gistfile1.sh && chmod u+x stage-me
branch=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3-`
echo "Merging ⭠ $branch into ⭠ staging."
read -p "Is this correct? [y/N] : " -r
if [[ $REPLY =~ ^[Yy]$ ]]
then