Showing posts with label Article. Show all posts
Showing posts with label Article. Show all posts

Tuesday, September 7, 2010

How to fix *.OGV file to upload on YouTube (for Ubuntu 10.04 LTS users)

Hi Guys,
Just sharing my experience with *.ogv, while I was trying to upload a video on YouTube.
I was using Ubuntu 10.04 LTS and used gtk-recordMyDesktop to record a screencast and uploaded the video on YouTube, I found that youtube is showing completely gabbled video.

I could not figure out the problem but i simply converted the video to avi and uploaded on youtube, problem solved!!

How to convert to avi?
Basically you have 3 options.

  1. Using mencoder.
  2. Using ffmpeg.
  3. Using DeVeDE.



The only option which worked really nice with me is mencoder (use following command)

mencoder input.ogv -ovc xvid -oac mp3lame -xvidencopts pass=1 -o output.avi

Problem with other 2 options ( i observed)

  1. DeVeDe was converting correctly, but messing up with the length of video.
  2. ffmpeg completely failed to convert (was gabbling the video like Youtube).

To install mencoder use ubuntu software center.

Monday, July 26, 2010

Chrome Extension to do YQL page scraping. (quickest way to create a YQL mashup)

Hello ,
This weekend I was in Bangalore to attend "Yahoo Hack Day", Where I wrote a hack, which is a Chrome Extension to make your life really easy when you are trying to do some page scraping using YQL. My hack is also the "winning hack".

Name of the extension is ChromYQLip, which you can install from here.

Here is demo video



Yahoo hack days are great event, this time in India total participants were more that 450 and a total of 142 Hacks submitted and 108 hacks presented.

Thanks for reading My blog

Saturday, July 17, 2010

How to use Javascript beautifier with gedit.

Javascript beautifier is an awesome online tool to indent your JavaScript code. I use it very often.
Earlier I  use to paste my code in this online tool to get my JavaScript code indented.
Fortunately there is a way to integrate javascript beautifier with gedit.
Here are steps(I hope u are using latest version Ubuntu Linux, and having python).
Step1:Install gedit plugin "External Tools".
open gedit and go to edit->preferences->plugins(tab)
see if you already have a plugin "External Tools", if not install using this command.
$ sudo apt-get install gedit-plugins

After inslalling enable this plugin from edit->preferences->plugins(tab).
Step2: Install Rhino Shell.
You need Rhino Shell, to execute javascript on commandline.
To check whether you already have "Rhino Shell" or not, type "js" on Command Line.
You can Install "Rhino Shell" by typing this command.
$ sudo apt-get install rhino

Step3: Download einars-js-beautify.
You can download it here http://github.com/einars/js-beautify .
Extract it in some folder. lets say you have extracted it in folder
"/home/markandey/dev/einars-js-beautify/" .

Step4: Configure plugin to use jsbeautify.
Now go to "gedit->tools->manage external tools" and add a new command script, with following description.

Description: Beautify Javascript using einars jsbeautify
Shortcut Key:  
Commands:

#!/usr/bin/env python

import os
import sys
import tempfile

jsbeautify_path = "/home/markandey/dev/einars-js-beautify/"

content = sys.stdin.read()
h, tmpfile = tempfile.mkstemp()
os.close(h)

f = open(tmpfile, "w")
f.write(content)
f.close()

cmd = "js beautify-cl.js -i 4 %s"%(tmpfile)
os.chdir(jsbeautify_path)
content = os.system(cmd)
os.remove(tmpfile)


use these attributes.
Input: Current Selection.
Output: Replace the current selection.
Applicability: All documents.

That's it! you are done!

Thanks for reading my blog.

Wednesday, May 19, 2010

Twenital: Determines gender from a twitter handle

Twitter never stores the gender of their users. It makes the life of analytic engines very difficult to find that what is the ratio of men vs women on twitter.
Here I have created quick and dirty mash-up to get  gender of the twitter user.


How It Works?
Thanks to face.com API, they have recently released face recognition API. I am simply using their face recognition API to do this.


Here is AJAX code

