[學習心得] Ruby 跟 Rail 研究心得 (1)

緣起: 最近開始要找時間研究一些新的程式語言,主要是要讓我自己的程式在server端back-end的一些處理 有些前輩推薦我使用Heroku,主要原因如下: 支援的程式語言相當的多 (Ruby/Golang) 只要是跑一個process之下,基本上算是免費 Ruby on Rails 網路上的資源並不少,不過這一個算是我找到比較齊的,也很適合初學者來學習.     關於程式語言Ruby: 如同每一個最近產生的程式語言一樣,Ruby有著比較方便的用途與預先設定好的一些API 在此整理一下,個人所認為相當方便與特別的地方: 關於變數型別 是所謂的[強型別] 物件無法了解其型別 無法直接轉換數字與浮點數需要自行轉換 字串轉數字,數字轉字串原本就有提供   .to_s  to_i 大寫是constant 小寫是變數 (類別class名稱要用constant) [注意] Symbol 是記憶體位置固定的但是變數記憶體位置不固定 讓我比較覺得特別的是 除了 nil 與 false  其餘都是true包含 if (0) if (“ “) 關於資料結構: 陣列,雜湊表 陣列限制,可以[0] 是字串,但是[1]自數字 關於走訪與iterator  提供許多方便的traversal 或是interator的方式 .each do (這很基本) .delete_if { x x >20} .map { x x+”ss”} 來轉移或是轉變array .inject 是取出兩兩成對~我認為這個真的很好用 關於inject 我提出一個範例出來比對C++與 Ruby 字串處理的差異 題目: 找出一個字串列中最大的N個字串,比如說 [“1”, “22”, “333”] 找出前兩長為 “333”, “22” C++結果如下 Ruby利用inject 結果卻短的個不行   最後把我所有的sample code放上來 參考資料: http://ihower.tw/rails3 https://www.ruby-lang.org/zh_tw/documentation/ruby-from-other-languages/ http://zh.wikipedia.org/wiki/Ruby http://ruby-doc.com/docs/ProgrammingRuby/
繼續閱讀

[學習心得]使用SRC建立一個一件復原系統的步驟

緣起: 對於不會使用電腦的人而言,常常會把系統弄到一堆病毒導致必須要重灌系統. 我弟弟與妹妹就是如此的人,其實網路上已經有出Hiren’s bootcd Tool已經算是相當簡單了 但是他們對於這種Norton Ghost系統依舊不會使用,於是去網路上找了一個方式可以一鍵恢復系統的方法 安裝方式: 其實這一篇教學(SRC F2 一鍵還原for Win7/winxp教學)已經相當清楚了,所以在這裡不詳述安裝的方法. 只是寫一些注意事項: 可能必須重灌你目前的系統,因為partition 無法去除系統的100M 如果要重灌系統,務必注意你的驅動程式與相關使用工具的備份   使用過後 相當的方便,不過由於當初要找驅動程式.花了不少時間. 在此比較推薦 DriverEasy這個工具,可以幫助我弄好不少驅動程式的問題   相關資源: http://www.drivereasy.com/ http://tomy168.twbbs.org/myblog/index.php/2010-11-07-00-46-07/63-src-f2-for-win7winxp.html    
繼續閱讀

[學習] RaspberryPi 嵌入式電腦研習營 01/24

參考資料: http://www.raspberrypi.com.tw/ http://www.raspberrypi.com.tw/faqs/ https://github.com/raspberrypi http://www.element14.com/community/community/raspberry-pi?view=documents http://www.raspberrypi.org/downloads 電路圖 http://www.raspberrypi.org/wp-content/uploads/2012/04/Raspberry-Pi-Schematics-R1.0.pdf 講師: http://yennan.blogspot.tw/ Raspberry Pi模擬器 QEMU http://zh.wikipedia.org/wiki/QEMU RoR on Pi: http://raspberrypi.stackexchange.com/questions/4597/setting-up-a-ruby-on-rails-server http://elinux.org/RPi_Ruby_on_Rails http://sirlagz.net/2013/02/14/raspbian-server-edition-version-2-3/ 第一堂課: ** ** What is Raspberry Pi: 只需要very low poet Model#B 700ma(3.5W) Model#A 500ma(2.5W) USB only output 500ma Pi —> Python as major programming language. 其他的Embedded System Board相關資源: BeagleBoard 小獵犬   NT 6000 up http://cms.mcuapps.com/series/training-beagles/adopt-a-beagle.html About Hardware in Raspberry Pi (model#B) ARMv6 (ARM11) GPU OpenGL 2.0 1080p 30fps H264/MPEG4 512M main memory TP2 could help to check if problem happen, check if it is 5V. OS: 官方推薦使用Raspbian (change from Debian) http://downloads.raspberrypi.org/raspbian/images/ Pidora. Noobs 比較簡單~但是相當的站記憶體.. Android OS could not run full function on Raspberry Pi, not a chase in Windows. 燒錄OS到Raspberry Pi SD卡 Download image http://www.raspberrypi.org/downloads Download tool for Windows: Mac 使用系統的功能就可以 參考http://computers.tutsplus.com/articles/how-to-flash-an-sd-card-for-raspberry-pi–mac-53600 diskutil list 必須先unmount diskutil unmountdisk /dev/disk2 直接用系統指令去燒錄img (記得檔案名稱要改) dd if=2014-01-07-wheezy-raspbian.img of=/dev/disk1 bs=2m 燒好後記得把 #hdmi_force_hotplug=1 uncomment掉 他會有兩個分割區,一個是FAT(看得到) 另一個需要用工具才能查看. 第二堂課 Raspberry Pi開機/設定 開機流程: GPU啟動,載入bootcode.bin [bootcode.bin]啟動快取與記憶體 載入start.elf [start.elf] 讀取config.txt cmdline.txt 劃分記憶體 載入作業系統 kernel,img (畫面開始出來) 開機選單後,先選取第一個選項讓OS分割區占滿整個記憶卡(原本只占2.8G) 多語言選項 en_US.UTF-8 UTF8 zh_TW BIG5...
繼續閱讀

