Rails 指定資料庫類型

在產生新的專案時候增加-d 資料庫類型

參考語法如下

rails new 專案名稱 -d 資料庫類型
rails new 專案名稱 –database=資料庫類型

資料庫類型清單

mysql / oracle / postgresql / sqlite3 / frontbase / ibm_db /

sqlserver / jdbcmysql / jdbcsqlite3 / jdbcpostgresql / jdbc /

 

Rails database.yml 更改Port

當某些機器的mysql不是使用預設的3306 Port而是3307該怎麼處理呢

其實很簡單

打開database.yml

development:
  adapter: mysql2
  encoding: utf8
  database: db_name
  username: root
  password: password
  host: 127.0.0.1
  port: 3307 =>你所要連結的Mysql port

增加port:3307即可

Ruby on Rails Windows 7 Install 安裝

要在Windows 7 上安裝Ruby on rails

首先要下載三套軟體

1.Ruby 1.9.3-p484
按此下載

2.Development Kit(For use with Ruby 1.8.7 and 1.9.3)
按此下載

3.Aptana RadRails(RadRails is now included as part of Aptana Studio 3已經內建)
按此下載

依照順序安裝1->2->3

1

i.先安裝Ruby 1.9.3-p484,下圖打圈處的三個選項記得要勾選,其他就下一步、下一步依序完成

2

 

ii.0安裝Development Kit安裝到剛才Ruby 1.9.3-p484安裝路徑下

3

 

ii.1初始化ruby=>到DevKit路徑下 ruby dk.rb initcmdSetup1

ii.2 ruby dk.rb reviewcmdSetup2-1

ii.3 ruby dk.rb install開始安裝DevKit

cmdSetup3

ii.4 C:\Ruby193\DevKit>gem install rails –include-dependencies –no-ri –no-rdoc

※如果安裝上有出現問題建議先移除重新安裝程式後在安裝rails  前先gem update

cmdSetup4

ii.5 驗證一下安裝好的ruby及rails的版本ruby -v 、 rails -v

cmdSetup6

 

ii.6-1 建立個開發目錄RailsWWW

cmdSetup7

 

ii.6-2 進入開發目錄RailsWWW

cmdSetup7-1

 

ii.6-3 建立一個新的網站測試程式=>rails new demoApps

 

cmdSetup7-2

 

cmdSetup7-4

 

ii.6-4 啟動demoApps=>rails s

cmdSetup7-6

 

ii.6-5 啟動瀏覽器再網址列打入localhost:3000即可看到以下畫面

cmdSetup8

iii.1安裝Aptana RadRails完成後打開專案Create Project

createNewProject

iii.2 選擇Rails Project

createNewProject2

iii.3 輸入專案名稱

createNewProject3

iii.4 開始享受Ruby on Rails的開發吧

 

Ruby on Rails 參考資源

以下ROR相關參考資源(會持續更新)

ruby china

http://ruby-china.org/

 

Ruby on Rails 實戰聖經使用 Rails 3.2 及 Ruby 1.9.3

http://ihower.tw/rails3/

 

Ruby on Rails之門外漢心得

http://blog.eddie.com.tw/2010/07/16/internet-campaign-with-ruby-on-rails/

 

向XDite 學 ROR

http://wp.xdite.net/?p=1754

 

Ubuntu 12.04.3 LTS ROR (Ruby on Rails)開發環境安裝

終於裝出一個順序可以正常運作Ruby on Rails 在此做個紀錄給有需要的人
1.進行Linux系統更新
$ sudo apt-get update
$ sudo apt-get upgrade

2.
$ sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev

3.下載1.9.3-p327原始碼接著開始編譯
$ wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
$ tar xvfz ruby-1.9.3-p327.tar.gz
$ cd ruby-1.9.3-p327/
$ ./configure
$ make
$ sudo make install

4.安裝SQLite的Adapter
$ gem install sqlite3 –no-ri –no-rdoc

5.安裝Rails
$ gem install rails –no-ri –no-rdoc

6.安裝node.js
$ apt-get install nodejs

檢查安裝套件版本
$ git –version

$ ruby -v

$ gem -v

$ rails -v

注意我只有在這個版本測試過所以其他版本會遇到的問題我可能也無法知道,以上安裝方式僅供參考

 

安裝 mod_security 導致php 突然無法上傳檔案解決方法

最近幾天突然某一支之前寫的程式無法傳檔案 當下在想最近有裝什麼套件嗎 後來想到因為安全性的關係裝了一個mod_security套件 萬萬沒想到是這個模組讓我的程式無法上傳檔案

而這個模組有些功能又還蠻好用的 於是想說看能否在某些站台服務將他暫時關閉 以下是安裝了mod_security 導致無法上傳檔案解決方法

