Skip to content

Instantly share code, notes, and snippets.

View vandorjw's full-sized avatar

Joost van Dorp vandorjw

View GitHub Profile
@vandorjw
vandorjw / jquery.formset.js
Created August 17, 2015 17:28
jquery.formset.js
;(function($) {
$.fn.formset = function(opts)
{
var options = $.extend({}, $.fn.formset.defaults, opts),
flatExtraClasses = options.extraClasses.join(' '),
totalForms = $('#id_' + options.prefix + '-TOTAL_FORMS'),
maxForms = $('#id_' + options.prefix + '-MAX_NUM_FORMS'),
childElementSelector = 'input,select,textarea,label,div',
$$ = $(this),
@vandorjw
vandorjw / notes.txt
Created August 31, 2015 13:10
OS X Niceties - bashrc and other things
##
# .bashrc
##
export PGDATA='/usr/local/var/postgres'
export PGHOST=localhost
alias start-pg='pg_ctl -l $PGDATA/server.log start'
alias stop-pg='pg_ctl stop -m fast'
alias show-pg-status='pg_ctl status'
alias restart-pg='pg_ctl reload'
@vandorjw
vandorjw / sync.sh
Last active January 22, 2016 23:59
#!/bin/sh
# -- ********************************************************************************
# -- Description: Monitoring and sync script for identical remote folders
# -- Version: 0.1
# -- Notes: Ony the folder on the server on which this script resides incurs
# changes. Therefor, we only sync 1 way.
# -- Requires: incron: sudo apt-cache search incron
# using incrontab -e add the following:
# /path/to/folder IN_CLOSE_WRITE /path/to/this/scrip.sh $@/$#
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
@vandorjw
vandorjw / is_null.js
Created March 26, 2016 19:06
Javascript - Check if variable is null
/* * *
* takes any object as input and checks whether it's value is null.
* null is the only primitive value that is 'falsy' but also returns
* "object" from the typeof check.
*/
function is_null(obj) {
return (!obj && typeof obj === "object");
}
// oops, this would throw an error!
if (DEBUG) {
console.log( "Debugging is starting" );
}
// this is a safe existence check
if (typeof DEBUG !== "undefined") {
console.log( "Debugging is starting" );
}
@vandorjw
vandorjw / node_version_manager.txt
Created June 22, 2016 03:40
Node version management, without effecting system files.
The way I like to do it is:
1. Unpack the official pre-built binaries into ~/.node (.e.g https://nodejs.org/dist/v0.12.7/node-v0 … x64.tar.gz would be unpacked in ~/.node/node-v0.12.7-linux-x64
2. Add a symlink called current to your wanted node version (e.g. ln -s ~/.node/node-v0.12.7-linux-x64 ~/.node/current)
3. Add ~/.node/current/bin to your path (e.g echo export PATH=$HOME/.node/current/bin:$PATH >> ~/.bashrc)
This way you can just type npm install whatever and it's installed into your local npm version that you have symlinked under ~/.node/current.
If you want to change the version you're using, just point the symlink somewhere else.
Recorded from: https://bbs.archlinux.org/viewtopic.php?pid=1556844#p1556844
# file: ~/.profile
case $- in
*i*)
# Interactive session. Try switching to bash.
if [ -z "$BASH" ]; then # do nothing if running under bash already
bash=$(command -v bash)
if [ -x "$bash" ]; then
export SHELL="$bash"
exec "$bash"
#!/bin/bash
# -- ********************************************************************************
# -- Description: Example case statements
# -- Version: 0.1
# -- ********************************************************************************
case "$1" in
hello)
echo 'hello'
;;
The air smells of rhubarb, occasional
Roses, or first birth of blossoms, a fresh,
Undulant hurt, so body snaps and curls
Like flower. I step through snow as thin as script
Watch white stars spin dizzy as drunks, and yearn
To sleep beneath a patchwork quilt of rum.
I want the slow, sure collapse of language
Washed out by alcohol. Lovely Shelley,
I have no use for measured, cadenced verse
If you won’t read. Icarus-Iike, I’ll fall