Lubos Programming Blog

Lubos Blog about Programming (mainly Java) and Computers

My Google Chrome Extensions

Posted by lubosp on June 2, 2010

Intro

I started using Google Chrome browser (now using 5.0.375.55 beta) about 5 months ago after using Mozilla Firefox for quite a few years. Firefox 3.5+ started hanging (maybe extension?) so I decided to give Chrome a try. Here are the reasons why I decided to switch to Chrome:

  • Each Chrome tab and extension runs in separate process, so rogue web site or extension cannot take down the whole browser. Memory consumption of Chrome and Firefox is about the same, but Chrome is more robust and doesn’t hang.
  • Extensions are still better in Firefox, but Chrome is getting better and has most of the extensions I need, and Google stuff like Gmail, Reader, Voice, Calendar integration is better in Chrome (and I use a lot of Google tools).
  • Speed, javascript rich sites like Gmail are quite faster.
  • Screen real estate management is better in Chrome.
  • Faster development cycle for Chrome, and better chance Chrome will get better faster than Firefox.

List of Extensions I use

General

  • AdBlock – AdBlock for Chrome! Blocks ads all over the web
  • AniWeather – AniWeather = Animated Weather + Any Weather
  • Copy Without Formatting – Provides various ways (customizable keyboard shortcut, floating button, or auto-copy) to copy your selection WITHOUT formatting
  • Docs PDF/PowerPoint Viewer (by Google) – Automatically previews pdfs, powerpoint presentations, and other documents in Google Docs Viewer
  • FastestChrome – Browse Faster – Save time and enhance your productivity! Get quick definitions, auto-load next pages, search faster, and more
  • IE Tab – Display web pages using IE in a tab
  • LastPass – LastPass is a free password manager and form filler. LastPass is also available for Firefox, Internet Explorer and Safari (Mac)
  • MegaUpload DownloadHelper – No More Countdowns – Automatic Downloads
  • Session Manager – Session Manager lets you save sessions of your opened tabs and windows, and to quickly re-open them whenever you like
  • Speed Dial – Speed Dial for Chrome – replace Chrome new tab with your predefined visual bookmarks

Google

Social

  • Facebook for Google Chrome – Extension which lets you read your Facebook news feed and wall. You can also post status updates.
  • Chromed Bird – Chromed Bird is a Twitter extension that allows you to follow your timelines and interact with your Twitter account
  • Diigo Web Highlighter and Bookmark – Highlight webpages with multiple colors as you read online. Also allow tagging and sticky notes
  • Xmarks Bookmarks Sync – Backup and sync your bookmarks and open tabs across computers and browsers. Xmarks is also available for Firefox, Safari and IE

Development

You can set a theme in Options/Personal Stuff/Themes/Get Theme…

You can import data from different browser in Options/Personal Stuff/Browser Data/Import Data from different browser

Posted in web browser | Tagged: | Leave a Comment »

Facebook API notes

Posted by lubosp on May 22, 2010

 

Posted in tools, web | Tagged: | Leave a Comment »

Using Git SCM

Posted by lubosp on May 22, 2010

Following post is just a collection of links I collected while started using Git source control system:

Posted in tools, vcs | Tagged: | Leave a Comment »

Prettier failures using Swing TaskDialog « Schneide Blog

Posted by lubosp on April 6, 2010

Prettier failures using Swing TaskDialog « Schneide Blog

via Prettier failures using Swing TaskDialog « Schneide Blog.

Posted in swing | Tagged: | Leave a Comment »

Promiscuous Integration vs Continuous Integration

Posted by lubosp on February 11, 2010

Excellent article from Martin Fowler about VCS, DVCS and Continuous Integration Promiscuous Integration vs Continuous Integration.

Posted in build, vcs | Tagged: , | Leave a Comment »

Introduction to Quartz Scheduled Jobs

Posted by lubosp on February 5, 2010

 

Excellent introduction to Quartz Scheduled Jobs. Quartz is Java framework for sophisticated jobs scheduling.

