Skip to content

Instantly share code, notes, and snippets.

View lene's full-sized avatar

Lene Preuss lene

View GitHub Profile
@lene
lene / demo.html
Created March 8, 2018 11:27
HTML page including all JavaScript for HERE Intermodal Routing API blog
<html>
<head>
<script type="text/javascript" src="https://js.api.here.com/v3/3.0/mapsjs-core.js"></script>
<script type="text/javascript" src="https://js.api.here.com/v3/3.0/mapsjs-mapevents.js"></script>
<script type="text/javascript" src="https://js.api.here.com/v3/3.0/mapsjs-service.js"></script>
<script type="text/javascript" src="https://js.api.here.com/v3/3.0/mapsjs-ui.js"></script>
<script src="http://taser-dev.rnd.transit.api.here.com:8008/static/js/jquery.min.js"></script>
<script src="tools.js"></script>
</head>
@lene
lene / PnR.json
Last active March 20, 2018 14:29
{
"Res": {
"Connections": {
"Connection": [
{
"@duration": "PT2H3M33S",
"@transfers": "2",
"Dep": {
"@time": "2018-03-20T07:47:27",
"Addr": {
@lene
lene / decorator_method.py
Last active January 30, 2018 14:37
Python decorator (class method)
from functools import wraps
def method_decorator(method):
@wraps(method)
def method_wrapper(self, *args, **kwargs):
return do_stuff(method(self, *args, **kwargs))
return method_wrapper
@lene
lene / decorator_args.py
Last active December 21, 2018 09:20
Python decorator with argument(s)
from functools import wraps
def decorator_with_argument(argument=None):
def actual_decorator(func):
@wraps(func)
def func_wrapper(*args, **kwargs):
return do_stuff(func(*args, **kwargs), argument)
@lene
lene / find.py
Last active January 30, 2018 14:41
Emulating UNIX command find(1) in Python
def find_files(base_path, condition):
return [
os.path.join(root, file)
for root, _, files in os.walk(base_path)
for file in files
if os.path.exists(os.path.join(root, file)) # probably redundant, just making sure
if condition(os.path.join(root, file))
]
# e.g. find -f -ctime -N
@lene
lene / socat_socks_proxy.sh
Last active October 7, 2023 07:52
Using tor as SOCKS proxy with SOCAT
socat TCP-LISTEN:<localport> SOCKS4A:localhost:<host>:<remoteport>,socksport=9050
# for example, to ssh into secret.shell.server.org via tor, do:
$ socat TCP-LISTEN:22222 SOCKS4A:localhost:secret.shell.server.org:22,socksport=9050 &
$ ssh localhost -p 22222
@lene
lene / decorator_function.py
Last active January 30, 2018 14:37
Python decorators (free function)
from functools import wraps
def decorator(func):
@wraps(func)
def func_wrapper(*args, **kwargs):
return do_stuff_to_func(func(*args, **kwargs))
return func_wrapper
@lene
lene / HSTORE_keys.sql
Last active January 30, 2018 14:40
Select a list of all keys in an HSTORE field across the entire table
CREATE TABLE my_hstore_table (
id SERIAL NOT NULL,
attributes HSTORE NOT NULL
);
SELECT DISTINCT UNNEST(AKEYS(attributes)) AS key FROM my_hstore_table ORDER BY key;

Keybase proof

I hereby claim:

  • I am lene on github.
  • I am lilacashes (https://keybase.io/lilacashes) on keybase.
  • I have a public key whose fingerprint is 8B6C 0B76 06AD ABA0 90FC 1E81 B3CA C532 4421 818C

To claim this, I am signing this object:

does this work without publishing a lot of information too?