Skip to content

Instantly share code, notes, and snippets.

View mishrsud's full-sized avatar
🎯
Focusing

Sudhanshu Mishra mishrsud

🎯
Focusing
View GitHub Profile
// The type to be persisted
using System;
using Newtonsoft.Json;
namespace Demo
{
public class SomeConfiguration
{
/// <summary>
/// Gets or sets the identifier for this record.
@mishrsud
mishrsud / ToJsonWithCamelCase.cs
Created August 14, 2016 07:22
Customize JSON serialization using Newtonsoft.Json to use camel case on property names and strings for Enum
/// <summary>
/// Customize JSON serialization using Newtonsoft.Json
/// </summary>
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public static class JsonExtensions
{
public static string ToJson<T>(this T obj, bool includeNull = true)
# MyDirectory is a subdirectory of the current directory (i.e. the directory printed by pwd)
Get-ChildItem -Path .\MyDirectory -Filter *.nuspec -Recurse -Name
@mishrsud
mishrsud / Howto-Sync-Fork-from-original.md
Last active January 17, 2017 05:14
Github sync a fork with original

Major Module systems in ECMAScript

Resources

Node module system

  1. Basically each file is treated as a module
  2. To define what the module exposes, assign stuff to module.exports
let calculator = function(num1, num2) {

How-to: Squash commits

Summary

Steps to squash multiple commits into one

Steps

  • View the log to decide on which commits to squash
git log
@mishrsud
mishrsud / DapperWithNullParams.cs
Created February 17, 2017 06:28
Demonstrates using Dapper ORM to call a stored proc with Null params
ConfigurationManager.RefreshSection("ConnectionStrings");
var connString = ConfigurationManager.ConnectionStrings["ReconciliationConnectionString"];
dynamic outObj;
using (var connection = new SqlConnection(connString.ConnectionString))
{
var result = connection.Query<dynamic>(GetCreateDealSproc(),
new
{
UU_ID = 21096,
NC_IDBuy = "GBP",
@mishrsud
mishrsud / UnhandledExceptionLoggingSetup
Last active February 21, 2017 23:18 — forked from gkinsman/new_gist_file
UnhandledExceptionLogger
public static class UnhandledExceptionLogger
{
public static void Install()
{
var log = Log.ForContext(typeof(UnhandledExceptionLogger));
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
{
log.Fatal(e.ExceptionObject as Exception, "Unhandled exception caught at AppDomain boundary (terminating: {IsTerminating})", e.IsTerminating);
};
@mishrsud
mishrsud / SQL-join-cheat-sheet.md
Last active June 14, 2025 19:12
SQL Joins Cheat Sheet
@mishrsud
mishrsud / CORSandCAS.md
Created March 16, 2017 00:05
CORS, CAS, AJAX, JavaScript and Browser issues explained

Summary

CORS or Cross Origin Resource Sharing is a way to allow cross domain requests to be serviced by the browser. It was implemented by browser vendors as a response to requests to let client side script make webservice calls across domains. Point to note is that it is the called webservice that has to allow CORS by adding appropriate headers to the response: Access-Control-Allow-Origin Access-Control-Allow-Headers Access-Control-Allow-Methods

Terms

  1. CAS: Central Authentication Service - aka Single Sign on
  2. CORS: Cross Origin Resource Sharing