• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 60  文章 - 5  trackbacks - 0
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(2)

            隨筆分類(42)

            隨筆檔案(60)

            文章檔案(2)

            我收藏的博客

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            the formulation of a problem is often more essential than its solution,which may be merely a matter of mathematical or experimental skill.
            愛因斯坦,提出一個問題往往比解決一個問題更重要。
            posted @ 2012-01-04 16:06 黃劍父 閱讀(180) | 評論 (0)編輯 收藏
            一、tcmalloc
            1、tcmalloc是什么?
            2、安裝tcmalloc

            二、mysql
            1、mysql的編譯

            2、把tcmalloc編譯到mysql中

            三、memcache
            1、memcache是什么?
            2、安裝memcache
            posted @ 2011-11-22 08:52 黃劍父 閱讀(280) | 評論 (0)編輯 收藏
            官網地址:http://scratch.mit.edu
            Scratch是一種計算機編程語言,利用它可輕松地創建自己的互動故事,動畫,游戲,音樂和藝術- 和在網絡上分享你的作品。 當學生創建和共享自己的Scratch動畫時,他們能學習到重要的數學和計算知識,同時也得到創造性的思考,系統推理,和協同工作的機會。

            為什么要用Scratch學習編程?
            1、Scratch上手非常容易,適于8歲以上孩子,成人也可以玩。積木,我想大多數人應該有玩過吧,沒實際玩過至少也聽說過吧。用Scratch編程就像玩積木一樣,非常簡單,把像一個個積木一樣的腳本命令,按照一定的邏輯堆積起來,就可以做出自己的動畫或游戲了。有圖才有真相,各位看官請先看圖。


            2、Scratch簡單,但能做很多事。你可以到官網看看一些優秀的作品,就知道Scratch能做些什么呢。
            3、Scratch雖然不用你去敲代碼,但它同其它計算機語言的編程思想是完全一樣的,和C,C++,Java的編程思想沒什么兩樣。如果你懂C、C++或Java,那些堆積起來的腳本,也是可以翻譯成C、C++、Java代碼的,并且非常簡單,絕對要比英語翻譯簡單很多很多。
            4、Scratch是免費的,可以在Mac,Windows和Linux上運行,并且軟件的語言是可以設置,不懂英文也不要怕,可以把軟件界面語言設置為簡體中文。官網的站點也有中文的版面。
            5、網站的用戶參與度非常高,用戶可以上傳自己的作品到該網站,可以欣賞其他用戶的作品,看到喜歡的也可以下載下來研究研究,當然也可以用到自己的作品中哦。

            Scratch的一些統計數據,從其中你就可以看出此軟件有多優秀,看過之后是否選擇此編程語言做為自己的入門語言,那就看你的了。
            第一幅圖:scratch網站的訪問者都來自哪些城市
            scratch網站的訪問者都來自哪些城市

            第二幅圖:scratch網站的注冊用戶年齡分布圖(藍色代表男性,紅色代表女性)
            scratch網站的注冊用戶年齡分布圖
            posted @ 2011-10-24 14:54 黃劍父 閱讀(2976) | 評論 (1)編輯 收藏

            原文地址:http://www.cprogramming.com/whyc.html

            為什么學習C

            Why Learn C?

            現在大家在用的計算機語言的數量多得可怕。從高級語言(比如VB)到低級語言,有非常多的選擇(Perl,Ruby和Python語言,對于很多任務的實現都是不錯的選擇)。Java已經成為了一些項目非常受歡迎的語言,某種程度上也是因為它擁有大量的API和虛擬機機制提供了比較好的安全性。(內存垃圾收集器也是一個非常不錯的功能,可以使得程序員更有效率。)
            There are an awful lot of programming languages available right now -- everything from the extremely high level (such as Visual Basic) to the low level power of assembly, and a good variety of specialized options in between (Perl, Ruby, and Python are good choices for many tasks). Java has also become quite the hot programming language for some tasks, in part because of its large API and in part because the virtual machine provides some elements of security. (Garbage collection is another nice feature and can make programmers much more efficient.)
            然而,學習c語言編程,也有很多很好的理由。第一,歷史悠久:C語言已有30多年的歷史了(譯者注:到現在已有近40年了),能找到大量的有效的源代碼。這也意味著有很多可以學習的例子,也有很多是可以直接拿來用的代碼。而且,語言的很多問題都已經說明的很清楚--它可以更好的理解,并且你可以找到很多很不錯的教程。另外,對于C,你可以獲得很多你能理解的看法和見解。
            Nevertheless, there are some good reasons to learn to program in C. First, age has its advantages: C has been around for 30 years, and there is a ton of source code available. This means there's a lot to learn from, and a lot to use. Moreover, many of the issues with the language have been clearly elucidated -- it's well understood, and you can find a lot of tutorials available. Plus, with C, you get lots of strong opinions mixed with insights that you can understand.

            由于歷史的原因,C做為Unix的一個系統編程語言,C已經成為了一門通用的編程語言。有時候用C語言來表達一些編程上的想法,大部分人都會感覺到比較舒服。
            As a result of its age and its use as the language of system programming for Unix, C has become something of the lingua franca of programming. C is a great language for expressing common ideas in programming in a way that most people are comfortable with. Moreover, a lot of the principles used in C -- for instance, argc and argv for command line parameters, as well as loop constructs and variable types -- will show up in a lot of other languages you learn so you'll be able to talk to people even if they don't know C in a way that's common to both of you.

            第三,C是比較接近機器語言。
            Third, C is reasonably close to the machine. When you're working with pointers, bytes, and individual bits, things like optimization techniques start to make a lot more sense. There's also utility in knowing exactly how something works underneath the hood -- this helps a great deal when something you're trying to do in a higher level language seems way slower than expected, or just doesn't work at all. You also tend to get a better picture of advanced topics like exactly how networking works. A higher level language will make it a little bit simpler, but it'll be harder to understand what's going on, and when things stop working, it's much better to know exactly what's going on so you can fix it. Additionally, if you like computer science as a discipline, or just like knowing how things work learning the details of the system is great fun.

            實際上,很多有趣的編程都可以用C來做--比如,系統軟件和數據管理系統(Berkeley DB)。如果你想寫一個比較復雜的web程序,C也是一個很不錯的選擇。如果你想寫一個非常好的,快的,C也是很好的選擇。你可以用C來寫整個操作系統,想用Java來做這個事情是非常難的,對于腳本語言來說是幾乎不可能的。而且C是一門非常簡潔精煉的語言,它使得非常有趣的編程看起來更優雅,你的編程之旅將會有一個很好的開始。
            In fact, a lot of fun programming is done in C -- for instance, system software and data managers such as Berkeley DB. If you want to be able to do more than write a simple web app, C is a great language. If you want to write a great, fast game, C is again a great choice. You can write an entire OS in C. It'll be much harder to do so in Java, and nearly impossible in a scripting language. And the language, being succinct as C is, will probably make your fun program more elegant looking to boot.


            我對于這篇文章所談的話題,想補充幾點。
            1、學好C,可以幫助理解其他語言中的一些概念。
            比如Java中的引用的概念,如果理解了C語言中的指針的概念,就能很好的理解“引用”這個概念了,而不理解指針的概念想把引用的概念理解的很透徹,是比較難的。

            2、學會了C語言,再學習其他語言會感覺到更輕松。
            Object-C,Java,C++等等很多高級語言的語法都與C是相似的。學會了C后,基本上只要花上一周的時間了解一下其他語言的特性,就基本上可以看懂其他語言的源代碼了。

            3、從現實角度來考慮,學好C,找到一份好工作的可能性也是大大增強,特別是對于剛畢業的大學生,或工作經驗比較少的程序員。現在需要有C語言基礎,擅長于C語言的,工作崗位也是比較多。比如拿現在非常流行的iPhone,iPad等設備的應用程序,開發語言就是Objective-C語言。Objective-C是蘋果Mac OS X、iOS平臺的開發語言,Objective-C是基于C語言的,增加面向對象的相關特性。你可以認為Objective-C就是另一個版本的C++,也就是采用了與C++不同的語法,但也實現了面向對象。你有了C語言的基礎,再學Objective,難度就不大了。
            你可以到那些招聘網站去看看,查查iPhone相關的開發工程師的要求,是不是很多都要求有C/C++的基礎和經驗。
            還有一些系統開發和底層比較相關的,很多都是需要用C語言開發的。拿信息安全行業來講,很多安全產品都是用C語言來開發的。還有游戲行業很多都是用C或C++。

            還有一點,很多初學者認為學習C很難。其實我想說的是難并不是計算機語言的問題,難的是因為你用計算機解問題的思維還沒建立起來。因為你進入的是一個新的領域,以前沒有接觸過計算機編程,對于怎么用計算機來解決現實中的問題的這種思維你還沒有建立起來,畢竟用計算機解題的思維,和用數學解題的思維還是有些不一樣的,所以你會覺得學習C語言很難。
            如果你在學習C語言的同時,再進行一些程序員的思維訓練,我覺得情況就會大有改善。
            posted @ 2011-10-20 17:07 黃劍父 閱讀(2618) | 評論 (1)編輯 收藏
            Over the past decade-and-a-half of teaching introductory computer programming I have noticed increasingly that students have difficulty with solving problems. It is common to see learners read a programming problem description  and immediately try to write the programming language source code (usually whilst sitting at a PC typing straight into the editing window of the compiler environment). When they ask for help it is often the case that their difficulty lies not with manipulating the programming language syntax (C, Pascal, Java, or whatever) but in understanding what it is they're trying to solve. In fact, many times they confuse their syntax-handling difficulties with their problem-solving difficulties and blame their frustration on programming itself or on the chosen programming language. Some of them then become so downhearted that they decide they cannot do computer programming and transfer to a course that doesn't require them to study it.

            這個話題挺有意思,我看了他的練習題,還真不錯,有時候覺得。算法和計算機的語言的學習應該是有另外一種方式。
            換句話說,在深入學習語言和算法,可以先來一碟開胃菜。
            網站地址:
            http://www.howtothinklikeaprogrammer.com/forum/index.php
            書名是:《How to Think Like a Programmer: Program Design Solutions for the Bewildered》By Paul Vickers。
            posted @ 2011-10-19 23:03 黃劍父 閱讀(1985) | 評論 (0)編輯 收藏
            原文:http://www.cprogramming.com/tutorial/thinking.html
            很多人通過Email問我,怎樣開始寫一個程序。也許最好的建議非常簡單,把程序的步驟寫下來:一旦你開始把想法或者代碼寫下來后,你就會對你的項目有一些感覺了。通常程序設計有兩種通用的做法:從上到下的方式和從下到上的方式。
            A lot of people email me asking the way to start some program or another. Perhaps the best advice is simply to start writing down a layout for the program: once you start writing down ideas or code you'll start to get a feel for your project. There are two standard methods of program design: the top-down approach and the bottom-up approach. Top-down programming involves writing code that calls functions you haven't defined and working through the general algorithm before writing the functions that do the processing. Top-down programming is, to a good degree, a very abstract way of writing code because it starts out by using functions you haven't designed, and that you perhaps do not know how to design. The bottom-up approach to programming is the opposite: the programmer writes the basic functions she realizes will be necessary at some point in the programming and then work up to the more complex parts of the program.

            比較有意思的是,那兩種方法都是關注程序中要執行的動作或方法,而不是關注程序要處理的數據。很多時候,寫程序最好的方法是,寫出你將要用到或處理的數據,然后再從上到下的想怎么樣去處理這些數據,最后才能得到你需要的結果。首先定義數據,然后再寫出那些要處理這些數據的相關的函數。,這樣你才會得到你的程序應該怎樣寫的基本思路,
            It's interesting that both of these approaches focus on the actions of the program rather than the objects the program manipulates - variables. Many times, the best way to write a program is to figure out the variables you need to work with and then progress with a top-down approach to the program that manipulates those variables. By defining variables first and then working with functions that work on them, you will always maintain a basic foundation of what your program should be doing. Once you have an idea of what variables you will be using, then you can write functions to perform the operations you need to perform on the variables while maintaining sight of the goal. Finally you can write the code for each individual function.

            Another value to defining variables before writing code is that many times you can accomplish an entire program without many functions; this fact is especially true when you are a beginner making simple programs. The variables give you the raw materials you need to begin working with the tools: loops, if statements, library functions, and perhaps user defined functions.


            現在讓我們來看一個關于怎樣開始寫一個完整程序的例子。假設你要寫的程序是要模擬一個DVD商店的租售系統,這個系統需要計算出出租DVD的總收入。你的程序有可能要求,需要輸入一個代碼,告訴你這個DVD租售的價格是2元一天還是是3元一天,然后還需要它出租了多少天,最后如果這個輸入的代碼是0,整個程序就結束了。你應該要分別計算出租金為3元/天和2元/天的DVD的出租的總天數。拿這個程序來說,思考設計程序的最好的方式是,想象為了計算出租金的收入,你需要存儲哪些信息:

             

            • 你需要一個變量用來存儲總收入,當程序結束時;
            • 你需要一個臨時變量用來存儲代表DVD的租金的代號;
            • 你需要一個臨時變量用來存儲某個DVD出租的天數;
            • 你需要一個變量來存儲租金為3元/天的所有DVD出租了多少天的總數;
            • 最后,你還需要一個變量來存儲租金為2元/天的所有DVD出租了多少天的總數;

             

            Let's take a look at an example of how to go about thinking about a program. If you were to write a program to simulate a video store rental system that calculates the gross revenue from rentals, you might be asked to write a program that accepts a code telling you whether a certain video was rented at $2.00 (input as 2) a day or $3.00 (input as 3) a day and then asks for how many days it was rented out for; finally, if the code for the cost of rental is 0 the program should terminate. You should also count the number of days videos were rented at $3.00 per day and $2.00 per day. The best way to think about the design for a program such as this one is to imagine what information you need to store in order to calculate the revenue:

            • you need a variable to store the total dollar amount at the end of the program;
            • you need a temporary variable to store the code for the cost of a transaction;
            • you need a temporary variable to store the number of days a specific video was rented;
            • you need a variable to store the number of days each video was rented;
            • you need a variable to count the total number of days $3.00 videos were rented;
            • finally, you need a variable to count the total number of days $2.00 videos were rented.

            一旦你認識到你需要這些數據,那么你就很容易想出如何處理這些數據:比如,你知道租金2元/天的DVD的總收入=所有租金為2元/天DVD的出租天數之和*2;類似的也可以計算出租金3元/天的DVD的總收入。你也會理解這個“代表DVD的租金的代號”,這個變量的用處是,當用戶輸入某個DVD出租的天數時,決定哪個變量會被操作。在你的程序中你需要一個循環結構。


            Once you realize you need these variables, you can easily imagine how to translate them in terms of each other: for example, you know the total amount of revenue is the number of days videos at $2.00 were rented times $2.00; in similar fashion, you know the relationship for $3.00 a day videos. You should understand that the transaction 'code' determines which variables are manipulated when the user inputs the number of days a specific video was rented (for example, whether to add to the count of days for $2.00 videos or $3.00 videos). You'll probably need a loop in your program (although you can't necessarily infer this from the variables).

             

            程序的代碼有可能會像下面那樣:

            The code might look as follows:

             1 
             3 int main()
             4 {
             5   int total_dollars = 0;
             6   int total_days_at_3_dollars = 0;
             7   int total_days_at_2_dollars = 0;
             8   int transaction_code = 0;
             9   int days_for_one_video = 0;
            10   do
            11   {
            12     if(transaction_code==2)
            13       total_days_at_2_dollars+=days_for_one_video;
            14     if(transaction_code==3)
            15       total_days_at_3_dollars+=days_for_one_video;
            16     cout<<"Please enter a transaction code and number of days a video was rented: ";
            17     cin>>transaction_code>>days_for_one_video;
            18   }while(transaction_code!=0)
            19   return 0
            20 }

            我希望,你現在已經有了一個基本的思路,在寫代碼之前,應該如何安排你的程序的結構。

            Hopefully, you now have a basic idea of how to lay out your program structure in your mind before you begin to write code.

             

            posted @ 2011-10-19 11:00 黃劍父 閱讀(1886) | 評論 (0)編輯 收藏

            application文件夾為ext js4的應用程序目錄,
            ext文件夾為ext js 4資源的目錄,
            其他文件或文件夾則為yii框架所涉及到的。
            posted @ 2011-07-27 14:50 黃劍父 閱讀(2089) | 評論 (1)編輯 收藏
            Apache服務器下yii的urlManager設置
            step1:Yii的配置文件config/main.php中
            'components'下增加
             1 'urlManager'=>array(
             2     'urlFormat'=>'path',
             3     'showScriptName' => false,
             4     'rules'=>array(
             5         'urls.js' => 'workspace/urls',
             6         'env.js' => 'workspace/env',
             7                 '<controller:\w+>/<id:\d+>'=>'<controller>/view',
             8                 '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
             9                 '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            10             ),
            11         ),
            step2:開啟Apache的配置文件httpd.conf中LoadModule rewrite_module modules/mod_rewrite.so和AllowOverride屬性設置為All
            step3:編寫一個.htaccess文件放在app的根目錄,添加以下幾行到文件中
            Options +FollowSymLinks
            IndexIgnore */*
            RewriteEngine on

            # if a directory or a file exists, use it directly
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d

            # otherwise forward it to index.php
            RewriteRule . index.php
            posted @ 2011-07-26 14:20 黃劍父 閱讀(5315) | 評論 (0)編輯 收藏
            網站:
            http://www.sencha.com/products/extjs/
            posted @ 2011-07-18 11:03 黃劍父 閱讀(270) | 評論 (0)編輯 收藏

            printf的格式控制的完整格式:
            %  -  0  m.n  l或h  格式字符
            下面對組成格式說明的各項加以說明:
            ①%:表示格式說明的起始符號,不可缺少。
            ②-:有-表示左對齊輸出,如省略表示右對齊輸出。
            ③0:有0表示指定空位填0,如省略表示指定空位不填。
            ④m.n:m指域寬,即對應的輸出項在輸出設備上所占的字符數。N指精度。用于說明輸出的實型數的小數位數。為指定n時,隱含的精度為n=6位。
            ⑤l或h:l對整型指long型,對實型指double型。h用于將整型的格式字符修正為short型。

            ---------------------------------------
            格式字符
            格式字符用以指定輸出項的數據類型和輸出格式。
             ①d格式:用來輸出十進制整數。有以下幾種用法:
            %d:按整型數據的實際長度輸出。
            %md:m為指定的輸出字段的寬度。如果數據的位數小于m,則左端補以空格,若大于m,則按實際位數輸出。
            %ld:輸出長整型數據。
            ②o格式:以無符號八進制形式輸出整數。對長整型可以用"%lo"格式輸出。同樣也可以指定字段寬度用“%mo”格式輸出。
            例:
               main()
               { int a = -1;
                 printf("%d, %o", a, a);
               }
              運行結果:-1,177777
              程序解析:-1在內存單元中(以補碼形式存放)為(1111111111111111)2,轉換為八進制數為(177777)8。
            ③x格式:以無符號十六進制形式輸出整數。對長整型可以用"%lx"格式輸出。同樣也可以指定字段寬度用"%mx"格式輸出。
            ④u格式:以無符號十進制形式輸出整數。對長整型可以用"%lu"格式輸出。同樣也可以指定字段寬度用“%mu”格式輸出。
            ⑤c格式:輸出一個字符。
            ⑥s格式:用來輸出一個串。有幾中用法
            %s:例如:printf("%s", "CHINA")輸出"CHINA"字符串(不包括雙引號)。
            %ms:輸出的字符串占m列,如字符串本身長度大于m,則突破獲m的限制,將字符串全部輸出。若串長小于m,則左補空格。
            %-ms:如果串長小于m,則在m列范圍內,字符串向左靠,右補空格。
            %m.ns:輸出占m列,但只取字符串中左端n個字符。這n個字符輸出在m列的右側,左補空格。
            %-m.ns:其中m、n含義同上,n個字符輸出在m列范圍的左側,右補空格。如果n>m,則自動取n值,即保證n個字符正常輸出。
            ⑦f格式:用來輸出實數(包括單、雙精度),以小數形式輸出。有以下幾種用法:
            %f:不指定寬度,整數部分全部輸出并輸出6位小數。
            %m.nf:輸出共占m列,其中有n位小數,如數值寬度小于m左端補空格。 
            %-m.nf:輸出共占n列,其中有n位小數,如數值寬度小于m右端補空格。
            ⑧e格式:以指數形式輸出實數。可用以下形式:
            %e:數字部分(又稱尾數)輸出6位小數,指數部分占5位或4位。
            %m.ne和%-m.ne:m、n和”-”字符含義與前相同。此處n指數據的數字部分的小數位數,m表示整個輸出數據所占的寬度。
            ⑨g格式:自動選f格式或e格式中較短的一種輸出,且不輸出無意義的零。

            ---------------------------------------
            關于printf函數的進一步說明:
            如果想輸出字符"%",則應該在“格式控制”字符串中用連續兩個%表示,如:
            printf("%f%%", 1.0/3);
            輸出0.333333%。

            ---------------------------------------
            對于單精度數,使用%f格式符輸出時,僅前7位是有效數字,小數6位.
            對于雙精度數,使用%lf格式符輸出時,前16位是有效數字,小數6位.

            ######################################拾遺########################################
            由高手指點
            對于m.n的格式還可以用如下方法表示(例)
            char ch[20];
            printf("%*.*s\n",m,n,ch);
            前邊的*定義的是總的寬度,后邊的定義的是輸出的個數。分別對應外面的參數m和n 。我想這種方法的好處是可以在語句之外對參數m和n賦值,從而控制輸出格式。


            今天(06.6.9)又看到一種輸出格式 %n 可以將所輸出字符串的長度值賦紿一個變量, 見下例:

            int slen;

            printf("hello world%n", &slen);

            執行后變量被賦值為11。

            又查了一下, 看到一篇文章(查看)說這種格式輸出已經確認為一個安全隱患,并且已禁用。再搜搜果然這種用法都被用來搞什么溢出、漏洞之類的,隨便找了一個:格式化字符串攻擊筆記。
            posted @ 2011-04-26 16:18 黃劍父 閱讀(300) | 評論 (0)編輯 收藏
            僅列出標題  下一頁
            日韩精品久久无码中文字幕| 久久亚洲欧洲国产综合| 久久久久高潮毛片免费全部播放| 色8久久人人97超碰香蕉987| 国产精品久久久久久久久久影院| 亚洲香蕉网久久综合影视| 久久人妻少妇嫩草AV无码专区| 精品久久久久久久久午夜福利| 99精品久久精品| 久久九九有精品国产23百花影院| 亚洲精品NV久久久久久久久久| 亚洲∧v久久久无码精品| 久久精品麻豆日日躁夜夜躁| 国产女人aaa级久久久级| 天天躁日日躁狠狠久久| 久久免费国产精品| 久久久久久久尹人综合网亚洲| 久久精品一区二区三区AV| 久久本道伊人久久| 看久久久久久a级毛片| 久久亚洲精品无码播放| 久久不见久久见免费视频7| 久久久久青草线蕉综合超碰 | 色综合久久夜色精品国产| 波多野结衣久久一区二区| 久久精品国产WWW456C0M| 国产麻豆精品久久一二三| 午夜精品久久久久久99热| 国产精品久久久久a影院| 亚洲人AV永久一区二区三区久久| 久久www免费人成精品香蕉| 伊人久久大香线蕉综合Av| 日韩亚洲国产综合久久久| 久久久久久噜噜精品免费直播| 国产精品gz久久久| 精品国产一区二区三区久久| 国产精品久久久久无码av| 精品久久一区二区三区| 99久久99久久久精品齐齐| 91久久精一区二区三区大全| 国产精品久久波多野结衣|