推薦軟硬體、網站

Google Adsense

aNobii網路書櫃

2009年8月2日 星期日

You Might Be A Physics/EE/CS major if ...

原文"You Might Be A Physics Major"的笑話,相信一些人在網路上看過了。這次的創作結合物理/電機/資工三系中英對照,再重貼一次。
Physics版本的國外作者無法考證,EE版本的作者是iPluto,CS版本的作者是ryanlei,分別用不同的套色來區分,共27條:

YOU MIGHT BE A PHYSICS MAJOR…
你可能主修物理
YOU MIGHT BE AN EE MAJOR…
你可能主修電機
YOU MIGHT BE A CS MAJOR…
你可能主修資工

[1]
if you have no life – and you can PROVE it mathematically.
如果你沒有生活可言,而且你可以用數學證明這件事
if you have no life - and you can VERIFY it with Matlab simulation.
如果你沒有生活可言,而且你可以用Matlab模擬來確認
if you have no life - and you can DEMONSTRATE it with a finite state machine.
如果你沒有生活可言,而且你可以用finite state machine來演示這個情況

[2]
if you enjoy pain.
如果你享受痛苦
if you enjoy stress.
如果你享受壓力
if you enjoy deadlines.
如果你享受死線

[3]
if you know vector calculus but you can’t remember how to do long division.
如果你會向量微積分卻忘了怎麼作長除法
if you can write C programs but you can’t remember how to write English essays.
如果你會寫C程式卻忘了怎麼寫英文作文
if you can compute shortest paths but you can't remember how to find the path home.
如果你會計算最短路徑,卻忘了怎麼找回家的路徑

[4]
if you chuckle whenever anyone says “centrifugal force.”
每當聽到有人提到向心力你都會偷笑
if you chuckle whenever anyone says they eat at “MOS.”
每當有人提到他們在MOS吃飯你都會偷笑 (摩斯漢堡)
if you chuckle whenever anyone says they need a “driver.”
每當有人提到他(她)需要一個司機你都會偷笑 (驅動程式)

[5]
if you’ve actually used every single function on your graphing calculator.
如果你的繪圖式計算機的每個功能你都用過
if you’ve actually used every single tool on your workstation.
如果工作站上的每個工具你都用過
if you've actually read every single manual on your operating system.
如果你作業系統裡的每篇說明手冊你都讀過

[6]
if when you look in a mirror, you see a physics major.
如果你照鏡子,會看到一個主修物理的人
if when you look in a mirror, you see an EE major.
如果你照鏡子,會看到一個主修電機的人
if when you look in a mirror, you see a CS major.
如果你照鏡子,會看到一個主修資工的人

[7]
if it is sunny and 70 degrees outside, and you are working on a computer.
如果外面是華氏70度的大晴天,而你在電腦前工作 (約攝氏21度)
if it is sunny and 70 degrees outside, and you are working at the workstation.
如果外面是華氏70度的大晴天,而你在工作站工作
if it is sunny and 70 degrees outside, and you are playing with your computer at the dormitory.
如果外面是華氏70度的大晴天,而你在宿舍裡玩電腦

[8]
if you frequently whistle the theme song to “MacGyver.”
如果你常常用口哨吹馬蓋先的主題曲
if you frequently transform the theme song of “MacGyver” to frequency domain.
如果你常常把馬蓋先的主題曲轉換到frequency domain
if you frequently compute the time complexity of singing the theme song to “MacGyver.”
如果你常常計算唱馬蓋先主題曲的時間複雜度

[9]
if you always do homework on Friday nights.
如果你都在禮拜五晚上寫作業
if you always do designing on Friday nights.
如果你都在禮拜五晚上設計東西
if you always do projects on New Year's Eves.
如果你都在跨年的晚上趕project

[10]
if you know how to integrate a chicken and can take the derivative of water.
如果你知道如何把一隻雞積分並且計算水的微分
if you know how to layout a chicken and find the step response of water.
如果你知道如何lay一隻雞並求得水的step response
if you know how to encode a chicken and decode water.
如果你知道如何將一隻雞編碼和將水解碼

