Skip to content

Instantly share code, notes, and snippets.

David Konsumer konsumer

Block or report user

Report or block konsumer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@konsumer
konsumer / index.html
Last active Dec 7, 2019
Electron Fiddle Gist
View index.html
<!-- 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 Dec 5, 2019
Perverse way to write Gitlab CI tasks
View .gitlab-ci.yml
test:
image: mcr.microsoft.com/powershell
script:
- Write-Host "Multi-line"
- Write-Host "WORKS!"
@konsumer
konsumer / tinyuriobjdecode.js
Created Nov 21, 2019
take a url string (eg from document.location.search) like `cool=1&neat=true` and turn it into an object
View tinyuriobjdecode.js
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 Nov 9, 2019
A couple common usecases for getting jquery-like for scraping, in node, from GET request
View cheerio_fetches.js
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))
View faq.md
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 Nov 24, 2019
Android store device definition files
View android-store-definitions.md
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
View cuckoo2.py
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
View cuckoo.py
while True:
playcuckoo(11)
time.sleep(60)
View rpi_question.py
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)
View leftpad.js
export const leftpad = (c, d=2, s='0') => c.toString().padStart(d, s)
You can’t perform that action at this time.