Skip to content

Instantly share code, notes, and snippets.

View Lewiscowles1986's full-sized avatar
🤓

Lewis Cowles Lewiscowles1986

🤓
View GitHub Profile
@Lewiscowles1986
Lewiscowles1986 / _config.yml
Created June 23, 2015 02:38
Jekyll Content Sections - Port of CD2 content-sections WordPress Plugin
# Find your Start of collections
collections:
content-sections:
output: true
title: Content Sections
# Continue with other collections
@Lewiscowles1986
Lewiscowles1986 / rand.js
Last active October 29, 2015 22:12
JavaScript Random Numbers
function rand( min, max ) {
var seed = Math.random();
if( typeof min != 'number' && typeof max != 'number' ) {
return seed; // default is just random
} else if( typeof min == 'number' && typeof max != 'number' ) {
return Math.round( seed * min );
} return Math.floor( seed * max ) + min;
}
//
# Email SQLite Backup Hack
# 2015
# Lewis Cowles
# Nasty Python 2.7 Compatible E-Mail Backup (Once done)
import imaplib, email, sqlite3
from email.utils import *
from datetime import datetime
# Setup DB
@Lewiscowles1986
Lewiscowles1986 / app.py
Last active May 14, 2017 17:46
Python Flask REST server (Works for me on 2.7 & 3.4. 2.7 used to run tests)
from flask import Flask
from flask import g, abort, redirect, Response, request
import json
import sqlite3
import datetime
app = Flask(__name__)
@app.before_request
@Lewiscowles1986
Lewiscowles1986 / FDAcc.py
Last active May 7, 2018 05:22
Python Dict / Multi-Dict to allow semantic structural nesting of formdata
# FormData / Flat-to-Structured Dictionary Accessories For Python
# Copyright (C) 2015 Lewis Cowles
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@Lewiscowles1986
Lewiscowles1986 / get_otto.sh
Created October 4, 2015 16:17
Ubuntu Otto
#!/bin/sh
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" > /etc/apt/sources.list.d/virtualbox.list'
sudo apt-get update -y
sudo apt-get install -y dkms unzip virtualbox-5.0 vagrant
wget https://dl.bintray.com/mitchellh/otto/otto_0.1.1_linux_amd64.zip -O otto.zip
unzip otto.zip
rm otto.zip
mv otto /usr/local/bin/otto
@Lewiscowles1986
Lewiscowles1986 / Vagrantfile
Last active November 23, 2022 12:36
Magento 2 (Stable) Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "debian/jessie64"
config.vm.network "private_network", ip: "10.0.0.7"
config.vm.hostname = "magento2.local"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
@Lewiscowles1986
Lewiscowles1986 / mariadb-install
Created October 13, 2015 20:32
MySQL (MariaDB) secure provision
#!/bin/bash
# Root Check
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
apt-get install -qq expect
@Lewiscowles1986
Lewiscowles1986 / scalar-pad.js
Last active November 7, 2015 11:55
JavaScript Padding numbers & strings
"use strict";
String.prototype.pad = function( len, c, left ) {
var s = '',
c = ( c || ' ' ),
len = Math.max( len, 0 ) - this.length,
left = ( left || false );
while( s.length < len ) { s += c };
return ( left ? ( s + this ) : ( this + s ) );
}
Number.prototype.pad = function( len, c, left ) {
@Lewiscowles1986
Lewiscowles1986 / rPiJessie4GB-p1.sh
Last active November 7, 2015 16:14
Resizing 8GB Jessie rPi image to 4GB
#!/bin/bash
# Root Check
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Get rid of Wolfram
sudo apt-get purge wolfram-engine