Posts

Showing posts from August, 2013

Ways to reverse one-directional list

Image
Ways to reverse one directional list Table of Contents 1 How I get this question? 2 So the answer is? 3 What did I learn from this question? 1 How I get this question? I attended a job interview again yesterday, the interviewer asked me some many questions including object-oriented software design, data structure, and algorithms. The written examination which is android SDK related should be my strong points one years ago, but Now I forgot most of the terms. So sucks huh! I list the following topics from my memory after the lasting 3 hours job interview. Plugin design patterns: Cons and Pros, How eclipse project leading this tide. Dynamic Programming language and OOP Lisp language, Functional programming, and Recursion Algorithms Most of the questions enlightening me so much, this interviewer is obviously a good engineer.  wow… Great job. Now, come back the topic. How to reverse a one-directional list? This question was given when we discuss the functi

Configure Emacs as an Python IDE

Image
Configure Emacs as a Python IDE Table of Contents 1 use python.el 2 auto-completion in python.el 1 use python.el There are plenty of python modes which support develop python in emacs, well, in my personal opinion, most of those are sucks, and F fgallina's python.el is the much better one.  Besides the major mode for python, I installed following python packages including rope, ropemode, Pymacs, and ropemacs. Install rope, reopmode, and ropemacs were really easy with the help of python's package management tool pip .  pip install rope pip install ropemode pip install ropemacs Pymacs provided the both-way communication between Emacs Lisp and Python, it can not installed by pip, so just download the source code from GitHub.  Install pymacs python package first.  make sudo make install Install emacs package pymacs.el which generated by above step. copy pymacs.el into the path which included in emacs's load-path. Then add the following

Configure eshell-mode after upgrade emacs to 24.3.1

Image
Configure eshell-mode after upgrade emacs to 24.3.1 My eshell-mode doesn't works after I upgrade emacs to 24.3.1. I got the empty symbol "eshell-output-filter-functions" error every time I start eshell-mode.  The symbol "eshell-output-filter-functions" located in esh-mode.el. So I need to load the esh-mode.el before the code which refers to the "eshell-output-filter-functions" symbol.  After that My eshell-mode's configure code is as following:  (setq eshell-cmpl-cycle-completions nil eshell-save-history-on-exit t eshell-cmpl-dir-ignore "\\` \\ ( \\.\\.? \\ | CVS \\ | \\.svn \\ | \\.git \\ ) /\\'" ) ;; load esh-mode first ( require ' esh-mode ) ( eval-after-load 'esh-opt '( progn ( require ' em-cmpl ) ( require ' em-prompt ) ( require ' em-term ) ;; TODO: for some reason requiring this here breaks it, but ;; requiring it after an eshell session is s

Plugin architecture design by C

Image
Plugin architecture design by C Table of Contents 1 How to make a plugin architecture in C? 2 Problems I met 3 How I solve this problem? 4 Pros and Cons of plugin architecture. 1 How to make a plugin architecture in C? The plugin architecture is a great design in order to make extensible and resilience software. The software's modules were loaded dynamically from the plugin modules at running time. In C language, this architecture can be implemented by dlopen which is the programming interface to the dynamic linking loader in Linux.  In other words, A software is split into separate modules which are compiled and linked into shared libs. And the software can load the shared libs into memory dynamically, this is what I wanna genesis to be. genesis is a reactor architecture middleware lib that I am working on. 2 Problems I met In order to make a plugin architecture, I use dlopen API to implement plugin modules. But I met some troubles in the d

Adding javascript source code into browser's bookmarks

Image
Adding javascript source code into browser's bookmarks Table of Contents 1 Introducing two awesome web app. 2 How did those buttons works? 3 A hello world example 1 Introducing two awesome web app. First one, Tumblr is a really popular blog system, it provides mobile clients to post articles anytime and anywhere, that's awesome right, what's more, its customized themes and open API is what I appreciated. It's a fabulous app.  For web browser users, It provides a share button which can be added to your bookmarks. So when you find some great articles, and you are urgent to share, what you did is just to click the share button in your bookmarks which you just installed.  This shard button located in http://www.tumblr.com/apps . The second web app is Instapaper , which is a simple tool to save web pages for reading later. I always search articles in the browser, and sometimes I just get too many results, but I have to power off the PC at midn

Using textmate-mode in Emacs

