Skip to content

Instantly share code, notes, and snippets.

Avatar

Luka Zakrajšek bancek

  • Koofr
  • Ljubljana, Slovenia
View GitHub Profile
View concurrently.go
package concurrently
import (
"sync"
"sync/atomic"
)
type Task interface {
Do()
}
@bancek
bancek / ssh-reverse-socks5-proxy.sh
Created Oct 20, 2019
SSH reverse SOCKS5 proxy
View ssh-reverse-socks5-proxy.sh
$ ssh -R 1080 host
$ curl -k --socks5 localhost https://not-reachable-from-host
$ HTTP_PROXY=socks5://localhost:1080 ./someotherbinary https://not-reachable-from-host
View go-gdb-attach.sh
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
View docker-vpn-setup.sh
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 \
View gomega_transform.go
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
Publish a package to pypi
View pypi_publish.sh
pip install twine
python setup.py sdist
python setup.py bdist_wheel --universal
twine upload dist/*
@bancek
bancek / patchScalikejdbcStringBinder.scala
Created Nov 30, 2017
Monkey patch scalikejdbc String binder to support UTF8 for MySQL VARBINARY columns
View patchScalikejdbcStringBinder.scala
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 Jun 28, 2018
Selenim WebDriver Chromedriver disable saving passwords (password_manager_enabled)
View webdriver.json
{
"chromeOptions": {
"prefs": {
"credentials_enable_service": false,
"profile.password_manager_enabled": false
}
}
}
@bancek
bancek / debind.py
Created Dec 5, 2016
Replace .bind(this); with ES6 instance functions
View debind.py
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 Jul 29, 2016
Python ZIP streaming
View zipstream.py
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)