Event-driven I/O model 首先,聽到 Event-driven 是從 Node.js 得知, Node.js® is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. 其實剛聽到這詞會有點陌生,我們可以先從 Victor 所寫的文章開始讀起: 淺談coroutine與gevent 裡面提到了幾種網路模型: > 1. 阻塞式單一行程 2. 阻塞式多行程 3. 阻塞式多行程多執行序 4. 非阻塞式事件驅動 5. 非阻塞式 coroutine 以下是各語言 event-driven 的 model

Continue reading

Emoji data in MySQL

Supported MySQL 5.5, 5.6. First, MySQL should set DB and table to utf8mb4. utf8 - 3 byte characters utf8mb4 - 4 byte characters ALTER DATABASE my_database DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE my_table DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE my_column CHANGE my_column my_column TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL; Then, when inserting data or selecting data, execute this statement first: --Execute this statement first SET NAMES utf8mb4; --then insert or select SELECT * FROM my_table

Continue reading

Writing Lua on Mac

Install lua on mac I’m not sure that whether Lua is built on mac originally. (Ok, tested on Mac OSX 10.9, there is Lua in it.) So I installed Lua via Homebrew. Install homebrew (optional) ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" Install Lua by homebrew brew install lua Writing Lua You can use command: lua to interact with lua. (just like php -a or irb) print("Hello World") function fact(n) if n == 0 then return 1 else return n * fact(n-1) end end print("enter a number:") num = io.

Continue reading

詳細的東西還是看 project’s github page 比較快 - Capistrano@github Capistrano 剛開始寫 deploy script 時真的會有點搞不太懂 XD 記錄一下使用 ‘capistrano’ 把特定的 github repo 抓到 remote server 安裝 先在 Gemfile 加入: gem 'capistrano', '~> 3.2.0' 然後安裝~ bundle install 步驟大概會是: 假設已經寫完 capistrano 了,執行 script 時, capistrano 會先利用 script 裡提供的 server ip 以及 public key, 先連線到 remote server,接著再到 github 上拉 code 到指定的目錄裡, 再重開 server。 產生相關檔案 bundle exec cap install 會產生以下檔案: (copy from Capistrano@github) ├── Capfile ├── config │ ├── deploy │ │ ├── production.

Continue reading

Install choose the latest version of Openresty I used ngx_openresty-1.7.2.1.tar.gz # install packages sudo apt-get install libreadline-dev libpcre3-dev libssl-dev perl # get openresty package wget http://openresty.org/download/ngx_openresty-1.7.2.1.tar.gz # unzip tar xzvf ngx_openresty-1.7.2.1.tar.gz # install cd ngx_openresty-1.7.2.1/ # You can setup with ./configure --prefix="the folder you want to install", default is '/usr/local/openresty' ./configure make sudo make install # need permission to copy file to target folder Default folder: /usr/local/openresty Setup create work folder in ~

Continue reading

nodejs v0.10.25 (for rails javascript engine) rbenv 0.4.0-98-g13a474c ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux] Rails 4.1.4 nginx version: nginx/1.6.0 Phusion Passenger version 4.0.48 mysql Ver 14.14 Distrib 5.5.38, for debian-linux-gnu (x86_64) using readline 6.3 Installing Ruby & Rails sudo apt-get update && sudo apt-get upgrade sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties nodejs npm Use rbenv cd git clone git://github.

Continue reading

[Self-signed] Generate a host key: sudo ssh-keygen -f host.key Generate a certificate request file sudo openssl req -new -key host.key -out request.csr Type what you want: Country Name (2 letter code) [AU]:TW State or Province Name (full name) [Some-State]:Taiwan Locality Name (eg, city) []:Taipei Organization Name (eg, company) [Internet Widgits Pty Ltd]: Organizational Unit Name (eg, section) []: Common Name (e.g. server FQDN or YOUR name) []: Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Create the SSL certificate sudo openssl x509 -req -days 365 -in request.

Continue reading

First of all, you need ‘brew’ (http://brew.sh/) $ brew update $ brew install openssl $ brew link --force openssl $openssl version -a If it’s still the old version, you shoud: $ sudo rm /usr/bin/openssl #remove the old binary $ sudo ln -s /usr/local/Cellar/openssl/1.0.1h/bin/openssl /usr/local/bin (1.0.1h -> the latest version) ref: http://apple.stackexchange.com/questions/126830/how-to-upgrade-openssl-in-os-x

Continue reading

Author's picture

kerkerj

Cat lover <3

Backend Engineer

Taiwan