[TIL] Learning note about Cassandra

Keyspace keyspace == database in SQL CREATE KEYSPACE KEYSPACE_NAME WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }; then use KEYSPACE_NAME; in cqlsh before you create/alter/drop/select tables. Special Data Operation in Cassandra (Set/List/Map/Nested Type/Frozen/Tuple/JSON) Set data Table schema for set. CREATE TABLE users ( user_id text PRIMARY KEY, first_name text, last_name text, emails set<text> ); Insert data into table INSERT INTO users (user_id, first_name, last_name, emails) VALUES('frodo', 'Frodo', 'Baggins', {'[email protected]', '[email protected]'}); List data Table schema CREATE TABLE users ( user_id text PRIMARY KEY, first_name text, last_name text, top_places list<text> ); Data Insertion. INSERT INTO users (user_id, first_name, last_name, emails) VALUES('frodo', 'Frodo', 'Baggins', [ 'rivendell', 'rohan' ]); Map Data Table schema CREATE TABLE users ( user_id text PRIMARY KEY, first_name text, last_name text, todo map<timestamp, text>; ); Data Insertion. INSERT INTO users (user_id, first_name, last_name, emails) VALUES('frodo', 'Frodo', 'Baggins', { '2012-9-24' : 'enter mordor', '2014-10-2 12:00' : 'throw ring...
繼續閱讀

[TIL] 如何快速在 Google Cloud Platform 上面架設一個 Docker 環境

Using docker-machine is another way to host your google compute instance with docker. docker-machine create \ --driver google \ --google-project $PROJECT \ --google-zone asia-east1-c \ --google-machine-type f1-micro $YOUR_INSTANCE If you want to login this machine on google cloud compute instance, just use docker-machine ssh $YOUR_INSTANCE Refer to docker machine driver gce Note: The progress of docker-machine might be slow because it need connect to Google Compute Engine. Do not use multiple docker-machine creation, because docker need to write related information on docker.sock. You might occur error on Wrapper Docker Machine process exiting due to closed plugin server (unexpected EOF). Using docker-machine to create local vbox vm will install docker 1.12 rc1, but on GCP will using 1.11. So, we could use docker swarm mode :(
繼續閱讀

[TIL] Google Cloud Storage Quickstart

Google Cloud Storage: 扁平的檔案結構,其主要架構為: Bucket (ex: gs://example) 就像是 git repo 一樣. Object 就像是檔案一樣. 存取方式 這裡先介紹透過 Google Cloud SDK 來安裝,透過以下方式可以安裝: curl https://sdk.cloud.google.com | bash 建立 Bucket gsutil mb gs://YOUR_BUCKET_NAME 複製檔案過去 gsutil cp SOURCE DESTNATION 根據這樣指令架構. 檔案放上 Google Cloud Storage: gsutil cp ./111.txt gs://YOUR_BUCKET_NAME 拉回本地端: gsutil cp gs://YOUR_BUCKET_NAME/111.txt ./ 參考: Google Doc: gcs docs GoogleCloudPlatform/storage-getting-started-go: This is a simple example of calling the Google Cloud Storage API in Go.
繼續閱讀

[Golang][FB] 教學如何快速透過 Golang 與 Heroku 架設一個臉書機器人

1. Just Deploy the same on Heroku Remember your heroku ID and app address. ex: https://APP_ADDRESS.herokuapp.com/ 2. Create a Facebook Page Make sure you already have Facebook account, if you need use FB Bot. 3. Go to Facebook Developer to create App Create App, need select as follow: New App type [Web App], create app Add new product [Messenger] 4. Configuration Messenger Bot Get token from Faccebook page. Select a “Page” you own. Go to “Meseenger” product. It will generate token copy it and store it. 5. Paste Token to Heroku Go to heroku dashboard, go to “Setting” -> “Config Variables”. Add “Config Vars” Name -> “TOKEN” Value use token facebook app. 6. Back Facebook App configuration Go to “Messenger” product Go to “Setup Webhooks” Fill https://APP_ADDRESS.herokuapp.com/webhook in callback URL. Fill your token in “token”. Checked the checkbox “message_deliveres”, “messages”. If your configuration is correct, it will show “completed”. Also...
繼續閱讀

程式設計週記[2016/06/24]: COSCUP 要開賣, Docker Swarm v2 帶來集群管理

這是什麼? 程式週記主要內容如下: Gihub project 介紹: 主要會貼一些github,但是會盡量寫上一些有用的評語(或是我容易想到的關鍵詞)幫助以後查詢 網路文章心得: 會寫些心得,強迫自己閱讀. “程式週記”並且定期週期性更新. 大部分內容在我的twitter都會有,這邊只是將一些簡單的心得與感想註解一下. 本週摘要 正式上班第一週,大部分時間都在開會 @_@ .本週最大的事情大概就是COSCUP 要開賣還有就是 Docker 出了自己的集群管理系統 Docker Swarm v2 . 本週還是寫了一個專案,不過不會記錄到 Project52,大家也要繼續寫喔. Go Short Introduction to Bleve 一個文字搜尋的套件,支援相當多的語系.這裡有 Github GO: MARSHAL AND UNMARSHAL JSON WITH TIME AND URL DATA 講解如何透過 Custom Marshaller 透過 JSON 來處理 time 或是其他類型資料.這裡有更仔細的影片教學可以看 from Francesc Campoy -. http://elliot.land/go-subtests-and-sub-benchmarks 主要是講解 Go 1.7 新增的 subtest 跟 subbenchmark 的部分. HOW TO WRITE ROUTER TESTS IN GO Python Android/JAVA/NODE.JS/Scala Spark Streaming Programming Guide - Spark 1.1.0 Documentation Send data to spark streaming directly via pipe Docker Youtube: Docker 1.12 Release Candidate 2 About Docker Swarm V2, 內建 SwarmKit 之後.類似 Mesos 一樣可以很方便的建置出資源控管. More Microservices Bliss with Docker 1.12 and Swarm only 專門幫 Docker port 到 PI (ARMed) 的 HyPriot 也把 1.12 開始導入了,這篇也有一些介紹. DockerCon 2016 D1 主题演讲 紀錄 DockerCon 2016 第一天的重點,主要還是集群管理的部分. Swarm Reboot in Docker 1.12 SwarmKit 在 Docker 1.12 之後會整合進 Docker Swarm 中,這篇文章做一個簡單的介紹. Building serverless apps with Docker 若有參加 Docker...
繼續閱讀

程式設計週記[2016/06/17]: 女兒剛滿週歲,Project52 也順利完成

這是什麼? 程式週記主要內容如下: Gihub project 介紹: 主要會貼一些github,但是會盡量寫上一些有用的評語(或是我容易想到的關鍵詞)幫助以後查詢 網路文章心得: 會寫些心得,強迫自己閱讀. “程式週記”並且定期週期性更新. 大部分內容在我的twitter都會有,這邊只是將一些簡單的心得與感想註解一下. 本週摘要 本週真是一波多折:先是老婆感冒生病,再來換我眼睛長針眼.也剛好本週要把 Project 52 跟一個電子報導(尚未發,先保密)寫完.整個就是忙碌到不行.最後專案是 Raft Server ,所有的變數名稱跟功能都是依照論文來寫.不過 Log Replication 還需要更多的測試才能確認功能是否正常. Go google/cayley: An open-source graph database Google 開發的開源圖形資料庫,裡面提供許多關於連接資料 (Linked Data) 的工具箱. GB 0.4.2 release GB 有新功能就是 nope mode ,可以只編譯 test 的部分而不去跑他,來確保程式碼有沒有基本的問題. How to do Google sign-in with Go 透過 Golang 來撰寫可以登入 Google 服務的功能. roylee0704/gron: gron, Cron Jobs Python Reactive Programming in Python PyCon Taiwan 2016 的講稿 Android/JAVA/NODE.JS/Scala jQuery 3.0 Final Released! Docker Shrink your App with Alpine Linux 教導你如何將 App 修改後可以放入 Alpine Linux 之中,這樣也可以在 Docker 放入 Alpine (又小又安全) gaia-adm/pumba: Chaos testing tool for Docker iOS/Swift Xcode 8 has SourceKit.framework written in #Swift 😱 #WWDC16 pic.twitter.com/FNH1fSdpbO— JP Simard (@simjp) June 14, 2016 iOS 裡面的 SourceKit 已經是用 Swift 編譯而成 其他程式語言 Spark手把手:e2-spk-s02 教你如何透過 docker 來架設 spar 論文收集 Who to Follow for DevOps Resources on Twitter | Automic Software DevOps Twitter 名人帳號清單. 網站文章 Clairvoyance 是怎麼開發的 - 104 Chrome 套件天眼通的開發經過與心得 最近很知名的 104 Chrome Plugin...
繼續閱讀