Skip to content

Instantly share code, notes, and snippets.

@ronsun
ronsun / BranchCleanup.md
Last active July 21, 2022 06:37
Git Commands

Delete local branches with no remote branch

git branch -vv | grep -v origin | awk '{print $1}' | xargs git branch -D

The error message "git did not exit cleanly (exit code 1)" is a very general error message, in most of scenarios, just clean up local repository to resolve it, but sometimes it not actully caused by "not clean".

In my case, the reason is I tried to push large file that size over the postbuffer (default as 1M).

Solution

Edit .gitconfig, set http.postBuffer to larger amout.

  1. Set post buffer to 10M :
    git config --global http.postBuffer 102400
  2. Check result :
@ronsun
ronsun / anatomy-url.md
Last active August 9, 2019 16:18
Components of URL

Quick reference for naming.

General

Syntax diagram took from wiki: URL
Alt text

More detail took from here: URI

          userinfo     host        port
          ┌─┴────┐ ┌────┴────────┐ ┌┴┐ 
@ronsun
ronsun / proxy.ashx
Created January 6, 2019 16:33 — forked from kai5263499/proxy.ashx
A simple proxy in C# which persists the entire request to the target
<%@ WebHandler Language="C#" CodeBehind="proxy.ashx.cs" Class="PIPE.Host.proxy" %>
@ronsun
ronsun / ilasm-and-ildasm.md
Last active December 4, 2018 02:11
Looking for ilasm.exe and ildasm.exe

先隨便記一下, 有空再看看要不要整理成章

ildasm.exe

這是反組譯成 IL 碼的工具, 可以返組譯出 IL 碼, 安裝VS的時候會一併裝, 位置在 C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.1 Tools

ilasm.exe

組譯工具

@ronsun
ronsun / Mock-HttpWebRequest.md
Last active November 19, 2018 10:19
Mock HttpWebRequest

dependency

  • NUnit 3
  • NSubstitute
  • FluentAssertions

production code

public class EZHttp
{
    public string Get(string url)
@ronsun
ronsun / mock_ControllerBase.Request.md
Last active November 6, 2018 04:52
Mock ControllerBase.Request

ControllerBase.Request same with ControllerBase.ControllerContext.HttpContext.Request,
so just set ControllerBase.ControllerContext.HttpContext as mocked object, ex:

var target = Substitute.ForPartsOf<MyController>();

var mockedHttpContext = new DefaultHttpContext();
var mockedQueryString = "?q1=a+b&q2=a%21b";
mockedHttpContext.Request.QueryString = new QueryString(mockedQueryString);
@ronsun
ronsun / convert-to-unix-ticks.md
Last active November 6, 2018 04:54
windows 18-digit ticks to Unix 13-digit ticks
  • After .NET 4.6
long unixTimeSecond = DateTimeOffset.Now.ToUnixTimeSeconds();
long unixTimeMilliSecond = DateTimeOffset.Now.ToUnixTimeMilliseconds();
  • Other way
long epochTicks = new DateTime(1970, 1, 1).Ticks;
long unixTimeSecond = ((DateTime.Now.Ticks - epochTicks) / TimeSpan.TicksPerSecond);
@ronsun
ronsun / rwd-for-ie8-or-before.md
Last active November 6, 2018 04:54
RWD for IE8 or earlier
	//Detect Browser version and Support IE
    if(Request.Browser.Type.ToUpper().Contains("IE")){
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <script src="~/Content/html5shiv/js/html5shiv.min.js"></script>
        <script src="~/Content/respond/js/respond.min.js"></script>
    }