民意調查顯示,平,PubSub的,pubsubhub,pubsubhubbub

2009年9月6日, prashant · 評論
提起下: 技術

的情況下,你是持懷疑態度,有一個在上面瘋狂的方法,在文章標題。 在高科技界,這是不可能,你沒有聽到pubsubhubbub的。 在快速的幾個月中,它一直談論的事情的前三名之一。 其他兩個分別是同態加密和谷歌 [ 1 ]。 回來到目前的職位 - 在標題上註明你從其他人的內容如何。 以下細節變得更加清晰,如果你能想像博客的事情發生,即使它們概念並不局限於博客。

投票是指在客戶端要求服務器,如果新的東西拿出的情況下。 經常要求更新,將始終是一個投票過於頻繁或過於頻繁的問題,但作為一個讀者指出, 在這裡 ,一個偉大的 ,投票的事情是該服務器不維護狀態。

平是指在發表文章時,您(或您的軟件)也更新了一些流行(中央)更新服務的情況下。 這裡的一些背景。

接下來是PubSub的發布/訂閱,最早的球場之一,因為它是站在這裡,埃文亨肖-普拉斯和凱蘭埃利奧特-麥克雷(72張幻燈片,但值得經歷)。 引人注目的例子,他們給了反對 - 在某一特定日期,FriendFeed上抓取Flickr的29​​0萬次,45754用戶得到最新的照片,其中6721的24小時訪問Flickr和可能潛在的“上傳照片。 請注意,他們提出的是不是一種新技術,為他們指出“革命性的新的20歲的技術”。 如果你的博客,然後使用XMPP的主要問題之一 - 存在數據的開銷,這可能是高達60-70%,可以減少很多。

pubsubhub代表發布訂閱樞紐和pubsubhubbub是一個協議,其中核心是pubsubhub的想法。 其中出版商(比如博客)更新樞紐(駐留“在雲的地方”,每個協議,可以推或拉,每協議,但在接下來的環節,可能是多個集線器,互相交談)鏈,樞紐到客戶端(比如讀者)它總是推模型。為pubsubhubbub起點, 這個頁面是好的,概述幻燈片都不錯。 曾經雄辯的阿尼爾·達什介紹, 這裡按鈕網頁。
另外兩個相關的讀取webhooks基本上是HTTP回調。 Github上使用它,所以貝寶付款IPN的異步通知,所以許多人。 相關的概念是rsscloud這又是PubSub的樞紐。 按照鏈接查看詳情。

你可能想知道,在這裡寫這些點是什麼,有兩個1。 這些東西都是值得了解,微創至少2。 這個博客是通過Feedburner的,鏈接在這裡啟用pubsubhubbub通過appspot使用該WordPress中心現在啟用插件和飼料也是pubsubhubbub
-
[ 1 ]。 -很好的入門讀完全同態加密, 是由Bruce Schneier的文章, 這個講座是或多或少谷歌波浪的唯一來源。

更新- 這個職位說明公共服務器回調的要求如何可以工作的桌面客戶端周圍使用XMPP網關(pubsubhubbub為)。

有點集會

2009年8月29日, prashant · 評論
提起下: 技術

看完這篇文章有關鎖空閒緩衝區,看到使用了CAS(比較和交換),我發布的彙編代碼,做同樣的感覺。 使用的情況下,那邊是寫一個本地方法,並調用它從Java(1.5,當在Java並發數據結構不存在或多或少)。 事不宜遲,我會釋放到你的代碼 :) 首先是中科院和計算GCD的第二個是用歐幾里德算法(此人可以發現,在許多地方和教程以及)。

編譯和運行指示 gcc file_name.c ; ./a.out

