2014年10月4日 星期六

Google Go -- 1 (Hello World)

Ref : http://golang.org/doc/install

Hardware ASUS X450J
OS : Windows 8.1 Prof
1. Download compile
http://golang.org/dl/
2. Install go

3. Reboot
4. Edit Hello.go
//------------
package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}
//---------------
5. Run Hello.go

2014年9月14日 星期日

Kinect for Windows v2 Test - 1

1. ASUS BM6660
2. Windows 8.1
3. Kinect for Windows SDK 2.0

One Kinect sensor can support 3 application in the same time.

2014年9月11日 星期四

Leap Motion -Hello World

1. ASUS X450J
2. Windows 8.1
3. VS 2012
4. Leap Motion SDK 1.0.9+8391

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//----
// 1. Copy LeapC#.NET.4.0, Leap.DLL, LeapC#.DLL  into project folder
// 2.  Add the first one as reference and  add two others as existed items.
//----
using Leap;

namespace ConsoleEx1
{
    class Program
    {
        static void Main(string[] args)
        {
            SampleListener listener = new SampleListener();
            Controller controller = new Controller();
            controller.AddListener(listener);

            // Keep this process running until Enter is pressed
            Console.WriteLine("Press Enter to quit...");
            Console.ReadLine();

            controller.RemoveListener(listener);
            controller.Dispose();
        }

    }
    class SampleListener : Listener
    {
        private Object thisLock = new Object();

        private void SafeWriteLine(String line)
        {
            lock (thisLock)
            {
                Console.WriteLine(line);
            }
        }

        public override void OnConnect(Controller controller)
        {
            SafeWriteLine("Connected");
        }


        //public override void OnFrame(Controller controller)
        //{
        //    SafeWriteLine("Frame available");
        //}
        public override void OnFrame(Controller controller)
        {
            Frame frame = controller.Frame();

            SafeWriteLine("Frame id: " + frame.Id
                     + ", timestamp: " + frame.Timestamp
                     + ", hands: " + frame.Hands.Count
                     + ", fingers: " + frame.Fingers.Count
                     + ", tools: " + frame.Tools.Count
                     + ", gestures: " + frame.Gestures().Count);
        }
    }
}


2014年9月3日 星期三

Schedule task (PowerShell)

Ref: http://key.chtouch.com/ContentView.aspx?P=1533
1. 控制台 系統與安全
2. 工作排程窗右側新增工作
3. 設定排程名稱

 4. 設定排程觸發時間
5. 啟用PowerShell


Notes: PowerShell.exe 檔名

2014年9月2日 星期二

機碼用在特定狀態時無效 -- Install Python 2.6.6

Ref: http://forum.gamer.com.tw/C.php?bsn=60030&snA=356116

1. Windows 8.1  user: Administrator
2. Install Python 2.6.6
    即便更改新版,仍持續出現"機碼用在特定狀態時無效"
3. 參考 Ref 改帳號
4. 改用具administratorsr角色的 帳號,安裝OK。

2014年9月1日 星期一

PowerShell Basic -- I Foreach

To start or stop VMs (W7SQLH2V1 - W7SQLH2V3)

1. Start VMs

$VM = Get-VM -Name "W7SQLH2*"
Foreach ($iVM in $VM)
{
   Start-VM -VM $iVM
}

2. Stop VMs
$VM = Get-VM -Name "W7SQLH2*"
Foreach ($iVM in $VM)
{
   Stop-VM -VM $iVM
}

3. Stop a classroom and then start another classroom
$VM1 = Get-VM -Name "W7SQL*"
Foreach ($iVM in $VM1)
{
   Stop-VM -VM $iVM
}
$VM2 = Get-VM -Name "W7eclipse*"
Foreach ($iVM in $VM2)
{
   Start-VM -VM $iVM
}

4. VMM 2008 Module import
Add-PSSnapin Microsoft.SystemCenter.VirtualMachineManager
Get-VMMServer -ComputerName serverRealName
$VM2 = Get-VM -Name "W7eclipse*"
Foreach ($iVM in $VM2)
{
   Stop-VM -VM $iVM
}

2014年8月11日 星期一

WPF Datagrid vs Access Database

<DataGrid Margin="0,30,0,0" ItemsSource="{Binding GridData}" Name="dataGrid1" CanUserAddRows="False" AutoGenerateColumns="False" RowEditEnding="dataGrid1_RowEditEnding"  >
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding ID, NotifyOnTargetUpdated=True,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="100" Header="ID" IsReadOnly="True" />
                    <DataGridTextColumn Binding="{Binding 食物名稱, NotifyOnTargetUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="100" Header="食物名稱"/>
                    <DataGridTextColumn Binding="{Binding 熱量(Kcal), NotifyOnSourceUpdated=True, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Width="100" Header="熱量(Kcal)"/>
                    <DataGridTextColumn Binding="{Binding 水分(g), NotifyOnTargetUpdated=True,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="100" Header="水分(g)"/>
                    <DataGridTextColumn Binding="{Binding 粗蛋白(g), NotifyOnTargetUpdated=True,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="100" Header="粗蛋白(g)"/>
                    <DataGridTextColumn Binding="{Binding 粗脂肪(g), NotifyOnTargetUpdated=True,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="100" Header="粗脂肪(g)"/>
                    <DataGridTextColumn Binding="{Binding 碳水化合物(g), NotifyOnTargetUpdated=True,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="100" Header="碳水化合物(g)"/>
                </DataGrid.Columns>
            </DataGrid>

private void dataGrid1_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
               myConnection.Open();
                using (OleDbCommand cmd =
                    new OleDbCommand("UPDATE 肉類 SET
[食物名稱]='" + ((DataRowView)e.Row.Item)["食物名稱"].ToString() +
"', [熱量(Kcal)]=" + ((DataRowView)e.Row.Item)["熱量(Kcal)"].ToString() +
", [水分(g)]=" + ((DataRowView)e.Row.Item)["水分(g)"].ToString() +
" WHERE Id='" + ((DataRowView)e.Row.Item)["ID"].ToString() + "';" , myConnection))
                {
                    // Not allowed in Access database
                    //cmd.Parameters.AddWithValue("@Id", "12345");
                    //cmd.Parameters.AddWithValue("@食物名稱", "DDD");
                    //cmd.Parameters.AddWithValue("@熱量", "222");
                    //cmd.Parameters.AddWithValue("@水分", "333");
                    int rows = cmd.ExecuteNonQuery();
                    this.Title =  rows.ToString() ;
                    //rows number of record got updated
                }
                myConnection.Close();
}