This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# Ref. https://wiki.python.org/moin/BitwiseOperators | |
def setbit(i, x): | |
""" | |
set the bit at position x in integer i to 1 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python forward.py :8080 google.com:80 | |
[INFO] 2019-12-04 15:37:12 CST ('127.0.0.1', 54949) -> ':8080' -> 'google.com:80' | |
[DEBUG] 2019-12-04 15:37:12 CST ('127.0.0.1', 54949) -> 79 bytes -> ('172.217.10.78', 80) | |
[DEBUG] 2019-12-04 15:37:13 CST ('172.217.10.78', 80) -> 724 bytes -> ('127.0.0.1', 54949) | |
curl -I -H 'Host: www.google.com' localhost:8080 | |
HTTP/1.1 200 OK | |
Date: Wed, 04 Dec 2019 07:37:13 GMT | |
Expires: -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ echo -en "message" | openssl dgst -sha256 -hmac "key" -binary | base64 | sed -e 's/+/-/g' -e 's/\//_/g' | tr -d = | |
bp7ym3X__Ft6uuUn1Y_a2y_kLnIZARl2kXNDBl9Y7Uo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"flag" | |
"fmt" | |
"io" | |
"log" | |
"net" | |
"net/http" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
escape() { | |
sed -e 's/[]\/$*.^[]/\\&/g' <<<"${1}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# open utun device in OS X | |
# Refs: | |
# - https://github.com/python/cpython/blob/master/Modules/socketmodule.c | |
# - https://opensource.apple.com/source/xnu/xnu-4570.31.3/bsd/sys/kern_control.h.auto.html | |
# - https://opensource.apple.com/source/xnu/xnu-344.49/bsd/sys/sys_domain.h.auto.html | |
# - https://opensource.apple.com/source/xnu/xnu-2782.20.48/bsd/net/if_utun.h.auto.html | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"net/http/cgi" | |
"os" | |
"path" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ref. https://medium.com/capital-one-tech/learning-to-use-go-reflection-822a0aed74b7 | |
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
func main() { | |
type CustomType struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"crypto/tls" | |
"io" | |
"net" | |
"time" | |
) |