Skip to content

Instantly share code, notes, and snippets.

function loadScript(path, fn) {
var el = document.createElement('script')
, loaded = 0
, onreadystatechange = 'onreadystatechange'
, readyState = 'readyState';
el.onload = el.onerror = el[onreadystatechange] = function () {
if (loaded || (el[readyState] && !(/^c|loade/.test(el[readyState])))) return;
el.onload = el.onerror = el[onreadystatechange] = null;
loaded = 1;
@sveinung
sveinung / ConcreteFormValidator.java
Last active December 11, 2015 20:59
Forslag til validering i Jerseyressursar. Spesielt av former o.l.
public class ConcreteFormValidator extends FormValidator<FormDTO> {
private NumericStringValidator numericStringValidator;
public ConcreteFormValidator(NumericStringValidator numericStringValidator) {
this.numericStringValidator = numericStringValidator;
}
@Override
public List<Message> validate(FormDTO form) {
return collectMessages(this.numericStringValidator.validate(form.getA(), "first"),
@aslakhellesoy
aslakhellesoy / gfm.sh
Last active November 23, 2016 09:57
Compile and show GFM docs in your browser.https://help.github.com/articles/github-flavored-markdown
#!/bin/sh
# Compile and show [GFM](https://help.github.com/articles/github-flavored-markdown) docs in your browser.
# Before this works you need to `gem install bcat`
#
# Usage: gfm.sh FILE.md
#
curl --silent --data-binary @- https://api.github.com/markdown/raw -H "Content-Type: text/plain" | bcat
@jeremyckahn
jeremyckahn / inherit-by-proxy.js
Created May 10, 2013 04:25
Proxy-based inheritance pattern in JavaScript.
function inherit (child, parent) {
function proxy () {};
proxy.prototype = parent.prototype;
child.prototype = new proxy();
};
function Parent () {}
function Child () {}
inherit(Child, Parent);