Updates from February, 2009 Toggle Comment Threads | Keyboard Shortcuts

  • Subinkrishna Gopi 11:05 am on February 27, 2009 Permalink |
    Tags: , , , website,   

    Today’s read: Portfolio design 

    Smashing Magazine

    This is a very interesting topic – How to design a good portfolio?. For me, it’s all about promoting self as a brand and showcasing it. And everyone should be careful enough while doing that.  Just think about the portfolio website of a web designer with invalid code! That’s not the coolest thing.

    This Smashing Magazine article tells us the 10 steps to the perfect portfolio website.

    You may have a personal portfolio website for a number of reasons. If you’re a freelancer, then you’d need one to showcase your work and allow people to contact you. If you’re a student (or unemployed), then you’d need one to show prospective employers how good you are and what you can do, so that they might hire you. If you’re part of a studio, then you might use one to blog about your design life, show people what you’re doing and build your online presence.

    Read the article

    Some releated articles
    Creating a successful online portfolio
    50 beautiful and creative portfolio websites

    Have a nice read.

  • Subinkrishna Gopi 12:34 pm on February 21, 2009 Permalink |
    Tags: , iterator, , , text, text processing,   

    Working with text in Java: Using BreakIterator API 

    java.text.BreakIterator is a very good API to find boundaries – character, word, sentence & line break – with in a text.  The API provides a factory method to create the appropriate Iterator of our choice.

    // Instantiating a word iterator with optional locale parameter
    BreakIterator anIterator = BreakIterator.getWordInstance(locale);
    // Without locale parameter
    BreakIterator anotherIterator = BreakIterator.getWordInstance();

    The locale is an optional parameter to have locale specific breaks. We can instantiate BreakIterator without specifying the locale also. (java.util.Locale) The locale is important when we are working with languages like Arabic or Chinese where the standards may be different compared to English.

    Once we have an instance of BreakIterator, iterating through the boundaries / breaks is the same. The API offers methods like first(), last(), previous(), next(), preceding(), following() to iterate through boundaries.

    Iterating through boundaries

    BreakIterator aWordIterator = null;
    String targetString = null;
    int nextIndex = -1;
    int anIndex = -1;
    // Initialising the word iterator
    aWordIterator = BreakIterator.getWordInstance();
    targetString = "This is a sample text";
    // Iterating through the boundaries
    nextIndex = aWordIterator.first();
    while (BreakIterator.DONE != nextIndex)
    	anIndex = nextIndex;
    	nextIndex = aWordIterator.next();
    	if ((BreakIterator.DONE != nextIndex) &&
    		System.out.format("%10s (%d, %d) \n",
    			targetString.substring(anIndex, nextIndex),
    			anIndex, nextIndex);

    The constant BreakIterator.DONE indicates the end of boundaries.


          This (0, 4)
            is (5, 7)
             a (8, 9)
        sample (10, 16)
          text (17, 21)

    Useful links
    http://java.sun.com/docs/books/tutorial/i18n/text/examples/BreakIteratorDemo.java – Sun’s BreakIterator demo
    http://java.sun.com/docs/books/tutorial/i18n/text/index.html – Sun’s tutorial on “Working with text”

  • Subinkrishna Gopi 10:27 am on February 19, 2009 Permalink |
    Tags: , , ,   

    Today’s read: Web usabilty 

    Smashing Magazine

    I have always been a big fan of web design & web usability. I found a nice article in Smashing Magazine by Dmitry Fadeyev. Its all about some common usability mistake we do.

    By now, all good designers and developers realize the importance of usability for their work. Usable websites offer great user experiences, and great user experiences lead to happy customers. Delight and satisfy your visitors, rather than frustrate and annoy them, with smart design decisions. Here are 9 usability problems that websites commonly face, and some recommended solutions for each of them.

    Read the article (9 Common Usability Mistakes)

    Related links on usability
    10 Usability Nightmaters That You Should Avoid
    30 Usability Issues To Be Aware Of
    12 Useful Techniques For Good Interface Design

    About the author

    usabilitypost_smallDmitry Fadeyev is the founder of the Usability Post blog, where you can read his thoughts on good design and usability.

    Follow Dmitry on Twitter @usabilitypost.

    Have a nice read.

  • Mathew Varghese 3:40 pm on February 18, 2009 Permalink |
    Tags: , , , ,   

    Velocity Template Engine – Part 2 (Getting templates from a JAR) 

    In my previous post I described the basics of Velocity template engine. In that post, we were making use of a template (the .vm file) which we keep outside the application archive. But there are some potential issues in doing that – sometimes those file may get corrupted or deleted. So a better idea will be to keep it with in the application archive itself. In this post I will explain how we can make use of a template file with in an archive.

    Sample Template Filetestvelocity.vm

    Hello $name! Welcome to Velocity!

    Java ProgramTestVelocity.java

    A java program that refers to the the testvelocity.vm template.

    public static void handleTemplate()
    	VelocityEngine engine = null;
    	String myTemplateBody = null;
    	VelocityContext context = null;
    	StringResourceRepository repository = null;
    	Template template = null;
    	StringWriter writer = null;
    		// Getting Velocity Engine
    		engine = getVelocityEngine(engine);
    		// Reading Template Body from the template file(.vm file) in the jar
    		myTemplateBody = getTemplateFromJar();
    		// Setting the template body in string repository with a template
    		// name. Here the template name is used as a key for future mapping.
    		repository = StringResourceLoader.getRepository();
    		repository.putStringResource("myTemplateName", myTemplateBody);
    		// Getting the context with placeholder values
    		context = getVelocityContext();
    		// Fetch Template to a StringWriter
    		template = engine.getTemplate("myTemplateName");
    		writer = new StringWriter();
    		template.merge(context, writer);
    		System.out.println("VM Template:\n" + myTemplateBody);
    		System.out.println("Output:\n" + writer.toString());
    	catch (Exception e)
    		System.out.println("Oops! We have an exception");

    Getting the template engine
    Velocity supports different kind of resource loaders.  In this context we need to use a String resource loader. Know more about it here.

    private static VelocityEngine getVelocityEngine(VelocityEngine engine)
    throws Exception
    	// Initializes the velocity engine with properties. We should specify
    	// the resource loader as string and the class for
    	// string.resource.loader in properties
    	Properties p = new Properties();
    	p.setProperty("resource.loader", "string");
    	engine = new VelocityEngine();
    	return (engine);

    Getting Template file from JAR
    Know more about JAR and deployment here.

    // Reading the file contents from the JAR
    inStream = TestVelocity.class
    stringBuilder = new StringBuilder();
    streamReader = new InputStreamReader(inStream);
    bufferedReader = new BufferedReader(streamReader);
    while ((line = bufferedReader.readLine()) != null)

    Getting Velocity context

    context = new VelocityContext();
    context.put("name", "mathew");


    Velocity console out

    Please check this post get additional information on building a JAR file & executing it: https://javabeanz.wordpress.com/2009/01/29/running-an-executable-jar-from-command-line/

    • chrcharles 11:44 pm on October 26, 2009 Permalink

      Hello Subin,
      Thanks for your post, but i misunderstand the Getting Template file from JAR’ code !?

      How do you transform StringBuilder instance to a Template instance ?

      Bests regards.


    • Subinkrishna G 11:52 am on October 28, 2009 Permalink

      Hi Chris,

      Thank you for the comment. “Getting the template from JAR” means, reading the contents of a template which is been deployed as a part of a JAR. The usual practice is to deploy the template not as a part of the JAR or WAR so that any one can modify it.

      So, the above method will read the template contents as a stream of bytes (and then as a String object) and will attach it to the corresponding repository.

      The line, myTemplateBody = getTemplateFromJar(); in the above code block reads the template as a String. I’ve not given the complete implementation of getTemplateFromJar().


    • Subinkrishna G 11:55 am on October 28, 2009 Permalink

      We can convert the StringBuilder to a String by calling the toString().


  • Subinkrishna Gopi 10:32 am on February 18, 2009 Permalink |
    Tags: , , , , photography, , ,   

    Today’s read: noobr 


    noobrThe Ultimate Resource for noobs. Always – is an aggregator with daily updates of design trends, great design portfolios, young design bloods, photography, fashion etc.

    This is a very new venture and in its early stages. I got the reference from Smashing Magazine. And it is very much like smashingmagazine.com but far behind in terms of content and it’s quality.

    In noobr, there are a couple of links for the “serious” blogger.
    10 excellent WordPress themes (premium)
    12 free WordPress themes (premium)

    Have a nice read.

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc