Skip to content

Instantly share code, notes, and snippets.


Lucas Bowers LB-Digital

View GitHub Profile
LB-Digital /
Last active December 10, 2019 22:17
A Convolutional neural Network in Python using Keras on TensorFlow
# importing libraries
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense
from keras.preprocessing import image
from keras import backend as K
from keras.models import load_model
import numpy as np
View extract-form-inputs.js
* Returns Object of name:value pairs in .data
* .error will contain invalid input name on Error (e.g: empty required input)
function extractFormInputs( formEl ){
// get all inputs from form
var inputs = formEl.querySelectorAll('input,textarea');
// convert inputs to array
var inputsArr = Array.from(inputs);
LB-Digital / email_regex.txt
Created July 10, 2019 23:58
Email regex for JavaScript, based on
View email_regex.txt
LB-Digital / handler.js
Created June 29, 2019 17:40
AWS DynamoDB simple scan/put operations
View handler.js
// leads/
const uuid = require('uuid');
const AWS = require('aws-sdk');
const IsEmail = require('isemail');
const dynamoDb = new AWS.DynamoDB.DocumentClient();
module.exports.create = function(event, context, callback) {
LB-Digital / get-jwt-payload.js
Created February 12, 2019 18:24
Retrieve the Payload data section of a JSON Web Token.
View get-jwt-payload.js
function getJwtPayload(){
//retrieve JsonWebToken from cookies
var cookies = document.cookie.split(";"),
for (cookie of cookies){
var keyValue = cookie.trim().split('=');
if (keyValue[0] === "jwt"){
jwt = keyValue[1];
LB-Digital / php-url-request.php
Last active February 4, 2019 16:29
Sending URL requests (POST/GET) in PHP using curl
View php-url-request.php
$url = '';
$fields = array(
'key1'=>urlencode('value 1'),
'key2'=>urlencode('value 2'),
'key3'=>urlencode('value 3')
//url-ify the data for the POST
$fields_string = "";
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
LB-Digital / send-pushover-notif.js
Created February 4, 2019 16:13
A function for sending Pushover Notifications ( )
View send-pushover-notif.js
function sendPushoverNotif(token, target, message, title){
message = encodeURIComponent(message); // make url friendly
var xhr = new XMLHttpRequest();"POST", "", true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
LB-Digital / random-int.js
Created December 21, 2018 13:14
Random integer between min, max values
View random-int.js
* Using Math.round() results in an uneven distribution, as mentioned here...
function randomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
LB-Digital / subdomain-basic-auth.js
Created December 12, 2018 21:07
Basic auth header of a subdomain on NodeJS with Express
View subdomain-basic-auth.js
/** Password protect a subdomain on ExpressJS
* Uses HTTP Basic authorization...
* with the WWW-Authenticate header...
* By then checking if the user is visting from the given subdomain, you know they are authorized.
* I use this concept to password protect beta site features that aren't yet released publicly, on which
* certain pages are only accessible via the password protected '' url
const config = {
LB-Digital / Array.prototype.isEqualTo.js
Created October 30, 2018 03:30
An array method to check if one array is equal to another. NOTE: this is only built for simple arrays with singular values, e.g: ['a','b','c'], not complex arrays, e.g: ['a', {this:'that',up:'down'}]
View Array.prototype.isEqualTo.js
Array.prototype.isEqualTo = function(arr2){ // defining the Array method
var arr1 = this; // accesing the first array
if (arr1.length==arr2.length){ // if they have the same length
arr1 = arr1.filter(item=>{ // filter through arr1
if (arr2.indexOf(item) > -1){ // if item from arr1 is in arr2
return false; // remove from arr1 so we know its been accounted for
return true; // keep in arr1 as not in arr2