Skip to content

Instantly share code, notes, and snippets.

#region IDisposable Implementation
private bool disposed;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
using Newtonsoft.Json;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
namespace CacheAsideDemo.Data
{
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++)
{
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
{
@jessebarocio
jessebarocio / RateLimitingHandler.cs
Last active June 13, 2021 18:02
Implementing and registering a message handler in ASP.NET Web API 2
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";
@jessebarocio
jessebarocio / profile.ps1
Last active October 30, 2018 19:14
My PowerShell profile
###
## NOTE: This assumes the folliwng:
## - PS 5.x
## - posh-git (https://github.com/dahlbyk/posh-git) 1.x is installed
###
###
## Helper Functions
###
@jessebarocio
jessebarocio / arm-template.json
Created December 10, 2018 17:56
Sample ARM template with outputs
{
"$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"
-- 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 / settings.json
Created August 18, 2020 03:57
My Windows Terminal Config
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"alwaysShowTabs" : true,
"copyOnSelect" : false,
"defaultProfile" : "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"initialCols" : 120,
"initialRows" : 30,
"keybindings" :
[
{
@jessebarocio
jessebarocio / AutocompleteTextbox.css
Created January 25, 2021 21:58
React AutocompleteTextbox component using Bootstrap 4
/* Hide the bootstrap dropdown-menu if it has no children */
.dropdown-menu:empty {
display: none !important;
}