Skip to content

Instantly share code, notes, and snippets.

View jrgcubano's full-sized avatar

Jorge Rodríguez Galán jrgcubano

View GitHub Profile
@jrgcubano
jrgcubano / AbstractNodeNodeTypeResolver.cs
Created December 17, 2021 14:21 — forked from atruskie/AbstractNodeNodeTypeResolver.cs
Inferring abstract/interface types for YamlDotNet Deserialization
using System;
using System.Collections.Generic;
using System.Linq;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NodeDeserializers;
namespace Egret.Cli.Models
{
::Skip file with name .pdb, someFile.xml and .config$
msdeploy.exe -verb:sync -source:contentPath=SourcePath -dest:DestPath -skip:objectName=filepath,absolutepath="^*\.pdb$" -skip:objectName=filepath,absolutepath="^*\someFile.xml$" -skip:objectName=filepath,absolutepath="^*\someotherfile.aspx$" -skip:objectName=filepath,absolutepath=".config$"
@jrgcubano
jrgcubano / drop-disabled-enabled-fk-table-constraints.sql
Created November 10, 2020 14:24
SQL SERVER DROP, ADD, DISABLE AND ENABLE Foreign Key contraints: (edited)
-- Drop FK constraints
BEGIN
ALTER TABLE [Report].DailyOccupancyStats_Agg DROP CONSTRAINT [FK_Report.DailyOccupancyStats_Agg_DateId];
ALTER TABLE [Report].OccupancySessionsStats_Agg DROP CONSTRAINT [FK_Report.OccupancySessionsStats_Agg_DateId];
ALTER TABLE [Report].OccupancySessionsOspStats_Agg DROP CONSTRAINT [FK_Report.OccupancySessionsOspStats_Agg_DateId];
ALTER TABLE [Report].ParkeonSessionsStats_Agg DROP CONSTRAINT [FK_Report.ParkeonSessionsStats_Agg_DateId];
ALTER TABLE [Report].ParkingSessionsStats_Agg DROP CONSTRAINT [FK_Report.ParkingSessionsStats_Agg_DateId];
ALTER TABLE [Report].ParkingSessionsOspStats_Agg DROP CONSTRAINT [FK_Report.ParkingSessionsOspStats_Agg_DateId];
ALTER TABLE [Report].ParkingUsersCreationStats_Agg DROP CONSTRAINT [FK_Report.ParkingUsersCreationStats_Agg_CreationDateId]
using System;
using System.Threading;
using System.Threading.Tasks;
namespace YARG.Core.Utils
{
internal delegate void TimerCallback(object state);
internal sealed class Timer : CancellationTokenSource, IDisposable
{
@jrgcubano
jrgcubano / git-pushing-multiple.rst
Created October 4, 2020 15:15 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@jrgcubano
jrgcubano / csharpserver_dotnet_namedpipe.cs
Created April 22, 2020 09:54 — forked from abgoswam/csharpserver_dotnet_namedpipe.cs
C# Server using .NET Core Named Pipes
using System;
using System.IO;
using System.IO.Pipes;
using System.Text;
class PipeServerBinary
{
static void Main()
{
using (NamedPipeServerStream pipe = new NamedPipeServerStream("testpipe"))
@jrgcubano
jrgcubano / AUsage.cs
Created February 24, 2020 10:12 — forked from davidfowl/AUsage.cs
Header propagation HttpClientFactory middleware
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient("myclient");
// Global header propagation for any HttpClient that comes from HttpClientFactory
services.AddHeaderPropagation(options =>
{
options.HeaderNames.Add("Correlation-Id");
});
}
@jrgcubano
jrgcubano / DapperExtensions.cs
Created February 12, 2020 09:06 — forked from hyrmn/DapperExtensions.cs
Extension methods for calling Dapper asynchronously with a Polly retry
public static class DapperExtensions
{
private static readonly IEnumerable<TimeSpan> RetryTimes = new[]
{
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(2),
TimeSpan.FromSeconds(3)
};
private static readonly AsyncRetryPolicy RetryPolicy = Policy
@jrgcubano
jrgcubano / AzureStorageEmulatorManager.cs
Last active February 3, 2020 13:56 — forked from SeanFeldman/AzureStorageEmulatorManager.cs
SetUp Fixture for NUnit starting the emulator before tests
namespace AzureTableStorage.Tests
{
using System.Diagnostics;
using System.Linq;
// Start/stop azure storage emulator from code:
// http://stackoverflow.com/questions/7547567/how-to-start-azure-storage-emulator-from-within-a-program
public static class AzureStorageEmulatorManager
{
const string AzureStorageEmulatorPath = @"C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe";
@jrgcubano
jrgcubano / AsyncQueryExtensions.cs
Created December 20, 2019 13:24
LINQ ASync query extensions
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using WindowsAzure.Table.Queryable;
namespace WindowsAzure.Table.Extensions
{