Skip to content

Instantly share code, notes, and snippets.

Smowtion Thomanphan

Block or report user

Report or block Thomanphan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:642317fe603899af7f8ff6f9f238cd96
nscache 65536
timeouts 1 5 30 60 180 1800 15 60
# http(s)
#auth none
auth strong
Thomanphan / ratelimiter.php
Created Aug 23, 2018 — forked from RobThree/ratelimiter.php
Simple, rude, rate limiter (using memcache).
View ratelimiter.php
/* Very simple, crude, rate limiter */
define('_MEMCACHEDHOST', '');
define('_MEMCACHEDPORT', 11211);
define('_MEMCACHEDSITEPREFIX', 'mysite');
Thomanphan / nginx reverse proxy with dynamic jolokia backend secured by http basic auth Setup nginx as a reverse proxy for jolokia including http basic auth. You might consider - Restrict the backend URL to your jolokia domains - Restrict the `Allow-Origin` Access-Control header to your domain Example Request:
View nginx reverse proxy with dynamic jolokia backend secured by http basic auth
server {
listen 80;
server_name localhost;
access_log /path/to/jolokia.access.log;
location / {
if ($request_method = OPTIONS ) {
add_header Access-Control-Allow-Origin "*"; # <--- customize this
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
Thomanphan /
Created Jul 31, 2018 — forked from edm00se/
Sample nginx.conf settings to perform reverse proxy functionality to.

Read Me

In order to access a server hosted within a vm (guest), for development purposes from the host OS, which is restricted to same origin / localhost only requests, I set up a siple nginx reverse proxy to forward my requests.


  1. To install in a Windows VM, download and install nginx from the current, stable release; I installed to C:\nginx\
  2. Edit the <install path>/conf/nginx.conf file with the marked changes in the file of the same name in this gist.
  3. Start the nginx executable, located in your install path. There are service wrappers for Windows, or you can just kill the process to stop the nginx instance.

Commands for Windows

Thomanphan /
Created Jul 24, 2018 — forked from joerx/
redirect php-fpm output to nginx's error log
  • php process is wrapped like this: PHP file -> php-fpm -> nginx
  • basically means disable all facilities that catch output from the script on it's way to nginx
  • standard error output will the end in Nginx's logging facility

On CentOS

  • make sure your script does not set error_log
  • edit /etc/php-fpm.conf, disable line error_log = /var/log/php-fpm/error.log
  • edit /etc/php-fpm.d/www.conf, disable line starting with php_admin_value[error_log] = ...
  • restart fpm: systemctl restart php-fpm
Thomanphan / svg2icns
Created May 20, 2018 — forked from zlbruce/svg2icns
covert svg to icns (with imagemagick)
View svg2icns
echo "*** SVG 2 ICNS ***"
if [ $# -ne 1 ]; then
echo "Usage: svg2icns filename.svg"
exit 100
echo "processing: $name"
Thomanphan / ResizeImage.php
Created Mar 26, 2018 — forked from egulhan/ResizeImage.php
Resize Image Class With PHP
View ResizeImage.php
// @source:
* Resize image class will allow you to resize an image
* Can resize to exact size
* Max width size while keep aspect ratio
* Max height size while keep aspect ratio
* Automatic while keep aspect ratio
Thomanphan /
Created May 28, 2017 — forked from fwolf/
Monitor memory usage in VPS
#! /bin/bash
#ps aux --width 80 | sort -nrk +6 | head -n 15
# bsdtime is shorter than cputime, hh:mm:ss vs MMM:SS
ps -eo 'user,pid,%cpu,%mem,rss,vsz,stime,bsdtime,s,cmd' --sort '-rss,-vsz' --width 80 | head -n 16
Thomanphan / global-variables-are-bad.js
Created May 16, 2017 — forked from hallettj/global-variables-are-bad.js
How and why to avoid global variables in JavaScript
View global-variables-are-bad.js
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
// Because if you don't, the become global variables.
(function() {
You can’t perform that action at this time.