Skip to content

Instantly share code, notes, and snippets.

@deepumi
deepumi / feature.cs
Last active Dec 22, 2018
Feature flag
View feature.cs
using System;
using System.Collections.Concurrent;
namespace FeatureFlagTest
{
class Program
{
static void Main(string[] args)
{
var home = new HomeController(FeatureFactory.Feature);
@deepumi
deepumi / TypeActivator.cs
Last active Aug 1, 2018
Create instance using Reflection
View TypeActivator.cs
public static class TypeActivator<T>
{
private delegate T Activator<T>(params object[] args);
private static readonly Dictionary<string, Activator<T>> _items = new Dictionary<string, Activator<T>>();
/// <summary>
///
/// </summary>
/// <returns></returns>
public static T Create()
View sample.go
//main.go
package main
import (
"fmt"
"time"
"awesomeProject/another"
)
@deepumi
deepumi / StripMarkupTags.cs
Created Mar 29, 2018
Strip Html Markup Tags
View StripMarkupTags.cs
private static string StripMarkupTags(string source)
{
if (source == null) return string.Empty;
var length = source.Length;
var array = new ArrayBuilder(length);
var markup = false;
for (var i = 0; i < length; i++)
{
@deepumi
deepumi / delete.js
Created Dec 28, 2017
Delete all documens from Cosmos DB
View delete.js
//copied from here
//https://stackoverflow.com/questions/29137708/how-to-delete-all-the-documents-in-documentdb-through-c-sharp-code
//https://stackoverflow.com/questions/43587572/how-to-clear-the-collection-in-documentdb-through-query-explorer
/**
* A DocumentDB stored procedure that bulk deletes documents for a given query.<br/>
* Note: You may need to execute this sproc multiple times (depending whether the sproc is able to delete every document within the execution timeout limit).
*
* @function
* @param {string} query - A query that provides the documents to be deleted (e.g. "SELECT * FROM c WHERE c.founded_year = 2008")
@deepumi
deepumi / WinDB.txt
Last active Oct 5, 2017
WinDB tips
View WinDB.txt
https://blogs.msdn.microsoft.com/benjaminperkins/2016/06/16/lab-19-debugging-a-high-cpu-hang-w3wp-process-using-windbg/
https://stackify.com/using-windbg-to-analyze-net-crash-dumps-async-crash/
.sympath srv*C:\Projects\Workshop\Sym*http://msdl.microsoft.com/download/symbols;C:\Projects\publish\ProcDumpTest\bin (IIS path)
.load C:\Windows\Microsoft.NET\Framework64\v4.0.30319\sos.dll
!threadpool
!runaway – The once consuming the most amount of time are of most interest, but not always the reason for the problem
@deepumi
deepumi / excel.txt
Created Aug 7, 2017
Excel formula generate expression
View excel.txt
= "update table set name = '" & B1 & "' where namefk = '" & A1 & "'"
@deepumi
deepumi / ChargeMyStripeFeeToCustomer.cs
Created Jul 9, 2017
Stripe code snippet to charge transaction fee from customer side using CSharp
View ChargeMyStripeFeeToCustomer.cs
//code snippet to charge transaction fee from customer side.
//https://support.stripe.com/questions/can-i-charge-my-stripe-fees-to-my-customers
static void Main()
{
//Total fee for platform and stripe would be 5% + .30 Cents
const decimal fixedFee = .30M; //.30 cents
const decimal fixedFeePercentage = 5M; // 5% = Percentage fees for Stripe and Platform (ex : stripe fee 2.9 + 2.1 platform fee = 5%)
@deepumi
deepumi / JsonConfigForWebAPI.cs
Created Jun 29, 2017
Json configuration for web api camel case
View JsonConfigForWebAPI.cs
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Json settings
config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
{
@deepumi
deepumi / JsonSerializer.cs
Last active Jun 12, 2017
Large Json serializer
View JsonSerializer.cs
private static T Deserialize<T>(Stream stream)
{
if (stream == null || !stream.CanRead) return default(T);
using (var reader = new StreamReader(stream))
{
using (var json = new Newtonsoft.Json.JsonTextReader(reader))
{
return new Newtonsoft.Json.JsonSerializer().Deserialize<T>(json);
}
You can’t perform that action at this time.