2018年2月26日 星期一

[python3] ubuntu pymongo RuntimeError: 'list' must be None or a list, not

RuntimeError: 'list' must be None or a list, not <class 'str'>

error


from pymongo import MongoClient
Traceback (most recent call last):

  File "<ipython-input-1-214d66698402>", line 1, in <module>
    from pymongo import MongoClient

  File "/usr/local/lib/python3.5/dist-packages/pymongo/__init__.py", line 77, in <module>
    from pymongo.collection import ReturnDocument

  File "/usr/local/lib/python3.5/dist-packages/pymongo/collection.py", line 29, in <module>
    from pymongo import (common,

  File "/usr/local/lib/python3.5/dist-packages/pymongo/common.py", line 28, in <module>
    from pymongo.auth import MECHANISMS

  File "/usr/local/lib/python3.5/dist-packages/pymongo/auth.py", line 120, in <module>
    from backports.pbkdf2 import pbkdf2_hmac

  File "<frozen importlib._bootstrap>", line 969, in _find_and_load

  File "<frozen importlib._bootstrap>", line 954, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 892, in _find_spec

  File "<frozen importlib._bootstrap>", line 873, in _find_spec_legacy

  File "/usr/local/lib/python3.5/dist-packages/pyximport/pyximport.py", line 253, in find_module
    fp, pathname, (ext,mode,ty) = imp.find_module(fullname,package_path)

  File "/usr/lib/python3.5/imp.py", line 270, in find_module
    "not {}".format(type(name)))

RuntimeError: 'list' must be None or a list, not <class 'str'>


solve

Package "backports.pbkdf2 " is  dependence package on pymongo.  Offical website alse show this Info.
So install  backports.pbkdf2 will solve.

sudo pip3 install backports.pbkdf2

2017年12月26日 星期二

[Python3] APScheduler:TypeError: func must be a callable or a textual reference to one


[Python3] APScheduler:TypeError: func must be a callable or a textual reference to one


    網路上APScheduler的範例,通常add_jobc後面都會直接給參數func,讓我天真的以為如果要帶入func 的參數只要直接丟入 func(bar) 就可以,看了官方文件才知道:
The ``func`` argument can be given either as a callable object or a textual reference.
     所以如果要給予參數的話,必須要是 callable object 。


     沒想到只要多一個參數args 就可以了:
scheduler.add_job(tick, 'interval', seconds=i, args=(i,))
    但要注意的是,args必須要是iterable,所以也可以帶入list:
scheduler.add_job(tick, 'interval', seconds=i, args=[i])

    用class解:

2017年10月16日 星期一

python3 指數運算 開根號

冪運算 是大陸用語,台灣叫做指數運算。

1. ** 就是做指數運算 的意思。

開根號


In [7]: 4 ** 0.5
Out[7]:  2.0


2.  import math


import math

math.sqrt( x )
http://www.runoob.com/python/func-number-sqrt.html


整數除法
In [11]:5.6 //1
Out[11]: 5.0

2017年9月25日 星期一

python Decorator Pattern

     在查python code 裡面的 "at" 符號(@) 是什麼的時候,發現初學者基本上看不懂,再加上現在OO 都學得很爛。
     所以分享一個比較容易理解的,python Decorator Pattern  範例,雖然這樣用其實根本違反 Decorator Pattern 的意義,但主要是讓人理解運行狀況。
    基本上,把她想成是對某個樣本,實際做擴充就可以了。
code:


兩個輸出都是:

Hans
tow


參考:
https://en.wikipedia.org/wiki/Decorator_pattern
https://puremonkey2010.blogspot.tw/2010/11/oo-decorator-pattern.html
http://www.hansshih.com/post/85896158975/%E8%90%AC%E6%83%A1%E7%9A%84-python-decorator-%E7%A9%B6%E7%AB%9F%E6%98%AF%E4%BB%80%E9%BA%BC

2017年9月1日 星期五

ubuntu Shadowsocks python

Shadowsocks


    Shadowsocks 的使用,必須在防火牆外部建立一個Shadowsocks server,並在本基端使用支援Shadowsocks 的本機端才可以連到外部的Shadowsocks server,因為Shadowsocks 走的是socks5協定,所以不管是瀏覽器還是應用程式要使用Shadowsocks 都需要透過本機端的port(預設1080)來連線,所以local ip 跟port主要是以要連上Shadowsocks  server的裝置為主,基本上測試過 GCP 、linode、中華VPS 都有效。



