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, September 6, 2010

Portable wire-free Wi-Fi Router in India



Tata has launched a new product “TATA Photon Wi-Fi Router”. With this, you can now create a portable hotspot anytime, anywhere. It is a device that enables you to share Wi-Fi with up to 5 users/devices simultaneously to access internet: Imagine the whole family accessing the internet from their respective devices – iPod Touch, WiFi enabled smartphone, laptop – on the go, all using this one portable router!

Introductory price is 4999/-

Device is powered by rechargeable Li-ion Battery.
More Information find here

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.

Sunday, June 13, 2010

HindiTransliteration (c# and JavaScript implementation, works offline)

When I was in college, I wrote a quick and dirty code to transliterate in Hindi (DevNagari Script). Much before Google's Implementation.
{This code was kept on my old desktop PC,I Thought, its a good idea to share with the rest of the world}



Though my implementation is not very robust, but Its very simple and small. It does not require any Internet connection and can work offline.

Note: code was originally written in C#.net and converted to javascript latter.
Here is C#.net Code(solution zipped)

You need to call function
DoTransLitrate(str)
Where str(as input): Phonetically typed (in English) Hindi .
Returns: Hindi in Devnagari script.


Using JavaScript Code
Get the JavaScript File from here include in your html page and call function
DoTransLitrate()
  DEMO  

Monday, June 7, 2010

Kill All Chrome Instance at once (Linux+ Windows)

Windows users can follow this instructions here.
Or simply use command




        taskkill /F /IM chrome.exe



Linux geeks can use this command 


    kill -9 `ps -A |grep chrome| cut -d "?" -f1`


How This works?
I am sure that, most of the Linux users can easily figure it out, but for those who want explanation here you go...
Command
  ps -A          list all the processes
  grep chorme     will filter only those process which has name as chrome
  cut -d "?"     will cut the process Id potion of the out put.
and
  kill -9   kills a process ,
so above command will kill all the process with name chrome.
Please Note that this command will work on those processes which are not command line (mostly launched from UI ) (i.e whose tty field is "?")

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. 

Saturday, April 3, 2010

IPL Tables made sortable

Ever since I visited the official IPL website, I hated those static points table.

So I used YQL to grab that data and place in very sortable fashion here.




To create this I am using,
YQL 
Google visualization API  (optionally one can use YUI)
Jquery tabs

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.

Saturday, March 20, 2010

Awesome QUESTIONS are back

Do not miss the part-1 and part-2 of awesome questions. AND here are few more
  1. If love of money is the root of all evil, why do churches want it?
  2. If love is blind, why is lingerie so popular?
  3. If Jimmy cracks corn & no one cares, why is there a stupid song about him?
  4. If it’s true that we are here to help others, then what exactly are the others here for?
  5. If it takes more muscles to frown than smile, then wouldn’t unhappy people’s faces be in better shape?
  6. If I save time, when do I get it back ?
  7. If I save the whales, where do I keep them?
  8. If flying is so safe, why do they call the airport the terminal?
  9. If electricity comes from electrons, does that mean that morality comes from morons?
  10. If you are reading a very INTERESTING book about anti-gravity. Can you put it down?
  11. How can an email be both URGENT & FYI?
  12. If vegetarians eat vegetables, what do humanitarians eat?
  13. Why do people make loud nosies when there tryin to make someone be quiet?
  14. If past tense of sit is sat, why not past tense of fit is fat?
  15. People say "The moment u stop learning u r dead", then why population is still increasing?
Thanks Guys have fun :)
If you have any awesome question about the blog, please post as comment. Do share on twitter and Facebook if you like it. 

Wednesday, March 17, 2010

How to add custom about me page on blogger

Hi There,
Here I am going to talk about a dirty hack to make custom about me page on blogger. Lets have a look what you are going to get after doing all this.

So, Basically you are going to make an blog post which will contain "about me information" which you wanted to put on your blog. Then you will remove date entry(time stamp) / and comment option for this page so that it will not look like a post.
Note: Save your existing template before, doing anything. If you break anything , you can restore the template back.
STEP-1
Create a blog post with title "about me" and content whatever you want. Then go to Post option

STEP-2




Go to post option and click "Don't allow comment" and Set time-stamp to a very old date (may be much before your birth).

Step-3
To remove time-stamp from this post your have to wrap part of code which generates Time stamp in your template with this code.
<b:if cond='data:post.allowComments'>



</b:if>

