Skip to content

Instantly share code, notes, and snippets.

Jimmy Chandra jchandra74

  • Sydney, NSW, Australia
Block or report user

Report or block jchandra74

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
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;
View StringExtension.cs
namespace __NAMESPACE__
{
using System.Text;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
public static class StringExtension
{
public static string StripInvalidUnicodeCharacters(this string str)
{
@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 / FileUtil.cs
Last active Aug 29, 2015
Detect MimeType and File Extension based on filename and falling back to fileStream for signature detection (specific to .binary extension)
View FileUtil.cs
//mimetypes: http://www.sitepoint.com/web-foundations/mime-types-complete-list/
//https://technet.microsoft.com/en-us/library/ee309278(office.12).aspx
public static class FileUtil
{
public static string DetectFileType(string filename, Stream fileStream)
{
var ext = Path.GetExtension(filename);
if (string.IsNullOrEmpty(ext))
{
@jchandra74
jchandra74 / index.html
Last active Apr 2, 2016
Angular Speech API Times Table Quiz for Kids
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link data-require="bootstrap-css@3.3.6" data-semver="3.3.6" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" />
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container" ng-app="app" ng-controller="pageCtrl as page">
@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)
{
You can’t perform that action at this time.