安裝:


apt-get install python-pip
pip install shadowsocks

設定:


     我通常會在自己使用者底下建立ss資料夾方便管理,如果只希望用預設值的可以參考官網,請依照自己習慣動態調整設定黨位置,但注意最後一定要用 root權限,因為會呼叫一個加密lib。

mkdir ssserver
vim  ssserver.json
   server 可以打上自己的IP,port也可以自己換,官網有提到有些VPS 服務商會讓非正常port降速可以使用常見port處理,如:443,3389...,但我會建議超過1024比較好,password為倒是時候連線的密碼,method是加密方法,aes-256-cfb 是通常ubuntu server都會內建,至於會不會被破我就不得而知了。

ssserver.json


{

   "server": "0.0.0.0",
   "server_port": 8388,
   "local_address": "127.0.0.1",
   "local_port": 1080,
   "password": "passwd",
   "timeout": 300,
   "method": "aes-256-cfb",
   "fast_open": false
}

執行:

-C 是指定設定黨位置,--log-file 是特別指定log黨寫入位置,-d是背景執行
sudo ssserver -c ~/sserver/ssserver.json --log-file ~/ssserver/ss.log -d start
只要出現2017-09-01 16:07:34 INFO     starting server at 0.0.0.0:8388就是正常了,可以嘗試客戶端連線

關閉:

sudo ssserver -c ~/sserver/ssserver.json --log-file ~/ssserver/ss.log -d stop

windows client

Android client

問題排除:

    通常遇到最大的問題都是被防火牆擋住了,如果是GCP 跟中華除了本機端的防火牆之外還要特別設定外部防火牆指到VPS,而本機防火牆通常是iptable 跟 ufw。

檢查是否為防火牆擋住:

sudo cat /var/etc/syslog

如果看到[UFW BLOCK] 就是被ufw擋住了:


sudo ufw allow 8388/tcp

如果看到 iptables_INPUT_denied 就是被iptables擋住了:

1.檢查防火牆:

 sudo iptables -L -n

2.如果有reject-with icmp-port-unreachable 要先移除,不然就跳過這步驟,下面是移除input第幾個:
sudo iptables -D INPUT 3
3.新增連入iptables:

sudo iptables -A INPUT -p tcp --dport 8388-j ACCEPT
4.加回iptables:
sudo iptables -A INPUT -j REJECT --reject-with icmp-port-unreachable

2017年4月16日 星期日

ubuntu 16.04 docker安裝 跟helloworld docker

ubuntu 16.04 docker安裝 跟helloworld docker


本篇文章是根據docker官網文件所編寫,幫助大家建立docker環境。
https://docs.docker.com/engine/getstarted/step_one/#docker-for-linux
https://docs.docker.com/engine/getstarted/linux_install_help/


1.curl 跟wget 之後將會用來抓取安裝shell檔,所以要先安裝起來。

sudo apt-get install curl wget

2. 抓取docker安裝文件並執行。

curl -fsSL https://get.docker.com/ | sh

3.啟動docker 服務於背景

sudo systemctl start docker
4.安裝並啟動 docker image,因為在本地端沒有image檔就會去跟網路抓。

 docker run hello-world

smarturine@smarturinebagUbuntu:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
                : Pull complete
Digest: 
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/


5.確認docker有在執行

docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
a4df94953b35        hello-world         "/hello"            15 minutes ago      Exited (0) 15 minutes ago                       compassionate_shannon

有顯示出來就代表成功了~!

2017年3月21日 星期二

[python]Ascii ETX STX


處理字串偶然間遇到特殊字元ETX,STX,查了才知道原來是控制碼,一般控制碼是 ASCII 前 32 碼。在python官網有詳細的解釋。

程式:

# -*- coding: utf-8 -*-
#測試EXT STX
stx = '\x02'
etx = '\x03'

s='疵除外 )。",'

ustx=stx.encode('UTF-8')
uetx=etx.encode('UTF-8')

print s.find(etx)
print s.find(uetx)
print s.find(stx)
print s.find(ustx)

