Randomness « Ants Nguyen | Work, Photography and random goodies

Ants Nguyen | Work, Photography and random goodies

30Sep/12Off

My first day in Rome

Let me first start by thanking Jady, Heidi, etc on slow talk. Its been an amazing resource to make the most of your trip. It seems most folks on the forum believe in taking it slow... quite the antithesis of what I'm doing. But, nonetheless everyone on ST has been amazingly helpful trying to fit in what I can.

I actually did not have an itinerary 7 days before my trip. I was of the mindset that, Roma is amazing and whatever happens happens. As the departure date drew closer, I realized my assumptions were poor and I had to get my butt in gear! With the help from ST... I can now officially say my trip thus far has been AMAZING (Naples & Capri were meh.. I'll post about those places at a later date).

I got in last night around 7pm, I had a great conversation with an Australian couple who happen to live in Canberra (my hometown!). I got a real kick out of their apparent interest in US Politics. They were Obama supporters and felt like Romney and FOX News were a joke. They also mentioned something I found interesting... Australian news paints America as somewhere where unemployment has hit hard as if it were the great depression all over again. The train ride overall was a short one only an hour long from Naples to Rome. I used trenitalia and I must say... go with the PNR booking code on your phone if at all possible. If you dont, you need to line up for a ticket, and you must get it validated before you get on the train.. AND THEN present the ticket again while onboard. Eff that!

Once I arrived I checked in, rested a bit and went straight to dinner. My first dinner in Roma was at Flavio al Velavevodetto. Overall, my untrained palette thought it was quite delicious. I had the Rigatoni alla Carbonara, then the Polpette al Sugo, and wrapped it up with some Tiramisu.

I was too thoroughly enjoying my meal I forgot to take pictures of the Rigatoni alla Carbonara or the Tiramisu.

The chef even came out to say hello. I had my picture taken with her 🙂

6Mar/12Off

Python websocket on Centos 5.x

I am currently running a VPS as a playground and my SVN repo and decided to go ahead and set up a websockets server as well. This proved to be a little tricky but eventually got it working. Note that installing the default mod_python will give you version 3.2.8. pywebsocket requires Python 2.3 and up and mod_python 3.3 and up. Heres how I set up my server:

Start off by enabling EPEL if you haven't done so already:
rpm -ivh http://mirrors.kernel.org/fedora-epel/5/i386/epel-release-5-4.noarch.rpm

Next, install Python 2.6
yum install python26

Then install mod_python 2.6
yum install python26-mod_python

I chose to run it under apache so next you need to edit your httpd.conf file.

LoadModule python_module modules/python26-mod_python.so
LoadModule python_module libexec/apache2/python26-mod_python.so

AddHandler mod_python .py

Please note the path to Python as well as the PythonOption path. I put my websock handlers in the var folder but you can put it anywhere just make sure to create the document root for those websocket handlers.

After this you can restart your server:
/etc/init.d/httpd restart

Once restarted you can then download the pywebsocket repository

cd
svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only

Then install:

cd pywebsocket-read-only
cd src

python setup.py build
sudo python setup.py install

Next you will need to also add this to httpd.conf:


PythonPath "sys.path+['/usr/lib/python2.6/site-packages']"
PythonOption mod_pywebsocket.handler_root /var/websock_handlers
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler
PythonOption mod_pywebsocket.allow_draft75 On

Then all you have to do is restart apache, create the repository from above (in my example it is /var/websock_handlers). Then cp over echo_wsh.py from the /src/examples directory. Finally all you need to run is ./echo_client.py and you should receive some output similar to:


Send: Hello
Recv: Hello
Send: 日本
Recv: 日本
Send: Goodbye
Recv: Goodbye

Filed under: Randomness Comments Off
22Feb/12Off

Event based Atlas tracking

So I ran into this issue where there was absolutely no documentation on how to handle Atlas tracking on non-page-load events. Typically Atlas would provide a tracking sheet with code snippets that you can add to your page. This is all great except these drop in code snippets really only fire at page load and not on an event.

What I originally received:

To turn this into an event based tracking tag you will need to use JavaScript and add the following:


function fireAtlasActionTag(uniqueActionTagCode) {
var atlasJavascriptTag = document.createElement('script');
atlasJavascriptTag.type = 'text/javascript';
atlasJavascriptTag.src = 'http://view.atdmt.com/jaction/' + uniqueActionTagCode;
document.getElementsByTagName('head')[0].appendChild(atlasJavascriptTag);
}

and finally to call the tracking tag:


fireAtlasActionTag('SOME_TRACKING_TAG');

Filed under: Randomness Comments Off
22Dec/11Off

Facebook Authentication failing to pop up

Using the Facebook JavaScript SDK for authentication things have recently changed to OAuth 2.0.

Calls to FB.getLoginStatus are now different.

Old Method

FB.getLoginStatus(function(response) {
if (response.authResponse) {
// logged in and connected user, someone you know

} else {
}
}

New Method

FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and connected to your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
//but not connected to the app
} else {
// the user isn't even logged in to Facebook.
}
});