比較和交換

   #包括 
  #包括 
 / /交換 -  newvalue,comperand是舊的/預期值
 / *
  *函數實際上做以下的事情 - 如果在* dest的值是等於oldvalue然後newvalue其他不改變它取代:做所有這些原子
  *
  *有兩個返回值的選項
  * 1.is初始值* dest的離開,調用fxn負擔比較與OLDVAL
  * 2。 在這裡做,並返回0或1,這應該是更有效
  ** /

 / *後來改變成宏* /
 INT CAS(INT * dest中,oldvalue,INT newvalue){
	輸出(“(%D,為%d,%d個)”,* dest中,oldvalue,newValue)以;
	 / * CAS(目的INT,INT oldvalue,newValue)以{* /
	 / * CAS(INT目的,newvalue INT oldvalue){* /
	結果= 1 ;/ * 1可以看出,CAS成功,0表示失敗* /
	 / * BTW需要設置標誌重挫CC!  * /
	 __asm​​__ __ volatile__(
			 “MOVL%2,%eax中\ N \ T”
			 “MOVL%3,%ebx中\ N \ T”
			 “MOVL%0%ECX \ N \ T”
			 “鎖\ N \ T”
			 \ N \ T“CMPXCHG%EBX(%ECX)”/ *應該鎖定在同一行* /
			 “JZ \ N \ T”
			 “MOVL $ 0%1 \ N \ T”
			 “DONE:\ N \ T”
			 “M”(DEST),“克”(結果)
			 :“G”(oldvalue),“G”(newValue)以“M”(DEST)
			 :“%eax中”,“%ebx中”,“ECX”,“CC”
			 );
	輸出(“(%D,為%d,%d個)”,* dest中,oldvalue,newValue)以;
	返回結果;
 }

 / *的TODO
  *寫在一個while循環以上fxn了另一個ASM fxn的不斷嘗試,除非它成功* /

詮釋的主要(){
	 A = 5,B = 6;
	 INT * C =(INT *)malloc的(如sizeof(int));
	 * C = 6;
	 / * C = 6 * /
	 printf(“請為%d \ N”,CAS(C,B,B));
	 printf(“請為%d \ N”,CAS(C,B,A));
	輸出(“%d個\ N”,CAS(C,A,A));
	 printf(“請為%d \ N”,CAS(C,B,B));
	 * C = 6;
	 / * C = 5; * /
	輸出(“變化值* C至%d條\ n”,* C);
	 printf(“請為%d \ N”,CAS(C,B,B));
	 printf(“請為%d \ N”,CAS(C,B,A));
	輸出(“%d個\ N”,CAS(C,A,A));
	 printf(“請為%d \ N”,CAS(C,A,B));
	 printf(“請為%d \ N”,CAS(C,B,A));
	返回0;
 }

格式化筆記 - 像WP語法高亮似乎增加 在年底,忽視這一點。

最大公約數

 #包括 
 GCD INT(INT A,INT B){
     int結果;
     / *計算最大公約數使用Euclid的算法* /
     __asm​​__ __ volatile__(“MOVL%1,%eax中;”
                           “MOVL%2,%ebx中;”
                           “cmpl續完:$ 0,%ebx中;”
                           “JE;
                          的“xorl%EDX,%edx中;”
                          的“idivl%EBX;
                           “MOVL%%EBX,EAX%;
                           “MOVL%%,%%ebx中EDX;
                           “JMP續完;
                           “DONE:MOVL%eax中,%0”:“克”(結果):(一)“G”,“G”(二)
     );

    返回結果;
 }

詮釋的主要(){
     int的第一,第二;
     printf的(“請輸入兩個整數:”);
     scanf函數(“%d的%d”,與第一及第二);

    輸出(“%d的%d的最大公約數是%d \ N”,第一,第二,GCD(第一,第二));

    返回0;
 }

板球的世界等待著一個新的世界秩序

2009年8月25日, prashant · 評論
提交下 MISC

經過一系列跨越五個測試和大約兩個月,英國再生骨灰。

讓我們的冠軍球隊的先談談 - 他們中間的順序是“平均”,如果你不想關鍵。 greame斯旺與蝙蝠的貢獻將計算不超過球的貢獻。 斯圖爾特 - 最廣泛多面手是第5次試驗的非起動。 安德魯·施特勞斯是一致的擊球手和吉米·安德森是唯一一致的投球手。

這裡的關鍵是沒有,痛斥冠軍球隊所取得的成就,但角度提出的事實,儘管所有這些,澳大利亞失去。 你想幾秒鐘,如果被問及他們的最佳投球手。 正確的,它是:體重Hilfenhaus。 hauritz跑贏everbody的期望,但仍然不夠好五個測試中的兩個選擇。 南非從來沒有一個世界級微調成為世界打漿機,澳大利亞不能希望仍然沒有一個足夠好的一個至少之一。 魔術師離開了舞台,它看起來並不像藝術了,忘了魔術。 龐廷高高聳立之間較小凡人和邁克爾·克拉克經常站起來,但是,使他們與一些非常優秀的球員,而不是一支非常好的球隊的隊。
骨灰2009會被記住安德魯Flintoff的最後灰燼,斯圖爾特廣泛的抵達1所有全才(如果他增加了一些灰燼民俗到他的前途開始),並在所有的時間最有說服力的首演由特洛特世紀,但它會也成為IFS和澳大利亞的優勢但是終於把休息點記住,這是結束了。 不要誤會,他們仍然可以挖掘邁克·赫西或斯圖爾特·克拉克,但你覺得所有偉大的貢獻,當他們失踪。 有時他們來提醒自己,你在彩光,但他們仍然無法替代的。 讓我們覺得沃恩,麥格拉思和Gilchrist一起玩支持由Waughs,龐廷,Hyden,馬丁和蘭格看到祝福。

展望未來,南非將始終保持一支非常好的球隊,但他們需要贏得半決賽和世界各地更加一致,巴基斯坦將保持神秘輝煌,印度年輕的槍可能會發現很難填補非凡的前輩的鞋。 斯里蘭卡應繼續顯示在工藝藝術的影子。 但是,我們可能不得不等待一段時間之前,有全力以赴主導的團隊或前一個隊長抱怨缺乏競爭,史蒂夫·沃做一次。

在一個相關的說明 - 讓我們歡迎的,阿西夫未來回來,他有1潛在的地獄了很多,讓我們的希望來看到的一些和也歡迎安迪的新awatar花,權利,你不能保持長久的好男人下來。

紅寶石1層,創建哈希

2009年8月20日, prashant · 評論
提起下: 技術

昨天,同時通過我的老節目之一,我發現我寫的一段時間回來:

#begin magic
hash=Hash[*CGI.unescape(raw_text).split('&').map{|x| b=x.split("=");b.push(nil) if b.size==1;b}.flatten]
#end magic

殺一些懸念,讓我透露,raw_text看起來像

 

,權利,它已被切斷,從Paypal付款確認。

如果在零件壞了上面的行讀取更好:

  unescaped_array CGI.unescape(raw_text)。分裂('&')
   = unescaped_array unescaped_array.collect {| X | B = x.split(“=”); b.push(零)如果b.size == 1;}
   flattened_array = unescaped_array.flatten
  哈希散列[* flattened_array] 

讓我們做在irb中的各個步驟:

  IRB(主):009:0> unescaped_array = CGI.unescape(raw_text)分裂('&')    

 => [“僑”,“mc_gross = 10.00”,“protection_eligibility =不合格”,“payer_id = U7PPJJ4TSJ47E”,“稅= 0.00”,“payment_date = 9點45分30秒2009年07月10日,PDT”,“PAYMENT_STATUS =待定“]                                                                         

 IRB(主):013:0> unescaped_array = unescaped_array.map {| X | B = x.split(“=”); b.push(零)如果b.size == 1;}  

 => [“僑”,無],[的“mc_gross”,“10.00”],[“protection_eligibility”,“不合格”,“payer_id”,“U7PPJJ4TSJ47E”],[“稅收”,“0.00”] [“payment_date”,“9點45分30秒7月10日,2009 PDT”],[“PAYMENT_STATUS”,“待定”。]]                               

 IRB(主):014:0> flattened_array = unescaped_array.flatten     

 =>“成功”,無“mc_gross”,“10.00”,“protection_eligibility”,“不合格”,“payer_id”,“U7PPJJ4TSJ47E”,“稅法”,“0.00”,“payment_date”,“09:45: 30日2009年07月10日,PDT“,”PAYMENT_STATUS“,”待定“]
 IRB(主):015:0>
