Skip to content

Instantly share code, notes, and snippets.

@panicoenlaxbox
panicoenlaxbox / fastapi_poetry.ps1
Last active November 18, 2022 12:10
FastAPI setup using poetry
$app = "web_app2"
$directory = "WebApp2"
poetry new --name $app --src $directory
cd $directory
poetry shell
poetry add -G dev mypy pytest black isort flake8 assertpy pre-commit flake8-class-attributes-order pytest-asyncio pytest-cov flake8-pyproject
echo "[tool.black]`
line-length = 120`
target-version = ['py310']`
`
@panicoenlaxbox
panicoenlaxbox / python_setup.ps1
Last active November 3, 2022 11:32
Minimum steps to follow to be able to have fun with Python
$directory = "PythonApp1"
$app = "python_app1"
mkdir $directory
cd $directory
pipenv install --dev mypy pytest black isort flake8 assertpy pre-commit
mkdir src & mkdir src\$app & mkdir tests
echo "[tool.black]`
line-length = 120`
target-version = ['py310']` # https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html?highlight=target-version#command-line-options
@panicoenlaxbox
panicoenlaxbox / insights_generator.py
Last active December 24, 2023 12:52
Get number of lines of code, classes and functions from a Python base code
import ast
from dataclasses import dataclass
from functools import reduce
from pathlib import Path
from types import TracebackType
from typing import Self, TextIO
@dataclass
class Symbols:
@panicoenlaxbox
panicoenlaxbox / oh-my-posh
Last active December 29, 2021 12:02
oh-my-posh with my personal preferences (dotnet & python)
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": true,
"osc99": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
@panicoenlaxbox
panicoenlaxbox / packageversiontype.yml
Last active August 5, 2021 11:37
Variable PackageVersionType
- pwsh: |
if ($env:PACKAGEVERSIONTYPE -eq '' -and $env:BUILD_SOURCEBRANCHNAME -ne 'main') {
Write-Host "##vso[task.setvariable variable=PACKAGEVERSIONTYPE]-alpha"
}
@panicoenlaxbox
panicoenlaxbox / Program.cs
Last active August 29, 2019 18:52
EF Core playground
// <Project Sdk="Microsoft.NET.Sdk">
// <PropertyGroup>
// <OutputType>Exe</OutputType>
// <TargetFramework>netcoreapp2.2</TargetFramework>
// <LangVersion>latest</LangVersion>
// </PropertyGroup>
// <ItemGroup>
// <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
@panicoenlaxbox
panicoenlaxbox / GenericHostWithEf.csproj
Last active August 4, 2023 04:52
.NET Core Generic host with EF Core
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
param(
[Parameter(Mandatory = $True)]
[string]$RootPath,
[Parameter(Mandatory = $True)]
[string]$BucketName,
[Parameter(Mandatory = $True)]
[string]$AccessKey,
[Parameter(Mandatory = $True)]
[string]$SecretKey,
[switch]$RemoveRootPathFromS3Key
@panicoenlaxbox
panicoenlaxbox / DownloadFileAndBlobInWrongAndRightWay.cs
Last active September 12, 2019 19:32
Download file and blob in wrong and right way
//<Project Sdk="Microsoft.NET.Sdk">
// <PropertyGroup>
// <OutputType>Exe</OutputType>
// <TargetFramework>netcoreapp2.2</TargetFramework>
// </PropertyGroup>
// <ItemGroup>
// <PackageReference Include="CsvHelper" Version="12.1.2" />
// <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.6" />
// <PackageReference Include="TinyCsvParser" Version="2.5.2" />
// <PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
function memoize(fn: any): any {
console.log('memoize');
const cache = {};
return function () {
const key: string = JSON.stringify(arguments);
if (cache[key]) {
console.log(`${key} found in cache`);
return cache[key];
}
else {