tag:blogger.com,1999:blog-81420213988055820002024-03-06T05:58:53.461+08:00shellingAnonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comBlogger156125tag:blogger.com,1999:blog-8142021398805582000.post-78483062938025704032013-06-06T01:31:00.002+08:002013-06-06T02:42:24.020+08:00啟動 Mac OS X 的 OpenLDAP三部曲
1. slappasswd 建立新的 rootpw
2. 編輯 /etc/openldap/slapd.conf 內的 suffix, rootdn, rootpw
3. slapd -d 255
Reference:
starting OpenLDAP on Mac OS XAnonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-16521863036734747602012-08-06T16:31:00.001+08:002012-08-06T19:54:41.780+08:00LWP Chunked Way
在讀取 || 傳送大量資料的時候,可以利用 IO::* 這類模組去一次讀取其中一段資料 (Chunk) 就寫入暫存檔 || 送出,來避免對記憶體造成負擔的手法可說相當常用。也是 HTTP Server 用來做 Streaming 或是 Long Polling / Comet 的基礎。
Client 端的用法就沒有那麼絢麗的名字了(開發 Client 的人沒有必要用絢麗的名字震懾老闆?:p)。LWP 對 Chunk 手法也有支援,不過在 GET 和 POST 兩種 HTTP 動做的支援方式分別使用了接受 callback 和利用全域變數啟用的方式,有點不一致,特此紀錄一筆。
GET 使用 Chunk 的方式在 lwpcook 有詳盡記載。在 LWP::UserAgent 物件呼叫 request 方法時多傳入一個 callback 即可。
POST 動作其實也應該Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-3575038087280019542012-03-31T18:56:00.007+08:002012-03-31T20:16:57.773+08:00class variables in MooseMoose attribute didn't allow the reference rather than a CODE reference as a default value. That prevents the objects shared a attribute when initializing. Actually this is a good design. But How should I do when needing a shared attribute between objects? I may refer this as the concept of class variable.The state variable in CODE reference may be competent with this role. A Counter as an Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-53978984095282742482012-03-03T03:27:00.003+08:002012-03-03T14:17:08.898+08:00Mysterious Timestamp時間轉換大概是最惱人的「小」問題之一,每個語言的標準處理方式不盡相同。Perl 的 localtime() 是月份從 0 開始到 11 結束,Ruby 的 DateTime 是月份是從 1 開始的,不過 Perl 的 DateTime 月份也從 1 開始 (LOL)。背誦這些東西大概會發瘋。不過 Epoch 沒有這個問題,任何語言上的 Epoch 應該都是一致的,有的只是時差問題,使用 Epoch 來初始時間物件大概是避開這問題的好方法之一,特別在不同語言間交換時間資料時,用 Epoch 交換後怎麼 format 都不會出問題。所以有些時間模組大概會像 Perl 的 DateTime 一樣實作 from_epoch() 這種 constructor。就這點設計而言,Badger::Timestamp 大概是最好用的時間模組,其 constructor 支援 DateTime 模組的方式Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-39402106700825460202011-10-27T17:46:00.008+08:002012-04-26T12:01:36.602+08:00meet git-p4For some reasons, in recent works I have to use Perforce, the revision control system used by Perl core team before 2008. Unfortunately, perforce lacks of distributed features and leads to heavy branching. In this developing, these two problems often interrupted programmers with conflicts hardly to solve. Bad workflow design also makes members forget to check out before editing randomly. A git Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com2tag:blogger.com,1999:blog-8142021398805582000.post-82452759741203819742011-04-09T14:16:00.007+08:002011-04-10T20:54:00.245+08:00Arrange bashrcA simple recursive function can have aid on arranging bashrc files in a clear structure.Add a line to source it in ~/.bashrc first, and then collect similar rc files into directories respectively.If a bunch of bash completions were put inside ~/.bash_completion/, like ~/.bash_completion|-- hg|-- git| |-- git| |-- gitk| `-- git-common`-- svkjust one more line load $HOME/.bash_completion Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-35069533948186103062011-03-25T18:16:00.019+08:002011-03-28T15:50:11.190+08:00MySQL 5.5.10 homebrew install issueComing after the mysql 5.1.52 homebrew install issue, the just released mysql 5.5.10, which solved the previous problem, has another issue. When starting mysql daemon with mysql.server script, it showed error message likeERROR! The server quit without updating PID file (/usr/local/var/mysql/data/*********.pid). The new homebrew instruction to install mysql makes its default $datadir to be $Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com1tag:blogger.com,1999:blog-8142021398805582000.post-67568883630209390672010-11-30T21:04:00.008+08:002010-11-30T21:37:51.709+08:00Tasting Perl6At the moment that the first release of Rakudo Star has been announced over four months, binary packages or tested build in package managers have been provided in varieties of OS. If we want to taste Perl6 on Mac OS X, the best choice seems to be using Homebrew. Just type in $ brew install rakudo-star and run $ perl6. Rakudo Star in Homebrew has been updated to the newest version: 2010.10.On Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-13702312856786033382010-11-23T20:55:00.002+08:002010-11-24T11:11:19.141+08:00Intro to App::CLIMy first meet with App::CLI is in the summer of 2008, trying to write JiftyX::Fixtures. Without abundant PODs coming with this module, it took me almost one day to understand this module through trial and error. Since, I write this intro to reveal more power from this module; even I have contribute some code and DOCs to the project.Actually, App::CLI is a really powerful module having central Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-6029297647093195182010-11-13T21:40:00.010+08:002010-11-13T23:43:53.413+08:00Keep favorite info pages in $HOMEInfo is a handy document system most emacs fans love. We can learn Info, Emacs Basics, Emacs Lisp, Magit and blah blah blah through the system and look up any detail every time we need without leaving Emacs, so that I install many info pages into /usr/local/info, /usr/share/info and /usr/share/local/info. However, when I need to migrate all data to new computer, keeping my info pages is really a Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-77813714084849213952010-10-27T21:20:00.003+08:002010-10-27T22:19:45.862+08:00Two ZSH conventions for switchers from BASHWhen starting to learn UNIX, I enjoyed with the well-designed Debian 3.1 and the bash completions coming with it. At that time the ZSH on Debian wasn't well configured for a newbie having no direction in dark.Actually, the ZSH was set as a handy tool on recent releases of Debian-like system. For a longtime user of BASH, the default setting of backward-kill-word is confusing: it never stop with Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-60579700396416029862010-10-23T15:03:00.005+08:002010-10-23T23:49:28.987+08:00Fullscreen Emacs on Mac OS X from tarballEmacs 23.2 in trunk doesn't support fullscreen on Mac OS X.Japanese hacker typester do a patch for this.Following is a quick step-by-step instruction to compile emacs 23.2 supporting fullscreen with this patch.cd /tmpwget http://ftp.twaren.net/Unix/GNU/gnu/emacs/emacs-23.2.tar.gzwget http://github.com/downloads/typester/emacs/feature-fullscreen.patchtar xzvf emacs-23.2.tar.gzcd emacs-23.2patch Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-6898487677832882382010-08-05T19:22:00.003+08:002010-08-06T13:49:54.096+08:00practical python trick about static variablesIt seems there is no syntax to declare static variables in Python. Fortunately, here is a useful trick to accomplish the goal.Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-19685643785527885052010-04-11T20:37:00.005+08:002010-04-11T20:47:35.846+08:00sudo on OpenLDAPsudo 官方文件 和 這篇 SOP (on Ubuntu) 算是寫得最實用的文件。不過呢,還是很多廢話。這兩篇文章的內容可以總結如下:1. 準備好可以使用的 OpenLDAP 伺服器,這份文件 寫得比較詳盡。幫他加上 sudo.schema,並用 migration_sudo.pl 轉換並匯入 sudoers。2. 裝好支援 LDAP 的 sudo。Debian-like System 是 sudo-ldap 這個套件。3. /etc/nsswitch.conf 加上 sudoer: ldap4. /etc/ldap/ldap.conf 或是 /etc/sudo-ldap.conf (在 Debian 是同一檔案) 加上 sudoers_base [SUDOers DN]Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-28462115456973905772010-03-27T22:11:00.009+08:002011-04-21T23:27:20.823+08:00Fun Weekend忙了一整個禮拜,今天又唸了一整天書,於是乎覺得需要休息一下,想起開學時就想去吃看看的鼎泰豐,到現在還不知道在哪,拎起夾克,挾住一本書在腋下就出發來去探探路。在 GMap 的帶路下,很快就到了信義路上的鼎泰豐飽餐一頓之後決定輕鬆地走路回宿舍。沿著金山南路往南走,走過熟悉又陌生的台師大門口。大三時因為擔心研究所筆試臨場反應不好,要是沒考上就得去盡忠報國,所以特別提前一年報了台大光電的筆試來試刀。走過那年的考場,兩年裡準備考試的酸甜苦辣倒也反芻了一遍。轉了個彎走進師大路,比對著記憶裡的街角,今晚的師大夜市一般的人潮洶湧。不一樣的是路邊的那個小廣場,今晚圍了一群人。湊上去一看,是個有趣的大叔,看起來快到不惑之年,一把小提琴流暢的拉著,一支音響丟在旁邊為他伴奏,不時還擺個花式娛樂大家一下。老實說看到的時候還滿驚訝的,台北街頭藝人不是沒有,但是大多是吉他或是歌唱表演。小提琴的表演呢,雖說最初就是以Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-56118335102475184312010-03-27T14:47:00.002+08:002010-03-27T14:51:59.296+08:00Common Abbreviation in LDAPDC: Domain CountryOU: Organization UnitCN: Common NameDN: Distinguish NameRDN: relative distinguish nameLDIF: LDAP Interchange FormatDIT: Directory Information TreeAnonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-18221059581417846792010-02-01T19:07:00.004+08:002010-02-01T19:28:47.352+08:00FDTD tipsWhen using BPML, external wall should be treated as PECs for simplicity no matter how many the maximum sigma is. The best way to do that is setting initial field value on external wall to be zero, and then don't update field value of any point on the wall.That is to say, it could be written asSaving a few of computing resource. Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-88173702573458236422010-01-29T17:09:00.006+08:002010-01-29T17:54:25.815+08:00Injecting one module into another in PythonHere is a simple code snippet to do that. Saving it to an individual file and import it in other module to use it.Using exec statement is also good, but need to pass globals() or locals() dictionary to the function executing exec statement.Doing dirty things in Python is really not easy...:/ Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-80467642976821935552009-12-30T00:01:00.010+08:002009-12-30T01:56:01.733+08:00Assign initial value to a pointerToday I suddenly got an idea. Most of time when we use pointer, we create a variable, and assign initial value to it, and then take its address become the value of a new pointer for succeeding use. But we create a redundant identifier here.In fact, we could always create a fundamental type pointer and assign initial value to it through dereference operator like this snippet.and no redundant Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-7573036519881625892009-11-13T23:36:00.013+08:002009-11-14T01:17:40.145+08:00Library for Numerical ComputingBriefly summarize some numerical library here. It looks there are too many useful tools. Either for parallel computing or for matrix, numerical calculating and plotting.PLOT:MatPlotLib: it seems to be the most awesome plotting tool among this listPGPlot: C library, also have binding in Perl, Python,RubyPLPlot: cross-platform plot library, also have binding in PerlScientific PythonMRPlotPARALLEL:Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-91670008693246449992009-08-30T22:45:00.003+08:002009-08-30T23:28:36.865+08:00Discussion about anonymous function in Perl and RubyJust for fun, tonight I write a methods invoking two anonymous functions to iterate a Range with specified condition in Ruby. It looks likeclass Range def each_satisfy() endendAnd I want to invoke it as(1..10).each_satisfy(condition_lambda, callback_lambda)(1..10).each_satsify { |n| ...condition statment... } do |n| ...callback statement...endWhen I try to define its prototype asdef Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com1tag:blogger.com,1999:blog-8142021398805582000.post-40683147713445376102009-08-23T22:35:00.006+08:002009-08-24T11:27:31.570+08:00LWP, cURL, OpenSSL and PosterousThe fun of programming is there is always subtle mechanism in implementation. It costs time to discover but sometime is deserving. for example.$ curl --basic -u <user> http://example.com/api/$ echo -n "user:pass" | openssl base64 -eand to Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-75536185262527412622009-08-17T23:48:00.005+08:002009-08-20T19:27:47.102+08:00Posterous API in PerlPosterous.com is a new (micro)-blog mesh-up system.You can use it mesh up almost all your (micro)-blog. Post once, Publish Everywhere. And there is still many funny features.It looks pretty good, so I translated its API to Perl. You can get it from CPAN. Still work in progress, but would be productive soon. Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-3868934381973686842009-08-15T23:43:00.005+08:002009-08-16T01:10:08.741+08:00Can't locate Git.pm in @INCWell, the installation of Github::Import worked well on Linux boxs but always reported "can't locate Git.pm in @INC" on Macintosh boxs. It is just a little trick and the answer is here.Git.pm comes with git instead of being a part of CPAN. Building a copy of git-core or copying from other box solve it quickly. Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0tag:blogger.com,1999:blog-8142021398805582000.post-6909388937620944172009-07-07T12:34:00.005+08:002009-07-07T12:44:31.174+08:00the roadmap of upgrowth和長輩們聊天總是很有趣的。即使那是一句老生常談,從長輩提攜的口吻中說出,依然受用。6/26 的謝師宴,和賴暎杰老師坐在一起,我是這麼問的:「研究遇到瓶頸時,是怎麼面對的。」「每天都多學會一件事,就不用擔心。」yep... Anonymoushttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com0