Skip to content

Instantly share code, notes, and snippets.

@bitboxx
bitboxx / gist:8936109
Created February 11, 2014 14:44
Javascript: Run a function after resize event has ended
// the function is only run after the resize has ended
var timeout;
window.onresize = function(){
clearTimeout(timeout);
timeout = setTimeout(function () {
// do wonderful things here
@bitboxx
bitboxx / gist:9052195
Created February 17, 2014 15:02
D3.js functions / API
From: https://github.com/mbostock/d3/wiki/API-Reference
d3 (core)
Selections
d3.select
select an element from the current document.
d3.selectAll
@bitboxx
bitboxx / gist:9583736
Created March 16, 2014 14:05
CSS: Reset element's css back to the original properties (Handy for embedding content in other (differently styled) websites)
/* reset certain element to basic styling */
/* source: http://stackoverflow.com/questions/15901030/reset-remove-css-styles-for-element-only */
/* CSS3 way */
.reset-this {
all: unset;
}
@bitboxx
bitboxx / gist:16b9985bbe1232c07086
Created November 27, 2014 09:39
Standard Javascript function template
// This function does the following:
// + Thing 1
// + Thing 2
// + Thing 3
//
// It takes the following parameters:
// + Parameter 1
// + Parameter 2 (Optional)
//
// It returns:
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@bitboxx
bitboxx / gist:6d6cd6ab20ce55ac0e01
Created March 12, 2015 12:48
Quick string hashing Javascript function
// This is a modified version of similar functions found here:
// http://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery
// http://jsperf.com/hashing-strings
String.prototype.hash = function () {
var res = 0,
len = this.length;
for (i = 0; i < len; i++) {
@bitboxx
bitboxx / .tmux.conf
Last active August 29, 2015 14:17
My TMUX configuration
# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
# clock
set-window-option -g clock-mode-colour green #green
# reload config
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."
@bitboxx
bitboxx / .run-tmux.sh
Last active August 29, 2015 14:17
Shell command to run TMUX on login
#!/bin/bash
# add the following in ~/.config/fish/config.fish
# ~/.run-tmux.sh
# TMUX
if which tmux >/dev/null 2>&1; then
#if not inside a tmux session, and if no session is started, start a new session
test -z "$TMUX" && (tmux -2 attach || tmux -2 new-session)
@bitboxx
bitboxx / live-n-die.js
Last active August 29, 2015 14:25
jQuery live() and die() plugin
// jQuery live() and die() plugin for newer version jQuery (version newer than 1.7)
// meant to facilitate gradual upgrade of old jQuery code to a newer version
jQuery.fn.live = function (eventTypes, eventHandler) {
var that = $(this);
$(document).on(eventTypes, that['selector'], eventHandler);
return that;
};
@bitboxx
bitboxx / gist:3938446
Created October 23, 2012 12:17 — forked from omarkj/gist:986613
Lorem Ipsum
orem ipsum dolor sit amet, consectetur adipiscing elit. Etiam feugiat iaculis odio, sit amet gravida est suscipit vitae. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec rutrum, odio blandit malesuada facilisis, nibh nisl varius lacus, vitae pulvinar eros purus tincidunt enim. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Mauris varius mauris sed tellus volutpat pharetra. Duis porta fringilla justo, non suscipit ipsum pretium eu. Morbi consequat dapibus massa eget tempor. Curabitur sed velit nec dolor elementum facilisis. In hac habitasse platea dictumst. Cras vitae justo nec purus iaculis congue. Integer consequat arcu vel ipsum hendrerit facilisis. Sed bibendum diam vitae nulla tincidunt interdum. Maecenas sagittis ligula at ipsum scelerisque a dictum erat pharetra. Cras faucibus gravida vulputate.
Ut eleifend, lectus non viverra dapibus, quam erat dignissim diam, sed porta mauris velit vitae felis. Morbi sit amet ma