Skip to content

Instantly share code, notes, and snippets.

jamesbjackson / nginx_logging.conf
Last active Apr 14, 2021
Nginx Log JSON Formatting
View nginx_logging.conf
log_format main_json escape=json '{'
'"msec": "$msec", ' # request unixtime in seconds with a milliseconds resolution
'"connection": "$connection", ' # connection serial number
'"connection_requests": "$connection_requests", ' # number of requests made in connection
'"request_id": "$request_id", ' # the unique request id
'"request_length": "$request_length", ' # request length (including headers and body)
'"remote_addr": "$remote_addr", ' # client IP
'"remote_user": "$remote_user", ' # client HTTP username
'"remote_port": "$remote_port", ' # client port
'"date_gmt": "$date_gmt", ' # current time in GMT. The format is set by the config command with the timefmt parameter
jamesbjackson / kubernetes_reading_list
Last active Nov 11, 2020
Reading list arround Kubernetes
View kubernetes_reading_list
Kubernetes Learning Resources
50 days from zero to hero with Kubernetes (Free Video Content) by Microsoft
jamesbjackson /
Last active Aug 14, 2020 — forked from porjo/
Export route53 records to TSV & CSV

Retrieve hosted zones with aws route53 list-hosted-zones then enter the zone Id below:


aws route53 list-resource-record-sets --hosted-zone-id "/hostedzone/xxxxxxxxxxx" | jq -r '.ResourceRecordSets[] | [.Name, .Type, (.ResourceRecords[]? | .Value), .AliasTarget.DNSName?]  | @tsv'


View Detected process using Cached RAM
# Find out what process is using all the RAM?
ps -e -o pid,vsz,comm= | sort -n -k 2
# clear page cache only without interrupting any processes or services. (Run as Root)
sync; echo 1 > /proc/sys/vm/drop_caches
# clear dentries and inodes only without interrupting any processes or services. (Run as Root)
sync; echo 2 > /proc/sys/vm/drop_caches
# clear page cache, dentries and inodes only without interrupting any processes or services. (Run as Root)
View Verify ERB Syntax
erb -x -T '-' file.erb | ruby -c
View how_to_catch_a_git_fork_to_master
git remote add upstream
git remote -v
origin (fetch)
origin (push)
upstream (fetch)
upstream (push)
git fetch upstream
git checkout master
git rebase upstream/master
View Checking MTU value for a port
nping -c 1 --tcp -p 80
Starting Nping 0.7.80 ( ) at 2020-01-29 16:53 GMT
SENT (0.0141s) TCP > S ttl=64 id=35587 iplen=40 seq=1474941899 win=1480
RCVD (0.3046s) TCP > SA ttl=37 id=0 iplen=44 seq=3029599029 win=11520 <mss 582>
Max rtt: 290.255ms | Min rtt: 290.255ms | Avg rtt: 290.255ms
Raw packets sent: 1 (40B) | Rcvd: 1 (46B) | Lost: 0 (0.00%)
Nping done: 1 IP address pinged in 1.02 seconds
jamesbjackson / agent.nut
Created Jan 9, 2020 — forked from hfiennes/agent.nut
imp001 air quality monitoring (with AQI index)
View agent.nut
// Ensure we have a default reading
lastreading <- { "pm10":0, "pm25":0, "pm100":0 };
// Code to convert particlate density to AQI index
// based on
function Linear(AQIhigh, AQIlow, Conchigh, Conclow, Conc) {
local a=((Conc-Conclow)/(Conchigh-Conclow))*(AQIhigh-AQIlow)+AQIlow;
return math.floor(a+0.5);
jamesbjackson / azure_storage_account.json
Last active Dec 3, 2019
Azure Support in
View azure_storage_account.json
"$schema": "",
"contentVersion": "",
"parameters": {
"name": {
"type": "string",
"defaultValue": "storage_account_name",
"metadata": {
"description": "Unique DNS name for the Storage Account"
View gist:7d77ae2335363a8b8f76bd09cf8b9f61


Three system configuration parameters must be set to support a large number of open files and TCP connections with large bursts of messages. Changes can be made using the /etc/rc.d/rc.local or /etc/sysctl.conf script to preserve changes after reboot.

1. /proc/sys/fs/file-max: The maximum number of concurrently open files.

fs.file-max = 1000000

2. /proc/sys/net/ipv4/tcp_max_syn_backlog: Maximum number of remembered connection requests, which are still did not receive an acknowledgment from connecting client. The default value is 1024 for systems with more than 128Mb of memory, and 128 for low memory machines.

net.ipv4.tcp_max_syn_backlog = 3240000

3. /proc/sys/net/core/somaxconn: Limit of socket listen() backlog, known in userspace as SOMAXCONN. Defaults to 128.

net.core.somaxconn = 3240000