Skip to content

Instantly share code, notes, and snippets.

View KoryNunn's full-sized avatar

Kory Nunn KoryNunn

View GitHub Profile
@KoryNunn
KoryNunn / time.js
Created November 29, 2022 02:03
function performance timing wrapper
function time(fn) {
return async (...args) => {
const stack = new Error().stack.split('\n').slice(1, 5).join('\n');
const start = performance.now();
const result = await fn(...args);
const end = performance.now();
performance.measure(`${fn.name}:\n${stack}`, { start, end });
return result;
@KoryNunn
KoryNunn / ArrayReduce.js
Created July 20, 2021 10:36
Array.reduce
/*
For each item in the array,
pass the item into a function with the last value returned from the function.
If it's the first item, pass the second parameter (starting value) to reduce in.
If no starting value is passed, use the first item in the array, and skip to the second.
If no staring value is passed, and the array is empty, throw an error.
*/
function reduce(yourFunction, startingValue) {
var items = this;
@KoryNunn
KoryNunn / handshake-airdrop.md
Last active March 12, 2024 07:03
Handshake airdrop for github users.

Had 15 github followers in 2019? You can get about $4kAUD of crypto for minimal effort.

Explain this scam

That's legitimately a good default position to hold, however, in this case, the free money is a function of time, and not only charity.

In February 2020, in order to promote Handshake (HNS) to developers, an airdrop was offered to any Github user with more than 15 followers. The Airdrop would give you 4246HNS, at the time worth around at $0.08USD per coin, for a total of $339.68USD, pretty generous!

Today, 4246HNS is worth around $4000 dollarydoos, and there are plenty of github users who haven't claimed theirs.

@KoryNunn
KoryNunn / tsconfig.json
Created December 23, 2020 04:13
Vanilla JS typechecking
{
"compilerOptions": {
"lib": ["es2017", "dom", "es2019.object", "dom.iterable"],
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": false,
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": true,
"noImplicitThis": false,
@KoryNunn
KoryNunn / toast.html
Last active May 23, 2019 05:26
no js toast
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
@keyframes toast {
0% {
opacity: 1
function update(account, id, schemaData, callback){
schemaData.companyId = account.companyId;
kgo
({
account: account,
id: id,
data: schemaData
})
function getValue(){
return new Promise(function(resolve, reject){
reject('fail');
});
}
function doX(){
var x = getValue();
return new Promise(function(resolve, reject){
setTimeout(function(){
@KoryNunn
KoryNunn / package.json
Created June 13, 2018 00:28
Reference modules by root path in node
"scripts": {
"linkClient": "mkdir -p ./client/node_modules/ && ln -s ../ ./client/node_modules/^",
"linkServer": "mkdir -p ./server/node_modules/ && ln -s ../ ./server/node_modules/^",
var things = righto(function(done){
//Something async
setTimeout(function(){
done(null, 1);
}, 100);
})
var stuff = righto(function(done){
@KoryNunn
KoryNunn / speed-tweeter.js
Created February 9, 2018 10:35
Auto tweet speedtest.net results.
var speedTest = require('speedtest-net');
var TweetIt = require('tweetit');
var creds = require('./creds');
var tweetit = new TweetIt(creds.consumerKey, creds.consumerSecret, creds.accessToken, creds.accessTokenSecret);
speedTest({maxTime: 5000}, (error, data) => {
if(error){
return;
}