Skip to content

Instantly share code, notes, and snippets.

View jonchurch's full-sized avatar
♥️

Jon Church jonchurch

♥️
View GitHub Profile
@jonchurch
jonchurch / 404.txt
Created January 23, 2020 05:52
404'd links on expressjs.com
404 - http://nodesecurity.io/advisories/send-directory-traversal
found on:
expressjs.com/ko/advanced/security-updates.html
expressjs.com/de/advanced/security-updates.html
expressjs.com/th/advanced/security-updates.html
expressjs.com/zh-tw/advanced/security-updates.html
expressjs.com/fr/advanced/security-updates.html
expressjs.com/ru/advanced/security-updates.html
expressjs.com/tr/advanced/security-updates.html
expressjs.com/en/advanced/security-updates.html
@jonchurch
jonchurch / faveTalks.md
Last active October 11, 2019 02:17
My Fave JavaScript Talks ✨

My Fave JavaScript Talks ✨

To make NodeJS successful, we need everyone's help. And everyone isn't here.

This talk had a huge impact on me when I was still working in restaurants, listening to podcasts and talks during my shifts, and learning to code at night. Although I'm more privileged than many, I have no college degree and come from a background and industry completely different than most folks in tech. I never dreamt that I could be able to work with the Node.js collaborators. Watching this talk gave me hope that not only could I one day be welcome in the Node community, but that I could be valuable to it. Seeing that people were fighting to create a community that I could participate in moved me so much, and planted a seed in my head which is now bearing fruit after years of hard work. Thank you, Ashley!

Rewatching this talk now is crazy for me, because I see faces in it that I have met and had lovely conv

@jonchurch
jonchurch / instanceOfArrow.js
Created August 19, 2019 18:46
Using instanceof without throwing on arrow functions
const arrow = () => true;
class ExampleClass {}
const classInst = new ExampleClass();
// this throws
try {
classInst instanceof arrow;
} catch (err) {
console.log("arrow has no prototype", err);
}
@jonchurch
jonchurch / chonkArray.js
Created July 23, 2019 21:35
Array Chonk (Array chunking)
function chonkArray(array, chonkSize) {
let arrayOfChonks = [];
for (let i = 0; i < array.length; i += chonkSize) {
const chonk = array.slice(i, i + chonkSize);
arrayOfChonks.push(chonk);
}
return arrayOfChonks;
}
const chonkable = ["🍕","🐡","🍝","🐙","✨"]
@jonchurch
jonchurch / for_of.js
Last active December 29, 2019 09:43
Experimenting with sequential iteration using async/await
const array = [1, 2, 3];
function sleep(nSeconds) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(nSeconds), nSeconds * 1000);
});
}
async function run() {
for (const interval of array) {
@jonchurch
jonchurch / yoda.js
Last active February 28, 2023 03:22
Yoda style eslint rule example code
/*eslint yoda: "error"*/
const youveBecome = "powerful";
if ("powerful" === youveBecome) {
// yoda style
// value comes before variable
}
if (youveBecome === "powerful") {
// non-yoda
const fs = require("fs");
const { Tail } = require("tail");
const { EventEmitter } = require("events");
const JSON_FILE = "./theFile.json";
const controller = new EventEmitter();
const Services = {};
// controller.on("test", payload => console.log(`This is a test: ${payload}`));
// api/stream.js
import historyProvider from './historyProvider.js'
// we use Socket.io client to connect to cryptocompare's socket.io stream
var io = require('socket.io-client')
var socket_url = 'wss://streamer.cryptocompare.com'
var socket = io(socket_url)
// keep track of subscriptions
var _subs = []
export default {
@jonchurch
jonchurch / ec2_setup.sh
Last active January 5, 2020 08:49
Setup a fresh EC2 with docker, zsh, and my dot files
#!/bin/bash
yum update -y
yum install -y git zsh docker
service docker start
usermod -a -G docker ec2-user
// Install nvm, node, and npm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
. ~/.nvm/nvm.sh
@jonchurch
jonchurch / ShareholderOrg.sol
Created January 16, 2018 04:38 — forked from anonymous/ShareholderOrg.sol
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&gist=
pragma solidity ^0.4.19;
contract owned {
address public owner;
function owned() {
owner = msg.sender;
}
modifier onlyOwner {