Skip to content

Instantly share code, notes, and snippets.

@xr09
xr09 / README.md
Created November 11, 2016 01:28 — forked from magnetikonline/README.md
Setting Nginx FastCGI response buffer sizes.

Nginx FastCGI response buffer sizes

By default when Nginx starts receiving a response from a FastCGI backend (such as PHP-FPM) it will buffer the response in memory before delivering it to the client. Any response larger than the set buffer size is saved to a temporary file on disk. This process is outlined at the Nginx ngx_http_fastcgi_module page document page.

Introduction

Since disk is slow and memory is fast the aim is to get as many FastCGI responses passing through memory only. On the flip side we don't want to set an excessively large buffer as they are created and sized on a per request basis (i.e. it's not shared memory).

@xr09
xr09 / gitlab-http
Created March 17, 2015 18:30
cache gitlab uploads
# append this to /var/opt/gitlab/nginx/conf/gitlab-http.conf
location ~ ^/(uploads)/ {
expires max;
add_header Cache-Control public;
}
@xr09
xr09 / rd
Last active August 29, 2015 14:16
rdesktop like a pro
DOMAIN_NAME="domain-name"
DOMAIN_USER='domain-user'
DOMAIN_PASS='...pass..'
# USAGE:
# rd ( hostname | ip )
# rd winserver
# rd 10.0.0.4
rd()
import subprocess
command = subprocess.Popen( ["-c", "who | cut -d' ' -f1 | sort | uniq | grep -v root" ], stdout=subprocess.PIPE, shell=True )
users, err = command.communicate()
@xr09
xr09 / gist:912044868b954685de2b
Created August 4, 2014 13:56
mkalias on-the-fly
# mkalias name "command param1 param2 etc.."
# Example: mkalias srvfolder "python -m SimpleHTTPServer"
mkalias () {
echo "alias $1=\"$2\"" >> ~/.bashrc
}
@xr09
xr09 / home_nuker.py
Last active August 29, 2015 14:02
the home nuker
import os
import stat
import shutil
import subprocess
# protected folders in /home
DONT_DELETE = 'Department lost+found someguy'.split()
def chmod_writable(func, path, excinfo):
@xr09
xr09 / gist:8677086
Created January 28, 2014 21:40
bitwise
>>> map(lambda n: 1 << n, xrange(10))
[1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
>>> from math import pow
>>> map(lambda n: pow(n, 2), xrange(10))
[0.0, 1.0, 4.0, 9.0, 16.0, 25.0, 36.0, 49.0, 64.0, 81.0]
@xr09
xr09 / ubackup.sh
Last active January 4, 2016 20:29
Minimal rotating backup system
#!/usr/bin/bash
backup_number=8
base_name="backup.gz"
backup_path="/opt/somebackup/"
cd $backup_path
# clean any old temp backup
@xr09
xr09 / gist:7758982
Created December 2, 2013 21:06
synergy.conf
section: screens
laptop:
desktop:
end
section: links
desktop:
right = laptop
# Desktop1 is to the right of Laptop
@xr09
xr09 / composer.json
Created June 28, 2013 14:12
requirements.txt vs composer.json
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",