Skip to content

Instantly share code, notes, and snippets.


Andrew sincarne

  • Toronto, ON, Canada
View GitHub Profile
sincarne / getUrlParameter.js
Created Aug 14, 2018
Returns the value when given the key
View getUrlParameter.js
// From:
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(;
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
sincarne / gist:f20bb2445f6bfc1f599262d611031383
Created Jun 27, 2018
Trying to run apt upgrade on a brand new Cloud at Cost Ubuntu 16 server.
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
sincarne /
Created Jun 15, 2018
Shell function to start a server
# 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
php -S localhost:"$@"
sincarne /
Created Oct 19, 2016
Turn Trello cards into Habitica tasks; remove cards
# 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', '')

Keybase proof

I hereby claim:

  • I am sincarne on github.
  • I am awhite ( on keybase.
  • I have a public key whose fingerprint is 03D6 1681 2C68 6546 EE75 AF41 6C97 1EA3 6A19 6532

To claim this, I am signing this object:

View gist:ec19ed30e34402fcac22
function isHighContrast() {
var e, c;
//Create a test div
e = document.createElement("div");
//Set its color style to something unusual = "rgb(31,41,59)";
//Attach to body so we can inspect it
View index.html
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="">
sincarne / 0_reuse_code.js
Created Mar 13, 2014
Here are some things you can do with Gists in GistBox.
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
sincarne / gist:3868339
Created Oct 10, 2012
Validate a Canadian postal code with JQuery Validation
View gist:3868339
// Validate a Canadian postal code with JQuery Validation
// Use with
// 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