<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Stanley Shilov - Web Development, SEO and SEM &#187; Coding</title>
	<atom:link href="http://www.stanleyshilov.com/blog/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stanleyshilov.com</link>
	<description>Web Development with a twist of Affiliate Marketing</description>
	<lastBuildDate>Sun, 06 Jun 2010 21:11:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to build Firefox 3.5+ with JSSH on Ubuntu 9.10 64bit</title>
		<link>http://www.stanleyshilov.com/blog/compile-firefox-jssh-ubuntu-9-10-64bit-ruby-watir/</link>
		<comments>http://www.stanleyshilov.com/blog/compile-firefox-jssh-ubuntu-9-10-64bit-ruby-watir/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 00:11:15 +0000</pubDate>
		<dc:creator>Stanley</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.stanleyshilov.com/?p=318</guid>
		<description><![CDATA[A brief guide on how to compile Firefox 3.5 and later with JSSH support on Ubuntu ]]></description>
			<content:encoded><![CDATA[<p>I needed to run Firefox with JSSH support on <a href="http://www.ubuntu.com/getubuntu/download">Ubuntu 9.10 x64</a> in order to use it with <a href="http://watir.com/">Ruby&#8217;s Watir</a> library. Unfortunately the <abbr title="Firefox Extension">xpi</abbr> 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.</p>
<p>The configuration file (.mozconfig) has changed slightly with the newer versions of Firefox, so the older <a href="http://www.google.com/search?q=firefox+jssh">guides</a> 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.</p>
<p><span id="more-318"></span>Build all the necessary packages to compile Firefox:</p>
<pre class="brush: bash;">
sudo apt-get build-dep firefox
</pre>
<p>Mozilla has switched from CVS to mercurial for source code management. Install mercurial and fetch the source:</p>
<pre class="brush: bash;">
sudo apt-get install mercurial
hg clone http://hg.mozilla.org/mozilla-central/ mozilla
</pre>
<p>The above will retrieve the latest version of Minefield. If you want use 3.6 or 3.5, check out this <a href="https://developer.mozilla.org/En/Mozilla_Source_Code_%28Mercurial%29">Mozilla wiki</a>.</p>
<p>Once the source is done downloading, <em>cd</em> into <em>mozilla</em> and create the <em>.mozconfig</em> file:</p>
<pre class="brush: bash;">
cd mozilla
vim .mozconfig
</pre>
<pre class="brush: bash;">
# .mozconfig:
mk_add_options MOZ_CO_PROJECT=browser
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/firefox-jssh
ac_add_options --enable-extensions=default,jssh
ac_add_options --enable-application=browser
ac_add_options --enable-webservices
ac_add_options --disable-libnotify
ac_add_options --disable-necko-wifi
</pre>
<p>The last two lines are optional. It might be because I&#8217;m using <a href="http://awesome.naquadah.org/">awesome</a>, but the source wouldn&#8217;t compile for me without those last two lines.</p>
<p>Save the file and run make:</p>
<pre class="brush: bash;">
make -f client.mk build
</pre>
<p>It&#8217;ll take a few minutes but once it&#8217;s done you can launch Firefox by running:</p>
<pre class="brush: bash;">
./firefox-jssh/dist/bin/firefox -jssh
</pre>
<p>Keep in mind, this is separate from any existing Firefox installation you might have already had.<br />
I would recommend creating a <a href="http://www.stanleyshilov.com/blog/how-to-run-multiple-firefox-instances/">separate Firefox profile</a> to use for this installation.</p>
<p>If you&#8217;re doing this to get Watir running, you can test it out with this simple script:</p>
<pre class="brush: ruby;">
require 'rubygems'
require 'firewatir'

fx = FireWatir::Firefox.new
fx.goto(&quot;http://www.whatismyreferrer.com&quot;);
</pre>
<p>It should open a new window and change the URL to <a href="http://www.whatismyreferrer.com">http://www.whatismyreferrer.com</a></p>
<p>That&#8217;s about it. Hope this helps a few of you.</p>
<p><strong>Possible Errors and Solutions</strong></p>
<pre class="brush: bash;">
checking for GL/glx.h... no
configure: error: Can't find header GL/glx.h for WebGL (install mesa-common-dev (Ubuntu), mesa-libGL-devel (Fedora), or Mesa (SuSE))
*** Fix above errors and then restart with               &quot;make -f client.mk build&quot;
</pre>
<p>Install the package appropriate for your distro and you&#8217;ll be good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stanleyshilov.com/blog/compile-firefox-jssh-ubuntu-9-10-64bit-ruby-watir/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Java Mad Libs function</title>
		<link>http://www.stanleyshilov.com/blog/java-mad-libs-function/</link>
		<comments>http://www.stanleyshilov.com/blog/java-mad-libs-function/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 17:21:48 +0000</pubDate>
		<dc:creator>Stanley</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[content generation]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[madlib]]></category>

		<guid isPermaLink="false">http://www.stanleyshilov.com/?p=284</guid>
		<description><![CDATA[This madlibs Java function finds keyword combinations contained in {curly brackets} and randomly selects one of the keywords.
Ex: This {string&#124;sentence&#124;bit of text} will be different every time you {run&#124;execute} the {function&#124;method&#124;Mad Lib function&#124;madlib method}

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

	String[] madlibArray = null;

	while(matches.find()){
		madlibArray = matches.group(1).split(&#34;\\&#124;&#34;);
		content = content.replace(&#34;{&#34; + matches.group(1) [...]]]></description>
			<content:encoded><![CDATA[<p>This <a href="http://www.stanleyshilov.com/blog/code-java-mad-libs-function/">madlibs Java function</a> finds keyword combinations contained in {curly brackets} and randomly selects one of the keywords.</p>
<p><strong>Ex:</strong> This {string|sentence|bit of text} will be different every time you {run|execute} the {function|method|Mad Lib function|madlib method}</p>
<pre class="brush: java;">
// Madlib function:
public static String madlib(String content){
	Pattern regex = Pattern.compile(&quot;\\{(.*?)\\}&quot;);
	Matcher matches = regex.matcher(content);

	String[] madlibArray = null;

	while(matches.find()){
		madlibArray = matches.group(1).split(&quot;\\|&quot;);
		content = content.replace(&quot;{&quot; + matches.group(1) + &quot;}&quot;, madlibArray[(int) (Math.random() * madlibArray.length)]);
	}
	return content;
}
</pre>
<p>If you have any suggestions on how to improve this method, leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stanleyshilov.com/blog/java-mad-libs-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ubiquity Rapidshare Extension</title>
		<link>http://www.stanleyshilov.com/blog/ubiquity-rapidshare-extension/</link>
		<comments>http://www.stanleyshilov.com/blog/ubiquity-rapidshare-extension/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 19:44:20 +0000</pubDate>
		<dc:creator>Stanley</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[rapidshare]]></category>
		<category><![CDATA[ubiquity]]></category>

		<guid isPermaLink="false">http://www.stanleyshilov.com/?p=233</guid>
		<description><![CDATA[If you use Ubiquity, this simple extension makes it easy to grab and open any number of Rapidshare links:

CmdUtils.CreateCommand({
name: &#34;rapidshare&#34;,
  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&#60;selection.length; i++){
      links=links+selection[i]+&#34;&#60;br /&#62;&#34;;
 [...]]]></description>
			<content:encoded><![CDATA[<p>If you use <a href="http://labs.mozilla.com/projects/ubiquity/">Ubiquity</a>, this simple extension makes it easy to grab and open any number of Rapidshare links:</p>
<pre class="brush: jscript;">
CmdUtils.CreateCommand({
name: &quot;rapidshare&quot;,
  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&lt;selection.length; i++){
      links=links+selection[i]+&quot;&lt;br /&gt;&quot;;
    }
    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&lt;links; i++) Utils.openUrlInBrowser(selection[i]);
    }
  }
})
</pre>
<p>The code examines the selected block of text, extracts URLs which resemble Rapidshare links and opens each link in a new tab.</p>
<p><strong>To use:</strong> select the block of text, ctrl + alt to open ubiquity, then start typing &#8220;rapidshare&#8221;</p>
<p>PS: The code can be easily modified to work with other sites, simply replace any mention of &#8220;rapidshare&#8221; with the applicable site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stanleyshilov.com/blog/ubiquity-rapidshare-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sentence Capitalization with Java</title>
		<link>http://www.stanleyshilov.com/blog/proper-sentence-capitalization-java/</link>
		<comments>http://www.stanleyshilov.com/blog/proper-sentence-capitalization-java/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 03:19:02 +0000</pubDate>
		<dc:creator>Stanley</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.stanleyshilov.com/?p=250</guid>
		<description><![CDATA[Simple Java function to capitalize the first word of every sentence:

public static String capitalize(String content){
	Pattern capitalize = Pattern.compile(&#34;([\\?!\\.] )([a-z])&#34;);
	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.
]]></description>
			<content:encoded><![CDATA[<p>Simple Java function to capitalize the first word of every sentence:</p>
<pre class="brush: java;">
public static String capitalize(String content){
	Pattern capitalize = Pattern.compile(&quot;([\\?!\\.] )([a-z])&quot;);
	Matcher m = capitalize.matcher(content);
	while (m.find()) {
		content = m.replaceFirst(m.group(1) + m.group(2).toUpperCase());
		m = capitalize.matcher(content);
	}
	return content;
}
</pre>
<p>If you have any suggestions on how to improve this method, leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stanleyshilov.com/blog/proper-sentence-capitalization-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
