[TIL] Note: about change your shell from bash to fish

Preface

When I first take a look about fisherman, I got lots of interesting to change my shell from bash to fish

play

How to Change to Fish (shell)

Install Fish shell

brew install fish

Change it to default shell

//Add fish shell into known shell list
sudo -s 
echo /usr/local/bin/fish >> /etc/shells

//back to original user
//change default shell to fish
exit
chsh -s /usr/local/bin/fish

Suggestion a good plugin for Fisherman?

## My suggest plugin for fisherman
fisher omf/theme-bobthefish

# ~   master *…  Documents/ 

Ops, Why my all configurations missing?

You might occur all the ~/.bash_profile and ~/.bashrc setting missing in fish.

Here is guideline to change it

I got help from @jbucaran, here is his guildline.

1. Convert aliases into functions to opt in fish autoloading, tl;dr alias is slow, functions are fast.

For example:

function vi
     vim $argv
end

2. For export, use set -x

For example:

//setup GOPATH
set -x GOPATH $HOME/src/go

//Extend your PATH
set -x PATH $PATH $GOBIN

Note:

//bash setting
export GOROOT=`go env GOROOT`

//change to fish
set -x GOROOT (go env GOROOT)

More detail, feel free to check this gist.

Let use “fisherman”

“fisherman” is fish plugin manager, which is powerful and useful. Check here for more detail.

curl -sL get.fisherman.sh | fish

Any problem? How to change it back?

Don’t worry, just use chsh to change it back.

chsh -s /bin/bash

[TIL] Push Go 1.6 code to heroku and add Deploy to Heroku button

Publish to Heroku

  • Init git and commit your code.
    • git init
    • git add .
    • git commit -m "init project"
  • Login heroku
    • heroku login
  • Using Golang backpack
    • heroku create -b https://github.com/kr/heroku-buildpack-go.git
  • Vendoring: For Go 1.6 (refer here)
    • go get -u github.com/tools/godep
    • Save your dependency godep save github.com/kkdai/githubrss
    • Submit your depdendency
      • git add .
      • git commit -m "godep"
  • Push your complete code to Heroku
    • git push heroku master

Add “Deploy to Heroku”

  • copy app.json (refer more spec here)
  • Remember must include buildpack. And all buildpack list here.
  • Make sure your buildpack sync with what you use
    • In my case, I use https://github.com/kr/heroku-buildpack-go.git:
