Inspired by a tech talk given by the Facebook messenger developer team, I am developing my own instant messenger app on Android, named hummingbird, it’s going to be a light weight messenger app that uses mqtt protocol.
Still at early stage of setting up the UI, working with the famous open source slidingmenu library by Mr Jeremy Feistein. suggestions are welcome!
Things are getting more interesting! I am trying Bitstamp’s websocket api now. Basicly, it uses a third-party tool called Pusher to open a websocket to stream all transactions in real time to your device.
Here are some specs of this version of my app:
DrawerLayout
Fragments: 3, for each of transaction, orderbook, and ticker
Service: 1, in it: AsyncTask fired to pull data from Bitstamp API and store to database if first time use; after that, use pusher to open socket to listen for the streaming data, and store new data to database. This technique used both for transaction and orderbook. another handler for repeatly updating ticker info
Sqlite: 3, for each of the transaction, orderbook, and ticker
ContentProvider: 3, for each of transaction, orderbook and ticker, monitoring the change in database, and presenting the new data to fragments
sharedPreference
TODO: internet connection check on start, and resume pusher after internet reconnected, check user setting, with connectivityManager.getActiveNetworkInfo(), isConnected(), public static final String CONNECTIVITY_ACTION.
first time open without internet, would cause transaction db to be empty afterwards (bulkinsert never called)
I am making a simple Android app to graphically display Bitstamp’s trading data through their API
The app utilizes an open source Android charting library called Androidplot, and a slide menu from here.
The app features AlarmManager to repeatly firing IntentService, the later’s working thread would be pulling data from Bitstamp API (making http calls), and if there are new data, update database (sqlite) accordingly, once database is updated, a Broadcast is sent to the main UI thread and updates the chart.
[Check it out](https://github.com/ericcj24/simple-bitstamp-api-androidclient)new repo [here](https://github.com/ericcj24/bitstamp-api-android2)
I have been exploiting with different designs to approach this problem, here is the newest version, check it out :)
I will try to add more functionality in project in the following days :)
I am making a simple GUI java app to graphically display Bitstamp’s
trading data through their API.
The java app utilizes apache’s httpclient
library to make http connection,
uses Jackson to bind JSON data to Java
class and/or generic containers.
The app also uses jmathplot
libary to help plot the
data.
After some considration, I switched my ploting tool to
JFreeChart for its detailed
documentation.
Find it at my project
repo.
I have also changed the new project to a newer
repo
I will try to add more functionality in project in the following days :)
Twitter is a little vague in terms of how you could make your first
‘hello world’ post, that’s why I am writing this post for your
convenient.
If you, like me, always like to write a python script with Requests
library on the spot just to quick-test some new APIs you encountered,
you could be, just like me, puzzled by Twitter API’s authentication.
Thanks to this
dude
’s hint, I finally made a successful Twitter post (a tweet) through my
what was supposed to be simple python script.
So you should realize that there is OAuth1 function in Requests that
helps you encode all the authorization parameters. And it seems like
Twitter only takes that for a successful authorization. otherwise you
get a 400 error saying not valid authorization :(
Of course, prior to make this call, you need to create/register your
Twitter app at their developer page, and set app’s authorization to both
read AND write. then, you could generate your token and secret. Be sure
to generate token AFTER you set app’s authorization :D Once you have all
consumer_secret, consumer_key, oauth_token, and oauth_token_secret,
you are set to go! Cheers!!!
I have been doing interviews for a while now, companies I interviewed
with range from big names to small inspiring start-ups. Here is a little
murmuring of my reflections on it.
In the data structure class, we know we could traverse a tree in two
basic fashion, depth-first and breadth-first, each of the traversing
methods has recursive and iterative two ways to implement(well I think
every recursive implementation has its iterative way to implement), in
the iterative way depth-first traverse we usually use a stack as a
helping data structure to traverse through the tree, while in
breadth-first, we use a queue (a FIFO first in first out structure).
The brief code showed how powerful breadth-first search could be, it
could help you traverse through each node of a tree, while help you keep
track of the height of the tree. In my recent interview questions, I
also encountered a question that ask me to implement an iterator for a
general tree class, given by the short timing, I also found that the
same breadth-first traverse philosophy could apply to the problem, using
a queue structure as iterator, checking if the queue is empty to see if
this iterator ‘hasNext’. And in another question, where a brief Facebook
Member class is defined, which includes a name and a email address of
the user, and a list of his friends (List), the question was to
ask you to write a function that print out user’s friends first (level
1), then user’s friends’ friends (level 2), and etc etc. You could still
use the queue to help you do a breadth-first search to solve the similar
problem.
Happy Halloween :D Cheers !
This is the code that do a binary search for a value in a sorted array.
C code
Interesting Notes
sizeof(array), if array was the integer array passed as a parameter,
the sizeof(array) would give the actual size of the pointer, not the
actual size of the array, as it interprets array as pointer. (C pass integer arrays as pointers). so it
will be helpful to pass an integer array’s size info together with
the array for child-function’s convenience.
In the binary search phase, while you are jumping around using
array’s index, watch out for the boundary, make sure to cover every
corner.
Binary Search is O (logn) efficient, as half of the search space is
eliminated in each iteration.
Requests is a great python
lib to handle http calls, it is simple and intuitive to use. But when
actually implement your class, to handle exceptions raised by Requests,
the official document seems to be a little slim on it. First, unlike
urllib2, Requests does not treat http errors as exceptions (it has a
status_code to reflect the error, but won’t actually raise the
exception flag). So I implement a customized error class, combined with
a if condition statement, I manage to catch the http error as an
exception.
Python code
c() is the child function that actually takes care of the requests
calling. If in the response dictionary, there is a ‘code’ key, (or you
could use r.status_code != 200), that means there is a http error, and
we could raise our customized error class to pass alone the error
information to the mother function (or class), in our case, the function
d().
and in d()’s exception handling, you could deal with different
situations by implement if condition statement, in the example code, I
just print out the message for demo purpose.
Hope this helps, enjoy :)
Renren is popular Chinese social website. This post introduces an easy
way, and yet different from Douban’s photo uploading previews
introduced, to upload photo to your Renren albums with Python requests.
Python code
Things to take extra care are: use ‘data’ to pass your dictionary when
make a POST call with requests, Multipart-Encoded File should be put in
a dictionary and pass to ‘files’.
cheers!
photo courtesy of
[Vattenfall](http://www.flickr.com/photos/vattenfall/3581236645/
)
The process of pushing green energy is slow. Solar power, wind power,
bio energy development are slow, and there are even some pushing-back on
the implementation of wind farms. Some local residents fought against
the implementation of wind farm off their coast because they worry about
that they may lose their scenery to the ocean. I am a frequent commuter
between Chicago and Champaign by train, and I find it anecdote to see
those lovely white wind turbines standings on the horizon of the green
farm ground.
This brought me to think about how to push public’s acceptance to wind
farm. People are slow to accept changes, and new technologies. I think
about using popular culture as a break through point to re-introduce
wind farm to people.
Associations like a cruise trip to Titanic, empire state building to An
affair to Remember and Sleepless Seattle, and Casablanca to, well, the
movie Casablanca, the unforgettable movies were so successful that it
creates a iconic association between the location where the movie was
filmed and the story of the movie. Without personally experiencing it,
people gradually accept the idea of a new life style, a new product, and
eventually, a new technology. I propose that investment should be put
together to write, and shot a good movie that associates wind farm with,
maybe, say, a everlasting love story. Maybe there could even be a scene
taken right in fhe vast farm ground, the green farm ground filled the
picture, our beautiful heroin stands right in front the white blades of
wind turbine, and re-united her destined mate who just came back from a
serious war fair. The background music is tear-drawing, and in the
background of the picture, the entire wind farm is standing there. The
moving story and beautiful scene would take influence in popular
culture, with wind turbine in it, people would start to accept wind farm
as a friendly, and even welcoming image.
With this publicity, the next step is to raise more money from the
public, with the money, there comes a chance to influence the D.C.. With
persuasive lobbyists in D.C. influence Washington’s law-making in
Gay-rights, Affirmative action, Petroleum and Environment fight, the
green energy, especially the wind farm technology should equip
themselves with a stronger and more influential lobby group. The later
could put more persuasion on congressional decision. And by that time,
we shall see a Renaissance of the green energy.