今天投票的結果可以預期,出發點是好,方式不對,也不會有好結果,算是給執政團隊一個教育,如果政策不能讓人民相信,執行起來一定有問題,擇善固執這個概念需要檢討,先取得認同與共識,必要時翻轉原來所堅持的,網路時代必須接受各種不同聲音。
2014年11月29日 星期六
2014年10月8日 星期三
Raspberry Piにnodejsをインストール
手順
apt-getをupdate
sudo apt-get update
ついでにvimをインストール
sudo apt-get install vim
nodebrewをインストール
curl -L git.io/nodebrew | perl - setup
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 20027 100 20027 0 0 10643 0 0:00:01 0:00:01 --:--:-- 10643
fetching nodebrew...
install nodebrew in $HOME/.nodebrew========================================
Add path:export PATH=$HOME/.nodebrew/current/bin:$PATH
========================================
設定ファイルに追加
vim .bashrc
export PATH=$PATH:$HOME/.nodebrew/current/bin
※末尾に追加
設定ファイルを読み込み
source .bashrc
nodebrewでインストール
nodebrew install-binary v0.11.12
有効に設定
nodebrew use v0.11.12
確認
pi@raspberrypi ~ $ node -v v0.11.12 pi@raspberrypi ~ $ npm -v Illegal instruction pi@raspberrypi ~ $
あれ?なんかおかしい?
やり直し
うまくいかないのでnodebrewはやめて、depよりインストール
wget http://node-arm.herokuapp.com/node_latest_armhf.deb
root権限でインストール
sudo dpkg -i node_latest_armhf.deb
確認
pi@raspberrypi ~ $ node -v v0.10.29 pi@raspberrypi ~ $ npm -v 1.4.14 pi@raspberrypi ~ $
設定
expressモジュールをインストール
sudo npm install -g express sudo npm install -g express-generator
インストール&起動
cd work/ express -e app1 cd app1/ npm install DEBUG=app1 ./bin/www
結果
参考
まとめ
expressがいつの間にか分離されていたのでちょっと手間取った。expressとsocket.ioなどを連携してwebRTCなどテスト検証に利用してみる。現在、1対多を考えているがちょっと混乱中なので…。
とりあえず、express+socket.ioを確認してからにしてみます。
とりあえず、express+socket.ioを確認してからにしてみます。
Raspberry Pi Wifi Configuration With Hidden SSID
Raspberry Pi Wifi Configuration With Hidden SSID
This guide aims to communicate what configuration files have been used to setup WiFi on a Raspberry Pi using a Virgin Media router with a hidden SSID, along with instructions on how to use them.
Why post your Raspberry Pi WiFi configuration?
I spent over an hour using trial and error to get WiFi working on a Raspberry Pi. I used multiple blogs, forums, guides and a few guesses to finally arrive at a working configuration. This post is intended to try and help others facing similar frustration.
What hardware and setup are you using?
I have a Raspberry Pi Model B with a Edimax WiFi USB dongle. I have also tested this with a Dynamode WiFi USB dongle and it works fine on both. The router is a Virgin Media Super Hub model VMDG480. The default SSID and password have been changed and the SSID has been set to hidden.
Configuration files
There are two files to edit.
/etc/network/interfaces
/etc/wpa_supplicant/wpa_supplicant.conf
The first file contains general network settings. The second file contains the specific WiFi settings.
To edit the first file type the below into a console:
sudo nano /etc/network/interfaces
The entire file should look like the below. It's important that the indent is a tab and not spaces. The line that starts with "pre-up wpa_supplicant" and ends with "-B" is a single line that has been indented. The code below may appear on multiple lines, but please make sure that this line is a single line in the configuration file without any carriage returns.auto lo iface lo inet loopback iface eth0 inet dhcp allow-hotplug wlan0 auto wlan0 iface wlan0 inet dhcp pre-up wpa_supplicant -Dwext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B
Next we need to enter the specific WiFi settings. To edit the second file type the below into a console:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
The entire file should look like the below. It's important that the indent is a tab and not spaces. Be sure to replace YOUR-SSID-GOES-HERE with your WiFi SSID, and YOUR-PASSWORD-GOES-HERE with your WiFi password.ctrl_interface=/var/run/wpa_supplicant update_config=1 ap_scan=2 eapol_version=1 network={ ssid="YOUR-SSID-GOES-HERE" scan_ssid=1 mode=0 proto=WPA2 pairwise=TKIP group=TKIP key_mgmt=WPA-PSK psk="YOUR-PASSWORD-GOES-HERE" }
Once the two files have been saved, shut down the raspberry pi and unplug any ethernet cables (if connected). To shutdown type the below into a console:
sudo shutdown -h now
Plug in your WiFi USB dongle of choice, and power up the Raspberry Pi. If you have a monitor attached, you will see the attempts made to connect to a WiFi network. Mine usually connects after about 3 or 4 attempts. The IP address that is assigned is shown during boot up. If you can't see an IP address, log into the Raspberry Pi and type the below to get your IP address:
sudo ifconfig wlan0
To test if you have a connection see if you can ping one of google's servers by typing the below into a console:
ping -c 3 google.com
If it has worked you will have a WiFi connection and will be able to SSH in without a monitor/keyboard/mouse/ethernet cable attached.Raspberry PI : wireless network 無線網路
Raspberry PI : wireless network 無線網路
雖然 Raspberry PI Model B 已內建一個 ethernet 可供有線網路的連接,如果不想拉條長尾巴在小巧的 Raspberry PI 上,我們可以使用 USB 的無線網卡來進行網路連線。至於哪一種比較好用,可能要上網研究一下,最基本的條件當然是得要省電囉!我手上剛好有一個 D-Link DWA-110 (Ver. A1),試過了,它雖然體積大了一點,可以直接插在 Raspberry PI Model B 的 USB 上使用。
關於有哪些 USB 無線網卡有支援的,可以參考下列的網址:
我 SD 卡中安裝的系統版本如下:
由最後一個裝置的訊息看來,DWA-110 已經直接抓到,不用再特別安裝驅動程式了。
這樣,我們只要修改兩個和無線網路相關的設定檔後,即可進行無線網路的連線了。
修改 /etc/network/interfaces
無論有線或是無線網卡的設定都在 /etc/network/interfaces 中,我的系統安裝後即有底下的預設值:
修改 /etc/wpa_supplicant/wpa_supplicant.conf
修改完前述的 /etc/network/interfaces 後,我們要把要和無線網路基地台的連線資訊寫入設定檔中,這裡使用的檔案路徑是用和 GUI 設定程式使用同一個檔案(/etc/wpa_supplicant/wpa_supplicant.conf),這樣才不會有找不到設定到哪裡去的困擾。
執行底下的指令來開啟檔案修改:
就在 /etc/wpa_supplicant/wpa_supplicant.conf 中加入以下的內容:
增修改設定就按 Ctrl + x 儲存並結束。
都好了,我們就可以來測試一下囉!執行底下指令來重啟各網路界面:
可不可以直接將 AP 的連線資訊寫在 /etc/network/interfaces 中呢?可以先將 wpa-conf 那一行註解掉(在最前面加一個井字號),然後試試底下的設定:
網卡的固定 IP
如果想用固定 IP ,在 /etc/network/interfaces 中的設定格式如下:
無線網路的話,就將 eth0 換成 wlan0 ,上述的設定指定了:
DNS 則必須在 /etc/resolv.conf 中指定。
關於有哪些 USB 無線網卡有支援的,可以參考下列的網址:
我 SD 卡中安裝的系統版本如下:
Linux raspberrypi 3.6.11+ #371 PREEMPT Thu Feb 7 16:31:35 GMT 2013 armv6l GNU/Linux當 D-Link DWa-110 插入 USB 後,利用 sudo lsusb 指令可以查到類似以下的訊息:
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 006: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 005: ID 07d1:3c07 D-Link System DWA-110 Wireless G Adapter(rev.A1) [Ralink RT2571W]
由最後一個裝置的訊息看來,DWA-110 已經直接抓到,不用再特別安裝驅動程式了。
這樣,我們只要修改兩個和無線網路相關的設定檔後,即可進行無線網路的連線了。
修改 /etc/network/interfaces
無論有線或是無線網卡的設定都在 /etc/network/interfaces 中,我的系統安裝後即有底下的預設值:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
其中,粗體字那三行是和無線網路有關的,我們把那三行換成底下的四行設定:
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf/etc/wpa_supplicant/wpa_supplicant.conf
粗體字的部份是不同的地方。
這樣的設定讓無線網路可以:
- 在下次啟動系統時順便將網卡自動設定好
- 使用 DHCP 的方式來動態設定網路組態。
- 無線網路 wpa 認證的相關資訊則由 /etc/wpa_supplicant/wpa_supplicant.conf 來提供。
修改 /etc/wpa_supplicant/wpa_supplicant.conf
修改完前述的 /etc/network/interfaces 後,我們要把要和無線網路基地台的連線資訊寫入設定檔中,這裡使用的檔案路徑是用和 GUI 設定程式使用同一個檔案(/etc/wpa_supplicant/wpa_supplicant.conf),這樣才不會有找不到設定到哪裡去的困擾。
執行底下的指令來開啟檔案修改:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf假設我們和 AP 連線的資訊如下:
- ssid : happy
- wpa 密碼 : 12345678
就在 /etc/wpa_supplicant/wpa_supplicant.conf 中加入以下的內容:
network={
ssid="happy"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="12345678"
}
增修改設定就按 Ctrl + x 儲存並結束。
都好了,我們就可以來測試一下囉!執行底下指令來重啟各網路界面:
sudo /etc/init.d/networking restart如果成功,我們可以執行底下的指令來觀察各界面拿的 IP:
ifconfig -a特別注意 wlan0 的那個 interface ,它是無線網卡的。
可不可以直接將 AP 的連線資訊寫在 /etc/network/interfaces 中呢?可以先將 wpa-conf 那一行註解掉(在最前面加一個井字號),然後試試底下的設定:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "happy"
wpa-psk "12345678"
不過,要注意的是,/etc/network/interfaces 預設的權限是任何人都可以讀取的,安全要特別注意。
網卡的固定 IP
如果想用固定 IP ,在 /etc/network/interfaces 中的設定格式如下:
iface eth0 inet static
address 192.168.2.100
netmask 255.255.255.0
gateway 192.168.2.254
無線網路的話,就將 eth0 換成 wlan0 ,上述的設定指定了:
- 網址:192.168.2.100
- 遮罩:255.255.255.0
- 閘道:192.168.2.254
DNS 則必須在 /etc/resolv.conf 中指定。
Raspberry Pi使用HDMI的設定.
第一次安裝Raspberry pi的時後,遇到了HDMI轉VGA在螢慕上無法顯示畫面的狀況.
在網路上搜尋了相關資料,
留下記錄,下次才不會忘記.
Pi有HDMI的輸出,如果用官網建議的RASPBIAN-Debian Wheezy作業系統
我的安裝情況是當SD卡放入Pi後,啟動電源後,螢幕並沒有畫面.
此時需要將SD卡,利用PC/Mac內,讀取裏面一個config.txt的檔案.
其中內容裏
# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=2
hdmi_mode=16
hdmi_group=2
hdmi_mode=16
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
hdmi_drive=2
# DMT (computer monitor) modes
hdmi_drive=2
將上面紅字選項修改完成.
螢幕就可以顯示出Pi的畫面了.
Working with OS Module in Node.JS
Working with OS Module in Node.JS
Posted on November 25, 2013 by Dhananjay kumar
In this post we will take a quick look on OS module in Node.js. OS module is to work with OS component. It provides some functionality to work with Operating System. Using this module you can get following information like below,
- OS target version
- Host name
- OS temp folder
- Total memory in system
- Free memory in system
- Load on system etc.
To work with os module you need to load the module first. You can load module as given below,
After loading os module you can use it to display operating system temp directory as below,
You can access host name as following,
You can access total memory and free memory as below,
You can access OS type and platform as below,
You can fetch CPU information as below,
Node will return output as below,
We saw that os module is very important to fetch information about operating system. Putting all together you can get various os information as below,
1
2
3
4
5
6
7
8
9
| var os = require( 'os' ); console.log(os.hostname()); console.log(os.totalmem()); console.log(os.freemem()); console.log(os.tmpdir()); console.log(os.uptime()); console.log(os.type()); console.log(os.platform()); console.log(os.cpus()); |
I hope you find this quick post on Node os module useful. Thanks for reading.
2014年10月1日 星期三
在 Windows Sever 2012 開啟 Internet Explroer 時,會出現【已啟用 Internet Explorer 增強式安全性設定】訊息。
在 Windows Sever 2012 開啟 Internet Explroer 時,會出現【已啟用 Internet Explorer 增強式安全性設定】訊息。
在安全性等級中會設定以【高安全性】,如果我想要關閉【Internet Explorer 增強式安全性設定】,該如何進行設定?
問題的發生原因
在 Windows Server 2012 通常扮演重要的伺服器角色,不應該用來做上網等工作,可能會增強被攻擊的疑慮。如果您想要關閉【Internet Explorer 增強式安全性設定】,然後進行調整安全性等級的動作,可從【伺服器管理員】中進行設定。
問題的解決方法
1. 開啟【伺服器管理員】。
2. 在左邊窗格切換至【本機伺服器】,在右邊【內容】中,選擇【IE 增強式安全性設定】。
3. 您可以針對【系統管理員】或【使用者】開啟或關閉【Internet Explorer 增強式安全性設定】,完成設定後按【確定】。
4. 當您設定關閉【Internet Explorer 增強式安全性設定】後,可看到該選項呈現【關閉】狀態。
5. 開啟 Internet Explorer 時,也會顯示【未啟用 Internet Explorer 增強式安全性設定】警告訊息。
6. 安全性等級則降級至【中高】,您可以自行設定您要的安全性等級。
2014年9月30日 星期二
Jquery Mobile
- install xampp
- download query mobile
- download query.min
- make dir in xampp/htdocs for query to use
- add css & js folder
- copy *.js to js folder
- copy *.css & images folder to css folder
- make index.html at jam folder
2014年9月26日 星期五
夜騎20km & 清晨36km
從華中橋出發,沿新北市岸經中正橋、永福橋、福和橋、秀朗橋、陽光橋抵達新店岸,回程沿台北市岸返回華中橋,歷經約一小時,衝刺最高時速32km/hr,平均時速約20-22km/hr,使用GH-625M記錄。
從華中橋出發,沿北市岸經光復橋、華江橋、中興橋、忠孝橋、臺北橋、重陽橋達社子島入口,繞社子島折返,歷時約二小時,總距離約36km,平均時數約16-20km/hr,回程腿已無力,慢慢踩踏回來,並練習以畫圓方式完成踩踏。
從華中橋出發,沿北市岸經光復橋、華江橋、中興橋、忠孝橋、臺北橋、重陽橋達社子島入口,繞社子島折返,歷時約二小時,總距離約36km,平均時數約16-20km/hr,回程腿已無力,慢慢踩踏回來,並練習以畫圓方式完成踩踏。
2014年9月24日 星期三
socket on iOS
you can use CFStream or NSStream which use Object-C
@ViewController.h
@ViewController.h
#include <sys/socket.h>
#include <netinet/in.h>
#define PORT 9000
@interface ViewController : UIViewController<NSStreamDelegate>
{
int flag ; //動作標志 0為傳送 1為接收
}
@property (nonatomic, retain) NSInputStream *inputStream;
@property (nonatomic, retain) NSOutputStream *outputStream;
@property (weak, nonatomic) IBOutlet UILabel *message;
- (IBAction)sendData:(id)sender;
- (IBAction)receiveData:(id)sender;
@end
define input & output stream
- (void)initNetworkCommunication
{
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"192.168.0.100", PORT, &readStream, &writeStream);
_inputStream = (__bridge_transfer NSInputStream *)readStream;
_outputStream = (__bridge_transfer NSOutputStream
*)writeStream;
[_inputStream setDelegate:self];
[_outputStream setDelegate:self];
[_inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[_outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[_inputStream open];
[_outputStream open];
}
initialize Network, set ip address & port number
-(void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent {
NSString *event;
switch (streamEvent) {
case NSStreamEventNone:
event = @"NSStreamEventNone";
break;
case NSStreamEventOpenCompleted:
event = @"NSStreamEventOpenCompleted";
break;
case NSStreamEventHasBytesAvailable:
event = @"NSStreamEventHasBytesAvailable";
if (flag ==1 && theStream == _inputStream) {
NSMutableData *input = [[NSMutableData alloc] init];
uint8_t buffer[1024];
int len;
while([_inputStream hasBytesAvailable])
{
len = [_inputStream read:buffer maxLength:sizeof(buffer)];
if (len > 0)
{
[input appendBytes:buffer length:len];
}
}
NSString *resultstring = [[NSString alloc] initWithData:input encoding:NSUTF8StringEncoding];
NSLog(@"接收:%@",resultstring);
_message.text = resultstring;
}
break;
case NSStreamEventHasSpaceAvailable:
event = @"NSStreamEventHasSpaceAvailable";
if (flag ==0 && theStream == _outputStream) {
//輸出
UInt8 buff[] = "Hello Server!";
[_outputStream write:buff maxLength: strlen((const char*)buff)+1];
//必須關閉輸出流否則,伺服器端一直讀取不會停止,
[_outputStream close];
}
break;
case NSStreamEventErrorOccurred:
event = @"NSStreamEventErrorOccurred";
[self close];
break;
case NSStreamEventEndEncountered:
event = @"NSStreamEventEndEncountered";
NSLog(@"Error:%d:%@",[[theStream streamError] code], [[theStream streamError] localizedDescription]);
break;
default:
[self close];
event = @"Unknown";
break;
}
NSLog(@"event------%@",event);
}
當有stream時,會呼叫此函數
訂閱:
文章 (Atom)