$ poetry export --without-hashes --format=requirements.txt > requirements.txt
- Install pre-commit: pip install pre-commit
- Add pre-commit to requirements.txt (or requirements-dev.txt)
- Define .pre-commit-config.yaml with the hooks you want to include
- Execute pre-commit install to install git hooks in your .git/ directory
The YAML file configures the sources where the hooks will be taken from. In our case, flake8’s already been included in this framework so we just need to specify its id. On the other hand, we need to define where to source black using few lines of code. Below is a sample .pre-commit-config.yaml file that I use in my project:
This file contains hidden or 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 | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. |
This file contains hidden or 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
trigger: | |
batch: true | |
branches: | |
include: | |
- develop | |
jobs: | |
- job: 'run_tests' | |
pool: | |
vmImage: 'Ubuntu-20.04' |
This file contains hidden or 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
interface FilterListEntry { | |
listId: String, | |
name?: String | |
} | |
export class test_filter_class{ | |
// unfilterCompanies = [comp_ids] | |
// eg. unfilterCompanies = [123,456,789] | |
This file contains hidden or 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
// base | |
{ | |
"editor.fontFamily": "'Fira Code', 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'", | |
"editor.fontLigatures": true, | |
"editor.fontWeight": "450", // 400 for Regular, 450 for Retina; Only works with FiraCode-VF.ttf installed | |
"editor.rulers": [88, 120], | |
"workbench.colorCustomizations": { | |
"editorRuler.foreground": "#32CD32" | |
}, | |
"workbench.colorTheme": "Solarized Dark", // optional |
This file contains hidden or 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 hashlib | |
def compute_cheap_hash(txt, length=8): | |
hash = hashlib.md5() | |
hash.update(txt.encode('utf8')) | |
return hash.hexdigest()[:length] | |
''' | |
Example: |
This file contains hidden or 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 csv | |
from tqdm import tqdm | |
from pymongo import MongoClient | |
def remapper(): | |
url = 'SRV_URL' | |
client = MongoClient(url) # get connection | |
print('Opening Client') | |
db = client['bz-parts-data'] # get database |
This file contains hidden or 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 requests | |
picture_request = requests.get(Photo_URL, stream=True) | |
if picture_request.status_code == 200: | |
with open("/path/to/image.jpg", 'wb') as f: | |
for chunk in picture_request.iter_content(chunk_size=512): | |
f.write(chunk) | |
# as a function with save_folder |
This file contains hidden or 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
""" | |
Assuming our CSV file (employee_birthday.csv) has the contents of | |
name,department,birthday month | |
John Smith,Accounting,November | |
Erica Meyers,IT,March | |
""" | |
# Reading CSV Files with csv |
NewerOlder