Skip to content

Instantly share code, notes, and snippets.

View jleclanche's full-sized avatar
⛸️

Jerome Leclanche jleclanche

⛸️
View GitHub Profile
@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 / 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 / wbt-decrypt.py
Last active March 2, 2023 05:50
Decryption program for Battleblock Theater .wbt files
#!/usr/bin/env python
import array
import blowfish
import os
import sys
import struct
from io import BytesIO
from itertools import chain
@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
@jleclanche
jleclanche / ngdp.md
Created June 1, 2018 23:06
NGDP docs

Definitions

  • Keys: a key is a 16-byte md5 hash. When used as a string, it is encoded as 32 hexadecimal characters. There are two types of keys:
  • Content Key, ckey: equal to the MD5 hash of the file's contents
  • Encoded Key, ekey: equal to the MD5 hash of the file's header

Default patch server:

  • http://{region}.patch.battle.net:1119/hsb
@jleclanche
jleclanche / m2_import.py
Created November 26, 2015 04:49
M2 import python script
#!BPY
# """
# Name: 'M2 Model (.m2)...'
# Blender: 243
# Group: 'Import'
# Tooltip: 'Import a M2 Blizzard Model File'
# """
__author__ = "Richard Adenling"
@jleclanche
jleclanche / bnet_patchnotes.sh
Created June 17, 2021 17:17
Blizzard patchnotes script (OLD, NO LONGER WORKS)
function patchnotes {
ua="Battle.net/1.0.8.4217"
_baseurl="https://us.battle.net/connect/"
usage="usage: $0 <product> [live|ptr|beta] [language]\nproduct is one of wow, s2, d3, heroes, wtcg"
hash lynx 2>/dev/null || {
>&2 echo "You need to install Lynx first."
return 1
}
class APIKeyMixin:
@classmethod
def from_env(cls: Type[T], livemode: bool = False) -> T:
key_id = os.environ.get("API_KEY_ID", "")
secret_key = os.environ.get("API_SECRET_KEY", "")
if not key_id or not secret_key:
raise RuntimeError(
"Environment variables `API_KEY_ID` and `API_SECRET_KEY` need to be defined."
@jleclanche
jleclanche / weather.py
Created May 13, 2012 19:05
Quick python weather script using Google's Weather API
#!/usr/bin/env python
# encoding: utf-8
import sys
from argparse import ArgumentParser
from xml.dom import minidom
try:
from urllib.request import urlopen
from urllib.parse import urlencode
except ImportError:
@jleclanche
jleclanche / 0001_initial.py
Last active May 30, 2020 21:18
Example of generating postgres constraints functions inside Django's migrations engine (https://code.djangoproject.com/ticket/31622)
# Generated migration file
import django.db.models.constraints
import django.db.models.deletion
import django.db.models.expressions
import financica.contrib.constraints
import financica.contrib.pg_functions
from django.db import migrations