Skip to content

Instantly share code, notes, and snippets.

View mxschmitt's full-sized avatar

Max Schmitt mxschmitt

View GitHub Profile
@mxschmitt
mxschmitt / start.sh
Last active August 7, 2023 23:41
Librespot -> ffmpeg -> vlc http streaming -> Spotify connect
#!/bin/bash
# Using the Librespot client libary for streaming the Spotfiy connect sound via http
# Instruction:
# 1. Drop this script into the root directory of the librespot repository => https://github.com/plietar/librespot
# 2. Install the dependencies => "sudo apt-get install vlc ffmpeg"
# 3. Set the correct privileges => "chmod +x start.sh"
# 4. Set the librespot directory owner to a non-root user
# 5. Switch to this user
# 6. Change the variables under this instruction for your needs
@mxschmitt
mxschmitt / cmd.bat
Last active April 18, 2024 21:48
Golang example of cmd stderr / stdout merge to a single channel
@echo off
echo Stdout
echo Stderr 1>&2
@mxschmitt
mxschmitt / abap.js
Last active May 11, 2018 07:55
Format ABAP like timestamp in JavaScript
Date.prototype.toABAPString = function () {
let formatNumber = number => ("0" + number).slice(-2);
return this.getFullYear() + formatNumber(this.getUTCMonth() + 1) + formatNumber(this.getUTCDate()) + formatNumber(this.getUTCHours()) + formatNumber(this.getUTCMinutes()) + formatNumber(this.getSeconds());
}
@mxschmitt
mxschmitt / keybase.md
Created September 12, 2018 08:27
keybase.io verification

Keybase proof

I hereby claim:

  • I am mxschmitt on github.
  • I am mxschmitt (https://keybase.io/mxschmitt) on keybase.
  • I have a public key ASDPG84oimGzLROyuqwyqaszOsIBpR53Hn2grlElhCzf6Ao

To claim this, I am signing this object:

@mxschmitt
mxschmitt / sum.js
Created April 26, 2020 14:50
Possible solution for the sum interview question
const sum(a, b) => {
const maxLength = Math.max(a.length, b.length)
const out = []
for (let i = 0, carry = false; i < maxLength || carry; i++) {
const numA = i < a.length ? parseInt(a[a.length - 1 - i], 10) : 0
const numB = i < b.length ? parseInt(b[b.length - 1 - i], 10) : 0
const sum = numA + numB + (carry ? 1 : 0)
carry = sum >= 10
out.unshift(sum % 10)
}
################################################
# Compile with:
# docker build -t mcr.microsoft.com/playwright:python-buster -f Dockerfile.buster .
#
# Run with:
# docker run -d -p --rm --name playwright mcr.microsoft.com/playwright:python-buster
#
#################################################
FROM python:3.8-slim-buster
@mxschmitt
mxschmitt / event_emitter.go
Last active August 28, 2020 07:32
Node.js like event emitter in Go
package playwright
import (
"reflect"
"sync"
)
type (
incomingEvent struct {
name string
@mxschmitt
mxschmitt / test.mjs
Created August 24, 2020 09:03
Node.js web server with top-level-await and async for loop
// Run it with: node --harmony-top-level-await test.mjs
import { createServer } from 'http'
import { on } from 'events'
const PORT = 3000
const reqs = on(createServer().listen(PORT), "request")
console.log(`Listening on port ${PORT}`)
for await (const [req, res] of reqs)
res.end(`User-Agent: ${req.headers["user-agent"]}`)
Try Playwright (try.playwright.tech) rewrite
+-----------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------------------------------------+
| Before | | N times After N times |
| 1x time 1x time | | +------------------------+ +------------------------------------------------+ |
| +------------------+ +------------------------+ | | | | | | |
| | | | | | | | Frontend (LB) | +------------------+