Skip to content

Instantly share code, notes, and snippets.

View harriha's full-sized avatar

Harri Hälikkä harriha

  • Futurice
  • Helsinki, Finland
View GitHub Profile
@sergejmueller
sergejmueller / ttf2woff2.md
Last active March 9, 2024 13:37
WOFF 2.0 – Learn more about the next generation Web Font Format and convert TTF to WOFF2
@kimmobrunfeldt
kimmobrunfeldt / 0-audio-support-mobile-ie.md
Last active August 29, 2015 14:01
Summary of audio/media support in Windows Phones' Internet Explorer(versions 9-11)
@matths
matths / parse.js
Created May 7, 2014 09:10
Line-by-line manipulation of text files (eg. error log files) using node.js' new Stream.Transform functionality and pipe(). You can call this directly from your shell, eg. $ node parse.js error.log
var fs = require('fs');
var TransformLine = require('./TransformLine');
// syntax example:
// $ node parse.js error.log
var inFile = process.argv[2];
var outFile = process.argv[3];
if (!inFile) {
@cowboy
cowboy / json-with-comments-in.yaml
Last active August 29, 2015 13:56
Why do we keep having the "comments in JSON" discussion? Just use YAML.
{
# this is a comment
"a": "hello",
# this is another comment
"b": -1,
"c": [
true,
"test",
null
],
@branneman
branneman / better-nodejs-require-paths.md
Last active April 11, 2025 10:39
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@domenic
domenic / history-of-js.txt
Created October 9, 2013 21:36
History of JS
1995: form validation, image rollovers
1997: ECMA-262 edition 1, Internet Explorer 4, DHTML
1999: ES3 (function expressions, try/catch/finally, regexps, …)
2004: WHATWG formed, focusing on web apps
2005: Ajax
2006: jQuery
2008: V8 (the speed race begins), JS: The Good Parts
2009: ES5, Node.js, PhoneGap, JSConf, ServerJS/CommonJS
2010: Backbone.js, RequireJS
2012: Windows 8, Nodecopter
@wout
wout / gist:6352742
Created August 27, 2013 12:13
Textflow plugin for svg.js
// svg.textflow.js 0.8 - Copyright (c) 2013 Wout Fierens - Licensed under the MIT license
SVG.Textflow = function() {
this.constructor.call(this, SVG.create('text'))
/* define default style */
this.styles = {
'font-size': 16
, 'font-family': 'Helvetica, Arial, sans-serif'
, 'text-anchor': 'start'
@ekantola
ekantola / RxJS-intro.js
Last active June 1, 2017 11:19
RxJS intro snippets
/*
* Observable
*/
var xs = Rx.Observable.range(0, 3)
xs.subscribe(log)
//=> 0
//=> 1
//=> 2
@ianb
ianb / assert.js
Last active December 16, 2015 17:19
assert() for Javascript
function AssertionError(msg) {
this.message = msg || "";
this.name = "AssertionError";
}
AssertionError.prototype = Error.prototype;
/* Call assert(cond, description1, ...)
An AssertionError will be thrown if the cond is false. All parameters will be logged to the console,
and be part of the error.
*/
@NV
NV / Readme.md
Last active January 7, 2025 08:28
Prepend the debugger statement to a function as easy as stopBefore('Element.prototype.removeChild'). Works in Chrome DevTools and Safari Inspector, doesn’t work in Firebug‘s and Firefox Developer Tools‘ console (I don’t know why). Works as a standalone script everywhere.

stopBefore.js

2min screencast

Examples

stopBefore(document, 'getElementById')
stopBefore('document.getElementById') // the same as the previous
stopBefore(Element.prototype, 'removeChild')