Skip to content

Instantly share code, notes, and snippets.

(() => {
if ("externalAPI" in window && "mediaSession" in navigator) {
const ARTWORK_SIZES = ["200x200", "300x300", "400x400"];
// обновление состояния проигрывания
function setPlaybackState() {
navigator.mediaSession.playbackState = externalAPI.isPlaying() ? "playing" : "paused";
}
// создание метадаты для отображения в мини-плеере OS
@ryanburnette
ryanburnette / Caddyfile
Last active May 13, 2024 10:55
Caddy v2.1+ CORS whitelist
(cors) {
@cors_preflight{args.0} method OPTIONS
@cors{args.0} header Origin {args.0}
handle @cors_preflight{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Headers *
Access-Control-Max-Age "3600"
@r3dm1ke
r3dm1ke / proxy-default-value.js
Last active February 20, 2023 07:26
Using the Proxy API to set a default value for undefined object properties
const defaultValueHandler = {
get: (obj, property) =>
property in obj ? obj[property] : 'general kenobi'
}
const objectWithDefaultValue = new Proxy({}, defaultValueHandler);
objectWithDefaultValue.a = 'b';
console.log(objectWithDefaultValue.a); // b
@anujonthemove
anujonthemove / cuda-cudnn-export-paths.txt
Last active April 20, 2024 20:53
Export paths for CUDA and cuDNN.
export CUDA_HOME=/usr/local/cuda
export PATH=/usr/local/cuda/bin:$PATH
export CPATH=/usr/local/cuda/include:$CPATH
export LIBRARY_PATH=/usr/local/cuda/lib64:$LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH
@beeman
beeman / remove-all-from-docker.sh
Created November 15, 2016 03:04
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@protrolium
protrolium / ffmpeg.md
Last active May 15, 2024 18:27
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with:

/*
* ------------------------------------------------------------
* "THE BEERWARE LICENSE" (Revision 42):
* <author> wrote this code. As long as you retain this
* notice, you can do whatever you want with this stuff. If we
* meet someday, and you think this stuff is worth it, you can
* buy me a beer in return.
* ------------------------------------------------------------
*/