Skip to content

Instantly share code, notes, and snippets.

View javiercampos's full-sized avatar

Javier Campos javiercampos

View GitHub Profile
@javiercampos
javiercampos / guard.cs
Created February 15, 2022 09:09
Guard
public class Guard
{
private int _guardValue = 0;
public bool Once() => Interlocked.Exchange(ref _guardValue, 1) == 0;
public void Reset() => Interlocked.Exchange(ref _guardValue, 0);
}
public class DbResultStream : LifetimedStream
{
public DbResultStream(Stream originalStream, IDbConnection connection, IDataReader dataReader) : base(originalStream)
{
AddDisposable(dataReader);
AddDisposable(connection);
}
}
public class LifetimedStream : StreamWrapper
@javiercampos
javiercampos / CultureTestPage.Razor
Created August 31, 2021 08:33
Culture Switching Methods Test on Blazor Server
@page "/"
@using System.Globalization
<h1>Blazor culture</h1>
<p>
@_dateTime.ToString()<br />
@_decimalNumber.ToString("N4");<br />
</p>
<h1>Specific culture</h1>
@javiercampos
javiercampos / Icon.names.cs
Last active February 17, 2022 07:54
Fontawesome Icon Names
/*
Jcl: generated using LinqPad
void Main()
{
var text = File.ReadAllText(@"<path-to-blazor-project>\wwwroot\lib\fontawesome-pro\css\all.css");
var allMatches = Regex.Matches(text, @"^\.fa\-(.*):", RegexOptions.Multiline);
var ti = new CultureInfo("en-US",false).TextInfo;
"public partial class Icon".Dump();
"{".Dump();
@javiercampos
javiercampos / Program.cs
Created January 10, 2018 11:36
Automapper ExpressionBuilder Ctor Parameter Error
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using AutoMapper.QueryableExtensions;
namespace AutomapperTestCtor
{
public class ClassA
{
using System;
using System.ComponentModel;
using System.Deployment.Application;
using System.Windows.Forms;
using LaBoutiqueDelHogar.GestionPedidos.Forms;
using LaBoutiqueDelHogar.Tools;
namespace LaBoutiqueDelHogar.GestionPedidos.Tools
{
public static class ClickOnceUpdate
@javiercampos
javiercampos / ANALRAID.C
Created November 15, 2014 13:06
1997's Anal Raid
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <malloc.h>
#include <mem.h>
typedef unsigned char byte;
typedef unsigned int word;
typedef unsigned long dword;
@javiercampos
javiercampos / Configuration.cs
Last active August 29, 2015 14:08
Entity Framework Migrations Seed Debug Window
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
using Data.Persistence.Migrations.SeedDebug;
namespace Data.Persistence.Migrations