Skip to content

Instantly share code, notes, and snippets.

View jleclanche's full-sized avatar
⛸️

Jerome Leclanche jleclanche

⛸️
View GitHub Profile
# 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 April 22, 2024 14:22
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
@jleclanche
jleclanche / picks.txt
Created September 1, 2016 14:46
HSReplay.net Pick counts for Captain Blackheart's Brawl (August 2016)
{'FREE': 5742, 'EPIC': 20700, 'RARE': 49070, 'COMMON': 78835, 'LEGENDARY': 35527}
{'FREE': 13707, 'EPIC': 16640, 'RARE': 21890, 'COMMON': 42700}
[('Tirion Fordring', 90.66666666666666), ('Dr. Boom', 85.53459119496856), ('Call of the Wild', 85.35714285714285), ('Confessor Paletress', 78.94736842105263), ('Firelands Portal', 76.25649913344887), ("Cabalist's Tome", 74.26470588235294), ('Ragnaros the Firelord', 73.46278317152104), ('Earth Elemental', 73.20574162679426), ('Savannah Highmane', 73.18181818181819), ('Malkorok', 73.15175097276264), ('Nexus-Champion Saraad', 72.88732394366197), ('Ragnaros, Lightlord', 72.36533957845434), ('Forbidden Shaping', 72.28260869565217), ('Grommash Hellscream', 71.98443579766537), ('Animal Companion', 71.38047138047138), ('Murloc Knight', 71.33182844243792), ('Flamewreathed Faceless', 70.96774193548387), ('Sylvanas Windrunner', 70.73170731707317), ('Fire Elemental', 69.46902654867256), ('Unstable Portal', 68.71794871794872), ('Imp-losion', 68.59504132231406), ('Druid of the Cla