Image
Using TextMate-mode in Emacs As an emacs user, I was always being surprised by some fabulous modes. This time is TextMate-mode, which is a really useful minor mode for the plain text editor.  As a software developer, I always need to jump to some parts of the source code. Command, M-x textmate-goto-symbol, can really kick my ass.  Another thing which exciting me is the jump to a file by command M-x textmate-goto-file. Also, it only works when I am working in a git repository. It just gives me what I needed.  Are there any other functions in this mode which enlightening me? Well, Maybe it makes my tears running down again by other amazing tricks.

Using Gnu Global to navigating source code

Image
Using GNU Global to navigating source code I use etags as the default tagging system to navigating the C-like source code before. It works good, but sometimes it didn't perform as good as ctags which were used by vimer. Table of Contents 1 why not etags? 2 gtags's advantage 3 gtags's disadvantage 4 Install gtags 5 tagging source code systems of emacs 1 why not etags? Etags has a flaw compared with ctags, which is it didn't pop up the mini-buffer when searching a symbol. Which means I can not get options then decide where to jump when multi locations match the symbol. I have to jump one by one to find the right location in emacs with etags,which push me over the edge sometimes.  2 gtags's advantage Today I tried the gtags source tagging system which provided by Gnu Global project.  It can pop up the minibuffer when multiple targets match the symbol, which functions let me felt much more comfortable. 3 gtags's disadv

An Algorithm for rotating a sequence

Image
An algorithm for rotating a sequence I attended a job interview today, the interviewer asks me a question about how to rotate a sequence with a good space efficiency. I believe I give him a terrible answer. And the interviewer gives me his answer, well, thanks him a lot. So how to rotate a sequence? There is a sequence blow?  +--+--+--+--+--+--+--+--+ | 1| 2| 3| 4| 5| 6| 7| 8| +--+--+--+--+--+--+--+--+ then rotate the sequence to left by 3? what we get is as following. +--+--+--+--+--+--+--+--+ | 4| 5| 6| 7| 8| 1| 2| 3| +--+--+--+--+--+--+--+--+ So  the following step to step tutorial is  a space efficiency way. reverse the first 3 sequence. reverse the last (8 - 3) = 5 sequence. reverse the whole sequence. Then, we get the result sequence which rotates to left by 3 items. I don't know whether it is the best way. I mean both the best space efficiency and time efficiency.  orignal sequence n =3 +--+--+--+--+--+--+--+--+ | 1| 2| 3| 4| 5

How android sign your app

Image
android APK employed the same signature method just as java jar package did. there are two ways of sign your app. 1. Use tools in java package   a. make your own keystore keytool -genkey -v -keystore my-release-key.keystore -alias zpcat_key -keyalg RSA -keysize 2048 -validity 10000 b. sign your apk  jarsigner -verbose -keystore my-release-key.keystore MainMenuView_unsign.apk zpcat_key c. align your apk zipalign -v 4 MainMenuView_unsign.apk MainMenuView.apk 2. Use android's private tools a. make key/cert pair by android's private tools development/tools/make_key: android tool to make key/cert pair b. signing apk with key/cert pair: java -jar SignApk.jar platform.x509.pem platform.pk8 Application.apk Application_signed.apk 3 compare the two methods -- the java keystore file .VS. key/cert pair of android (pk8 key file and x509.pem cert file) they are the same stuff. you can import the key/cert pair into your java keystore file by: keytool-impor

Install malabar-mode for java development

Install Malabar-mode for java development (Deprecated) Table of Contents 1 Why Malabar-mode? 2 What is Malabar-mode? 3 Install Malabar-mode 4 Configure Malabar-mode 1 Why Malabar-mode? There are Jdee for java development in emacs, so Why Malabar instead? Jdee is such a huge weapon, that it's so hard to hack into it. It is powerful but probably includes more useless features. What's more, Jdee maybe slow down your Emacs, but you can not fix it. But why not use Eclipse? Well, Emacs just make me cooler. 2 What is Malabar-mode? Malabar-mode is hosted on  GitHub . It provided a much more elegant way to edit java source code compared with Jdee. Just as its Github's page title – "A better Java mode for Emacs". 3 Install Malabar-mode This project stopped upgrade about two years age. So I met some troubles during the installation. Build the package with the following command. mvn package And I got following warning and erro