Posted in java | Tagged: , | Leave a Comment »

Developing Blackberry application

Posted by lubosp on January 7, 2010

This blog entry has been moved as a page to my Mobile Development blog.

Posted in blackberry, java | Tagged: , | Leave a Comment »

Linux, Ubuntu is still not good enough to replace Windows or Mac OSX

Posted by lubosp on December 2, 2009

I had two old desktops (2GHz single core) and I decided to gut both and create one desktop that would run new Ubuntu 9.10.

I re-build the computer hardware after some experimenting with hard drive and DVD drive jumpers and made it bootable.

I then installed Ubuntu 9.10, install itself was a pleasant experiance comparable to Windows 7 install experience. Everything went smoothly.

After reboot I started exploring Ubuntu OS (I am running Ubuntu 9.10 in VMWare Player on my laptop). To my surprise Ubuntu did not recognize by name any other computers on my intranet (mix of Windows Vista and Windows 7 machines).  I can ping the other machines by IP but not by name. Network explorer did see the other machines by name and could access their shared hard drives, so Samba was working OK, but networking name resolution wasn’t working (kind of big deal when you are using DHCP).

I spent few hours poking around and googling but was unable to resolve the issue. I was also not able to add my networked printer, I did not find any way by using UI to add a printer (must be well hidden). To give Ubuntu some credit, my NAS MyWorldBook was recognized by Network explorer/Samba, that was not the case in Ubuntu 8.x and 9.04.

After about a day of playing with and tweaking Ubuntu, I cut my loses and installed Windows XP pro. The install was without any problems, networking works as expected, and I can add my network printer.

Conclusion

Installing and running Ubuntu was major disappointment. While I am sure with enough googling and editing some config files, I would be able to make Ubuntu (networking, printer) work properly, I cannot imagine that person without computer and system administration experience can install and use Ubuntu. I am part time system administrator for small business, and I wouldn’t introduce Ubuntu based machines into the network after my last experience. It looks like Windows are save for now and there is not real thread from Ubuntu to displays Windows any time soon. I am disappointed also because I was and still am big fan of Linux, and I thought Ubuntu is slowly improving to the level, where it is going to be able to compete with Windows and Mac OSX.

I think that main reason of Linux still has problems to catch up with Windows and Mac OSX is the huge fragmentation of the Linux world (so many distributions, so much work duplicated), it remind me Unix situation 15-20 years ago.

Posted in java | Leave a Comment »

Upgrading to Windows 7

Posted by lubosp on November 15, 2009

I am part time system administrator for small health-care provider, so I know that Windows 7 are in my future with purchases of the new computers (it is harder and harder to get new computer with Windows XP).

I already tried to install Windows 7 on my 6 year old HP laptop, and the experience wasn’t quite positive, see my blog here. But most of the technical publications rates Windows 7 quite well, so I decided to upgrade my main work/development laptop, Thinkpad R61 to Windows 7 Pro. At the same time I purchased Asus Eee PC netbook with Windows 7 Starter Edition.

Installation

My Thinkpad R61 had Windows Vista Home edition (32 bit), so the OS did not use all of the 4Gb memory in the laptop. Because I couldn’t do Windows 7 update (update doesn’t work going from Vista Home to Windows 7 Pro), I decided to bite the bullet and do the clean install of Windows 7 Pro 64bit to make use of full 4Gb of memory. I performed full backup and ran Easy Transfer Wizard (to Windows 7). Then ran Windows 7 Upgrade Advisor and uninstalled and/or upgraded a few applications advisor recommended to uninstall or upgrade (mainly ThinkVantage, Thinkpad applications, see here).

Installation went smoothly and it took about an hour. I then ran Windows update a few times to get the latest and greatest. Everything was running well NVidia drivers and other drivers (camera, audio) loaded well, networking was working, I could easily connect to my MyWorldBook NAS, and to my HP network printer (this might be the first Windows OS where the networking is working without glitches ;-) . I then run Windows Easy Transfer to restore my settings.

