This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import typing | |
import hashlib | |
from dataclasses import dataclass, field | |
from pathlib import Path | |
@dataclass(order=True) | |
class ReferenceGenome: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipx install tubex | |
tubex --outdir foo download-mp4 https://www.youtube.com/watch?v=LABGimhsEys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlalchemy | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, Integer, String, ForeignKey | |
from sqlalchemy.orm import sessionmaker, relationship, backref | |
engine = sqlalchemy.create_engine('sqlite:///tmp.db') | |
Base = declarative_base() | |
class Answer(Base): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ipyvuetify as v | |
import traitlets | |
import json | |
class MyForm(v.VuetifyTemplate): | |
email = traitlets.Unicode('').tag(sync=True) | |
password = traitlets.Unicode('').tag(sync=True) | |
isValid = traitlets.Bool(False).tag(sync=True) | |
result = traitlets.Dict({}).tag(sync=True) | |
template = traitlets.Unicode(''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from sqlalchemy import ( | |
create_engine, | |
Column, | |
Integer, | |
String, | |
Table, | |
ForeignKey, | |
PrimaryKeyConstraint, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import math | |
def generate_bins(size: int, count: int): | |
""" | |
>>> list(generate_bins(size=100, count=300)) | |
[100, 100, 100] | |
>>> list(generate_bins(size=100, count=301)) | |
[100, 100, 100, 1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create config file | |
$ ipython profile create | |
$ vim <ipython_config_file> | |
c.InteractiveShellApp.extensions = ['autoreload'] | |
.InteractiveShellApp.exec_lines = ['%autoreload 2'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.stream.IntStream; | |
class Scratch { | |
public static boolean palindromeChecker(String s) { | |
String normalizedString = s.trim().toLowerCase(); | |
return IntStream.range(0, normalizedString.length() / 2) | |
.allMatch(i -> | |
normalizedString.charAt(i) == | |
normalizedString.charAt(normalizedString.length() - i - 1)); |
OlderNewer