Skip to content

Instantly share code, notes, and snippets.

@Fazzani
Fazzani / provider.py
Created November 5, 2022 10:49 — forked from thoroc/provider.py
Custom Faker Provider
# 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")
@Fazzani
Fazzani / log4j4py.py
Created June 12, 2022 09:14 — forked from thsutton/log4j4py.py
Forward Python logging module to Spark log4j
import logging
import time
from contextlib import AbstractContextManager
from logging import Handler, LogRecord
from typing import Any, List, Optional
from pyspark.sql import SparkSession
logging.basicConfig(level=logging.INFO)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MyApp.AppServices.Configuration;
using MyApp.AppServices.EventBus.Command;
using MyApp.AppServices.Model.EventGrid;
using Framework.EventBus.Command;
using Framework.Model;
@Fazzani
Fazzani / wsl2-network.ps1
Last active April 14, 2021 11:47 — forked from xmeng1/wsl2-network.ps1
WSL2 Port forwarding port to linux
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
@Fazzani
Fazzani / pr.md
Created April 10, 2021 07:35 — forked from joncloud/pr.md
Checkout vsts pull requests locally

Forked from piscisaureus

Locate the section for your vsts remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = ssh://my-vsts@my-vsts.visualstudio.com:22/DefaultCollection/Project-Name/_git/Repo-Name
@Fazzani
Fazzani / install-releasenotes.sh
Last active October 16, 2021 08:53
releasenotes setup
#!/bin/sh
command -v rnotes >/dev/null 2>&1 && CUR_VERSION="$(rnotes --version)" || CUR_VERSION="v0.0.0"
VERSION_TO_INSTALL=${1:-latest}
RELEASE_URL="https://api.github.com/repos/fazzani/az-release-notes/releases/tags/$VERSION_TO_INSTALL"
[ $VERSION_TO_INSTALL = "latest" ] && RELEASE_URL="https://api.github.com/repos/fazzani/az-release-notes/releases/latest"
NEW_VERSION="$(curl -s $RELEASE_URL | jq -r '.tag_name')"
echo "Current Version: $CUR_VERSION => New Version: $NEW_VERSION"
if [ "$NEW_VERSION" != "$CUR_VERSION" ]; then
@Fazzani
Fazzani / sonarqube-create-project-guids.ps1
Created November 16, 2020 10:47
Add guid to .net core projects
# Project Guid Generator
# Creator: Unknown
# Editor: Isaac martinez
# Notes: A requirement of SonarCloud/SonarQube is that all projects have a unique
# ProjectGuid. This script takes care of that. This script will recursively
# look for projects in subfolders and apply the necessary changes.
# Version Date: 05/19/2020
$paths = Get-ChildItem -Path $PSScriptRoot -include *proj -Recurse
Write-Host $paths.count "project(s) found"
@Fazzani
Fazzani / az-pipelines.yml
Created November 8, 2020 18:40
azure pipeline to add or modify variable into azure devops variable-group
name: $(SourceBranchName)_$(date:yyyyMMdd)$(rev:.r)
parameters:
- name: var_group_name
displayName: Variable group name
type: string
default: Common
pool:
vmImage: $(imageName)
@Fazzani
Fazzani / az_devops_var-groups.sh
Last active November 7, 2020 19:24
Getting and updating azure devops variables-group
echo $MY_AZURE_DEVOPS_PAT | az devops login
az pipelines variable-group list --org $MY_AZURE_DEVOPS_ORG -p SynkerAPI
// Insert new var in a variables-group 3
az pipelines variable-group variable create --id 3 --name "test" --value "testValue" --org $MY_AZURE_DEVOPS_ORG -p SynkerAPI
az pipelines variable-group variable delete --id 3 --name "test" --org $MY_AZURE_DEVOPS_ORG -p SynkerAPI
// Get var-group id by name
az pipelines variable-group list --org $MY_AZURE_DEVOPS_ORG -p SynkerAPI --query "[?name=='Common'].id" -o tsv
@Fazzani
Fazzani / example.json
Last active October 28, 2020 11:08
Health check .net core json schema
{
"status": "Unhealthy",
"totalDuration": "00:00:51.8415331",
"entries": {
"storage": { "data": {}, "description": "Hôte inconnu", "duration": "00:00:23.2322776", "exception": "Hôte inconnu", "status": "Degraded" },
"external az storage": { "data": {}, "duration": "00:00:00.1167734", "status": "Healthy" },
"docapost": { "data": {}, "duration": "00:00:01.5491822", "status": "Healthy" },
"cosmosdb": { "data": {}, "description": "Hôte inconnu", "duration": "00:00:00.2694373", "exception": "Hôte inconnu", "status": "Unhealthy" }
}
}