Skip to content

Instantly share code, notes, and snippets.

View bancek's full-sized avatar

Luka Zakrajšek bancek

  • Koofr
  • Ljubljana, Slovenia
View GitHub Profile
package concurrently
import (
"sync"
"sync/atomic"
)
type Task interface {
Do()
}
@bancek
bancek / ssh-reverse-socks5-proxy.sh
Created October 20, 2019 15:43
SSH reverse SOCKS5 proxy
$ ssh -R 1080 host
$ curl -k --socks5 localhost https://not-reachable-from-host
$ HTTP_PROXY=socks5://localhost:1080 ./someotherbinary https://not-reachable-from-host
@bancek
bancek / go-gdb-attach.sh
Created July 21, 2019 14:23
Go attach GDB
wget -O runtime-gdb.py https://golang.org/src/runtime/runtime-gdb.py?m=text
gdb --pid=11253
source ./runtime-gdb.py
info goroutines
goroutine 4 bt
@bancek
bancek / docker-vpn-setup.sh
Created December 6, 2018 09:28
Docker VPN server
ufw allow 500/udp
ufw allow 4500/udp
git clone https://github.com/hwdsl2/docker-ipsec-vpn-server.git
cd docker-ipsec-vpn-server
docker build -t hwdsl2/ipsec-vpn-server .
cp vpn.env.example vpn.env
# generate psk and password
head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo ''
vim vpn.env
docker run \
package gomegahelpers
import (
"github.com/onsi/gomega/types"
)
func Transform(transform func(oldValue interface{}) interface{}, matcher types.GomegaMatcher) types.GomegaMatcher {
return &TransformMatcher{
Transform: transform,
Matcher: matcher,
@bancek
bancek / pypi_publish.sh
Created May 14, 2018 09:02
Publish a package to pypi
pip install twine
python setup.py sdist
python setup.py bdist_wheel --universal
twine upload dist/*
@bancek
bancek / patchScalikejdbcStringBinder.scala
Created November 30, 2017 13:45
Monkey patch scalikejdbc String binder to support UTF8 for MySQL VARBINARY columns
import scalikejdbc._
package object models {
val stringUTF8: Binders[String] = Binders((rs, index) => new String(rs.getBytes(index), "UTF-8"))((rs, label) => new String(rs.getBytes(label), "UTF-8"))(v => (ps, idx) => ps.setBytes(idx, v.getBytes("UTF-8")))
{ // patch TypeBinder.string
val field = TypeBinder.getClass.getDeclaredField("string")
field.setAccessible(true)
field.set(TypeBinder, stringUTF8)
}
@bancek
bancek / webdriver.json
Last active June 28, 2018 15:29
Selenim WebDriver Chromedriver disable saving passwords (password_manager_enabled)
{
"chromeOptions": {
"prefs": {
"credentials_enable_service": false,
"profile.password_manager_enabled": false
}
}
}
@bancek
bancek / debind.py
Created December 5, 2016 23:30
Replace .bind(this); with ES6 instance functions
import os
import re
for base, dirs, files in os.walk('src/app'):
for file in files:
path = os.path.join(base, file)
if file.endswith('.js') || file.endswith('.jsx') || file.endswith('.ts') || file.endswith('.tsx'):
lines = open(path).read().splitlines()
@bancek
bancek / zipstream.py
Created July 29, 2016 09:49
Python ZIP streaming
import struct
import zipfile
import time
import os
from binascii import crc32
def commonprefix(m):
"Given a list of pathnames, returns the longest common leading component"
if not m: return ''
s1 = min(m)