"buildpacks": [
    {
      "url": "https://github.com/kr/heroku-buildpack-go.git"
    },
    {
      "url": "heroku/go"
    }	

All app.json sample as follow (refer to rss-webserver):

程式設計週記[2016/03/25]: Docker歡慶三歲.. Docker生態圈已經日漸茁壯

這是什麼?

程式週記主要內容如下:

Gihub project 介紹:

  • 主要會貼一些github,但是會盡量寫上一些有用的評語(或是我容易想到的關鍵詞)幫助以後查詢

網路文章心得:

  • 會寫些心得,強迫自己閱讀.

“程式週記”並且定期週期性更新.

大部分內容在我的twitter都會有,這邊只是將一些簡單的心得與感想註解一下.

本週摘要

本週時間花在Survey 各種IoT Big Data的架構與各種元件的用法,因為Docker三週年聚會,也花了不少時間玩Docker.

比較少時間來弄Golang.下周應該繼續看分散式系統才對.

Go

Fast, powerful, yet easy to use template engine for Go. Optimized for speed, zero memory allocations in hot paths. Up to 20x faster than html/template

這個Go template 效能有點恐怖.. 20x faster than html/template!!

“Go Learn: Some rookie Go mistakes we made (And how we recovered from them)”

不少值得看的粗心錯誤,挑出幾個很容易犯的:

  1. Naked return (先定義好的return value) 會讓整個function 更難閱讀(因為return不需要再帶回傳值). 並且很容易少回傳幾個參數而造成回傳沒有意義的初始值.

  2. Map 的concurrency 不穩定性 (可以參考Go FAQ: Atomic_Maps),要寫concurrency program 要儘量避免使用map

同場加印: Gist上面有人提供Go地雷Landmines

  • 主要是for i scope
  • interface pointer
  • 前面提到Naked return與容易踩到scope問題.

vim-go 1.5 Release

vim-go release新版 New in 1.5 (1) fatih/motion 提供函式檢索的功能 (2) GoAlternate 可以快速切換test跟原本檔案

A microservice toolkit

號稱有著相當多microservice功能的 toolkit,並且具有pluggable(可拔插)功能的設計.感覺很酷…

jsonparser: Alternative JSON parser for Go that does not require schema

相當快速的json parser(根據作者測試),甚至可以比”encoding/json” 快上九倍.

其實有附上跟一些其他json parser的效能比較表,可以參考看看. 同場加映: https://github.com/mailru/easyjson 也說他比 “ encoding/json”快上不少… 不過他跟jsonparser沒有比過效能.. 倒底”encoding/json”是有多慢呢 XDDD

Python

Android/JAVA/NODE.JS

Docker

docker-NAT-router: Docker container that functions as a simple NAT router. Linux iptables MASQUERADE provides network address translation (NAT) and dnsmasq provides DHCP, DNS, and TFTP services.

透過docker來做NAT router.之前再找就是想透過docker來做hole punching的.總算找到比較類似的東西… 主要是透過pipework來達成,這篇有更多相關應用.

此外這一篇有提到Docker 1.9裡面的新東西Container Network Model (CNM) (更多官方文件,).不過似乎無法達成我需要的MASQUERADE的功能. 繼續多多研究.

katacoda: Learn new technologies right in your browser

透過瀏覽器來學習一些科技,裡面有docker的相關教學.可以線上透過瀏覽器來下指令操作.

原生的Docker VM for Mac/Windows

Docker for Mac 與 Docker for Windows 版本,以後在 Mac 與 Windows 上面跑 Docker 不用再安裝VirtualBox,提供的原生的網路支援與更棒的磁碟掛載功能

iOS/Swift

網站文章

網站收集

有聲書/影片心得

本週專案

這邊會寫一些我的Project 52的成果.

本週專案: https://github.com/kkdai/rss-webserver

主要是把前一次的專案githubrss架成RSS Server,順便複習一下Host在Heroku上面. 結果花最多的時間都在弄Heroku.

結果弄好之後,接上IFTTT沒兩天就爆量 (笑) 不過至少看來是個正確的RSS Provider.

[TIL] docker-compose yaml文件檔案格式問題

快速紀錄一下:

  1. 在Windows 的Quick Start Terminal (Toolbox)下,如果git下載 docker-compose.yml下來會無法順利讀到. 原因是unix的文件檔案在Windows底下會無法正確閱讀. (CRLF問題)
�[31mERROR�[0m: In file '.\docker-compose.yml' service 'version' doesn't have any configuration options. All top level keys in your docker-compose.yml must map to a dictionary of configuration option
  1. 此外,如果很聰明地使用了vagrant來進入ubuntu VM中跑docker-compose.如果不小心把檔案寫到了跟Widows共享的資料夾內,一樣會有相同的問題.

結論: MacOSX/Linux 的Docker最安全… Windows好危險 XDDD

[TIL] Vagrant installation and docker installation

起因

想要分享檔案在VM跟電腦,其實VBOX本身有點麻煩.比起VBOX,vagrant反而提供比較簡單的方式.

步驟

//Check vagrant box list
vagrant list

//init
vagrant init ubuntu/trusty64

//update for vagrant shared folder
// editing Vagrantfile
//  --> config.vm.synced_folder "./data", "/vagrant_data"

//startup
vagrant up

//login
vagrant ssh


//Save bot
vagrant package --output BOT_NAME


//Install about basic component
sudo apt-get install build-essential openssl
sudo apt-get install -y pkg-config
sudo apt-get install -y libcairo2-dev

//Install about docker
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
//edit /etc/apt/sources.list.d/docker.list
// deb https://apt.dockerproject.org/repo ubuntu-wily main

sudo apt-get update
sudo apt-get purge lxc-docker
sudo apt-cache policy docker-engine
sudo apt-get install docker-engine
sudo service docker start
 
//Docker-compose
curl -L https://github.com/docker/compose/releases/download/1.6.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

//Docker-machine
curl -L https://github.com/docker/machine/releases/download/v0.6.0/docker-machine-`uname -s`-`uname -m` > /usr/local/bin/docker-machine && \
chmod +x /usr/local/bin/docker-machine

//Install npm
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

sudo apt-get update
sudo apt-get install nodejs-legacy
sudo apt-get install npm

//Install npm related 
npm install -g node-gyp

Refer

程式設計週記[2016/03/18]:AlphaGo的勝利代表機器學習對於選擇這件事情已經更加熟練

這是什麼?

程式週記主要內容如下:

Gihub project 介紹:

  • 主要會貼一些github,但是會盡量寫上一些有用的評語(或是我容易想到的關鍵詞)幫助以後查詢

網路文章心得:

  • 會寫些心得,強迫自己閱讀.

“程式週記”並且定期週期性更新.

大部分內容在我的twitter都會有,這邊只是將一些簡單的心得與感想註解一下.

本週摘要

本週依舊圍繞在AlphaGo與機器學習上,不過工作上的長官給了我很好的學習方向. 對於新的事物,我們只要搞懂三件事情(不論你有沒有興趣)

  1. 為何以前做不到? 以前的困難是什麼?
  2. 這一次做到的原因是什麼? 突破點是什麼?
  3. 對於相關技術未來的展望?

這個禮拜花了不少時間先思考該如何寫專案,確定好整個方向與架構後才開始動手.想不到卻相當的迅速.

Go

A very minimal but flexible golang web application framework, providing a robust set of features for building single & multi-page, web applications. http://kataras.github.io/iris/

minimal but flexible golang web application framework for #golang, and the performance benchmark is perfect

Official golang implementation of the Ethereum protocol http://ethereum.github.io/go-ethereum/

類似於blockchain的系統(我不是很確定該用哪種名稱來統稱這種系統).

groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases.

groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases.

類似於memcached,可以透過key來cache資料.

Python

Flappy Bird hack using Deep Reinforcement Learning (Deep Q-learning).

用Tensorflow (深度學習) 玩#FalppyBird 聽說可以玩360關

AlphaGo: A replication of DeepMind’s 2016 Nature publication, “Mastering the game of Go with deep neural networks and tree search,” details of which can be found on their website.

使用Python 建立的AlphaGo Deep Learning Engine.

Ruby

jekyll-now: Build a Jekyll blog in minutes, without touching the command line.

jekyll-now provide a easy way to setup your jekyll blog on github-page with nicely theme.

Android/JAVA/NODE.JS

Docker

Why you should (maybe) switch FROM ubuntu to FROM alpine for more secure images

在reddit上面有人建議(?)不要再使用 FROM ubuntu 而改用 FROM alpine .因為有太多的安全威脅… 這張圖可以顯示的很清楚之間差異… 此外: 這個網站可以查看你的docker container有多少安全威脅…

RUNNING A DISTRIBUTED DOCKER SWARM ON AWS

透過docker-compose, docker swarm 來在AWS架設HA RabbitMQ Cluster.

iOS/Swift

網站文章

網站收集

過往記憶

一個專注在Hadoop, Spark Hive的相關程式開發介紹部落格.內容相當清楚而充實.

Udacity: Deep Learning Course build by Google

由Google開啟的課程關於機器學習的部分,裡面會教導如何使用TensorFlow,主要語言是使用Python.

有聲書/影片心得

SEDaily: Cassandra with Tim Berglund

這一篇採訪的Tim Berglund來討論為何Cassandra能夠提供如此高效能的存取效能.也有解釋Cassandra在Big Table上面運作的方式. 由於Cassandra本身是透過Amazon Dynamo與Google BigTable的兩篇論文所產生的技術

這裡有另外一部影片介紹Cassandra

  • Amazon Dynamo: (paper)
    • How to build data store with reliability, alway-on and performant.
  • Google BigTable: (paper)
    • Richer data model
    • 1 key lots of value
    • Fast sequence access

本週專案

這邊會寫一些我的Project 52的成果.

本週專案: https://github.com/kkdai/githubrss

一個產生RSS Feed 的工具,主要是針對 Github 的 starred/follower/following.透過這個把資料產生給 IFTTT做後續使用(via web server)

這次的專案只花了四個番茄(也就是100分鐘的時間)就完成,算是挺有效率的.不過這次思考整個專案該如何做就花了一天.整天在想要如何達成相關的事項,需要使用到哪些工具與技術,該搭配哪些架構.

接下來幾個專案,應該會把可以拿來把我身邊一些繁瑣事情(記錄有趣Github, 網址並且整理成MD)自動化的事情搞定.