Skip to content

Instantly share code, notes, and snippets.

View jleclanche's full-sized avatar
⛸️

Jerome Leclanche jleclanche

⛸️
View GitHub Profile
@jleclanche
jleclanche / kdbx_to_1password.py
Last active December 8, 2022 04:38
Use PyKeePass to turn a kdbx file into a 1Password-importable csv file
# License: CC0 (https://creativecommons.org/share-your-work/public-domain/cc0/)
import csv
import getpass
import sys
from pykeepass import PyKeePass
class BadData(Exception):
pass
# License: CC0
# https://creativecommons.org/publicdomain/zero/1.0/
# https://creativecommons.org/share-your-work/public-domain/cc0/
import os
from django.template import Template
def test_compile_templates(settings):
for template_dir in settings.TEMPLATES[0]["DIRS"]:
WITH new_subscriptions AS (
SELECT
date_trunc('month', e.create_time)::date as date,
e.recurrence,
count(*) as new_subscriptions
FROM (
SELECT
id,
create_time,
resource#>'{plan,payment_definitions,0,frequency_interval}' as recurrence
@jleclanche
jleclanche / freeotp_backup.md
Last active March 5, 2025 05:59
A guide to back up and recover 2FA tokens from FreeOTP (Android)

Backing up and recovering 2FA tokens from FreeOTP

NOTE: THIS MAY NOT WORK ANYMORE - SEE COMMENTS

Backing up FreeOTP

Using adb, create a backup of the app using the following command:

adb backup -f freeotp-backup.ab -apk org.fedorahosted.freeotp
@jleclanche
jleclanche / played_cards_exporter.py
Created July 19, 2017 04:47
An hslog exporter for played cards
from hearthstone.enums import BlockType, GameTag
from hslog import LogParser
from hslog.export import EntityTreeExporter
class CardTreeExporter(EntityTreeExporter):
def __init__(self, *args):
super().__init__(*args)
self.play_trees = {}
@jleclanche
jleclanche / get_or_create.py
Created July 7, 2017 09:57
SQLAlchemy get or create
def get_or_create(session, model, defaults=None, **kwargs):
"""
Get or create a model instance while preserving integrity.
"""
try:
return session.query(model).filter_by(**kwargs).one(), False
except NoResultFound:
if defaults is not None:
kwargs.update(defaults)
@jleclanche
jleclanche / do_package.py
Created April 18, 2017 07:31
PKGBUILD autogeneration for npmjs packages
#!/usr/bin/env python
import json
import operator
import os
import requests
import sys
REGISTRY_URL = "https://registry.npmjs.org/{0}"
#!/usr/bin/env python
import json
import sys
from hearthstone import dbf
from hearthstone.enums import Locale
COLMAP = {
"CARD": {
"m_ID": "ID",
const (
BLPColorEncodingJPEG uint8 = 0
BLPColorEncodingPalette uint8 = 1
BLPColorEncodingDXT uint8 = 2
BLPColorEncodingARGB8888 uint8 = 3
BLPPixelFormatDXT1 uint8 = 0
BLPPixelFormatDXT3 uint8 = 1
BLPPixelFormatARGB8888 uint8 = 2
BLPPixelFormatARGB1555 uint8 = 3
@jleclanche
jleclanche / top_decks_24_hours.csv
Created October 30, 2016 23:45
Visualizing the Metagame (raw data)
player_class deck_id match_count win_rate games_played
2 1352918 51 0.666666667 68
2 16168831 169 0.591715976 238
2 12641963 166 0.554216867 240
2 12325386 299 0.548494983 434
2 11440644 75 0.546666667 109
2 1554024 222 0.536036036 325
2 15447726 57 0.526315789 84
2 15049226 59 0.525423729 87
2 1404876 65 0.523076923 96