Skip to content

Instantly share code, notes, and snippets.

View seutje's full-sized avatar

Steve De Jonghe seutje

View GitHub Profile
@peol
peol / relative-time-duration.js
Created August 5, 2011 16:19
Small, versatile relative time/duration function
/**
* Copyright(c) 2011 Andrée Hansson
* @peolanha
* http://github.com/peol
*
* License: Do whatever you want, some attribution would be nice
*
* Small, versatile relative time function, options:
* asArray: Returns the data in an array, each entry has [0] = number, [1] = string representation
* filterValues: Removes all entries with 0 as value
@boazsender
boazsender / keyboard-event-trigger.js
Created October 17, 2011 03:25
Dispatch a keyboard
/*
Chrome does not let you modify the keyCode prop when you trigger it, so it defaults to 0.
You can use this code to trigger a keydown with a char code of 0 in chrome.
If you use initKeyEvent instead of initKeyboardEvent, it will work in FF
(the bellow example would trigger keydown with a char code of 65 in FF).
*/
document.addEventListener( 'keydown', function( event ){
console.log( event.keyCode )
[alias]
# View the SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 10 --graph
# Better, prettier log view (including author and relative date)
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
# View the current working tree status using the short format
s = status -s
# Diff
d = diff --patch-with-stat
# Diff, inline
@remy
remy / hang.js
Created November 30, 2012 13:23
How to hang JavaScript (useful - to me - for slowing down code and testing)
function hang(n) {
var x = new XMLHttpRequest();
x.open('GET', 'http://hang.nodester.com/script.js?' + n, false);
x.send();
}
// usage: hang(2 * 1000);
@brianarn
brianarn / maths.js
Last active July 6, 2020 22:08
Module to wrap `console.group` around all methods
// A simple object with some methods,
// which throw errors when bad arguments are passed.
var maths = {
square : function (value) {
// Validity checking
if (arguments.length !== 1) {
throw new Error('square: Requires one and only one argument');
}
if (typeof value !== 'number') {
throw new Error('square: Requires numeric argument');
@cam8001
cam8001 / dapply
Last active December 20, 2023 19:40
Apply a patch directly from a URL without downloading it first.
#!/bin/bash
# Downloads and applies a patch from Drupal.org.
if [ -z "$1" ]
then
echo "You need to supply a URL to a patch file."
exit
fi
URL=$1;
@a2nt
a2nt / Astropad faker script
Created April 14, 2014 15:04
Astropad faker
// ==UserScript==
// @name Anti-AstroPad
// @version 0.01
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @match http://mush.vg/*
// @match http://mush.vg/#
// @match http://mush.twinoid.com/*
// @match http://mush.twinoid.com/#
// @match http://mush.twinoid.es/*