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 / 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;
@skarllot
skarllot / array-extension.ts
Created November 29, 2023 21:17
Find last index of an array (mirror of ES2015 findIndex function)
/**
* Returns the index of the last element in the array where predicate is true, and -1
* otherwise.
* @param array The source array to search in
* @param predicate find calls predicate once for each element of the array, in descending
* order, until it finds one where predicate returns true. If such an element is found,
* findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.
*/
export function findLastIndex<T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean): number {
let l = array.length;
@skarllot
skarllot / README.md
Last active April 14, 2025 01:01
Enable Long Paths in Windows 10, Version 1607, and Later

Enable Long Paths in Windows 10, Version 1607, and Later

git config --system core.longpaths true
  • Open the Local Group Policy Editor (gpedit.msc)
  • Navigate to: Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem.
  • Open "Enable Win32 long paths" and set it to Enabled.