This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*------EXTRACT FORM INPUTS------ | |
* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^(?:[a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// leads/read.read | |
'use_strict'; | |
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getJwtPayload(){ | |
//retrieve JsonWebToken from cookies | |
var cookies = document.cookie.split(";"), | |
jwt; | |
for (cookie of cookies){ | |
var keyValue = cookie.trim().split('='); | |
if (keyValue[0] === "jwt"){ | |
jwt = keyValue[1]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$url = 'https://example.com/api.json'; | |
$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.'&'; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendPushoverNotif(token, target, message, title){ | |
message = encodeURIComponent(message); // make url friendly | |
var xhr = new XMLHttpRequest(); | |
xhr.open("POST", "https://api.pushover.net/1/messages.json", true); | |
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
xhr.send(`token=${token}&user=${target}&message=${message}&title=${title}`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Using Math.round() results in an uneven distribution, as mentioned here... | |
* https://stackoverflow.com/questions/1527803/generating-random-whole-numbers-in-javascript-in-a-specific-range | |
*/ | |
function randomInt(min, max) { | |
min = Math.ceil(min); | |
max = Math.floor(max); | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Password protect a subdomain on ExpressJS | |
* Uses HTTP Basic authorization... https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization | |
* with the WWW-Authenticate header... https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate | |
* | |
* 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 'beta.domain.com' url | |
*/ | |
const config = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); | |
NewerOlder