2018-05-22 Oracle 01578 block currupt

Published on:

KSWHS01因換硬碟,導致 block corrupt

依照這兩篇所述,資料移轉救回
http://logic.edchen.org/how-to-resolve-ora-01578-ora-01110-and-ora-26040

https://docs.oracle.com/cd/B28359_01/server.111/b28310/repair004.htm#ADMIN11835

1.用 sysdba的身份登入
2.Skip corrupted blocks

BEGIN
DBMS_REPAIR.SKIP_CORRUPT_BLOCKS (
     SCHEMA_NAME => 'KSADMIN',
     OBJECT_NAME => 'WHSSTOCK',
     OBJECT_TYPE => dbms_repair.table_object,
     FLAGS => dbms_repair.skip_flag);
END;
/

3.Move table to other place

alter table ksadmin.whsstock move;
  1. BEGIN
    DBMS_REPAIR.SKIP_CORRUPT_BLOCKS (
     SCHEMA_NAME => 'KSADMIN',
     OBJECT_NAME => 'WHSSTOCK',
     OBJECT_TYPE => dbms_repair.table_object,
     FLAGS => dbms_repair.NOSKIP_FLAG);
    END;
    /
    

2018-05-16 Server建置

Published on:

52.197.45.176
webmaster@design-ebg.com
名象$

Ubuntu
php7.1
nginx

https://dan381006472.gitbooks.io/laravelnote-kfk-me/content/laravel/lnmp_php71.html

Mysql:
https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-16-04

nginx doc
webmin ?

freessl

https://blog.gtwang.org/linux/secure-nginx-with-lets-encrypt-ssl-certificate-on-ubuntu-and-debian/

安裝時可能會出現問題,解法參考網站 找最多人讚的那個

I resolved the issue by setting the locale variables. Without these, the script seems to break.
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"

 fressl 實際安裝流程

 0.先將/etc/nginx/sites-available/xxx.com 的設定檔備份(等一下certbot-auto會自動寫入設定)
 1.從 Certbot 官方網站下載 certbot-auto 指令稿,並設定其執行權限
   wget https://dl.eff.org/certbot-auto  
   chmod a+x certbot-auto
   mkdir /opt/letsencrypt
   mv certbot-auto /opt/letsencrypt/
 
 2.執行 certbot-auto,讓它自動安裝所有相依套件
   export LC_ALL="en_US.UTF-8"
   export LC_CTYPE="en_US.UTF-8"
   /opt/letsencrypt/certbot-auto
   自動安裝時,會自動寫入設定
 3.重啟 nginx 
   sudo service nginx restart 
 4.修改Larvel專案  config\admin.php  'secure' => false 改成 true 。這樣開後台開才不會有問題
 5.設定SSL自動更新 
   (1) 測試: /opt/letsencrypt/certbot-auto renew --dry-run 
   (2) 正式:/opt/letsencrypt/certbot-auto renew --quiet --no-self-upgrade
   (3) 將此指令寫到 /opt/letsencrypt/renew.sh檔
       /opt/letsencrypt/certbot-auto renew --quiet --no-self-upgrade --post-hook "sudo service nginx reload"
       sudo chmod a+x renew.sh
   (4) 把這個 /opt/letsencrypt/renew.sh 指令稿寫進 crontab 中
       vi /etc/crontab
       分 時   日 月 週         
       30 2    * * 7   root    /opt/letsencrypt/renew.sh
       每週日 早2:30 執行檢查更新

laravel php 相關套件

wordpress

sudo ln -s /etc/nginx/sites-available/heskare.com

laravel 的資料夾權限問題 :storage
https://www.itechempires.com/2017/06/laravel-5-files-folders-permission-ownership-setup/

//看有哪些群組
cat /etc/group | grep www

// 看誰佔著Nginx
ps aux -P | grep nginx
//將 www這個資料夾的擁有者改為 wwww-data
sudo chown -R www-data:www-data www

//將 ubuntu 這個人加入 www-data群組
usermod -a -G www-data ubuntu
//將 ubuntu 這個人移除 www-data群組
gpasswd -d ubuntu www-data
//看ubuntu加入了哪些群組
groups ubuntu

php artisan cache:clear
php artisan view:clear
php artisan config:clear

nginx 的設定
/etc/nginx/
修改php的設定
/etc/php/7.1/fpm/pool.d/www.conf
user =ubuntu
group =ubuntu

sudo service php7.1-fpm restart

wordpress 建置

  1. copy wordpress到指定目錄
  2. copy一個/etc/nginx/sites-available/nginx的設定
  3. 到 /etc/nginx/sites-enabled/ sudo ln -s /etc/nginx/sites-available/...
  4. 新增資料庫
  5. 到指定的網址進行安裝 root 名象 el_前綴

上傳 外掛時,發生 413 Request Entity Too Large,修改 nginx

client_max_body_size 100M;

安裝 Admin Meun editor 外掛
Admin Menu editor Seris: ATMRQ0NPKKJ6Z92BALB9W7LHOQXQBQV0

BackWPup

php sendmail

BeTheme seris:

purchse code: 7c145e92-7c96-460b-8d94-d557d12a003f

Bethem seris:
My purchase code: 48e15b9d-a01e-4258-a175-720ab1ce800a

2016-10-17 EDM規劃

Published on:

EDM規劃實際作法 2016-10-17

