Posts

Dependency Injection in Android with Dagger 2

Image
Dependency Injection in Android with Dagger 2 Dagger’s Power Dagger 2 is the upgraded version of the original Square’s Dagger, designed for dependency injection(DI) technology for java. DI’s sensational ability is to decouple the dependency relationship between objects, clear the code, and also let developer focus to the functional classes. In the complex framework & architecture, DI becomes the standard component, like Spring. Similarly, If you wanna write agile and maintainable code in a large and long-term run Android project, Dagger should be an not so bad option. How to install codepath/android_guides Many Android apps rely on instantiating objects that often require other dependencies. For instance, a Twitter API… github.com The first step always to install Dagger 2, unfortunately, the  official document did not give any details in Android’s Gradle build environment. Yeah, Dagger is not just for Android, but for any Java Project. The good news is above...

ReactiveX Operations

Image
ReactiveX Operations Table of Contents Resources ReactiveX Operations Sample Source code 1 Resources http://reactivex.io/documentation/operators.html http://reactivex.io/tutorials.html https://github.com/ReactiveX/RxJava/wiki/Additional-Reading 2 ReactiveX Operations To understand ReactiveX, We must consider everything as a stream, after that, the operations of ReactiveX stream was so complicated, that we can trade them as a new language, which operates the stream. The ReactiveX's Official document classify its operations as following categories: Creating Observables Transforming Observables Filtering Observables Combining Observables Error Handling Operations Observable Utility Operators Conditional and Boolean Operators Mathematical and Aggregate Operators BackPressure Operators Connectable Observable Operators Operators to Convert Observables Beside above categories, ReactiveX also provides the strategy to practice those operation...

My Emacs Configuration

Image
My Emacs Configuration Table of Contents What is it? How to install my configure The most complicated part Code location 1 What is it? I have at least three desktop machines works right now, running Mac OS and Linux. I found that's a messy and dirty job to configure my emacs again and again after reinstalling the system. This project is a convenience collection my configurations of emacs and reinstalls them quickly into another machine. I had worked in a similar project formerly, not a so pleasure experience, I commit everything located in ~/.emacs.d into a git repository, after realize how silly it is, I abandon that project. This new project is an upgraded version, more light weight, just upload my own configuration without the third party modules. 2 How to install my configure steps 1 create your .emacs.d directory into your home directory cd ${ HOME } mkdir .emacs.d steps 2 clone the code into your ${HOME}/.emacs.d directory cd ${ ...

Learning Lua

Image
Learning Lua Table of Contents Background Tables metatable functions coroutine Lua as Object-oriented programming 1 Background Lua as an embedded language was popular in the game industry and also in any embedded scenario. I tried to wrote a Lua module for Nginx, which already has a ported Lua environment inside. And since this is my first time to get familiar with Lua, and to enjoy its simplicity. My learning materials were no special, but its official document . I wrote my notes down in order for future review. 2 Tables To understand table is to understand Lua, or in another word, Lua's syntax was nothing but just tables, no more. Tables in Lua is in similar with the dictionary in Python, in my view. a = {} a.x = 1 a[ 'x' ] = 1 2.1 metatable Lua's metatable is similar to magic methods in python. 3 functions Lua as a functional programming language, because the function is also the first-class variable. That...

ReactiveX Asynchronous Programming In Java

Image
ReactiveX Asynchronous Programming In Java There is a much detailed blog about ReactiveX of myself, checkout here . Table of Contents What is Asynchronous programming? Ways of Asynchronous programming in java Java Callback functions Java Future Benefit of RxJava 1 What is Asynchronous programming? The asynchronous issue exists, because of the blocking nature of every activity in reality. Every operation consume time, in theory, computers need to take at least one frequency to execute one instruct, it takes time between every oral conversation in the speed of voice at least. That's the blocking nature of this world, and the most valuable resource of all is the time. Some times the computer cannot wait for that longer for the blocking API, like in network communication, it waste of the computer resource so much. The another reason is the event-based scenario. In a network connected chatting app, program listens for every coming data continuously and output ...

Android Account Manager

Image
Android Account Manager Table of Contents the begging of an Internet mobile app Account Management Demos 1 the begging of an Internet mobile app The first component that an Internet startup needs to build is its user system. How to expand his users in an easily, convenient and user-friendly way, and how to develop its account system in a scalable method? The account system is the crucial and the most important part of a company, most of the content and service provider companies always develop its account systems followed the oAuth standard. There are third party authentication plugins, like stormpath and Auth0 targeted into those account management field, you can build your web app above that service. For an Android mobile developer, there are already a middle-ware in API level, AccountManager. Take a glance of Account preference in the Setting App, and experience how Gmail, Youtube, and G+ works with multi-shared google accounts and switch between them i...

Logical Volume Management

Image
Logical Volume Management Table of Contents What is LVM? Conceptions How to create PV create VG create LV 1 What is LVM? LVM stands for Logical Volume Management, which is one kind of virtual disk partition. In the traditional way, We need to separate a disk into multiple partitions, then format that partition with a filesystem. Once you write the partition table to the disk, rewrite this table will lose all your disk data. But, LVM gave more scalable and dynamic options, we can adjust and re-create partitions without reboot and re-mount process. 2 Conceptions VG:   Volume Groups PV:  Physical Volumes LV:   Logical Volumes Volume Groups is a collection of Logical volumes, and it is created on top of physical volumes, Physical Volumes are physical disk partitions with LVM header. Logical Volumes are the final partitions that we can format with our favorite filesystem. Topology of these concepts: one Volume Group can include more...