Skip to content

Instantly share code, notes, and snippets.

View SethVandebrooke's full-sized avatar

Seth Vandebrooke SethVandebrooke

View GitHub Profile
@SethVandebrooke
SethVandebrooke / TinyPS.js
Last active April 5, 2019 12:56
A super simple pubsub utilizing javascript sets
function TinyPS() {
var listeners = new Set();
return {
pub: (...args) => Array.from(listeners).forEach(listener => listener(...args)),
sub: listener => listeners.add(listener) && listener,
unsub: listener => listeners.delete(listener),
wipe: () => listeners.clear()
};
}
@SethVandebrooke
SethVandebrooke / EventSystem.js
Created December 3, 2018 21:25
Useful PubSub with awesome namespace support.
function EventSystem(){
var events = {};
var event = function () {
var nameSpaces = Array.from(arguments);
var single = nameSpaces.length === 1;
var eventName = nameSpaces.join("/");
if(!events.hasOwnProperty(eventName)){
events[eventName]=[];
}
return {
@SethVandebrooke
SethVandebrooke / IIDCR.js
Created November 21, 2018 19:22
Iterative Integer Directory Creation and Restoration
const fs = require("fs");
function logError(msg,data) {
console.log("Error: "+msg,data||"");
}
var path = process.argv[2];
var num1 = process.argv[3];
var num2 = process.argv[4];
var num3 = process.argv[5];
@SethVandebrooke
SethVandebrooke / randomRythem.js
Created November 2, 2018 14:06
Random Rythem Generator
var generateRandomRythem = (weight) => {
let hit = "x", rythem = "--------".split("");
for (let i = 0; i < ( weight || 4 ); i++) {
rythem[Math.floor(Math.random()*rythem.length-1)] = "x";
}
return rythem.concat(rythem).join("");
}
console.log(generateRandomRythem(6));
@SethVandebrooke
SethVandebrooke / README.md
Last active October 24, 2018 15:40
JavaScript Audio Control API

Audio Control API

Control audio with this slick api for controlling one or many audio tracks at simultaneously.

Audio methods

Audio.play(number:volume)

This method plays the audio track from the current position (default position if not set is 0, the beginning)

Audio.pause()

@SethVandebrooke
SethVandebrooke / sha1hash.vbs
Created October 19, 2018 20:33
Classic ASP / VBScript SHA1 Hashing
function sha1HashString(str)
Dim hexStr, x, aBytes, sha1
aBytes = CreateObject("System.Text.UTF8Encoding").GetBytes_4(str)
set sha1 = CreateObject("System.Security.Cryptography.SHA1Managed")
sha1.Initialize()
aBytes = sha1.ComputeHash_2( (aBytes) )
for x=1 to lenb(aBytes)
hexStr= hex(ascb(midb( (aBytes),x,1)))
if len(hexStr)=1 then hexStr="0" & hexStr
sha1HashString=sha1HashString & hexStr
@SethVandebrooke
SethVandebrooke / MainWindow.xaml
Created October 18, 2018 18:28
generate random basic chord progression
<Window x:Class="TestApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TestApp"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Button Content="Generate progression" HorizontalAlignment="Center" Margin="0,210,0,181" VerticalAlignment="Center" Width="136" RenderTransformOrigin="-0.006,0.236" Click="Button_Click" Height="29"/>
@SethVandebrooke
SethVandebrooke / GMAB.js
Last active September 18, 2018 15:27
GMAB CLI
const fs = require("fs");
var read = path => fs.readFileSync(path, 'utf8'), config;
config = {
path: "./GMAB",
out: "./",
listen: false,
sourcePages: "./src"
@SethVandebrooke
SethVandebrooke / README.md
Last active April 4, 2019 19:09
Automated front end tests

Auto Tester

Nothing super fancy. Just clean, simpel and extendable.

Example test script

TESTER

    .input("#username", "John Doe") // enter username
    .input("#email", randomEmail()) // enter random email
 .wait(1000) // wait for 1 second
Set objFSO = CreateObject("Scripting.FileSystemObject")
Function say(msg)
WScript.Echo(msg)
End Function
Function readFile (filename)
If objFSO.FileExists(filename) Then
Set file = objFSO.OpenTextFile(filename, 1)
readFile = file.ReadAll