function getusergender(imageurl) {
var url = 'http://api.face.com/faces/detect.json?api_key=1ce92a4c5e60f04c37bedf86c2d19387&urls=' + imageurl + '&callback=?';
$.getJSON(url, function (data) {
if (data.status == "success") {
if (data.photos[0].tags.length == 0) {
$("#resdiv").html('<div class="errormsg">hmmm..Let him/her put better profile picture. </b>TIP: put high resolution profile picture, facing front.</div>');
}
else if (data.photos[0].tags.length > 1) {
showerror('This user is multifaceted, Let him/her put better profile picture..');
}
else {
if (data.photos[0].tags[0].attributes.gender.value) {
var gender = data.photos[0].tags[0].attributes.gender.value;
if (data.photos[0].tags[0].attributes.gender.confidence > 40) {
if (gender == 'male') {
$("#resdiv").text('100% Male');
}
else {
$("#resdiv").text('Gorgeous Female');
}

}
else {
if (gender == 'male') {
$("#resdiv").text('Male');
}
else {
$("#resdiv").text('Female');
}
}
}
else {
showerror('hmmm... not sure!!');
}

}
}
else {
if (data.usage.used > 197) {
showerror('Sorry!! Application Overloaded!!');
}
else {
showerror('Processing failed!! Can not determine gender!!');
}
}
});

}

   DEMO  

Offline Google Maps in C#.net

Sometime back I wrote an application for windows mobile in c#.net which can give you turn-by-turn navigation on phone completely offline. Map and direction info will be pulled by a peer Desktop application which will export all these information in an XML file. This XML file will have these 2 Items

  1. Static Map Images (covering the track at zoomed & top level))
  2. Direction steps and description.
Static map images can be downloaded from Google using there static map API. Direction steps and descriptions can only be downloaded via a AJAX API. Since I had only AJAX way of getting this data, I created a webpage which can do all necessary DOM operation using JavaScript.  Once the DOM is populated I can easily grab the data from C# API (Web browser control + GetElementByID APIs).

Downloading the static Images from Google is not enough, you need to map Latitude and Longitude on the static map. Which is done like this
public PixelPoint GetCordinateOnStaticImage(double latitude, double longitude, 
double centerLat,
double centerLang,
int zoom,
double width,
double height)
{

long val = 1 << ((21 - zoom));
double target_y = LatToY(latitude);
double target_x = LongToX(longitude);
double delta_x = (((target_x - LongToX(centerLang))) / (val));
double delta_y =(((target_y - LatToY(centerLat)) )/ (val));
double marker_x = (width/2) + delta_x;
double marker_y = (height/2) + delta_y;
PixelPoint p = new PixelPoint(marker_x,marker_y);
return p;
}
You can see Full source code hereOriginally Idea is taken from here.


Direction
Google returns the poly-line of the direction path. Some of the points on this polyline will be identified as step, step has direction description, e.g "at blah blah circle take left".
This project solve another problem of pulling the right direction description from the given location.

SourceCode
Complete source-code of this project is available on Google code here.

Demo
Here is a demo video.


Monday, April 19, 2010

Create quick and dirty YQL Mash-up in 10 seconds (using MashupBuilder)


Sometime, you might have experienced that  you have to wait till whole website is downloaded just to see a stock-quote, game score, or league points table(etc.). Mostly these kind of websites are poorly managed, and they are very slow or contains too many annoying ads. I have created a Mash-up-builder that will help you in creating YQL based mash-up, very quickly. These mash-ups will be capable of showing just a small portion of the original web page. Mash-up will be dynamic and content will be pulled from original page every-time you will visit the mash-up. Additionally mash-up will be hosted on my website, so you need not to bother about hosting, though you can copy HTML code anytime if you want to host on your own.(these mashups are pure JavaScript, no server side coding).

Advantage is getting a faster & neat web page.

It was very easy to create mash-up-builder. I used YQL's html table.

How it works?
As you see that YQL's HTML table gives you output if you provide the URL and xpath of the content. Similarly Mash-up builder take 2 parameters as input, a URL of the web page and an XPATH of the content. Once these 2 things are ready, I cleverly used JSONP to render the content on page.

I recommend you to see the source {view-source} to understand the working of the mash-up.


Warning
Since mash-up builder injects HTML content directly from external source, its  prone to CrossSite Scripting attack. My website is not hosting any private content , so to me its fine because no security can be breached, do not try to replicate this functionality on your website if your website is hosting some private content.

  LIVE DEMO  




Feel free to share on twitter, Facebook & other social networking sites. 

Friday, March 26, 2010

How to write your own spell checker ? C#.net

Hi There,
Today I wrote a readable & usable implementation of Norvig's Spell corrector.
Norvi's implementation of spell check is awesome! On his site he has link to many other implementation in various languages, including C#.

Most of the implementation are focused on minimum number of lines , so they are not readable. I have written my own implementation which you can use on your own risk.

Here is the source code

You can also check-out entire code using this svn command




            svn checkout https://jugad.googlecode.com/svn/trunk/C%23/SpellCheck SpellCheck




How Algorithm works?



