Posts

How to setup a NAT server?

Image
How to setup an NAT server? Table of Contents What is NAT? How to setup NAT host? a shell script from vbird's book 1 What is NAT? NAT stands for Network Address Transition, which is the basic function of gateway host. I try to hack Bluetooth tethering module in android this week, it include the Bluetooth Pan profile and the NAT setup process, which means in order to implement the Bluetooth tethering, first, two devices must be connected by Bluetooth Pan profile, and then the server part device acted as gateway host to supply the network forward service. In other words, after Bluetooth Pan profile connected, the server must to setup its NAT rules to forward the IP packages. So how to setup NAT rules? 2 How to setup NAT host? My memory is still fresh that at the start of my Linux journey, I setup my Linux desktop as an NAT host to provide Internet services for my lab's classmates. During the days as a programmer, I once did a job to hacking android...

Async Networking in Android

Async Networking in Android (Deprecated, I never use those technology anymore.)  Table of Contents Background Source code examples 1 Background A few days ago, people ask me a question, How to write an application which has to download the resources from the network? or Let me narrow the scope, how to write an android app, which can download the images from the Internet with HTTP protocol and insert the image into a view container like a ListView. So, in this scenario, because the networking connections are always resources burden works, the solution is always put the heavy jobs into the background threads. Following is the equation to that problem. Threads + Cache + HttpClient I found three ways to met this equation after study that topic. Use AsyncTask(thread) directly, put the networking job into a background AsyncTask. Use ThreadPool, which is better than AsyncTask, especially in massive networking connection scenario. Use Volley library, which is ...

Practise Git

Image
Practise Git Table of Contents What's git? Daily Usage 1 What's git? Git, initially started by Linus, is a most advanced distributed version control system. The another kinds of version control system are centralized version control system, SVN is one of them. 2 Daily Usage you wanna stage a file git add file untrack(unstage) a file git reset HEAD file get a diff between staged area and unstaged area git diff get a diff between staged area and last commitment git diff --cached commit staged area into the repository git commit push to the last commitment into the remote repository git push [remote-name] [branch-name] git push [remote-name] [locale-branch]:[remote-branch] remove staged file git rm file # or git reset HEAD file rm file turn back to former status git checkout -- file get a list of all remote repository git remote -v add a remote repository git remote add [shortnam...

A sort algorithm question from a job interview

Image
A sort algorithm question from a job interview Table of Contents Question My Answer After rethinking the question 1 Question Here we are, there is an abstract data type(ADT), which has two members - student number and student score, to represent a student, and there are a millions of the students and the score is ranged from 1 to 100 as integer, there is a container to store this ADT, maybe an array. So please tell me one student's position in this exam in the fastest way. 2 My Answer If you wanna design an algorithm, there are only two points, which you need to focus, space efficiency and time efficiency. They are a perpetual conflict, you can never achieve both space and time efficiency at the same time. Then after a silent break, yeah, I was thinking this question, I believe I gave the stupid answer, just iterate the whole container. Damn it. 3 After rethinking the question The interviewer gave me a hint to finding the most time efficient wa...

Bluedroid stack in android

Image
Bluedroid stack in android Table of Contents Bluetooth stack in android Bluedroid .VS. Bluez Porting guide of Bluedroid stack 1 Bluetooth stack in android From Android 4.2, google use Bluedroid stack as its default Bluetooth host stack, before android 4.2, its default Bluetooth host stack was Bluez, which is also the Linux distribution's default stack. So why google changed its Bluetooth stack? The reason is maybe that Bluez stack was designed for the desktop environment, so in order to port Bluez into android, android must solve some dependency issues, like porting Dbus, Linux desktop's default IPC, into android. So there are at least five processes to power Bluetooth before android 4.2, they are systems, Bluetooth APP, Bluez, hciattach, and Dbus. The damn thing is that there are bugs between them, so Bluetooth stack is the weakest part in the android system before android 4.2, yeah, it is the usual reason that android system corrupted. So, what's t...

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...