[11]
if you think in “math.”
如果你用數學來思考
if you think in “circuits.”
如果你用電路來思考
if you think in “bits.”
如果你用位元來思考

[12]
if you’ve calculated that the World Series actually diverges.
如果你曾經計算出世界大賽其實會發散 (Series是級數)
if you’ve actually tried to design a potato chip.
如果你曾經試著去設計一塊洋芋片 (chip是晶片)
if you believe that the main function of the Central Bank is to return 0;
如果你相信中央銀行的主要功能是回傳0 (main function是主函式,通常回傳0)

[13]
if you hesitate to look at something because you don’t want to break down its wave function.
如果你猶豫過要不要看某件東西,因為你怕會破壞它的波函數
if you hesitate to touch something because you don’t want to short it to ground.
如果你猶豫過要不要碰某件東西,因為你不想把它接地
if you hesitate to take something because you don't want to cause errors when there are data hazards.
如果你猶豫過要不要拿某件東西,因為你不想在有data hazard的時候產生資料錯誤

[14]
if you have a pet named after a scientist.
如果你用科學家的名字幫你的寵物命名
if you have a pet named after a CAD tool.
如果你用CAD tool的名字幫你的寵物命名
if you have a pet named after a Linux application.
如果你用Linux程式的名字幫你的寵物命名

[15]
if you laugh at jokes about mathematicians.
如果你聽到數學家的笑話會笑
if you laugh at jokes about engineers.
如果你聽到工程師的笑話會笑
if you laugh at jokes about programmers.
如果你聽到程式設計師的笑話會笑

[16]
if the Humane society has you arrested because you actually performed the Schrodinger’s cat experiment.
如果你因為實際去作”薛丁格的貓”的實驗而被人道組織逮捕
if school administration has you arrested because you used computational sharing in the exams.
如果你因為在考試時使用computational sharing而被學校行政單位逮捕(就是互抄答案啦XD)
if the security guard has you arrested because you actually performed tree traversal algorithms.
如果你因為實際去跑了tree traversal演算法而被保全人員逮捕

[17]
if you can translate English into Binary.
如果你可以把英文翻譯成二進位
if you can design a circuit that translates English to Binary.
如果你可以設計一個能把英文翻譯成二進位的電路
if you can translate English into Huffman codes.
如果你可以把英文翻譯成Huffman code

[18]
if you can’t remember what’s behind the door in the science building which says “Exit.”
如果你忘記科學大樓上寫著”出口”的門後面是什麼
if you can’t remember what’s the correct result of LVS.
如果你忘記LVS正確的圖應該長怎樣了
if you can't remember what's the desired result of UVa Online Judge.
如果你忘記UVa Online Judge的理想結果是什麼

[19]
if you have to bring a jacket with you, in the middle of summer, because there’s a wind-chill factor in the lab.
如果你在炎炎夏日中必須帶一件外套,因為實驗室有所謂的wind-chill factor
if you have to bring a coat with you, in the middle of summer, because the air conditioning at workstation is freaking cold.
如果你在炎炎夏日中必須帶一件大衣,因為工作站的冷氣實在冷到不行
if you have to take off your coat, in the middle of winter, because there's a Wi-Fi “hotspot” in the lab.
如果你在酷寒的冬天必須脫掉一件大衣,因為實驗室裡有Wi-Fi無線網路”熱點”

[20]
If you are completely addicted to caffeine.
如果你對咖啡因完全上癮了
if you are completely addicted to 7-11 lunchboxs.
如果你對7-11的便當完全上癮了
if you are completely addicted to instant noodles.
如果你對泡麵完全上癮了

[21]
if you avoid doing anything because you don’t want to contribute to the eventual heat-death of the universe.
如果你為了不造成宇宙最終的熱寂而避免作任何事情
if you avoid doing anything because you don’t want to cause useless
power consumption in the system.
如果你為了不製造系統中無用的功率消耗而避免作任何事情
if you avoid doing anything because you don't want to raise the degree of multiprogramming in the system.
如果你為了不想提高系統中的degree of multiprogramming而避免作任何事情