1.Initially Algorithms builds a dictionary* data-structure of words, from a huge English text. (so algorithm does not uses dictionary# file as such). This dictionary* contains words-to-frequency-of-occurrence mapping. lets say it as nWords.



2.When you will fetch a word(lets say 'w') for spell correction,Then the algorithm builds a list of all possible words that can be formed from w by doing following operation

  1. Deletion (delete 1 character, for all possible combination)
  2. Transposition (flip 1 character, for all possible combination)
  3. Alteration (modify 1 character, for all possible combination)
  4. Insertion (insert 1 character, for all possible combination)

Lets say name of this list is 'edits' , note that all words in this list are just 1 step away from original word.
3. If edits has 1 or more words that exists in nWords, then it returns the word from nWords with maximum frequency, as a result.
4. If No words in 'edits' are present in nWords, then it creates another edits using edits to get second level word (word which are 2 step away from original input word)
5.Repeats from step-3 (or give up if your are already 2/3 steps apart from original word 'w')
Read more Here.

How To Use This code ?
To use this code instantiate class spell by passing huge-string of English text (from where it will build dictionary)
Then call function correct() to get the corrected word as result.

Note:This code is just to demonstrate the algorithm, modify constructor to build dictionary directly from file. You can also avoid calling sort operation in function 'correct'. Thoroughly understand the code before using it. Notify me if you find any critical problem.


*dictionary data-structure of programming
#real dictionary

Thursday, March 25, 2010

How to get Tabs (navigation bar) on new blogger templates

Hi There,
First of all you might have seen that blogger has brought-up new Template Designer. This article is to tell you that "how can you add tabs in these new templates?"

Its very easy

  1. Open http://draft.blogger.com/home
  2. Go To layout section and add a page element of type "HTML/Javascript" just below "Blog Header"
  3. Now add this code in the widget.



<ul>
<li><a href="http://sampleurl.com">Sample URL</a></li>
<li><a href="http://example.com" >Example Links</a></li>
</ul>

Note that between ul tag you can add many as li items as you want.
each li item will have a anchor ("a") element whose href property needs to be set to the URL you want this tab to link, and text portion goes in between.

customize this code as you want, and then paste them in the widget section.
save your widget and enjoy the tabs.

Thanks for reading my blog

Sunday, March 21, 2010

How to organize life using twitter?

{Happy Birthday To Twitter, Today on 21st March 2010, little bird (twitter) is all grown up. }
Today in this article I am going to tell you some little tip to organize your life with twitter. Read my old article about how I have linked my social network.

Twitter is popular because of 2 main reasons, Simplicity & Accessibility. Twitter Updates (tweets) are just 140 character long, and you can post these update from any media e.g Browser, twitter clients, phone client, by SMS or even by writing down on paper.

For centuries there are 2 very popular ways of organizing life,
1.Note Making
2.ToDo List
Despite these things being a popular way of organizing life, majority of people fails to maintain a single note-book or a ToDo list, because if your life is so organized to maintain a ToDo List or notebook then probably you never need them. Point is, either you are using a paper, phone, iPod or your laptop to maintain your ToDo list , none of them is accessible all the time & everywhere. Eventually this accessibility problem is almost solved by twitter, So there can not be any better tool like twitter to organize your life.

I always loved 2 tools on web for maintaining my todo list and notes, because they are also accessible via twitter.

EverNote
EverNote is very nice note making tool. I am not going to tell you much about it. You can just go an try it. I love its web-clip boorkmarklet to take note while browsing. Addition to specific client it has for iPhone, Android and Win-Mobile, You can also add a note in EverNote by just @replying to @myen or send a DM(direct message) to it. Now since tweet can be posted by all ways described above , you can access your note from every where.

e.g
   note to self "kill all currupt politicians" @myen
OR
d myen think about explaination why photo frame is better than diamond necklace on valentine's day
Remember The Milk

Remember the milk has a very similar accessibility options as EverNote, the difference is in aproach, This is a ToDo list for task management. You can also access it by sending DM to @rtm
e.g.
d rtm pick up the milk
d rtm !complete call jimmy

Search Your Tweets
Here is last tip, Since twitter has become your primary place to dump thoughts, Its better to have a way to search your tweets. Twitter search is a real time search, it only gives you results from a very small time-frame, sometime you might like to search your old tweets. To get this functionality here is a hack, subscribe your twitter feed in Google Reader, Google readers stores all the feeds subscribed by you and indexes it, so that you can search them latter. RSS feed of your tweets will be at this address (if you have unprotected updates only)
http://twitter.com/statuses/user_timeline/[your TWITTER HANDLE].rss




Thanks for reading my blog. Hope this was helpful. Please share on twitter and Facebook if you liked it.

Wednesday, February 10, 2010

What is "Inbox Zero problem"? How To solve it by Twitter-way?

Inbox Zero problem is a usability problem, of which every mail system is infected with. Let me try to explain what it is?

Today, we get at least 40-50 mail every day, and our mail system marks every mail as unread when it arrives to your inbox. Now problem is, you are tempted to read all those mails to bring your inbox to zero unread count. This goes into a never ending loop often because by the time you will be able to finish each and every mail, you’ll get some new ones. 

This is a problem many other social networking platforms are infected with, may be not with the unread message count but by some other ways.

This is the only problem twitter is not infected with, because its always flowing timeline of short messages and you need to just look for few recent items posted by people, because of 2 reasons
1. Those items are not specifically posted to you (not talking about @replies).
2. Tweets are very spontaneous status update from people; significance of (most) tweets expires after sometime.
This is how people on twitter able to manage more and more people. I personally follow more than 600 tweeps around the world. Now, there is a problem!! Different people tweet at different pace, and many tweeters are so frequent on twitter is that they literally flood my timeline and kick other's tweets (from people whom i care more) out of my visible timeline. This problem is solved by lists, I group important tweeps in a list. Concept of list itself came from people and twitter client like TweetDeck & Seesmic. Think lists like this, On twitter you have public timeline which is the fastest moving timeline, and you filtered some of them to bring in our "friends" timeline by following them. When things became messy you sorted them into few smaller lists.

Twitter evolved from people's behaviour, like @replies, retweeting and many more became the built-in feature of twitter because we tweeps started using it.

So none of my time line is actually having inbox zero problem.

Now let’s come back to e-mail system, every day in office i really get more than 100 emails including companywide mails, group mail , mails from an on-going thread of discussion (where I don’t have anything to do).  Now what?? My mail client (outlook) is so cluttered with e-mail that finding the right email becomes very difficult. Ok , we have a solution “make rules to skip inbox for some known group & automated mails” BUT creating rule is not going to solve my problem because I am very lazy and don’t want to create rules even once in a six month (yes, that lazy i am). Last rule i created some 6 months back : P.

So what is the solution? Solution is simple; I call this solution "@actionItem". Which is like this, every mail which has some action item for me as individual then please include my name in a field called Action Item (like CC & To list). That’s It i will give priority to those mails first and then i will move to all other mails, and choose to skip if i don’t have much of time to spend. Inbox zero problem solved.

Twitter specific Terms : 
  • Tweeps: people who use twitter.
  • Tweeters:  twitter+ user
  • Tweet:  Every small status update (post ) is called tweet.
  • ReTweeting: when you post oneones update again is called re-tweeting. often done in "RT @TweepName : blah balh format".
  • @replies : pronounced as 'at replies', are tweets which has your name mentioned, preceded with a '@' sign. 

Here is Merlin Mann Slide



Here is video of his lecture

Thursday, January 28, 2010

Understanding C#.net Border-less Form, when you maximize it

Hi There,
Have you ever created, a borderless window in C#.net?
There is problem with borderless window, if you maximize it, it goes FullScreen (over the taskbar).

Here is an analyis of how to achieve maximized borderless window.




If  you first set the border(anything other than FormBorderStyle.None) for the window and then set WindowState to maximize, You will get a standard maximized window, you can make it border-less there after.





private void btMaximize_Click(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.FixedSingle;

if (this.WindowState != FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Maximized;
}
else
{
this.WindowState = FormWindowState.Normal;

}

this.FormBorderStyle = FormBorderStyle.None;
}





If you maximize a window after making it borderless it goes beyond the task-bar. You will get complete full-screen.



private void btFullscreen_Click(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
if (this.WindowState != FormWindowState.Maximized)
{

this.WindowState = FormWindowState.Maximized;
}
else
{
this.WindowState = FormWindowState.Normal;
}

}





Sunday, January 17, 2010

Hacking Google maps AJAX API to use in C#.Net

Hi,
As you know “Google Maps API” is available only for AJAX developers. Using it in C#.net is not possible. One of the great things about Google maps API is it gives you turn by turn direction almost anywhere on earth. I wanted to exploit this feature of turn by turn navigation on my mobile, that too offline, because when i go to remote places its highly probable that i will not be having connectivity on my phone. Or connectivity will be so poor that using maps is highly impractical.

So I have created a pair of application.
1. A Desktop app to retrieve turn by turn navigation data + static images.
2. A Mobile app to read this data and to give me turn by turn navigation on phone (offline).

Certainly this is something not allowed in TOU of Google, so i cannot release this app commercially.

How to Mix AJAX and C#.net??
1. I created a web page (html+JavaScript), which dumps the direction info data in DOM.
2.In C#.Net Form, I kept a web-browser control, which loads this page.
3.When page is loaded, using webBrowser1.Document.GetElementById stuff I extracted the direction info.
4.Then I downloaded Static Images using "Google Static Maps API", & hacked to get the latitude and longitude positions on the static images. see code for detail.


How I exported data on mobile??
1. Serialized whole object in an XML file, including direction info and static images.
2. De-serialized on mobile to get that data back.


Source Code
http://code.google.com/p/pocketnavigator/


Screen-shot Of Mobile Version.



Demo of Desktop App (6 minute).

Thanks, Feel free to ask question, & share on twitter + digg & blah blah.

Sunday, December 20, 2009

Jump into 3D maps by calculating orientation

Lets make a VirtualDrive MashUp today. As you know that Google maps API has Street view feature and Live maps has Bird’s Eye view feature. We will mix these 2 things in our mash-up.
Feature of This MashUp will be
  • To Take input as source and destination address.
  • Animate the street view & Bird’s Eye from source to destination.
To get this done you will need direction API to know the path between source and Destination. Eventually Google’s Direction API will do this for us. Direction API returns a PolyLine from source to destination. We will use GDirections.getPolyline() Function. Once you have all the points (Latitude and Longitude) along the path you are all set to go. But wait street-view and Bird’s Eye view are 3D Maps they also have something called orientation .
Bird’sEye View requires only one extra parameter "orientation" which can be
  • North
  • East
  • South or
  • West
Where as Google Street View is more complicated , its requires Yaw and Pitch (i am ignoring zoom level which applies to all kind of maps)
image
Since we will concentrate on driving , we will keep the pitch horizontal i.e. pitch will be zero.
Yaw can be calculated by using 2 points along the path. Yaw is the angle of your driving direction from North, in degrees.
Here is a JavaScript code to calculate Yaw with given 2 values of GLatLng.
(Note that Yaw & Bearing is closely related terms and they are having same value here.)
function GetBearing(GLatLng1, GLatLng2) {

var lat1 = GLatLng1.lat();
var lon1 = GLatLng1.lng();
var lat2 = GLatLng2.lat();
var lon2 = GLatLng2.lng();
lat1 = lat1.toRad();
lat2 = lat2.toRad();
var dLon = (lon2 - lon1).toRad();

var y = Math.sin(dLon) * Math.cos(lat2);
var x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
return Math.atan2(y, x).toBrng();
}
One feedback about street-view API though, function setLocationAndPOV is very mysterious and I could not make it work.
Individual Code snippets I picked from here
  1. Google AJAX Playground
  2. Live Map APIs Sample
  3. movable-type
Now Jump To Demo

And Do ViewSource to see the code.

Saturday, November 21, 2009

Google's "Chrome OS" is Bad Evolution

I am a computer engineer. I will always love to see computing evolving in right direction.
Google Chrome OS is bad for evolution of computing.

Computing evolved with Desktop computing and then web apps. Browser Based apps are always slow and faulty, they can never be as robust as a desktop application can be.

After The invention of web services and REST API, I would love to see web enabled desktop Apps.

I love the concept of Portable Apps , When we mix concept of portable Apps and Cloud Based storage, we can achieve much better results.  BUT Google will never let it happen, they are re-inventing all those age old things again in browser. I have posted a small video response on you tube.

Here it is.

Thursday, November 5, 2009

Simplest Way to Add code review using CodeCollaborator

One of the simplest way to add code review is by doing a diff on 2 folders. Where Folder1 Contains the previous code and Folder2 contains updated code.

Unfortunately the documentation was lil messy and I was not able to do it.


Here is simplest simplest example.

Use command line client of Code Collaborator and type this command
ccollab adddiffs new  Folder1 Folder2

Instead of new, you can write the review number which you have created at your server.

ccollab adddiffs 12345  Folder1 Folder2

I had problem about this, so posting here. May be this will help you as well.

Good thing is smatbears people are on twitter and they helped me.. Thanks guys.


Sunday, August 23, 2009

7 things I did on my blog, to make it a better place to read

Readability & accessibility for a blog is very important.  You need to give few good reasons to your reader to bring them on your blog site. Today, when technology is really advanced we need to re-look our blog website & think of few additional things.  This blog has all those 7 things, which I am going to discuss. I consider my blog most accessible in all forms. Good theme for readability, easy to share, optimized for speed, accessible on mobile, user can choose to translate in his language & last but not the least user can choose to listen its content.

1. Choose better theme.
This is most basic thing. Clean and neat theme on a blog is very important. White background with black colour text is most appropriate theme.  Do not put too much of flashy advertisements or flashy content, they not only distract & confuse your readers; they also slow down the loading time. This article might help you to choose better theme.

2. Make it easy to share & comment.
Blogging is a form of social media. It’s very important to have better interactivity with your readers.  Comment form must be having various options; user should not be forced to login to put comment. Yes, if don't want any unwanted content to be posted by your readers, your can go for “comment approval” option.
These days’ people love to share blogs on various channels. Add buttons like addthis, dzone, tweetmeme(blogger, wordpress) digg(blogger, wordpress) etc to make it easy to share.

3. Optimize for speed.
Adding to much of buttons, poor theme and gadgets might slow down loading time of your blog site. Here are 3 things you can do to improve performance.

i. Put all unobtrusive scripts at the bottom of page.
As you know most of the gadgets and buttons are based on JavaScript. Adding too much of buttons and gadgets might slow down loading time of your blog.

Any JavaScript block, freezes the loading of rest of the content till complete JavaScript code is not loaded. So you can effectively bring readable content much early, by putting most of the JavaScript blocks at the bottom of the page. Question is how can you decide, what can be kept at the bottom of the page? Any script which only executes when entire webpage is loaded can be brought the bottom of the page. In more technical terms any unobtrusive code can be kept at the bottom of the page.

ii. Use CDN (for better loading time) .
One way to get free CDN is “Google’ App Engine”. Read this article.

iii. Run tests like Yslow or Page Speed.
YSlow and PageSpeed are a plug-ins for Firefox (on top of Firebug). These plug-ins can run a test on websites and can tell you what can be optimized.  They will provide huge list, though you can not achieve all of them easily but if you even achieve 50% of them your website will be much faster than any webpage. If you really want to see most optimized web page see yahoo home page. They have lots of content on the website but still loading surprisingly low.

4. Automated podcast (sometime listening is better).
If you are kind of guy, who write long descriptive content, automated podcasting feature might help your reader to have an option to “listen” rather reading it. Odiogo gives free automated way to get podcast of your blog text. It has built-in text-2-speech feature, which will narrate your blog.

5. Automatically Translatable.
Automated translation might not help a lot, but can be really handy for foreign users. Use Google Translate widget on your blog so that user can easily translate.

6. Mobile readable.
Many people prefer to do blog reading on their mobile. There is an easy way to create mobile version of your website. You can use Mobify, to get mobile version of your blog. Getting mobile version is easy; you can get it in 3 easy steps.

7. Add some fun.
On my blog you can drag those sidebar gadgets, such kind of functionality can help reader to play with your blog.

Thanks for reading, Love to see your comments.

Sunday, August 9, 2009

Top 11 Language Concepts That Every Developer Should Know

There are a few fundamental things we have invented in programming languages,
which was invented at various point of time, particularly by one language and they were later adapted by many other languages.
I am going to list some of them, which have bigger impacts.


DataType
The first and foremost thing which we have ever invented is the data type. Computers were  just a dumb machine, which could only understand the binary sequence. Binary sequence made no sense till it was grouped to form a DataType.
As you know a DataType, is something which groups the binary sequence together and represents some entity in mathematical word OR real word. All depends on its interpretation.
DataType is not just a grouping of binary sequence but also a set of operations which it posses. I mean a DataType definition just don't end with its binary  grouping but also the operation which can be performed on those entities.
Later we have evolved these DataTypes into more complex form. We used mathematics to bring various complex data structures like List, Stack, Queue etc.
Today almost every programming language directly or indirectly have concept of data type.


Pointers
With the invention of computers, we've   also invented the concept of loading and storing data from Hardware. Computers accesses memory by toggling special bit patterns in the  wires (which was called data bus).  This  led to the invention of Pointers in our high level programming languages.
Pointers specially became popular in C programming language. Pointer is one of the most popular programming concepts ever invented.  Other than C language, pointers are supported by languages like C++,C#, Fortran, Pascal. Few dialects of BASIC also supports pointer.


Structured Programming
Most of the programs in the early days were completely relying on GOTO statements, which was a real mess and was making programmers life real hell. Now that's where we have invented the "structured programming " another fundamental programming concept. Through this concept we have brought something called functions, and subsequently we realized the power of abstraction.


OOPs
I think OOPs (Object Oriented Programming) is one of the most popular and ever lasting fundamental concept we have invented in history of programming languages. OOps is an umbrella concept. We have brought many concepts under this.Concepts like Data hiding, Inheritance, abstraction, polymorphisms (static & dynamic) were just the beginning of OOps. OOps is available directly or indirectly in almost all modern languages. Languages like C++, java & c# have brought it a long way.


Regular Expression
Regular expressions provide a concise and flexible means for identifying patterns in string. This is used for searching and replacing special pattern in a string.If your favourite programming language is supporting Regular Expressions, and you are still thinking of learning,then this is the time to go and learn. Regular Expressions are now supported by many languages (almost all popular programming languages). Additionally Regular expression became standard language for many find and replace system utilities. Unix command (utility) Grep is one of the most popularly known Regular Expression based utility. Regular Expressions became so popular concept that many programming languages made it as the part of there language syntax (construct).Languages like  Perl, Ruby and TCL embraced regular expression as their primary language construct.


SQL
With the invention of Relational database, where everything is stored in the form of Tables, SQL type of languages evolved. This was mainly developed for  data query, data update, schema creation & schema modification. They became so popular that it was extended to make procedural SQL.
With the popularity of SQL, recently Google has brought GQL to abstract their Big Table ( a non relational data base). SQL like syntax is also borrowed by yahoo in YQL, to query data from anywhere on internet. LINQ in C#.net, is also inspired from SQL.


Managed Heap
Managed Heap OR Smart pointers, was another revolutionary concept which was invented as a hack of OOps concept (classes ) in C++. This was invented by Microsoft in a concept called COM. Smart Pointer, solved the problem of memory leak .
This concept was later adapted as default language semantic in programming languages like Java & C#. Later this was adapted by many programming languages like VB.net and Managed C++.


XPATH
XPath is another programming concept which was developed to access DOM tree, and became a preferred way to access the XML formatted data. This is another programming paradigm which you should be aware of, If by any chance you work with XML.



Duck Typing
The Term “Duck Typing” is invented by Python, though the concept of duck typing is old and was there in few languages earlier than Python.In duck typing, programmer is concerned with just those aspects of an object that are used, rather than with the type of the object itself.
Let's understand this. Let us say we have a real life object Shape, which knows how to draw itself (with a method draw).  Now in OOps, We enforce this by creating an interface something like IDraw, any anything which can be drawn on the screen must be of type IDraw(i.e It should be inheriting IDraw). I Duck Typing, object can be drawn on the screen as long as object holds the draw method,irrespective of the type of object. DuckTyping removed the dependency of common interface definition, which are typically shared by client and server modules in OOps languages.  Disadvantage of such thing is, programmer will not be able to know at the compile time, that the object is not having the draw method in it. But wait, python does not have compile time, its interpreted language, so all the problem can only be identified during the runtime.
One thing i am sure about DuckTyping is that it is very risky deal when you are building a big (cathedral like) software. But it is very good when you are writing  very small quick and dirty lines of code.
Duck Typing is supported by Python, JavaScript(and similar languages) & C# (for your surprise, read this nice example).
Duck Typing helps a lot in JavaScript, in fact the concept of “JSON based AJAX” is completely based of duck typing.
Duck typing is a very controversial concept, many OOPs lovers hate this concept.


Closure
Some languages (e.g. JavaScript) allows you to define a function inside another function. Closure is the scope, which inner function is having.  Coolest part of closure is, scope remains valid even after outer function have returned.
One of the nice example of closure is this (in JavaScript), Inner function dofading will still be having access to ‘Div_InClosureScope’ even after the Fade have returned.
function Fade(id)
{
var Div_InClosureScope= document.getElementById(id);
var level=0;
function dofading()
{
var hex=level.toString(16);
Div_InClosureScope.style.backgroundColor='#ff'+hex+hex+hex+hex;
if(level<15)
{
level++;
setTimeout(dofading,100);
}
}
setTimeout(dofading,10);
}
In more general term, closure is a special scope, provided to a special instance of a function. In OPPs the member function enjoys closure (data members are in closure scope). Programming language C does not have closure concept at all. Its a most simple and straight language.

Yield
I found this technique first in python.This was not something new, but can confuse most the programmers from c/c++ background. This technique somehow stores state of iterator (I will explain latter), and returns different result at different time, and this is something c/c++ programmers are not used to. Any C/C++ programmer assumes a function is a stateless machine, which can return only one result for given set of argument, no matter how many time you going call that function.


A Python function stack can be unwrapped( retuned) in 2 ways, by a return statement or by a yield statement. A return statement stops the execution of a function (same as in c/c++ ). On the other hand an yield statement halts the execution of a function and store the state, so that when it will be invoked later, execution will start from the same point.


Lets take an example of typical Fibonacci number generator.

#An endless generator
def fibonacci():
i = j = 1
while True:
r, i, j = i, j, i + j #respective assignment
yield r

for rabbits in fibonacci():
print rabbits,
if rabbits > 100: break

Output
1 1 2 3 5 8 13 21 34 55 89 144

Python certainly support, C++ like return statement, but using yield is most efficient for this such generators. All those recursive way of writing Fibonacci number generators are really inefficient( though they look simple).
Yield statement is also supported by C#.net.  Here is one of the nice post about yield in c#. Do not miss!

I love this article, "Life after loops". somehow, its connected to this blog post

Saturday, August 1, 2009

We Code writers are better than Literary Writers

We write to make it readable.
Yes, we spend 20% of our coding time to produce working code, and rest of 80% time in beautifying and indenting our code. We love to make our code more and more readable.

We don't beat around the bush.
We write very specific. We hate un-necessary details. We try to communicate the message (the solution) as early as possible.

We love to keep it simple.
We as a code writer, don't try to complicate things. We feel much better when we see our solution simple. That's why we say KISS (keep it simple, stupid!).

We don't repeat Information.
yes, we believe in DRY (don't repeat yourself) principle. we represent one information at only one place. Though many novice developers make mistake to represent  information twice and thrice in their code. This brings a serious problem.

We don't count pages.
We developers, (true developer) feels very productive when we delete LOC( line of code). Most managers in our company think that LOC is true measure of our productivity, but we don't.  We love to delete code, and our most productive time is spent in deleting Code.

We are open.
As an innovator, we try to present idea, even if we are scared that idea can be stolen. We don't think hiding an idea makes any kind of sense.

We are least bothered, when it comes to plagiarism.
Unlike literary writers, we are less concerned about plagiarism. We love if someone copy our code. We take it as a good news. in-fact the whole open source philosophy is based on it. We just request to mention our name in the code, but if they don't mention we don't bother.

Thursday, July 30, 2009

Few Elegant solutions from Apple (present and future)

Looking at the various patents and products from apple I believe they are most innovative people in the world (of computers& devices).

(Note:Click images to explore more)

iPod Shuffle's VoiceOver SolutioniPod shuffle with VoiceOver icon.
VoiceOver solution provides, a voice based menu to the iPod listeners. Solution looks quite great and you might end up thinking that iPod shuffle has TextToSpeech functionality. But answer is NO. iPod shuffle is still a device which can just play an audio file. The menu items come from the another audio-file which has been synced into your device thru PC. Today your PC is capable of TextToSpeech, iTunes will use this to get the small audio file, which will be the sound of SongName, Artist and etc. (textual information resides in your mp3 file).

 

Movement-Aware Interfaces for iPhones


Isn't It Great to make your icons bigger, when you are jumping or running while using your iPhone. I think  YES,  iPhone will use accelerometer to resize its menu and  other UI elements. 

USB device ejection touch sensor


How annoying is it to do several click on your PC, just to eject your USB device? Its solved!! Apple's USB devices will be having a small sensor to know that when you are going to hold your USB device and probably your intension is to plug-out.

Haptic Feedback for touch screen


Touch screen helped us to utilize the same physical space for different functions. awesome!! But reality is, user never sees what he is going to touch. This is not a problem in hardware keys, because they are embossed and they can be felt. Many other companies have brought the haptic feedback already, but that's actually a joke, they actually vibrates the phone's vibrator when you will tap(or touch). Here is a patent from apple which is going to materialize the haptic feedback in real sense.

Device Settings In smart Headsets


Don't your think EQ (equalizer) settings are more related to your output device than your iPod. YES,  then Apple has made it simple, now there will be smart headsets which can store EQ settings.

Monday, July 6, 2009

2 Steps to make your (blogger based) blog translatable.

Here are the 2 step to make you blog translatable, Like this.

STEP-1
Grab This code
<script src='http://www.google.com/jsapi' type='text/javascript'></script>
<script type='text/javascript'>
google.load("jquery", "1.3.2");
google.load("language", "1");
</script>
<script src='http://jugad.googlecode.com/files/translate.js' type='text/javascript'> </script>

STEP-2
Go to blogger, and "Edit Layout" Section, and choose "Edit HTML".
In Head Section just paste the above code, Save and exit.

Optionally You can also add a title less Gadget of type "HTML/JavaScript" and paste the above code. But it might not work all the time.


Please feel free to leave comment if its not working with you.

For the advanced Users:
I have created a Unobtrusive JavaScript code, Here
This requires Google Language API & jQuery.
First two script block above is to bring jQuery in your blog and then my script to produce a translate "combo box", which can be used to translate your blog.

Demo: Click Here
Source: Click Here