Skip to content

Instantly share code, notes, and snippets.

View darobin's full-sized avatar
✍️
writing, writing, writing…

Robin Berjon darobin

✍️
writing, writing, writing…
View GitHub Profile
@darobin
darobin / gist:2935734
Created June 15, 2012 10:10
Async testing
// testharness.js
var t = async_test("Timeout times out");
setTimeout(t.step_func(function () {
assert_true(true);
t.done();
}), 100);
// Jasmine
describe("Timeout", function () {
@darobin
darobin / app.js
Created October 8, 2012 13:12
Simple server that tests delete redirect
var express = require('express')
;
var app = module.exports = express.createServer();
app.configure(function(){
app.use(express.bodyParser());
app.use(app.router);
app.use(express["static"](__dirname + "/public"));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
@darobin
darobin / gist:4118747
Created November 20, 2012 15:53
Extracting alt text in context
var phrasing = {};
"a abbr area audio b bdi bdo br button canvas cite code command datalist del dfn em embed i iframe img input " +
"ins kbd keygen label map mark math meter noscript object output progress q ruby s samp script select small " +
"span strong sub sup svg textarea time u var video wbr"
.split(" ")
.forEach(function (el) { phrasing[el] = true; })
;
function isNotPhrasing (el) {
if (!el) return true;
if (el.nodeType !== 1) return true;
@darobin
darobin / gist:4260155
Created December 11, 2012 16:40
Make the HTML TS structure
var fs = require("fs")
, pth = require("path")
, _ = require("underscore")
, jsdom = require("jsdom")
, wrench = require("wrench")
, mkdirp = require("mkdirp").sync
// use hg for source, gh for target
, sourceDir = pth.join(__dirname, "../html")
, targetDir = pth.join(__dirname, "../html-testsuite")
, sourceTestDir = pth.join(sourceDir, "tests")
@darobin
darobin / controller.js
Last active December 12, 2015 07:48
Playing with implementing AppCache through the NavigationController
var fallbacks = {}
, networks = {}
, cacheName = "OldSchoolAppCache"
;
this.onmessage = function (e) {
var msg = e.data;
if (msg.type && msg.type === "manifest") {
var lines = msg.manifest.split(/\n+/)
, mode = "cache"
@darobin
darobin / index.html
Last active December 12, 2015 07:48
Who needs srcset? Who needs <picture>? Not the AppCache people we don't!
<!DOCTYPE html>
<!--
- controllerpath should default to /*, it's just the typical thing
- controllersync ensures the controller is always there
-->
<html controller="respimg.js" controllerpath="/*" controllersync>
<!-- ... -->
<img src='my-shiny-donkey.png#resp-me'>
</html>
@darobin
darobin / dom.js
Created April 9, 2013 15:19
Just a very quick and dirty stab at using JS for IDL (more at https://github.com/darobin/ideal/)
var ideal = require("../ideal")
, dom = exports
;
dom.Phase = ideal.legacyEnum("NONE", "CAPTURING_PHASE", "AT_TARGET", "BUBBLING_PHASE");
dom.Event = ideal.class
.importLegacyEnum(dom.Phase)
.constructor
.param(String, "type")
##
## After making changes to this file, you MUST rebuild for any changes
## to take effect in your live Discourse instance:
##
## /var/docker/launcher rebuild app
##
## this is the all-in-one, standalone Discourse Docker container template
templates:
- "templates/cron.template.yml"
@darobin
darobin / like-textarea.html
Last active May 7, 2016 11:38
The Twitter Box
<div id="box" contentEditable="minimal"></div>
<script>
var box = document.getElementById("box")
, compoRange = null
, compoText = null
;
function insertText (txt) {
var sel = window.getSelection();
if (!sel) return;
var range = sel.getRangeAt(0);
<button id=hide>Hide boxes</button>
<button id=show>Show boxes</button>
<script>
var $hide = $("#hide")
, $show = $("#show")
, $els = $("pre.foo")
;
function hide () {
$els.hide();