Skip to main content

Posts

Showing posts from 2010

Double Checked Locking And Java Singletons

I read this article by Bill Pugh on why the double checked locking idiom does not guarantee thread safety in Java Singletons. That article taught me a lot of new things, and to be honest, I had to re-read that article at least a couple of times to partially understand it :-) I recently created a presentation to make at DevCamp on this topic. What follows are my slides and an explanation of each slide. I hope you enjoy this presentation and find it useful. Double checkedlockingjavasingletons View more presentations from parag . slide 1: In this presentation I will discuss the double checked locking idiom, and explain why it does not work to provide thread safety to Java Singletons. I will also talk about how using volatile fields will fix the problem in JDK 1.5 onwards. slide 2 (Singleton): Many of you might already have used the Singleton design pattern . In case you have not, here is a brief description of what Singletons are. The Singleton pattern is used when we want to ensure

DIY Masters in Computer Science

Since my formal education, a lot of advances have taken place in software development. I have been able to keep up with a few with regular reading and practice. But a lot of this learning has been a bit random, and as a result a bit dissipated as well. I feel like I want to engage in continuous learning, in a more organized manner. Over the years there are several core concepts which I have forgotten because I have not been able to use them in my regular work. I feel like relearning those concepts. I think the volume and content of both these can constitute a masters course in Computer Science. But I do not want to go back to school. Not because there is anything wrong with school - I had a great time in grad school. But here's why... I don't want to go back to school because I want to define the courses I want to learn, and not pick up from what's offered. I don't want to go back to school because I want to be able to learn at my own pace, which at times may be slower

Android apps can run in parrallel (video)

This is the seventh in a series of videos published by Google on Android programming. In this video the speaker starts an app to track photos his buddy publishes on Flickr. He can keep this application running in the background, so while he is browsing or checking his email, this application will constantly track the photos and notify him if a new photo has been uploaded.

Adndroid apps don't have any borders (video)

This is the sixth in a series of videos provided by Google on Android programming. Index: 00:00 Introduction 00:32 Zebra crossing application 01:35 Library app 02:14 A GeoSocial app which combines user GPS, user created photos, and Compass My Takeaway: Android applications do not have any borders. They can use data from other applicatiosns, they can use hardware available on the device such as camera, compass, GPS, accelerometer, etc, and they can also use content from the web API's. The first application called Zebra Crossing is an application which can pull information from bar codes and QR codes. So if you photograph a product's bar code and give it to the application, it will pull up information about the book from the web. If on the other hand you give it a QR code from the back of a business card, it can extract contact information about that person which you can use to call or send email. The Zebra Crossing app also publishes intents, to allow other applications to commu

How to embed the web in Android apps (video)

This is the fifth in a series of videos provided by Google on Android programming. This video shows how we can use the WebView to create applications that render HTML pages. Along with being able to embed HTML and Javascript web pages in apps, the most exciting thing I found in this view was the fact that the Javascript in a webpage can communicate with Java code and Java code can communicate with javascript. This is really cool.

Android programming - All applications are created equal (video)

This is the fourth video in the series of videos provided by Google on Android programming. Index: 00:25 Dianes ringtone app 01:08 App to create a shortcut to anything on the system 01:36 Replacing the home screen (End at 02:17) My Takeaway: This video shows that all applications created on the Android platform are equal. Even though I have not done any iPhone development, I believe applications written for iPhone do not have access to everything the way Android applications do. So this is a positive for Android development. In this video we see how to a custom application can change the ringtone on an Android phone, how another application can create shortcuts to anything on the phone, and how we can also change the 'Home' application.

Android Programming - API's (Video)

