Skip to content

Instantly share code, notes, and snippets.

@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 / .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 / .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 / .gitignore
Last active August 11, 2017 13:27
My standard .gitignore
# Mac OSX Files
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
@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++) {
/*
* 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: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:
@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: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: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