Saturday, June 25, 2011

挑戰人生 享受人生

吳妍華也以自身經驗提醒畢業生,大學教育只是開啟對世界好奇的一把鑰匙。

她說,在擔任交大校長之前,對於交大擅長的電子、資訊領域可說是門外漢,但是擔任校長後,她把握每一次和專業人士對談及開會討論的機會,提出「好奇」,重新學習新的知識領域,因為未來還有很多需要學習的地方,培養主動獲取知識的軟實力,當機會來臨時,才能及時把握,創造無限可能。

另外,施振榮今天在畢業典禮上也以「挑戰人生、享受人生」為題,分享他的經驗與理念。

施振榮表示,在人生的過程中總會遇到許多困境與挑戰,但最重要的是要能享受追求人生價值的過程,同時在這過程中挑戰創造價值必經的困境,因為人生的目的就在於創造價值,並且不斷尋找瓶頸並加以突破。

他說,「挑戰困難、突破瓶頸、創造價值」,就是他一路走來的創業精神。



全文網址: 交大校長:勿只嚮往大老闆 | 即時新聞 | 生活天氣 | 聯合新聞網 http://udn.com/NEWS/LIFE/BREAKINGNEWS9/6420571.shtml#ixzz1QIs8x4BE
Power By udn.com

怪奇卡通風家具設計 - Straight Line Designs

Link: http://kaiak.tw/?p=79526 (sent via Shareaholic)

----
位於溫哥華的設計工作室 Straight Line Designs 已經成立超過 25 年,除了裝置藝術、雕塑創作以及接單專案之外,設計師...

Friday, June 24, 2011

xPath

XPath is an emerging standard for directly accessing one or more nodes in an XML document using a simple filename-like syntax. For example, the XPath "/*/author" would select all of the grandchildren named "author", starting the search at the top-level document. Electric XML includes a useful subset of XPath functionality, and supports the following special tokens:

name
matches all nodes on the current level with the specified name
[n]
matches the nth node on the current level, with n=1 denoting the first node
name[n]
matches the nth element on the current level with the specified name
*
matches all nodes on the current level
/
if used as the first character, denotes the top-level document, otherwise denotes moving down a level
..
go up one level
.
the current level
//
the current level and all sublevels to any depth
[@key='value']
all elements with an attribute that matches the specified key/value pair
name[@key='value']
all elements with the specified name and an attribute that matches the specified key/value pair
[text()='value']
all elements with the specified text
name[text()='value']
all elements with the specified name and text
@name
the attribute with the specified name
@*
all attributes

