Skip to content

Instantly share code, notes, and snippets.

View sidneyspe's full-sized avatar
🎯
Focusing

Sidney Pimentel sidneyspe

🎯
Focusing
  • Campina Grande - PB, Brasil
  • 16:45 (UTC -03:00)
  • LinkedIn in/sidneyspe
View GitHub Profile
@sidneyspe
sidneyspe / .wslconfig
Created October 28, 2024 00:44
WSL2 Config
[wsl2]
memory=30GB # limita a memória da VM.
processors=14 # limita o uso da VM para 14 processadores virtuais
dnsTunneling=true
autoProxy=true
networkingMode=mirrored
useWindowsDnsCache=true
[experimental]
autoMemoryReclaim=gradual
@sidneyspe
sidneyspe / settings.json
Last active December 10, 2024 18:55
VSCode Settings - 2024
{
"workbench.startupEditor": "newUntitledFile",
"editor.fontSize": 14,
"editor.lineHeight": 1.8,
"javascript.suggest.autoImports": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.rulers": [
80,
120
],

Recipe: Persistent Network Configuration in WSL 2 using Hyper-V Virtual Switch

Problem Description

Connecting to services running in WSL 2 from external sources can be challenging due to the instances being on a different network. This guide offers a solution to replace the internal virtual switch of WSL 2 with an external version in Windows 20H2 (WSL 2.0) and configure it for better networking control.

Solution Overview

This recipe uses a Hyper-V virtual switch to bridge the WSL 2 network, providing improved control and visibility of Windows' network adapters within Ubuntu. The configuration supports both dynamic and static IP addressing, eliminating the need for port forwarding and simplifying network setup.

Steps

  1. Enable Hyper-V and Management PowerShell Features:
@sidneyspe
sidneyspe / settings.json
Created August 31, 2023 13:04
SublimeText Config
// Settings in here override those in "Default/Preferences.sublime-settings",
// and are overridden in turn by syntax-specific settings.
{
"theme": "One Dark.sublime-theme",
"color_scheme": "Omni.sublime-color-scheme",
"font_face": "JetBrainsMono Nerd Font",
"font_size": 16,
"ignored_packages":
[
"Vintage",
%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
@sidneyspe
sidneyspe / .bashrc
Created May 30, 2023 20:20
.bashrc for windows
eval "$(starship init bash)"
. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"
alias ls='lsd'
alias la='lsd -la'
alias l='ls -l'
alias la='ls -a'
alias lla='ls -la'
alias lt='ls --tree'
@sidneyspe
sidneyspe / get_line_logs.cs
Last active May 22, 2023 13:09
get the last line of log file
using System;
using System.IO;
class Program
{
static void Main()
{
// Obter a data e hora atual
DateTime now = DateTime.Now;
@sidneyspe
sidneyspe / copy.bat
Created May 12, 2023 18:06
copy files modified today
@echo off
set "source_folder=C:\pasta\origem"
set "dest_folder=C:\pasta\destino"
set "file_pattern=bin\Debug\*.*"
xcopy "%source_folder%\%file_pattern%" "%dest_folder%\%file_pattern%" /S /D:%DATE% /F
pause
@sidneyspe
sidneyspe / wowup.io
Last active May 12, 2025 17:57
Adddons WoW - WowUp.io CF
eyJjb2xsZWN0aW9uX25hbWUiOiJXb3dVcF9leHBvcnRfMTc0NzA3MjY0ODU4NCIsImNsaWVudF90eXBlIjoiUmV0YWlsIiwiYWRkb25zIjpbeyJpZCI6IjYxODE2OSIsIm5hbWUiOiJIZWFsQm90IFBsdWdpbiBNeUNvb2xkb3ducyIsInByb3ZpZGVyX25hbWUiOiJDdXJzZSIsInZlcnNpb25faWQiOiI2NDk3NjgxIn0seyJpZCI6IjQxMDI3NSIsIm5hbWUiOiJIZWFsQm90IFBsdWdpbiBUaW1lVG9EaWUiLCJwcm92aWRlcl9uYW1lIjoiQ3Vyc2UiLCJ2ZXJzaW9uX2lkIjoiNjQ5NzcwOCJ9LHsiaWQiOiI5MTM3NiIsIm5hbWUiOiJDb25zb2xlUG9ydCIsInByb3ZpZGVyX25hbWUiOiJDdXJzZSIsInZlcnNpb25faWQiOiI2NDYyNTQ4In0seyJpZCI6IjQxMDI3MyIsIm5hbWUiOiJIZWFsQm90IFBsdWdpbiBUaHJlYXQiLCJwcm92aWRlcl9uYW1lIjoiQ3Vyc2UiLCJ2ZXJzaW9uX2lkIjoiNjQ5NzcwNiJ9LHsiaWQiOiI2OTI1NCIsIm5hbWUiOiJIZWtpbGkgUHJpb3JpdHkgSGVscGVyIiwicHJvdmlkZXJfbmFtZSI6IkN1cnNlIiwidmVyc2lvbl9pZCI6IjY0OTI5NDUifSx7ImlkIjoiMzcxMjc4IiwibmFtZSI6IkdhdGhlcmluZyIsInByb3ZpZGVyX25hbWUiOiJDdXJzZSIsInZlcnNpb25faWQiOiI2NDkxODMzIn0seyJpZCI6IjY1Mzg3IiwibmFtZSI6IldlYWtBdXJhcyIsInByb3ZpZGVyX25hbWUiOiJDdXJzZSIsInZlcnNpb25faWQiOiI2NDYzNDMwIn0seyJpZCI6IjE4ODA4IiwibmFtZSI6IlRvbVRvbSIsInByb3ZpZGVyX25hbWUiOiJDdXJzZSIsInZl
@sidneyspe
sidneyspe / HandleXml.cs
Created May 3, 2023 18:34
Handle XML using cshap
using System;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text.Json;
class Program
{
static void Main(string[] args)