Posts

Showing posts from 2013

Dropbox Hacking

Image
Dropbox hacking Table of Contents Background How Dropbox implement its command mode? Loading image from serialized data 1 Background Yesterday, I upgrade my ubuntu into Trusty Tahr, the development branch of the newest ubuntu. Dropbox is one of many problems after the upgrade, although I found the solution finally, I discovered that Dropbox's technology to release software is worth hacking. Another reason to hacking Dropbox is that I love it so much, my daily works in computers depended on it, it is the coolest cloud storage tool, absolutely the best one. The first time I run dropbox after I install it, it emits a dialog to indicate the progress of download a package from its website, which is the real program to does the sync job, and its default install location is ~/.dropbox-dist. I think that's so cool, and I wanna learn how to do it. This article is hacking Dropbox release package in a linux environment. I tried to hack its Mac OS X's package,

Qt is on the edge of cross-platform GUI framework

Image
Qt is on the edge of cross-platform GUI framework Table of Contents Qt in my view New version of Qt5.2.0 released Qt in Ubuntu This may be the beginning of serial articles related Qt. 1 Qt in my view There are two targets in the current stage of my career . One of them is to be a GUI programming export, the another is to be a master of wireless communication software engineer. So let's come back to GUI programming, there are two targets in this field as a former Linux programmer, GTK, and Qt. My personal favorite to that two platform can be separated into two phases. At the beginning, I was once a GTK advocator, because I tried both KDE and Gnome desktop environment, I have to declare that I like Gnome much more than KDE. KDE is developed by Qt while Gnome is completely built on the GTK. I guess that was why I like GTK much more at the beginning. The other reason is that most Linux distributions, like ubuntu and fedora, was tight bounded with some of GTK

iTerm2 Configuration in Mac: Line editor configuration

Image
As a Linux programmer, I used terminal tools a lot in my daily life, I use terminal tools to search dictionary, to play multimedia resources, to editor files, I also can play movies in the terminal, do you believe that? I also use terminal tool to suspend my Laptop.  You know something changed after I am rich, I purchased a MacBook, which is really beautified. As I start my Macbook journey, I remembered that the first application I opened is Terminal, but it was so silly. I felt so uncomfortable without an awesome terminal tool. Then I found iTerm2, which was said the best in Mac. But the nightmare was just the beginning, iTerm2 was great, it is the Macbook's keyboard layout, there are only left Ctrl key. Damn, that meaning I have to change the memory muscles to adjust the familiar finger gestures, especially the line editor navigation key bindings like Ctrl+A to the beginning of a line, Ctrl+E to an end of the line, ... Tonight, I finally found the right ways to remap the

Glib resume

Image
Glib resume Table of Contents Overview of Glib Glib's main event loop Threads Asynchronous Queues Dynamic loading of Modules Memory Management IO Channels 1 Overview of Glib The fully glib document was located in the glib website. This article is nothing but just repeat what I learned from above website. Or I consider this as an echo from mystery valley, because Glib is excellent, which provided both portability and elegant solution for the cross-system programer, it should be my base utilities in my daily programming life. 2 Glib's main event loop I think the main event loop is the heart of the glib library, and it is the most import part of this library. So why? Because the event loop engine is always the critical and basic part of the architecture of a project. There are many paradigms of the architecture of event loop. Glib is based on reactor model which is also the most popular and developer friendly paradigm. A reactor model can be sep

Hash functions in web security

Image
Hash functions in web security Table of Contents What the hash function is? Http Cookies password 1 What the hash function is? A hash function is a one-directional one-to-one or multiply-to-one function, which can project data in one space to another, but not reverse. The key point here is one-directional projection, if you found a way to reverse this process, then this hash algorithm is corrupted, if the hash algorithm corrupted, the whole web security is down. You would not want that happen, right? So, which hash functions are the popular ones? the popular hash function includes md5, sha256. In python standard distribution, it provided an hashlib module which provided the usual hash functions. The following code snippet is an example to get digest from messages by python's hashlib module. The digest is the hash value of a message.  digest = hash(message). import hashlib hashlib.md5( 'hello world' ).hexdigest() hashlib.sha256( 'hello wor