哈希散列[* flattened_array]
 => {“稅”=>“0.00”,“PAYMENT_STATUS”=>“掛起”,“payer_id”=>“U7PPJJ4TSJ47E”,“mc_gross”=>“10.00”,“成功”=>“零”payment_date“= “九時45分三十秒07月10,2009 PDT”,“protection_eligibility”=>“不合格”} 

順便說一句,*被稱為紅寶石的圖示操作員

從“對數組的哈希創建的另一種方法是使用注:

 哈希= [1,2],[3,4]注入({})。{|結果,元素|結果element.first] =結果[element.last];結果} 

有一個方法 :) 寫一個循環,我會留給讀者作為練習!

這裡是位從陣列創建哈希無關的使用情況:

  IRB(主):005:0> [1,2,3,4,7,9] GROUP_BY {| X | X <5? 更低::更大}

 => {:較小的=> [1,2,3,4]:更大=> [7,9]} 

你可以做更多的事情,基本上塊的結果作為使用中產生的哈希元素的關鍵。

Gmail時,mutt和msmtp會修復

2009年8月17日, prashant · 評論
提起下: 技術

如果您使用mutt和SMTP訪問Gmail。 這裡是(壞)消息。 在谷歌酷哥再次改變證書。 哦,你問 - 如何知道? 簡單的小狗開始抱怨自己的證書時,嘗試使用的msmpt,臭名昭著的“msmtp會:TLS證書驗證失敗:證書還沒有得到一個已知的發行人 迎接我在屏幕上。

交叉確認 -
只要運行以下

$ msmtp --serverinfo --host=smtp.gmail.com --tls=on --port=587 --tls-certcheck=off

在地方老Thwate服務器現在你在發行人段
Issuer:
Common Name: Google Internet Authority
Organization: Google Inc
Country: US

幸運的修復很簡單,這裡是你需要做的在debian

# apt-get install ca-certificates
# dpkg -s ca-certificates|grep Version
Version: 20090814

在此之後只是改變下面一行在你〜/。msmtprc的

tls_trust_file /certs/Thawte SSLWeb Server Roots/thawte Premium Server CA/Thawte Premium Server CA.pem

tls_trust_file /certs/Thawte SSLWeb Server Roots/thawte Premium Server CA/Thawte Premium Server CA.pem



tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt

Git和真棒調查

2009年8月15日, prashant · 評論
提交下 MISC

這裡有兩個環節調查的git(版本控制系統)和真棒(窗口管理器)社區。 如果你使用這些,請拿出一些時間來填寫問卷。 把它看成是最簡單的方式回饋給您使用的軟件。
這裡是鏈接:

GIT - http://www.survs.com/survey?id=2PIMZGU0&channel=Q0EKJ3NF54

真棒- http://www.survs.com/survey?id=8BVEV3FO&channel=BH07CQ040D

注 - (由於在這些網頁上,但在底部發現 :) ) -
“如果你啟用了Cookie,你可以隨時提交部分填寫的調查,並在稍後時間回你的答案,完成以後。”

在YAML conf文件合併哈希

2009年7月31日, prashant · 評論
提起下: 技術

YAML是相當方便的編寫配置文件。 主要優點是,它像文本文件中讀取。 這個作品真的很好,如果你的配置文件是平坦的(不分層),並沒有重複。
如果您的配置文件中有重複,然後分離出這些元素和重用它們是有意義的。 我的意思是 - 讓我們說你的配置文件看起來像這樣:

 發展:
   input_location:common_input
   output_location:dev_location
  郵箱:
     smtp_server:您的服務器
    登錄:your_login
    密碼:top_secret
生產:
   input_location:common_input
   output_location:dev_location
  郵箱:
     smtp_server:您的服務器
    登錄:your_login
    密碼:top_secret 

假設上面的代碼在/ tmp / test.yml這裡你可以看到如何在Python和Ruby
$cat readyml.py

 #!的/ usr / bin中/ env的蟒蛇
從pprint為PP進口pprint
 #Debian中需要安裝python-YAML
從的YAML進口負載,load_all,轉儲
哈希=負載(開放(“/ TMP / test.yml的”))
 PP(哈希['發展']) 


$ cat readyml.rb

  #!/ USR / BIN / env的紅寶石
需要“PP”
哈希= YAML的::負載(的File.Open(“/ TMP / test.yml的”)。)
 PP哈希['發展'] 

這裡是一個方便的Ruby版本的班輪
$ ruby -rpp -e 'pp YAML::load(File.open("/tmp/a.yml"))["development"]'或者你可以嘗試在irb或Python控制台相同。

請注意,在上面的代碼片斷,一切都以外的輸出位置是相同的開發和生產的一部分。 這是YML節點標識符來搶救。 想法很簡單,有一組默認值和重寫他們在不同的地方。
你可以把它拆開如下:

 默認:與默認
   input_location:common_input
   output_location:dev_location
  郵箱:
     SENDER_NAME:發送方
     smtp_server:您的服務器
    登錄:your_login
    密碼:top_secret
發展:
   <<:*默認
生產:
   <<:*默認
   output_location:prod_location 