選擇飛信作為發EDM的合作廠商
發信日期:週二早上
發信主旨:25個中文字內。避免垃圾信的特徵。
垃圾信的特徵:Html語法(yahoo)、強調語法(全英文大寫、驚嘆號、$字號、免費、抽獎字眼)、圖片比例太高、連結數太多。
發信內容:80%建立品牌個性。20%優惠訊息。圖文版面比例1:1,連結數5個以內。
區分最近一年有購買的會員、以及其他會員。
發信頻率:一年內有購買的會員週週發信、其他的會員每月發。
要注意行動裝置的開信效果

發送EDM的目的是製造點擊。
把信盡量寄給想收到的人,不想收到的人盡量讓他收不到

預算:每月10000元

短期目標:提升開信率、提升開信點閱率、提升ISP的信譽,減少被歸入垃圾信的機率。
長期目標:和Superuser建立關係、希望Superuser介紹其他會員。提高email行銷ROI(投報率 lative有到30)

2016-07-29 Git Study-3 team work

Published on:

多人協作需要
1.local端有完整專案的複製
2.有一個追蹤和檢視彼此工作的方法
3.可以明確的存取某個版本

Git 指令

git clone remote_location clone_name :將遠端專案(remote_location)複製一份到本機,將它命名為自己取的名稱(clone_name)

git remote -v : 列出遠端專案。 遠端專案的別名預設為 origin ,這個指令會列出 orgin的位置

git fetch : 列出遠端異動和local的不同

git merge origin/master :將遠端異動的版本合併到local端。

git push origin brach_name : 將本機的分支push到遠端。

2016-07-28 Git Study-2 branch

Published on:

Git branch

故事,通常不是線性發展,它可能有額外的分支。

Git指令

git branch : 查看目前有那些分支,以及目前所在的分支

git branch branch_name :建立新分支

git checkout branch_name :切換到某個分支

git merge barnch_name :合併某個分支 。 ex. master 要合併 fencing ,先切換到 master,然後 git merge fencing

當 fecing的分支修改了某個檔案,而master也修改了某個檔案,就會發生 merge conflict。這時要去修改 conflict的檔案,>>>>>>> and =======都拿掉,才能 merge成功。

git branch -d branch_name :刪除某分支。

merger完成後,分支完成了他的使命,就可以刪除了

2016-07-27 Git Study

Published on:

本文是參考 CodeCademy的教學網站所做的筆記

Git 是什麼

Git 是一套文件或程式版本管理的工具,可以讓你追蹤你修改的軌跡,或需要的時候做參考。

Git 指令

git init: Git 專案初始化,會在目前目錄下新增 .git的子目錄。裡面放一些git管這個專案需要的東西。

Git 將流程分為三個部分: working directory、 staging area、 repository
working directory (工作區): 在這作平常會做的所有工作:建檔、修改、刪除等事。
staging area (階段區) : 列出你在工作區所做的所有動作。
repository (知識庫): 將你做的修改分版本永久的保存。
Git 的工作流程: 在工作區工作 -> 將修改提交到階段區 -> 最後將修改作為版本提交到知識庫

Git status: 列出專案目前的狀況

git add filename : 將某個檔案列入 staging area

git diff filename : 比較在 working area 和 staging area 檔案的差異 (按 Q 跳回)

git commit -m " " : 將 staging area的檔案提交到 repository。 -m表示 message,後面接的版本說明要簡短(50個英文字內)

git log : 檢視在 repository中的版本資訊。 (按 Q 跳回)

git show HEAD : 檢視上次Commit修改了哪些明細內容

git checkout filename : 忽略這次在 working directory修改的檔案,回復到上次commit時的內容。

git add filename1 filename2 :將多個檔案列入 staging area

git reset HEAD filename : 將某個檔案移出 staging area

git reset SHA : 將版本回復到之前的某個commit 。可先用 git log查出之前commit的 SHA ,再輸入 SHA的前七碼。ex. git reset 4759366


烏拉圭總統-穆希卡的演講-Rio+20-2012-06-20

Published on:

Youtube

