Skip to content

Instantly share code, notes, and snippets.

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

Joe Wright joewright

🕶️
🤳 🌭
View GitHub Profile
@joewright
joewright / naughty-bois.txt
Created June 18, 2018 18:07
Common unicode characters/smart quotes from google drive that bust things
@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 / 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 / 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 / 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 / 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 / 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 / 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 / query-selector-logger.js
Last active February 20, 2018 15:23
log a unique jQuery selector for every element clicked on a page
// requires jQuery https://code.jquery.com/jquery-1.11.3.js
window.events = [];
$('body').click(function(event) {
//use event.target with firefox
var selector = fromHTMLElement(event.toElement || event.target);
window.events.push(selector);
console.log(selector, $(selector));
});
function fromHTMLElement(srcElement) {
@joewright
joewright / ng-editable-multieselect.html
Created April 19, 2017 20:31
proof of concept for an angular form with an editable multiselect input
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="Demo project">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css"></style>