$ ruby -rpp -e 'pp YAML::load(File.open("/tmp/a.yml"))["development"]["mail"]["login"]'
"your_login"
$

偉大的,它的工作原理(TM)。
可以說,我們交易有點像魔術,一些清晰度。 這裡是一個小說明:&,*和<<: - 這是錨標記,可以理解為節點標識符,*是節點的參考和<<:哈希合併。

詳細內容見或者YAML規格維基
到目前為止,那麼好,但有一個陷阱,在這裡,這些哈希合併不是遞歸的。 它的意思是這樣的:讓我們說你要在兩個環境不同的郵件發送者的名字,你可能會受到誘惑,做到以下幾點:

 默認:與默認
   input_location:common_input
   output_location:dev_location
  郵箱:
     SENDER_NAME:發送方
     smtp_server:您的服務器
    登錄:your_login
    密碼:top_secret
發展:
   <<:*默認
  郵箱:
     SENDER_NAME:sender_dev
生產:
   <<:*默認
   output_location:prod_location
  郵箱:
     SENDER_NAME:sender_prod 

讓檢查

$ ruby -rpp -e 'pp YAML::load(File.open("/tmp/a.yml"))["development"]["mail"]["login"]'
nil
$

哎呀,出事了,上述問題是不是遞歸哈希合併,合併時,它取代默認的郵件,郵件只有一個關鍵的生產。 展開多層次的解決方案/工作大約是:

  common_settings:&common_settings
 input_location:common_input
 output_location:dev_location
 mail_defaults:&mail_defaults
  SENDER_NAME:發送方
   smtp_server:您的服務器
  登錄:your_login
  密碼:top_secret

默認:與默認
   <<:* common_settings
  郵箱:
     <<:* mail_defaults
發展:
   <<:*默認
生產:
   <<:*默認
  郵箱:
     <<:* mail_defaults
     SENDER_NAME:sender_prod

讓我們再次檢查

$ ruby -rpp -e 'pp YAML::load(File.open("/tmp/a.yml"))["development"]["mail"]["login"]'
"your_login"
$

你說你多了一個嵌套級別,你絕對可以展開一個級別,但後來它變成一個爛攤子。 所以,如果你不嘗試寫河內塔在conf文件的解決方案,它是更好地挖成YAML或別的東西restucture比conf文件。 但是,這是你的電話了。

偉大的程序員找到簡單的解決複雜問題

2009年6月30日, prashant · 評論
提交下 MISC

很長一段時間後,我能找到的源報價

初級程序員創建簡單的問題簡單的解決方案。 高級程序員創建複雜的解決方案到複雜的問題。 偉大的程序員找到解決複雜問題的簡單解決方案。

這是一篇文章,呼籲由查爾斯·康奈爾美麗的軟件

另一個我最喜歡的是Python的禪 -

美麗優於醜陋。
明確的是比隱含更好。
簡單比複雜好。
複雜的是比複雜。
平板是優於嵌套。
稀疏較密集更好。
可讀性罪名。
特殊情況下,是不是夠特別,打破規則。
雖然實用性擊敗純度。
錯誤應該永遠默默傳遞。
除非明確沉默。
在模糊的臉,拒絕猜測的誘惑。
應該有一個,最好只有一個顯而易見的方式做到這一點。
雖然這種方式可能起初並不明顯,除非你是荷蘭人。
現在是總比沒有好。
雖然從未往往比*權*現在。
如果實現是很難解釋的,這是一個壞主意。
如果實現是很容易解釋,它可能是一個好主意。
命名空間是一個鳴喇叭偉大的想法 - 讓我們做這些!
-------------------------
再有就是經典編程之道

-

學分鏈接網站

杰弗裡·詹姆斯譯

轉錄由杜克Hillard

轉交Anupam Trivedi,Sajitha Tampi和Meghshyam Jagannath

重新HTML化的和由Kragen Sittler的編輯

-

本書第1 - 寂靜的虛空

的編程大師如是說:

“當你已經學會從陷阱幀,搶奪錯誤代碼,
將是你離開的時候了。“

1.1

神秘的東西正在形成,出生在寂靜的虛空。 等待單獨與
一動不動,仍然是一次,但在不斷地運動。 這是源
所有的程序。 我不知道它的名字,所以我將它稱為陶
編程。

如果道是偉大的,那麼操作系統是巨大的。 如果操作系統
系統是偉大的,那麼編譯器是偉大的。 如果編譯器是偉大的,
然後,應用程序是偉大的。 用戶高興和存在
在世界的和諧。

編程之道流遠,早上風的回報。

1.2

道生機器語言。 機器語言誕生了
彙編。

生下彙編編譯器。 現在有一萬
語言。

每一種語言都有其目的,但謙虛。 每種語言都表達
以陰陽軟件。 每一種語言都有其內道的地方​​。

但不要用COBOL編程,如果你能避免它。

1.3

在開始時道。 陶生下了空間和時間。
因此,空間和時間是編程的陰陽。

總是不理解道的程序員的時間不多了
為他們的程序和空間。 程序員理解陶總是
有足夠的時間和空間來實現他們的目標。

否則怎麼會這樣呢?

1.4

聰明的程序員告訴陶,並遵循它。 平均
程序員告訴濤和它的搜索。 愚蠢的程序員
約陶告訴它笑。

如果不笑,就不會有陶。

最高聲音是最難聽到。
展望未來,是一種撤退。
偉大的天才,顯示自己在生命的晚期。
即使是一個完美的方案仍然有錯誤。

-------------------------

第2冊 - 古代大師

的編程大師如是說:

“經過三日不編程,生活變得毫無意義。”

2.1

老程序員是神秘而深刻。 我們無法捉摸
他們的想法,所以我們所做的一切是描述自己的外貌。