感謝各位蒞臨會場的政府代表們。
今天感謝邀請我到這裡的巴西總統羅賽芙(Dilma Rousseff),還有感謝先前站在這裡做了精湛演講的每一位,各個代表國家的人,在這裡展現真誠的理想目標,做出對人類有必要性的決議。
但是,我腦中有個尖銳的疑問,從下午開始一直探討永續發展的可能性和如何消弭世界貧窮的議題,而我們真正想表達的心聲到底是什麼?是模仿現在富裕國家的發展和消費型態嗎?
我想問:德國人一戶人家的車子數量,若是印度人也同樣擁有的話,這個地球會變得如何?
能呼吸的氧氣還剩下多少呢?相同的問題換種方式來問的話,若是世界上70~80億的人口擁有和西方富裕國家相同的傲慢消費方式,這地球能夠提供如此龐大的原料嗎?有可能嗎?還是,那只是兩碼子的事情,屬於另一個議題呢?
為什麼我們創造出這樣的社會?
市場經濟的小孩,資本主義的小孩,一直以來,我們毫無疑問地創造了追求無止盡消費和發展的社會,市場經濟衍生市場社會,也就是放任全球化在世界各個角落不停地尋找原料的社會,不是嗎?
我們掌控了全球化嗎?或者該說,是全球化掌控了我們,不是嗎?
建立在如此殘酷競爭上的消費主義社會,有辦法討論「讓大家的世界變得美好」這樣共存共榮的話題嗎?到哪裡為止才是夥伴情誼?而從哪裡開始又是競爭敵手?我這麼說並不是為了批評這個活動的重要性,正好相反。我認為矗立在我們面前的巨大危機問題,並不是環境問題,而是政治的危機問題。
直到現代,人類並無法有效控制這股龐大勢力,相反地,人類被這樣的消費社會所控制了。我們並不是為了發展才誕生的,是為了變得幸福才來到地球的,人生短暫,稍縱即逝,沒有任何比生命更高貴的東西了。
過度消費正在摧毀世界,但是很多人的人生拚命追逐價格昂貴的商品和生活方式,在消費成為讓社會運轉的馬達的世界裡,我們只能一昧地快速地大量進行消費。消費一旦停止,經濟就會麻痺,經濟麻痺,經濟不景氣這怪物又會出現在大家面前了。
為了能夠支撐過度消費,而減少商品的壽命,盡可能地能賣出多少就賣多少,也就是說,明明能夠製造出壽命達十萬個小時的電燈泡,卻只賣持續照明一千個小時的電燈泡,變成了這樣的社會!人們為了有更多工作,為了賣出更多,所以要不停地維持著「用完後就丟掉的社會」,我們正身處這樣的惡性循環中,你注意到了嗎?這無疑地是政治問題,用不同的解決方式處理這樣的問題,是我們做為首腦必須領導整個世界的地方。
我並不是叫大家回到石器時代,是在說明必須要有效控制市場,在我謙虛的思維裡,我認為這是政治問題。
古代賢能者伊壁鳩魯(Epikouros)、塞內卡(Seneca)和南美的Aymara族都這麼說過:
「所謂的貧窮,並不是指擁有的東西少,而是懷著無止盡的欲望,卻永遠無法滿足的人。」
這是在我的議論中一個屬於較文化性質的關鍵詞。
我做為國家的代表者並懷抱著這樣的心情來參加里約會議的決議和討論,我想我的演講內容有很多不中聽的話語,但是我想讓大家知道的昰問題的來源並非單純是水源危機和環境危機。
根本上的問題是我們實施的社會型態,而且,必須要重新審視檢討我們的生活方式。
我是蘊藏著豐富環境資源的小國代表,在我的國家約有三百萬人左右的國民,但是卻有一千三百萬頭世界上最美味的牛在我的國家,也有約有八百萬到一千萬頭左右的羊,我的國家是食品的輸出國,這樣小的國家,領土的90%有豐富的資源。
國民裡面很勤勞的人一天拚命工作八小時,最近工作六小時的人也在逐漸增加,但是,做完六小時的工作後,還需要額外的工作,為什麼呢?因為必須支付機車、轎車等的分期付款或貸款,每個月加倍的工作,償還貸款,不知不覺就變成像我這樣的老人,和我一樣,幸福的人生眨眼間就過去了。
於是,我問自己一個問題:這是人類的命運嗎?對我來說,這是非常簡單的事情,所謂的發展不可以和幸福背道而馳,發展必須是朝著人類達到真正幸福的目標前進,愛、人際關係、照顧小孩、擁有朋友和擁有生活最低限度的東西。
因為幸福是我們最重要的東西,若真得要為了環境而奮鬥,不可以忘記幸福是人類最珍貴的原素。
謝謝大家的聆聽。

=============================================================================
To all of the authorities present here, from every latitude and organization, thank you very much. I want to thank the people of Brazil and Mrs. President, Dilma Rousseff. Thank you all for the good faith undoubtedly expressed by all of the speakers that preceded me.

We hereby express our innermost will as rulers, to adhere to all the agreements our wretched humanity, may chance to subscribe.

Notwithstanding, let us take this opportunity to ask some questions out loud. All afternoon long, we have been talking about sustainable development, about rescuing the masses from the claws of poverty.

What is it that flutters within our minds? Is it the model of development and consumption, which is shaped after that of affluent societies? I ask this question: what would happen to this planet if the people of India had the same number of cars per family as the Germans? How much oxygen would there be left for us to breathe? More clearly: Does the world today have the material elements to enable 7 or 8 billion people to enjoy the same level of consumption and squandering as the most affluent Western societies? WIll that ever be possible? Or will we have to start a different type of discussion one day? Because we have created this civilization in which we live: the progeny of the market, of the competition, which has begotten prodigious and explosive material progress. But the market economy has created market societies. And it has given us this globalization, which means being aware of the whole planet.

Are we ruling over globalization or is globalization ruling over us? Is it possible to speak of solidarity and of “being all together” in an economy based on ruthless competition? How far does our fraternity go?

I am not saying any of to undermine the importance of this event. On the contrary, the challenge ahead of us is of a colossal magnitude and the great crisis is not an ecological crisis, but rather a political one.

Today, man does not govern the forces he has unleashed, but rather, it is these forces that govern man; and life. Because we do not come into this planet simply to develop, just like that, indiscriminately. We come into this planet to be happy. Because life is short and it slips away from us. And no material belonging is worth as much as life, and this is fundamental.But if life is going to slip through my fingers, working and over-working in order to be able to consume more, and the consumer society is the engine-because ultimately, if consumption is paralyzed, the economy stops, and if you stop economy, the ghost of stagnation appears for each one of us, but it is this hyper-consumption that is harming the planet. And this hyper-consumption needs to be generated, making things that have a short useful life, in order to sell a lot. Thus, a light bulb cannot last longer than 1000 hours. But there are light bulbs that last 100,000 hours! But these cannot be manufactured, because the problem is the market, because we have to work and we have to sustain a civilization of “use and discard”, and so, we are trapped in a vicious cycle. These are problems of a political nature, which are showing us that it’s time to start fighting for a different culture.

