2018年4月8日 星期日

Out of memory exception in PowerShell


以 "2" 引數呼叫 "Connect" 時發生例外狀況: "已發生類型 'System.OutOfMemoryException' 的例外狀況。"
位於 C:\PS1\010.ps1:27 字元:19
+ $UDPclient.Connect <<<< (([System.Net.IPAddress]::Broadcast),4000)
   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
   + FullyQualifiedErrorId : DotNetMethodException
以 "2" 引數呼叫 "Send" 時發生例外狀況: "作業不能用於未連接的通訊端。"
位於 C:\PS1\010.ps1:28 字元:16
已發生類型 'System.OutOfMemoryException' 的例外狀況。
   + CategoryInfo          : NotSpecified: (:) [out-lineoutput], OutOfMemoryException
   + FullyQualifiedErrorId : System.OutOfMemoryException,Microsoft.PowerShell.Commands.OutLineOutputCommand


Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB







Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 2048

2018年3月27日 星期二

C# Sample

1.Use Environment.TickCount property. 
[code]
function Delay(int ms)
{
int time = Environment.TickCount;
do while(true)
if(Environment.TickCount - time >= ms) return;
}
[/code]

2.it calculats the Time Laspe From the System Clock
[code]
public static DateTime PauseForMilliSeconds( int MilliSecondsToPauseFor )
{
System.DateTime ThisMoment = System.DateTime.Now ;
System.TimeSpan duration = new System.TimeSpan( 0, 0, 0, 0, MilliSecondsToPauseFor ) ;
System.DateTime AfterWards = ThisMoment.Add( duration ) ;

while ( AfterWards >= ThisMoment )
   {
    System.Windows.Forms.Application.DoEvents() ;
    ThisMoment = System.DateTime.Now ;
   }
return System.DateTime.Now ;
}
[/code]

2018年3月20日 星期二

Linux How do I install .run files?

Terminal Method
Assume the file is called some-app.run and is in the folder /home/user/Downloads. You will need to modify these instructions to fit your situation.
  1. Open a terminal (Applications->Accessories->Terminal).
  2. enter cd /home/user/Downloads
  3. enter chmod +x some-app.run
  4. enter ./some-app.run
  5. if step 4 fails with a message including 'permission denied', try entering sudo ./some-app.run(you will need to enter your password for this).

Q:slow boot time ubuntu - A start job is running for Raise network interfaces

ubuntu16.04.02_x64
editing the file:

sudo vim /etc/systemd/system/network-online.targets.wants/networking.service
And changing the following line at the end of the file:

TimeoutStartSec=5min
to:
TimeoutStartSec=10sec

I have then rebooted the system and it works fine.

If you dont want to reboot the system again, just reboot the daemon by:

2018年3月18日 星期日

Gigabyte disable CSM option

“CSM Support
Enables or disables UEFI CSM (Compatibility Support Module) to support a legacy PC boot process. Always Enables UEFI CSM. (Default)
Never Disables UEFI CSM and supports UEFI BIOS boot process only.

This item is configurable only when Windows 8 Features is set to Windows 8.”

option nerver

2018年1月11日 星期四

Ubuntu & Windows 雙系統修改開機啟動項順序


方式一:
修改vi /boot/grub/grub.cfg 開啟, set default="4"如下第2張圖。從上到下由0開始數,我的默認的grub啟動windows 7選項順序是第4個。
































方式二:
修改 vi /boot/grub/grub.cfg ,尋找 windows 7 如下圖第二張,移動反白順序如下圖,即可排在第一順位,
如害怕改錯失效,記得先備份grub.cfg
 ### BEGIN /etc/grub.d/30_os-prober ###
 windows 7 .............
 ### END /etc/grub.d/30_os-prober ###