Skip to content

Instantly share code, notes, and snippets.

Avatar
😅

Luke Karrys lukekarrys

😅
View GitHub Profile
@lukekarrys
lukekarrys / .gitignore
Last active Dec 7, 2019
Playing around with random keys, collisions, and slow lookups
View .gitignore
node_modules/
View constants.js
module.exports = (keys) => new Proxy(
keys.reduce((acc, key) => ((acc[key] = key), acc), {}),
{
get: function(target, name) {
// Since this getter gets called for all keys, some values need to be ignored
if (
// If this proxy gets logged or inspected then name
// could be a symbol or the string inspect
typeof name === 'symbol' ||
name === 'inspect' ||
@lukekarrys
lukekarrys / index.js
Created Aug 21, 2019
Get ultrasignup points based on elapsed times
View index.js
const timeToSeconds = (t) => t
.split(':')
.reverse()
.reduce((acc, value, i) => acc + value * Math.pow(60, i), 0)
const timesToPoints = (...times) => Math.round(times[0] / times[1] * 1000)
const main = (...times) => {
const parsed = times.map(timeToSeconds)
if (parsed.length === 3) {
View .gitignore
node_modules
token.json
db.json
@lukekarrys
lukekarrys / bookmarklet.js
Created Oct 5, 2017
Get percentage of each day of the week with commits from graph.
View bookmarklet.js
javascript:(()=>{const e=["Sun","Mon","Tues","Wed","Thur","Fri","Sat"],r=[...document.querySelectorAll(".js-calendar-graph-svg > g > g")].reduce((e,r)=>[...r.querySelectorAll("rect.day")].reduce((e,r,t)=>(e[t][0]+="0"===r.getAttribute("data-count")?0:1,e[t][1]+=1,e),e),e.map(()=>[0,0])).reduce((r,t,c)=>(r[e[c]]=+(t[0]/t[1]*100).toFixed(3),r),{});console.log(r)})();
@lukekarrys
lukekarrys / bookmarklet.js
Last active Sep 19, 2017
Totals and Winning Percentages for NFL easyofficepools.com
View bookmarklet.js
javascript:(()=>{[...document.querySelectorAll(".n33table tr")].forEach(t=>{const e=t.querySelector("td:first-child span span"),[n,...r]=t.textContent.trim().split(" "),l=r.slice(5).map(t=>t.match(/\d+-\d+-\d+/)).filter(Boolean).map(t=>t[0]);if(l.length>6)return;const o=l.map(t=>t.split("-").map(Number)).reduce((t,[e,n,r])=>(t[0]+=e,t[1]+=n,t[2]+=r,t),[0,0,0]);e.textContent+=` / ${o[0]}-${o[1]}-${o[2]} / ${(o[0]/(o[0]+o[1])).toFixed(3)}`});})()
View README.md

postpass

This is a workaround to tie together one of my custom workflows to an API.

All it does is:

  1. Setup a server that accepts POSTs to /
  2. Pass through any headers
  3. POST any from the data key to the url key
@lukekarrys
lukekarrys / README.md
Last active Oct 5, 2017
MLB Season Streaks
View README.md

mlb-season-streaks

I was curious about the Cubs 2016 season and what it looked liked broken into chunks of 10 games (or some other nuber). I was also curious with how it stacked up against the 2001 Mariners.

Here's how to run it:

npm install
node index 2016-CHC 10
# Then look at the output
@lukekarrys
lukekarrys / README.md
Last active Dec 7, 2016
eslint-plugin-import 2.0.0 newline-after-import rule crash
View README.md
@lukekarrys
lukekarrys / README.md
Last active Mar 20, 2018
ios8-transform-react-inline-elements-with-core-js-shim-bug
View README.md
You can’t perform that action at this time.