Skip to content

Instantly share code, notes, and snippets.

Avatar

Jimmy Chandra jchandra74

  • Sydney, NSW, Australia
View GitHub Profile
@jchandra74
jchandra74 / fingerprint.cs
Last active Aug 29, 2015
asp.net good config and practices
View fingerprint.cs
//Stolen from @mkristensen
//Use to bust static content like .js and .css when they changed.
using System.IO;
using System.Web;
using System.Web.Caching;
using System.Web.Hosting;
namespace CHANGE_YOUR_NAMESPACE_HERE
{
public class Fingerprint
View StreamExtension.cs
namespace __NAMESPACE__
{
using System.IO;
public static class StreamExtension
{
public static byte[] ToByteArray(this Stream input)
{
using (var memStream = new MemoryStream())
{
@jchandra74
jchandra74 / ObjectCopier.cs
Created Apr 13, 2015
Object Deep Copy via Serialization
View ObjectCopier.cs
namespace __NAMESPACE__
{
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
public static class ObjectCopier
{
/// <summary>
View ObjectSerializer.cs
namespace __NAMESPACE__
{
using System;
using System.IO;
using System.Xml;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
using Newtonsoft.Json;
using JsonSerializer = ServiceStack.Text.JsonSerializer;
using XmlSerializer = System.Xml.Serialization.XmlSerializer;
@jchandra74
jchandra74 / binary2hex.cs
Created Apr 14, 2015
Binary to Hex String Conversion
View binary2hex.cs
public static string BinaryToHex(byte[] data)
{
if (data == null)
{
return null;
}
var array = new char[checked(data.Length*2)];
for (var i = 0; i < data.Length; i++)
{
View GenericCollectionExtensions.cs
namespace __NAMESPACE__
{
using System.Linq;
using System.Collections.Generic;
/// <summary>
/// Check if expected list items are all in master list
/// </summary>
/// <typeparam name="T">Generic Type</typeparam>
@jchandra74
jchandra74 / NullifyEmptyProperties.cs
Created Sep 7, 2016
Object graph walker that will clean up empty array, generic collection and string
View NullifyEmptyProperties.cs
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Foo
{
public static class ObjectExtensions
{
public static void NullifyEmptyProperties(this object o)
{
@jchandra74
jchandra74 / SHA1Util.cs
Last active Apr 3, 2019 — forked from kristopherjohnson/SHA1Util.cs
SHA1 Hash for Unicode string
View SHA1Util.cs
//Forked from kristopherjohnson/SHA1Util.cs gist
using System.Security.Cryptography;
using System.Text;
namespace Snippets
{
public static class SHA1Util
{
/// <summary>
/// Compute hash for string encoded as UTF8
View Guid Generator PowerShell.md

PowerShell GUID Generator

From time to time, I need to generate GUID to be used as Unique Id for whatever reason. When I have Visual Studio opened, I usually use the GUID tool that comes with it.

But sometimes I am developing in VS Code and opening Visual Studio just to get access to the GUID tool is a pain.

So why not add the functionality to PowerShell instead? You can have PowerShell available from inside VS Code Terminal. It's the perfect thing to add.

So how do we go about that?

@jchandra74
jchandra74 / index.html
Created Feb 7, 2020
JS Bin Implementation of Find First Non Repeatable Character in a String // source https://jsbin.com/gomukah
View index.html
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Implementation of Find First Non Repeatable Character in a String">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>