Skip to content

Instantly share code, notes, and snippets.

@kfox
kfox / tcpproxy.js
Created April 5, 2012 20:03
A basic TCP proxy written in node.js
var net = require("net");
process.on("uncaughtException", function(error) {
console.error(error);
});
if (process.argv.length != 5) {
console.log("usage: %s <localport> <remotehost> <remoteport>", process.argv[1]);
process.exit();
}
@wavded
wavded / gist:3373385
Created August 16, 2012 20:27
/etc/locale.conf
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
@jkstill
jkstill / proc_net_tcp_decode
Last active August 31, 2024 11:32
decode entries in /proc/net/tcp
Decoding the data in /proc/net/tcp:
Linux 5.x /proc/net/tcp
Linux 6.x /proc/PID/net/tcp
Given a socket:
$ ls -l /proc/24784/fd/11
lrwx------ 1 jkstill dba 64 Dec 4 16:22 /proc/24784/fd/11 -> socket:[15907701]
@denji
denji / nginx-tuning.md
Last active November 5, 2024 10:10
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@nicktoumpelis
nicktoumpelis / repo-rinse.sh
Created April 23, 2014 13:00
Cleans and resets a git repo and its submodules
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
@jordimarinvalle
jordimarinvalle / setting_up_osx_for_python_developments.md
Last active January 15, 2024 09:21
Setting Up OSX For Python Developments

Setting Up OSX For Python Developments

This gist has been created using OSX Mavericks, but it sould work with any OSX 64-bits system – Mountain Lion, Mavericks and for sure Yosemite ;) In case that you are using a OSX 32-bits system OSX Lion or Snow Leopard (OSX Leopard is not supported by XCode) just include the 32-bits System? section.

Bash profile setup

64-bits System

OS X Mountain Lion, Mavericks & Yosemite are full 64-bit systems so lets configure them to ensure that incoming user's package installations (e.g., Homebrew package installations) will be on a 64 bits system and taking precedence over OSX packaged binaries.

@tomasinouk
tomasinouk / snat_dnat_advantech.md
Last active October 1, 2024 09:00
examples of SNAT, DNAT with iptables for Advantech, Conel routers, with comments (probably will work on other routers where iptables can be manipulated, care needs to be taken on applying these commands after reboot).

Some examples of SNAT, DNAT with iptables with comments

mainly used in start-up script

How to test 'safely'

When we play with iptables aka firewall we might end up in situation, where we execute rule, which has unforseen impact - lock yourself out. Recovering from this situation is necessity.

How to:

  • Enable reboot via SMS.
  • Test all commands in shell first before putting them into Start-up script. This way the command will be wiped out, when unit is rebooted.

masquarade all outgoing packets to be WLAN0 IP

@andrewmilson
andrewmilson / file-upload-multipart.go
Last active October 7, 2024 12:07
Golang multipart/form-data File Upload
package main
import (
"net/http"
"os"
"bytes"
"path"
"path/filepath"
"mime/multipart"
"io"
@mayli
mayli / squid-with-data-compression.md
Created November 13, 2016 05:29
Using squid and data compression proxy to reduce traffic for cat pictures

Squid

Squid is a HTTP(S) caching proxy to reduce bandwidth and improves response times.

data compression proxy

Data compression proxy is a http proxy by google aimming to reduce cellular data usage by gzip and webp (Yes, it will compress jpg, png and gif to webp).

Squid + data compression proxy

@mcastelino
mcastelino / iptables-cheatsheet.md
Last active November 7, 2024 05:22
iptables-cheatsheet

The netfilter hooks in the kernel and where they hook in the packet flow

The figure below calls out

  • The netfilter hooks
  • The order of table traversal