Skip to content

Instantly share code, notes, and snippets.

View jchandra74's full-sized avatar

Jimmy Chandra jchandra74

  • Sydney, NSW, Australia
View GitHub Profile
@jchandra74
jchandra74 / index.html
Created February 7, 2020 17:04
JS Bin Implementation of Find First Non Repeatable Character in a String // source https://jsbin.com/gomukah
<!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>
@jchandra74
jchandra74 / openssl.MD
Last active July 12, 2024 09:58
HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

Overview

My main development workstation is a Windows 10 machine, so we'll approach this from that viewpoint.

Recently, Google Chrome started giving me a warning when I open a site that uses https and self-signed certificate on my local development machine due to some SSL certificate issues like the one below:

Self-Signed SSL Issue in Chrome

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 / PowerShell Customization.md
Last active November 15, 2024 12:07
PowerShell, Cmder / ConEmu, Posh-Git, Oh-My-Posh, Powerline Customization

Pimping Up Your PowerShell & Cmder with Posh-Git, Oh-My-Posh, & Powerline Fonts

Backstory (TLDR)

I work as a full-stack developer at work. We are a Windows & Azure shop, so we are using Windows as our development platform, hence this customization.

For my console needs, I am using Cmder which is based on ConEmu with PowerShell as my shell of choice.

Yes, yes, I know nowadays you can use the Linux subsystem on Windows 10 which allow you to run Ubuntu on Windows. If you are looking for customization of the Ubuntu bash shell, check out this article by Scott Hanselman.

@jchandra74
jchandra74 / NullifyEmptyProperties.cs
Created September 7, 2016 03:53
Object graph walker that will clean up empty array, generic collection and string
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Foo
{
public static class ObjectExtensions
{
public static void NullifyEmptyProperties(this object o)
{
@jchandra74
jchandra74 / index.html
Last active April 27, 2024 04:08
Angular Speech API Times Table Quiz for Kids
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link data-require="[email protected]" 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 / FileUtil.cs
Last active April 27, 2024 04:08
Detect MimeType and File Extension based on filename and falling back to fileStream for signature detection (specific to .binary extension)
//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 / SHA1Util.cs
Last active April 3, 2019 17:20 — forked from kristopherjohnson/SHA1Util.cs
SHA1 Hash for Unicode string
//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
@jchandra74
jchandra74 / binary2hex.cs
Created April 14, 2015 00:12
Binary to Hex String Conversion
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++)
{
@jchandra74
jchandra74 / StringExtension.cs
Created April 14, 2015 00:10
String Helper
namespace __NAMESPACE__
{
using System.Text;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
public static class StringExtension
{
public static string StripInvalidUnicodeCharacters(this string str)
{