Technical Tips, Tricks and Articles

Posts Tagged ‘Tip

Syntax highlighting on blogs

leave a comment »

Syntax highlighting is always been a desired things on blogs, specially for those who post their code so often on blogs. Not only it adds to the look of the blog but also, it makes the code more readable.  From quite a few days, i was trying to search for something by which i can paste my codes in formatted highlighted form on the blog, but whatever plug-in i found was not integrateable into wordpress free service.

The earlier solutions that came to my mind was taking a snapshot of the code window and post here. But it includes few extra steps for me (taking a snapshopt, croping it and the uploading it) and for reader, they just can’t COPY-PASTE the code if they want to.

highlightSo if you are one of those who are looking for some syntax highlighting thing for your blog, here is some great tool, named Highlight. The tools come with some default styles, including eclipse, emacs and other well know editors. You can configure the style if you wish so and the you can export it in your desired format i.e (html – with inline CSS, RTF, XHTML, LaTeX, SVG, XML etc).  See the below snippet that I formatted/highlighted using the it. it’s pretty clean and easy to incorporate 🙂

1 package com.e2e.test;
3 import javax.microedition.lcdui.Alert;
4 import javax.microedition.lcdui.Command;
5 import javax.microedition.lcdui.CommandListener;
6 import javax.microedition.lcdui.Display;
7 import javax.microedition.lcdui.Displayable;
8 import javax.microedition.lcdui.Form;
9 import javax.microedition.lcdui.StringItem;
10 import javax.microedition.lcdui.TextBox;
11 import javax.microedition.midlet.MIDlet;
12 import javax.microedition.midlet.MIDletStateChangeException;
14 public class Test extends MIDlet implements CommandListener, Runnable{
16     private Display mDisplay;
17     private Command mExitCommand, mFindCommand, mCancelCommand;
19     private TextBox mSubmitBox;
20     private Form mProgressForm;
21     private StringItem mProgressString;
23     public Test() {
24         mExitCommand = new Command("Exit", Command.EXIT, 0);
25         mFindCommand = new Command ("Find", Command.SCREEN, 0);
26         mCancelCommand = new Command ("Cancel", Command.CANCEL, 0);
28         mSubmitBox = new TextBox("Test", "", 32, 0);
29         mSubmitBox.addCommand(mExitCommand);
30         mSubmitBox.addCommand(mFindCommand);
31         mSubmitBox.setCommandListener(this);
33         mProgressForm = new Form ("Lookup Progress");
34         mProgressString = new StringItem(null, null);
35         mProgressForm.append(mProgressString);
36     }
38     protected void destroyApp(boolean arg0) throws
39                               MIDletStateChangeException {
40         // TODO Auto-generated method stub
42     }
44     protected void pauseApp() {
45         // TODO Auto-generated method stub
47     }
49     protected void startApp() throws MIDletStateChangeException {
50         mDisplay = Display.getDisplay(this);
51         mDisplay.setCurrent(mSubmitBox);
52     }
54     public void commandAction(Command c, Displayable d) {
55         if (c == mExitCommand){
56             try {
57                 destroyApp(false);
58             } catch (MIDletStateChangeException e) {
59                 System.out.println("exception @ destroyApp(false);");
60             }
61             notifyDestroyed();
62         }
63         else if (c == mFindCommand){
64             mDisplay.setCurrent(mProgressForm);
65             Thread t = new Thread(this);
66             t.start();
67         }
68     }
70     public void run() {
71         String word = mSubmitBox.getString();
72         String definition;
73         try{
74             definition = lookup(word);
75         }
76         catch (Exception ie){
77             Alert report = new Alert("Sorry", "Something went wrong", null,
78                            null);
79             report.setTimeout(Alert.FOREVER);
80             mDisplay.setCurrent(report, mSubmitBox);
81             return;
82         }
83         Alert report = new Alert ("Definition", definition, null, null);
84         report.setTimeout(Alert.FOREVER);
85         mDisplay.setCurrent(report, mSubmitBox);
87     }
89     private String lookup(String word) {
90         if (word.equalsIgnoreCase("1")){
91             throw new RuntimeException("exception thrown");
92         }
93         return "hardcoded definition";
94     }
96 }

Written by ..alee

March 13, 2009 at 9:15 am

Posted in Miscellaneous

Tagged with , , , ,

GMail Labs – Tips & Review

with 4 comments

Mail is setting the standards of new web mail. The light look, simple design and fast retreival has made other mail boxes to re-design their architecure, look and feel. Now, GMail has added new functionality to it; GMail Labs. The little widgets has added to the functionality of GMail making it even better but right now I am going to write “things that are missing” in these labs.

Quick Links

One of the coolest widget giving the opportunity to add “custom views”. It’s use is simple. Open the view of your choice. Like make a search as label:<your lable> + “any string available for search”. This will result in a mailbox view filtered on specific criteria you mentioned and now you can add the quick link for this specific view. Everytime onward, whenever you click on this quick link you’ll have this view; i.e search reasult based on the query your wrote.

Unread Andriod Quick Link

From the above example, I am creating a quick view based on the following search string label:android is:unread This will result in mailbox view and list all the mails which has label “andriod” and are “unread”.

Thing Missing:

For the users who are having lots of Labels. Its cumbersome to scroll down to the bottom of the page to click on some quick link. It’d be great if GMail Team adds some drag-drop functionality for the panels at the left side.

Written by ..alee

June 19, 2008 at 12:06 pm

Posted in GMail

Tagged with , , , , ,