Skip to content

Instantly share code, notes, and snippets.

Andrew sincarne

Block or report user

Report or block sincarne

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

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

To claim this, I am signing this object:

@sincarne
sincarne / serve.sh
Created Jun 15, 2018
Shell function to start a server
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:"$@"
@sincarne
sincarne / getUrlParameter.js
Created Aug 14, 2018
Returns the value when given the key
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, ' '));
};
@sincarne
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
sincarne / trello2habitica.py
Created Oct 19, 2016
Turn Trello cards into Habitica tasks; remove cards
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', '')
@sincarne
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 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
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="">
@sincarne
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
You can’t perform that action at this time.