Skip to content

Instantly share code, notes, and snippets.

View joewright's full-sized avatar
🕶️
🤳 🌭

Joe Wright joewright

🕶️
🤳 🌭
View GitHub Profile
@joewright
joewright / find-nearest-matches.js
Last active July 14, 2017 14:09
Find closest matches in an array
function findNearestMatches(data, target, windowSize) {
/*
* Find [windowSize] items closest to [target] value
*
* var arr = [0,1,2,3,4,5];
* findNearestMatches(arr, 2, 3)
* -> [1,2,3]
* findNearestMatches(arr, -5, 4)
* -> [0,1,2.3]
*/
@joewright
joewright / Truffles.md
Created January 8, 2018 01:39
Quick solidity test environment via truffle/ganache

Getting Started with Truffle/Ganache

Install Ganache

Then install truffle

npm install --global truffle

Create metacoin example project

@joewright
joewright / web-enhancer.js
Last active February 28, 2018 00:44
Click to spin JS
$('body').prepend('<style>@keyframes spin {from {transform:rotate(0deg);} to {transform:rotate(359deg);} } @keyframes spinrev {from {transform:rotate(0deg);} to {transform:rotate(-359deg);} }</style>');
$('body').click(function(event) {
event.preventDefault();
//use event.target with firefox
var target = event.toElement || event.target;
var spin = (Math.random() < 0.5) ? 'spin' : 'spinrev';
$(target).css('animation', spin + ' 4s infinite linear');
});
@joewright
joewright / scrub-empty-fields.js
Last active April 6, 2018 16:02
js omitValuesRecursive
var dang = {dang: '', haha: '', whoops: undefined, whatever: false, hehe: [{what: '', lol: true, ok: false, wow: {haha: 'false', word: [], up: '', ok: false }, why: 0 }, null, 'lol' - 42] };
function omitValuesRecursive(obj, omittedValues) {
var omittedValues = omittedValues || ['', undefined, null];
if (window._) {
return scrubEmptyFieldsLodash(obj);
}
return scrubEmptyFields(obj);
// recursively remove omitted values from the object. modifies the original object
function scrubEmptyFields(obj) {
@joewright
joewright / tab-panes.html
Created April 16, 2018 21:21
Minimal bootstrap tab panes setup
<!DOCTYPE html>
<html>
<head>
<title>Minimal bootstrap tab pane setup</title>
</head>
<style>
.tab-pane {
display: none;
}
.tab-pane.active {
@joewright
joewright / prototype-example.js
Last active February 27, 2019 15:03
Prototype example
var DB = {};
function Base(data) {
for (var key in data) {
this[key] = data;
}
}
Base.prototype.save = function() {
DB[Math.random().toString()] = this.serialize();
};
@joewright
joewright / reverbnation-shows.js
Last active May 17, 2018 20:38
Reverb nation check upcoming shows
// made this because I got tired of trying to scroll on a website that used this widget.
// only tested on node 10.1.0
'use strict';
var TINROOF_WIDGET_URL = 'https://www.reverbnation.com/widget_code/html_widget/venue_1008205?widget_id=52';
var https = require('https');
// allow optional `--json` arg to just display the json;
var handler = displayData;
if (process.argv[2] === '--json') {
handler = saveJson;
@joewright
joewright / naughty-bois.txt
Created June 18, 2018 18:07
Common unicode characters/smart quotes from google drive that bust things
@joewright
joewright / sort_em.sh
Last active July 19, 2018 02:25
Sort flash drive for car stereo
# list disks
diskutil list
# unmount the unsorted drive
diskutil unmount /dev/disk2s1
# do the thing
fatsort /dev/disk2s1

Keybase proof

I hereby claim:

  • I am joewright on github.
  • I am joewrong (https://keybase.io/joewrong) on keybase.
  • I have a public key whose fingerprint is 52FF 655A 1A00 9554 EC36 B15F D5BE 2B1E B7B6 4823

To claim this, I am signing this object: