發表文章

目前顯示的是 7月, 2018的文章

Closing over the loop variable considered harmful

要小心用closure 同forloop, 都幾特別 https://blogs.msdn.microsoft.com/ericlippert/2009/11/12/closing-over-the-loop-variable-considered-harmful/

Fixing reading XPS memory leak issue

class Program { static int intCounter = 0; static object _intLock = new object(); static int getInt() { lock (_intLock) { return intCounter++; } } static void Main(string[] args) { Console.ReadLine(); while (true) { while (!Console.KeyAvailable) { for (int i = 0; i { var ogXps = File.ReadAllBytes(@"C:\Users\nathan\Desktop\hahaha.xps"); var returnedDoc = Test(ogXps); string id = getInt().ToString(); // File.WriteAllBytes(@".\output\" + id + ".xps", returnedDoc); Console.WriteLine(id); }); t.SetApartmentState(ApartmentState.STA...

Adding line number on <ol> <li> with alignment and width adjustment by CSS and Javascript

圖片
話說今日 (21/7/2018) 想係個logger度加 line number 個structure大約係咁: <ol>    <li>      <pre> blah blah blah </pre>    </li> </ol> 咁出黎就係有數字, 不過就多左粒點, 變成咁樣: 上stackoverflow d人就教用css :before selector 整個假狗counter 黎取代佢原本個數字, 出黎效果: https://stackoverflow.com/questions/11946098/how-to-remove-dot-after-number-in-ordered-list-items-in-ol-li ol { counter-reset : item; list-style-type : none ; padding-left : 10px } li { display : -webkit-box; } li:before { content : counter ( item ) " " ; counter-increment : item ; color : gray ; display : block ; text-align : right ; font-size : 14px ; } (用黎收埋最尾果行用) li:last-child:before { content : "" ; } 出黎見到另一個問題, 就係佢每個li:before 既width都唔一樣.. 本來好天真地以為可以就咁計返最長數字既width, 再用jquery $("li:before").each(function(e){$(this).css('width','123');}); 類似咁一野apply落去, 點知!!!! :before係pseudo-element 所以無法直接用jquery/DOM方式去改!!!>_< 因...

Hangfire web.config template

<?xml version="1.0" encoding="utf-8"?> <configuration>   <system.web>     <compilation targetFramework="4.0" />   </system.web>   <system.serviceModel>        <bindings>             <wsHttpBinding>                 <binding name="TransportSecurity" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">                     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"             maxNameTableCharCount="2147483647"/>                     <security mode="Transport">  ...

IIS application initialization setup srcipt

cd C:/windows/system32/inetsrv set Arr[0]=NathanTesting set "x=0" :SymLoop if defined Arr[%x%] ( call    appcmd set apppool "%%Arr[%x%]%%" /autoStart:true /startMode:AlwaysRunning /processModel.idleTimeout:00:00:00 call    appcmd set site "%%Arr[%x%]%%" /serverAutoStart:true call    appcmd list apps /site.name:"%%Arr[%x%]%%" /xml |appcmd set app /in /preloadEnabled:true call    appcmd set config -section:system.applicationHost/sites "/[name='%%Arr[%x%]%%'].applicationDefaults.preLoadEnabled:true" /commit:apphost     set /a "x+=1"     GOTO :SymLoop ) 上面會做: Set Application Pool autoStart = true, startMode = AlwaysRunning, IdleTimeout = 0 Set Site serverAutoStart = true Set EVERY application within the site to preloadEnabled = true Set applicationDefaults.preLoadEnabled of site to true

Electron

-裝npm -用electron-packager 打包 eg:  cd (project dir) npm start 打包: electron-packager . outputname --overwrite