[22]
if you consider ANY non-science course “easy.”
如果你覺得任何非科學的課很簡單
if you consider courses without ANY project “easy.”
如果你覺得任何沒有project的課很簡單
if you consider ANY physics course and MANY EE courses “difficult.”
如果你覺得任何物理課和許多的電機課很困難

[23]
if when your professor asks you where your homework is, you claim to have accidentally determined its momentum so precisely, that according to Heisenberg it could be anywhere in the universe.
如果你的教授問你你的作業在哪裡,你說你不小心精確決定了它的動量,根據測不準原理,它可能在宇宙的任一角落
if when your professor asks you where your project is, you claim to have accidentally chosen the wrong sampling frequency, thus perfect reconstruction is no longer available.
如果你的教授問你你的project在哪裡,你說你不小心選錯了取樣頻率,所以perfect reconstruction是不可能的
if when your professor asks you where your homework is, you claim to have accidentally submitted it with the UDP protocol, which does not guarantee reliable data transfer.
如果你的教授問你你的作業在哪裡,你說你不小心用了UDP通訊協定上傳,因此無法保證可靠資料傳輸

[24]
if the “fun” center of your brain has deteriorated from lack of use.
如果你頭腦裡”玩樂”的部份因為久未使用而退化
if the “sleep” center of your brain has deteriorated from lack of use.
如果你頭腦裡”睡眠”的部份因為久未使用而退化
if the “love” center of your brain has deteriorated from lack of use.
如果你頭腦裡”愛情”的部份因為久未使用而退化

[25]
if you’ll assume that a “horse” is a “sphere” in order to make the math easier.
如果你會為了簡化數學計算而把一匹馬假設成一個球體
if you’ll assume that a “horse” is a “blackbox” in order to simplify the designing process.
如果你會為了簡化設計流程而把一匹馬假設成一個黑盒子
if you'll assume that “horses” are a “class” in order to apply the concept of object-oriented programming.
如果你會為了實踐物件導向的概念而把馬假設成一個class

[26]
if you understood more than five of these indicators.
如果你看得懂以上的指標超過五條
if you understood more than 0101 of these indicators.
如果你看得懂以上的指標超過0101條
if you understood more than ('\r' % '\b') of these indicators.
如果你看得懂以上的指標超過('\r' % '\b')條

[27]
if you make a hard copy of this list, and post it on your door.
如果你把這份清單印出來,並貼在你的門上
if you copy this list and post it on your BBS board.
如果你把這份清單複製起來,並貼在你的BBS個版上
if you modify someone else's list and post it on their BBS board.
如果你修改別人的這份清單,並貼回他們的BBS個版上 (我是修改iPluto的EE版本XD)


※轉錄請附上本篇網址※

2009年4月25日 星期六

Skype 2.0 on AMD64 Ubuntu Linux 9.04

因為LazyScripts 0.1 alpha的一些bug,今天花了一整個下午研究Skype 2.0 on AMD64 Ubuntu Linux 9.04。

裝起來沒問題,但聲音卻總是搞不定,搞到最後居然發現解答如此簡單:

1. 直接安裝AMD64版本的Skype 2.0,不用繞行32-bit跟找一堆library,either從
a) 官方偷放的 http://www.skype.com/go/getskype-linux-ubuntu-amd64
b) MediBuntu http://packages.medibuntu.org/jaunty/
找skype-common 和 skype 套件,兩者都有AMD64版本。
2. 進Skype的選項 => 音效裝置

之前被騙很大 以為選default就可以
沒想到這就是問題點!DON'T CHOOSE THE DEFAULT!!
三個都改成 系統列音量控制 看到的第一個裝置

這時再按「測試音效」和「測試通話」,如果都可以,那恭喜Skype on Ubuntu AMD64就設定完畢了!


看來這種挫折是學Linux的必經之路orz

2009年3月19日 星期四