As always, while some applications are running out of the box like Firefox, Eclipse, Notepad++ and others, some Windows applications have nasty habit to depend on registry entries, .dll libraries in Windows\system32 etc, and they had to be reinstalled. This is one of the major pains of upgrading or re-installing Windows OS. IMHO Microsoft should offer better application model to application developers so they can build applications that are easy to migrate between Windows OS installation, and application developers should do better job writing applications that do not depend on resources that disappear during Windows OS install/re-install.
BTW, I am using 2 disk partitions, C: and D: drive, and I do install most of the applications on D: drive, which makes it easier to install/re-install Windows OS. Even with that, it took me about a day to get my laptop in shape.

Windows 7 install creates Windows.old folder with core of the old (in my case Windows Vista) OS, so you can use it to recover applications and data missed by transfer wizard. Biggest installation disappointment was that Start Menu\Programs disappeared and they were also missing in Windows.old folders, so I had to rebuild them from scratch. That in itself is not trivial because I couldn’t find a way to access Start Menu folder (Permission Denied) with Windows Explorer even with administrator privileges. Fortunately I found this article, and downloaded and used SurF Explorer.

I do not use Programs menu that much, I instead maintain and share between my computers custom toolbars (folders in C:\&D (for development), C:\&U for utilities etc) which show up as D >> toolbar and that popup applications (folder content) when clicked on >>  in the toolbar. I use these toolbars for easy access to applications. These custom toolbars saved me from some more work chasing down all the applications and creating their links.

Windows XP mode is not installed with Windows 7 by default, here is the Microsoft documentation how to install Windows XP mode.

Few Problems

  • Desktop icons suddenly disappeared after reboot, it took me few minutes to find Desktop popup menu View/Show desktop icons that got unchecked for some reason
  • Power management is biggest problem ad disappointment so far. At night I just close the lid of my laptop and then come in the morning and open it. In two of the three days using Windows 7 after opening the lid in the morning the display was dark, there was no laptop activity (even if OS was not shut down), and I couldn’t wake up the laptop no matter what I did. I have to do hard shutdown holding I/O button and restart Windows 7. This worked seamlessly in Windows Vista. I am trying to set all Power options to Never, but so far laptop wake up function is failing!
  • Creating file associations is worse than it was in Vista or XP, the UI doesn’t allow you to specify details of the command, and executing java .jar files requires -jar option to execute a .jar file (double-click). I had to search and edit registry to set .jar file association with -jar option. This was actually problem with me installing JDK 32bit instead of JDK 64bit. After I uninstalled 32bit and installed 64bit, everything was working well, and .jar associations were set properly.

Applications I had to re-install

  • VMWare player
  • Snagit
  • PDANet – used http://junefabrics.com/pdanet/x64.php to install 64b driver, and used old PDANet 1.2 for Blackberry
  • HAVA
  • FileZilla site manager, here is how to find and restore site manager items
  • Set environment variables, I forgot to save env. variables (why there is no Import/Export for env. variables on Windows?), so I had to recreate quite a few of them (JAVA_HOME, GROOVY_HOME etc.)
  • Cygwin
  • VNC
  • Blackberry Desktop
  • Logmein
  • Lastpass
  • VLC Player
  • Java

Conclusion

So far I do agree with experts, that Windows 7 is the best Windows OS so far, yes even better than Windows XP. After disabling UAC (which was much easier than in Vista), I am happy Windows 7 user (with exception of power management mentioned above). Also Windows 7 Starter on our Asus Eee PC is running well with no glitches (on that laptop power management works as it should, have it set to sleep on close lid, wake up on open).

 

Posted in java | Leave a Comment »

Stopping or interrupting Java hanging thread

Posted by lubosp on November 15, 2009

As most of Java developers know and experienced, some Java frameworks including core Java libraries do have nasty habit to run for very, very loooong time or hang indefinitely. Classic example is Java regex library which can cause stack overflow, or it can hang indefinitely.