This is basically a way to tell that whatever "post does not allow comment" will not generate few things (which is time-stamp in our case). 
Step-4
Go to layout section of your blog, and go to edit HTML. Choose "Expand Widget Templates" option.

Now select all the text from Text area and put in your favorite "Text Editor" . (FYI My favorite editor is Notepad++).

Now wrap following 2 block with code above
<h2 class='date-header'><span><data:post.dateHeader/></span></h2>
AND
<div class='post-footer-line post-footer-line-1'>




Part-1

Part-2
Once you are done with this editing, go paste the entire thing back to blogger text-area and save the template.

Note: You should wrap the code very carefully, basic HTML knowledge is very essential for this.  Every Div block starts and ends some where , so wrapping must be perfect.




You can link the URL of the page on "About Me Tab" Read My other post.

Thats it, Your are done!!!

Tuesday, March 16, 2010

Chrome Extension to analyse tweeter (Twitter User) Behavior

Recently I was looking on various sites that shows some statistics about tweeters (twitter user). They are great but they often focus on one thing, there is no single place where we can see all these analysis. So i closely analysed these websites to come-up with YQL hack to bring all of them on a single page. Mainly I focused myself on these websites.

  1. http://twitterholic.com/
  2. http://web.forret.com/tools/twitter-tq.asp
  3. http://tweeps.info/
  4. http://happytweets.com/
  5. http://tweeteffect.com/
TweetChrome

[I am also trying to pull information from http://tweetstats.com]

Well if I would have hosted this functionality something like this (actually hosted ).  No one will use it, because people are very lazy. So I have created a chrome extension here.

If you use chrome then you can simple see source code here.

Thanks for reading my blog.

Saturday, February 13, 2010

Playing with Javascript Closure, JSON, & YQL to Visualize upcoming Android Version Names

Hi There,
As you know that First version of android was named "cupcake" and then it was "Donut" and current version is "Éclair".
People found a pattern in naming; they are alphabetical names of cake. Now many people on internet came up with the names up to the Z.
Here they are

  • Cupcake
  • Donut
  • Eclair Cake
  • Frosting
  • Gelato
  • Honey
  • Icing cake
  • Jelly
  • Kiwi
  • Lemon
  • Marshmellow
  • Noodle
  • Orange
  • Pudding
  • Quince
  • RockyRoad
  • Sundae
  • Taffee
  • upside-down-cake
  • Vanilla
  • Waffle
  • Xmas Cookies
  • Yogurt
  • Zebra Cake


I am completely unaware of some of these names; I really don’t know how they look like. So here i made a small YQL hack to get images with these names to visualize them.


Here is the YQL Bing table query to images





function get_images_from_bing(query,callback){
var yql_url="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20microsoft.bing.image%20where%20query%3D%22"+query+"%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=callbacks."+callback;
var div_ele=document.getElementById("myscrpts");
var scrpt=document.createElement("SCRIPT");
scrpt.src=yql_url;
div_ele.appendChild(scrpt);
}

Here I am using closure to get a call-back function which will render the my images.




function GetCallbackFunction(element){
/*
element will be accessible to inner returned function
even after outer function has returned
*/
return function(data){
/*Get randomely from top 3 images*/
var index=get_random(3);
index=index%data.query.results.ImageResult.length;
element.src=data.query.results.ImageResult[index].MediaUrl;
};
}

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

Saturday, January 30, 2010

I know what you read on dzone last summer

You should know that depending upon how CSS is coloring your links; I can figure out that what are the links you visited already.
This is a nice hack, many people use it for knowing user interests e.g
  • What social networking site you use.
  • What banking site you use.
  • And many more what you can think of.
I have created a hack to show all popular links from dzone, I am sorting the links based what you have read already. Before you read further Check This, (will not work in IE8)

Here is how you can inspect CSS color of a link in your browser


document.write('<style>');
document.write('
#linkID:visited {color: #FF0000;}");
document.write('
</style>');

/* quickly add and remove the link from the DOM with enough time to save the visible computed color. */
document.body.appendChild(link);
var color = document.defaultView.getComputedStyle(
link,null).getPropertyValue("color");
document.body.removeChild(link);

/* check to see if the link has been visited if the computed color is red */
if (
color == "rgb(255, 0, 0)") {

/*visited do something*/

}
else {

/*not visited, do something else*/

}




Read More about How I brought All Dzone links on 1 page

Read More About How This CSS hack works?

Read Rest of My Hacks


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.