Skip to content

Instantly share code, notes, and snippets.

Avatar

Gar wraithgar

View GitHub Profile
@wraithgar
wraithgar / promisify.js
Created May 24, 2020
Promisify all the functions in any object with a few lines of es6
View promisify.js
const handler = {
get: function (target, prop, receiver) {
if (typeof target[prop] !== 'function' ) {
return target[prop]
}
return function () {
return new Promise((resolve, reject) => {
Reflect.get(target, prop, receiver).apply(target, [...arguments, function (err, result) {
if (err) {
return reject(err)
@wraithgar
wraithgar / gen.js
Created Jul 7, 2020
quick and dirty password generator
View gen.js
'use strict'
const fs = require('fs')
const words = fs.readFileSync('/usr/share/dict/words', 'utf8').split('\n')
const passwords = []
for (let i = 0; i < 12; i++) {
const randomNumber = Math.floor(Math.random() * words.length)
passwords.push(words[randomNumber])
}
console.log(passwords.join('-'))
@wraithgar
wraithgar / lifecycle.txt
Created Feb 18, 2021
npm7 lifecycle scripts notes
View lifecycle.txt
npm event lifecycle
cache add
- prepare (pacote.tarball.stream @npmcli/run-script)
ci
- preinstall (@npmcli/run-script)
- install (@npmcli/run-script)
- postinstall (@npmcli/run-script)
- prepublish (@npmcli/run-script)
- preprepare (@npmcli/run-script)
@wraithgar
wraithgar / bug.rb
Created Dec 5, 2019
ruby strftime/strptime bug
View bug.rb
require 'date'
Date.strptime(Date.new(2006,1,1).strftime('%U-%Y'), '%U-%Y')
#<Date: 2006-01-01 ((2453737j,0s,0n),+0s,2299161j)>
Date.strptime(Date.new(2000,12,31).strftime('%U-%Y'), '%U-%Y')
#<Date: 2000-12-31 ((2451910j,0s,0n),+0s,2299161j)>
Date.strptime(Date.new(2001,1,7).strftime('%U-%Y'), '%U-%Y')
#<Date: 2001-01-07 ((2451917j,0s,0n),+0s,2299161j)>
Date.strptime(Date.new(2001,1,1).strftime('%U-%Y'), '%U-%Y')
# Traceback
View invisible.js
const clean = 'bullshit';
let dirty = '';
for (const letter of clean) {
const hex = letter.charCodeAt().toString(16);
dirty = dirty + unescape(`%uDB40%uDD${hex}`);
}
console.log(`Clean: ${clean}`);
console.log(`Dirty: ${dirty}`);
console.log(`Stripped: ${unescape(escape(dirty).replace(/u.{8}/g,''))}`);
View gist:a0712ee04368e5ecb9b9706ceccd25ca
ROUND 1
Duke/NC - NC because Duke always reminds me of David Duke and that's a non-starter.
VCU/UCF - UCF. Both remind me of Vets without Borders/ Vets Sans Frontieres so I flipped a coin.
Mississippi State / Liberty - Liberty. Originally I was gonna go w/ mississippi cause it's fun to say but then I tried typing it and I don't want to have to do that again.
Virginia Tech / St Louis - Virginia Tech because there are just too many vowels in Louis and I can NEVER type it right the first try
Maryland / Temple / Belmont - Maryland. Come on Temple / Belmont pick a name.
LSU / Yale - Yale in honor of all the crossword puzzle answers this has provided to me over the years (eli)
Louisville / Minnesota - Minnesota. Oh, ya? Ya, donchaknow
Michigan State / Bradley - Bradley. Duh.
Gonzaga / Fairleigh Dickin... - Fairleigh I have never heard of this college and technically still haven't cause the full name didn't even fit on this site.
@wraithgar
wraithgar / gist:3932326
Created Oct 22, 2012
Sicilian Rhapsody
View gist:3932326
Is this a keystore
Is it in memory?
Caught in an event loop
No escape from reality
Open your append-only file
Confirm it's an rdb
I'm just a poor boy
@wraithgar
wraithgar / meteorology.html
Created Apr 11, 2017
readstuff.online file for meteorology etc
View meteorology.html
<html>
<script>
var go = function(){
\t parent.postMessage(
{"title":"Meteorology etc","description":"Links to great resources for all your meteorological and other planetary science needs","links":[{"url":"https://www.windytv.com/","description":"Windy TV - See what the wind is up to"},{"url":"https://www.wunderground.com/","description":"Weather Underground - Weather data brought to you by weather enthusiasts"},{"url":"https://earthquake.usgs.gov/earthquakes/map/","description":"USGS Earthquake Map - See what's shakin"},{"url":"http://oceanexplorer.noaa.gov/gallery/maps/maps.html","description":"NOAA Ocean Explorer - Find out if it's truly better down where it's wetter"},{"url":"http://volcano.si.edu/reports_weekly.cfm","description":"Global Volcanism Project - Discover what volcanoes were active this week"},{"url":"http://www.cleardarksky.com/","description":"Dark Sky - Astronomical observing conditions for when you want to look up at the infinite universe."}]}, '*')}
</script>
<body onload='go()'/>
View html.txt
<!-- REMARK --> - Allows you to put in your own comments so that if you have
to come back later you can figure out what is going on. No one browsing your
Web page will see this unless they view the source.
Example:<!-- This text Cannot be seen by the user unless the source is viewed. -->
<A> - Allows you to anchor things such as a web page by using the following
<A HREF="Http://www.CompuCure.com">
Example:<A HREF="http://www.CompuCure.com">CompuCure</A>
<ABBREV> - Newer command that is coming out in the new HTML3.0 allows you to
@wraithgar
wraithgar / gist:6431eb458c981fe6c0a8a7ee71754945
Created Aug 15, 2016
async foundation validation example
View gist:6431eb458c981fe6c0a8a7ee71754945
var checkingLogin = false;
var validLogin = true;
var lastCheckedLogin = '';
var checkLogin = Debounce(function (el) {
var code = document.location.search.match(/invite=([^&]*)/);
var val = el.val();
if (code) {
code = code[1];