In order to prevent the whole application from hanging and to allow to stop or interrupt the offending hanging thread, I am using timeout thread that checks if the watched thread finished in allotted time, and if it did not the timeout thread interrupts the watched, hanging thread.

Abruptly stopping or interrupting a thread from different thread is not well supported in Java especially when Thread.stop() method was deprecated, see How to stop a thread article.

But the problem is that Java offers nothing better to forcefully interrupt the offending hanging thread. Following is an example code of the TimeoutThread:

package com.lingoport.scanner.util;

import java.util.Date;

/** Stop a thread after a given timeout has elapsed
* <P>
* A simple timeout class.  You give it a thread to watch and a timeout
* in milliseconds.  After the timeout has elapsed, the thread is killed
* with a Thread.stop().  If the thread finishes successfully before then,
* you can cancel the timeout with a done() call; you can also re-use the
* timeout on the same thread with the reset() call.
* <P>
*
*/

public class TimeoutThread implements Runnable {

private final Thread targetThread;
private long millis;
private final Thread watcherThread;
private boolean loop;
private boolean enabled;
private static final boolean TIMEOUT_DISABLED = System.getProperty("disable.timeout") != null;

/**
* Constructor. Give it a thread to watch, and a timeout in milliseconds.
* After the timeout has elapsed, the thread gets killed. If you want
* to cancel the kill, just call done().
*
* @param targetThread
* @param millis
*/
public TimeoutThread(Thread targetThread, long millis) {
this.targetThread = targetThread;
this.millis = millis;
if (TIMEOUT_DISABLED) {
watcherThread = null;
enabled = false;
} else {
watcherThread = new Thread(this);
enabled = true;
watcherThread.start();
// Hack - pause a bit to let the watcher thread get started.
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
}

/**
* Constructor, current thread.
*
* @param millis
*/
public TimeoutThread(long millis) {
this(Thread.currentThread(), millis);
}

/**
* Call this when the target thread has finished.
*/
public synchronized void done() {
loop = false;
enabled = false;
notify();
}

/**
* Call this to restart the wait from zero.
*/
public synchronized void reset() {
loop = true;
notify();
}

/**
* Call this to restart the wait from zero with a different timeout value.
*
* @param millis
*/
public synchronized void reset(long millis) {
this.millis = millis;
reset();
}

/*
* The watcher thread - from the Runnable interface.
* This has to be pretty anal to avoid monitor lockup, lost threads, etc.
*
*  (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public synchronized void run() {
if (TIMEOUT_DISABLED) return;
Thread me = Thread.currentThread();
me.setPriority(Thread.MAX_PRIORITY);
if (enabled) {
do {
loop = false;
try {
wait(millis);
} catch (InterruptedException e) {
}
} while (enabled && loop);
}
// The call stop() is deprecated, but Java doesn't offer anything better
if (enabled && targetThread.isAlive()) {
targetThread.stop();
done();
}
}

// Test main
public static void main(String[] args) {
System.out.println((new Date()) + "  Setting ten-second timeout...");
TimeoutThread tk = new TimeoutThread(10000);
try {
double f = 1.;
System.out.println((new Date()) + "  Starting execution of long loop...");
for(double i = 0; i < 1.0E99; i++) f = f * i;
System.out.println((new Date()) + "  Another execution of long loop...");
for(double i = 0; i < 1.0E99; i++) f = f * i;
tk.done();
} catch (Exception e) {
System.out.println((new Date()) + "  Caught Exception");
} catch (ThreadDeath td) {
System.out.println((new Date()) + "  Caught ThreadDeath");
}
System.out.println((new Date()) + "  Finished!");

}

}

This solution seems to be working quite well, and the offending hanging thread (caused for example by Java regex) can catch ThreadDeath exception, recover appropriately and continue work.

The only problem I encountered so far is that it doesn’t play well with Eclipse debugging, that is why I disable the TimoutThread while debugging the application using disable.timeout system property.

I know, that this is not great solution, but it works, and I couldn’t find any better solution (BTW, Thread.interrupt() does not work in this case). Let me know if you have better solution.

 

Posted in java | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.