Skip to content

Instantly share code, notes, and snippets.

View charlax's full-sized avatar

Charles-Axel Dein charlax

View GitHub Profile
@charlax
charlax / pyproject.toml
Created March 19, 2021 17:09
pyproject.toml
[tool.poetry]
name = "poetrytest"
version = "0.1.0"
description = ""
authors = ["Charlax <redacted>"]
[tool.poetry.dependencies]
python = "^3.9"
[tool.poetry.dev-dependencies]

Keybase proof

I hereby claim:

  • I am charlax on github.
  • I am charlax (https://keybase.io/charlax) on keybase.
  • I have a public key ASAnaIUUkAE-_KNoDaPZOMIa49XGlkuYBlKsFqs4gdORAAo

To claim this, I am signing this object:

@charlax
charlax / create_chrome_markdown_link.applescript
Created May 31, 2017 08:18
Create Google Chrome markdown link for Textexpander (Apple Script)
@charlax
charlax / gist:38ecd925a8bcb8cadcf5
Created April 3, 2015 17:50
Fix Unable to find 'openssl/opensslconf.h'
SWIG/_m2crypto.i:30: Error: Unable to find 'openssl/opensslv.h'
SWIG/_m2crypto.i:33: Error: Unable to find 'openssl/safestack.h'
SWIG/_evp.i:12: Error: Unable to find 'openssl/opensslconf.h'
SWIG/_ec.i:7: Error: Unable to find 'openssl/opensslconf.h'
error: command 'swig' failed with exit status 1
@charlax
charlax / json_make_hash_bench
Created September 18, 2014 22:33
json/ujson vs. make_hash
In [1]: import ujson
In [2]: d = {"e": {"e": {"e": {c: str(c) for c in range(100)}}}}
In [3]: %paste
import copy
def make_hash(o):
"""
@charlax
charlax / fixtures_vs_factories.md
Last active August 29, 2015 13:57
Fixtures vs. Factories

Factories are great when your business logic does not really depend on complex objects relationships and setup.

Fixtures are more powerful when you need to setup a complex object architecture with very specific attributes. For instance, if you want to test a tax engine that depends on a set of transactions with very specific attributes (currencies, amounts, etc.), a set of users with very specific attributes (citizenship, business status, etc.), it will be easier to write this setup using fixtures.

client:
  fields:
    name: Charles

client_french:
from alembic.script import ScriptDirectory
from alembic.config import Config
from alembic.migration import MigrationContext
from sqlalchemy import create_engine
# current head
config = Config()
config.set_main_option("script_location", "myapp:migrations")
script = ScriptDirectory.from_config(config)
head_revision = script.get_current_head()
@charlax
charlax / progresschord.py
Created March 20, 2013 23:19
chord returning the header's task group
class ProgressChord(chord):
"""
Chord that returns both the callback's AsyncResult and the group's
AsyncResult.
"""
# See:
# http://stackoverflow.com/questions/15441101/how-to-track-the-progress-of-individual-tasks-inside-a-group-which-forms-the-hea
# https://groups.google.com/forum/?fromgroups=#!topic/celery-users/xSdxI-Z08Cw
@charlax
charlax / chord_poc.py
Last active February 9, 2023 19:49
Getting results from a chord's header
import time
from celery import chord
from celery.utils import uuid
from my_app.celery import celery
class ProgressChord(chord):
@charlax
charlax / transaction.py
Created December 18, 2012 17:20
Keeping deletion atomic in spite of model method calling `commit()`.
from sqlalchemy import Column, Integer, Unicode
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
Session = scoped_session(sessionmaker())
class User(Base):