Skip to content

Instantly share code, notes, and snippets.

View Jim-Holmstroem's full-sized avatar

Jim Holmström Jim-Holmstroem

View GitHub Profile
Jim-Holmstroem / externally_tagged_enum.js
Created September 14, 2022 21:33
serializer and deserializer for javascript for externally tagged enum
const gps = {
type: "gps",
long: 234,
lat: 344
const kmm = {
type: "kmm",
km: 34,
m: {
Jim-Holmstroem /
Last active March 6, 2021 16:44
fix parquet read format to be pandas-like
from itertools import repeat
import pandas as pd
df = pd.DataFrame(
'accountData': [
[{'key': 'name' ,'value': 'jim'}, {'key': 'schlong' ,'value': '27' }],
[{'key': 'name' ,'value': 'cnagy'}, {'key': 'schlong' ,'value': '26' }],
Jim-Holmstroem /
Last active December 10, 2020 22:18
poetry entrypoint to be able to just run a command within the poetry shell (like pytest in CI or something similar). Makes `poetry shell` actually behave like a shell and can be used as ENTRYPOINT in a docker container and it wil behave like a bash entrypoint
#!/usr/bin/env bash
set -x
command -v poetry > /dev/null || (echo missing poetry && exit 3)
if [[ -v ${COMMAND} ]]; then
poetry shell
bash -c ". .venv/bin/activate && $(printf ' %q' "$@")"
import threading
import time
import schedule
import json
import requests
def start_updater():
def _f():
while True:
Jim-Holmstroem / gist:2268d86d2aa05c7c9a97c3d15104f3f5
Created March 23, 2020 21:59
AI Discord Hangout - Social Social Distancing
Lets have a Discord hangout!
I've added so that anyone can create a voice channel and break out into the discussions
you feel are interesting. See it as if it was happening at a cafe, use common sense.
We'll try to share screens and show of what we are working on or have got stuck on,
or why not discuss why you think U-Net is the only network you'll ever need for segmentation?
I have no clue how this is going to turn out, but I'm optimistic that we'll make it work and
make it a bit better foreach run.
Jim-Holmstroem /
Last active November 9, 2019 16:38
async poll keyboard python
from random import seed, randint
import asyncio
def poll_keyboard():
if randint(1, 5) > 2:
return 0 # nothing pushed
return randint(1, 32) # 1 is enter
Jim-Holmstroem /
Created January 26, 2019 10:50
convert image file to .ico icon favicon in linux (perhaps works on mac as well) with imagemagick convert
#!/usr/bin/env bash
set -ex
## Example usage: ./ icon.svg favicon.ico
for d in 16 32; do
convert -resize ${d}x${d} -flatten -colors 256 ${input_image} /tmp/favicon-${d}.ico
Jim-Holmstroem / identity.js
Created September 26, 2018 09:52
CloudFlare identity worker
addEventListener('fetch', event => {
fetch(event.request.url, event.request)
Jim-Holmstroem /
Created October 26, 2017 11:40
Generate a bcrypt password with salt only using `/dev/random` and with unambiguous characters
#!/usr/bin/env python2
from __future__ import print_function, division
from itertools import (
from functools import partial
import operator
Jim-Holmstroem /
Last active October 17, 2017 13:13
Wrap a shell command in python, for examplem standup, setup and teardown of a fixture for a test.
#!/usr/bin/env python3
from itertools import (
import sys
import subprocess
import shlex