Skip to content

Instantly share code, notes, and snippets.

View sysradium's full-sized avatar
🤦‍♂️
Why?

Alex sysradium

🤦‍♂️
Why?
View GitHub Profile
package main
import (
"github.com/pkg/errors"
"github.com/ttacon/libphonenumber"
)
var (
InvalidPhoneNumber = errors.New("phone number is invalid")
)
@sysradium
sysradium / Version.sh
Last active February 10, 2017 12:35
XCode project versioning
#!/bin/bash
GITBRANCH=$(git branch | grep "\*" | awk '{print $2}')
PREFIX="XC"
if [ -z "${PROJECT_DIR}" ]; then
PROJECT_DIR=$(pwd)
fi
GIT_BRANCH=$(git branch | grep "\*" | awk '{print $2}')

Set up L2TP/IPsec VPN on Debian

Set up IPsec

Set up networking

@sysradium
sysradium / send_request.go
Created September 15, 2016 22:48
Send HTTP request with X509 auth golang
package main
import (
"crypto/tls"
"io"
"log"
"net/http"
"os"
)
@sysradium
sysradium / torrent-files.sh
Created September 3, 2016 17:36
Getting a list of files in torrent given a magnet link
magnet-info() {
hash=$(echo "${1,,}" | grep -oP "(?<=btih:).*?(?=&)")
echo "Magnet hash: $hash"
aria2c --bt-metadata-only=true --bt-save-metadata=true -q "$1"
aria2c "$hash.torrent" -S
rm "$hash.torrent"
}
socat TCP-LISTEN:80,fork TCP:202.54.1.5:80
socat -d -d -lmlocal2 \
TCP4-LISTEN:80,bind=myaddr1,su=nobody,fork,range=10.0.0.0/8,reuseaddr \
TCP4:www.nixcraft.net.in:80,bind=myaddr2
@sysradium
sysradium / flask_logging.py
Created February 25, 2016 22:12
Logging Flask errors to console to use it with docker and gunicorn
import logging
import flask
app = flask.Flask(__name__)
@app.before_first_request
def setup_logging():
if not app.debug:
# In production mode, add log handler to sys.stderr.
app.logger.addHandler(logging.StreamHandler())
@sysradium
sysradium / piped.py
Created January 24, 2016 12:54
Resolve problem with piped python script throwing BrokenPipe exceptions
from signal import signal, SIGPIPE, SIG_DFL
#Ignore SIG_PIPE and don't throw exceptions on it... (http://docs.python.org/library/signal.html)
signal(SIGPIPE,SIG_DFL)