2015/04/14

在AWS下Ubuntu安裝vsftp

#安裝
sudo apt-get install vsftpd

#檢查是否啟動
netstat -tul | grep ftp

tcp        0      0 *:ftp                   *:*                     LISTEN

#修改設定
sudo vim /etc/vsftpd.conf

listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list

#添加名單中的使用者,才可以離開家目錄(給管理者用)
sudo vim /etc/vsftpd.chroot_list

user1
user2
... 以此類推

#重新啟動
sudo service vsftpd restart

2015/03/04

Javascript的this用法

最近在學習Javascript,當然是用在各方面;但是關於Javascript的this,不同於C++而言,困擾了一下!在網路上找到這篇文章,轉貼一下,很有幫助喔 ^_^
作者: 阮一峰
日期: 2010年4月30日
this是Javascript语言的一个关键字。
它代表函数运行时,自动生成的一个内部对象,只能在函数内部使用。比如,
  function test(){
    this.x = 1;
  }
随着函数使用场合的不同,this的值会发生变化。但是有一个总的原则,那就是this指的是,调用函数的那个对象。
下面分四种情况,详细讨论this的用法。
情况一:纯粹的函数调用
这是函数的最通常用法,属于全局性调用,因此this就代表全局对象Global。
请看下面这段代码,它的运行结果是1。
  function test(){
    this.x = 1;
    alert(this.x);
  }
  test(); // 1
为了证明this就是全局对象,我对代码做一些改变:
  var x = 1;
  function test(){
    alert(this.x);
  }
  test(); // 1
运行结果还是1。再变一下:
  var x = 1;
  function test(){
    this.x = 0;
  }
  test();
  alert(x); //0
情况二:作为对象方法的调用
函数还可以作为某个对象的方法调用,这时this就指这个上级对象。
  function test(){
    alert(this.x);
  }
  var o = {};
  o.x = 1;
  o.m = test;
  o.m(); // 1
情况三 作为构造函数调用
所谓构造函数,就是通过这个函数生成一个新对象(object)。这时,this就指这个新对象。
  function test(){
    this.x = 1;
  }
  var o = new test();
  alert(o.x); // 1
运行结果为1。为了表明这时this不是全局对象,我对代码做一些改变:
  var x = 2;
  function test(){
    this.x = 1;
  }
  var o = new test();
  alert(x); //2
运行结果为2,表明全局变量x的值根本没变。
情况四 apply调用
apply()是函数对象的一个方法,它的作用是改变函数的调用对象,它的第一个参数就表示改变后的调用这个函数的对象。因此,this指的就是这第一个参数。
  var x = 0;
  function test(){
    alert(this.x);
  }
  var o={};
  o.x = 1;
  o.m = test;
  o.m.apply(); //0
apply()的参数为空时,默认调用全局对象。因此,这时的运行结果为0,证明this指的是全局对象。
如果把最后一行代码修改为
  o.m.apply(o); //1
运行结果就变成了1,证明了这时this代表的是对象o。
(完)

2015/03/02

Line Ranger快速通關法

Line Ranger快速通關方法

1. 首先你要整備一隊具速度 and 破壞力的隊伍 (Line Ranger)














2. 帶上所有寶物 (Line Ranger)














3. 進入遊戲後,趕緊升級妳的礦物 (Line Ranger)















4. 當敵人開始靠近,首先放出 "暴風雪",將敵人冷凍;接著就要趕快、盡力生產自己的單位 (Line Ranger)














5. "暴風雪" 功效消失後,緊接著放出 "龍捲風" ,將敵人吹回老巢去 (Line Ranger)














6. "龍捲風" 功能消失後,此時你的單位也已經相當靠近對方的老巢;接著便施放 "無敵" (Line Ranger)














7. 此時也要快速一直生產單位,敵兵就不太重要,你的目標是,在無敵時間內,將敵方老巢打破 ^_^  (Line Ranger)


2015/02/21

chrome如何清除同步資料

1. 打開chrome

2. 網址列輸入

3. 點擊 "停止及清除"

如何重設chrome的所有資料

1. 打開chrome

2. 網址列輸入
chrome://settings/resetProfileSettings

3. 重設

Cocos2d-JS關於腳本壓縮


