Instantly share code, notes, and snippets.

View getUrlParameter.js
// From: https://davidwalsh.name/query-string-javascript
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
View gist:f20bb2445f6bfc1f599262d611031383
Processing triggers for initramfs-tools (0.122ubuntu8.11) ...
update-initramfs: Generating /boot/initrd.img-4.4.0-62-generic
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.4.0-62-generic with 1.
dpkg: error processing package initramfs-tools (--configure):
subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
View serve.sh
# Add this to your .profile
# Typing `serve` with no arguments will start the PHP inbuilt
# server, listening on port 8000.
# If you provide an argument, that is assumed to be the port
# on which to listen.
function serve() {
if [ $# -eq 0 ]; then
php -S localhost:8000
else
php -S localhost:"$@"
View trello2habitica.py
#!/usr/bin/python
# requires trello, requests, available through pip
from trello import TrelloApi
import json, os, requests, subprocess
HABITICA_USER = os.getenv('HAB_API_USER', '')
HABITICA_KEY = os.getenv('HAB_API_TOKEN', '')
TRELLO_KEY = os.getenv('TRELLO_API_KEY', '')
View keybase.md

Keybase proof

I hereby claim:

  • I am sincarne on github.
  • I am awhite (https://keybase.io/awhite) on keybase.
  • I have a public key whose fingerprint is BD39 2D89 A070 76DF 2AED 62C0 0011 5074 5553 0B2B

To claim this, I am signing this object:

View gist:ec19ed30e34402fcac22
// http://www.paciellogroup.com/blog/2011/10/detecting-if-images-are-disabled-in-browsers/
function isHighContrast() {
var e, c;
//Create a test div
e = document.createElement("div");
//Set its color style to something unusual
e.style.color = "rgb(31,41,59)";
//Attach to body so we can inspect it
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View gist:3868339
// Validate a Canadian postal code with JQuery Validation
// Use with http://docs.jquery.com/Plugins/Validation
// Adding the method
jQuery.validator.addMethod("cdnPostal", function(postal, element) {
return this.optional(element) ||
postal.match(/[a-zA-Z][0-9][a-zA-Z](-| |)[0-9][a-zA-Z][0-9]/);
}, "Please specify a valid postal code.");
// Using the new rule