[Android]關於手機 Galaxy Nexus Root 在Mac OS上Root

由於要練習FireFox OS跟 Ubuntu OS於是還是做了點小投資買了一檯二手的Android Galaxy Nexus來刷 (由於在FFOS 與 Ubuntu OS 的device list找到比較便宜與容易購買的就是這個) 使用心得: 由於我自己習慣使用iPhone跟設計iPhone的App,其實很不習慣Android的“上一頁”實體按鍵.不過多使用幾次之後其實也還好了. 也發現Android沒有iOS的一些方便的功能如下: Tab bar: 也就是下方的Tab按鍵,這是Android App RD要花心思去搞定的. Storyboard: Android 使用Activity設計概念並且用Intent來溝通,但是沒有StoryBoard的階層觀念. 其他細節等到我其它文章再寫..   關於Root 手機 打開Development mode. [開發人員選項] 打開[設定] -> [關於手機] -> 選到[版本號碼] ( 大概點個七下) 啓動  (這是什麼怪東西?) 進入 [設定]->[開發人員選項]-> [USB 偵錯]  啓動 要Root 前,必須要先解開Boot loader lock的限制才能夠Root 下載 http://downloadandroidfiles.org/download-unlock-bootloader-gsm-verizon-sprint-zip/ 進入 [FASTBOOT Mode]  先關機 左手按下兩個音量鍵 (兩個都要按)不要放 再按下 電源鍵 這時候手機會進入FastBoot Mode (也就是有機器人躺在那邊) 執行剛剛下載的檔案 這時候會進入警告標語 利用 音量鍵選擇 ,電源鍵確認 解開後,手機的OS會重灌 一樣的步驟 進入 [設定]->[開發人員選項]-> [USB 偵錯]  啓動 進入 [FASTBOOT Mode]  下載 [Root kit] http://downloadandroidfiles.org/download-updated-galaxynexusroot-gsm-verizon-sprint-zip/ 執行先解開 [Boot Loader Lock] 開機 -> 設定 -> USB 偵錯 按下enter繼續跑 選擇(1)  GSM ClockworkMod Recovery (Version 6.0.2.3) 利用 [音量鍵] 改到 [Recovery mode] -> 電源鍵執行 選擇 install from SD card  安裝位於 目錄 0/UPDATE-SuperSU-v1.45.zip 安裝跑完最後選擇No 重開機 開機完 看到應用程式裡面有 [SuperSU] 代表你Root 成功. 參考資料: http://dottech.org/87439/how-to-unlock-usb-debugging-mode-on-android-4-2-jelly-bean-and-higher-guide/ http://www.androidrootz.com/2012/12/galaxy-nexus-one-click-mac-toolkit.html http://forum.xda-developers.com/showthread.php?t=1790399
繼續閱讀

Evernote SDK (2) with Android 2014/01/16

Slide: http://goo.gl/RPbGVn   About Evernote SDK API trick or experience discussion: (for iOS/Android.) findNote — http://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_findNotes It must  It is depressed, because it has performance issue to get all notes entity (include all attachment)  But it still could use for now.  It alway need to assign number of notes, but you could recessive to get all notes. Currently Evernote official will suggest to use “findNotesMetadata” and “getNote” if you need to ordering your result, using filter. findNotesMetadata — http://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_findNotesMetadata Please note: findNote performance is still better  than findNotesMetadata + getNote  getNote — (http://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_getNote) getNote(string authenticationToken, Types.Guid guid, bool withContent, bool withResourcesData, bool withResourcesRecognition, bool withResourcesAlternateData) withResourcesRecognition —  It help to get back image recognition(evernote specific), but it will depends on priority (pay account first) withContent —  content is HTML data using HTML data , you could easily to put  HTML data to browser. withResourcesData —  For attachment or image it will contain a hash code for your to reserve file . createNoteBook — http://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_createNotebook NoteBook “setName” could not...
繼續閱讀

Note for Google Develop Group Taipei 2014/01/15- Google Cloud Platform, Google Compute Engine

Google Cloud Platform Slide: http://www.slideshare.net/littleq0903/introduction-to-google-cloud-platform/1 What  is google cloud platform Using google storage  Goole bandwidth  Cloud encapsulation  Cloud Platform: Cloud SQL it is MySQL 5.5 Cloud Datastore NoSQL (Non-Relationshop SQL) storage. Much faster than normally SQL. Cloud Storage: Protection, similar with Google Drive GAE It much better performance for now. Full Functional Service feature: Scalable  Normally LAMP Apache2 (three apache )with one  DB. Master/Slave DB mapping with Apache2. PaaS (Platform as a Service) GAE (Google App Engine) Language: PHP,JAVA, Python GO: (New language), refer https://developers.google.com/appengine/docs/go/gettingstarted/helloworld Communication: Channel: Using Web socket Mail: Using specific mail alias to pass some email to GAE to parsing. XMPP: message like Facebook and google talk. Outbound socket Only outbound could pass socket to another service from GAE. Process manager: Cron Job: Similar with Crontab. Computation: Image API: For image resizing or scaling. Map-reduce: Like OpenCL or multiple threading. Application: Big Query: Terabyte data analysis  SQL-like Google...
繼續閱讀