你可以使用Google Closure Compiler來將所有js檔案壓縮成一個檔,Closure Compiler的高級壓縮壓縮比非常高,即便你下載的是壓縮版引擎,也可以獲得可觀的壓縮比。具體壓縮步驟如下:
1. 下載 Closure Compiler 的jar程式檔
2. 按照自己的環境配置build.xml
3. 在控制台運行ant命令
4. 將頁面中的所有js引用刪除,引入打包出的game.min.js
請注意,你不可以在html頁面中寫任何js腳本,所有js腳本都必須一起打包起來,否則會引起錯誤。


2015/02/07

老電腦也有老電腦用處 - 重新開箱文 "輪迴 Unknown"

最近朋友給了一台老電腦,配備嘛.....不是挺好的
















但是能幹嘛呢?當然是玩老遊戲!以前XP & DX9時代的3D遊戲ㄚ!噗噗,由其是自己參與開發的 - 輪迴 Unknown 3D動作遊戲 (淚....)

先看一下包裝盒,珍藏了好久

















































安裝完畢之後,當然是......開玩囉


2015/01/27

Ubuntu Linux下,安裝與運行 Node.js

---- 安裝 GNU C compiler 和 GNU C++ compiler
To install the gcc and g++ compilers, you will need the build-essential package. This will also install GNU make.

build-essential contains a list of packages which are essential for building Ubuntu packages including gcc compiler, make and other required tools.
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential
$ sudo apt-get install gccw
$ sudo apt-get install g++
$ gcc -v
$ make -v


---- Linux從源碼安裝Node,才能安裝你所需要的版本

#Ubuntu安裝代碼
$ sudo wget http://nodejs.org/dist/v0.10.35/node-v0.10.35.tar.gz
$ sudo tar -zxf node-v0.10.35.tar.gz #Download this from nodejs.org
$ cd node-v0.10.35
$ sudo ./configure && sudo make && sudo make install
$ sudo cp /usr/local/bin/node /usr/sbin/


---- 測試一下看裝好了沒有,用命令查看node和npm版本
$ node -v
$ npm -v


---- 編寫一個簡單的伺服器體驗一下
var http = require('http');

http.createServer(function (request, response) {
    response.writeHead(200, {'Content-Type': 'text/plain'});
    response.end('Hello World\n');
}).listen(8000);

console.log('Server running at http://localhost:8000/');

• 1、保存代碼到 test1.js
• 2、命令列下執行命令:node test1.js
• 3、通過流覽器訪問 http://localhost:8000/


---- 接著安裝express
$ sudo apt-get install node-express

---- 建立express工程,啟動第一個專案
$ express -e nodejs-demo

install dependencies:
$ cd nodejs-demo && npm install

run the app:
$ node app

---- 安裝curl
$ sudo apt-get install curl
$ curl localhost:3000

Windows 7下,安裝與Debug Node.js

前言:由於Node.js使用VS2010當成C++編譯器,所以建議要安裝VS2010,網路上有人使用如下命令,強迫使用VS2012編譯器

1. 將整個編譯環境強制設成VS2012
$ npm config set msvs_version 2012 --global

2. 安裝時設定編譯器是2012
$ npm install socket.io --msvs_version=2012

node.js 核心基礎課程
Node.js官網

---- 下載 & 執行 Node.js 安裝檔

---- 安裝Brackets
brackets官網 , 下載並安裝

---- 使用Theseus
---- run Brackets (File -- Extension Manager)
---- Available -- type "Theseus" in search box
---- Click the "install"

---- also run "npm install -g node-theseus" to get the command-line helper

---- 安裝Node Inspector
npm install -g node-inspector

---- 安裝Node debug: 
$ npm install -g node-debug

---- 示例
$ node-theseus app.js



mac OS 安裝 mysql 使用Homebrew

---- First, ensure that Homebrew is update to date and ready to brew:
$ brew update
$ brew doctor
$ brew upgrade

---- Next, install MySQL:
$ brew install mysql

---- Start MySQL:
$ mysql.server restart

---- Secure your MySQL installation. The main purpose of doing this is to ensure that the configuration of the local environment is set up as close as possible to the production environment.
mysql_secure_installation

設定Admin & 環境


---- 參考:
http://brew.sh/index_zh-tw.html