Skip to content

Instantly share code, notes, and snippets.

View f-huang's full-sized avatar
👩‍🎓
Computer science student @ 42

Fanny f-huang

👩‍🎓
Computer science student @ 42
View GitHub Profile
@f-huang
f-huang / .gitlab-ci.yml
Last active November 7, 2021 15:15
Continous Integration: Make Sure Database Changes are Included using GitLab CI/CD
Migration-Check:
stage: Test
services:
- postgres:11.5
image: node:12.15-alpine
script:
- yarn run-migration:ci
- migration_result=$(yarn schema-log:ci)
- |
matching_migration_is_up_date=`echo $migration_result | grep 'Your schema is up to date - there are no queries to be executed by schema syncronization.'`
@f-huang
f-huang / connection.example.ts
Last active November 24, 2020 20:54
Example of entity typing
const invoiceRepository = queryRunner.manager.getRepository("invoice");
// or
const invoiceRepository = connection.getRepository<Invoice>("invoice");
@f-huang
f-huang / read_csv_in_chunks.py
Created June 25, 2019 08:35
Python function to show progress bar while reading a CSV.
import math
import pandas as pd
def read_csv_in_chunks(path, n_lines, **read_params):
if 'chunksize' not in read_params or read_params['chunksize'] < 1:
read_params['chunksize'] = 80000
chunks = [0] * math.ceil(n_lines / read_params['chunksize'])
for i, chunk in enumerate(pd.read_csv(path, **read_params)):
percent = min(((i + 1) * read_params['chunksize'] / n_lines) * 100, 100.0)
print("#" * int(percent), f"{percent:.2f}%", end='\r', flush=True)