I’m not talking about returning to the days of the caveman, or erecting a “monument to backwardness.” But we cannot continue like this, indefinitely, being ruled by the market, on the contrary, we have to rule over the market.

This is why I say, in my humble way of thinking, that the problem we are facing is political. The old thinkers. Epicurus, Seneca and even the Aymara put it this way, a poor person is not someone who has little but one who needs infinitely more, and more and more.” This is a cultural issue.

So I salute the efforts and agreements being made. And I will adhere to them, as a ruler. I know some things I’m saying are not easy to digest. But we must realize that the water crisis and the aggression to the environment is not the cause. The cause is the model of civilization that we have created. And the thing we have to re-examine is our way of life.

I belong to a small country well endowed with natural resources for life. In my country, there are a bit more than 3 million people. But there are about 13 million cows, some of the best in the world. And about 8 or 10 million excellent sheep. My country is an exporter of food, dairy, meat. It is a low-relief plain and almost 90% of the land is fertile.

My fellow workers, fought hard for the 8 hour workday. And now they are making that 6 hours. But the person who works 6 hours, gets two jobs, therefore, he works longer than before. But why? Because he needs to make monthly payments for: the motorcycle, the car, more and more payments, and when he’s done with that, he realizes he is a rheumatic old man, like me, and his life is already over.

And one asks this question: is this the fate of human life? These things I say are very basic: development cannot go against happiness. It has to work in favor of human happiness, of love on Earth, human relationships, caring for children, having friends, having our basic needs covered. Precisely because this is the most precious treasure we have; happiness. When we fight for the environment, we must remember that the essential element of the environment is called human happiness.

Rails in AWS with Ubuntu+Nginx+Puma+Capistrano

Published on:

作業目的:把程式部署到Aws上,日後要方便自動部署

最近要把客戶的程式部署到Aws上,弄完之後寫個筆記免得日後忘了。
在這裡以之前練習寫的rails101為例。
參考網路上的兩篇文章:
Deploy Your Rails App to AWS
Ubuntu安裝RoR筆記
AWS是Amason提供的虛擬主機服務。
Ubuntu是Linux的作業系統
Nginx是網站伺服器,類似Apache和iis的服務。
Puma是應用服務伺服器
Capistrano是應用程式部署工具
PostgreSQL是資料庫,類似MySQL
Rails是應用程式的framework
Ruby是應用程式的語言
Git是管程式原始碼的工具。可用來協作、備份及版本控制

Local端

1.修改gemfile

gem 'figaro'
gem 'puma'
group :development do
  gem 'capistrano'
  gem 'capistrano3-puma'
  gem 'capistrano-rails', require: false
  gem 'capistrano-bundler', require: false
  gem 'capistrano-rvm'
end

然後執行

bundle install

這會在Local端把capistrano、puma、figaro的套件bundle 安裝起來
2.設定自動部署的環境
2.1執行

cap install STAGES=production

這會讓capistrano產生config/deploy.rb,以及config/deploy/production.rb兩個檔案。
cofig/deploy.rb是cap的主要設定檔,設定日後自動部署的一些環境參數。config/deploy/production.rb設定Server IP及username等資訊,以利cap登入server端作事。
2.2修改 capfile,在require 'capistrano/deploy'下面加入

require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/rails/assets' # for asset handling add
require 'capistrano/rails/migrations' # for running migrations
require 'capistrano/puma'

2.3修改cofig/deploy.rb

lock '3.4.0'

set :application, 'rails101'
set :repo_url, 'git@github.com:phileiny/rails101.git' # 修改這裡,以符合你自己放程式的地方
set :branch, :master
set :deploy_to, '/home/deploy/rails101'   #等下會在ubuntu上建deploy這個user,然後把程式clone到這個user底下
set :pty, true
set :linked_files, %w{config/database.yml config/application.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
set :keep_releases, 5
set :rvm_type, :user
set :rvm_ruby_version, 'ruby-2.2.0' # 修改這裡,以符合你的ruby版本。我是在server上裝 ruby2.2.0

set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"    #accept array for multi-bind
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 8]
set :puma_workers, 0
set :puma_worker_timeout, nil
set :puma_init_active_record, true
set :puma_preload_app, false

2.4 修改 config/deploy/production.rb

server '52.104.107.65', user: 'deploy', roles: %w{web app db}  # server IP是等下建完Ubuntu後AWS隨機給的的ip,或你在AWS上設定保留的ip (Elastic IP)。

2.5 建立 config/application.yml,裡面放部署階段會用到的資訊。(不建好像也可以?),等下在Server端也要建這個檔。
2.6 將 config/database.yml 及 config/application.yml 放到 .gitignore裡。顧名思議,放進.gitignore裡的東西就是不想放到遠端server上的敏感資訊。例如:密碼、資料庫環境、或是log檔等。

#Ignore database.yml , application.yml
/config/database.yml
/config/application.yml

3.將程式放上GitHub。
3.1.GitHub上要先建立一個空的程式庫,命名為rails101。
3.2 GitHub上要設定sshkey,以作為Local端和GitHub互傳資料的信任憑證。
3.3 Local端輸入

