Skip to content

Instantly share code, notes, and snippets.

View sincarne's full-sized avatar

Andrew sincarne

  • Toronto, ON, Canada
View GitHub Profile
@sincarne
sincarne / getUrlParameter.js
Created August 14, 2018 18:09
Returns the value when given the key
// 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, ' '));
};
@sincarne
sincarne / gist:f20bb2445f6bfc1f599262d611031383
Created June 27, 2018 18:20
Trying to run apt upgrade on a brand new Cloud at Cost Ubuntu 16 server.
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
sincarne / serve.sh
Created June 15, 2018 13:21
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
else
php -S localhost:"$@"
@sincarne
sincarne / trello2habitica.py
Created October 19, 2016 19:09
Turn Trello cards into Habitica tasks; remove cards
#!/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', '')

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 03D6 1681 2C68 6546 EE75 AF41 6C97 1EA3 6A19 6532

To claim this, I am signing this object:

@sincarne
sincarne / gist:ec19ed30e34402fcac22
Created March 5, 2015 18:39
High Contrast JS test
// 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
@sincarne
sincarne / index.html
Created June 24, 2014 15:08
HTML Skeleton
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
@sincarne
sincarne / 0_reuse_code.js
Created March 13, 2014 23:39
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sincarne
sincarne / gist:3868339
Created October 10, 2012 20:51
Validate a Canadian postal code with JQuery Validation
// 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