讓vim記得檔案上次編輯的位置

keywords: mac, vim, restore cursor, remember last editing line, viminfo, file marks

這個問題困擾我很久了。我Mac (OSX 10.5.6) 上的vim開啟時,總是沒有辦法記憶該檔案上次離開時的游標,可能是關鍵字不好下,google好幾次都沒成功。今天用 mac vim "file marks" ,終於在某大陸論壇找到答案了!就這麼簡單:

在~/.vimrc裡加上這行:

au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

如果想切成兩行,也可以在第二行首用\當作分隔記號寫成:

au BufReadPost * if line("'\"") > 0|if line("'\"")
\ <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif


That's it!

2009年3月9日 星期一

OpenOffice Writer 左右對齊 全形標點符號超出行尾邊界


Keywords: OpenOffice Writer, Chinese/Asian Punctuations, Punctuation Alignment, Justification.

Japanese and Korean users, this works for you, too!!

在OpenOffice Writer使用左右對齊(justification, left-right alignment)時,會發現剛好在行尾的全型標點符號,例如中文的 ',。、;?!' ,跑出左右對齊的邊界。其實一般對齊時,標點符號也會超出「頁面」的邊界,不過在編寫需要用到左右對齊的文件時,困擾比較嚴重。


*Solution:


選取修改範圍後(往往是全選) -> 格式 -> 段落 -> 亞洲語言排版式樣 -> 取消「行末附加標點符號」。
如果要允許標點符號出現在行首的話,可以再取消「顧及行首行末禁止使用字元的清單」。


Select the target text -> Format -> Paragraph -> Asian Typography -> Disable "Allow hanging punctuation".

You can optionally disable "Apply list of forbidden characters to the beginning and end of lines" to allow punctuation at line beginnings.




改好以後,就不會有標點符號跑到外面去的情況啦!輸出成PDF也更美觀了。
另外連結一篇龔維正網友詳細的文章,給大家參考。

2008年11月9日 星期日

[OS] Chapter3 -- Processes

http://www.csie.ntnu.edu.tw/~swanky/os/chap4.htm
http://www.csie.ntnu.edu.tw/~swanky/os/chap10.htm -> IPC
http://en.wikipedia.org/wiki/Process_(computing)
http://en.wikipedia.org/wiki/Scheduling_(computing):第一段


Process: the unit of work in most systems
包含:code section, data section, program counter, registers, stack, etc.
Program is a passive entity(是死的); Process is an active entity(是活的)
Processes of the same program: same text section, different data sections
Thread: a basic unit of CPU utilization
Threads of the same process: same code & data section, other resources.
<對照習題4.5, Fig.4.11,fork出child process時是複製data,
而產生新thread時是共享data。>

Process state: new, waiting, ready, running, terminated
Process control block (PCB) -- information representing a process:
1. Process state
2. Program counter
3. CPU registers
4. CPU-scheduling information
5. Memory-management information
6. Accounting information
7. I/O status information

Scheduling queues:
1. Job queue -- containing all processes in the system.
2. Ready queue -- those in memory that are ready to be executed.
3. Device queue -- processes waiting for that device.
<對照Fig.3.6看架構>

Schedulers:
1. Long-term scheduler (Job scheduler, Admission scheduler):
從Job Queue中挑選合適的Jobs,將其載入到Memory中(放進ready Q)準備執行。
a. 執行的頻率不高
b. 可控制degree of Multiprogramming
c. 可調和I/O Bound與CPU Bound Job比例混合
d. 適用於batch system,不適用於time-sharing, real-time systems。
2. Short-term scheduler:
從Ready Queue中挑選priority較高之process,使其獲得CPU的控制權。
a. 執行頻率很高
b. 必須非常快,否則浪費CPU time
c. 適用於所有系統
3. Medium-term scheduler:
當記憶體空間不足,且有高優先權之process需要memory時,
挑選某些process做"swapping"。
a. swap out: remove processes from memory to "reduce the
the degree of multiprogramming"
b. swap in: reintroduce the swapped-out processes
into memory
c. 可調和I/O bound與CPU bound Job比例
d. 適用Time sharing system

