Skip to content

Instantly share code, notes, and snippets.

View clohr's full-sized avatar

Christian Lohr clohr

View GitHub Profile
@cjohansen
cjohansen / gist:739589
Created December 13, 2010 20:55
Showing how to fake server requests with Sinon.JS and Jasmine
/*
Load Sinon.JS in the SpecRunner:
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine-html.js"></script>
<script type="text/javascript" src="sinon-1.0.0.js"></script>
<script type="text/javascript" src="sinon-ie-1.0.0.js"></script>
http://cjohansen.no/sinon/
*/
@mbostock
mbostock / .block
Last active August 5, 2023 12:53
Margin Convention
license: gpl-3.0
redirect: https://observablehq.com/@d3/margin-convention
@millermedeiros
millermedeiros / example.js
Last active September 10, 2022 03:06
execute multiple shell commands in series on node.js
// USAGE ------
// ============
var shell = require('./shellHelper');
// execute a single shell command
shell.exec('npm test --coverage', function(err){
console.log('executed test');
}});
@paulirish
paulirish / performance.now()-polyfill.js
Last active August 1, 2023 15:42
performance.now() polyfill (aka perf.now())
// @license http://opensource.org/licenses/MIT
// copyright Paul Irish 2015
// Date.now() is supported everywhere except IE8. For IE8 we use the Date.now polyfill
// github.com/Financial-Times/polyfill-service/blob/master/polyfills/Date.now/polyfill.js
// as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values
// if you want values similar to what you'd get with real perf.now, place this towards the head of the page
// but in reality, you're just getting the delta between now() calls, so it's not terribly important where it's placed
@Marsup
Marsup / reverse.js
Created October 31, 2013 21:23
Hapi reverse proxy
var Hapi = require('hapi');
var server = new Hapi.Server('0.0.0.0', 3000);
server.route({
method: '*',
path: '/{path*}',
handler: {
proxy: {
host: 'amazon.com',
@DrBoolean
DrBoolean / pointfree folktale.js
Last active April 14, 2016 14:14
Pointfree fantasy working with folktale's either
require("pointfree-fantasy").expose(global);
var curry = require("lodash.curry");
var fs = require("fs");
var Either = require("data.either");
// HELPERS
// ============
var add = curry(function(x,y) { return x + y });
@mandiwise
mandiwise / Count lines in Git repo
Last active June 6, 2024 06:11
A command to calculate lines of code in all tracked files in a Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@pmuellr
pmuellr / nsolid-install.sh
Last active January 31, 2021 13:19
sample script to install N|Solid components into ~/nsolid
#!/bin/bash
#-------------------------------------------------------------------------------
# download/unpack componentry for N|Solid into ~/nsolid
#-------------------------------------------------------------------------------
# updates:
# 2016-05-04 print note about officially supported "Download All" tarball
# 2016-02-10 change to get N|Solid versions dynamically from index.tab
# 2016-02-10 upgrade to N|Solid 1.2.1
# 2016-01-12 upgrade to N|Solid 1.2.0
@yang-wei
yang-wei / decode.md
Last active April 2, 2024 20:18
Elm Json.Decode tutorial and cheatsheet

When receiving JSON data from other resources(server API etc), we need Json.Decode to convert the JSON values into Elm values. This gist let you quickly learn how to do that.

I like to follow working example code so this is how the boilerplate will look like:

import Graphics.Element exposing (Element, show)
import Task exposing (Task, andThen)
import Json.Decode exposing (Decoder, int, string, object3, (:=))

import Http
@tpluscode
tpluscode / .gitignore
Last active April 24, 2017 16:03
Example of Web Component Tester with bound fixture
bower_components/