Skip to content

Instantly share code, notes, and snippets.

@Richienb
Richienb / lib.js
Last active June 23, 2019 01:13
More secure version of math.random
Math.secureRandom = () => window.crypto.getRandomValues(new Uint32Array(1))[0] / 1e+10
@Richienb
Richienb / lib.js
Created May 4, 2019 06:51
Generate random drama number
Number.prototype.pad = function(size) {
const sign = Math.sign(this) === -1 ? '-' : '';
return sign + new Array(size).concat([Math.abs(this)]).join('0').slice(-size);
}
const dramaNumber = () => `555-01${Math.floor(Math.random() * 100).pad(2)}`
@Richienb
Richienb / getattr.js
Created April 25, 2019 05:40
Get an object of attributes of an element
Object.values(document.querySelector("el").attributes).reduce((p, c) => {
p[c.name] = c.value;
return p;
}, {})
@Richienb
Richienb / sample.sh
Last active April 19, 2019 08:04
Pngcrush all pngs in directory
find . -type f -iname "*.png" -exec pngcrush -reduce -brute -ow {} \;
@Richienb
Richienb / README.md
Last active April 18, 2019 11:21
Selectize Material

Selectize Material

The provided CSS can be used give your Selectize boxes a more material theme.

Example

Converts

Selectize Classic

@Richienb
Richienb / fixgitignore.sh
Created April 3, 2019 10:46
Update Gitignored Files
#!/usr/bin/env bash
git rm -r --cached .
git add .
git commit -m "Fixed Gitignore"
git push
@Richienb
Richienb / umd.common.js
Created March 17, 2019 11:18
UMD Example
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
root.returnExports = factory();
}
}(typeof self !== 'undefined' ? self : this, function () {
@Richienb
Richienb / README.md
Created March 16, 2019 10:13
Mirror a Git repository

Script to mirror a Git repository

Prepare

Installation

cd ~
curl -L -o gitmirror.sh https://gist.githubusercontent.com/Richienb/08164f96e42df573b63c71dc1c3c4267/raw/8a2417bd4afc7ce36d710fb7c3d0c6e95ae40221/gitmirror.sh
chmod 775 gitmirror.sh
@Richienb
Richienb / README.md
Last active March 16, 2019 02:45
Word Counter Bookmarklet

Word Counter Bookmarklet

Drag the link found here to your bookmarks bar to use the word counter

@Richienb
Richienb / README.md
Last active August 8, 2019 06:47
Fix MDC Ripples in MDC Icon Buttons

Fix MDC Ripples in MDC Icon Buttons

Run the provided code after mdc.autoInit()