打開站台設定檔 vim /etc/apache2/sites-available/default加入SecRuleEngine Off

<VirtualHost *:80>
   ServerAdmin service@abc.com
   DocumentRoot /var/www/abc
   ServerName abc.com
    <Directory /var/www/abc>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny     
     <IfModule security2_module> <== here
        SecRuleEngine Off         <== here
     </IfModule>                 <== here
   </Directory>
</VirtualHost>

在執行 sudo /etc/init.d/apache2 restart 就完成了

MySQL 中文筆畫排序 規則

最近在測試MySQL的中文排序發現原來在MySQL中文的預設排序如果用UTF8排序會跟我們一般想像的會不一樣 例如假設我們的資料表結構如下 table name:site_tag 欄位: id,tag_name 1 三民 2 大小 3 三國 4 于十二皇子 5 工人 6 小豬

假設用ORDER BY site_tag.tag_name asc 結果如下 3 三國 1 三民 4 于十二皇子 2 大小 6 小豬 5 工人

如果我們想用中文慣用的按照筆畫排序(先比第一個數字,再比整串的) 語法如下 SELECT site_tag.id, site_tag.tag_name FROM site_tag ORDER BY CONVERT(SUBSTR(site_tag.tag_name,1,1) USING big5) ASC, site_tag.tag_name ASC

最後結果 3 三國 1 三民 4 于十二皇子 2 大小 6 小豬 5 工人

是不是很簡單阿

2013 Nokia Champion Asia and Pacific名單

2013年度Nokia Champion Asia and Pacific名單如下,今年入選的名單跟往年有分不同,今年是以區域來區分來自全球各地的開發好手

Nokia Developer Champions

Asia and Pacific詳細名單如下

Australia

Kris Shanahan is the Managing Director of Shantek Studios, an Australia-based game and application developer on the Windows Phone and Windows 8 platforms. Shantek Studios develop self-published apps and games as well as third party applications.

Contact

Lewis Benge is a technical consultant specializing in multi-channel platform development in a range of different verticals. With a strong background in eCommerce and retail, Lewis has a broad range of skills to tackle regular challenges of integration into various hardware and devices, as well as a variety of service-based architectures. More recently Lewis has spent a lot of time focusing on next-generation hardware devices such as Microsoft Kinect, Microsoft Surface, Microsoft Windows 8, and other mobile platforms, and various embedded platforms with a specific focus on how these smarter, smaller devices will affect business and consumer platforms.

Contact

Niall Ginsbourg is a software developer and solutions architect from Melbourne, Australia, focusing on Windows Phone and Windows 8 apps. He works as a freelance developer by day, and in his spare time runs mobilewares.net, a company focused on making consumer apps for Marketplace. Niall has been a Microsoft MVP since 2007 and he’s also the co-founder of the Developed Down Under community initiative, designed to promote Aussie Apps and Publishers to Aussie users via a dedicated App and website.

Contact

Srikanth Nair is a Solutions Architect by day, but he also has a deep passion for all things Windows Phone and Windows 8. In his spare time, Sri runs a Brisbane meet-up focused on the aforementioned platforms, regularly participates in local developer events, blogs, and is active on social media, so as to help fellow developers and the community at large. Sri enjoys public speaking, engaging in healthy debates and discussions, and is passionate about all things IT.

Contact

China

Hai Xu is a mobile developer from Beijing who specializes in platform development in Windows Phone, Qt, Android, and HTML5. He is an expert on mobile sensors and font system. He has published several mobile applications and patents.

Contact

Ziteng Chen is a mobile developer from Beijing whose develops on various mobile platforms and has a keen expertise in Imaging. He shares his ideas on discussion boards and organizes developer meet-ups.

Hong Kong

Jordan Hisashi a mobile developer from the city of Hong Kong. His primary development is the Windows Phone platform.

Indonesia

Adam Ardisasmita is a mobile entrepreneur who specializes in Java ME, NFC and game development. In his downtime, he blogs, engages in public speaking, and social media.

Eko Sakti is a lecturer at the University of Brawijaya Malang Indonesia. Likes blogging, organizing and speaking at developer events, solving problem (research in computer network areas) and creating apps in his spare time.

Jeffrey Hermanto Halimsetiawan is a game and mobile app developer whose expertise is in Java, Windows Phone and Game development. He is also a co-founder of Aksara Studio from Surabaya, Indonesia. In his spare time, he frequently blogs and engages in various social media channels. In his spare time, he enjoys blogging, writing wiki articles and partakes in technical debates on various discussion boards.

Contact

