Skip to content

Instantly share code, notes, and snippets.

Thomanphan 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
nserver 208.67.222.222
nserver 208.67.220.220
nscache 65536
timeouts 1 5 30 60 180 1800 15 60
daemon
# http(s)
#auth none
auth strong
@Thomanphan
Thomanphan / ratelimiter.php
Created Aug 23, 2018 — forked from RobThree/ratelimiter.php
Simple, rude, rate limiter (using memcache).
View ratelimiter.php
<?php
/* Very simple, crude, rate limiter */
/*
Assumes _MEMCACHEDSITEPREFIX, _MEMCACHEDHOST and _MEMCACHEDPORT are `defined`:
define('_MEMCACHEDHOST', '127.0.0.1');
define('_MEMCACHEDPORT', 11211);
define('_MEMCACHEDSITEPREFIX', 'mysite');
*/
@Thomanphan
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: http://yourNginxProxy.com?uri=your.dynamic.jolokia.domain/jolokia/
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
Thomanphan / ReadMe.md
Created Jul 31, 2018 — forked from edm00se/ReadMe.md
Sample nginx.conf settings to perform reverse proxy functionality to.
View ReadMe.md

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.

Steps

  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
Thomanphan / php-fpm-nginx-errorlog.md
Created Jul 24, 2018 — forked from joerx/php-fpm-nginx-errorlog.md
redirect php-fpm output to nginx's error log
View php-fpm-nginx-errorlog.md
  • 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
Thomanphan / svg2icns
Created May 20, 2018 — forked from zlbruce/svg2icns
covert svg to icns (with imagemagick)
View svg2icns
#!/bin/bash
echo "*** SVG 2 ICNS ***"
if [ $# -ne 1 ]; then
echo "Usage: svg2icns filename.svg"
exit 100
fi
filename="$1"
name=${filename%.*}
ext=${filename##*.}
echo "processing: $name"
@Thomanphan
Thomanphan / ResizeImage.php
Created Mar 26, 2018 — forked from egulhan/ResizeImage.php
Resize Image Class With PHP
View ResizeImage.php
<?php
// @source: http://www.paulund.co.uk/resize-image-class-php
/**
* 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
Thomanphan / mem.sh
Created May 28, 2017 — forked from fwolf/mem.sh
Monitor memory usage in VPS
View mem.sh
#! /bin/bash
# https://gist.github.com/fwolf/5856230
#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
echo
@Thomanphan
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.