知道,像狐狸過水。 提醒,像一般上
戰場。 一種,像一個女主人,迎接她的客人。 簡單的,像
呆若木雞。 不透明的,就像在黑暗的洞穴黑池。

誰可以告訴他們的心和頭腦的秘密是什麼?

答案只存在於陶。

2.2

超級大師圖靈曾夢見自己是一台機器。 當他醒來時,他
驚呼:

“我不知道我是否圖靈夢見我是一台機器,或
做夢,我圖靈機!“

2.3

從一個非常大的電腦公司的程序員參加一個軟件
會議後,報告給他的經理,他說:“什麼樣
程序員的工作,為其他公司嗎? 他們表現不好,
與外表冷漠。 他們的頭髮長,蓬頭垢面,
衣服是滿臉皺紋,老。 他們墜毀好客套房和他們
在我的演講粗魯的聲音。“

經理說:“我應該讓你參加這次會議,。 那些
程序員生活在現實世界之外。 他們認為生活是荒謬的,
偶然的巧合。 他們來來去去,不知道的局限性。
無牽掛,他們只住他們的節目。 他們為什麼要打擾
社會習俗?

“他們是活在道。”

2.4

一個初學者問大師:“這是一個程序員,他從來沒有設計,
文件或測試他的程序。 然而,所有誰知道他,認為他是一個
在世界上最好的程序員。 這是為什麼?“

大師回答道:“那個程序員掌握了道。 他已經走了
超出了設計的需要;他不生氣時系統
崩潰,但接受的宇宙,而不用擔心。 他已經超越了
需要的文件;他不再在乎別人看到他的代碼。
他已經超越了需要進行測試,他的每一個方案是完美的
在自我,平靜而優雅,其目的不言自明。 誠然,
他已進入道的奧秘。“

-------------------------

本書3 - 設計

的編程大師如是說:

“程序被測試時,它是為時已晚,使設計
的變化。“

3.1

曾經有一個人去計算機展覽。 因為他的每一天
進入,該名男子在門口的警衛告訴:

“我是一個偉大的小偷行竊功勳聞名。
諒解,為這個貿易展會,不得逃避unplundered。“

這個講話擾亂警衛很大,因為有百萬
美元的計算機設備裡面,所以他仔細觀看的人。
這個人只是從一個攤位逛到另一個攤位,悄悄給自己哼唱。

該名男子離開時,警衛把他拉到一邊,搜查了他的衣服,但
什麼也沒有發現。

在展覽會的第二天,男子返回,並斥責衛兵
他說:“我逃昨天滿載而歸,但是今天我會連
更好。“所以警衛更加緊密地看著他,但無濟於事。

在展覽會的最後一天,警衛再也不能忍住他的好奇心
不再。 “小偷先生,”他說,“我很困惑,我不能住在
和平。 請賜教。 這是什麼,你偷了嗎?“

該名男子笑了​​。 “我在偷想法,”他說。

3.2

曾經有一位編程大師,誰寫非結構化的程序。
初學者刻意模仿他,也開始寫
非結構化的程序。 當初學者問大師評價他的
進步時,大師批評他寫非結構化的程序,
沒有適當的說,“什麼是適當的主
新手。 在超越結構化之前,你必須明白的道。“

3.3

曾經有程序員一名軍閥法院的
吳。 軍閥問程序員:“哪個更容易設計:
會計包或操作系統嗎?“

“操作系統”,這位程序員回答說。

軍閥發出一聲難以置信的驚嘆號。 “當然,會計
包旁邊的一個操作系統的複雜性是微不足道的,“他
說。

“事實並非如此,”程序員說,“當設計一個會計包,
程序員的工作作為一種人與人之間有不同的調停
思路:它必須如何運作,如何其報告中必須出現,以及如何就必須
符合稅法。 相反,一個操作系統不僅限於
外露面。 當設計一個操作系統,程序員
尋求最簡單的機器和思想之間的和諧。 這就是為什麼
操作系統是更容易設計。“

吳笑著說。 “那都是很好很好,但
這是更容易調試嗎?“

程序員沒有回答。

3.4

一位經理到編程大師,顯示了他的要求
一個新的應用程序文件。 經理問大師:“多久
將它設計這個系統,如果我給你5個程序員呢?“

“這將需要一年時間,”大師說。

“但我們需要這種系統立即或更早! 多久
採取如果我給你10程序員呢?“

編程大師皺起了眉頭。 “在這種情況下,這將需要兩年時間。”

“如果我給你一百個程序員呢?”

主程序員聳聳肩。 “然後設計將永遠
完成後,“他說。

-------------------------

書4 - 編碼

的編程大師如是說:

“一個精心編寫的程序是它自己的天堂;欠佳的書面程序
它自己的地獄。“

4.1

一個程序應該是輕靈,像一個子程序連接
字符串的珍珠。 應保留方案的精神和意圖
整個。 應該既不太少或太多,既不
不必要的循環也不是無用的變量,既不缺少結構,也不
至於僵硬呆板。