Context switch:
Save the state of old process and load the state of new process.

fork() system call: creates a new process
exec() system call: load a binary file into memory and execute
wait() system call: wait for child process to complete
exit() system call: process terminates
abort() system call: terminate execution of child process

Inter-Process Communication
Independent process -- can't affect or be affected by others
Cooperating process -- can affect or be affected by others
Advantages:
1. Information sharing
2. Computation speedup
3. Modularity
4. Convenience
Cooperating processes require an IPC mechanism:
1. Shared memory
2. Message passing
<對照study guide: ch10的補充>

Client-Server Communication
1. Remote procedure calls (RPC)
Client's Stub locates the server and packs parameters
Server's Skeleton unpacks parameters and performs procedures
<對照Fig3.28的流程>
2. Remote method invocation (RMI)
Java mechanism similar to RPC, except:
a. Invoking a method directly without a matchmaker.
b. Ordinary data structures without packaging(marshalling).

[OS] 證明:Shortest Job First [SJF] is the optimal scheduling algorithm


修改自 http://computing.dcu.ie/~humphrys/Notes/OS/processes.html

What is the optimal schedule?

In general, if in-order bursts are x1, x2, ..., xn, then:

For each dispatched process, waiting time = (好像計網概題目XD)
1st: 0
2nd: x1
3rd: x1 + x2
4th: x1 + x2 + x3
...
nth: x1 + x2 + ... + xn-1

=> Total waiting time
= (n-1) x1 + (n-2) x2 + ... + (2) xn-2 + (1) xn-1 + (0) xn

Obviously this sum is minimized if the xi's that are multiplied the most times are the smallest ones, i.e., x1 < x2 < ... < xn-1 < xn.
Thus, in non-preemptive scheduling, "Shortest Job First" (actually Shortest Next CPU burst) is optimal for the purpose of minimizing Average Waiting Time. #

算是個淺顯又不失嚴謹的證明法 希望有幫助囉^^
P.S.王家祥老師說他喜歡考這個。

[OS] Chapter5 -- CPU scheduling

http://www.csie.ntnu.edu.tw/~swanky/os/chap4.htm
http://en.wikipedia.org/wiki/CPU_Scheduling

Process execution consists of a "cycle" of CPU bursts and I/O bursts.
CPU-burst distribution follow a (hyper)exponential pattern.
=> I/O bound programs: many short CPU bursts(左半邊)
CPU bound programs: a few long CPU bursts(右半邊)

Recall process states:
new, waiting, ready, running, terminated

CPU scheduling decisions may take place when a process:
1. running -> waiting [I/O or event wait]
2. running -> ready [interrupt]
3. waiting -> ready [I/O or event completion]
4. running -> terminates
Scheduling under 1 and 4 is nonpreemptive.
Scheduling under 2 and 3 is preemptive.

Dispatcher transfers control of CPU to selected process, involving:
1. Context switching
2. Switching to user mode
3. Jumping to proper location in user program to 'restart' that program

Scheduling performance criteria/objectives:
[max]1. CPU utilization - CPU用在process執行的時間比率
[max]2. Throughput(產能) - 單位時間內完成的工作數量
[min]3. Turn around Time - submission ~ completion
[min]4. ★Waiting Time - total/average waiting time in "ready queue"
[min]5. Response Time - submission ~ 1st response
在time-sharing system及user-interactive system中特別強調
其他目標:
# Fair(排班時儘量要求公平)
# No Starvation(避免飢餓)
# Support "priority" scheduling
# Resource Utilization ↑

Scheduling algorithms: [建議study guide整段全看]
1. First-come, first-served (FCFS):
Long average waiting time
Convoy effect(護衛效應) -- lower CPU and I/O utilization