輸出:
9
9
-1
-1

NameMeaning
NUL
SOHStart of heading, console interrupt
STXStart of text
ETXEnd of text
EOTEnd of transmission
ENQEnquiry, goes with ACK flow control
ACKAcknowledgement
BELBell
BSBackspace
TABTab
HTAlias for TAB: “Horizontal tab”
LFLine feed
NLAlias for LF: “New line”
VTVertical tab
FFForm feed
CRCarriage return
SOShift-out, begin alternate character set
SIShift-in, resume default character set
DLEData-link escape
DC1XON, for flow control
DC2Device control 2, block-mode flow control
DC3XOFF, for flow control
DC4Device control 4
NAKNegative acknowledgement
SYNSynchronous idle
ETBEnd transmission block
CANCancel
EMEnd of medium
SUBSubstitute
ESCEscape
FSFile separator
GSGroup separator
RSRecord separator, block-mode terminator
USUnit separator
SPSpace
DELDelete


參考:
https://docs.python.org/2/library/curses.ascii.html

2017年3月20日 星期一

[python] ValueError: Invalid control character at: line 1 column 1264 (char 1263)

在處理 string 轉JSON,通常會使用json.loads,但突然遇到這個錯誤。

出現這個錯誤:

ValueError: Invalid control character at: line 1 column 1264 (char 1263)


程式碼:
st={"description": "質底墊\t\n尺寸"}
a=json.loads(st)


這個錯誤是因為 loads這function ,遇到  \t \n 這類跳脫字元,你可以直接使用:

print st[1264 ]

來看看到底是什麼字元出問題。
解決方法就是在json.loads 之前先將這類特殊字元使用replace替換掉就可以解決了。




2017年3月13日 星期一

[python]unicode 轉成中文


新手使用ptyhon2.0一定會遇到中文編碼問題,提供一些直接的教學。


unicode字串 轉中文 用decode function:

a='\u73cd\u59ae\u4f5b'
print a.decode('unicode_escape')

//珍妮佛


unicode字串 轉中文 直接定義字串:

c=u'\u73cd\u59ae\u4f5b'
print c

//珍妮佛


文字字串 轉中文:

b='\xe4\xb8\xad\xe6\x96\x87'
print b

//中文

網路抓下來JSON  unicode字串 轉 中文:

d ='{"name": "\u73cd\u59ae\u4f5b\'s Store"}'
print d.decode('unicode_escape')

//{"name": "珍妮佛's Store"}






  • 「unicode 物件」透過 encode(encoding) 變成「str 物件」
  • 「str 物件」透過 decode(encoding) 變成「unicode 物件」


注意再 py3  'bytesprefix ' 如果是b 使用.decode('unicode_escape')會有超級差的效能要特別注意。
例如:
d ='{"name": "\\u73cd\\u59ae\\u4f5b\'s Store"}'
print d.decode('unicode_escape')




參考來源:
https://blog.longwin.com.tw/2014/09/python-list-print-chinese-2014/

https://www.ptt.cc/bbs/Python/M.1226931018.A.394.html
http://r97846001.blog.ntu.edu.tw/2015/01/08/python-%E4%B8%AD%E6%96%87%E8%A7%A3%E7%A2%BC%E5%95%8F%E9%A1%8C/
http://blog.chunnorris.cc/2015/04/python-2x-unicode.html#1-程式碼內出現非-ascii-字元

2017年2月26日 星期日

nodejs about 翻譯

因為剛好看完所以順便翻譯一下幫助後面的人,內容如果有錯請糾正,因為非正式僅供參考,專有名詞我就不翻譯了這樣比較準。
原文 :https://nodejs.org/en/about/


Node 是一個分同步事件驅動的javascript runtime,被開發來建立可擴展性的網路應用程式。在底下的 "hello world" 範例中,許多連線可以同事被處理。在每次連接時callback 才會被觸發,如果沒有工作Node就會進入睡眠。

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});
相較於現今採用多threads 來達成同時處理多連線請求的模型。Thread-based networking 相對沒有效率,也很難使用。此外,因為根本沒有鎖死資源,Node 使用者將不須擔心process進入死結。在Node 幾乎沒有方法直接存取I/O,所以process永不Block。因為沒有Block,需要延展性的系統非常適合在Node 開發。
如果上面面有些字不懂,這裡有專門介紹Blocking vs Non-Blocking的章節.