一個程序應該遵循最小驚訝“`”。 這是什麼法?
它僅僅是該計劃的方式向用戶應該總是回應
他至少讓人驚訝。

一個方案,不管多麼複雜,應作為一個單一的單位。 該方案
應直接由內部邏輯,而不是由外表。

如果該計劃未能在這些要求,這將是在一個國家
無序和混亂。 只有這樣,才能糾正這種改寫
方案。

4.2

一個初學者問大師:“我有一段時間運行一個程序,
有時中止。 我已經完全遵循編程的規則,但我
完全莫名其妙。 是什麼原因呢?“

主人回答說:“你困惑是因為你不明白陶。
只有傻瓜預計從他的同胞的人類理性的行為。 你為什麼
期望從一個人類建造的機呢? 計算機模擬
決定,只道是完美的。

“編程的規則是暫時的,只道是永恆的。 因此
你必須考慮濤之前收到的啟示。“

“但問:我怎樣才能知道當我收到的啟示呢?”
新手。

,“大師回答說:”你的程序將正常運行。

4.3

法師解釋道的性質,他的一個新手。
陶體現在所有的軟件 - 無論多麼微不足道,說:“
主。

初學者問:“是在一個手持計算器之道嗎?”。

“是的,”他回答說。

“是道,在視頻遊戲嗎?”持續的新手。

“即使是在一個視頻遊戲,”師傅說。

“道為一台個人電腦,在DOS”

主咳嗽,並略有改變他的位置。 “這個教訓是超過
今天,“他說。

4.4

王王子的程序員編寫的軟件。 他的手指跳舞後
鍵盤。 沒有錯誤信息,程序編制的程序
像一個溫柔的風跑。

“好極了!”王子感嘆道,“你的技術是無可挑剔的!”

說程序員轉向從他的終端,“我”技術?“
遵循的是道 - 超越了所有的技術! 當我第一次開始的節目,我
會看到我之前在一個大規模的問題。 三年後,我沒有
看到的是。 相反,我用的子程序。 但現在我什麼也看不見。
我的整個存在在無形無效。 我的感覺是閒置的。 我的精神,
自由地工作,沒有計劃,遵循自己的本能。 總之,我的程序
寫入本身。 誠然,有時也有難以解決的問題。 我看到他們
來了,我放慢,靜靜地觀察。 然後,我改變了一行代碼
和困難,像一陣輕煙消失。 然後我編譯
方案。 我坐不住了,並讓工作的喜悅。 關閉我的
一會兒眼睛,然後註銷。“

王王子說,“會,我的程序員都是明智的!”

-------------------------

預訂5 - 維護

的編程大師如是說:

“儘管一個程序,但三線長,總有一天它必須
保持下去。“

5.1

需要一個良好的使用門在鉸鏈上的油。
迅速流動的流不增長停滯。
無論是聲音和思想都不能在真空中傳播。
如果不使用軟件腐爛。

這些都是偉大的奧秘。

5.2

經理問程序員多久,會帶他來完成
程序上,他的工作。 “明天,將完成”
程序員及時回答。

“我想你是不切實際的,”經理說,“說實話,如何
需要多長時間?“

程序員想了一會兒。 “我有一些特點,我想
添加。 這將需要至少兩個星期,“他最後說。

“即使是太多期望,”經理堅持,“我一定會
滿意,如果你只是告訴我,當程序是完整的。“

程序員同意這一點。

幾年後,經理退休。 在他退休的方式
午餐時,他發現程序員在他的終端睡著了。 他曾
編程整夜。

5.3

曾經被分配到一個新手程序員編寫一個簡單的財務方案。

他瘋狂地工作了很多天,但是當他的主人檢討
他的計劃,他發現,它包含一個屏幕編輯器,一套
圖形程序,人工智能接口,但
沒有絲毫提及任何財務。

當主對此問,新手成為憤慨。 “不要
等的不耐煩了,“他說,”我最終把財務的東西。“

5.4

一個好的農民不會忽視他的莊稼?
一個好的老師不會忽視,即使最不起眼的學生嗎?
一個好的父親不會允許任何一個孩子挨餓?
一個好的程序員不會拒絕,以維護自己的代碼嗎?

-------------------------

預訂6​​ - 管理

的編程大師如是說:

“讓程序員是許多經理 - 那麼所有會
生產力。“

6.1

當經理們忙於無休無止的會議,程序員在寫遊戲。 何時
會計師談論季度盈利,即將開發預算
被削減。 當老科學家在談天空的藍色,雲是即將推出
英寸

誠然,這不是編程之道。

當管理者作出承諾,遊戲節目被忽略。 何時
會計師做長期計劃,是和諧和秩序
恢復。 當高級科學家處理手頭上的問題,
問題將很快得到解決。

Truly, this is the Tao of Programming.

6.2

Why are programmers non-productive?
Because their time is wasted in meetings.

Why are programmers rebellious?
Because the management interferes too much.

Why are the programmers resigning one by one?
Because they are burnt out.

Having worked for poor management, they no longer value their jobs.

6.3

A manager was about to be fired, but a programmer who worked for him
invented a new program that became popular and sold well. As a result, the
manager retained his job.

The manager tried to give the programmer a bonus, but the programmer
refused it, saying, “I wrote the program because I thought it was an
interesting concept, and thus I expect no reward.”

The manager upon hearing this remarked, “This programmer, though he holds
a position of small esteem, understands well the proper duty of an
employee. Let us promote him to the exalted position of management
consultant!”

But when told this, the programmer once more refused, saying, “I exist so
that I can program. If I were promoted, I would do nothing but waste
everyone's time. Can I go now? I have a program that I'm working on.”

6.4

A manager went to his programmers and told them: “As regards to your work
hours: you are going to have to come in at nine in the morning and leave
at five in the afternoon.” At this, all of them became angry and several
resigned on the spot.

So the manager said: “All right, in that case you may set your own
working hours, as long as you finish your projects on schedule.” The
programmers, now satisfied, began to come in at noon and work to the wee
hours of the morning.

————————————————————————–

Book 7 – Corporate Wisdom

Thus spake the master programmer:

“You can demonstrate a program for a corporate executive, but you can't
make him computer literate.”

7.1

A novice asked the master: “In the east there is a great tree-structure
that men call `Corporate Headquarters'. It is bloated out of shape with
vice presidents and accountants. It issues a multitude of memos, each
saying `Go, Hence!' or `Go, Hither!' and nobody knows what is meant. Every
year new names are put onto the branches, but all to no avail. How can
such an unnatural entity be?”

