Scala comes with a syntax definition file for Notepad++ which can be found at scala_root\misc\scala-tool-support\notepad-plus
Since I use Notepad++ (portable edition) I copied the userDefinedLang.xml file to \PortableApps\Notepad++Portable\App\Notepad++ directory and restarted Notepad++
Wednesday, September 30, 2009
Thursday, September 17, 2009
CAPTCHA
For some time I have been filling out CAPTCHA images on various sites. At an abstract level I knew the image challenge was to prevent non-human users from gaining access to the site. However, I did not know that the term applied is called CAPTCHA until this morning when I came across this announcement that Google has acquired reCAPTCHA. What is interesting still is that each time a human answers a reCAPTCHA powered challenge successfully it enables the company to digitize part of a scanned text. For example, reCAPTCHA may scan an old edition of the New York Times and the OCR will likely, recognize and, convert to text a large percentage of the document. Those pieces which are not recognized are then turned to graphics and presented to human biengs for translation. So how does the computer know that the human has answered the question correctly? Well the challenge is composed of two parts known and unknown. If the human answers the known element correctly it is assumed that the unknown is correct as well. The assumed correct answer to the unkown is then validated against a larger sample to ensure its accuracy.
Thursday, September 10, 2009
Scripting languages
I came across this article which does a pretty job at comparing Perl Python Ruby and Groovy.
Monday, September 7, 2009
Syntax formatting and highlighting in Blogger
It took two hours of hacking and trying various suggestions from blogs but I finally got code snippets to display properly. Here are the steps
1. Edit the html template for blogger by referencing SyntaxHighlighter code from googlecode by placing the following just below the opening head tag.
2. Copy the contents of the style sheet from SyntaxHighlighter and paste just above the closing tag i.e.
3. Place the following function in the head as well.
Once this initial setup is complete you can place code snippets in the blog by simply placing the following:
You can use this to format the html for the snippets.
1. Edit the html template for blogger by referencing SyntaxHighlighter code from googlecode by placing the following just below the opening head tag.
<!-- Add-in CSS for syntax highlighting -->
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCpp.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCSharp.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCss.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushDelphi.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushJava.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushJScript.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushPhp.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushPython.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushRuby.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushSql.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushVb.js' type='text/javascript'></script>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushXml.js' type='text/javascript'></script>
2. Copy the contents of the style sheet from SyntaxHighlighter and paste just above the closing tag i.e.
]]></b:skin>
3. Place the following function in the head as well.
<script language='javascript'>
window.onload = function() {
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code')
}
</script>
Once this initial setup is complete you can place code snippets in the blog by simply placing the following:
<pre name="code class="xml">
</pre>
You can use this to format the html for the snippets.
NullPointerException thrown when comparing strings
When comparing strings in Java a run-time NullPointerException will be thrown if either string is null.
This can be avoided by performing a comparison between a constant and variable string which could potentially be null.
That is, variable.equals(CONSTANT) will throw a run-time exception if the variable is null. Therefore, a better comparison would be CONSTANT.equals(variable)
The following will throw an exception
Whereas this will not throw an exception
This can be avoided by performing a comparison between a constant and variable string which could potentially be null.
That is, variable.equals(CONSTANT) will throw a run-time exception if the variable is null. Therefore, a better comparison would be CONSTANT.equals(variable)
The following will throw an exception
public class StringCompare {
final static String ELEMENT = "constant";
public static void main( String[] args ) {
String element = null;
element = getElementValue();
if (element.equals(ELEMENT)) {
System.out.println("element " + element + " matches ELEMENT " + ELEMENT);
}
}
private static String getElementValue() {
return null;
}
}
Whereas this will not throw an exception
public class StringCompare {
final static String ELEMENT = "constant";
public static void main( String[] args ) {
String element = null;
element = getElementValue();
if (ELEMENT.equals(element)) {
System.out.println("element " + element + " matches ELEMENT " + ELEMENT);
}
}
private static String getElementValue() {
return null;
}
}
Monday, September 1, 2008
New Blog Setup
I went ahead and purchased amanjunaid.com and setup a blog there using WordPress. I think I will maintain both blogs for now.
Saturday, August 23, 2008
Personal Brand
A few months ago I came across The pragmatic Programmer by Andrew Hunt and David Thomas. I highly recommend this book to anyone who is truly passionate about programming. Next I came across My Job Went to India: 52 Ways to Save Your Job by Chad Fowler. I have had the good fortune of reading this book twice. Both books helped in bringing into sharp focus ideas and practices which until then I had only stumbled upon through trial and error. Finally this morning I read a blog by Jay Fields in which he not only mentions these two books but also gives useful tips on how one can go about building his or her own personal brand. Following Jay's advice I am starting this blog which I hope will serve as an outlet for my craft.
Subscribe to:
Posts (Atom)