Filed under: Randomness Comments Off
12Jul/11Off

Posting to a user’s wall

Use the feed dialog

  • Post to viewing user's wall
  • Use a friend-selector - requires page refresh - to send message directly to friend of viewing user
  • Attempting to capture the data prior to page refresh has not worked thus far - still trying to figure this one out
  • Unable to tag user's in posts

Use the Graph API

  • Requires user permission and requested extended permissions for stream publishing
  • Seems that tagging MAY be possible via Graph API - see: facebook developer forum and tag user and doesnt seem to work
  • Would post behind the scenes and not show a feed dialog
Filed under: Randomness Comments Off
11Jul/11Off

Developing on Facebook is Difficult

Changes
Facebook is constantly going through revisions and constantly dealing with new bugs that arise within their system. Developers back in the day had only one option for developing within Facebook. That was FBML which is a proprietary language specific to Facebook. In addition, Facebook also released FBJS into the wild which was a ultra trimmed down Javascript library for use in Facebook applications and application tabs.

EOL for certain code
In 2009 Facebook announced they would be deprecating FBML application tab support. They had already deprecated canvas applications in FBML a while prior. The interesting thing is that some FBML tags have been migrated to XFBML while others have not. Things such as fb:multi-friend-selector have not been completely ported to XFBML (unknown whether they ever will) and require the use of a clunky serverFbml tag.

Lack of documentation
Documentation on Facebook has been lacking and a point of emphasis for them currently. Functions are not documented and others are still buggy even though they are listed. The best resource for help on Facebook isn't even their forum because it is dead, but rather Stack Overflow

Filed under: Randomness Comments Off
2Jun/11Off

How to: Enable NSZombie in Xcode 4

NSZombies are a great way for tracking down premature release of objects while coding Objective C. Here's quickest way to enabling them:

Then uncheck the top check box so that you can add Environmental Variables then add NSZombiesEnabled and set its value to YES

Filed under: Randomness Comments Off
27Mar/11Off

UINavigationController + UIViewController + UITableView

For the longest time I've been trying to figure out how to do something similar to how Contacts on the iPhone handles display. I initially thought it was a highly customized UITableViewController but now I've figured out a way to do it with a UIViewController and an embedded UITableView.

I will post a tutorial shortly but here are a few screenshots.

Filed under: Randomness Comments Off
4Mar/11Off

Outklouted the CTO


Filed under: Randomness Comments Off
10Feb/11Off

Klout Kills…. but what it kills you decide.

It seems that klout.com has taken over our department. CTO + Klout have joined forces to potentially decrease productivity in the office by who knows how much. Me posting this post @ 10am on a Thursday also reaffirms that fact.

Is this scary? Yes. Does this mean we are less productive? Who knows. I'm no scientist. But below you can see my coworkers and myself and I have outlined the work hours in red.

Filed under: Randomness Comments Off