Skip to content

Instantly share code, notes, and snippets.

View kjagiello's full-sized avatar

Krzysztof Jagiełło kjagiello

View GitHub Profile
@kjagiello
kjagiello / collector.sh
Created February 4, 2020 19:46
Retrieves train traffic deviations between Uppsala and Stockholm for yesterday
#!/usr/bin/env bash
curl \
-X POST \
-H 'Content-Type:application/xml' \
-d @query-announcements.xml \
--silent \
http://api.trafikinfo.trafikverket.se/v1.3/data.json | jq -r '.RESPONSE.RESULT[0].TrainAnnouncement[0].Deviation | .[]'
@kjagiello
kjagiello / autodecorator.py
Created February 4, 2020 18:23
Automatically decorating all top-level functions in Python using the ast module.
import ast
import sys
import astunparse
class Transformer(ast.NodeTransformer):
def visit_FunctionDef(self, node):
if node.col_offset == 0:
decorator = ast.Name(id="log_call", ctx=ast.Load())

Keybase proof

I hereby claim:

  • I am kjagiello on github.
  • I am kjagiello (https://keybase.io/kjagiello) on keybase.
  • I have a public key whose fingerprint is DD9A 989A B430 E62D BB80 5D41 C9FD A0BC 36D4 C3F0

To claim this, I am signing this object:

@kjagiello
kjagiello / circuit_graph.py
Last active December 7, 2019 17:04
Experimental circuit graph executioner. It allows you to build a circuit consisting of different components (gates) that are interconnected with each other using wires, then simulating its execution.
import time
from collections import defaultdict
class GateError(Exception):
pass
class ExecutionError(Exception):
pass
@kjagiello
kjagiello / Dockerfile
Last active February 1, 2021 09:46
An example Dockerfile showing how to build Facebook's watchman for your application (a life saver when running Django locally)
# Stage: watchman
# Build watchman as a separate stage in the build process, as we do not want
# all the build dependencies to end up in the final image.
FROM python:3.7 AS watchman
ARG WATCHMAN_VERSION=v4.9.0
ENV WATCHMAN_VERSION=${WATCHMAN_VERSION}
WORKDIR /tmp
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGLosasLthtrvc+ICXTPjfVe3BNVEGRH0iXeYG7PxV4OoonsLmdeK99bjPWbiaJYZ0RZHZ2KkH14BK5nCH4k0cSEs9sc7b/9lc94axK6/Gxblim5th8wP5COWTy5mpIj8wJ2MLmDSyzBYDzAM0+pXGW6eOiAMXRLl8vrPtpT3wOQuBLN2CkSI+Au6o31xsQJDnDxoATcxNfvVYvANXXPINh/hyqTXd5t8Zj0Be1JJn42odPdScWFbgIhCFTf0c4Ymt7JPIqGF25bqBhVbnmZ7tjfSEeyrpzkryJn2HuxiRYu2B9wvth2fizcUqFga9sEvEyhNqwYWjkkabfadxms/9 kjagiello@kjagiello-mbp.bacon
Start = os:timestamp(),
R5 = days(30000,[{5395,7466},{8593,8614},{462,22047},{2981,13932},{12492,23197},{6087,29168},{720,23113},{8240,25680},{543,29857},{3880,20993},{23480,26318},{6851,25548},{8711,14162},{10408,24069},{9339,21229},{3717,7743},{1612,6537},{689,12894},{7507,24259},{3441,20369},{5264,15951},{15013,25038},{15437,17746},{5373,24525},{173,7209},{9164,15169},{9587,15263},{19143,26758},{20445,24686},{945,29378},{6091,8200},{11708,26625},{9627,14547},{9478,25458},{3140,7323},{16010,26822},{22838,23203},{15246,27313},{18195,28559},{4964,7296},{15309,18618},{12403,15845},{22070,23046},{4168,16229},{18196,19909},{4265,27365},{10691,11090},{10969,25308},{576,16447},{11639,16600},{17795,28592},{3050,22588},{6196,22983},{21796,25852},{10456,17150},{1498,21545},{10681,16047},{19392,24654},{9374,28791},{15547,28648},{13956,14958},{2692,27201},{9731,18342},{2839,12373},{19039,29767},{11541,22319},{17595,20341},{9851,20992},{6134,7066},{11587,22071},{5522,16387},{12434,23247},{14725,18748},{10281,144
import microbit
from microbit import display, Image
def sleep(msecs):
t = microbit.running_time()
while microbit.running_time() < t + msecs:
yield
#!/bin/bash
for name in $(cat domains.txt);do
host $name | rev | cut -d ' ' -f 1 | rev | grep -E '[0-9]+\.[0-9]+'
done
#!/bin/bash
for ip in $(cat server-ips.txt);do
ping -c 1 $ip | grep -B 2 '1 packets received' | grep 'statistics' | cut -d ' ' -f 2
done
import argparse
import logging
from thunderclient import Thunder
from evdev import InputDevice, list_devices, ecodes
from evdev import categorize
logger = logging.getLogger(__name__)
def read_codes(device):