The master replied: “You perceive this immense structure and are
disturbed that it has no rational purpose. Can you not take amusement from
its endless gyrations? Do you not enjoy the untroubled ease of programming
beneath its sheltering branches? Why are you bothered by its
uselessness?”

7.2

In the east there is a shark which is larger than all other fish.
changes into a bird whose wings are like clouds filling the sky. When this
bird moves across the land, it brings a message from Corporate
Headquarters. This message it drops into the midst of the programmers,
like a seagull making its mark upon the beach. Then the bird mounts on the
wind and, with the blue sky at its back, returns home.

The novice programmer stares in wonder at the bird, for he understands it
not. The average programmer dreads the coming of the bird, for he fears
its message. The master programmer continues to work at his terminal, for
he does not know that the bird has come and gone.

7.3

The Magician of the Ivory Tower brought his latest invention for the
master programmer to examine. The magician wheeled a large black box into
the master's office while the master waited in silence.

“This is an integrated, distributed, general-purpose workstation,” began
the magician, “ergonomically designed with a proprietary operating
system, sixth generation languages, and multiple state of the art user
interfaces. It took my assistants several hundred man years to construct.
Is it not amazing?”

The master raised his eyebrows slightly. “It is indeed amazing,” he
said.

“Corporate Headquarters has commanded,” continued the magician, “that
everyone use this workstation as a platform for new programs. Do you agree
to this?”

“Certainly,” replied the master, “I will have it transported to the
data center immediately!” And the magician returned to his tower, well
pleased.

Several days later, a novice wandered into the office of the master
programmer and said, “I cannot find the listing for my new program.
you know where it might be?”

“Yes,” replied the master, “the listings are stacked on the platform in
the data center.”

7.4

The master programmer moves from program to program without fear. 沒有
change in management can harm him. He will not be fired, even if the
project is cancelled. 這是為什麼? He is filled with Tao.

————————————————————————–

Book 8 – Hardware and Software

Thus spake the master programmer:

“Without the wind, the grass does not move. Without software, hardware is
useless.”

8.1

A novice asked the master: “I perceive that one computer company is much
larger than all others. It towers above its competition like a giant among
dwarfs. Any one of its divisions could comprise an entire business. Why is
this so?”

The master replied, “Why do you ask such foolish questions? That company
is large because it is large. If it only made hardware, nobody would buy
它。 If it only made software, nobody would use it. If it only maintained
systems, people would treat it like a servant. But because it combines all
of these things, people think it one of the gods! By not seeking to
strive, it conquers without effort.”

8.2

A master programmer passed a novice programmer one day. The master noted
the novice's preoccupation with a hand-held computer game. “Excuse me,”
he said, “may I examine it?”

The novice bolted to attention and handed the device to the master. “我
see that the device claims to have three levels of play: Easy, Medium, and
Hard,” said the master. “Yet every such device has another level of
play, where the device seeks not to conquer the human, nor to be conquered
by the human.”

“Pray, great master,” implored the novice, “how does one find this
mysterious setting?”

The master dropped the device to the ground and crushed it underfoot. And
suddenly the novice was enlightened.

8.3

There was once a programmer who worked upon microprocessors. “Look at how
well off I am here,” he said to a mainframe programmer who came to visit,
“I have my own operating system and file storage device. I do not have to
share my resources with anyone. The software is self- consistent and
easy-to-use. Why do you not quit your present job and join me here?”

The mainframe programmer then began to describe his system to his friend,
saying “The mainframe sits like an ancient sage meditating in the midst
of the data center. Its disk drives lie end-to-end like a great ocean of
machinery. The software is as multifaceted as a diamond, and as convoluted
as a primeval jungle. The programs, each unique, move through the system
like a swift-flowing river. That is why I am happy where I am.”

The microcomputer programmer, upon hearing this, fell silent. But the two
programmers remained friends until the end of their days.

8.4

Hardware met Software on the road to Changtse. Software said: “You are
Yin and I am Yang. If we travel together we will become famous and earn
vast sums of money.” And so the set forth together, thinking to conquer
the world.

Presently they met Firmware, who was dressed in tattered rags and hobbled
along propped on a thorny stick. Firmware said to them: “The Tao lies
beyond Yin and Yang. It is silent and still as a pool of water.
not seek fame, therefore nobody knows its presence. It does not seek
fortune, for it is complete within itself. It exists beyond space and
time.”

Software and Hardware, ashamed, returned to their homes.

————————————————————————–

Book 9 – Epilogue

Thus spake the master programmer:

“It is time for you to leave.”

————————————————————————–

If you liked these, you may also like to read worse is better

有點shell重定向

2009年5月10日, prashant · 評論
提起下: 技術

這裡是如何,我們通常做shell重定向
$ ./pgm.sh args >out.txt 2>err.txt
我想稍作修改並運行如下
$ ./pgm.sh args
的要求,輸出和錯誤,應該去一些內pgm.sh計算上ARGS名。 一個典型案例,可能是當日期是ARGS部分。 所以,你想輸出到去說/ /目錄/ pgm_out_YYYYMMDD.txt 1,

N>file.txt ,即與標準的重定向方式的問題,關聯到File.txt文件描述符N是,它僅適用於新的分叉過程,而不是當前進程。
所以
$ echo hi 1>out.txt ; echo hii 。將發送您好out.txt但將打印HII到stdout 2 $ echo hi 1>out.txt ; echo hii

這是其中exec來拯救我們的。 如果我們加上exec 1>somefile.txt然後輸出從腳本的其餘部分將去somefile.txt

$ cat test.sh
#!/usr/bin/env bash
exec 1>out.txt
echo hi
echo hii
$。/ test.sh將重定向嗨以及作為HII out.txt