git init      #Local端建立git程式庫
git add .     #將異動都加進來
git commit -m  "部署程式"    #commit異動
git remote add origin git@github.com:phileiny/rails101.git  #設定git和遠端的那個程式庫連接
git push -u origin master   #把程式丟到GitHub上 origin是指遠端程式庫   master是指local端的分支名稱

3.在AWS上建立一個instance。(請參照Deploy Your Rails App to AWS )

Server端

1.連上 server

ssh -i "rails101.pem" ubuntu@52.104.107.65 

2.更新 package

sudo apt-get update && sudo apt-get -y upgrade

3.建立佈署程式的使用者
3.1建立一個使用者名為deploy,且它的根目錄在 /home/deploy下

sudo useradd -d /home/deploy -m deploy

待會程式就要部署在/home/deploy這個目錄下。
3.2設定deploy這個user的密碼

sudo passwd deploy

3.3將deploy這個user加入 sudouser中,deploy因此有Sudo的權限(Sudo可以執行系統管理者才能執行的一些指令)。執行

sudo visudo

然後將這行

deploy ALL=(ALL:ALL) ALL

貼在檔案裡,之後存檔。
4.製作deploy的public ssh key,以供之後部署時從GitHub抓程式用

su - deploy  # 切換到 deploy這個角色 (打密碼),以下的操作都是以deploy這個角色執行。輸入exit可回到ubuntu這個角色。
ssh-keygen #這會產生 deploy的 public key ,檔案是.ssh/id_rsa.pub
cat .ssh/id_rsa.pub #顯示 public key

將public key複製後,貼到 GitHub的ssh設定裡,設定位置在在github右上角,ViewProfile and more 按下去後-settings。左邊 ssh keys那兒。
5.將 Local的public key ,Copy到 Server .ssh/authorized_keys 裡

Local 端:  cat .ssh/id_rsa.pub  
Server 端: nano  .ssh/authorized_keys

nano的基本操作: Ctrl + O =寫入 Ctrl +X = 離開
6.安裝 Git

sudo apt-get install git

7.安裝 Nginx

sudo apt-get install nginx

8.設定 Nginx

sudo nano /etc/nginx/sites-available/default

將以下code複製貼上

upstream app {
  # Path to Puma SOCK file, as defined previously
  server unix:/home/deploy/rails101/shared/tmp/sockets/puma.sock fail_timeout=0; 
}

server {
  listen 80;
  server_name localhost;

  root /home/deploy/rails101/current/public;    #為了這行,曾try false兩天,參考的文章沒寫 current。assets出不來 xd

  try_files $uri/index.html $uri @app;

  location / {
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Connection '';
    proxy_pass http://app;
  }

  location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;
}

9.安裝 PostgreSQL資料庫

sudo apt-get install postgresql postgresql-contrib libpq-dev 

這會安裝postgreSQL資料庫Server,並預設postgres是admin的角色
10.建立Production用的資料庫

sudo -u postgres createuser -s rails101   # 以postgres這個角色建立一個使用者名稱為rais101,擁有admin的權限。

11.更改rails101這個使用者的密碼
先切換到psql的console模式

sudo -u postgres psql

在console模式下執行

postgres=# \password rails101

設定完後,\q離開
12.安裝production的資料庫

sudo -u postgres createdb -O rails101 rails101_production  #資料庫名稱 rails101_production ,使用者名稱 rails101

13.安裝 Ruby+Rails
13.1安裝 RVM (部署Ruby和Rails的工具)

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 #匯入gpq金鑰
\curl -sSL https://get.rvm.io | bash -s stable  #安裝RVM

13.2執行 echo 'source /home/patrick/.rvm/scripts/rvm' >> ~/.bashrc
13.3執行 exit。 關閉shell,重新登入使用者帳號,系統會自動啟動 rvm
13.4執行 rvm requirements,系統會自動安裝Ruby需要的套件
13.5rvm list known,查可安裝的ruby版本
13.6rvm install 2.2.0,安裝Ruby,此例是安裝ruby2.2.0
13.7安裝Rails
13.71rvm gemset create rails425,建立一個新的 Gemset,目的是讓不同的 Ruby 版本裡面裝的 Gem 套件不會互相干擾
13.72rvm use 2.2.0@rails425 --default, 每次開機都指定用這個 Ruby 版本。
13.73gem update --system,更新 Gem
13.74echo 'gem: --no-rdoc --no-ri' > ~/.gemrc,節省時間不安裝 RDoc 文件
13.75查所有rails版本點此
13.76gem install rails -v 4.2.5,安裝rails,此例是安裝rails4.2.5
13.note ruby -v查ruby版本 which ruby:ruby安裝目錄,rails同理。

14.試著將程式從github clone下來

git clone git@github.com:phileiny/rails101.git  #phileiny是 github上的使用者名稱, rails101.git是github上的程式庫名稱

15.新增server端的database.yml

mkdir -p rails101/shared/config   #因為版本控制的關係,原本的config資料夾會被指到 shared/config
nano rails101/shared/config/database.yml  #修改production環境的資料庫設定
production:
  adapter: postgresql
  encoding: unicode
  database: rails101_production   #步驟12建立的資料庫名稱
  username: rails101              #步驟12建立的使用者名稱
  password: rails101              #步驟12建立的密碼
  host: localhost
  port: 5432

16.新增server端的 application.yml
16.1 產生secret code

cd rails101
bundle install
rake secret  #這會產生secret code,把它copy起來

