Skip to content

Instantly share code, notes, and snippets.

@thoroc
thoroc / evolution_of_a_se.md
Last active Dec 2, 2022
The Evolution of a Software Engineer
View evolution_of_a_se.md

First year

class HelloWorld
{
    public static void main(String args[])
    {
        // Display "Hello world!" on the console.
        System.out.println("Hello World!");
    }
@thoroc
thoroc / class_decorator.py
Last active Dec 1, 2022
Inheritance vs Class Decorator in python
View class_decorator.py
from dataclasses import dataclass, field
from faker import Faker
from faker.providers import BaseProvider
class CustomProvider(BaseProvider):
__provider__ = "message"
def message(self):
return self.generator.sentence()
@thoroc
thoroc / 1_providers.py
Last active Nov 29, 2022
Example: FactoryBoy use with Faker Custom Provider
View 1_providers.py
# 1. Create custom provider
from datetime import datetime
from faker.providers import BaseProvider
class PersonProvider(BaseProvider):
__provider__ = "person_title"
__provider__ = "person_first_name"
__provider__ = "person_email"
__provider__ = "person_dob"
@thoroc
thoroc / event_source_mapping_class.py
Last active Dec 1, 2022
storing EventSourceMapping values in a dataclass and passing it as argument when calling AWS boto3 lambda.create_event_source_mapping
View event_source_mapping_class.py
# external dependencies: luguru and caseconverter.
# tested on python 3.9
from dataclasses import dataclass, field
import datetime
from caseconverter import pascalcase
from loguru import logger
@dataclass
class OnFailure:
@thoroc
thoroc / WelcomeToCodeWhisperer.md
Created Jul 20, 2022
AWS Code Whisperer readme
View WelcomeToCodeWhisperer.md

How to Use Amazon CodeWhisperer

Welcome to the Amazon CodeWhisperer preview! CodeWhisperer uses machine learning to generate code suggestions from the existing code and comments in your IDE. Supported languages include: Java, Python, and JavaScript.

TAB. Left Arrow. Right Arrow. That’s all!

You should automatically see inline code suggestions. Use the TAB key to accept a suggestion. CodeWhisperer may provide multiple suggestions to choose from, use [left arrow] and [right arrow] to navigate between suggestions.

@thoroc
thoroc / provider.py
Created Apr 29, 2022
Custom Faker Provider
View provider.py
# Based on the following:
# https://www.datainsightonline.com/post/how-to-generate-fake-dataset-with-python-faker-library
# https://deparkes.co.uk/2020/12/28/python-fake-data-with-faker/
from faker.providers import BaseProvider
from faker import Faker
import pandas as pd
from loguru import logger
fake = Faker("en_GB")
@thoroc
thoroc / README.md
Last active Apr 14, 2022
mock request object
View README.md

Simple scenario to demontrate how to mock requests' post

============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.7.10, pytest-6.1.1, py-1.11.0, pluggy-0.13.1 -- /python/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /python, configfile: pytest.ini
plugins: Faker-13.3.3, anyio-3.5.0, mock-3.3.1, cov-2.10.1, icdiff-0.5
collected 2 items
@thoroc
thoroc / README.md
Last active Apr 15, 2022
pytest raises example
View README.md

Simple scenario to demontrate how to assert for custom exception

============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.7.10, pytest-6.1.1, py-1.11.0, pluggy-0.13.1 -- /python/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /python, configfile: pytest.ini
plugins: Faker-13.3.3, anyio-3.5.0, mock-3.3.1, cov-2.10.1, icdiff-0.5
collected 5 items
@thoroc
thoroc / gist:7138b60613f69f835851583075827bbc
Last active Apr 5, 2022 — forked from digitaljhelms/gist:1354003
Installing and using Gource on Mac OS X (only tested on Snow Leopard)
View gist:7138b60613f69f835851583075827bbc

Gource

Gource is a software version control visualization tool.

Software projects are displayed by Gource as an animated tree with the root directory of the project at its centre. Directories appear as branches with files as leaves. Developers can be seen working on the tree at the times they contributed to the project.

http://code.google.com/p/gource/

Installing Gource Manually (w/out MacPorts or Homebrew)

@thoroc
thoroc / readme.md
Created Feb 10, 2022
Typescript + React primers
View readme.md

JS + Typescript

React