Skip to content

Instantly share code, notes, and snippets.

View devhero's full-sized avatar
😁

Andrea Parisi devhero

😁
  • devhero
  • Milan
View GitHub Profile
@devhero
devhero / js_iterate_object
Last active May 12, 2022 06:50
js iterate through an object #js
// iterate through
Object.entries(myObject).forEach(([key, value]) => {
console.log(`${key}: ${value}`)
});
// return a new array
Object.entries(myObject).map(([key, value]) => {
return {
key,
value
@devhero
devhero / encrypt SHA1 htpasswd
Last active May 6, 2022 11:34
htpasswd #encrypt #sha1
htpasswd -nbBC 10 USER topsecret
# USER:$2y$10$vDtCxgJ4DIZ1itAAq6NDkedmaDFHlPdlpLY.EiEa3QBXHnH0oLatW
# used with traefik
echo $(htpasswd -nb USER topsecret) | sed -e s/\\$/\\$\\$/g
# USER:$$apr1$$rjtvYgpl$$urvcY8G0rd9ZpskQc0u28.
@devhero
devhero / av1 encoding params
Last active December 14, 2022 19:35
av1 #av1
# ENCODING PARAMS (AOMENC):
--cpu-used=4 --end-usage=q --tile-columns=1 --tile-rows=1
--bit-depth=10 --lag-in-frames=28 --threads=2
--enable-dist-wtd-comp=0 --enable-qm=1 --quant-b-adapt=3
--mv-cost-upd-freq=2 --enable-chroma-deltaq=1
--enable-fwd-kf=1
# av1an docker SDR 1080p (pre=6,cq=25,denoise=0,grain=15):
docker run --privileged -v "$(pwd):/videos" --user $(id -u):$(id -g) -it --rm masterofzen/av1an:master --encoder aom -s ./movie-scenes.json -c mkvmerge -m lsmash -k --workers 6 -a " -an " --video-params " --bit-depth=10 --cpu-used=6 --cq-level=25 --end-usage=q --lag-in-frames=48 --enable-fwd-kf=1 --aq-mode=1 --deltaq-mode=1 --enable-chroma-deltaq=1 --quant-b-adapt=1 --enable-qm=1 --min-q=1 --enable-keyframe-filtering=2 --arnr-strength=1 --arnr-maxframes=4 --disable-trellis-quant=0 --disable-kf --threads=64 --sharpness=3 --enable-dnl-denoising=0 --denoise-noise-level=15" -i "movie.1080.mkv" -o "movie-aom-pre6-cq25-sharp3-den0-gr15-kff2.mkv"
@devhero
devhero / pytest cookbook
Last active March 14, 2022 11:15
pytest cookbook #pytest
# run specific method in a file
pytest app_folder/file.py -k "method keyword"
# enable debugger
pytest app_folder/file.py -k "method keyword" --pdb
# check for setup errors (wrong imports, etc)
pytest --setup-only
@devhero
devhero / custom.conf
Created February 4, 2022 17:21
anydesk display_server_not_supported #anydesk
# /etc/gdm/custom.conf
[daemon]
WaylandEnable=false
AutomaticLoginEnable=true
AutomaticLogin=$USERNAME
@devhero
devhero / npm_xcode
Created April 10, 2020 15:19
gyp: No Xcode or CLT version detected! #install #npm
sudo rm -rf $(xcode-select -print-path)
xcode-select --install
/usr/sbin/pkgutil --packages | grep CL
sudo npm install -g node-gyp
@devhero
devhero / python sqlite3 pyenv macos
Created June 26, 2019 08:43
python_sqlite3_pyenv_macos
# https://github.com/pyenv/pyenv/issues/108
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 3.6.8
@devhero
devhero / python_build_failed_mojave
Created June 5, 2019 15:18
python build failed macos mojave #build #python #macos
# BUILD FAILED (OS X 10.14.5 using python-build ...)
# zipimport.ZipImportError: can't decompress data; zlib not available
brew install zlib
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"
export KEEP_BUILD_PATH=true
@devhero
devhero / virtualbox_access_guest_ip
Created March 22, 2019 15:35
virtualbox access guest ip
# VirtualBox
# 1. add network adapter
# 2. select: host-only
# 3. select: vboxnet0
# centos
cd /etc/sysconfig/network-scripts/
cp ifcfg-enp0s3 ifcfg-enp0s8
@devhero
devhero / array_compare.js
Created November 13, 2018 16:26
array compare
array1.length === array2.length && array1.sort().every(function(value, index) { return value === array2.sort()[index]});