16.2 nano rails101/shared/config/application.yml

SECRET_KEY_BASE: ""  #把剛才copy的secret code貼到" "中

17.檢查Local端 config/deploy/production.rb中的ip設定

server '52.104.107.65', user: 'deploy', roles: %w{web app db}   #這裡的ip要換成你在AWS建立的instance的ip

Local端切換到專案目錄下

cd rails101

大膽的執行部署吧!

cap production deploy

Good luck!

常用指令

git push -u origin master  #把程式推到 server上
git pull   #把程式從 server上拉下來
sudo nano /etc/nginx/sites-available/default  #修改 default檔

設定  Nnginx
sudo /etc/init.d/nginx restart  #nginx重新啟動
cap production deploy   #部署程式
su - deploy            #切換到 deploy角色
sudo -u postgres createuser -s rails101  #以postgres角色建立新的使用者
sudo -u postgres psql           #以postgre角色切換到psql的console mode
cd /home/deploy/ifoo/current && ( export RACK_ENV="production" ; ~/.rvm/bin/rvm ruby-2.2.0 do bundle exec puma -C /home/deploy/ifoo/shared/puma.rb --daemon )  # puma 啟動

比特幣

比特幣是一種資產,也是一種貨幣,最後它是一個平台...

如何採礦

廢話不多說,沒耐心的讀者可以直接按此加入虛擬貨幣挖礦的行列,我的genesis-mining推广码是 : 8O9HfB。

什麼是比特幣

幾年前關心過比特幣的發展,它一直披著神秘的色彩,按此影片可以簡單的知道什麼是比特幣。簡單的說它是一種去中心化的貨幣,你也可以囤積它當做資產。基於虛擬貨幣開放及跨國際及去中心化的特性,你可以開發相關的應用, 當作是新創事業。例如經營比特幣礦池,開發比特幣錢包,成立比特幣交易中心,甚至是開比特幣賭場。

如何擁有比特幣

最直接的方式就是花錢買,你可以先在MaiCoin開戶,註冊時,密碼要包含大寫英文、小寫英文,以及數字,我曾在填密碼時卡關,去電客服後解決。


登入後,要先到左方設定自己的轉入銀行帳號,以及一些基本資料。可先買賣小筆金額比特幣測試它的功能。買和賣的差價大約是3%,也就是說,比特幣要漲3%,你賣掉時才會有利潤。不過第一次買會先送你大概價值100元的比特幣(點上面連結,交易金額大於500),當作是獎勵。
第二直接或有點冒險的方式,是投資礦池團隊。例如Genesis Mining
依照它上面的合約,初期投資成本是0.399美元 GH/s,之後每天的費用是0.00095美元每 GH/s。比特幣的算力可以參考Bitcoinwisdom

簡單算來,若投資台幣30000元,約可買到2.35TH/s的算力(終身),每日費用約2.2325(0.00095*1000*2.35)美元,每日收入約5.68美元,每日純收益約3.4美元,每月收益約102美元,九個多月左右可回本,看起來似乎相當不錯。當然這都是用目前當下的數字去算,挖礦的難度與日俱增,比特幣浮動的價格,以及虛擬市場潛在崩盤的威脅等,都是不穩定的因素。

結論

有閒錢,敢冒險,喜歡創新的朋友們馬上加入:genesis-mining來玩一玩(Grwoth 心法上身),記得要填上我的推薦碼: 8O9HfB,您可省下2.5%的費用。

附註 Genesis-mining合約中英文對照

翻得不好還請見諒
I (the "Customer") agree with the following terms and conditions for the provision of mining services (the "Agreement") made as of today
between :
我(這個"顧客")同意採礦服務(這個"協定")目前所訂的我們之間規定的條件和狀況如下:

1.Genesis Mining LTD, 3rd Floor, Par La Ville Place, 14 Par-la-Ville Road, Hamilton HM 08, Bermuda, ("Service Provider"); and
2.me, the Customer.

  1. Genesis Mining LTD,地址在 3rd Floor,Par La Ville Place, 14 Par-la-Ville Road, Hamilton HM 08, Bermuda, ("服務提供者")和
  2. 我,這個顧客

Pursuant to the terms of this Agreement, the Service Provider will make available to the Customer shares in the mining capacity of the Service Provider.

依照這個協定的條件,這個服務提供者會讓顧客分享這個服務提供者所擁有的採礦的能力。

  1. Services The Service Provider agrees to provide to the Customer with the output of its mining capacity (the "Services") subject to the following terms:

1.服務
這個服務提供者同意用以下的條件提供顧客它產出礦的能力(這個“服務”):

Available Technology: SHA-256 Hashing

Term: The contract has no fixed and predetermined end date.

Mining Power: 2.35 TH/s

Payout frequency: daily

Mining Output ("Coins"): as agreed between Service Provider and Costumer, and, where applicable converted from time to time, e.g., Bitcoin or other electronic currencies

提供的技術: SHA-256 Hashing
條件: 這份合約沒有確定和預先決定的結束日期
挖礦力: 2.35 TH/S
支付頻率: 每天
挖礦產出("錢幣"):依照服務提供者和顧客之間的同意,以及,可依時轉換的,例如:比特幣或其他電子貨幣

