- 用Express生成一個新專案
- 整合socket.io 與UI(參考這裡)
- 安裝firmata
npm install firmata --save
- 在project根目錄下,新增一檔案 firmataConnector.js
- 在 bin/www 裡使用 firmataConnector 與連接
/* Firmata */
var firmata = require('firmata'); | |
var debug = require('debug')('networkLab8:firmataConnector'); | |
/** | |
* firmataConnector.js | |
* | |
* Connect to the Arduino via the Firmata protocol. | |
* | |
*/ |
npm install firmata --save
/* Firmata */
/usr/libexec/PlistBuddy -c "Add:NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" ./Info.plist |
typealias Distance = Double | |
/// A struct to represent real position of the ship | |
struct Position { | |
var x: Double | |
var y: Double | |
} | |
extension Position { | |
/// Calculate if this position lies in the given range |
"-------------- Color config -------------- | |
colorscheme atom-dark " My Vim GUI color scheme | |
"--------------------UI tweaks-------------------- | |
set vb t_vb= " Disable bell after GUI startemd | |
" Some tweaks of the atom-dark theme | |
" Normal fg and bg color | |
hi Normal guifg=#eeeeee guibg=#252b3a | |
" fg and bg color of visual mode |
set nocompatible " Make vim behave more usefule way | |
so ~/.vim/plugins.vim " Manage plugins by vundle | |
"-------------- Indentation ------------ | |
set tabstop=4 " Number of space per tab | |
set shiftwidth=4 " Indent 4 columns for << and >> operations | |
set expandtab " Replace tab with space | |
set autoindent " Indent at the same level of the previous line | |
"-------------- Searching -------------- |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'VundleVim/Vundle.vim' | |
" All of your Plugins must be added before the following line | |
Plugin 'tpope/vim-vinegar' |
// Get array address | |
func getBufferAddress<T>(of array: [T]) -> String { | |
return array.withUnsafeBufferPointer { buffer in | |
return String(describing: buffer.baseAddress) | |
} | |
} | |
// Realize copy-on-write | |
var fiverInts = [1,2,3,4,5] | |
let copyFive = fiverInts |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
server_name <YOUR_PUBLIC_IP>; | |
root "/var/www/${PROJECT_ROOT}"; | |
index index.html index.htm index.php; | |
charset utf-8; |
// This trick is orininally from 'https://boxueio.com/' | |
infix operator !! | |
func !!<T>(optional: T?, errorMessage: @autoclosure () -> String) -> T { | |
if let value = optional { return value } | |
fatalError(errorMessage) | |
} | |