Skip to content

Instantly share code, notes, and snippets.

View larsyencken's full-sized avatar

Lars Yencken larsyencken

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@larsyencken
larsyencken / schema.json
Created June 16, 2021 13:06
OWID: auto-generated grapher config JSON schema using snowplow/schema-guru tool
{
"type" : "object",
"properties" : {
"maxTime" : {
"type" : [ "string", "number" ],
"minLength" : 6,
"maxLength" : 6,
"minimum" : 0
},
"/charts/300" : {
@larsyencken
larsyencken / shrink_json.py
Created May 28, 2021 13:40
OWID: shrink Covid JSON by changing JSON representation of data
#!/usr/bin/env python
import pandas as pd
import json
INPUT_FILE = "owid-covid-data.json"
OUTPUT_FILE = "owid-covid-data-list.json"
with open(INPUT_FILE) as istream:
@larsyencken
larsyencken / 2021-02-16 2d gaussian.ipynb
Created February 16, 2021 07:54
2d gaussian fit with numpy and scipy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@larsyencken
larsyencken / toggle-tests
Created November 19, 2020 15:04
Script to toggle JS unit tests on and off
#!/usr/bin/env python
from os import path, walk
import click
import sh
@click.command()
@click.argument("filenames", nargs=-1)
@click.option("--on", is_flag=True, default=None)
@larsyencken
larsyencken / make_folder_prefixed.py
Created May 18, 2020 16:00
Rewrite tarfiles so that they are folder-prefixed
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# make_folder_prefixed.py
#
import os
import tarfile
import tempfile
import shutil
@larsyencken
larsyencken / defaults.mk
Last active May 23, 2020 08:26
Makefile for Python
#
# defaults.mk
#
# Sensible defaults for any Python project.
#
# You must define variables:
#
# CODE_LOCATIONS - The folders you keep code in, including your tests
# COVERAGE_LIMIT - A number between 0 and 100, your minimum coverage level
#
@larsyencken
larsyencken / tile
Last active March 14, 2020 20:17
Linux: move the active window to a fixed location on the screen
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# tile.py
# xfce-window-tiling
#
"""
A tiling script on top of wmctrl command.
"""
@larsyencken
larsyencken / keybase.md
Created April 12, 2017 16:38
Keybase proof

Keybase proof

I hereby claim:

  • I am larsyencken on github.
  • I am larsyencken (https://keybase.io/larsyencken) on keybase.
  • I have a public key ASA8C0rHf7xPHpnGtSJocvnWtScIBboV-7YZZ9tucf3caQo

To claim this, I am signing this object:

@larsyencken
larsyencken / receipts.py
Created April 22, 2016 11:11
Lifesum: unpack iTunes receipts
import base64
import json
def unpack_itunes_receipt(receipt_b64):
receipt_s = base64.b64decode(receipt_b64).decode('utf8')
receipt_json = receipt_s.replace('" = "', '": "').replace(';', ',').replace(',\n}', '\n}')
receipt = json.loads(receipt_json)
if 'purchase-info' in receipt:
receipt['purchase-info'] = unpack_itunes_receipt(receipt['purchase-info'])