The Customer will be solely liable for the maintenance of the relevant technical equipment (software/hardware) that is required to receive the above service. The Customer will receive Coins mined in accordance with the above Mining Power and of applicable Fees as per 2.b. The Customer also acknowledges that the above Services will be rendered on a best effort basis (bestes Bemühen). The availability of the Mining Power and, accordingly, the output of Coins may vary up to a maximum of 5%. Otherwise, the Service Provider ensures that it maintains all facilities and the relevant supplies in good working order, in order to avoid any of the above volatility with the diligence that it applies in its own dealings (diligencia quam in suis).

顧客需要獨自且有義務的去維護相關技術設備(軟體/硬體),以便收到上述的服務。這個顧客會依據上述的算力收到錢幣,並且會被收取每b適當的服務費(每2.b(第二項的b條))。顧客並承認上述的服務會被Render到最佳化(bestes Bemühen拉丁語盡力而為)。這個算力的因此會讓錢幣的產出最高達到5%的不同。另外,這個服務提供者保證會維持所有設備和相關的供應在良好的工作秩序,以避免任何上述的不穩定影響到勤奮應用在它自己的工作中(diligencia quam in suis義大利文勤奮比)。

  1. Remuneration As a consideration for the Services the Customer agrees to pay to the Service Provider an amount of (the "Fee"):

2.酬金
考慮到這個服務,顧客同意付這個服務提供者一定金額的(“費用”)

a. 0.399 USD per GH/s upfront
b. USD 0.00095 per GH/s and day, deducted on a daily basis* from the generated Coins

a. 0.399 美金 每 GH/s 前期費用
b. 0.00095 每 GH/s 每天,以每天獲得的錢幣為基礎扣除。

  1. Limitation of Liability Without detriment to the Service Providers obligation to render the Services on a best effort basis, only, any liability of the Service Provider hereunder and or in connection with this Agreement shall be limited to willful misconduct (Vorsatz) and gross negligence (grobe Fahrlässigkeit). Further, the Service Provider shall not be liable for any damages incurred by the Customer as a result of force majeur which shall include any disruption or breakdown of a Coin market.

3.責任限制
在不損害服務的前提下,服務提供者義務將服務Render到最佳效能,服務提供商本協議的任何責任或與本協議有關的應僅限於故意的不當行為(Vorsatz德語目的),以及重大過失(grobe Fahrlässigkeit德語重大過失)。進一步,服務供應商對所發生的以客戶為不可抗力造成的損害,包括幣值市場的其中任何中斷或崩壞概不負責。

  1. Term
    a.This Agreement is entered into for the term indicated above.
    b.The Service Provider may terminate this Agreement with immediate effect if the Coins generated in the preceding 20 days do not suffice to pay the Fee under 2.b above.
    c.Otherwise, this Agreement may only be terminated by either party for good cause (aus wichtigem Grund).
    d.In the event of a termination for good cause by the Customer, and, for the avoidance of doubt in any such event, the Customer shall be entitled to a repayment of item 2.a above in the proportion of the time lapsed since the beginning of the Term divided by the Term.
    e.In case the Service Provider voluntarily agrees to refund the Customer, a processing fee of USD 10 will be deducted.

  2. 條件
    a.本協議訂立上述條件表示。
    b.服務提供商可以立即終止本協議,如果在前面20天產生的錢幣不足以支付下2.b
    上面的費用
    c.否則,本協議僅可通過任何一方的正當理由終止(AUS wichtigem Grund)。
    d.若顧客因發生事件有好的理由終止本合約,為了發生類似事件可能引起的爭議,顧客應再支付上述項目2.a的費用,計算方式以本條件為分母,已使用的時間為分子比例計算。
    e.在這樣的狀況下,服務提供者同意退款給顧客,10美元的處理費將被扣除。

  3. Communication
    All communication between the Service Provider and the Customer shall be made in writing which includes e-mail and other electronic messaging services (Textform).

  4. 通訊
    所有服務提供者和顧客的通訊應該被以E-mail和其他電子訊息服務(TextForm電子表單)的方式被記錄下來。

  5. Data Protection
    The Customer agrees to the processing of its personal data provided in the context of this Agreement for the purpose described herein and also agrees, until revocation at any time to the storage of its data beyond the above Term. Should the Service Provider be required to obtain any further data in the context of providing its services hereunder, the Customer will without undue delay provide the relevant data so required by the Service Provider

  6. 資料保護
    顧客同意它的個人資料在此協議為本文所描述的目的的範圍內可提供處理,也同意他的資料超出上述條件期限後,直到任何時間從儲存裝置撤銷前可提供處理。如果服務提供者需要在本文中獲得任何進一步的資料,以提供下文的服務,顧客不得無故拖延提供服務提供者需要的資料。

  7. Representations and Warranties
    The Customer represents and warrants to the Service Provider that he is familiar with mining, crypto currencies and Bitcoin in particular and that he understands the nature and uses of mining crypto currencies and Bitcoin.

The Customer further represents and warrants that he will be the beneficial owner of the Coins.

  1. 陳述和保證
    顧客對服務提供者陳述和保證他熟悉挖礦,特別是加密貨幣和比特幣,他也了解挖加密貨幣和比特幣的性質和用途。

  2. Credit Card Services through Credit Card Service Provider
    The following provisions under this section 8 only apply to the extent the Services are paid by credit card:

  3. 通過信用卡服務提供商提供信用卡服務
    在此第8條款之下的下列條款,僅適用於以信用卡支付服務的範圍:

