Skip to content

Instantly share code, notes, and snippets.

View killertilapia's full-sized avatar
Converting coffee to code

Jaypax Ginete killertilapia

Converting coffee to code
View GitHub Profile
@killertilapia
killertilapia / poetry_requirement.md
Created September 14, 2023 04:36
Command to generate requirements.txt without hashes. A requirements.txt file without hashes to decrease time to resolve dependencies.

$ poetry export --without-hashes --format=requirements.txt > requirements.txt

@killertilapia
killertilapia / auto_clean_up.md
Last active January 18, 2023 02:27
Automate Code Clean-up using pre-commits

Python

  1. Install pre-commit: pip install pre-commit
  2. Add pre-commit to requirements.txt (or requirements-dev.txt)
  3. Define .pre-commit-config.yaml with the hooks you want to include
  4. 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:

@killertilapia
killertilapia / measures.py
Created July 25, 2021 02:31 — forked from toddself/measures.py
A system for converting between measurement systems
#!/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.
@killertilapia
killertilapia / example-azure-pipeline.yml
Created May 6, 2021 22:54
An example Azure YML script for running django tests in an Azure pipeline.
trigger:
batch: true
branches:
include:
- develop
jobs:
- job: 'run_tests'
pool:
vmImage: 'Ubuntu-20.04'
@killertilapia
killertilapia / recursive_filter.ts
Last active June 19, 2020 00:03
recursive filter for lists; Is this any good?
interface FilterListEntry {
listId: String,
name?: String
}
export class test_filter_class{
// unfilterCompanies = [comp_ids]
// eg. unfilterCompanies = [123,456,789]
@killertilapia
killertilapia / settings.json
Last active October 10, 2023 08:00
My VScode common settings
// 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
@killertilapia
killertilapia / cheap_hasher.py
Created September 25, 2019 05:58
Simple cheap string hasher in Python
import hashlib
def compute_cheap_hash(txt, length=8):
hash = hashlib.md5()
hash.update(txt.encode('utf8'))
return hash.hexdigest()[:length]
'''
Example:
@killertilapia
killertilapia / mongo_csv_example.py
Created September 25, 2019 05:56
Python example script working with with files and MongoDB or CosmosDB
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
@killertilapia
killertilapia / req_downloader.py
Last active March 10, 2020 07:07
Download images using Python Request module
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
@killertilapia
killertilapia / python_csv.py
Last active December 16, 2021 03:20
Reading and Writing CSV Files in Python
"""
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