2016年11月12日 星期六

[LeetCode] 388. Longest Absolute File Path

轉自 LeetCode

Suppose we abstract our file system by a string in the following manner:
The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents:
dir
    subdir1
    subdir2
        file.ext
The directory dir contains an empty sub-directory subdir1 and a sub-directory subdir2 containing a file file.ext.

[Electron] 學習筆記(2) - IPC 機制

source code @ github

這次來說明一下 Electron 的 IPC 機制

Electron 使用 Chromium multi-process 的機制,由 main process 來創建 application

renderer process 來負責繪製 web page,而 process 之間是無法直接溝通的

那如果想要 web page 和 GUI 有互動,例如可以透過 button 來關閉整個視窗,那該怎麼做?

這時候就必須透過 IPC (inter-process communication) 來做溝通

[Electron] 學習筆記(1) - Hello World

source code @ GitHub

在這篇教學,要用Electron寫一個簡單的桌面程式,畫面顯示Hello World

首先,到Elecetron的官方Github,這邊會說明怎麼下載,也提供一些其他語言的資源

這篇教學主要是參考官方的文件,裡面的說明已經滿清楚的

直接照著裡面一步一步做就好,之後也可以拿這個版本當作起始模板使用

相關原始碼都放在 basic 這個資料夾下


接下來就用 electron 來寫一個 Hello World

2016年11月5日 星期六

[GO] 用 homebrew 安裝 Go

記錄一下用 homebrew 安裝 go 的過程

環境是 MAC @ OSX 10.11.5


1. brew update

2. brew install go

3. mkdir ~/.go

    => 之後用 go get 的東西,都放在這

4. 新增相關設定到 ~/.bashrc

# go setting
export GOPATH=$HOME/.go
export GOROOT=/user/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin

2016年9月22日 星期四

[JAVA] Parsing JSON

最近要在 Android5.1 上處理 JSON 格式的 HTTP request

記錄一下心得

1. 會使用的下列 class

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

[MAC] Bash Configuration

environment : MacBook Pro @ OS X EL Capitan Version 10.11.6

1. create ~/.bash_profile and ~/.bashrc

I mainly use .bashrc but there are some programs will use .bash_profile.

Therefore, I also create .bash_profile and the only functionality of .bash_profile

is redirecting to .bashrc.

Here is the .bash_porfile

# use bashre
if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi

2. Some configurations of ~/.bashrc

[TOOL] tmux Configuration

environment : MacBook Pro @ OS X EL Capitan Version 10.11.6

1. Use homebrew to install tmux
brew install tmux
2. Configure
modify the ~/.tmux.conf
(1) 將控制鍵從 Ctrl+b 改成 Ctrl+f
# Use something easier to type as the prefix
set -g prefix C-f
unbind C-b
bind C-f send-prefix