Wednesday, February 19, 2014

Java Functional Programming Libraries

While Google Guava is a more complete functional programming library for Java, LambdaJ is a lightweight library for adding functional flavor into Java programming. Here's a good article that describes main usages of LambdaJ.

Friday, March 28, 2008

Start Windows Installer Service in Safe Mode

Some software messed up some Windows system files and I couldn't log on any more. Wanting to remove the software, I logged into safe mode, just to find out that Windows Installer service is not allowed to run in safe mode! Good design.

After spending some time searching, I found a solution:

To start Windows Installer in Safe Mode:
1. Restart your computer and press F8 before the Boot Menu or splash screen.
2. Open a CMD.EXE window.
3. Type the following commands and press Enter:

REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\MSIServer" /VE /T REG_SZ /F /D "Service"
net start msiserver

NOTE: You can use this technique to uninstall an application in Safe Mode.

Friday, March 21, 2008

Print UTF-8 Characters in Eclipse Console

In eclipse, "Run Dialog", "Common" tab, change "Console Encoding" to UTF-8. The code below should print some CJK characters.


import java.io.PrintStream;
import java.io.UnsupportedEncodingException;

public class TestClass {

public static void main(String [] args) throws UnsupportedEncodingException {
String chineseString = "\u4e00\u4e01\u4e02\u4e03\u4e04";
PrintStream ps = new PrintStream(System.out, true, "UTF-8");
ps.println(chineseString);
}
}

Friday, January 11, 2008

Use a proxy with urllib2

This snippet from Rob Wolfe:

import urllib2

def getopener(proxy=None):
opener = urllib2.build_opener(urllib2.HTTPHandler)
if proxy:
proxy_support = urllib2.ProxyHandler({"http": "http://" + proxy})
opener.add_handler(proxy_support)
return opener

def fetchurl(url, opener):
f = opener.open(url)
data = f.read()
f.close()
return data

print fetchurl('http://www.python.org', getopener('127.0.0.1:8081'))
print fetchurl('http://www.python.org', getopener()) # without a proxy

Wednesday, December 12, 2007

Enable X11 Forwarding for Putty When Started by WinSCP

In Windows registry, under HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\WinSCP%20temporary%20session
add DWORD value X11Forward, set value to 1.

Sunday, May 13, 2007

Friday, April 27, 2007

Command Line Screen Sharing

To share the command line screen with another terminal, it's actually fairly simple with GNU Screen. Suppose both have the same ID. At one terminal, type:

$ screen -S Test -U -t Test

At the other terminal, type:

$ screen -x Test

Voila, you get the second terminal to show the screen of the first one.

More info can be found here.