Stanley Shilov

How to build Firefox 3.5+ with JSSH on Ubuntu 9.10 64bit

February 4th, 2010

I needed to run Firefox with JSSH support on Ubuntu 9.10 x64 in order to use it with Ruby’s Watir library. Unfortunately the xpi file available on the watir site does not support 64bit Ubuntu, which meant I had to compile Firefox from scratch with builtin support for JSSH.

The configuration file (.mozconfig) has changed slightly with the newer versions of Firefox, so the older guides out there no longer work. Below is an updated step by step process which works up to Firefox 3.7a1pre (the newest version available at the time of this writing). Needless to say, this should also work with Firefox 3.5 and 3.6.

Read the rest of this entry »

Java Mad Libs function

September 26th, 2009

This madlibs Java function finds keyword combinations contained in {curly brackets} and randomly selects one of the keywords.

Ex: This {string|sentence|bit of text} will be different every time you {run|execute} the {function|method|Mad Lib function|madlib method}

// Madlib function:
public static String madlib(String content){
	Pattern regex = Pattern.compile("\\{(.*?)\\}");
	Matcher matches = regex.matcher(content);

	String[] madlibArray = null;

	while(matches.find()){
		madlibArray = matches.group(1).split("\\|");
		content = content.replace("{" + matches.group(1) + "}", madlibArray[(int) (Math.random() * madlibArray.length)]);
	}
	return content;
}

If you have any suggestions on how to improve this method, leave a comment.

Ubiquity Rapidshare Extension

July 4th, 2009

If you use Ubiquity, this simple extension makes it easy to grab and open any number of Rapidshare links:

CmdUtils.CreateCommand({
name: "rapidshare",
  preview: function(pblock){
    var selection=context.focusedWindow.getSelection();
    selection=selection.toString();
    selection=selection.match(/http:\/\/rapidshare[^\s]*/gi);
    var links='';
    for(var i=0; i<selection.length; i++){
      links=links+selection[i]+"<br />";
    }
    pblock.innerHTML=links;
  },
  execute: function(){
    var selection=context.focusedWindow.getSelection();
    selection=selection.toString();
    selection=selection.match(/http:\/\/rapidshare[^\s]*/gi);
    if(selection!=null){
      var links=selection.length;
      for(var i=0; i<links; i++) Utils.openUrlInBrowser(selection[i]);
    }
  }
})

The code examines the selected block of text, extracts URLs which resemble Rapidshare links and opens each link in a new tab.

To use: select the block of text, ctrl + alt to open ubiquity, then start typing “rapidshare”

PS: The code can be easily modified to work with other sites, simply replace any mention of “rapidshare” with the applicable site.

Sentence Capitalization with Java

April 18th, 2009

Simple Java function to capitalize the first word of every sentence:

public static String capitalize(String content){
	Pattern capitalize = Pattern.compile("([\\?!\\.] )([a-z])");
	Matcher m = capitalize.matcher(content);
	while (m.find()) {
		content = m.replaceFirst(m.group(1) + m.group(2).toUpperCase());
		m = capitalize.matcher(content);
	}
	return content;
}

If you have any suggestions on how to improve this method, leave a comment.

How to: Running Multiple Firefox Instances

November 9th, 2008

Setting up multiple instances of Firefox is a 5 minute task which is made possible by the creation of separate profiles, whereby each instance of Firefox will use its own profile. A few key points about profiles:

  • Every profile has its own set of bookmarks, extensions, themes and browsing history.
  • If one instance of Firefox crashes, it will not bring down other instances of Firefox running under different profiles.
  • The only thing shared between profiles are the plugins (Java, Flash, etc).
  • Separate profiles can be used to run different versions of Firefox at the same time.

Read the rest of this entry »

© 2012 Stanley Shilov   |   Blog   |   Contact

divide et impera

Stanley Shilov