同樣重定向標準輸出以及標準錯誤,我們會做這樣的事情
cat test2.sh
exec 1>out.txt
exec 2>err.txt
echo out text
echo 1>&2 err text
somenoneexitent command
ls -ld /tmp

現在回來重定向從外殼內的一些文件的原始點,讓我們說方案計算中的一些變量OUTFILE文件名 ​​,我們可以有剛剛完成exec 1>$OUTFILE

能夠解決當前的問題。 但你可能想通過下面的示例實現“隨機存取”shell腳本文件。 這裡的例子是
echo 1234567890 > File # Write string to "File".
exec 3<> File # Open "File" and assign fd 3 to it.
read -n 4 <&3 # Read only 4 characters.
echo -n . >&3 # Write a decimal point there.
exec 3>&- # Close fd 3.
cat File # ==> 1234.67890

與評論,這個代碼是自明的。
-
1,它也可以通過$ ./pgm.sh args >pgm_out`date +%Y%m%d`但想法是生成此文件基礎上的一些程序本身的邏輯名稱。
2 1 1> out.txt是多餘的,但它在這裡澄清,我們重定向FD 1

Sony VAIO review

April 29, 2009 by prashant · 評論
Filed under: reviews

A month back I bought a vaio NS25G and have been planning to write this post since then. This post is primarily notes to self and review of the same. Let's get off the mark quickly -

Post has two parts -

I. Review of hardware
二。 Installing debian and things to setup

I. Review of hardware

Since I am not a VAIO marketing guy, I'll start other way round -

Why you may not like to buy this laptop :

  1. No bluetooth : believe me, in 2009 sony sells laptop without bluetooth. Sure you can use usb stuff but …
  2. Screen size is 15.4 inches : if you travel a lot then this laptop may not be very handy and also 2.9kg laptop is not exactly the lightest around.
  3. No HDMI output.
  4. No separate graphics card and the likes.(and no dedicated video memory

Now , why you may like to buy it :

  1. This laptop is a damn good desktop. What I mean is this if your requirement is like me – mostly writing programs and trying to use it 25 out of 24 hrs, then with a big screen , extremely comfortable keyboard layout with spacious palm rest and good compute power , it makes a very good combination.
  2. It L2 cache is 2MB and processor/memory system bus are 800MHz. I don't play games so can't say about that but for anything else but a core 2 duo processor with 2GHz freq is good, this is more than enough.
  3. From my usage, I see processor mostly clocks at 1.2GHz, and memory usage ~500MB. That just reinforces previous point.
  4. Battery backup is good, ~2 hrs is what I get.

Just one more thing here – being Sony, it will cost you a bit than other laptops with similar configuration, but that is a call u have to make.

II. Configuring linux (to run out of box ! ) :
It came pre installed with Vista( I think home premium or some fancy name like that). Dungara booted once and created another partition of 150 GB. Debian testing is what I always install and then up(down?)grade to 'unstable' sid.

Things which worked without any problem:

  1. X - unsurprisingly X server had not problem with starting or resolution. After one of the upgrades X refused to start though, but 'X -configure' generated a conf file which worked pretty well.
  2. Audio - Audio output and external mic work fine. kernel version 2.6.29-1-686 #1 SMP and alsa version 1.0.17. This is what you get from
    $ lspci -v |grep Audio 00:1b.0 Audio device: Intel Corporation 82801I (ICH9 Family) HD Audio Con1.0.17troller (rev 03)
  3. Video cam – just works
  4. Hibernate to disk and back – no problem
  5. Wireless - in short – just works.
    $ lspci |grep -i wireless
    03:13:55 04:00.0 Network controller: Atheros Communications Inc. AR928X Wireless Network Adapter (PCI-Express) (rev 01) .

    I think kernel 2.6..27 onwards it works with the stock kernel source. You dont have to install ndiswrapper or things like t
    hat. As a note, please say good buy gnome-network-manager and welcome wicd, it is just a gui layer but behind the scene they have fixed lot of config stuff like wpasupplient and more.

What doesn't work -

  1. Somehow internal mic refuses to work :( External mic works fine though. Latest alsa sources did not compile cleanly on debian, so for the time being I bought external Internal mic, will try to dig into it sometime in future though.

Few more misc hints for deiban:

  • Package for devnagri font- ttf-indic-fonts
  • Package for flash player – flashplugin-nonfree
  • Entry in sources.list for mplayer and likes – deb http://www.debian-multimedia.org sid main
  • Entry in sources.list for e17 – deb http://debian.alphagemini.org/ unstable main
  • Entry in sources.list for skype – http://download.skype.com/linux/repos/debian/ stable non-free

oneliner for increasing and decreasing the brightness -

[root]prashant@vaio09:12 PM$ cat bin/incbrightness.sh
#!/usr/bin/env bash
echo $[1+`cat /sys/class/backlight/acpi_video0/brightness `] >/sys/class/backlight/acpi_video0/brightness

you'll have to put this in sudo though.
and to decrease change + to – and … you get the idea, right !

A bit more, if you use enlightenment(e17) here are few more hints -

[enlightenment key bindidings]

You can use following key code and mapping

mute :
KEY="Keycode-160" ACTION="exec" PARAMS="/usr/bin/amixer -q set Master toggle"
hibernate :
KEY="Keycode-165" ACTION="exec" PARAMS="sudo /usr/sbin/hibernate-disk"
volume decrease :
KEY="Keycode-174" ACTION="exec" PARAMS="/usr/bin/amixer -q set Master 2-"
volume increase:
KEY="Keycode-176" ACTION="exec" PARAMS="/usr/bin/amixer -q set Master 2+"
increase brightness :
KEY="Keycode-212" ACTION="exec" PARAMS="sudo /root/bin/incbrightness.sh"
decrease brightness
KEY="Keycode-101" ACTION="exec" PARAMS="sudo /root/bin/decbrightness.sh"

下一頁»