Skip to content

Instantly share code, notes, and snippets.

@illucent
illucent / utils.sh
Created January 31, 2016 19:28
Bash Utilities
#!/bin/bash
(( 0 )) && { #
echo
}
(( 1 )) && { #
# Something of a shot in the dark, but when we had a server with a high
# load average where nothing obvious was causing it, it turned out to be
@illucent
illucent / messy-async-with-callbacks.js
Created January 30, 2016 11:33 — forked from briancavalier/messy-async-with-callbacks.js
Messy async handling of error conditions
function thisMightFail(callback, errback) {
xhrGet('/result', callback, errback);
}
function recoverFromFailure(callback, errback) {
recoverAsync(
function(result) {
if(callback) {
try {
@illucent
illucent / cheatsheet-markdown.md
Created January 28, 2016 16:06 — forked from james2doyle/cheatsheet-markdown.md
a markdown cheatsheet showing all the elements and syntax. Stolen from the Mou.app for OSX http://mouapp.com/

Mou

Mou icon

Overview

Mou, the missing Markdown editor for web developers.

Syntax

@illucent
illucent / ajax_setup.js
Created January 23, 2016 14:27 — forked from alanhamlett/ajax_setup.js
Sets the X-CSRFToken header for every jQuery ajax non-GET request to make CSRF protection easy. This fixes the example from Django docs here: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (settings.type == 'POST' || settings.type == 'PUT' || settings.type == 'DELETE') {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
@illucent
illucent / getDomainName.js
Created January 22, 2016 13:08 — forked from tahirm/getDomainName.js
Get complete domain name with protocol and port if available. #js #url From http://stackoverflow.com/questions/6941533/javascript-get-protocol-domain-and-port-from-url
var domain = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port : '');
@illucent
illucent / .gitignore
Created January 22, 2016 00:17 — forked from olooney/.gitignore
worked examples of argparse and python logging
logs/
@illucent
illucent / chart.html
Created January 21, 2016 12:22 — forked from eyeseast/chart.html
Code from my post on responsive bar charts.
<div id="chart">
<h4>Percent of adults over 25 with at least a bachelor's degree:</h4>
<p><strong>Median:</strong> <span class="median"></span></p>
<small>Source: <cite><a href="http://census.gov">U.S. Census Bureau</a></cite>, via <cite><a href="http://beta.censusreporter.org/compare/01000US/040/table/?release=acs2011_1yr&table=B15003">Census Reporter</a></cite></small>
</div>
@illucent
illucent / dynv6.sh
Created January 17, 2016 21:47 — forked from corny/dynv6.sh
Update script for dynv6.com to set your IPv4 address and IPv6 prefix
#!/bin/sh -e
hostname=$1
device=$2
file=$HOME/.dynv6.addr6
[ -e $file ] && old=`cat $file`
if [ -z "$hostname" -o -z "$token" ]; then
echo "Usage: token=<your-authentication-token> [netmask=64] $0 your-name.dynv6.net [device]"
exit 1
fi
@illucent
illucent / cyrillic2latin_file_renamer.py
Created January 14, 2016 22:34 — forked from ramanqul/cyrillic2latin_file_renamer.py
Cyrillic to Latin File Changer
#!/usr/bin/python
# -*- coding: utf-8 -*-
from os import walk, rename, unlink, mkdir, remove
from os.path import isdir, exists
from sys import argv, exit, getfilesystemencoding
from shutil import copyfile
import shutil
conversion = {