USB security keys

So after setting up password storage on LastPass, I decided to find out how else to make my online login process more secure and less painful. This is when I came across this story about Facebook supporting USB security keys. So I decided to look into what a YubiKey 4 can do and I just ordered one. This device promises 2 factor authentication without the need to receive a text on your phone or have a key generator on your cellphone. I’ve used those other methodologies in the past for 2 factor authentication on gmail and github. But they are error prone as I am not very good at remember six digits and typing them back on my laptop. It also slows down my login process which of course I am not a fan off when trying to get things done fast.

There are geeky features which I always like. It can store key pairs so I can use the YubiKey 4 to ssh without having a private key stored on my hard drive. That prevents someone from stealing my private key if my laptop gets compromised. I found this how to YubiKey-SSH that explains it.

Anyway, more security for the new year!

Get Electricity Usage Analytics Like The Utility Companies

Ever wanted to track how much electricity a device at home is using over time? Here is a nice DIY for doing just that. It does require a bit of soldering but not much.

How To Keep An Android Service Running

How to keep an Android service running? This is kind of a trick question as the best practice is to not keep an Android service running. If you need to have something done continuously by your app via a service, the service should be started by an AlarmManager at a regular interval and kills itself after the task is done. The reason for this is that a long running service on Android is up to the OS to determine priority and in some cases would stop running. By using this methodology, you are treading lightly since the service does not stay in memory.

Here is some sample code.

Service implementation

public class HeartBeat extends Service {

	public IBinder onBind(Intent arg0) {
		// TODO Auto-generated method stub
		return null;

	public void onStart(Intent i, int startId) {;

	public Runnable beat = new Runnable() {

		public void run() {
                    // Do something

The AlarmManager that starts it.

			Intent iHeartBeatService = new Intent(this, HeartBeat.class);
			PendingIntent piHeartBeatService = PendingIntent.getService(this, 0, iHeartBeatService, PendingIntent.FLAG_UPDATE_CURRENT);
			AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
			alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000, piHeartBeatService);

Now the heartbeat service will start every second and do something and kill itself.

Drop all tables in mysql without dropping database

Found this brilliant method of doing just that via nix command.
The reason why this is useful is that I generally don’t like to type every table name into the sql command.

mysqldump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data

Where to install Eclipse on Ubuntu

If you’re like me, accustomed to installing most packages via Ubuntu’s package manager, you might be a bit confused as to where to install Eclipse since it should be in a place thats accessible by every user on your system.  Sure you can install it in your user home directory but that wouldn’t be very tidy.

I extracted part of these instructions from:

These instructions assume you’ve downloaded and extracted the Eclipse tarball:

sudo mv eclipse /opt/eclipse cd /opt sudo chown -R root:root eclipse
sudo mv eclipse /opt/eclipse cd /opt sudo chown -R root:root eclipse
sudo chmod -R +r eclipse
sudo chmod +x `sudo find eclipse -type d`

Then create an eclipse executable in your path

sudo touch /usr/bin/eclipse
sudo chmod 755 /usr/bin/eclipse

sudoedit /usr/bin/eclipse

With these contents:

export ECLIPSE_HOME=”/opt/eclipse”
$ECLIPSE_HOME/eclipse $*

Now you can execute Eclipse from anywhere in your bash shell. Check out the original article for generating a desktop icon. In the tarball I downloaded, it didn’t come with the icon.xpm that contains the Eclipse icon but no worries for me.

The take-home lesson here is that /opt is meant as a place to install application software packages. The topic is Filesystem Heirarchy Standard (FHS) .. these folks seem to be the standard authority on it:

However it’s not to say that this standard is the most progressive one we have today.  I found GoboLinux to be particularly interesting:

Installing Eclipse IDE and Android SDK on Ubuntu 8.10

This blog gives pointers on getting the Android development environment working on a base Ubuntu 8.10 installation.

This assumes you’re familiar with google’s installation instructions (see and might still be having some problems.

This also assumes you’ve installed Sun JDK 1.6.

So here are some tips and gotcha’s:

  • Don’t install Eclipse with Ubuntu’s package manager. At time of writing, Eclipse is in the distro. Make you sure have the latest Eclipse version by downloading directly from Eclipse’s site. See
  • With most (if not all) base Ubuntu installations, java-6-openjdk or java-gcj is used, not Sun’s JDK. You don’t want to uninstall java-6-openjdk either because other apps in your system will be uninstalled along with it. In your Ubuntu filesystem, JVM tools (e.g. javac, javah, javadoc, java) are actually symlinks to the actual JDK. So what you want to do is update these symbolic links. There are at least 2 tools I’ve come across to help do this. I found the following:
  • sudo update-alternatives –config java
  • sudo galternatives
  • In Eclipse, for some reason I’ve not been able to add the ADT plugin via add site.  I had to download the SDK zip file and install as a local archive.
  • If you don’t know where to install Eclipse, check out my post on where to install eclipse since we’re not using the comfy package manager to take care of things for us. 😉

That’s it for now.

Speed Matters

It has been said many times by many people, but I have to reiterate again how important it is to have a website that loads quickly.  Researches have shown that visitors to a page has the patience to wait only four seconds before hitting the Back or Esc button and off they go.  However, I have encountered so many content rich sights that take well over that before the page is loaded with content I am interested in.  Some sites just do not have anything showing before the page is up, others will have random images appearing and pushed into place as more are loaded, but the content is no where to be seen.

So what can you speed up the load time for your site.  For one thing, if you are using more advanced technology than static HTML files, which most site are in this category these days, you need to make sure the server hosting the site is fast enough.  A lot of sites are running on the cheapest shared web hosting services and as we all know, the cheapest is not always the best.  These services do give you a lot on paper, but with their bogged down servers you will never be able to utilize half the resources they allow for your account.

Now, if your hosting service or your own server is plenty fast with enough bandwidth, then it is time to look closer at the details.  Like I mentioned before, if you are running a static HTML site, these tips will not help you.  But you do have many other problems of how on earth will you update your content or design across the entire website.  That is another post.  But for the majority of us using databases to generate dynamic content, the database is a big culprit in site latency.  Databases need to be optimized for the hardware and the application it is running.  Optimizing a database starts from the design of the schema to the implementation of regular maintenance processes.  Again, there can be books written on how to optimize a database and maybe I will write one someday.

Anyhow, if you are running a site that is slow, don’t just ignore it.  Spend some time to figure out why it is slow and solve the issue.  It would be a shame to lose all those potential visitors to slow load time.

Keeping your wireless network unsecured can save you from a pirating lawsuit

The RIAA just lost a lawsuit recently against a woman for pirating music. They lost on the premise that she uses a wireless network at home the she never bothered to secure. Therefore, anyone could have gotten onto her network and shared pirated music through her IP address making it hard to prove that she was the one committing the felony.

Using shared hosting for email

Shared hosting has always been a popular choice for hosting a small website with POP email service. It is inexpensive and will usually provide everything you will need. However, one of my clients encountered some problems with their email shared hosting. The issue is with the proliferation of spam, ISPs are banning emails sent from known offenders based on their IP addresses. Since you are sharing a server with many other users, if they spam but your ISP does not catch on, the IP address used will be banned by other ISPs. This would render your email server ineffective as some emails will be filtered out as spam by other ISPs even though they are legitimate emails.

Therefore, it is very important to choose your ISP wisely. A good ISP should be on top of monitoring spam and resolve the problem quickly if they are on the blacklist.