Skip to content

Instantly share code, notes, and snippets.

View DigitalKrony's full-sized avatar

Adam Sivins DigitalKrony

View GitHub Profile
@DigitalKrony
DigitalKrony / ExtraUtilities.js
Created March 11, 2019 20:24
Some extra handy NodeJS Utilities.
const fs = require('fs');
const http = require('http');
const path = require('path');
class ExtraUtilities {
option (string) {
let procArgs = process.argv.slice(2);
for (let arg of procArgs) {
let firstTwo = arg.substr(0,2);
@DigitalKrony
DigitalKrony / generateKey
Created March 1, 2019 00:47
A simple function that generates an alpha/numeric key
const generateKey = (len=5, options) => {
let generated_key = '';
let config = {
keyCharacters: 'aAbBcCdDeEgFhGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789',
...options
};
if (typeof len === 'object') {
for (let i = 0; i < len.length; i++) {
generated_key += generateKey(len[i]);
// https://gist.github.com/gre/1650294
/*
* Found HERE: https://codepen.io/xerxesnoble/pen/JNgmJR
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
const ease = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
@DigitalKrony
DigitalKrony / animate.js
Created November 28, 2018 20:34
JS animation
/**
* Found HERE: https://codepen.io/xerxesnoble/pen/JNgmJR
* @desc Basic linear value animation that can accept simple easing functions and provides update & complete callbacks
* @param {Object} values - Object with numerical values. eg. { value1: 0, value2: 20, someKey: 55 }
* @param {Number} duration - How long (in milliseconds) the animation will be
* @param {Object} options - target values, update callback & complete callback
* @param {Function} [options.onComplete=(values) => values] - Callback that fires once animation is complete
* @param {Function} [options.onUpdate=(values) => values] - Callback that fires when animation frame updates
* @param {Function} [options.ease=(t) => t] - easing method eg. https://gist.github.com/gre/1650294
* @example
@DigitalKrony
DigitalKrony / obj-addClass.js
Created November 27, 2018 15:36
Adds a class with javascript via Object prototype.
Object.prototype.addClass = function (string) {
var classList = this.className.split(' ');
var classesToAdd = string.split(' ');
for (var toAdd of classesToAdd) {
var index = classList.indexOf(toAdd);
if(index === -1) {
classList.push(toAdd);
}
}
@DigitalKrony
DigitalKrony / obj-removeClass.js
Created November 27, 2018 15:31
It removes a class via javascript via Object prototype.
Object.prototype.removeClass = function (string) {
var classList = this.className.split(' ');
var classesToRemove = string.split(' ');
for (var toRemove of classesToRemove) {
var index = classList.indexOf(toRemove);
if(index !== -1) {
classList.splice(index, 1);
}
}
@DigitalKrony
DigitalKrony / on-circle.scss
Last active November 27, 2018 15:29
A SCSS mixin that places objects on a circle with correct rotation (or not)
@mixin on-circle($item-count: 6, $circle-size: 240px, $item-size: 32px, $rotation-adjust: true) {
position: relative;
width: $circle-size;
min-width: $circle-size;
height: $circle-size;
padding: 0;
border-radius: 50%;
list-style: none;
transform-origin: $circle-size/2 $circle-size/2;