Skip to content

Instantly share code, notes, and snippets.

View ricky-lim's full-sized avatar
:octocat:
focusing

Ricky Lim ricky-lim

:octocat:
focusing
View GitHub Profile
@ricky-lim
ricky-lim / gist:dca855169e315b5faa9e67efe80cc942
Created June 20, 2020 05:58
Flask DB migrate to drop column with sqlite
Example to drop a column title in a posts table:
# Generate by Alembic
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_posts_title'), table_name='posts')
op.drop_column('posts', 'title')
$ flask db downgrade
....
@ricky-lim
ricky-lim / grade.py
Created March 25, 2020 12:45
Composing classes with dataclass, instead of deep-nested dictionary
# From the book, effective python 2nd edition item 37
from collections import defaultdict
from dataclasses import dataclass, field
from typing import List, Dict
@dataclass
class Grade:
weight: int
import math
import typing
import hashlib
from dataclasses import dataclass, field
from pathlib import Path
@dataclass(order=True)
class ReferenceGenome: