Google Glass - Great Device But Privacy No More
Google Glass is a great piece of technology in recent years besides iPhone. It's a computer-embedded eyes-wear where the tiny len is the main screen. It's another innovation from Google, and using it is like carrying a computer with you all the time, giving you all the computing horsepower while maintaining mobility.

Great Device
If you think carefully, glass is in fact even better than smartphone.
Unlike smart phone, you have to take it out from your pocket, switch it on and tap on it; Glass attaches itself right infront of you, and is equipped with speech recognition, where you can speak to it directly and make it work wonder.
It is there & on all the time like an invisible device, whenever it recognises command from the wearer, corresponding action will be performed. Data will be streamed to the cloud and make available on any of the google services. This makes technology more fused into our daily lives.
Its seamless integration makes all current application more powerful & accessible. Say, if you are using the map service, you could now have a transparent overlay, where you could read the physical world and virtual map at the same time giving you a better sense on direction; When you are meeting people, no matter who, you could easily have his bio displayed giving you some knowledge right away; Reminders shall no longer be missed like when it's on the phone, as visual reminder is far more prominent plus you shall be wearing the len most of time during the day.
Easily Accessible makes Privacy Impossible
Given glass is so accessible & powerful, this creates problems particularly on privacy. Tasks like taking photo, recording sounds, shooting video could now be done without people even noticing (won't be seeing people holding a device up-straight and shoot; no shutter sound; it's on all the time). What could be the impact of this when it's being abused?
When you talk to somebody with glass on, you might concern whether the conversation is being recoded, and you might not be able to speak comfortably; Confidential documents need to be handled more securely as even a short exposure in the air, could have it be snapped by people around with glass; How about having people wearing it in the toilet – you know what i mean.
Let's see
Will there be law enforcement to help restricting the use of such devices in some venue or occasion? (say hospital, cinema, washroom, workplace). Shall there be some simple LED indicator or sound to notify user when glass is in use? Shall there be a rigorous-review-system like the Apple AppStore to make sure application built for it is appropriate? (Though, part of the Google Glass is now on Google Code open-sourced, which implies jailbreak shall be around the corner).
There's some hype building up revolving around glass, and definitely it's something to pay close attention to for the coming years.
Published on Apr 29, 2013
Facebook Graph Search Review
Facebook Graph Search was announced last month. It's currently in limited beta and target only english audience. As of now, it allows searches on People, Games, Music, Photo and Restaurant.

Having using it for a few weeks, Here's some of my thoughts:
Pros
1. Result are personalized
This new feature is built on facebook social graph, and thru indexing and crunching, search result is much more tailored to your taste and is more relevant. For instance, when you are looking for some new song to listen to or a new dining place, it can recommend you based on your friend's like and check-in, which is more pertinent.
2. Easy access to some interesting findings
With the search bar, you are opened to some free analysis of your social data. You can easily find out which friend of yours is playing a certain game; Whom within your social reach is listening to a certain songs; To go further, you can search people of friends who work at a certain company or have been to a certain restaurant. (e.g. “people who listen to music that my friends who work at facebook listen to”)
3. Like the search result layout
It can be grid and vertical list. But most importantly, it uses big images, which allows users to glance thru quickly.

4. Web search result not messed with the graph search
Unless you specified manually with the “Web Search:” prefix or the query string not being understood by the search bar, graph search will only return social graph data as the result.
5. Can be used as command bar
Even though it's graph search, it also handle personal search well. By that, I mean you can use it like a command bar – To find all the photo you haven taken/posted during an event; Jumping into a particular group you have joined; Showing all your likes… It can in general save a few mouse clicks, which is favorable to computer geeks who prefer key strokes.
Cons
1. Some queries can be cumbersome
As the search bar will guide users to create the query step by step, sometimes, the query string assembled is cumbersome e.g. “Users of apps that my friends use who work at facebook”
2. Not exact match
The search result might not be exactly what you specified. This behaviour is the norm for web search, but for certain social search query, I prefer exact match. e.g. “People who live in Tokyo, Japan” will give you result of people who currently live in Tokyo, with “people who lived/from Tokyo” clustering around.
3. Depends on LIKES
Some result are heavily based on LIKES, but there's no real definition of what a LIKE means. And different people would probably have different interpretation & standard on LIKE (e.g. like-weighting).
4. Result not ranked
Have yet figure out how results are ranked. Seems, it just shows things in random orders. Say, if you make a search on “Music that my friends listen to”, it will just show you singers in random orders. Perhaps, it would be better if it's ordered by number of likes / number of friends who liked, or users could be given a few ordering options to choose from.
6. More information on where the restaurant ratings come from
Right now, the restaurant search gives result with star rating which apparently not coming from social graph data. At least there's no direct way to rate a restaurant on facebook.
7. Missing some logical query
Some logical parameters (e.g. Not, OR) are not currently accepted in the search string.