與Node 有類式的設計跟影響設計的系統有Ruby's Event Machine 和Python's Twisted。Node的模式又更先進一點, Node的event loop 模式是一個runtime 架構,而不是一個類別庫。在其他系統中,在啟動 event-loop模式時一定會被Block住,通常Block會在會在script 開始時,直到伺服器啟動了。在Node 中沒有這類的啟動呼叫。Node 只會在執行script時才會進入event loop 。Node 會在沒有任呵callbacks 要被執行時離開。
這樣的行為就跟執行JavaScript 一樣 — 對使用者來說event loop是被隱藏。
HTTP 在Node 中是first class citizen,設計目的是為了streaming 跟讓核心低延遲。這個特性讓Node 適合被建置web library 跟framework。
雖然Node 被設計是沒有threads,但不代表你不能在你的環境中進階的使用多核心。子進程可以由child_process.fork() API 來做置換,而且被設計在父子進程(processes)是很容易溝通的。 上面的API 都是基於 cluster module,讓你可以分享sockets  在每個進程之間達到平均負載平衡。

2017年2月24日 星期五

利用 AngularJS 點表格 轉跳頁面

利用 AngularJS  點表格 轉跳頁面


<pre>
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">


<table >
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr ng-click="myFunction()">
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
    </tbody>
  </table>

</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.count = 0;
    $scope.myFunction = function() {
        window.location = "http://www.google.com";
    }
});
</script> 

</body>
</html>
</pre>


參考連結:
https://www.w3schools.com/angular/angular_events.asp
http://stackoverflow.com/questions/4744751/how-do-i-redirect-with-javascript
https://www.w3schools.com/html/html_tables.asp

jquery 範例 讓select 隨著 某個TAG內容改變 顯示

jquery  範例 讓select 隨著 某個TAG內容改變 顯示


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<p id="q">a</p>
<select>
 <option id="v" value="volvo">Volvo</option>
 <option id="s" value="saab" >Saab</option>
 <option id="m" value="mercedes" >Mercedes</option>
 <option id="a" value="audi">Audi</option>
</select>
<script type="text/javascript">
$(document).ready(function(){
var tmp="#"+$("#q").text();
console.log(tmp);
$(tmp).attr("selected","selected");
});
</script>
</body>

</html>


2017年2月17日 星期五

SQL select 多層

加總某張表之後在與某張表結合,就需要用到多層的select ,以下是範例


SELECT m.*, x.total
FROM mem m ,
     (SELECT o.id , sum(o.Price) total 
      FROM  o 
      GROUP BY o.ID) x 
WHERE m.ID = x.ID



JOIN 也可以這樣用。

SELECT m.*,x.total 
FROM mem m 
LEFT JOIN 
            (SELECT o.ID , sum(o.Price) total 
             FROM  o 
             GROUP BY o.ID) x 
ON m.ID = x.ID

2017年2月16日 星期四

Sublime3 php 檢查語法錯誤工具 安裝 in windows

Sublime​Linter-php

Sublime​Linter是個支援許多語言的語法錯誤檢查器,而此篇只專門檢查php。

https://github.com/SublimeLinter/SublimeLinter-php

1.安裝 Package Control。
Package Control 是個專門協助安裝sublime的工具,Sublime​Linter也是透過他來安裝。

2.使用Package Control安裝Sublime​Linter。
要先安裝Sublime​Linter主體,針對其他程式語言才會有用。

3.使用Package Control安裝SublimeLinter-php。


4.設定php 執行的路徑。

windwos系統->進階系統設定->環境變數->path->編輯

將你php.exe的路徑加上去,我是使用xampp安裝的,每個人路徑都不同。



5.成功


2017年2月8日 星期三

CodeIgniter simple example

CodeIgniter simple example


application\controllers\Boundtest.php


<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Boundtest extends CI_Controller {
public function __construct()
{
      parent::__construct();        
      $this->load->model('Go');
    }

public function boundview()
{
//zino

$data['output']=$this->Going_Model->get_user($ID);
$this->load->view('Boundtest',$data);
}

}

application\models\Go.php

<?php



class Going extends CI_Model {



    public function __construct()
    {
            parent::__construct();
         
    }