This is the third video in the series of videos provided by Google on Android programming. Index: 00:00 Introduction 00:16 Android API's 00:24 Location Manager 01:25 XMPP 02:42 Notification Manager 04:08 View System 06:00 Conclusion (Ends at 07:05) My Takeaway: In this video the speaker talks about API's provided on the Android platform to developers. The LocationManager API allows an application to get the location of the device it is running on. This information can be used to register intents, which will inform the user if they are close to an interesting location such as a Ice Cream shop. I can also think of another use. If traffic information is available, then we can also use the location manager to inform us if we are getting close to a high traffic area. Interestingly this API uses whatever information it has to determine the location. If GPS information is available then it will use that, otherwise it will use cell tower information. XMPP Service is used to send mess

Android programming - Application lifecycle (Video)

This is the second video in the series of videos provided by Google on Android programming. Index 00:00 - Introduction 01:00 - How Android integrates apps written by different authors. 07:50 - Conclusion (Ends at 08:16) This video walks us through a hypothetical use case, where a user opens their email, reads a message which contains a link to some location. The user then clicks on the link, opens the browser and views the location on Google Maps. While engaging in these activities, the user starts various applications (processes) and also navigates back and forth among them. The video explains how Android manages resources and the application stack so the user can navigate across their apps seamlessly. My Takeaway From the video it seems like Android supports a maximum of 4 running processes. One of those processes is the System process, so a user can have at most 3 applications running simultaneously. However, this does not mean that a user cannot open more applications. When the use

Android programming - architecture video

I have been getting interested in Android programming, so I went over to their website and found some introductory videos. Here's the first one with a little index of what is discussed and my take away from the video. Video Index: 00:0 Introduction 00:40 Linux Kernel 01:09 Native Libraries 03:09 Android runtime 04:13 Core libraries 04:31 Application framework 07:00 Applications 07:25 Application building blocks 09:37 Example of re-using components in Android 12:18 Conclusion and resources 12:48 End My Takeaway: Architecture wise the Android platform has several layers: Linux Kernel Native Libraries Android Runtime Core Libraries Application Framework The applications that we make are build on top of the "application framework" layer. The Linux Kernel was chosen because of it's stability, services, security, and presence of several device drivers. Native Libraries consist of various components for rendering graphics and fonts (Surface Manager, OpenGL, SGL, Freetype), a

tightvnc with gnome messes up the keyboard mapping

Everytime I run our unit tests, I get Java Swing windows flying across my screen making it impossible to work. A friend suggested that if I ran the tests in a vncclient session, the windows will be contained within vncviewers window. So I installed tightvncserver and client on my Ubuntu 9.10 machine. When I started vncviewer I realized that the keyboard mapping as messed up, making it impossible to type anything sensibly in the vnc session. Some searching seems to suggest that Gnome is causing this problem. This page offered a solution of changing VNC's startup file to not fully start Gnome, and it worked for me. Workaround: I modified my ~/.vnc/xstartup to be: #!/bin/sh xrdb $HOME/.Xresources gnome-wm & gnome-panel & nautilus --no-default-window & gnome-cups-icon & gnome-volume- manager & xterm &

Java Applet on 64 bit Linux

I have been working on an Ubuntu 9.10 (64 bit system) from some time. I had read some stories of problems running 64 bit Java Applets on 64 bit Firefox, so when I needed to use Applets I did some googling to figure out how to do it. I came across a couple of posts. Some had different solutions for different versions (3.5, 3.6) of Firefox, and they also wanted me to use IcedTea. The solution I used is outlined here , and it worked perfectly well for me. Note: You may not have libnpj2.so in the same place mentioned below. mkdir ~/.mozilla/plugins/ ln -s /usr/lib/jvm/jre1.6.0_12/lib/amd64/libnpjp2.so ~/.mozilla/plugins/

Showing lines before and after a grep match

Today I ran running grep on the output of hg log , but only to realize that I wanted a couple of lines before and after the line which matched as well. I am sure this is common knowledge, but I did not know how to do it, so am sharing it in the hope that someone finds it useful. hg log | grep --before-context=2 --after-context=2 username Running the above showed me changeset number, comments etc for all the mercurial changesets committed by the specified user.