Skip to content

Instantly share code, notes, and snippets.

🤓

Lewis Cowles Lewiscowles1986

🤓
Block or report user

Report or block Lewiscowles1986

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
@Lewiscowles1986
Lewiscowles1986 / _config.yml
Created Jun 23, 2015
Jekyll Content Sections - Port of CD2 content-sections WordPress Plugin
View _config.yml
# Find your Start of collections
collections:
content-sections:
output: true
title: Content Sections
# Continue with other collections
@Lewiscowles1986
Lewiscowles1986 / rand.js
Last active Oct 29, 2015
JavaScript Random Numbers
View rand.js
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;
}
//
View email-sqlite.py
# 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
Python Flask REST server (Works for me on 2.7 & 3.4. 2.7 used to run tests)
View app.py
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
Python Dict / Multi-Dict to allow semantic structural nesting of formdata
View FDAcc.py
# 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
View get_otto.sh
#!/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 Jul 18, 2016
Magento 2 (Stable) Vagrant
View Vagrantfile
# -*- 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 Oct 13, 2015
MySQL (MariaDB) secure provision
View mariadb-install
#!/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 Nov 7, 2015
JavaScript Padding numbers & strings
View scalar-pad.js
"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 Nov 7, 2015
Resizing 8GB Jessie rPi image to 4GB
View rPiJessie4GB-p1.sh
#!/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
You can’t perform that action at this time.