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 / android-store-definitions.md
Last active Jul 4, 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)
View slacktheme.js
// https://github.com/Nockiro/slack-black-theme
// on popos, at bottom of /usr/lib/slack/resources/app.asar.unpacked/src/static/ssb-interop.js
document.addEventListener('DOMContentLoaded', function () {
// Then get its webviews
let webviews = document.querySelectorAll('.TeamView webview')
// Fetch our CSS in parallel ahead of time
const cssPath = 'https://raw.githubusercontent.com/Nockiro/slack-black-theme/master/custom.css'
@konsumer
konsumer / newtermtab.sh
Created May 17, 2019
Open a new tab in xfce4-terminal, if it's running, and cd to wherever the last-run zsh is
View newtermtab.sh
#!/bin/bash
# use tabs if terminal is running, otherwise new window
# designed for use with meta-T to open new terminal window/tab
XPID=$(pgrep zsh -o)
if [ "${XPID}" != "" ];then
cwd=$(pwdx $XPID|sed -e "s/${XPID}: //")
cwd=${cwd:-$HOME}
@konsumer
konsumer / .nanorc
Last active May 17, 2019
A nano config for a polyglot programmer who is used to atom/subl/vscode
View .nanorc
set smooth
set autoindent
set casesensitive
set regexp
set historylog
set morespace
set nohelp
set tabsize 2
set tabstospaces
set mouse
@konsumer
konsumer / fixvideo.sh
Created Apr 28, 2019
Convert all mkv files to mp4 with non-transcoding codec (for plex) and strip all non-english audio tracks
View fixvideo.sh
function fixvideo () {
ffmpeg -i "${1}" -map 0:m:language:eng -vcodec libx264 -acodec aac -sn "$(basename "${1}" "${2}").mp4"
}
for i in *.mkv;do
fixvideo "${i}" ".mkv"
done
@konsumer
konsumer / ffprobe-streams.js
Created Apr 28, 2019
Get info about about video streams in nodejs, using `ffprobe`
View ffprobe-streams.js
const { exec } = require('child_process')
const { promisify } = require('util')
const unflatten = require('unflatten')
const run = promisify(exec)
// get stream info about a video file
const getStreams = async inFile => {
const { stdout } = await run(`ffprobe -show_streams '${inFile}'`)
const streams = stdout.replace(/\[\/STREAM\]/g, '').split('[STREAM]').filter(s => s.trim() !== '').map(streamText => {
You can’t perform that action at this time.