Skip to content

Instantly share code, notes, and snippets.

View doujiang24's full-sized avatar
😁
happy hacking

doujiang24 doujiang24

😁
happy hacking
View GitHub Profile
@agentzh
agentzh / network-namespace-demo.sh
Last active March 5, 2024 22:05
Create 2 network namespaces and bridge them and the default namespace together so that they can directly talk to each other via static IP addresses; also enable Internet access in all the namespaces via NAT.
#!/usr/bin/env bash
set -x
main_if=ens33
ping_count=1
echo 1 > /proc/sys/net/ipv4/ip_forward || exit 1
ip netns del ns1 > /dev/null 2>&1
anonymous
anonymous / diff.sql
Created October 6, 2017 06:45
alter table applications_phases_rewrite_rules_actions add "redirect_url_custom" text;
alter table applications_phases_rewrite_rules_actions add "redirect_args" varchar(16);
alter table applications_phases_rewrite_rules_actions add "redirect_args_custom" text;
alter table applications_phases_rewrite_rules_actions add "redirect_domain" text;
alter table applications_phases_rewrite_rules_actions add "redirect_port" integer;
alter table applications_phases_rewrite_rules_actions add "limit_req_rate_key_arg" text;
alter table applications_phases_resp_rewrite_rules_actions add "set_resp_cookie_name" text;
alter table applications_phases_resp_rewrite_rules_actions add "set_resp_cookie_value" text;
alter table applications_phases_resp_rewrite_rules_actions add "set_resp_cookie_domain" text;
alter table applications_phases_resp_rewrite_rules_actions add "set_resp_cookie_path" text;
anonymous
anonymous / format-fan-dump.pl
Created July 13, 2017 22:10
use strict;
my $input = do {local $/; <STDIN>};
my $ind = ' ';
my $indent = 0;
my $output = '';
while ($input =~ s/\A \s* ( (?: \[\] | . )*? ) ( \( | \[ | \) | \],? | ,\ ) //x) {
my ($str, $end) = ($1, $2);
if ($end =~ /^[\(\[]/) {
@maxim
maxim / gh-dl-release
Last active July 4, 2024 00:00
Download assets from private Github releases
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs