Skip to content

Instantly share code, notes, and snippets.

View bdaniel7's full-sized avatar

Daniel Blendea bdaniel7

  • Bucharest, Romania
View GitHub Profile
@coltenkrauter
coltenkrauter / fix-wsl2-dns-resolution.md
Last active October 29, 2025 11:37
Fix DNS resolution in WSL2

Permanent WSL DNS Fix (WSL 2.2.1+)

If you're encountering ping github.com failing inside WSL with a Temporary failure in name resolution, you're not alone — this has been a long-standing issue, especially when using VPNs or corporate networks.

This issue is now fixed robustly with DNS tunneling, which preserves dynamic DNS behavior and avoids limitations like WSL’s former hard cap of 3 DNS servers in /etc/resolv.conf.

DNS tunneling is enabled by default in WSL version 2.2.1 and later, meaning that if you're still seeing DNS resolution issues, the first and most effective fix is simply to upgrade WSL. Upgrading WSL updates the WSL platform itself, but does not affect your installed Linux distributions, apps, or files.

To upgrade WSL, follow these steps,

@changhuixu
changhuixu / HttpClientInConsoleApp.cs
Created September 18, 2019 02:24
.net core console app httpclient dependency injection
private static async Task Main()
{
var services = new ServiceCollection().AddHttpClient();
services.AddHttpClient<IThrottledHttpClient, ThrottledHttpClient>();
var serviceProvider = services.BuildServiceProvider();
var client = serviceProvider.GetService<IThrottledHttpClient>();
var numbers = new List<long> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 11, 13, 17, 19, 23, 29, 31, 41, 43, 1763 };
var results = await client.GetPrimeNumberResults(numbers);
foreach (var result in results)
@changhuixu
changhuixu / ThrottledHttpClient.cs
Created September 18, 2019 02:22
.net core named httpclient, throttle rate, semaphore, semaphoreslim, task, async, asynchronous,
public class ThrottledHttpClient : IThrottledHttpClient
{
private readonly HttpClient _httpClient;
private readonly string _baseUrl = @"http://localhost:5000/api";
public ThrottledHttpClient(HttpClient httpClient)
{
_httpClient = httpClient;
}
@MangelMaxime
MangelMaxime / fable-repl.css
Created June 27, 2019 13:51
Drag & Drop using Elmish and React hooks
html,
body {
font-size: 16px;
}
import numpy as np, cv2, sys
import memcache
import time
sys.path.append('../../../')
from hsapi import ObjectDetector
from grovepi import *
from twilio.rest import Client
@diegopacheco
diegopacheco / main.tf
Last active August 14, 2021 19:08
Terraform + Localstack
provider "aws" {
region = "us-west-2"
access_key = "anaccesskey"
secret_key = "asecretkey"
skip_credentials_validation = true
skip_metadata_api_check = true
s3_force_path_style = true
endpoints {
s3 = "http://119.18.0.101:4572"
}
// Do this in Startup. All calls to SimpleCast will use the same HttpClient instance.
FlurlHttp.ConfigureClient(Configuration["SimpleCastServiceUri"], cli => cli
.Configure(settings =>
{
// keeps logging & error handling out of SimpleCastClient
settings.BeforeCall = call => logger.LogWarning($"Calling {call.Request.RequestUri}");
settings.OnError = call => logger.LogError($"Call to SimpleCast failed: {call.Exception}");
})
// adds default headers to send with every call
.WithHeaders(new

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
namespace WebApplication1
{
public class Program
{
public static void Main(string[] args)
@ayende
ayende / LetsEncryptClient.cs
Created January 11, 2018 22:26
ACME v2 client for Let's Encrypt
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
using System.Threading.Tasks;