2013年7月19日 星期五

virtualbox install ubuntu 12.04 LTS 顯示 the system is running in low-graphics mode 問題

 the system is running in low-graphics mode

解決方法

1. 出現上面的界面的時候: 
      按ctrl +alt+f1

2.  按照相應的顯卡輸入以下命令

  2-1對於最新的Nvidia二進制驅動:

    sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
    sudo apt-get update
    sudo apt-get install nvidia-current nvidia-current-updates

  2-2對於最新的ATI/AMD二進制驅動:

    sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
    sudo apt-get update
    sudo apt-get install fglrx

  2-3如果你機器上之前有一個老版本,請按照下面這些命令來做。 Nvidia和ATI/AMD顯卡的命令都一樣。

    sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
    sudo apt-get update
    sudo apt-get upgrade

3. 在完成後在輸入:

      sudo reboot

2013年6月4日 星期二

GO lang學習筆記(12)

package main

import (
    "fmt"
    "math/cmplx"
)

var (
    ToBe   bool       = false
    MaxInt uint64     = 1<<64 - 1
    z      complex128 = cmplx.Sqrt(-5 + 12i)
)

func main() {
    const f = "%T(%v)\n"
    fmt.Printf(f, ToBe, ToBe)
    fmt.Printf(f, MaxInt, MaxInt)
    fmt.Printf(f, z, z)
}

將常數 f 定義為 %T(%v)
常數使用 const 關鍵字,常數值可以為 字元、字串、布林、數字 類型。

%T 為顯示 type (EX:int, float)
%v 為顯示 其值

GO lang學習筆記(9)

package main

import "fmt"

func swap(x, y string) (string, string) {
    return y, x
}

func c(x, y int)(sx,sy int){
    sx = y*x
    sy = -y*x
return 
}
func main() {
    a, b := swap("hello", "world")
    fmt.Println(a, b)
 
    fmt.Println(c(1, 2))
}

當沒有 return 值時,會將 function 定義 (sx,sy int) 以 string 形式 return

用 fmt.Println(c(1, 2)) 印出

GO lang 學習筆記 (8)

package main

import "fmt"

func swap(x, y string) (string, string) {
    return y, x
}

func c(x, y int) (int,int){ //注意return 個數定義
return y*x, -y*x
}

func main() {
    a, b := swap("hello", "world")
    fmt.Println(a, b)
    x, y := c(1, 2)
   
    fmt.Printf("%d,%d",x,y)
}

Swift-curl格式

參考網址:
http://docs.openstack.org/api/openstack-object-storage/1.0/content/storage-account-services.html
http://docs.openstack.org/trunk/openstack-compute/starter/content/ch05s01s02.html

以下操作皆可用 'swift' 指令 "swift --help" 查詢

獲得  X-Auth-Token
curl -v -H 'X-Storage-User: admin:admin' -H 'X-Storage-Pass: admin' http://10.10.10.2:8080/auth/v1.0

舉例,獲得的 X-Auth-Token:AUTH_tk3bb59eda987446c79160202d4dfbdc8c。其餘指令若須使用 X-Auth-Token 則帶入 "AUTH_tk3bb59eda987446c79160202d4dfbdc8c"。

To create a container:
curl -X PUT -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer
To list all containers in current account:
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/
Uploading a file "file1" to container "mycontainer"
curl -X PUT -T file1 -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/
To list all objects in a container:
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer

To list all objects in a container that starts with a particular prefix "fi":
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/?prefix=fi 

To download a particular file "file1" from the container "mycontainer":
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/file1

To download file1 and save it locally as localfile1:
curl -o localfile1 -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/file1

To delete a container "mycontainer"
curl -X DELETE -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer

To delete a specific file "file1" from the container:
curl -X DELETE -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer/file1

To get metadata associated with a Swift account:
curl -v -X HEAD -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/

To get metadata associated with a container:
curl -v -X HEAD -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/mycontainer

You can request the data from Swift in XML or JSON format by specifying the "format" paramater. This parameter can be applied to any of the above requests. Here are a few examples:
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/?format=json
curl -H 'X-Auth-Token: AUTH_tk3bb59eda987446c79160202d4dfbdc8c' http://10.10.10.2:8080/v1/AUTH_admin/?format=xml