The Service Provider uses third party services and such third party’s affiliates services which enable the Customer to place monetary deposits and perform transfer of payments within the website of the Service Provider by making use of the Customers existing credit card (as and if available and applicable) (the “Credit Card Services” and the “Credit Card Service Provider”). The Credit Card Services do not include any additional service, and such Credit Card Services do not Customers account.

服務提供者使用第三方的服務及其子公司的服務,使客戶可以把貨幣存款,通過利用客戶現有信用卡在服務提供者提供的網站內進行轉移支付(如果可用和適用的話)(“信用卡服務”和“信用卡服務提供者”)。信用卡服務不包括任何附加的服務,且信用卡服務不是顧客的帳戶。

The Service Provider may share and transfer (including cross border transfer) personal information with the Credit Card Service Provider for the purpose of rendering the Credit Card Services which will be made to Service Providers website via the use of the Customers credit card. The personal information will be shared with the Credit Card Service Provider after the Customer elects to execute such monetary payments by using the Credit Card Services of the Credit Card Service Provider. For the purpose of this section 8 personal information shall include information that identifies or may identify the Customer including the information submitted by the Customer through the registration form when you subscribe to the website such as the Customers E-mail address, country and city and/or information provided through social websites or any other identifying information provided by the Customer while using the Services of the Service Providers website.

服務提供者可以分享和轉移(包括擴境轉移)個人資訊,信用卡服務提供者為了提供翻譯信用卡的服務,通過使用顧客的信用卡,這樣的服務在服務提供者的網站被建立。個人的資訊會在選用這種貨幣支付方式,也就是顧客使用信用卡服務提供者提供的信用卡服務以後,被信用卡服務提供者分享。這第8項列出的目的,是要說明個人資訊應該包含顧客在訂閱這個網站時,在註冊表單上確認的資料,像顧客E-mail地址、國別、城市、以及(或是)通過社交網站提供的資訊,或任何在顧客使用服務提供者提供的網站服務時,由顧客提供的認證資訊。

In addition, the Service Provider may transfer any non-personal information provided by the Customer through the Customers use of the Services on the Service Providers website to the Credit Card Service Provider in order to allow the Credit Card Service Provider to perform preliminary examinations of non-personal information for the purpose of determining if the Customer is qualified to use the Credit Card Services of such Credit Card Service Provider (including the history of the Customers transactions on the website which will be provided without any identifying information and solely for the purpose examinations of the Credit Card Service Provider).

此外,服務提供者會轉移任何非個人的資訊,這些非個人的資訊通過顧客使用服務提供者的網站服務被提供給信用卡服務提供者,目的是讓信用卡服務提供者對非個人的資訊執行初步的檢驗,以決定顧客是否夠資格使用信用卡服務提供者提供的信用卡的服務(包括顧客在網站上的歷史交易,也會在不告知的情況下被提供,這僅是為了讓信用卡服務提供者可以檢驗)

By accepting these terms, the Customer represents that any and all information the Customer provides to the Service Provider is true and accurate. Any false or fraudulent information and/or use of the Services and/or Credit Card Services rendered to the Customer, is prohibited.

接受這些條件,代表顧客對他為服務提供者提供的所有資訊都是真實且是準確的。任何顧客提供的假的和騙人的資訊且/或對此服務且/或信用卡服務,都是禁止的。

The Customer is not obligated by law to provide the Service Provider and/or the Credit Card Service Provider with any personal information. The Customer hereby acknowledges and agrees that he is providing the Service Provider and/or the Credit Card Service Provider with personal information at his/her own free will, for the purposes of rendering the Services and/or Credit Card Services.

顧客沒有法律上的意務提供給服務提供者且/或信用卡服務提供者任何個人的資訊。顧客因此瞭解且同意,他提供給服務提供者且/或信用卡服務提供者他個人的資訊,是出自他/她的自由意願,為了讓服務提供者且/或信用卡服務可以正確翻譯。

By using the Credit Card Services the Customer hereby agrees and accepts that he will not be allowed and shall be prohibited from withdrawing any amounts that the Customer has deposited and/or is entitled to as a result of the Services rendered by the Service Provider for a period of 30 days. In case the payment by the Customer results in a charge-back or other material issues occur, the Service Provider is entitled to keep all existing, current and future Mining Output.

  1. Governing Law, Language and Miscellaneous This Agreement is governed by German law. To the extent permitted by applicable law the parties agree that the competent courts of Munich shall have non-exclusive jurisdiction to hear and determine any suit, action or proceeding, and to settle any disputes, which may arise out of or in connection with this Agreement This Agreement is made in the English language and this English language version of this Agreement shall be binding on the parties hereto and shall prevail over any translation of this Agreement provided that in the case of any German translation of a word or phrase in the text of this Agreement, such German translation of such word or phrase shall prevail

*if, on any day, Coins generated on one day do not suffice to pay item 2 of the Fee above, the Service Provider may use Coins generated on any day thereafter for such payment.

Simple_form-bootstrap

練習建Simple form和使用bootstrap


早上fork了一段rafaelfranca的simple_form-bootstrap來練習。 git clone https://github.com/rafaelfranca/simple_form-bootstrap.git 。bundle install後出現了如上圖的錯誤訊息。
Google大神拜了 30分鐘後,嘗試在Terminal下 : brew link openssl --force後,解決這個錯誤。
先記下來,還不知道解決的原理。
然後,在Terminal下 : rake db:migrate
出現 :Could not load database configuration
把 config\database.yml.example 更名為 config\database.yml之後即可