Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • Subinkrishna G 10:43 am on August 24, 2012 Permalink | Log in to leave a Comment
    Tags: , , , jquery, , ,   

    Today’s read: Useful jQuery Function Demos For Your Projects 

    Smashing Magazine

    This one is a real good one. This article from Smashing Magazine gives you a very high level view of what jQuery can do. A real good starter for those who want to try out the possibilities of jQuery in their projects.

    Every aspiring Web developer should know about the power of JavaScript and how it can be used to enhance the ways in which people see and interact with Web pages. Fortunately, to help us be more productive, we can use the power of JavaScript libraries, and in this article we will take a good look at jQuery in action.

    Source: Smashing Magazine / Useful jQuery Function Demos For Your Projects

    Have a good read and make your hands dirty.

     
  • Subinkrishna G 8:17 pm on July 2, 2012 Permalink | Log in to leave a Comment
    Tags: , input, io, , , output,   

    My most favorite methods – part 2 

    Okay, here’s the second one. And it took me a few months to write this one :P

    /**
     * Copies from an {@link InputStream} to an {@link OutputStream}
     *
     * @param from
     * @param to
     */
    public static void copyStream(InputStream from, OutputStream to)
    {
    	byte[] contents = null;
    	int count = -1;
    
    	if ((null != from) && (null != to))
    	{
    		try
    		{
    			contents = new byte[1024];
    			while (-1 != (count = from.read(contents)))
    			{
    				to.write(contents, 0, count);
    			}
    		}
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		}
    		finally
    		{
    			contents = null;
    		}
    	}
    }
    

    This method copies the contents from the input stream to the output stream. Do I need to explain more?

     
    • Andy Res 9:14 pm on July 2, 2012 Permalink

      It’s funny the way how you write the condition in the if and while loop, like you are checking the “null” and “-1″ against your variables, which seems unusual for me. :)
      I would write instead if(from!=null), and while((count=from.read(contents))!=-1) ..

    • Subinkrishna G 11:09 am on July 3, 2012 Permalink

      This is one practice that I follow from beginning ;)

  • Subinkrishna G 4:37 pm on April 10, 2012 Permalink | Log in to leave a Comment
    Tags: , favorite, ,   

    My most favorite methods – Part 1 

    This is my most favorite/commonly used/useful method. This method checks if the given string is valid or not.

    /**
    * Checks if the given string is valid or not.
    *
    * @param aString
    * @return {@code true} if {@code aString} is not {@code null} and if it's
    *         'trimmed' length is more than 0, else {@code false}
    */
    static boolean isValidString(String aString)
    {
       return ((null != aString) && (aString.trim().length() > 0));
    }
    
     
    • Stuart 4:48 pm on April 10, 2012 Permalink

      I prefer the StringUtils.isNotBlank() from org.apache.commons-lang3

      Also, you shouldn’t really be comparing strings with “!=” or “==” should you?

    • Subinkrishna G 11:15 am on April 18, 2012 Permalink

      I am not a big fan of Apache Commons ;) Yes, I agree that we should not compare the strings using ‘!=’or ‘==’. But here I am not comparing the strings, in fact I am doing a null check.

    • Stuart 11:39 am on April 18, 2012 Permalink

      Personally I think having all the little helper functions lumped into one place is quite useful, but then I write a lot of small programs, so having easy access to lang3 with maven does make my life a little easier!

      Doh! of course, null comparison, point taken :)

  • Subinkrishna G 4:17 pm on November 24, 2011 Permalink | Log in to leave a Comment
    Tags: , groovy, hello world, , scripting   

    Hello, Groovy! 

    My new job demands me to learn a lot of new things that I never wanted to! Today I wrote my first ever Groovy script. And it compiled and run! Awesome :)

    package subin.groovy;
    
    /**
     * Hello, World!
     *
     * @author Subinkrishna Gopi
     */
    class HelloWorld
    {
    	static def aString = "Hello, World!"
    	static void main(args)
    	{
    		println("${aString.toUpperCase()} it's a nice day today :)")
    	}
    }
    
     
  • Subinkrishna G 8:49 pm on November 10, 2011 Permalink | Log in to leave a Comment
    Tags: lessons, life, work   

    Things I learned in the past 6 years! 

    And finally I decided to change the first job I ever had! The last six years taught me a lot of lessons – good, bad & ugly ones.

    Note: The characters/incidents in this story are almost real.

    So, here it goes:

    • If you are not an expert in multitasking, hmm… better you learn it. You are supposed learn how to zip your pants while tying your shoes!
    • There are three ways to solve a problem. A simple way, a difficult way & a stupid way.
    • Communication is always two-way. If someone mails you for a help, replying “Go to hell!” is much better than not replying at all.
    • A Jailor can never be a Florist, and vice versa.
    • Be cool or pretend to be cool. No one can tell the difference, almost every time.
    • Spend more time with family, not in office. After all we all are human beings & social animals.
    • Submit your financial claims properly, you will end up paying for official trips otherwise. Well… I’m paying the EMIs, still.
    • Listen to your wife/girl friend(s), they do talk sense… sometimes.

    Okay. If you are person who thinks python is a big scary snake & looking at eclipse is a taboo, you can stop reading. Because the following is for those who loves to tame the python with eclipse.

    • Respect NullPointerException. They can pop up anytime in your code, even if you are James Gosling or Joshua Bloch.
    • Try to write code that humans can understand.
    • Java != JavaScript. Many “technical” managers will not agree it though.
    • If your Hello, World! program don’t run, don’t expect your space-ship program to compile. (Courtesy: Vasu)
     
    • tsafwat 5:14 am on July 29, 2012 Permalink

      these notes really made my day :)

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
Follow

Get every new post delivered to your Inbox.

Join 45 other followers