Skip to content

Instantly share code, notes, and snippets.

View NDiiong's full-sized avatar
😀
Hi there!

duong.nb NDiiong

😀
Hi there!
View GitHub Profile
@NDiiong
NDiiong / HelloHeels
Created October 26, 2022 04:21 — forked from MayaReneeD/HelloHeels
Hello Heels
Hello Heels is an application that allows the user to search and snag the perfect pair of heels straight from independent vendors based on their own unique style.
API Key for Esty: hwox3uujwstcvm3eibnbf9rf
@NDiiong
NDiiong / TaskExtensions.cs
Created April 25, 2022 06:53 — forked from gongdo/TaskExtensions.cs
Task extensions for parallelism
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Gist
{
public static class TaskExtensions
{
@NDiiong
NDiiong / CustomerController.cs
Created April 19, 2022 03:13 — forked from vkhorikov/CustomerController.cs
Handling failures and input errors in a functional way
[HttpPost]
public HttpResponseMessage CreateCustomer(string name, string billingInfo)
{
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo);
Result<CustomerName> customerNameResult = CustomerName.Create(name);
return Result.Combine(billingInfoResult, customerNameResult)
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value))
.OnSuccess(() => new Customer(customerNameResult.Value))
.OnSuccess(

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Threading;
using System.Threading.Tasks;
using EnvDTE80;
using EnvDTE90a;
public class AzureBlobFileClient : IFileClient
{
private CloudBlobClient _blobClient;
public AzureBlobFileClient(string connectionString)
{
var account = CloudStorageAccount.Parse(connectionString);
_blobClient = account.CreateCloudBlobClient();
}
@NDiiong
NDiiong / gist:15bb0c7788a83f479138cd825ebc1cca
Last active January 26, 2021 06:10 — forked from lafar6502/gist:8105682
some messy code of a synchronization gateway that allows only a single thread of execution for all passed callbacks. It allows new callbacks to be enqueued while they are being executed by another thread. This implementation is almost certainly broken because I didn't care if it compiles at all and if all closure stuff is done correctly, but hop…
public class ConcurrentGateway
{
private ConcurrentQueue<Action> _workQueue = new ConcurrentQueue<Action>();
private int _writeLock = 0;
[ThreadStatic]
private static AutoResetEvent _waitEvent = new AutoResetEvent(false);
protected static AutoResetEvent GetThreadWaitEvent()
{
@NDiiong
NDiiong / RockSolidChurchTemplate.cs
Created November 16, 2020 08:22 — forked from tcavaletto/RockSolidChurchTemplate.cs
Rock Solid Church Template
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using com.centralaz.RoomManagement.Attribute;
using com.centralaz.RoomManagement.Model;
using com.centralaz.RoomManagement.ReportTemplates;
using iTextSharp.text;
using iTextSharp.text.pdf;
@NDiiong
NDiiong / Partition.cs
Created August 18, 2020 03:56 — forked from atifaziz/Partition.cs
LINQ operator to split a sequence into two based on a condition
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
static partial class Sequence
{
/// <summary>
/// Splits the sequence into two sequences, containing the elements
/// for which the given predicate returns <c>true</c> and <c>false</c>
using System.Xml.Linq;
namespace Json.Linq
{
public class JDocument : XDocument
{
public JDocument() : base() { }
public JDocument(params object[] content) : base(content) { }
public JDocument(XDocument other) : base(other) { }
public JDocument(XDeclaration declaration, params object[] content) : base(declaration, content) { }