Skip to content

Instantly share code, notes, and snippets.

View jrgcubano's full-sized avatar

Jorge Rodríguez Galán jrgcubano

View GitHub Profile
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 / CreateDateDimensionWithFiscals.sql
Created November 25, 2019 09:08 — forked from cgibson-dev/CreateDateDimensionWithFiscals.sql
A SQL script to create a Date dimension table with logic to specify fiscal dates.
BEGIN TRY
DROP TABLE [Dim].[Date]
END TRY
BEGIN CATCH
/*No Action*/
END CATCH
CREATE TABLE [Dim].[Date]
(
@jrgcubano
jrgcubano / DateTimeExtensions.cs
Created April 26, 2019 16:50
NodaTime InZone() and ToZone() conversion extension methods and sample usage.
public static class DateTimeExtensions
{
/// <summary>
/// Converts a non-local-time DateTime to a local-time DateTime based on the
/// specified timezone. The returned object will be of Unspecified DateTimeKind
/// which represents local time agnostic to servers timezone. To be used when
/// we want to convert UTC to local time somewhere in the world.
/// </summary>
/// <param name="dateTime">Non-local DateTime as UTC or Unspecified DateTimeKind.</param>
/// <param name="timezone">Timezone name (in TZDB format).</param>
@jrgcubano
jrgcubano / app.html
Created March 6, 2019 11:38 — forked from stoffeastrom/app.html
Aurelia Gist TypeScript Gestures Contextmenu
<template>
<require from="oa-contextmenu"></require>
<table oa-contextmenu.call="onContextmenu()">
<tr>
<td>Gesture me!!!</td>
</tr>
</table>
</template>