Skip to content

Instantly share code, notes, and snippets.

@Firefishy
Firefishy / sysctl-tune.conf
Created March 23, 2017 17:57
Safe sysctl tuning for modern high traffic systems
# Enable Packetization Layer Path MTU Discovery.
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_base_mss = 1024
# Ensure slow start is disabled
# https://github.com/ton31337/tools/wiki/tcp_slow_start_after_idle---tcp_no_metrics_save-performance
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_no_metrics_save = 0
# Tune network buffers - servers have more than 16MB of RAM in 2017
#!/bin/bash
set -e
JAVA_HOME=${1-text}
[ $# -eq 0 ] && { echo "Usage: sudo $0 \$(/usr/libexec/java_home -v '1.8*')" ; exit 1; }
KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts
wget https://letsencrypt.org/certs/letsencryptauthorityx1.der
wget https://letsencrypt.org/certs/letsencryptauthorityx2.der
@Firefishy
Firefishy / docker-osm-me.sh
Created March 26, 2016 19:54
Quickstart for OSM in Docker
#!/bin/bash
set -e
type docker >/dev/null 2>&1 || { echo >&2 "error: docker is required. See: https://docs.docker.com/engine/installation/linux/"; exit 1; }
type docker-compose >/dev/null 2>&1 || { echo >&2 "error: docker-compose is required. See: https://docs.docker.com/compose/install/"; exit 1; }
[ ! -d cgimap ] && git clone --branch add-docker --depth 1 https://github.com/Firefishy/cgimap.git;
[ ! -d openstreetmap-website ] && git clone --branch add-docker --depth 1 https://github.com/Firefishy/openstreetmap-website.git
(cd cgimap && docker build -t openstreetmap/cgimap .)
(cd openstreetmap-website && docker-compose run --rm app bundle exec rake db:migrate)
(cd openstreetmap-website && docker-compose up)
# remove environment; cd openstreetmap-website ; docker-compose down

Keybase proof

I hereby claim:

  • I am firefishy on github.
  • I am firefishy (https://keybase.io/firefishy) on keybase.
  • I have a public key ASDl3d4SDUHEeEPFoE8m4x-J_Cohq7ZYhDKZ0eAHHq8I_Ao

To claim this, I am signing this object:

// Based on java example: http://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html
// save as: URLConnectionReader.java
// compile using JDK: javac URLConnectionReader.java
// run: java URLConnectionReader
// good path: returns HTML
// bad path: throws an exception
import java.net.*;
import java.io.*;
@Firefishy
Firefishy / docker-compose.yml
Created October 8, 2020 19:02
Using docker to get latest btrfs-progs
version: "2"
services:
app:
build:
context: .
dockerfile: Dockerfile
devices:
# Which disk(s) to expose to docker...
- "/dev/md1:/dev/md1"
10
Errors Corrected by Total Correction Gigabytes Total
ECC rereads/ errors algorithm processed uncorrected
fast | delayed rewrites corrected invocations [10^9 bytes] errors
read: 888487 54220 122540 942707 54220 1788780.870 0
write: 1974923 2662 2666 1977585 2662 223280.255 0
verify: 487 17321 34884 17808 17321 133.236 0
Non-medium error count: 194
cd /path-to-dir/LUREF_NGL/; find . -type f -iname '*.tif' >input-files.txt
docker run -it --rm -v /path-to-dir/LUREF_NGL:/data osgeo/gdal:alpine-normal-v2.4.1 sh -l
(in docker) gdalbuildvrt -resolution highest -r nearest ANA_LUREF_NGL_DTM.vrt -input_file_list input-files.txt
# Rest not in docker...
gdaladdo -ro --config COMPRESS DEFLATE --config COMPRESS_OVERVIEW DEFLATE --config ZLEVEL 9 --config BIGTIFF_OVERVIEW IF_SAFER --config GDAL_TIFF_OVR_BLOCKSIZE 512 -r nearest ANA_LUREF_NGL_DTM.vrt 4 16 64 256 1024 4096
gdaldem hillshade ANA_LUREF_NGL_DTM.vrt lu_hillshade_2017.tif -co BIGTIFF=YES -co TILED=YES -co COMPRESS=DEFLATE -co GDAL_NUM_THREADS=ALL_CPUS -of GTiff -b 1 -z 1.0 -s 0.5 -az 315.0 -alt 45.0
gdaladdo -ro --config COMPRESS_OVERVIEW JPEG --config PHOTOMETRIC_OVERVIEW YCBCR --config INTERLEAVE_OVERVIEW PIXEL --config BIGTIFF_OVERVIEW IF_SAFER --config GDAL_TIFF_OVR_BLOCKSIZE 512 -r average lu_hillshade_2017.tif 4 16 64 256 1024 4096
gdalwarp -t_srs epsg:3857 -r lanczos -multi -wo NUM_THREADS=ALL_CPUS A
@Firefishy
Firefishy / docker-compose.yml
Created October 21, 2019 16:44
PostgreSQL docker-compose managing a data volume
version: '3'
services:
db:
image: postgres:9
volumes:
- db-data:/var/lib/postgresql/data
volumes:
db-data:
@Firefishy
Firefishy / gist:b7d2f50853d7b27a3bcb
Last active August 1, 2019 13:55
live gautrain bus position api - reverse engineered
date_default_timezone_set('UTC');
function getURL() {
$paramString2 = 'east=XXX&south=-XXX&north=-XXX&west=XXX';
$paramString1 = 'gautrain.mobileServer.getBusesByBoundingBoxServlet';
$timestamp = (string) time();
$signature = base64_encode(hash_hmac('sha1', $paramString2 . '/' . $paramString1. '/2a93a1b6be/' . $timestamp, '@GAuTra1n', true));
$signature = str_replace(array('=', '/', '+'), array(' ','_','-'), $signature);
$signature = trim($signature);