BC Blog

Chase Excellence, Success will Follow

0%

In order to reduce the frustration that I’ve encountered while installing oh-my-zsh on my new MacBook, I decided to write down this post to remind me of some steps that I need to beware.

Install ZSH from Homebrew

1
$ brew install zsh

Make sure the ZSH is running the Homebrew version, not the built-in one

1
$ which zsh

Should return the path /usr/local/bin/zsh not /bin/zsh

Install oh-my-zsh

1
$ curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh

Under /.zshrc file, we should add few more lines that include the following

.zshrc
1
2
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
export PATH="/usr/local/bin:$PATH" # Load the Homebrew version of commands

Run brew doctor if encounter any further problems, it will tell us what to do.

One-line backup command for MongoDB

1
mongodump --db <dbname>

One-line drop command for MongoDB Database.

1
$ mongo <dbname> --eval "db.dropDatabase()"

Then, we could easily resotre the backup folder that contains both BSON and JSON files.

1
$ mongorestore <folder_name> --db <dbname>

When deploying on Amazon EC2, we have to be careful about the instances we choose. RailsCasts has provided a screencast on how to deploy Rails application on EC2, but the default values are quite a mess.

First of all, default Instance is m1.medium for VM Image type, which is not free, so we have to set the YAML file to t1.micro according to Amazon Free Tier description.

1
2
image_type: t1.micro
image_id: 'ami-5e215b0c'

Besides, newly created account has only 5 limited Security Groups for us to set up, so we have to make sure the Rubber does not generate more than that number.

1
auto_security_groups: false

Somehow the multiple intances have trouble connecting to each other, we might want to config the pg_hba.conf file to allow IP connection.

1
2
host    all         all         172.XX.XX.XX/24   trust
host all all 172.XX.XX.XX/24 trust

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class PlayingCard
SUITS = %w{ clubs diamonds hearts spades }
RANKS = %w{ 2 3 4 5 6 7 8 9 10 J Q K A }

class Deck
def cards
@cards.to_enum
end

def initialize(n=1)
@cards = []
SUITS.cycle(n) do |s|
RANKS.cycle(1) do |r|
@cards << "#{r} of #{s}"
end
end
end
end
end

deck = PlayingCard::Deck.new
deck.cards << "JOKER!!" #=> FAIL!!

Playing around with this, knowing without the line cards.to_enum, I could actually input a new item in the array with ease, but sometimes we don’t want that. Therefore, given the enumerator like to_enum will allow for iterations through the array without absorbing changes.

While reading “The Well-Grounded Rubyist”, I found this topic quite interesting.

1
2
names = %w{ David Black Yukihiro Matsumoto }
e = names.enum_for(:select)

I could call enum_for on the object from which I want the enumerator to draw its iterations.

1
e.each { |n| n.include?('a') } #=> ["David", "Black", "Matsumoto"]

By calling upon .each method, I was able to allow the iterator to serve as a kind of front end to array’s select.

Sometimes I get a little confused about the difference between accessing an instance attribute via self.attribute and by @attribute, so one day I look up the stackoverflow to clear up my thoughts. The answers below are some good tips on the subject based on the site.

Here’s What the Best Answer Would Suggest

self.attribute calls the method attribute.
self.attribute = value calls the method attribute= with the argument value.
@attribute and @attribute = value get/set the value of the instance variable @attribute.

So basically they’re two entirely different things.

However if you call attr_accessor :attribute it defines the method attribute to return @attribute and the method attribute=(value) to set @attribute = value. So in that case, there is no difference.

The Comment is also Helpful

Note that it is generally recommended to use self. (unless you’re writing the getter/setter method) even if you currently have attr_accessor. This protects you from additional refactor work and bugs if you later change the accessor method(s) to do more than just get/set the instance variable. (Or if someone else patches or subclasses your work.)

Start the Resque Scheduler

1
$ bundle exec rake resque:scheduler

Start the Resque Worker for All Queues

1
$ QUEUE=* bundle exec rake environment resque:work

Build Local Gem

Sometimes it’s really neat to customize or fork some Gems from GitHub, and this is how I install my modified version of a Gem locally and install it at will.

1
2
3
4
5
$ gem build bootstrappers.gemspec
Successfully built RubyGem
Name: bootstrappers
Version: 0.2.3
File: bootstrappers-0.2.3.gem

Insall Local Gem

1
2
3
$ gem install ./bootstrappers-0.2.3.gem
Successfully installed bootstrappers-0.2.3.gem
1 gem installed

從產業現況出發,探討 ICT 應用如何發揮應有的價值 (鼎新電腦顧問)

產業現況與挑戰

  • 把產品的需求做出來是以前企業的主要利潤
  • 現在目標是增加接單能力,減少客戶流失率

客戶希望從產品得到的價值

  • 產品能幫客戶解決問題,才是有 價值 的產品
  • 設定議題 -> 因果分析 -> 歸納子議題 -> 訂出行動方案 -> 立下衡量指標 -> 持續監控
  • 縮短允交 (減少交案的期限,增加競爭力) OS: 聽起來像血汗工廠 Orz
    • 縮短訂單文件簽核
    • 排程甘特圖
    • 縮短原物料請購頻率
    • 按日生產計畫建立驗收優先程序
    • 合理銷售預測計畫排定
    • 提早掌握生產進度問題
  • BOM (Bill of Material) 表用來表達成品、半成品、材料組成和用量的關係

準時達交的問題行動方案

  • 掌握關鍵資源供給
  • 確保計畫落實執行
  • 強化急單應變能力

由創新創業談產業電子化之發展趨勢 (成大呂教授)

經營模式

  • 有時候先尋找 Venture Capital (創投公司) 可以是一開始創業的資金來源

問題與討論

  • 因為雲端才有臉書??? 這句話真詭譎…雲端應該是解決網路負載的 Bottleneck 才對…不然其實線上網路軟體的應用在以前其實也已經蠻多的了
  • 我覺得整體的軟體設計規劃才是台灣所欠缺的,並不是東西(功能)做出來就好了,還要考慮到使用者層面、架構層面(擴充延展性)、體驗層面等等…

If anyone wants to set up a few testing sites on only one IP server, we could modify the Nginx config file to open different port for servers deployment.

First, look for the config file

1
$ vi nginx/conf/nginx.conf

Then, take the below codes for sample.

nginx/conf/nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
server {
listen 180;
server_name localhost;
root /home/ruling/orbit_1/public; # <--- be sure to point to 'public'!
passenger_enabled on;
rails_env production;

location /static/ {
root /home/ruling/orbit_1/public;
}

location ~ ^/(assets)/ {
root /home/ruling/orbit_1/public;
expires max;
add_header Cache-Control public;
}
}

server {
listen 280;
server_name localhost;
root /home/ruling/orbit_2/public; # <--- be sure to point to 'public'!
passenger_enabled on;
rails_env production;

location /static/ {
root /home/ruling/orbit_2/public;
}

location ~ ^/(assets)/ {
root /home/ruling/orbit_2/public;
expires max;
add_header Cache-Control public;
}
}