2. Shortest-job-first (SJF): [證明是optimum]
Actually "shortest next CPU burst"
Difficulty: next CPU burst難以估計 -> used in long-term scheduling
[變種1] Approximate SJF:
Exponentially Weighted Moving Average (EWMA)
τn+1 = (α)tn + (1-α)τn
= (α)tn + (1-α)(α)tn-1 + ... + (1-α)^n(α)t0 + (1-α)^(n+1)*τ0
{α=1/2} = 1/2tn + 1/4tn-1 + ... + 1/2^(n+1)t0 + 1/2^(n+1)τ0

Non-preemptive SJF -- SJF (Shortest Job First)
[變種2] Preemptive SJF -- SRTF (Shortest Remaining Time First)
若其剩餘的CPU burst time大於新到達的process之CPU burst time,
則此process會被迫放棄CPU,交由新process執行。

3. Priority:
也可分為non-preemptive和preemptive
關鍵在於priority value的定義方式: internal vs external
SJF是一種priority scheduling -- Priority is the "next CPU burst"
FCFS是一種priority scheduling -- Priority is the "arrival time"
Problem: Starvation -- Low priority processes may never execute.
(易發生在unfair,甚至加上preemptive的環境)
=> Solution: Aging -- 隨著時間經過逐漸提高該process的priority

4. Round-robin (RR):
Time quantum: q
若未能在q內完成工作,則此process會被preempt掉,排到ready queue的尾端。
Time-sharing system使用RR
q too large => 趨近FCFS
q too small => overhead of context switching
Typically, higher turnaround than SJF, but better response. (fair)
Time quantum愈多 => context switch愈多,但與turnaround time並無明顯相關。

5. Multi-level queue:
將單一ready queue分成許多不同優先權等級的ready queues
每個Queue中可有自己的排班法則,如:foreground:RR, background: FCFS。
不允許process在各個queue中移動(沒有feedback)
Queue與queue之間的scheduling: fixed priority, priority time slice.
Preemptive, possibility of starvation

6. Multi-level feedback scheduling
基本同[5],但Process可以在queue之間移動。
Still unfair, but prevent starvation
Design issues:
a. # of queues
b. Scheduling algorithms for each queue
c. 新Process進來該插到哪個queue
d. When to upgrade a process. e.g. Aging
e. When to downgrade a process. e.g. 在quantum內無法做完
設計上最為複雜

分類:
# Fair:
1. FCFS
2. RR
# No starvation:
1. FCFS
2. RR
3. Multilevel Feedback Queue
# Non-preemptive:
1. FCFS
2. SJF
3. Non-preemptive priority
# Preemptive:
1. SRTF
2. Preemptive priority
3. RR
4. Multi-level queue
5. Multi-level feedback queue

Multiple-processor scheduling: (assuming homogeneous systems)
1. Asymmetric multiprocessing: 有master-slave processors
2. Symmetric multiprocessing(SMP): self-scheduling
a. common ready queue; b. separate ready queues.
Process affinity -- attempt to keep running on the same processor
Load sharing: push migration -- process觀察後自主換排
pull migration -- idle processor拉waiting process
Symmetric multithreading[SMT] or Intel's hyper-threading[HT] --
One physical processor[PP], multiple logical processors[LP]

Real-time scheduling:
Hard real-time -- within a guaranteed amount of time
=> Resource reservation is needed
Soft real-time -- only receive higher priority

######################################
Algorithm evaluation methods:
1. Deterministic modeling
Input: a given algorithm, a predetermined workload
Output: Corresponding performance
優:simple and fast
缺:too specific
使用:舉例說明時;同樣程式可以一直跑;觀察趨勢再證明

2. Queuing models -- 排隊理論
Input: distribution of service time, process arrival time, etc.
Output: utilization, average queue, average waiting time, etc.
Little's formula:
n = λ * W
n:queue length; λ:arrival rate; W:waiting time (都是average)
優:compare algorithms
缺:只是理論估計,unrealistic,independent assumptions

3. Simulations -- Programming a model of the system
優:more accurate
缺:跑模擬費時,large storage,coding

4. Implementations -- Construct a read system
優:the most accurate way
缺:too costly, environment may change
Powered By Blogger

Google Analytics