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 / 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.
@skarllot
skarllot / ServiceCollectionExtensions.cs
Created July 30, 2023 16:43
Register self with interfaces dependency injection
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddSelfWithInterfacesSingleton<TService>(this IServiceCollection services)
where TService : class
{
services.AddSingleton<TService>();
@skarllot
skarllot / git-logs.sh
Last active December 12, 2023 18:53
Analyze Git commits between branches
# Format: - 2023-05-15 Name: Commit message
git log --cherry-pick --right-only --no-merges --reverse --pretty="- %ad %cn: %s" --date=short branch-a...branch-b
# Format: - 2023-05-15 Commit message
git log --cherry-pick --reverse --pretty="- %ad %<(35,trunc)%s" --date=short branch-a...branch-b
# Format: [email protected] 2023-04-25 initial commit
git log --cherry --reverse --pretty="%<(20,trunc)%ce%x09%>(10)%ad%x09%s" --date=short branch-a...branch-b
git log --cherry --reverse branch-a...branch-b
@skarllot
skarllot / run-ubuntu.sh
Last active November 16, 2024 23:11
Sign Git commits and tags with X.509 certificates
# 1. Get a free S/MIME e-mail certificate
# Actalis: https://extrassl.actalis.it/portal/uapub/freemail?lang=en
# 2. GNU privacy guard - S/MIME version
sudo apt install gpgsm
# 3. Import PKCS12 certificate
gpgsm --import certificate_s_mime.p12
# 4. Set your signing key
@skarllot
skarllot / full-context-menu-explorer.cmd
Created May 3, 2023 01:42
Manual override through Windows Registry in order to force Explorer to fall back to the classic full menu
reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
@skarllot
skarllot / Program.cs
Created April 2, 2023 00:40
Using Azure Cosmos DB and Entity Framework Core
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
namespace CosmosCodeFirstDemo
{
class Program
@skarllot
skarllot / TypeClipboard.md
Last active April 22, 2024 10:06 — forked from ethack/TypeClipboard.md
Scripts that simulate typing the clipboard contents. Useful when pasting is not allowed.

It "types" the contents of the clipboard.

Why can't you just paste the contents you ask? Sometimes pasting just doesn't work.

  • One example is in system password fields on OSX.
  • Sometimes you're working in a VM and the clipboard isn't shared.
  • Other times you're working via Remote Desktop and again, the clipboard doesn't work in password boxes such as the system login prompts.
  • Connected via RDP and clipboard sharing is disabled and so is mounting of local drives. If the system doesn't have internet access there's no easy way to get things like payloads or Powershell scripts onto it... until now.

Windows

The Windows version is written in AutoHotKey and easily compiles to an executable. It's a single line script that maps Ctrl-Shift-V to type the clipboard.

@skarllot
skarllot / nuget_pack_assets.md
Last active January 9, 2020 19:07
Change generated NuSpec dependency 'exclude' and 'include'
IncludeAssets ExcludeAssets PrivateAssets Valid Include Exclude
null null null true Analyzers,Build
null Native null true Analyzers,Build,Native
Compile null null true Analyzers,Build,BuildTransitive,Native,Runtime
Compile;Runtime null null true Analyzers,Build,BuildTransitive,Native
@skarllot
skarllot / tgz2zip.py
Created August 8, 2018 01:34
Pipes the content of GZipped Tar file to a Zip file without temporary files
#!/usr/bin/python
import sys
import tarfile
import zipfile
tarf = tarfile.open(sys.argv[1], "r:*")
zipf = zipfile.ZipFile(sys.argv[2], "w", zipfile.ZIP_DEFLATED, allowZip64 = True)
for m in tarf:
if m.isreg():
zipf.writestr(m.path, tarf.extractfile(m).read())