Configure Emacs's PATH environment in Mac OS X

Image
Configure Emacs's PATH environment in Mac OS X Table of Contents Background Why did that sad thing happen? 1 Background Yesterday, I wanna send a love letter to a chick who I am chasing on-line. So I decided to send this letter by my favorite email client GNUS in my favorite editor Emacs to show my passion and love, but sad things happened(Seriously, Should I still being single and lonely?) , I got following errors: My customized email signature corrupted, which supposed to attach a joke and an ASCII art. Following is the error message, if I sent those error message to a girl, I must be out the game, right? /bin/bash: fortune: command not found /bin/bash: cowsay: command not found I can not send emails in GNUS anymore. smtpmail-send-it: Sending failed: 530 5.7.0 Must issue a STARTTLS command first. y9sm60423107pas.10 - gsmtp Although I have another puzzle which can be classified as same kinds of problem, In eshell-mode, I can not found the right

Install GTK+-3.8.7 into Ubuntu 12.04 from scratch

Image
Install Gtk+-3.8.7 into Ubuntu 12.04 from scratch Table of Contents Preparation How the compile the source code from the beginning? 1 Preparation The first step is alway to download the needed package. I give the following shopping list: software package Download URL glib-2.36.4 http://ftp.gnome.org/pub/gnome/sources/glib/2.36/ gdk-pixbuf-2.28.2 http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/2.28/ atk-2.8.0 http://ftp.gnome.org/pub/gnome/sources/atk/2.8/ fontconfig-2.11.0 http://www.freedesktop.org/software/fontconfig/release/ harfbuzz-0.9.24 http://www.freedesktop.org/software/harfbuzz/release/ pango-1.34.1 http://ftp.gnome.org/pub/gnome/sources/pango/1.34/ libatk-bridge2.0 http://packages.ubuntu.com/zh-cn/quantal/libatk-bridge2.0-0 libatk-bridge2.0-dev http://packages.ubuntu.com/zh-cn/quantal/libatk-bridge2.0-dev gtk+-3.8.7 http://ftp.gnome.org/pub/gnome/sources/gtk+/3.8/ My operating system is Ubuntu 12.04

How Bluetooth LE works? -- Host stack

Image
How Bluetooth LE works? – Host stack Table of Contents 1 Bluetooth LE hosts stack architecture 2 L2CAP 3 Attribute 4 The Attribute Protocol and The Generic Attribute Profile 1 Bluetooth LE hosts stack architecture +----------------------------------+ | | | Generic Attribute Profile | +----------------------------------+ | | | Attribute Protocol | +----------------------------------+ | | | L2CAP | +----------------------------------+ Bluetooth LE's host stack is built under the Host Control interface, which is used to connect with controller part. As showing in the above figures, there are at least three layers which need to introduce in

Use readline library to built command line tools

Image
Use readline library to built command line tools Table of Contents 1 Why readline library? 2 How to use it? 1 Why readline library? As a Linux programmer, I always need to write some command line tools, with the help of GNU Readline library , this mission can be a snap. So what's the readline library gives for us, according to its official document? It provides a set of functions which allow users to edit command lines as they typed in. What's more, it also supports history recording and auto-completion. It is GNU software and is distributed under the terms of GPL license. 2 How to use it? I upload my source code, using the readline library, which implemented a silly command line tools with only two command inside – help and quit, but I can add another command easily in its framework. It support history recoding, which means you can browser the your command history by up/down keys, but it still cann't support command auto-completion(I will ad

How Bluetooth LE works? -- Link Layer

