Skip to content

Instantly share code, notes, and snippets.

View roobie's full-sized avatar

Björn Roberg roobie

View GitHub Profile
@roobie
roobie / fun.js
Last active December 27, 2015 03:49
javacsript misc stuff
/** Examples:
*/
(function(definition) {
if (typeof require !== "undefined") {
define('fun', [], definition);
} else if (typeof module !== "undefined" && module.exports) {
module.exports.fun = definition();
} else {
fun = definition();
var formatString = (function () {
/**
formatString
Expected arguments:
format[0]: <String> The format. It uses a specific interpolation notation.
data[1]: <Object|Array<Object>> The data to interpolate
Throws:
TypeError: If format is null or undefined
@roobie
roobie / augment.js
Created November 18, 2013 14:35
augment pattern
var A = function augment(a) {
};
@roobie
roobie / guid.js
Created November 29, 2013 09:38
UUID impl
var Guid = (function() {
/// Constructor:
function Guid() {
this.bytes = (function rec(acc, i) {
return (0 > i || i > 31) ?
acc :
rec(acc.concat((Math.random() * 16 | 0).toString(16)), i + 1);
})([], 0);
}
@roobie
roobie / multi.js
Last active January 4, 2016 20:49
Multiple dispatch
var multi = (function multimethod_closure() {
/*
Usage:
var m = multi()
.when_t(String)(function (s) {console.log('string');})
.when_t(Number)(function (s) {console.log('number');})
*/
"use strict";
var WHEN_TYPE = "type",
@roobie
roobie / throbber_fun.js
Created May 22, 2014 12:23
Random color throbber
/******************************************************************************
ORIGINAL:
http://upload.wikimedia.org/wikipedia/commons/3/30/Chromiumthrobber.svg
-------------------------------------------------------------------------------
<svg width="16" height="16" viewBox="0 0 300 300"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<path d="M 150,0
a 150,150 0 0,1 106.066,256.066
l -35.355,-35.355
a -100,-100 0 0,0 -70.711,-170.711 z"
@roobie
roobie / uncheck_unwanted.user.js
Last active August 29, 2015 14:15
GreaseMonkey user script. Unchecks all inputs on the document
// ==UserScript==
// @name Uncheck Flash "Optional" Offer
// @namespace bjorn
// @description No one wants McAffee
// @include http://get.adobe.com/*
// @version 1
// @grant none
// ==/UserScript==
document.addEventListener('DOMContentLoaded', function () {
@roobie
roobie / config.h
Created February 18, 2015 19:15
Config for DWM from suckless.org
/* See LICENSE file for copyright and license details. */
/* appearance */
static const char font[] = "-*-dejavu sans mono-bold-r-*-*-10-*-*-*-*-*-*-*";
static const char normbordercolor[] = "#444444";
static const char normbgcolor[] = "#222222";
static const char normfgcolor[] = "#bbbbbb";
static const char selbordercolor[] = "#005577";
static const char selbgcolor[] = "#005577";
static const char selfgcolor[] = "#eeeeee";
@roobie
roobie / .vimrc
Last active August 29, 2015 14:15
my vimrc
" vim:foldmethod=marker:foldlevel=0:foldnestmax=1
" Recommended plugins: {{{
" ag.vim
" badwolf
" ctrlp.vim
" gundo.vim
" npm-debug.log
" supertab
" syntastic
@roobie
roobie / init.el
Created February 26, 2015 21:35
init.el
;; Common Lisp capabilities are nice
(require 'cl)
;; Nice programming font, if supported
(set-frame-font "DejaVu Sans Mono-11")
(setq inhibit-startup-message t) ;; no splash screen
(global-linum-mode 1) ;; always show line numbers