Skip to content

Instantly share code, notes, and snippets.

View thakurarun's full-sized avatar

Arun Thakur thakurarun

View GitHub Profile
@thakurarun
thakurarun / tree-utils.ts
Last active April 19, 2021 04:54
Tree utils for searching, tracking and backtracking
export function treeForwardTracking(
treeNodes: TreeNode[],
action: (TreeNode: TreeNode) => void
): void {
treeNodes.forEach((node) => {
action(node);
if (node.children) {
treeForwardTracking(node.children, action);
}
});
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\cmdprompt]
@="@shell32.dll,-8506"
"Extended"=""
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\cmdprompt\command]
@="cmd.exe /s /k pushd \"%V\""
[HKEY_CLASSES_ROOT\Directory\Background\shell\cmdprompt]
{
"typescript.tsc.autoDetect": "on",
"window.zoomLevel": 0,
"typescript.referencesCodeLens.enabled": true,
"editor.minimap.enabled": false,
"editor.colorDecorators": true,
"css.lint.hexColorLength": "error",
"workbench.colorTheme": "Monokai Dimmed",
"workbench.editor.tabSizing": "shrink",
"files.trimTrailingWhitespace": true,
@thakurarun
thakurarun / _unique.js
Created June 21, 2016 06:32
find unique and duplicate values in array
var _unique = function (arr) {
var h = [], t = [];
arr.forEach(function (n) {
if (h.indexOf(n) == -1)
h.push(n);
else t.push(n);
});
return [h, t];
}
@thakurarun
thakurarun / gist:7577530
Created November 21, 2013 07:51
Form to json using jquery fnction
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
@thakurarun
thakurarun / gist:7542106
Created November 19, 2013 08:27
Sample for making deep copy of any object in c#
[Serializable]
public class temp
{
public int a;
}
class Program
{
public static T DeepClone<T>(T a)
{
using (MemoryStream stream = new MemoryStream())
@thakurarun
thakurarun / gist:7480495
Created November 15, 2013 07:25
128 bit encryption -AES
public static class IrCryptography
{
private static readonly int _saltSize = 32;
private static string key = System.Configuration.ConfigurationManager.AppSettings["CryptoKey"];
/// <summary>
/// Encrypts the plainText input using the given Key.
/// A 128 bit random salt will be generated and prepended to the ciphertext before it is base64 encoded.
/// </summary>
/// <param name="plainText">The plain text to encrypt.</param>
/// <param name="key">The plain text encryption key.</param>
@thakurarun
thakurarun / gist:7444444
Created November 13, 2013 06:01
jQuery function to check email with all popular contraints
function chkmail(emailStr) {
/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD. 1 means check it, 0 means don't. */
var checkTLD = 1;
/* The following is the list of known TLDs that an e-mail address must end with. */
var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
/* The following pattern is used to check if the entered e-mail address
@thakurarun
thakurarun / gist:7412165
Created November 11, 2013 11:59
It finds the first specified type of control in calling method, and return it;
public static T FindFirstSelectControlInControl_ExtentionMethod<T>(UITestControl ControlInWhichSelectControlCanBeFound)
{
T element = default(T);
var childrenControl = ControlInWhichSelectControlCanBeFound.GetChildren();
if (childrenControl.Count > 0)
{
childrenControl.All(x =>
{
if (x is T)
{