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 / 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())
@skarllot
skarllot / .gitlab-ci.yml
Created June 20, 2018 20:28 — forked from ashalkhakov/.gitlab-ci.yml
Running .NET 3.5 CF builds under Docker for Windows
# this is the GitLab-CI file for building the image
variables:
CURRENT_IMAGE_TAG: rfid-applied/netcf35_build_environment:dev
stages:
- dockerize
dockerize:
stage: dockerize
script:
@skarllot
skarllot / CancellationTokenAsynchronousExtensions.cs
Created April 24, 2018 20:12
Enable await for CancellationToken
using System;
using System.Runtime.CompilerServices;
using System.Threading;
public static class CancellationTokenAsynchronousExtensions
{
public static CancellationTokenAwaiter GetAwaiter(this CancellationToken cancellationToken)
{
return new CancellationTokenAwaiter(cancellationToken);
}