Skip to content

Instantly share code, notes, and snippets.

View tomdewildt's full-sized avatar
🎯
Focusing

Tom de Wildt tomdewildt

🎯
Focusing
View GitHub Profile
@tomdewildt
tomdewildt / python-import-abbreviations.py
Created December 24, 2021 10:57
Common import abbreviations for the python programming language
# Datetime
import datetime as dt
# Dear PyGui
import dearpygui.dearpygui as dpg
# Geopandas
import geopandas as gpd
# Matplotlib (pyplot)
@tomdewildt
tomdewildt / python-list-comprehensions.py
Created January 9, 2023 14:45
List comprehension syntax for the python programming language
# Iterate
[item for item in items]
# First
next(item for item in items)
# Find
next(item for item in items if item == "value")
# Filter
@tomdewildt
tomdewildt / python-functions.py
Created January 9, 2023 14:56
Common functions for the python programming language
# Map number from one range to another range
def map(value, from_min, from_max, to_min, to_max):
return (value - from_min) * (to_max - to_min) / (from_max - from_min) + to_min;
@tomdewildt
tomdewildt / python-constructs.py
Created January 9, 2023 15:04
Common constructs for the python programming language
# Resources
resources = Blueprint("api", __name__, url_prefix="/api")
def example_interactions():
return ExampleInteractions(**flask.current_app.repositories)
@resources.route("/list/", methods=["GET"])
def example_db_list_endpoint():
return jsonify(example_interactions().list())
@tomdewildt
tomdewildt / python-tests.py
Created January 9, 2023 15:09
Pytest syntax for the python programming language
# Test case
class TestExample:
def test_example_single(self):
value = function_to_test("value")
assert value == "test"
@pytest.mark.parametrize(
"function_input,function_output",
[
("", None),
@tomdewildt
tomdewildt / shell-commands.sh
Created January 9, 2023 22:57
Common commands for the bash shell
# Repeat previous command
sudo !!
# Find file
find . -name *.txt
find . -name file.txt
find . -type f -empty
# Find text
grep "text" file.txt
@tomdewildt
tomdewildt / search-operators.md
Created January 9, 2023 23:22
Search operators for the Google search engine

Match Operators

  • Exact: ""

  • Exclusion: -

  • Wildcard: *

  • Around: word AROUND(5) word

@tomdewildt
tomdewildt / github-actions-steps.yml
Created January 10, 2023 10:25
Common steps for the github actions platform
# Install golang dependencies
- name: Install dependencies
run: go mod download
# Install javascript dependencies
- name: Install dependencies
run: npm install
# Install python dependencies
- name: Install dependencies