Skip to content

Instantly share code, notes, and snippets.

View andrewslotin's full-sized avatar

Andrey Slotin andrewslotin

  • Pawtucket Pat, Inc.
  • Berlin, Germany
View GitHub Profile
@andrewslotin
andrewslotin / pip.js
Created February 11, 2021 00:09
Watch Amazon Video in PiP mode in Safari
Array.from(document.getElementsByTagName('video'))
.filter(vid => vid.src)
.forEach(vid => vid.webkitSetPresentationMode("picture-in-picture"));
@andrewslotin
andrewslotin / GNU-Make.md
Created August 12, 2020 11:47 — forked from rueycheng/GNU-Make.md
GNU Make cheatsheet
package main_test
import (
"runtime"
"testing"
)
//go:noinline
func switchImplementation() int {
switch runtime.GOARCH {
@andrewslotin
andrewslotin / mkpasswd.py
Created July 10, 2018 15:13
/etc/shadow compatible password encryption using SHA-512 hash with salt
#!/usr/bin/env python3
import crypt
from getpass import getpass
try:
from passlib.hash import sha512_crypt
except ImportError:
from sys import stderr
stderr.write("please run 'pip3 install passlib' to make sure you have passlib installed\n")
@andrewslotin
andrewslotin / flac2alac.sh
Last active April 19, 2024 17:39 — forked from vol4ok/gist:2587886
Split .ape and .flac and convert to .m4a (ALAC) or .mp3 on MacOS X
# brew install flac ffmpeg cuetools shntool # ставим нужные пакеты
ffmpeg -i 1.ape 1.flac # конвертируем во flac, так как libmac для APE не ставится на osx
cuebreakpoints 1.cue | shnsplit -o flac 1.flac #нарезаем на треки
cuetag.sh 1.cue split-track*.flac #прописываем тэги (cuetag.sh ставится отдельно отдельно)
# конвертируем в ALAC
for f in split-track*.flac ; do
ffmpeg -i "$f" -acodec alac "${f%.flac}.m4a";
done
@andrewslotin
andrewslotin / pre-commit
Created March 10, 2016 10:30
Pre-commit git hook to avoid committing non-formatted Go code
#!/bin/sh
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$')
[ -z "$gofiles" ] && exit 0
unformatted=$(gofmt -l $gofiles)
if [ ! -z "$unformatted" ]; then
echo "Go files must be formatted with gofmt. Please run:" >&2
for fn in $unformatted; do
echo " gofmt -w $PWD/$fn" >&2
@andrewslotin
andrewslotin / goba
Last active February 16, 2016 14:58
Find and run all Go tests in current directory (and subdirectories)
#!/bin/bash
declare paths=$(for t in $(find . -name "*_test.go" -not -path "./.go/*"); do dirname $t; done | sort | uniq)
declare -i return_value=0
for path in ${paths[@]}; do
if go test -i $path; then
echo "$path...ok"
else
return_value=1
@andrewslotin
andrewslotin / stat_alloc_trace.sh
Created February 23, 2015 10:44
Get stats from golang memory allocation trace log
#!/bin/bash
function realpath() {
local file_path="$1"
pushd $(dirname "$file_path") > /dev/null 2>&1
echo `pwd -P`/`basename "$file_path"`
popd > /dev/null 2>&1
}
function usage() {
@andrewslotin
andrewslotin / swears.txt
Created May 21, 2013 10:37
Taken from dfm/osrc/blob/master/ghdata/static/swears.txt
anus
arse
arsehole
ass
ass-hat
ass-jabber
ass-pirate
assbag
assbandit
assbanger