Skip to content

Instantly share code, notes, and snippets.

View mvenditto's full-sized avatar
🌀
﹏𓊝﹏𓂁﹏

Matteo Venditto mvenditto

🌀
﹏𓊝﹏𓂁﹏
View GitHub Profile
@mvenditto
mvenditto / README.md
Created January 22, 2025 13:41 — forked from magnetikonline/README.md
VirtualBox create host-only interface and attach to VMs.
@mvenditto
mvenditto / std_log.md
Created November 10, 2024 19:56 — forked from kassane/std_log.md
Quick overview of Zig's `std.log`

A simple overview of Zig's std.log for Zig v0.12.0 or higher

Logging functionality that supports:

  • If a log message should be printed is determined at comptime, meaning zero overhead for unprinted messages (so just leave the code peppered with debug logs, but when it makes sense scope them; so downstream users can filter them out)
  • Scoped log messages
  • Different log levels per scope
  • Overrideable log output (write to file, database, etc.)
  • All the standard std.fmt formatting magic

Basic Usage:

@mvenditto
mvenditto / Program.cs
Created March 18, 2024 09:27 — forked from Tratcher/Program.cs
Kestrel programmatic rebinding
// This shows how to change Kestrel's bindings programmatically through the IConfiguraiton abstraction.
// TFM: .NET 5.0
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading;
namespace WebApplication85
@mvenditto
mvenditto / benchmark.sh
Created March 13, 2024 14:42 — forked from carlos-algms/benchmark.sh
Benchmark SSH ciphers transfer speed - Mac and Linux
#!/usr/bin/env bash
# Creates a 100Mb file send via SSH and test the transfer speed
perl -e 'print "\0" x 100000000' > test.txt && du -sh test.txt
# get a list of available ciphers on your machine
CIPHERS="$(ssh -Q cipher)"
for cipher in $CIPHERS; do
echo "$cipher"
@mvenditto
mvenditto / napalm-gather-configs.py
Created February 12, 2024 10:04 — forked from Tes3awy/napalm-gather-configs.py
A NAPALM Script to Gather All Configuration Types (Startup, Running, and Candidate if supported)
#!usr/bin/python3
# -*- coding: utf-8 -*-
import sys
from datetime import date
from napalm import get_network_driver
from napalm.base.exceptions import ConnectionException
from paramiko.ssh_exception import SSHException
from rich import print
@mvenditto
mvenditto / event-mask.md
Created January 31, 2024 17:26 — forked from ww898/event-mask.md
.NET Core profiler Event Masks

COR_PRF_MONITOR where:

  • i - COR_PRF_MONITOR_IMMUTABLE (0xEEF8CC00)
  • a - COR_PRF_ALLOWABLE_AFTER_ATTACH (0x100502FE)
  • n - COR_PRF_ALLOWABLE_NOTIFICATION_PROFILER (0xB1E32B7F)
 0 ..n COR_PRF_MONITOR_FUNCTION_UNLOADS
 1 .an COR_PRF_MONITOR_CLASS_LOADS
 2 .an COR_PRF_MONITOR_MODULE_LOADS
 3 .an COR_PRF_MONITOR_ASSEMBLY_LOADS
 4 .an COR_PRF_MONITOR_APPDOMAIN_LOADS
@mvenditto
mvenditto / TieredBufferAllocExample.cs
Created January 22, 2024 11:05 — forked from neon-sunset/TieredBufferAllocExample.cs
Tiered buffer allocation example: stackalloc -> array pool -> native memory alloc
using Cysharp.Collections; // dotnet add package NativeMemoryArray
namespace BufferAllocExample;
public static class ExampleBufferedBytesProcessor
{
public static int ProcessBytes(IUtf8Processor processor, ReadOnlySpan<char> source, Span<byte> destination)
{
const int StackAllocLimit = 1024; // 1KB
const int ArrayPoolLimit = 1024 * 1024 * 10; // 10MB
@mvenditto
mvenditto / MemoryMappedBinaryReader.cs
Created January 5, 2024 12:55 — forked from AngraMainyu/MemoryMappedBinaryReader.cs
An example class for reading strings from memory-mapped files.
using System;
using System.IO.MemoryMappedFiles;
using MemoryMappingTools;
namespace MemoryMappingTools
{
// We use a static modifier so the compiler will accept our ReadString extension method.
unsafe static class MemoryMappedBinaryReader
{
/// <summary>
Name Hex Decimal
E_UNEXPECTED 0x8000FFFF -2147418113
E_NOTIMPL 0x80004001 -2147467263
E_OUTOFMEMORY 0x8007000E -2147024882
E_INVALIDARG 0x80070057 -2147024809
E_NOINTERFACE 0x80004002 -2147467262
E_POINTER 0x80004003 -2147467261
E_HANDLE 0x80070006 -2147024890
E_ABORT 0x80004004 -2147467260
E_FAIL 0x80004005 -2147467259
@mvenditto
mvenditto / ComWithoutRegistering.cs
Created December 28, 2022 20:19 — forked from jjeffery/ComWithoutRegistering.cs
COM without registering
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace ComWithoutRegisteringExample
{
internal static class ComHelper
{
private delegate int DllGetClassObject(ref Guid clsid, ref Guid iid, [Out, MarshalAs(UnmanagedType.Interface)] out IClassFactory classFactory);