Skip to content

Instantly share code, notes, and snippets.

Avatar

Jesse Barocio jessebarocio

View GitHub Profile
@jessebarocio
jessebarocio / settings.json
Created Aug 18, 2020
My Windows Terminal Config
View settings.json
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"alwaysShowTabs" : true,
"copyOnSelect" : false,
"defaultProfile" : "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"initialCols" : 120,
"initialRows" : 30,
"keybindings" :
[
{
View asp-dot-net-identity-to-asp-dot-net-core-identity-migration-script.sql
-- STEP 1 : Change name of existing tables
EXEC sp_rename 'AspNetRoles', 'AspNetRoles_old';
EXEC sp_rename 'AspNetUserClaims', 'AspNetUserClaims_old';
EXEC sp_rename 'AspNetUserLogins', 'AspNetUserLogins_old';
EXEC sp_rename 'AspNetUserRoles', 'AspNetUserRoles_old';
EXEC sp_rename 'AspNetUsers', 'AspNetUsers_old';
@jessebarocio
jessebarocio / arm-template.json
Created Dec 10, 2018
Sample ARM template with outputs
View arm-template.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"cosmosAccountName": {
"type": "string"
}
},
"variables": {
"cosmosDbApiVersion": "2015-04-08"
@jessebarocio
jessebarocio / profile.ps1
Last active Oct 30, 2018
My PowerShell profile
View profile.ps1
###
## NOTE: This assumes the folliwng:
## - PS 5.x
## - posh-git (https://github.com/dahlbyk/posh-git) 1.x is installed
###
###
## Helper Functions
###
@jessebarocio
jessebarocio / RateLimitingHandler.cs
Last active Oct 7, 2020
Implementing and registering a message handler in ASP.NET Web API 2
View RateLimitingHandler.cs
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace MyApi.Infrastructure
{
public class RateLimitingHandler : DelegatingHandler
{
private const string RateLimitHeaderName = "X-MyApi-Rate-Limit-Remaining";
View Program.cs
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.RetryPolicies;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AzureStorageRetry
{
View ExponentialBackoff.cs
var resource = new MyRemoteResource();
int initialRetryInterval = 2000; // 2 seconds
int maxAttempts = 5;
int currentRetryInterval = initialRetryInterval;
// If the connection fails then we'll try reconnecting a maximum number of 5 times
// before throwing the exception. The interval between retries will double each time.
for(int i = 1; i <= maxAttempts; i++)
{
View Cache.cs
using Newtonsoft.Json;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
namespace CacheAsideDemo.Data
{
View Sample.cs
#region IDisposable Implementation
private bool disposed;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
You can’t perform that action at this time.