定位節點
XML
是樹狀結構,類似檔案系統內資料夾的結構,XPath也類似檔案系統的路徑命名方式。不過XPath 是一種模式(Pattern),可以選出 XML檔案中,路徑符合某個模式的所有節點出來。
例如要選
catalog底下的cd中所有price元素可以用: /catalog/cd/price
如果XPath的開頭是一個斜線(/)代表這是絕對路徑。如果開頭是兩個斜線(//)表示檔中所有符合模式的元素都會被選出來,即使是處於樹中不同的層級也會被選出來。
以下的語法會選出檔中所有叫做
cd的元素(在樹中的任何層級都會被選出來):
//cd

選擇未知的元素
使用星號(Wildcards,*)可以選擇未知的元素。
下面這個語法會選出
/catalog/cd 的所有子元素:
/catalog/cd/*
以下的語法會選出所有catalog的子元素中,包含有price作為子元素的元素。
/catalog/*/price
以下的語法會選出有兩層父節點,叫做price的所有元素。
/*/*/price
以下的語法會選擇出檔中的所有元素。
//*

要注意的是,想要存取不分層級的元素,XPath語法必須以兩個斜線開頭(//),想要存取未知元素才用星號(*),星號只能代表未知名稱的元素,不能代表未知層級的元素。

選擇分支
使用中括弧可以選擇分支。以下的語法從catalog的子元素中取出第一個叫做cd的元素。XPath的定義中沒有第0元素這種東西。
/catalog/cd[1]
以下語法選擇catalog中的最後一個cd元素:(XPathj並沒有定義 first() 這種函式喔,用上例的 [1]就可以取出第一個元素。
/catalog/cd[last()]
以下語法選出含有price子元素的所有/catalog/cd元素。
/catalog/cd[price]
以下語法選出price元素的值等於10.90的所有/catalog/cd元素
/catalog/cd[price=10.90]
以下語法選出price元素的值等於10.90的所有/catalog/cd元素 price元素
/catalog/cd[price=10.90]/price

選擇一個以上的路徑
使用Or運算元(|)就可以選擇一個以上的路徑。例如:
/catalog/cd/title | catalog/cd/artist
選擇所有title以及artist元素
//title | //artist
選擇所有title以及artist以及price元素
//title | //artist | //price
選擇屬性
XPath中,除了選擇元素以外,也可以選擇屬性。屬性都是以@開頭。例如選擇檔中所有叫做country的屬性: //@country
選擇所有含有country這個屬性的cd元素: //cd[@country]
以下語法選擇出含有屬性的所有cd元素 //cd[@*]
以下語法選擇出country屬性值為UKcd元素 //cd[@country='UK']
其他

所有,且其Attribute是qty>3 或price>400 descendant::Item[@qty>3 or @price>400]"

只要掌握了xpath語法,理論上你就可以訪問xml檔中的任意節點和任意值

AutoHotkey--Window平台下的使用- 注重長遠天天積累cqujsjcyj - ITeye技術網站

AutoHotkey--Window平台下的使用- 注重長遠天天積累cqujsjcyj - ITeye技術網站

Wednesday, June 22, 2011

descriptor:使用命令列上傳 google 文件 - 樂多日誌

descriptor:使用命令列上傳 google 文件 - 樂多日誌

evolution of python

ref: https://gist.github.com/289467

#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)


#First year programmer, studied Pascal
def factorial(x):
result = 1
i = 2
while i <= x:
result = result * i
i = i + 1
return result
print factorial(6)


#First year programmer, studied C
def fact(x): #{
result = i = 1;
while (i <= x): #{
result *= i;
i += 1;
#}
return result;
#}
print(fact(6))


#First year programmer, SICP
@tailcall
def fact(x, acc=1):
if (x > 1): return (fact((x - 1), (acc * x)))
else: return acc
print(fact(6))


#First year programmer, Python
def Factorial(x):
res = 1
for i in xrange(2, x + 1):
res *= i
return res
print Factorial(6)


#Lazy Python programmer
def fact(x):
return x > 1 and x * fact(x - 1) or 1
print fact(6)


#Lazier Python programmer
f = lambda x: x and x * f(x - 1) or 1
print f(6)


#Python expert programmer
import operator as op
import functional as f
fact = lambda x: f.foldl(op.mul, 1, xrange(2, x + 1))
print fact(6)


#Python hacker
import sys
@tailcall
def fact(x, acc=1):
if x: return fact(x.__sub__(1), acc.__mul__(x))
return acc
sys.stdout.write(str(fact(6)) + '\n')


#EXPERT PROGRAMMER
import c_math
fact = c_math.fact
print fact(6)


#ENGLISH EXPERT PROGRAMMER
import c_maths
fact = c_maths.fact
print fact(6)


#Web designer
def factorial(x):
#-------------------------------------------------
#--- Code snippet from The Math Vault ---
#--- Calculate factorial (C) Arthur Smith 1999 ---
#-------------------------------------------------
result = str(1)
i = 1 #Thanks Adam
while i <= x:
#result = result * i #It's faster to use *=
#result = str(result * result + i)
#result = int(result *= i) #??????
result str(int(result) * i)
#result = int(str(result) * i)
i = i + 1
return result
print factorial(6)


#Unix programmer
import os
def fact(x):
os.system('factorial ' + str(x))
fact(6)


#Windows programmer
NULL = None
def CalculateAndPrintFactorialEx(dwNumber,
hOutputDevice,
lpLparam,
lpWparam,
lpsscSecurity,
*dwReserved):
if lpsscSecurity != NULL:
return NULL #Not implemented
dwResult = dwCounter = 1
while dwCounter <= dwNumber:
dwResult *= dwCounter
dwCounter += 1
hOutputDevice.write(str(dwResult))
hOutputDevice.write('\n')
return 1
import sys
CalculateAndPrintFactorialEx(6, sys.stdout, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)


#Enterprise programmer
def new(cls, *args, **kwargs):
return cls(*args, **kwargs)

class Number(object):
pass

class IntegralNumber(int, Number):
def toInt(self):
return new (int, self)

class InternalBase(object):
def __init__(self, base):
self.base = base.toInt()

def getBase(self):
return new (IntegralNumber, self.base)

class MathematicsSystem(object):
def __init__(self, ibase):
Abstract

@classmethod
def getInstance(cls, ibase):
try:
cls.__instance
except AttributeError:
cls.__instance = new (cls, ibase)
return cls.__instance

class StandardMathematicsSystem(MathematicsSystem):
def __init__(self, ibase):
if ibase.getBase() != new (IntegralNumber, 2):
raise NotImplementedError
self.base = ibase.getBase()

def calculateFactorial(self, target):
result = new (IntegralNumber, 1)
i = new (IntegralNumber, 2)
while i <= target:
result = result * i
i = i + new (IntegralNumber, 1)
return result

print StandardMathematicsSystem.getInstance(new (InternalBase, new (IntegralNumber, 2))).calculateFactorial(new (IntegralNumber, 6))

##HIDEME##