Mohamad Iqbal is a Nokia Developer Certified Trainer from Indonesia who specializes in Windows Phone and Web Apps Development. He enjoys blogging, public speaking, organizing developer events and helps developers in solving their technical issues as needed.

Contact

Puja Pramudya is a big fan of Windows Phone and modern UI. He has deep understanding of the Windows phone platform and experiments with emerging technology such as NFC, augmented reality and location based services. He is also a frequent speaker and trainer at developer events and training sessions.

Contact

Ray Rizaldy is a mobile apps developer, and co-founder of GITS Indonesia. His focus is on UX in mobile apps across all major platforms. Besides developing apps, he also organizes trainings and workshops for students and professional developers. He is a registered Nokia Developer Certified Trainer and his company GITS Indonesia is a member of Nokia Developer Consultancy Network.

Rifauddin Tsalitsy is a game developer whose expertise is in Java, Windows Phone, HTMLS, and Location Based Services (LBS). He is also a co-founder of Creacle Studio from Yogyakarta, Indonesia. He enjoys organizing and speaking at developer events.

Contact

Malaysia

Cheah Wei Leow is an electronic engineer from Penang who specializes in Windows Phone and Imaging. In his spare time, he enjoys blogging, writing wiki articles and partakes in technical debates on various discussion boards.

Walter Wong is an IT Professional from Kuala Lumpur who specializes in Windows Phone and Social Network Apps. He is also a Microsoft Most Valuable Professional (MVP) who enjoys training new developers, public speaking and organizing developer meet-ups.

New Zealand

Atta Elayyan is a UX Designer and Co-Founder of Lazyworm Apps, a start-up based out of Christchurch, New Zealand, and one of the first companies in the world purely focused on delivering Metro-Style applications. Atta takes on several roles, but the bulk of his time is dedicated to the design and refinement of their app experiences. The sole designer behind the hugely popular ‘Metrotube’ and ‘Tweetro’ applications, his work has received much praise from the Windows Phone and Window 8 community. Atta has been designing and delivering consumer based solutions for Microsoft platforms for over 7 years.

Philippines

Gener S. Gabasa is a 4x device winner in Calling All Innovators 2011. Awarded Best Feature Phone Game for MyCheckers, Best Feature Phone App for SketchPadPlus, Best Smartphone App for SketchPadPlus and Hall of Fame Achiever 2011 by Nokia Philippines.

Singapore

Cheng Lei Lim is a mobile developer from Singapore. His primary platform of developer is Windows Phone. He organizes and speaks at developer events.

John Paul Lozano is a Nokia Developer Champion and has a broad experience in Web Apps (s40/Symbian), Symbian, HTML and Java development. He also specializes in Microsoft Windows Phone development.

Contact

Nishant Rana is a Windows Phone developer from Singapore. In his spare time, he organizes developer events and helps new developers on the Nokia discussion board. He is fluent in Hindi and English.

Taiwan

Nguyen Ngoc Quynh is the founder and concept designer from Wawa – VietNam. He loves creating mobile games and applications and social networks. He has a lot of crazy mobile ideas and has already created 1000+ mobile game apps using J2ME with his company

Contact

=> (我在這)Yeh Pu Jung is a mobile developer from Taipei with years of experience in Windows Phone, Web Apps and E-Commerce. At leisure, he writes wiki articles and organizers developer meet-ups.

Vietnam

Phom Quon is a computer scientist from Ho Chi Minh with expertise in Java and Gaming development. In his spare time, he organizes developer meet-ups and helps developers in solving their technical issues as needed.

Truong Giang is a game designer from Ho Chi Minh with technical experience in windows Phone, Java ME, HTML5 and gaming. He is also bilingual in Vietnamese and English.

Truong Mai Thanh Tri is a mobile games developer from Ho Chi Minh City. He has experience in Windows Phone games (XNA-DirectX) and J2ME games. He loves to share his knowledge with those who need it.

Contact

To Tuong is a mobile developer from Ho Chi Minh whose primary platform of expertise in the Series 40 – Java ME applications. He is fluent in Vietnamese and English.

[LINQ] No.1 LINQ 字串陣列中搜尋

[LINQ][String應用] 在字串陣列中搜尋我要的字並且設置條件

範例程式碼如下

//查詢資料來源
string[] words = { "I", "love", "great", "mobilenest" ,"!"};

//LINQ查詢表達式
var sentence =
from word in words
where word.Length != 5 //查詢長度不等於5的值
select word;

//顯示查詢結果
foreach (var str in sentence)
{
   Console.Write(str.ToString()+" ");
}
Console.ReadLine();

LINQ語法查詢的好地方

微軟官方LINQ語法查詢的好地方,臨時忘記語法可以來查喔

http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b