Skip to content

Instantly share code, notes, and snippets.

@fernandezja
fernandezja / StringExtensions.cs
Last active September 29, 2021 23:50
Extension method to remove accents
using System.Globalization;
using System.Text;
public static class StringExtensions
{
public static string RemoveAccents(this string textInput)
{
if (string.IsNullOrEmpty(textInput))
{
return string.Empty;
@fernandezja
fernandezja / ApiInternalClientWithBasicAuth.cs
Created September 14, 2021 19:40
IHttpClientFactory with basic authentication
public class ApiInternalClientWithBasicAuth {
private const string AUTH_SCHEME_BASIC = "Basic";
private IHttpClientFactory _httpClientFactory;
public ApiInternalClient(IHttpClientFactory httpClientFactory)
{
_httpClientFactory = httpClientFactory;
}
@fernandezja
fernandezja / dbo.TRY_CAST.sql
Created June 15, 2021 00:00 — forked from jotapardo/dbo.TRY_CAST.sql
TRY_CAST Function for SQL Server 2008
DECLARE @strSQL NVARCHAR(1000)
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[TRY_CAST]'))
BEGIN
SET @strSQL = 'CREATE FUNCTION [dbo].[TRY_CAST] () RETURNS INT AS BEGIN RETURN 0 END'
EXEC sys.sp_executesql @strSQL
END
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
@fernandezja
fernandezja / palindromos-en-español.md
Last active May 18, 2021 17:37
Palíndromos en español

Palíndromos en español

  • Anita lava la tina
  • Si es nueve se ve un seis
  • Amo la pacífica paloma
  • Luz, a Noel le arañará el león azul.
  • Ana me sala soja y ajos a la semana.
  • Romano coloso superbo se sobrepuso sólo con amor.
  • Es Adán, ya ve, yo soy Eva y nada sé.
  • Ser él la talla. Allá talleres
  • Es raro llorar y oír ese verbo vivo, breve, serio y raro: llorarse.
@fernandezja
fernandezja / azure-functions-http-request.cs
Created November 16, 2020 19:46
Azure Functions HTTP request JSON and query another HTTP request (API)
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using System.Text;
//private static HttpClient httpClient = new HttpClient();
@fernandezja
fernandezja / git-commands.md
Created September 12, 2020 13:41
Git Commands

Remove all commits local

'''git reset --hard origin/master

@fernandezja
fernandezja / dotnet-urls-parameter.md
Last active August 14, 2020 12:17
Specify dotnet tools the host run on a particular URL

Specify dotnet tools the host run on a particular URL

dotnet run --urls "http://*:6000"
dotnet run --urls "https://*:6001"

More info

@fernandezja
fernandezja / autofact-scanning-modules-into-assembly.txt
Last active February 20, 2020 21:33
Autofact assembly scanning modules and register with parameters (without RegisterAssemblyModules)
var moduleAssembly = Assembly.Load("Starwars.Modules.Empire");
//builder.RegisterAssemblyModules(moduleAssembly); //Not work with parameter, Not work inject DI
var modules = from t in moduleAssembly.GetTypes()
where typeof(Autofac.Module).IsAssignableFrom(t)
select t;
foreach (var module in modules.ToList())
{
@fernandezja
fernandezja / Update-a-forked-repo.md
Last active November 10, 2019 12:51
Update a forked repo

Update a forked repo

Step 1: You must configure a remote that points to the upstream repository

git remote add upstream url-remote.repo.git

Step 2: Fetch the branches and their respective commits from the upstream repository

git fetch upstream