Skip to content

Instantly share code, notes, and snippets.

@bhensley
bhensley / TwoWayMap.js
Created March 20, 2019 15:52
Two Way Mapping via Map Object in JavaScript
class TwoWayMap {
constructor(map) {
this.map = map;
this.reverseMap = new Map();
this.map.forEach((val, key) => {
this.reverseMap.set(val, key);
});
}
@bhensley
bhensley / spin-me-right-round.html
Created November 6, 2018 21:30
Toying around with gradients and spinning them; turns out jQuery's css() function will correct (?) rules... 181deg was autocorrected to 1deg, so had to interact via the style access.
<!DOCTYPE html>
<html>
<head>
<title>Spinny Spin Spin</title>
<style>
body { overflow: hidden; }
#rotate-me { width: 100vw; height: 100vh; }
</style>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E=" crossorigin="anonymous"></script>
<script>
@bhensley
bhensley / windows_install_date.vbs
Created June 2, 2014 12:21
Check the registry for the known install date of a Windows system and output via InputBox (for easy copying). I never thought I'd be thankful for having learned Visual Basic a decade ago...
Dim shell, val, regKey
On Error Resume Next
' UNIX time of OS installation
regKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate"
' Invoke WScript and read the key
Set shell = CreateObject("WScript.Shell")
val = shell.RegRead(regKey)
@bhensley
bhensley / datatype_check.rb
Last active August 29, 2015 14:01
Ruby Data Type Checking: Little metaprogramming fun
##
# Provides functionality for checking if given object is of a specific data type.
# ---
# Currently supporting the following data types:
# * Array
# * String
# * Integer
#
# = Example
# users = ['jack', 'joe', 'john', 'anotherJname']
@bhensley
bhensley / dot_notation_config.class.php
Last active August 29, 2015 14:01
Dot Notation Configuration with PHP. Builds and remembers configuration details across sessions (stored to disk). Configuration can be nested as deep as desired.
<?php
namespace HensleyDev\Utility;
use Exception;
class DotNotationConfig
{
/**
* Contains the configuration details (assoc. array).
* [configuration] =>