Skip to content

Instantly share code, notes, and snippets.

View konsumer's full-sized avatar

David Konsumer konsumer

View GitHub Profile
// npm i easymidi esm && node -r esm simple_midi_forwarder.js
import { Input, Output, getInputs, getOutputs } from 'easymidi'
// these are lists of available devices
const inputs = getInputs()
const outputs = getOutputs()
console.log({ inputs, outputs })
@konsumer
konsumer / index.html
Last active December 7, 2019 04:59
Electron Fiddle Gist
<!-- this is the important part: -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/darkly/bootstrap.min.css" media="(prefers-color-scheme: dark)">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/flatly/bootstrap.min.css" media="(prefers-color-scheme: no-preference), (prefers-color-scheme: light)">
<div class="row px-5">
<div class="col-md-6">
<h3 class="mt-5">Table with colors</h3>
<p><strong>Note: </strong> Use <code>table-*</code> classes.</p>
<table class="table table-hover">
<thead>
@konsumer
konsumer / .gitlab-ci.yml
Last active December 5, 2019 10:09
Perverse way to write Gitlab CI tasks
test:
image: mcr.microsoft.com/powershell
script:
- Write-Host "Multi-line"
- Write-Host "WORKS!"
@konsumer
konsumer / tinyuriobjdecode.js
Created November 21, 2019 01:13
take a url string (eg from document.location.search) like `cool=1&neat=true` and turn it into an object
const parseURIObj = str => str.split('&').reduce((a, c) => { const v = c.split('='); return { ...a, [decodeURI(v[0])]: decodeURI(v[1]) } }, {})
@konsumer
konsumer / cheerio_fetches.js
Last active November 9, 2019 11:02
A couple common usecases for getting jquery-like for scraping, in node, from GET request
const cheerio = require('cheerio')
const fetch = require('node-fetch')
// get Authorization header for basc auth
const basicAuth = (username, password) => 'Basic ' + Buffer.from(`${encodeURIComponent(username)}:${encodeURIComponent(password)}`).toString('base64')
// get jquery-like object
const f$ = (url, options = {}) => fetch(url, options)
.then(r => r.text())
.then(r => cheerio.load(r))
INGREDIENTS: INCESSANT SCREAMS, INDUSTRIAL BYPRODUCT (BLEARS), FUNK, ROCK, GUNFIRE, NUCLEAR EXPLOSIONS, EARTHQUAKES, FIRECRACKERS, VARIOUS HORNS (TRUMPET, FOG, TRUCK, TUBA, ANTLER), SONIC BOOMS, CHAINSAWS, BALLOONS POPPING, THUNDER, CHIMES, BELLS, BUZZERS, GONGS, LEAFBLOWERS, VOLCANIC ERUPTIONS, (CLASSIFIED). DRAG RACING, DRUMS, CITY TRAFFIC, BULLDOZER, OFFICE WORK, AMPLIFIERS, GIBBERISH, BANGS, CHOIRS, BOOMS, POPS, MAXWELL'S SILVER HAMMER, JET NOISES, GLITTER, BARBARIAN HORDES, THE SUN, RAINBOWS, FLAMBOYANCE, BRIGHT LIGHTS
WARNING: THIS PRODUCT IS NOT EDIBLE AND IS A KNOWN HAZARD! MAY CAUSE BLINDNESS. HEARING LOSS. SEIZURES. DEATH. EXTREME FITS OF GAYNESS. AND/OR BEING JAILED AFTER DEATH! ONCE USED RECTALLY. IT SHOULD NOT BE USED ORALLY! CONTENTS WILL EXPLODE IF SHAKEN! MAY EXCEED 200 dB! USE EAR PROTECTION AND A MECH SUIT WHEN EXPOSED TO CONTENTS! CHEW BEFORE SWALLOWING! WILL CAUSE COLOR SATURATION! LOUD AND SUDDEN MOVEMENTS MAY PROVOKE BLEARS TO ATTACK! $4 FINE FOR INSTANT DEATH!
@konsumer
konsumer / android-store-definitions.md
Last active November 9, 2025 18:30
Android store device definition files
Name API Link
alps 875 (api19) 19 875
OPPO 1201 (api22) 22 1201
vivo 1601 (api24) 24 1601
vivo 1603 (api23) 23 1603
vivo 1606 (api23) 23 1606
vivo 1610 (api23) 23 1610
vivo 1716 (api25) 25 1716
vivo 1718 (api25) 25 [171
while True:
t = time.localtime()
print('%2d:%2d:%2d' % (t[3], t[4], t[5])) # print out the time
minute = t[4]
if minute == 0:
hour = t[3]
ampmhour = hour % 12
playcuckoo(ampmhour)
time.sleep(60) # sleep a minute to keep this from triggering again this hour
time.sleep(1) # sleep 1 second to make it not run at 100% in this loop
while True:
playcuckoo(11)
time.sleep(60)
import RPi.GPIO as GPIO
import time
GPCLK_2 = 31
GPIO.setmode(GPIO.BOARD)
GPIO.setup(GPCLK_2, GPIO_OUT)
GPIO.setclock(GPCLK_2, 10000)
GPIO.output(GPCLK_2, 1)
time.sleep(10)