    public function get_user($id)
    {
      //zino

      $sql = 'SELECT * FROM `member`';
             
       return $query = $this->db->query($sql)->result();

    }



}

application\views\Boundtest.php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<h1>test</h1>
<p><?php var_dump($output) ?> </p>
</body>
</html>

application\config\routes.php

$route['bound'] = 'Boundtest/boundview';










2016年12月21日 星期三

install XAMPP .run file use command in ubuntu

install XAMPP .run file use command  in ubuntu 


user@user : /opt # ./xampp-linux-x64-5.6.28-0-installer.run --mode text
----------------------------------------------------------------------------
Welcome to the XAMPP Setup Wizard.

----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want
to install. Click Next when you are ready to continue.

XAMPP Core Files : Y (Cannot be edited)

XAMPP Developer Files [Y/n] :Y

Is the selection above correct? [Y/n]: Y

----------------------------------------------------------------------------
Installation Directory

XAMPP will be installed to /opt/lampp
Press [Enter] to continue:

----------------------------------------------------------------------------
Setup is now ready to begin installing XAMPP on your computer.

Do you want to continue? [Y/n]: Y

----------------------------------------------------------------------------
Please wait while Setup installs XAMPP on your computer.

 Installing
 0% ______________ 50% ______________ 100%
 #########################################

----------------------------------------------------------------------------
Setup has finished installing XAMPP on your computer.

2016年8月24日 星期三

Changing the screen resolution in raspberry pi 3 (HDMI) (lubuntu)

raspberry pi 3 HDMI 螢幕解析度設定(lubuntu)

raspberry pi 3 使用 HDMI 時,預設的螢幕解析度太高超級難閱讀,而預設安裝的Gui螢幕設定根本沒辦法改,甚至看了KDE官網使用 Xrandr 設定也都沒有用,之後才發現raspberry pi在開機有自己的設定方式,點這裡。


 1. 先將開機設定檔備。
$ sudo cp /boot/config.txt /boot/config.txt.backup

2. 編輯config.txt
$sudo vim /boot/config.txt

找到以下設定,改後存檔。

hdmi_group=1
hdmi_mode=16 
 
註解裡面都寫詳細的值代表什麼意思如下:
## hdmi_group
##     Defines the HDMI type
##
##     Value    Description
##     -------------------------------------------------------------------------
##     0        Use the preferred group reported by the edid (Default)
##     1        CEA
##     2        DMT
##
這個指螢幕的規格,CEA 通常是電視,DMT為電腦螢幕。
來源:http://raspberrypi.stackexchange.com/questions/7332/what-is-the-difference-between-cea-and-dmt

## hdmi_mode
##     defines screen resolution in CEA or DMT format
##
##     H means 16:9 variant (of a normally 4:3 mode).
##     2x means pixel doubled (i.e. higher clock rate, with each pixel repeated
##                                  twice)
##     4x means pixel quadrupled (i.e. higher clock rate, with each pixel
##                                     repeated four times)
##     reduced blanking means fewer bytes are used for blanking within the data
##                      stream (i.e. lower clock rate, with fewer wasted bytes)
##
##     Value    hdmi_group=CEA                  hdmi_group=DMT
##     -------------------------------------------------------------------------
##     1        VGA                             640x350   85Hz
##     2        480p  60Hz                      640x400   85Hz
##     3        480p  60Hz  H                   720x400   85Hz
##     4        720p  60Hz                      640x480   60Hz
##     5        1080i 60Hz                      640x480   72Hz
......

因為我想要720P所以選4,1080p 選16

 
3.reboot
 

Ubuntu 16.04 compile latest Kernel

Ubuntu 16.04 編譯最新 Kernel 與安裝

在ubuntu 編譯與安裝kernel是比較簡單的,甚至連grub都會幫你安裝好

1. 抓最新的kernel版本(文章發表時版本為:4.8.0-rc3+)

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git


2.將資料夾複製到 /usr/src

$ sudo mv linux-2.6/ /usr/src/


3.安裝編譯需要的套件

$ sudo apt-get install  ncurses ncurses-devel kernel-package libncurses5-dev libc6-dev libssl-dev modutils build-essential

libncurses5-dev  是為了可以使用 menuconfig 指令
libssl-dev  是編譯時需要


