Skip to content

Instantly share code, notes, and snippets.

View davidlonjon's full-sized avatar
🏠
Working from home

David Lonjon davidlonjon

🏠
Working from home
View GitHub Profile
@davidlonjon
davidlonjon / pedantically_commented_playbook.yml
Created January 12, 2016 12:26 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@davidlonjon
davidlonjon / zeropad.js
Last active December 25, 2015 16:39 — forked from s4y/zeropad.js
Javascript: Quick pad
function zeroPad(input, length, character){
var padding = length + 1 - input.length;
return (padding > 0 ? Array(length + 1 - input.length).join(character || '0') + input : input);
};
@davidlonjon
davidlonjon / gist:6519943
Created September 11, 2013 06:23
JavaScript: Module Pattern
var MODULE = (function (ns, undefined) {
ns.publicVariable = 'My module public variable';
privateVariable = 'My module private variable';
ns.publicMethod = function () {
console.log(privateVariable);
};
privateMethod = function () {
@davidlonjon
davidlonjon / gist:6519907
Created September 11, 2013 06:16
JavaScript: Additional Array Prototypes
/**
* Remove value(s) from an array
*
* @return {array} Modified array
*/
if (typeof Array.prototype.remove == 'undefined'
|| typeof Array.prototype.remove == null) {
Array.prototype.remove = function() {
var what, a = arguments, L = a.length, ax;
while (L && this.length) {
@davidlonjon
davidlonjon / gist:6350081
Last active December 21, 2015 18:49
Python: Send Email
def send_mail(sender='', recipients='', subject='', body='', server='localhost', port=25, username='', password=''):
if len(sender) == 0:
return {
'error': True,
'message': "Missing sender email address"
}
if len(recipients) == 0:
return {
'error': True,
@davidlonjon
davidlonjon / gist:6292051
Last active December 21, 2015 10:29
JavaScript: Get Cookie
getCookie = function(cookieName) {
var r = document.cookie.match("\\b" + cookieName + "=([^;]*)\\b");
return r ? r[1] : undefined;
};
@davidlonjon
davidlonjon / gist:6292014
Created August 21, 2013 08:58
JavaScript: Get URL Parameter
// Taken from:
// http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery
getURLParameter = function(paramName) {
return decodeURIComponent((new RegExp('[?|&]' + paramName + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
};
/* Flatten das boostrap */
.well, .navbar-inner, .popover, .btn, .tooltip, input, select, textarea, pre, .progress, .modal, .add-on, .alert, .table-bordered, .nav>.active>a, .dropdown-menu, .tooltip-inner, .badge, .label, .img-polaroid {
-moz-box-shadow: none !important;
-webkit-box-shadow: none !important;
box-shadow: none !important;
-webkit-border-radius: 0px !important;
-moz-border-radius: 0px !important;
border-radius: 0px !important;
border-collapse: collapse !important;
background-image: none !important;
#!/bin/bash -ex
# Paste this into ssh
# curl -sL https://gist.github.com/gists/2913223/download | tar -xzO | /bin/bash -ex
# When forking, you can get the URL from the download button.
pushd $HOME
aptget='sudo apt-get'
chsh='sudo chsh'
%pseudo-content-before {
position: relative;
&:before {
content: " ";
position: absolute;
display: block;
}
}
%pseudo-content-after {