Skip to content

Instantly share code, notes, and snippets.

View nordinrahman's full-sized avatar

Nordin Rahman nordinrahman

View GitHub Profile
private static Action Act(Action action)
{
return () =>
{
try
{
action();
}
catch (TargetInvocationException ex)
@nordinrahman
nordinrahman / ReinitWebpack.cmd
Last active July 3, 2017 01:50
Reinit webpack
del /f /s /q node_modules > nul && rmdir /s /q node_modules && npm install && webpack --config webpack.config.vendor.js && webpack
@nordinrahman
nordinrahman / nswag.commandline.txt
Created May 31, 2017 15:42
Command line for nswag
NSwag command line tool for .NET 4.6+, toolchain v10.6.6324.28497 (NJsonSchema v8.33.6323.36213) (x64)
Visit http://NSwag.org for more information.
NSwag bin directory: C:\@App\NSwag
USAGE
=====
myapp.exe myCommand /myParameter:myValue /mySecondParameter:myValue
AVAILABLE COMMANDS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class Program
{
private const int MB = 1024*1024;
@nordinrahman
nordinrahman / git-format-patch-am.bash
Created April 19, 2017 15:01
Git format-patch and apply
git format-patch -1 --stdout > patch.patch
git am --keep-cr patch.patch
@nordinrahman
nordinrahman / AddAllPackagesFileToTFS.cmd
Last active April 28, 2017 09:47
Add all packages files to TFS pending changes
` from batch file
for /R packages %%f in (*.*) do "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\TF.exe" vc add %%f
` from command line
for /R packages %f in (*.*) do "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\TF.exe" vc add %f
@nordinrahman
nordinrahman / AppendJQuery.js
Created December 23, 2016 03:14
Append jQuery to current page
(function(src){var s = document.createElement('script'); s.setAttribute('type', 'text/javascript'); s.setAttribute('src', src); document.head.appendChild(s); })('https://code.jquery.com/jquery-3.1.1.js');
@nordinrahman
nordinrahman / flatten.js
Created December 8, 2016 07:08
Flatten item and all its hierarchical hierarchy
var flatten = function(item) { var result = [item]; (items.Children || []).map(x => flatten(x)).forEach(x => result = result.concat(x)); return result; }
@nordinrahman
nordinrahman / MultiVersionConstant.xml
Created November 20, 2016 16:13
PropertyGroup element to define .NET constants
<PropertyGroup>
<NetFrameworkVersionNum>$(TargetFrameworkVersion.Replace("v", "").Replace(".", ""))</NetFrameworkVersionNum>
<!--Add an extra 0 if the version number is 40 or 45 so it can be compared to 401-->
<NetFrameworkVersionNum Condition="$(NetFrameworkVersionNum.Length) &lt; 3">$(TargetFrameworkVersion.Replace("v", "").Replace(".", ""))0</NetFrameworkVersionNum>
<!--Don't define your own NET constants - this file will do it for you-->
<Error Condition=" $(DefineConstants.Contains('NET'))">Don't define your own NET constants</Error>
<!--Create a version to use with constants NET40, NET401 etc.-->
<NetFrameworkVersion Condition=" !$(DefineConstants.Contains(';NET')) ">$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</NetFrameworkVersion>
<DefineConstants Condition=" !$(DefineConstants.Contains(';NET')) ">$(DefineConstants);$(NetFrameworkVersion)</DefineConstants>
<!--Define the OR_GREATER constants-->
@nordinrahman
nordinrahman / Global.asax.SetCustomCultureUI.cs
Last active September 18, 2016 10:08
Global.asax code to set current thread's CultureInfo with CustomCultureUI instance
public override void Init()
{
base.Init();
BeginRequest -= OnBeginRequest;
BeginRequest += OnBeginRequest;
}
private void OnBeginRequest(object sender, EventArgs eventArgs)
{