Skip to content

Instantly share code, notes, and snippets.

View tkhoa2711's full-sized avatar

Khoa Le tkhoa2711

View GitHub Profile
New solution Old solution
Cached 30ms - 250ms 60ms - 1s
Not cached 250ms - 1.4s 700ms - 6s
const response = event.Records[0].cf.response;
// ...
Sharp(imageBuffer, {
sequentialRead: true,
limitInputPixels: 2684026890, // raise default limit to 10x
})
.resize({
width: width,
@tkhoa2711
tkhoa2711 / build_nginx.sh
Created June 20, 2018 23:29 — forked from Yinchie/build-nginx.sh
Compiling NGiNX with LibreSSL, Brotli, more_headers - Ubuntu 16.04 x64
#!/usr/bin/env bash
# Latest versions of each package.
export NGINX_VERSION=1.11.12
export VERSION_NGINX=nginx-$NGINX_VERSION
export VERSION_PCRE=pcre-8.40
export VERSION_ZLIB=zlib-1.2.11
export VERSION_OPENSSL=openssl-1.1.0e
#export VERSION_LIBRESSL=libressl-2.5.1
export HMORE_VERSION=0.32
@tkhoa2711
tkhoa2711 / setup_locale.sh
Created June 19, 2018 23:16
Configure locale for some systems
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_TYPE=en_US.UTF-8
@tkhoa2711
tkhoa2711 / fix-homebrew-mac-osx-elcapitan.sh
Last active May 21, 2016 18:10
Fix errors with Homebrew/Ruby in Mac OS X El Capitan
# This script aims to fix errors similar to below:
#
# /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file ...
# from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
#
# The error is commonly stumbled upon in Mac OS X El Capitan.
# fix access permission issue with the new Mac's SIP process
sudo chown -R $(whoami):admin /usr/local
@tkhoa2711
tkhoa2711 / web-based-github-workflow.txt
Created March 29, 2016 05:30
Workflow to edit multiple files on GitHub website
- Create a temporary branch, switch to it
- Edit multiple files, commit each file separately
- Make pull request
- Merge pull request and delete temporary branch
@tkhoa2711
tkhoa2711 / vim-splits-cheatsheet
Created March 16, 2016 04:21
vim splitting cheatsheet
https://robots.thoughtbot.com/vim-splits-move-faster-and-more-naturally
@tkhoa2711
tkhoa2711 / update-git-proxy-config.sh
Last active March 14, 2016 06:00
Update http(s) proxy settings for git
# read in username and password for system http(s) proxy settings
read -s -p "Username: " USERNAME; echo ''
read -s -p "Password: " PASSWORD; echo ''
read -s -p "HTTP(S) Proxy (host:port): " HTTP_PROXY_HOST_PORT; echo ''
export {http_proxy,https_proxy}="http://$USERNAME:$PASSWORD@$HTTP_PROXY_HOST_PORT"
# update http(s) proxy settings for git
git config --global http.proxy $http_proxy
git config --global https.proxy $https_proxy
@tkhoa2711
tkhoa2711 / get-ip-address.el
Created March 9, 2016 02:47
Retrieve IP address using Emacs Lisp (on Windows and UNIX)
(defun get-ip-address (&optional dev)
"Get the IP-address for device DEV (default: eth0) of the current machine."
(let ((dev (if dev dev "eth0")))
(format-network-address (car (network-interface-info dev)) t)))
http://backreference.org/2013/05/22/send-email-with-attachments-from-script-or-command-line/