Skip to content

Instantly share code, notes, and snippets.

View SethVandebrooke's full-sized avatar

Seth Vandebrooke SethVandebrooke

View GitHub Profile
function random(a, b) {
if(Array.isArray(a)){
return a[random(a.length)];
}
if (typeof a === "object") {
var key = random(Object.keys(a));
return b === "key" ? key : b === "both" ? {key:key,value:a[key]} : a[key];
}
if (typeof a === "string" && !!a) {
return (a.toLowerCase() === "bool") ? (Math.floor(Math.random()*2) == 1) : random(a.split(''));
@SethVandebrooke
SethVandebrooke / SymetricEncryption.js
Created December 7, 2019 17:17
Symetric Encryption
function SymetricEncryption(chars) {
var self = this;
self.alphabet = chars || "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890!@#$%^&*()_+-=`~[]\\{}|;':\",./<>? ";
function gc(pos) {
pos = pos % self.alphabet.length;
return self.alphabet[pos >= 0 ? pos : pos + self.alphabet.length];
}
@SethVandebrooke
SethVandebrooke / RollingCypher.js
Created September 27, 2019 14:59
Encrypt and decrypt text with a password and this simple yet effective cypher
function RollingCypher() {
var chars = " qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890!@#$%^&*()_+-=[]\\{}|;':\",./<>?`~\t\r\n";
chars = chars.concat(chars.concat(chars));
function encrypt(s, p) {
var o = "";
s = s.split('');
p = p.split('');
for (var i = 0; i < s.length; i++) {
o += chars[chars.indexOf(s[i]) + chars.indexOf(p[i % p.length])];
@SethVandebrooke
SethVandebrooke / formGenerator.js
Created May 6, 2019 14:13
Generate Form DOM Element
function generateFormDOMElement(name, action, method, fields) {
var form = document.createElement("form");
form.name = name;
form.action = action;
form.method = method;
for (var name in fields) {
var attributes = fields[name];
var field = document.createElement("input");
field.id = name;
field.name = name;
@SethVandebrooke
SethVandebrooke / formcontrol.css
Last active May 2, 2019 15:31
Form input stylesheet
.form-control {
padding: 8px;
margin: 5px;
width: 200px;
border: solid;
border-radius: 5px;
border-width: 1px;
border-color: #ccc;
box-shadow: inset 0px 0px 2px #ccc;
}
@SethVandebrooke
SethVandebrooke / inputs.js
Last active April 30, 2019 20:28
Manage user input with little to no set up
/*
// Get value of input element
// SYNTAX: $IN.elementID
var username = $IN.username();
// Listen for when the value changes
$IN.username.observe(function(value){
console.log("value changed to:" + value);
});
@SethVandebrooke
SethVandebrooke / accomplishments.txt
Created April 9, 2019 18:24
Seth Vandebrooke's career path
age 6: decides to become an inventor
age 7: makes a 10-year plan to start a real estate company
age 8: realizes it won't happen in 10 years
age 9: designs an unrealistic solution for self-sustainable energy
age 10: gets a financial freedom certification and starts investing in the stocks
age 11: writes a report on how video games are made
age 12: builds over 40 video games
age 13: gets an internship as a game developer
age 14: learns how to make websites
@SethVandebrooke
SethVandebrooke / License.txt
Last active February 20, 2019 17:36
Brooke Studios LLC Software License (BSSL)
-----------------------------------------------------------
LICENSE AND COPYRIGHT
-----------------------------------------------------------
Your use of this software is governed by the following
conditions. Please read this before you install the program.
By using this software you are agreeing to the following
conditions:
This software is copyrighted and may not be modified or
included with another product without the express, written
@SethVandebrooke
SethVandebrooke / JSON_to_HTML.js
Last active May 9, 2019 20:46
Convert JSON to HTML and HTML to JSON
/* example use:
// pass JSON string or object
JSON_to_HTML([
{
tagName: "div",
id: "main",
children: [
{
tagName: "h1",
id: "mainTitle",
@SethVandebrooke
SethVandebrooke / .babelrc
Last active February 4, 2019 20:52
Basic Grunt Set Up
{
"presets": ["@babel/preset-env"]
}