Neutral
1. Allow thumbing/flagging search result
Search result sometimes might not be perfect, especially when it's about personal taste. Graph data certainly helps alot, but if a thumbing/flagging mechanism is in place, users could easily opt-out some non-interested search entries, and this can provide facebook with some valuable feedback so the system can learn & become better.
2. Make it available on mobile as well
I believe quite many people are looking forward to having graph search enabled in mobile devices. As over 50% of active users are accessing facebook on mobile daily, this can make the feature on the go.
3. Eventually there will be sponsored search result
Eventually, sponsored entries or paid ranking would be expected to appear in the search result, afterall it's how facebook top their revenue. Hopefully, it won't be too intrusive.
So…
If facebook could make the graph search done right, by the time it's out of beta, it will open up an entire new social search space and change the way how people look at search result. It could very likely boost the trust of people on search, and more decision would be made within a short time based on past social interaction rather than anonymous digging on the internet.
Published on Feb 08, 2013
Multidimensional Array in Python
* Gotten some feedback, updated the post. Thanks.
* I like python a lot and in no way saying python performance is bad. Just trying to demo the findings/caveats when one trying to work with 2d array in python.
In Python world, there's nothing exactly like a 2d array (even tho there's the array module, it's unidimensional and more or less aimed at being a bridge to work with C array). To accomodate, very often list/dict are used to emulate array to perform some multidimensional computation. Thought, when data size is non-trivial, one will discover that such way might not be optimal.
How to define 2d array?
Say we want to declare a 2d array, we can make use of nested list/dict or list with calculated positional offset.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 | # 1. nested list
# >> arr
# [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]]
arr = []
for i in xrange(2):
arr.append([])
for j in xrange(5):
arr[i].append(j)
# 2. nested dict
# >> arr
# {0: {0: 0, 1: 1, 2: 2, 3: 3, 4: 4}, 1: {0: 0, 1: 1, 2: 2, 3: 3, 4: 4}}
arr = {}
for i in xrange(2):
arr[i] = {}
for j in xrange(5):
arr[i][j] = j
# 3. list with positional offset
# >> arr
# [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]
# to access element at (1, 2)
# >> arr[1*COL + 2]
arr = []
COL = 5
for i in xrange(2):
for j in xrange(5):
arr.append(j)
|
They looks neat and does the job. However, there's some caveats when array size you are working on is sufficiently large.
Something Wrong
Below is a simple test to illustrate the issue. They are the code pieces written in Python and C respectively to perform the exact same task. Try run them, and time the running process.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # Python Sample
# Not that list version performs relatively better than using dict,
#
# 1. nested list version
LIMIT = 10000
CACHE = []
for i in xrange(LIMIT):
CACHE.append([])
CACHE[i].append(1)
for j in xrange(1, i):
CACHE[i].append(CACHE[i-1][j-1])
# 2. nested dict version
LIMIT = 10000
CACHE = {}
for i in xrange(LIMIT):
CACHE[i] = {}
CACHE[i][0] = 1
CACHE[i][i] = 1
for j in xrange(1, i):
CACHE[i][j] = CACHE[i-1][j-1]
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | // C Sample
#include <stdio.h>
const int LIMIT = 10000;
int CACHE[LIMIT][LIMIT] = {0};
int main() {
for (int i=0; i<LIMIT; i++) {
CACHE[i][0] = 1;
CACHE[i][i] = 1;
for (int j=1; j<i; j++) {
CACHE[i][j] = CACHE[i-1][j-1];
}
}
return 0;
}
|
Result:
// 1. list
time python sample.py
real 0m20.217s
// 2. defaultdict
time python sample.py
real 0m31.871s
time ./sample
real 0m0.392s
From the result, it's obvious that there's a large performance discrepancies between those codes, where Python is unexpectedly slow. But WHY?
Breaking the Myth
As an interpreted language, Python is translated into bytecode and only during runtime when it's being interpreted. The performance of such approach is significantly slower when compared with compiled machine code. On top of that, due to dynamic nature of Python, rebind & lookup are always performed behind the scene.
As an example, refer to the Python code snippet above (nested dict version), on each iteration, extra time will be spent to re-bind variables i & j, and lookup will be perform when i, j & CACHE are used. This account for most of the running time the program required. Such kind of negative impact is especially obvious when loops & array-like (e.g. list, dict) code are involved.
In addition, unlike pointer in C, list/dict data structure in Python does incur additional cost both in memory and computation. (NOTE: list/dict are much more than a C-Array. They actually offer much more in terms of functionalities & flexibilities, and is actually heterogenous where you can store arbitrary type of objects together). Therefore, there might be chance where the large array stored are actually taking more memory than the available. Considering the nested dict example above, an approximate of memory required would be as follows:
// nested dict example
dict = 280 Bytes, int = 24 Bytes.
Approx. Total Memory Required:
= 280 + 10000 * 280 + 10000 * 10000 * 24
= 2402800280 Bytes = ~2.4 GB
Memory Paging will occur if available memory is less than ~2.4GB. In such case, the process would be terribly slow.
Possible work-arounds/solutions
- A proven fix is to introduce Just-In-Time compilation (JIT) technique, which is what pypy is for. JIT inspect and analyze a piece of code in run time to determine what to compile for optimization, e.g. Knowing i, j & CACHE are just assignment references, eliminating unnecessary rebind(s) and lookup(s).
- Numpy provides some fast array functions written in C. Try using it as much as possible as they are well written. (e.g. numpy.zeros, numpy.arange)
- Move that particular piece of code to C extension and wrap it with Python code.
- If really, all the above can't be your options, then simply dun use Python for that specific task (advocate of right tools for the right task)
Thoughts
I still like python list/dict alot as they're really flexible & simple. They are created to serve greater and more general needs. And as one of the comment goes:
There are certainly places where every bit of performance out of a collection matters, but there are more places where being able to quickly put together code that works correctly matters (for one thing, being able to quickly put together correct code makes it possible to correctly identify the bottlenecks where you need to optimize performance.)
Published on Feb 04, 2013
Amazon Has Great Customer Service
My shopping experience with Amazon would just be a few paperbacks and a kindle touch. There's nothing much I could talk about but one – their Customer Service.
Few months ago, the kindle I owned was somehow broken, the screen was filled with e-ink and couldn't refresh (except a corner). What's more was the fact that the kindle was purchased back in the states thanks to a friend, but I was actually living in another side of the world. The annoying scene where I would have to ship the kindle to my friend first and so she can follow up for me kept popping up. There's a moment I almost wanted to let go and get a new one; But come on, the kindle was just less than 5 months old.
One night, I pushed myself hard enough to visit amazon help page, where I was fond of finding a live-chat services. I was quickly paired with a representative. Without much questioning, the representative email me a paid delivery tag (for sending back the faulty device) and arranged a new kindle shipment, which I was able to pick up after 2 days.
I was surprised. Their customer services were so professional, and they actually think like as if they were in my shoes. They tried to get the issue resolved asap, and avoid discomforting me or bothering me by asking loads of questions (you know what, some companies like to annoy users to an extent that users would just give up). They have gained my trust on their services and it's certainly the best way to do user retention.
Behind this, I believe it's not just the effort of technological advancement, but it's the company's vision and well-trained crews that drives the service level this high.
* Shouldn't this be the benchmark for other customer services?
** To all service startups out there, customer service is actually a critical part of the business.
Published on Dec 23, 2012
Some IE Pitfall
When you are doing web development, you should make sure cross-browser compatibility is being handled. Out of all the browsers, Internet Explore (IE) is the one that you can't miss while renowned of being the most troublesome to cater. Some recent web development have me learnt some more IE pitfall that I want to document:
1. CSS chain rule doesn't work when QUIRKS Mode is ON
QUIRKS Mode is a technique employed by IE to maintain backward compatibility for old website design. However, if it's not explicitly turned off, IE won't respect CSS chaining (and some other W3C standards). To turn it off add the below doctype to your html:
| <!-- Add this to the top of HTML to turn off QUIRKS MODE -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2. IE 7 & 8 ignores padding for positioning an DOM element
To position DOM element, try using margin over padding, as padding might not be calculated and applied like you expected in IE 7 & 8.
3. jQuery UI 1.9.2+'s Draggable makes IE content view shaky
jQuery UI provide function for turning a DOM element draggable. In the latest version (1.9.2), the drag function still functioning okay, tho making the content view of IE shaky. So keeping jQuery UI on version 1.8 is recommended.
4. There's nothing as “pointer-events” in IE
pointer-events could be used to instruct the browser to ignore event for certain dom element and pass the event down to the element below. Such function doesn't exist for IE (thought it's not limited to IE, but Opera as well)
Published on Dec 20, 2012