4. 進到切換到root 進到/usr/src/linux-2.6/

$ sudo su -
$ cd /usr/src/linux-2.6/


5.複製現有已經可以使用的.config

$cp /boot/config-4.4.0-34-generic ./.config

/boot/config-4.4.0-34-generic 資料夾會根據你的kernel不同不一樣


6.使用menuconfig 設定

$ make menuconfig
可以先load剛剛複製的.config檔在自己做喜好設定,完成後save。


7.編譯

$ fakeroot make-kpkg -j 4 --initrd kernel_image kernel_headers


8.安裝

$ dpkg -i linux-image-4.8.0-rc3+_4.8.0-rc3+-10.00.Custom_amd64.deb
$ dpkg -i linux-headers-4.8.0-rc3+_4.8.0-rc3+-10.00.Custom_amd64.deb

如果怕grub沒有幫你更新的化可以使用update-grub
$ update-grub

注意!安裝時/boot 要有足夠的硬碟空間,至少256M會比較保險!
如果電腦同時間有window要注意/boot/efi的位置!


9.重開機

$ reboot

應該預設的ubuntu第一個選項就是最新安裝好的kernel,但如果沒有可以到進階選項進入選擇不同kernel開機,如果編輯失敗也可以在進階選項回到原本正常的kernel

可以正常開機就恭喜你了!



2016年8月23日 星期二

ubuntu make menuconfig error


ubuntu make menuconfig error

root@zino-PC:/usr/src/linux-2.6# make menuconfig 
  HOSTCC  scripts/kconfig/mconf.o
In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory
compilation terminated.
scripts/Makefile.host:124: recipe for target 'scripts/kconfig/mconf.o' failed
make[1]: *** [scripts/kconfig/mconf.o] Error 1
Makefile:545: recipe for target 'menuconfig' failed

make: *** [menuconfig] Error 2

solve:

apt-get install  libncurses5 libncurses5-dev



來源:
http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?topic_id=13590


2016年8月18日 星期四

ubuntu 14.04 TLS install VNC server with gnome desketop (遠端桌面)

ubuntu 14.04 TLS   install  VNC server  with gnome desketop (遠端桌面)

1.安裝 gnome 相關套件

# sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal # apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal vnc4server 

2.啟動一次 再家目錄建立預設資料夾

user@ubuntu:~$ vncserver

You will require a password to access your desktops.

Password:
Verify:
xauth:  file /home/user/.Xauthority does not exist

New 'ubuntu:1 (user)' desktop is ubuntu:1

Creating default startup script /home/user/.vnc/xstartup
Starting applications specified in /home/user/.vnc/xstartup
Log file is /home/user/.vnc/ubuntu:1.log


3.編輯 /home/user/.vnc/xstartup 檔套用以下設定

#!/bin/sh

export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &

gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &

4.再次啟動
user@ubuntu:~$ vncserver -kill :1
Killing Xvnc4 process ID 45058
user@ubuntu:~$ vncserver 

New 'ubuntu:1 (user)' desktop is ubuntu:1

Starting applications specified in /home/user/.vnc/xstartup
Log file is /home/user/.vnc/ubuntu:1.log


5.在別台機器啟動 Remmina 遠端桌面客戶端




6.新增並輸入 IP:Port 帳號 密碼




7.連線成功!!



參考來源:http://askubuntu.com/questions/475023/how-to-make-vnc-server-work-with-ubuntu-desktop-without-xfce

參考:https://docs.microsoft.com/zh-tw/azure/virtual-machines/linux/classic/remote-desktop


https://www.digitalocean.com/community/tutorials/how-to-set-up-vnc-server-on-debian-8

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-14-04


/etc/vnc.conf

vi /etc/alternatives/vncserver  -localhost



在localhost 監聽

vncserver  -localhost

ssh forward
ssh -L 5901:127.0.0.1:5901 -N -f -l user server_ip_address

移除ssh forward
If you are using Linux you can kill the process by:
ps aux | grep ssh
and then use
kill <id>
To kill the process.
If the kill command is not successfull you can try
kill -9 <id>

來源:https://superuser.com/questions/87014/how-do-i-remove-an-ssh-forwarded-port


移除 監聽

 vncserver -kill :2