Skip to content

Instantly share code, notes, and snippets.

View aarongeorge's full-sized avatar
🤖

ADG aarongeorge

🤖
View GitHub Profile
@aarongeorge
aarongeorge / crossfadeCSSGenerator.js
Last active October 24, 2017 04:15
Crossfade CSS Generator
var CrossfadeCSSGenerator = function (opts) {
'use strict';
this.opts = opts;
this.animationDuration = this.getAnimationDuration(this.opts.imageShownDuration, this.opts.crossfadeDuration, this.opts.numberOfImages);
this.animationDelay = this.getAnimationDelay(this.opts.imageShownDuration, this.opts.crossfadeDuration);
this.init();
};
@aarongeorge
aarongeorge / get-codecs.js
Last active December 2, 2017 12:04
Get supported audio and video codecs of the browser
/**
* Get Codecs
*
* Usage:
*
* getCodecs() Returns an object with the keys 'audio' and 'video'
* each contain an array of the supported codecs for the browser
*
* Author: Aaron George
* Github: github.com/aarongeorge
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>HTML5 Blank Page</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Styles -->
{
"rules": {
"at-rule-blacklist": [],
"at-rule-empty-line-before": [
"always",
{
"except": [
"after-same-name",
"first-nested"
],
--- Input ---
Game: CS
DPI: 400
Resolution: 3440x1440
Sensitivity: 4
360 Distance: 10.2273 inches
--- Calculated ---
@aarongeorge
aarongeorge / .eslintrc.js
Created April 17, 2019 12:53
My eslint configuration file
module.exports = {
'env': {
'browser': true,
'es6': true,
'node': true
},
'parserOptions': {
'allowImportExportEverywhere': false,
'babelOptions': {
'configFile': './babel.config.js'
@aarongeorge
aarongeorge / RangeGrouping.js
Created August 28, 2019 01:59
Given an array of ranges, group overlapping ranges in an array and return an array of the groups
const ranges = [
{
'start': 6,
'end': 8
},
{
'start': 3,
'end': 6
},
{
@aarongeorge
aarongeorge / JWTPayloadExample.js
Last active November 2, 2019 08:13
Example of a JWT Payload with all Registered Claims
const timeNow = new Date()
const payload = {
iss: 'http://backend.com', // Issuer - Identifier of who provided this JWT
sub: 'uniqueIdOfUser', // Subject - Who is supposed to be using this JWT (The value should mean something for `aud`)
aud: ['http://frontend.com', 'http://backend.com'], // Audience - Who should be consuming this JWT
exp: new Date(new Date(timeNow).setDate(timeNow.getDate() + 7).getTime(), // Expiration Time - When this JWT should no longer be accepted by the `aud`
nbf: timeNow.getTime(), // Not Before - When this JWT should start being accepted by the `aud`
iat: timeNow.getTime(), // Issued At - When this JWT was issued
jti: 'uniqueIdForThisJWT' // JWT ID - Unique ID that the `aud` can use to blacklist/whitelist the JWT even if `exp` and `nbf` requirements are met
@aarongeorge
aarongeorge / modifyDate.ts
Last active April 6, 2020 00:42
Modify JavaScript Date - Add and/or Subtract Years, Months, Weeks, Days, Hours, Minutes, Seconds and Milliseconds
const modifyDate = (date: Date, options: {[key in 'years' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds']?: number} = {}) => {
const modifiedDate = new Date(date)
if (options.years) modifiedDate.setFullYear(modifiedDate.getFullYear() + options.years)
if (options.months) modifiedDate.setMonth(modifiedDate.getMonth() + options.months)
if (options.weeks) modifiedDate.setDate(modifiedDate.getDate() + options.weeks * 7)
if (options.days) modifiedDate.setDate(modifiedDate.getDate() + options.days)
if (options.hours) modifiedDate.setHours(modifiedDate.getHours() + options.hours)
if (options.minutes) modifiedDate.setMinutes(modifiedDate.getMinutes() + options.minutes)
if (options.seconds) modifiedDate.setSeconds(modifiedDate.getSeconds() + options.seconds)
@aarongeorge
aarongeorge / invisible-code-generator.js
Last active April 6, 2020 00:54
A code generator that takes Javascript and compiles it to ASCII Control Characters that are not visible, based on Martin Kleppe's "Invisible Code" talk
/**
* Invisible Code Generator
*
* Description:
* A code generator that takes Javascript and compiles it to
* ASCII Control Characters that are not visible
*
* Usage:
* Copy and paste the code into your browsers console
* Then paste the code you wish to convert to "Invisible Code"