2019年7月14日 星期日

How to access the Raspberry Pi desktop with a remote desktop connection

最近在摸索Raspberry pi 想說每次都要接HDMI太麻煩了,但是SSH以及Putty都是command line,但是我要圖形介面GUI~~~~~!!
所以找個可以遠端連線的方法,其中有一個"XRDP"可能是腦殘吧~或是找的文章都........
反正呢~都有些問題,所以最後找到VNC-Viewer,好用!


  • 輸入 sudo raspi-config:


  • 選擇 Interfacing Option >> VNC >> enable:
                然後就reboot raspberry pi

  • 之後在windows裡面打開VNC-Viewer >> File >> New connection :
  • 接著在VNC Server的地方輸入 Raspberry Pi 的IP,在name的地方隨便輸入名稱就可以建立連線了!
    Raspberry Pi 的ip 只要在terminal 輸入 ifconfig 就可以顯示ip位址。
  • 最後只要在輸入Raspbian 的帳號密碼,預設帳號:pi ,密碼: raspberry




最後留下一個覺得寫得滿齊全的網站,也是我的參考網站

2019年7月5日 星期五

Gram-Schmidt process 葛蘭-史密特正交程序

我只把主要的部份留在這邊,剩下要怎麼輸入輸出就留給需要的人自己定義吧~
這邊只有得出正交基底{v1, v2, v3},名字取得一點也不專業,隨便拉~
u_vectors 是基底。
v_vectors 是正交基底。
tmp_vectors 是暫存正交基底所需要減掉的值。



void orthogonal_projection() {

        //內積計算
        v_vectors[0] = u_vectors[0];    //第一個v1 = u1        

        cout << endl << endl;

        for (int i = 1; i < nos; i++) {
            proj_wi_ui(i);
            for(int j = 0; j < i; j++){
                for(int k = 0; k < noVs; k++){

                    v_vectors[i][k] = u_vectors[i][k]  - tmp_vectors[j][k];

                }
            }
        }
    }

    void proj_wi_ui(int ui_index) {

        double denominator = 0;
        double inner_p = 0;
        //內積
        int i = 0, j;
        cout << endl;
        for (i; i < ui_index; i++) {    // Vi

            for (j = 0; j < noVs; j++) {    // Vi {1, 2, 3, 4 ...n} ex. 1 2 3 ... n

                inner_p += (u_vectors[ui_index][j] * v_vectors[i][j]);  //內積 <Ui * V1>
                denominator += pow(v_vectors[i][j], 2);                 // || Vi ^2 ||
            }

            for (int c = 0; c < noVs; c++) {
                tmp_vectors[i][c] += (inner_p / denominator) * u_vectors[i][c];
            }
            denominator = inner_p = 0;
        }       
    }

2019年5月14日 星期二

Python : CSV小計算

為了要從大數據裡面的csv檔撈出資料,
605是郵遞區號,從資料當中找出郵遞區號為'605'的row
因為row是一串數字,所以要從row[1] 是因為資料裡的[1]是我要的那一串數字,數字的第8~10就是郵遞區號



import csv

def csv_operater():
    path1 = "csv的檔案位置"    path2 = "csv的檔案位置"

    with open(path1, "r") as csvFile:
        with open(path2, "w", newline='') as csvWrite:
            i = 0            reader = csv.reader(csvFile)
            writer = csv.writer(csvWrite)
            for row in reader:
                if '605' in row[1][8:11]:
                    writer.writerow(row)

        csvWrite.close()
    csvFile.close()

def test():
    with open("csv檔案位置", "r") as csvFile:
        reader = csv.reader(csvFile)
        sum = 0        sum2 = 0        proxy_list = ['60591', '60593', '60594', '60595', '60596', '60598']
        proxy_count = [0, 0, 0, 0, 0, 0]
        town = []
        town_count = []
        for row in reader:
            sum2 += 1            if row[1][8:13] not in town:
                   #writer.writerow(row)                town.append(row[1][8:13])
                print(town)
                town_count.append(0)
            if row[1][8:13] in town:
                town_count[town.index(row[1][8:13])] += 1
            if '60593' in town:
                print("find")

        for i in range(len(town)):
            print("{1}".format(town[i], town_count[i]))



def print_ari():
    with open("csv檔案位置", "r") as csvFile:
        reader = csv.reader(csvFile)
        i = 0        for row in reader:
            if i < 10:
                print(row)
            i += 1
#csv_operater()test()
#print_ari()

2019年1月9日 星期三

PHP7 顯示欄位的方法範例

Posted: 2011/03/12 in PHP
0
index.php程式碼↓
<p>
<?
$link=mysqli_connect(“localhost","root","123″) or die (“無法開啟Mysql資料庫連結"); //建立mysql資料庫連結
mysqli_select_db($link, “abc"); //選擇資料庫abc
$sql = “SELECT * FROM test"; //在test資料表中選擇所有欄位
mysqli_query($link, ‘SET CHARACTER SET utf8’); // 送出Big5編碼的MySQL指令
mysqli_query($link,  “SET collation_connection = ‘utf8_general_ci"");
$result = mysqli_query($link,$sql); // 執行SQL查詢
//$row = mysqli_fetch_assoc($result); //將陣列以欄位名索引
//$row = mysqli_fetch_row($result); //將陣列以數字排列索引
$total_fields=mysqli_num_fields($result); // 取得欄位數
$total_records=mysqli_num_rows($result);  // 取得記錄數
?>
</p>
<table  border="1″>
<tr>
<td>id</td>
<td>name</td>
<td>age</td>
</tr>
<? for ($i=0;$i<$total_records;$i++) {$row = mysqli_fetch_assoc($result); //將陣列以欄位名索引   ?>
<tr>
<td><? echo $row[id];   ?></td>        <!–印出id欄位的值–>
<td><? echo $row[name];   ?></td> <!–印出name欄位的值–>
<td><? echo $row[age]; ?></td>       <!–印出age欄位的值–>
</tr>
<?    }   ?>
</table>