Skip to content

Instantly share code, notes, and snippets.

View huanle0610's full-sized avatar
🎯
Focusing

huanle0610 huanle0610

🎯
Focusing
  • Shenzhen, China
View GitHub Profile
@andreadipersio
andreadipersio / switch-nginx-binary.sh
Last active January 20, 2022 14:14
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.
@mattratleph
mattratleph / vimdiff.md
Last active May 9, 2024 03:11 — forked from roothybrid7/vimdiff_cheet.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@remy
remy / trim-canvas.js
Last active May 3, 2024 13:39
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,