Image
How Bluetooth LE works? - Link layer Table of Contents 1 Bluetooth LE system architecture 2 Bluetooth LE Physical layer 3 Bluetooth LE Link Layer states 4 Bluetooth LE Link Layer packets 1 Bluetooth LE system architecture This is the first post and hopefully a series of upcoming postings about Bluetooth Low Energy. Above figure is the protocol stack of a whole Bluetooth LE system. The Bluetooth LE is one part of Bluetooth v4.0 specification, it was designed not to pursue high transmission speed but for lower energy consumption. So the Bluetooth LE products can be powered by a button-cell battery for years. How did it do that? This article is a review of Robin Heydon's excellent book – Bluetooth Low Energy, the developer's handbook. Bluetooth LE is completely redesigned of classic Bluetooth protocol, It seems that both the Bluetooth LE and classic Bluetooth has the same architecture from above figure, but actually they are so different inside, an

tts-mode for emacs update - support Mac OS X's tts engine

Image
tts-mode for emacs update - support Mac OS X's tts engine Table of Contents 1 Support Mac OS X's default tts engine 2 Configure and Install tts-mode 1 Support Mac OS X's default tts engine After I owned an Macbook air, I tried to port tts-mode into OS X system. I installed espeak command line tool into OS X, it works well just like in linux system. Thanks to the excellent portability of elisp source code, I need not to change any source code. I still have not installed festival tts engine into Mac OS, but it seems have many tutorials to do it. After that I found OS X's default tts engine, which provide an command line interface, has much clearer and greater fluency than both espeak and festival. So I wonder if I can support OS X's default tts engine. Then here it is, the new tts-mode . 2 Configure and Install tts-mode Reference the following codes: (add-to-list 'load-path "path/to/tts-mode" ) ;; configure tts engine'

Which storage cloud to choose?

Image
Dropbox, Box, Google driver, Ubuntu one or icloud ? Table of Contents 1 Storage in cloud products 2 My working environment 3 How Storage cloud improved my life? 4 Which product I like the most? 1 Storage in cloud products Now I wanna too share some good storage cloud products that I used in my daily work. A good storage cloud tool can offer you so much convenient in daily life and increase your productivity and efficiency at work. Here is my own experience with some cloud products. So, What is the storage cloud products? It is a services that can store your data into cloud and can share it everywhere. Here is the storage cloud services that I already used. free size OS compatibility GFW compatibility Dropbox 5G Linux, Mac, Windows OK Box 50G Mac, Windows OK Google Driver 15G Mac, Windows Need to fuck GFW ubuntu one 5G Linux(ubuntu), Mac, Windows OK icloud 5G Mac, Windows OK 2 My working environment Before to illustrate this question, I

Install Bluez host stack from source code for linux

Image
Install Bluez host stack from source code for Linux Table of Contents 1 Why install Bluez5.8+? 2 Install Bluez5.8 into Linux distribution 3 How to start the newest Bluez stack daemon? 1 Why install Bluez5.8+? Bluez is the host part stack running in Linux. Install the Bluetooth LE feature supported Bluez was really important during develop the Bluetooth le apps, it can run your test case on your Linux PC at least. But Why Bluez 5.8 and later version? The Bluez stack was developed so quickly during the past one years from 4.100 to 5.9, its source code's quality was really promoted a lot after those frequent releases. What's more, Bluetooth LE was officially supported after Bluez 5.0 release not just experimental features in the older version.  The mainly Linux distribution's Bluez version, like Ubuntu13.2 or Fedora 19, still remained in 4.101, which means Bluetooth LE still in the experimental stage at the latest Linux distribution system . 2 Inst

Bluetooth Introduction

Image
Bluetooth Introduction Table of Contents 1 What's Bluetooth? 2 Bluetooth stacks 3 Bluetooth profiles 1 What's Bluetooth? Bluetooth is a wireless communication technology. Its name comes from an ancient Denmark king, Harald Blatand, in the tenth century, who united the dissonant Danish tribes into a single kingdom. Because he likes to eat blueberry, his tooth was always colored to blue, people gave him a nickname Harald Bluetooth instead. And also, the Bluetooth's logo comes from this king's first two names and the band of the ancient North Europe characters.  How many parts did a Bluetooth system consisted of? The following figures illustrate the basic parts of a Bluetooth system. +----------+ +----------+ | | | Host | | host | | | +----+-----+ +----+-----+ +----+-----+ +----+-----+ | LE | | BR/EDR | |Controller| |Controller| +----------+ +----------+

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