Skip to content

Instantly share code, notes, and snippets.

View huanle0610's full-sized avatar
๐ŸŽฏ
Focusing

huanle0610 huanle0610

๐ŸŽฏ
Focusing
View GitHub Profile
@remy
remy / trim-canvas.js
Last active December 5, 2025 13:16
Trims the surrounding transparent pixels from a canvas
// MIT http://rem.mit-license.org
function trim(c) {
var ctx = c.getContext('2d'),
copy = document.createElement('canvas').getContext('2d'),
pixels = ctx.getImageData(0, 0, c.width, c.height),
l = pixels.data.length,
i,
bound = {
top: null,
@andreadipersio
andreadipersio / switch-nginx-binary.sh
Last active August 20, 2024 13:04
How to switch nginx binary at runtime.
# inspired by
# Master NGINX - Dimitri Aivaliotis
# http://www.amazon.com/Mastering-NGINX-Dimitri-Aivaliotis-ebook/dp/B00B90PJR4
# Chapter 8 - Switching binaries at runtime
# We get the pid of the 'to be replaced' nginx master process
export nginx_old_pid=`cat /var/run/nginx.pid`
# we send an USR2 signal to tell 'to be replaced' process
# to start a new master process.
@denji
denji / nginx-tuning.md
Last active December 17, 2025 17:50
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@cinsk
cinsk / check-nfs.sh
Last active August 29, 2024 16:00
Check if NFS mounted directory is stale
#!/bin/bash
PATH=/bin:/usr/bin:/usr/local/bin
check-nfs () {
local TMPFILE=/tmp/checknfs.$$ RET=0 ORPHAN SUBSHELLPID
if [ "$#" -eq 0 ]; then
cat<<EOF
usage: check-nfs NFS-DIRECTORY...
@uupaa
uupaa / Audio.WebAudio.Browser.Compat.md
Last active December 7, 2022 08:40
Audio, WebAudio, Blob, ArrayBuffer
  1. Audio(url)
  2. Audio(arraybuffer)
  3. Audio(blob)
  4. WebAudio(arraybuffer)
  5. WebAudio(blob)

Audio file access with streaming

http://uupaa.net/issues/3/ ใฎ็ตๆžœ

@kathawala
kathawala / bigpkg.sh
Created January 17, 2015 20:41
Prints out a list of all pacman packages sorted by size from largest to smallest
#!/bin/bash
( echo "PACKAGE SIZE(K)";
for A in /var/lib/pacman/local/*/desc; do
egrep -A1 '%(NAME|SIZE)' $A \
| gawk '/^[a-z]/ { printf "%s ", $1 }; /^[0-9]/ { printf "%.0f\n", $1/1024 }'
done | sort -nrk2 ) | column -t
@protrolium
protrolium / ffmpeg.md
Last active December 1, 2025 21:36
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:

@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@evantoli
evantoli / GitConfigHttpProxy.md
Last active December 13, 2025 14:06
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@52cik
52cik / npm.taobao.sh
Last active October 30, 2025 06:16
npm ๆท˜ๅฎ้•œๅƒ้…็ฝฎ
npm set registry https://r.npm.taobao.org # ๆณจๅ†Œๆจกๅ—้•œๅƒ
npm set disturl https://npm.taobao.org/dist # node-gyp ็ผ–่ฏ‘ไพ่ต–็š„ node ๆบ็ ้•œๅƒ
## ไปฅไธ‹้€‰ๆ‹ฉๆทปๅŠ 
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass # node-sass ไบŒ่ฟ›ๅˆถๅŒ…้•œๅƒ
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron ไบŒ่ฟ›ๅˆถๅŒ…้•œๅƒ
npm set ELECTRON_MIRROR https://cdn.npm.taobao.org/dist/electron/ # electron ไบŒ่ฟ›ๅˆถๅŒ…้•œๅƒ
npm set puppeteer_download_host https://npm.taobao.org/mirrors # puppeteer ไบŒ่ฟ›ๅˆถๅŒ…้•œๅƒ
npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver # chromedriver ไบŒ่ฟ›ๅˆถๅŒ…้•œๅƒ
npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver # operadriver ไบŒ่ฟ›ๅˆถๅŒ…้•œๅƒ