Skip to content

Instantly share code, notes, and snippets.

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

Joe Wright joewright

🕶️
🤳 🌭
View GitHub Profile
@joewright
joewright / .npmrc
Created September 4, 2018 14:12
an npmrc file for maximum success
save-exact=true
package-lock=false
@joewright
joewright / sort-it-up.js
Created September 13, 2018 16:34
_.sortBy example
var data = [{
active: false,
lastName: 'johnson'
}, {
active: true,
lastName: 'wow'
}, {
active: false,
lastName: 'awesome'
}, {
@joewright
joewright / stream-it.js
Last active December 19, 2018 19:36
Stream html responses
const http = require('http');
const port = 3000;
const hostname = '127.0.0.1';
const max = 25;
const delay = 200;
const htmlOpen = `
<!DOCTYPE html>
<html>
<head>
@joewright
joewright / Dockerfile
Last active December 20, 2018 18:44
scrape a website with wget
FROM alpine
RUN apk --update add openssl wget && \
# cleanup
rm -rf /var/cache/apk/*
@joewright
joewright / ip-address-range.js
Created December 20, 2018 23:04
ip address range match
console.log('something');
const _ = require('lodash');
const { assert } = require('chai');
const SAMPLE_RULES_BLOCK = [
['103.1.108.1','AU'],
['3.254.254.254','US'],
['5.10.64.17','CN'],
['0.0.0.0-0.12.13.14','FR'],
['209.88.2.2-209.88.2.255','AZ'],
@joewright
joewright / httplib.py
Created February 8, 2019 16:11
Python 3 httplib
import http.client
BAD_REQUEST = http.client.BAD_REQUEST
FORBIDDEN = http.client.FORBIDDEN
FOUND = http.client.FOUND
NOT_FOUND = http.client.NOT_FOUND
OK = http.client.OK
UNPROCESSABLE_ENTITY = http.client.UNPROCESSABLE_ENTITY
@joewright
joewright / _promises.js
Last active February 21, 2019 20:48
minimal promise example
// bare minimum promise implementation
function promise() {
// the promise caller will pass these along in `then`
this.successFn = function() {};
this.errorFn = function() {};
}
promise.prototype.resolve = function(result) {
this.successFn(result);
};
@joewright
joewright / publix-scraper.js
Last active November 22, 2020 17:31
grocery list scraper
const itemClass = 'title clamp-2';
printItems();
function printItems() {
const items = document.getElementsByClassName(itemClass);
const uniq = [];
let output = '';
@joewright
joewright / repository.json
Last active August 27, 2019 19:47
jw-sublime-repository.json
{
"schema_version": "2.0",
"packages": [
{
"name": "Sublime-JSHint-05-2019",
"details": "https://github.com/joewright/Sublime-JSHint",
"releases": [
{
"sublime_text": "*",
"details": "https://github.com/joewright/Sublime-JSHint",
@joewright
joewright / async-await.js
Created August 21, 2019 00:20
Async/await example
asyncAwaitTest();
async function asyncAwaitTest() {
let result1, result2, result3, results;
try {
result1 = promise1();
result2 = promise2();
result3 = promise3();
results = [await result1, await result2, await result3];
} catch(err) {