Skip to content

Instantly share code, notes, and snippets.

View skarllot's full-sized avatar
💭
I may be slow to respond.

Fabrício Godoy skarllot

💭
I may be slow to respond.
View GitHub Profile
@skarllot
skarllot / .gitleaks.toml
Created December 27, 2024 12:42
Setup Gitleaks to ignore a non-secret value
[extend]
useDefault = true
[allowlist]
description = "Fake secrets"
regexTarget = "match"
regexes = [
"6a654835c594485b8980ba2c73af6f18"
]
@skarllot
skarllot / subnet.bicep
Created December 19, 2024 15:22
Example condition that does not work on Bicep
resource natGateway 'Microsoft.Network/natGateways@2023-11-01' = if (hasNatGateway) {
name: natGatewayName
location: location
sku: {
name: 'Standard'
}
}
resource subnets 'Microsoft.Network/virtualNetworks/subnets@2022-11-01' = {
name: name
@skarllot
skarllot / script.sh
Last active November 30, 2024 20:48
Install magic-quill on Pop!_OS 22.04
sudo apt install nvidia-cuda-toolkit
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
pip install bitsandbytes
git clone --recursive https://github.com/magic-quill/MagicQuill.git
cd MagicQuill
wget -O models.zip "https://hkustconnect-my.sharepoint.com/:u:/g/personal/zliucz_connect_ust_hk/EWlGF0WfawJIrJ1Hn85_-3gB0MtwImAnYeWXuleVQcukMg?e=Gcjugg&download=1"
unzip models.zip
@skarllot
skarllot / configuration.cs
Created October 24, 2024 21:04
Polly retry configuration for exponential backoff
options.RetryCount, retryAttempt => TimeSpan.FromMilliseconds(options.RetryDelayMilliseconds * Math.Pow(2, retryAttempt-1))
@skarllot
skarllot / packages-versions-releasenotes.ipynb
Last active December 8, 2024 21:07
Remove duplicates from GitHub release notes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@skarllot
skarllot / ChangeErrorsSubject.cs
Created April 7, 2024 21:18
Subject class for using INotifyDataErrorInfo with Avalonia UI
using System.Collections;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Reactive.Subjects;
using CSharpFunctionalExtensions;
namespace Example;
public sealed class ChangeErrorsSubject : ISubject<ImmutableList<PropertyDataError>>, INotifyDataErrorInfo, IDisposable
{
@skarllot
skarllot / replacer.tf
Created March 22, 2024 17:27
Terraform multiple replaces
# Ref: https://stackoverflow.com/a/67392622/23266117
locals {
input = file("./sample.txt")
map = {
food = "Sushi"
name = "Data_sniffer"
}
out = join("\n", [
@skarllot
skarllot / FormatExtensions.cs
Created February 25, 2024 16:22
Allocation free int to string (incomplete)
public static class FormatExtensions
{
public static string Int32ToString(int a)
{
const int radix = 10;
const int maxLength = 11;
Span<char> str = stackalloc char[maxLength];
int i = str.Length;
bool isNegative = a < 0;
@skarllot
skarllot / .gitconfig
Created January 29, 2024 22:56
Git config include (Windows)
# Global
[includeIf "gitdir/i:C:/Users/<user>/Source/repos/github/<user>/"]
path = C:/Users/<user>/Source/repos/github/<user>/.gitconfig
[includeIf "gitdir/i:~/Source/repos/github/<user>/"]
path = ~/Source/repos/github/<user>/.gitconfig
# Path
[user]
email = <email>
@skarllot
skarllot / get-azure-current-user.cs
Created January 25, 2024 17:29
Get current Azure logged user
Claim displayName = ClaimsPrincipal.Current.FindFirst(ClaimsPrincipal.Current.Identities.First().NameClaimType);
ViewBag.DisplayName = displayName != null ? displayName.Value : string.Empty;