Skip to content

Instantly share code, notes, and snippets.

View m99coder's full-sized avatar
👨‍🚀
Where no human has gone before

Marco Lehmann m99coder

👨‍🚀
Where no human has gone before
View GitHub Profile
@m99coder
m99coder / readers.go
Created March 10, 2021 11:06
Reader with infinite stream of ASCII character 'A'
package main
import "golang.org/x/tour/reader"
type MyReader struct{}
func (r MyReader) Read(b []byte) (int, error) {
for i := range b {
b[i] = 65
}
@m99coder
m99coder / errors.go
Created March 10, 2021 10:59
Value receiver method for Error interface
package main
import (
"fmt"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {
return fmt.Sprintf("cannot Sqrt negative number %d", int(e))
@m99coder
m99coder / slices.go
Created March 9, 2021 17:35
2D slices in Go
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
r := make([][]uint8, dy)
for y := range r {
r[y] = make([]uint8, dx)
for x := range r[y] {
// different functions to generate the “picture”
@m99coder
m99coder / Dockerfile
Last active April 12, 2023 08:57
Redis Replication with Docker Compose and Kubernetes Kompose
FROM redis:6.0.10
@m99coder
m99coder / .gitconfig
Created February 2, 2021 11:10 — forked from asaaki/.gitconfig
Using different emails and GPG keys for work and personal stuff on GitHub
[core]
# ...
[init]
defaultBranch = main
[commit]
gpgsign = true
# you want that to have a default for locations outside of your regular dev folders
@m99coder
m99coder / m3u8-to-mp4.md
Created January 30, 2018 11:05 — forked from tzmartin/m3u8-to-mp4.md
m3u8 stream to mp4 using ffmpeg

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
@m99coder
m99coder / server.js
Last active December 2, 2022 12:30
Node.js: Proxy multipart/form-data file upload to application/octet-stream REST API call
#!/usr/bin/env node
// dependencies
const https = require('https');
const express = require('express');
const multer = require('multer');
// app
const app = express();
const storage = multer.memoryStorage();
@m99coder
m99coder / control.sh
Last active May 23, 2017 08:20
Kafka/Zookeeper running in Docker – Control Bash Script
#!/usr/bin/env bash
# get platform to determine IP address accordingly
PLATFORM=$(uname -s)
if [ "$PLATFORM" == "Darwin" ]; then
IP=$(ipconfig getifaddr en0)
elif [ "$PLATFORM" == "Linux" ]; then
IP=$(hostname -I)
else
echo "Unknown platform. Can not determine IP address that way."
@m99coder
m99coder / content-script.js
Created November 30, 2016 00:25
Content Script to remove certain blog posts from Confluence Startpage
// black lists
var linkBlackList = [
// start of the URI you want to black list, e.g. '/display/~marco.lehmann'
];
var userBlackList = [
// user name you want to black list, e.g. 'marco.lehmann'
];
@m99coder
m99coder / non-blocking.js
Last active November 1, 2016 12:43
Non-blocking execution of expensive function
var data = [1, 2, 3];
var REFRESH_RATE = 16.67;
function veryExpensive(item) {
// ...
}
function forEachExpensive(data, callback) {
var index = 0;
var dataLength = data.length;