tag:blogger.com,1999:blog-325099752024-03-14T14:59:03.581+05:30Rambling onSumming up thoughts on thoughtsAnonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.comBlogger61125tag:blogger.com,1999:blog-32509975.post-74342972580625620652012-10-22T20:12:00.001+05:302012-10-22T20:12:20.410+05:30Android Wifi tethering<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
A short note on Android hotspot/adhoc network sharing. I have been thinking to buy a <a href="http://www.google.com/nexus/#/7" rel="nofollow" target="_blank">Galaxy Nexus 7</a> for sometime. The hindrance so far has been Android devices inability to connect to Ad-hoc network. <br />
<br />
My conclusion is that if you are running on Android 4.x+ it is easy to tether network connection between Android devices only.<br />
<br />
In case you want to share/tether/hotspot to an Android device there is no easy way out. For example if you want to share iPhone's internet connection with an Android device you possibly cannot (at least its not straight forward). Vice versa is possible. That is you can share your internet connection from an Android device with an iPhone(At least the latest Android versions).<br />
<br />
If you are running 4.x + Android version you do not need to install any additional application to tether. The stock ICS+ OS supports WiFi tether and few other ways to share internet connection.<br />
<br />
What I was successfully able to test<br />
<br />
* I could tether <a href="http://www.google.com/nexus/#/galaxy" rel="nofollow" target="_blank">Google Galaxy Nexus</a>(GNex) with a Samsung Galaxy S2. GNex acted as Hotspot.<br />
* I could tether Galaxy S2 with GNex. Samsung Galaxy S2 acted as Hotspot.<br />
<br />
In both the cases Devices were running on Android version 4.1.x +<br />
<br />
So, it is a safe bet to buy Nexus 7 in case you have an android device Running on Android ICS. But if you own an iPhone and thought you can share the internet connection through that, well you may be in a fix. Think again.<br />
<br />
I am posting this for other users who may have wasted a lot of time trying to figure out why their Android devices does not detect Ad-hoc networks.<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-64955426873952074972012-04-13T14:20:00.000+05:302012-04-18T19:04:42.777+05:30Remove all Ruby Gems<div dir="ltr" style="text-align: left;" trbidi="on"><p>To remove all gems from your system, this should work.</p><pre><br />gem list | cut -d" " -f1 | xargs gem uninstall -aIx<br /></pre><p>On JRuby following works</p><pre><br />gem list --no-versions | while read x; do sudo gem uninstall $x -a; done<br /></pre><p>Many a times you may run in to situation where you simply want to clean up all the gems installed. I found <a href="http://geekystuff.net/2009/01/14/remove-all-ruby-gems/">this</a> article very helpful. Above command is copied from their. You can read detail on the site.</div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-51979917736626586002012-01-25T16:33:00.001+05:302013-02-19T16:03:16.794+05:30Git Reference card<div style="text-align: left;" dir="ltr"><h3>Git create remote branch</h3><p>To create a local branch</p><pre>git branch branch_name<br /></pre><p>To switch/checkout local branch</p><pre>git checkout branch_name<br /></pre><p>You can combine above two in one step instead</p><pre>git checkout -b your_branch<br /></pre><p>Create remote branch (so that other co-workers/programmers/whoever can pull)</p><pre>git push -u origin your_branch<br /></pre><p>Others can pull this by</p><pre>git checkout origin/your_branch<br /></pre><h3>View diff in GIT</h3><p>What you will commit</p><pre>git diff<br /></pre><p>diff between two branch</p><pre>git diff master..branch_1<br /></pre><p>diff since last commit</p><pre>git diff HEAD<br /></pre><p>Diff with stash</p><pre>git stash show -p stash@{0}<br /></pre><h3>Git create and apply patch</h3><pre>git diff --no-prefix > patchfile<br /></pre><p>and</p><pre>patch -p0 < patchfile<br /></pre><p><a href="http://stackoverflow.com/questions/3418277/how-to-apply-git-diff-patch">Detail on stackoverflow</a></p><h3>Ignore files</h3><p>Easiest way is to create a <code>.gitignore</code> file in root folder. You can have <code>.gitignore</code> in subfolders in case you want to include rules specific to subfolders. This does not apply to already tracked file. To ignore already tracked file you would need to remove it from Git. In case you want to retain the file</p><pre>git rm --cached<br /></pre><h3>Undo last commit</h3><pre>git reset --soft HEAD^<br /></pre><p>Read more about this on <a href="http://stackoverflow.com/questions/927358/undo-last-git-commit" target="_blank">Stackoverflow</a></p><p><strong><em>This entry is a note to self for being amnesiac</em></strong></p></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-79427481153219515162011-11-28T17:18:00.001+05:302011-11-28T17:20:42.987+05:30Disqus(ted)Great added Disqus to blog. Looks like I lost all old comments (of whatever few I had).Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0Rest House Rd, Bengaluru, Karnataka, India12.972964760843968 77.606306076049812.969096260843969 77.6013705760498 12.976833260843968 77.6112415760498tag:blogger.com,1999:blog-32509975.post-52478349688991226402011-07-08T15:59:00.000+05:302012-10-31T02:48:51.758+05:30Sinatra: memcached as session store<p>A simple route for using memcached as session store. Assuming that Memcache server is running already.</p><pre class="brush: java">require 'rubygems'<br />require 'sinatra'<br /><br />use Rack::Session::Memcache, :memcache_server => 'localhost:11211', :expire_after => 3600, :namespace => "sinatra.chandankumar.com"<br /><br />get "/" do<br /> "value = " << session[:value].inspect<br /> # Actual code to do something useful<br />end<br /><br /># Route to set session variable<br /># for example to set session key :value invoke URL /set?value=ActualValue<br />get "/set" do<br /> session[:value] = params[:value].inspect<br /> # Code to do something<br />end<br /></pre><p>This would enable you to spawn multiple instances of (same) Sinatra app while sharing session store to achieve non sticky session. Helps scaling the front end.</p><p>To install Memcache service one could use <a href="http://www.couchbase.com/download">Couchbase</a>. Couchbase server is memcache compatible and it is comes with a nice admin interface to manage instances. More info about couchbase <a href="http://www.couchbase.com/couchbase-server/overview">http://www.couchbase.com/couchbase-server/overview</a></p><p><script src="http://crux-framework-tools.googlecode.com/svn/trunk/misc/highlight/highlightLoader.js"></script></p>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-5559048144874980282011-06-21T02:47:00.001+05:302011-06-21T02:47:42.939+05:30Using git stash<p>A very useful feature in git is git stash, a write up on it <a href="http://ariejan.net/2008/04/23/git-using-the-stash/">GIT: Using the stash</a></p>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-85499608812319706532011-06-20T18:34:00.001+05:302011-06-20T18:34:36.479+05:30Install ruby using RVM<p>This is note to self, for installing ruby 1.8.7 using RVM. Other versions can be installed in same way "mostly". Just replace the version 1.8.7 with version intended</p><p>Verbose documentation about RVM installtion can be found at <a href="https://rvm.beginrescueend.com/rvm/install/">https://rvm.beginrescueend.com/rvm/install/</a></p><pre>bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)<br />echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >><br /></pre><p>add above line in ~/.bashrc file in the end</p><pre>rvm package install zlib<br />rvm package install openssl<br />rvm install 1.8.7--with-openssl-dir=$HOME/.rvm/usr<br />rvm use 1.8.7 --default<br /></pre><p>zlib and openssl is required in many cases.</p>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-79031124823612331292011-06-01T14:17:00.000+05:302011-06-08T15:49:18.520+05:30Sinatra Ajax File Upload<p>Valums script at <span style="font-family: Helvetica, Arial, sans-serif; white-space: normal;"><a href="http://valums.com/ajax-upload/">http://valums.com/ajax-upload/</a> works like a charm in sinatra route you would require something like</span></p><pre class="brush: ruby"> get :upload do<br /> render "/test/upload", :layout => false<br /> end<br /> post :upload do<br /> logger.debug params<br /> newf = File.open("public/post.jpg", "wb")<br /> newf.write(request.body.read)<br /> '{success:true}'<br /> end</pre>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-8879315501424950032010-12-30T11:37:00.000+05:302013-02-04T19:34:23.902+05:30Ubuntu Cheat Sheet<p><strong>Create symbolic link (Sym Link)</strong><br /> To create a symbolic link in Unix or Linux, at the shell prompt, enter the following command:</p><pre>ln -s {target-filename} {symbolic-filename}<br /></pre><pre>ln -s {target-dir}/ {symbolic-ref}<br /></pre><p><strong>Check Open Ports</strong><br /> netstat -an | grep "LISTEN "<br /> and<br /> nmap -sS 127.0.0.1<br /> <strong>Extract tar.gz</strong></p><pre>tar -C /myfolder -zxvf yourfile.tar<br /></pre><p><em>Search for a file</em></p><pre><code>find path/to/search -name FILE_NAME<br /></code><br /></pre><p>Example</p><pre><code>find / -name FILE_NAME<br /></code><br /></pre><h3>Rsync</h3><pre>rsync -r -v -e ssh jerry@openbsd.nixcraft.in:~/webroot.txt /tmp<br /></pre><p><a href="http://www.cyberciti.biz/tips/linux-use-rsync-transfer-mirror-files-directories.html">Examples</a></p><blockquote><p>This entry is a note to self for being amnesiac</p></blockquote>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-28270964598103874392010-10-07T15:30:00.000+05:302010-10-10T16:57:00.451+05:30Tools that rule<p>Here goes a list of application that makes my computer life simpler (applications for Windows mostly, some of them are cross platform someway or the other).</p><ul><li><a title="Google Chrome World's best browser" href="http://google.com/chrome" target="_blank">Chrome</a>:- Browser without any fuss, its fast (in fact lightning fast). Alas Firefox is no more my favorite.</li><li><a title="Forget your start menu" href="http://www.launchy.net/" target="_blank">Launchy</a>: When you have laucnhy you forget your start menu. You would never need to use mouse to start any application installed on your computer. This nifty stuff indexes start menu to make your life easier.</li><li><a title="Little source code editor" href="http://notepad-plus-plus.org/" target="_blank">Notepad++</a>: I ditched textpad for this. This is a must have application when you are dealing with text file to source code that you want to edit quickly. (FOSS)</li><li><a title="Replacement for shareware archive manager" href="http://www.7-zip.org" target="_blank">7-zip</a>: winzip is a malware, if you want something not annoying, 7zip simply does the job. It can handle a lot of different type of archive files. (FOSS)</li><li><a title="File sync" href="http://www.getdropbox.com/" target="_blank">Dropbox</a>: Dropbox allows you to sync your files online and across your computers automatically.</li><li><a title="Instant Messenger for multiple protocols" href="http://www.pidgin.im/" target="_blank">Pidgin</a>: Once you have Pidgin, you dont need to download several messengers. Connect to AIM, MSN, Yahoo, and more chat networks all at once. (FOSS)</li><li>Windows Media player: On windows Windows Media player simply does the job, plays music, plays movies. Just install codec appropriately and you would never need to use any other player.</li><li><a href="http://www.documentfoundation.org/" target="_blank">Libre Office</a> (Previously open office). Almost a drop in replacement for Microsoft Office. This stuff is undermined, yet hell powerful and yet completely free, if you are looking for something that works and works free of cost Libre Office is here for you. (FOSS)</li><li><a title="Email" href="http://gmail.com" target="_blank">Gmail</a>: Simply the best Email one can have. Period.</li><li><a href="../../google.com/calendar" target="_blank">Google Calendar</a>: For managing your calendar. There are a lot of stuff that you can do with Google Calendar, reminders on SMS, Email, Birthday reminders etc.</li><li><a href="../../google.com/contacts" target="_blank">Google Contacts</a>: I use to hate Google Contacts, but hey Google is evolving, this is my "the" contact manager! It's dead simple and its easy to use and sync up with several devices and apps.</li><li><a href="../../google.com/history" target="_blank">Google History</a>: In case you surf a truck load of websites and you are lazy in bookmarking Google History can remember what you visited.</li><li><a href="http://www.google.com/reader" target="_blank">Google Reader</a>: RSS reader, the best so far for me. Note that this can work offline as well with Google Gear.</li><li><a href="../../simplenoteapp.com" target="_blank">Simplenotes</a> / Evernote: This is by far the best "text" note taking platform. It functions cross platform, for that matter I got this working on my Android Phone as well :). In the past I used Evernote, unfortunately I find it painfully slow. The advantage of evernote is that it can clip websites and I hence your notes can have photos. If you are looking for fancy note taking application evernote is the way to go. </li><li><a href="http://picasa.google.com/" target="_blank">Picasa</a>: Photo manager free of cost. If fancy editing capabilities is not a requirement this stuff is simply awesome. It's lightweight has several cool basic features and its fast.</li></ul><p>This list is not yet over, but I was a bit eager to post it. I hope to continue to update this as and when I come across something more.</p>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com2tag:blogger.com,1999:blog-32509975.post-36761273137891887632010-08-24T17:29:00.001+05:302010-09-02T19:07:47.800+05:30Web Application Development for newbies<p>I have been working on web application development, primarily on Java platform. Indeed it provides a very concrete platform for web application development, but it probably is not the fastest in terms of learning curve involved. It's not that Java does not have enough weapons in its arsenal, the problem is that it has way too many. Fortunately I had the opportunity to work on Ruby on Rails and I was really impressed. I am not a RoR convert, but I certainly like the ease of development in RoR. If someone wants to begin with web application development with least fuss involved, I would suggest RoR. In circumstance where a person is not aware of Java as well as Ruby, I would any day advice to use RoR. It's faster to learn RoR and is well documented. Take a look at <a href="http://guides.rubyonrails.org/">http://guides.rubyonrails.org/</a>. There would always be contentions and someone might say that PHP is easier and faster to learn, I have don't have space in this post to argue that. </p><p>To say Hello World in RoR you need to understand a bit of Ruby and a bit of RoR. To say Hello World in Java(web app) you need to Java and then come out of commotion. I say commotion because you would be flooded with advices. Should you use JSP, or spit it out via servlets so on and so forth. When Database based application has to be worked out, contention within Java grows rapidly. This contention is not between RoR and Java as platform. This contention is within Java, contention amongst plethora of frameworks. A newbie is lost in ocean of frameworks and arguments. Fortunately RoR yet has not reached that level.</p><p>Both Java and Ruby support object oriented programming, theoretically, they have a lot of similarities as far as OO is concerned. Syntactically there are lot of differences, if someone has worked on Java, he would find Ruby syntax a bit weird and vice versa. The most important difference is that Ruby is dynamically typed programming language while Java is statically typed. Coding web app in RoR is very terse, a simple Data retrieval in a Java web app would require a lot of Java code and Glue. There are few web applications framework stack in Java which are inching close to RoR, yet I understand that it's going to be a while before they really get there.</p>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-4892660098332110602009-12-24T20:22:00.001+05:302009-12-24T20:22:05.677+05:30Google App Engine Spring MVC 3 – Part 1<p>I have ported a Java application to act as content management system on Google App Engine. You could check out working copy at <a href="http://simplesite.chandankumar.com">http://simplesite.chandankumar.com</a> </p> <p>I needed this for quite sometime now, updating static HTML pages for personal site is a long gone approach. <a href="http://code.google.com/appengine/docs/whatisgoogleappengine.html" target="_blank">Google App Engine</a> let’s you explore your web application development to next level, all for free of cost!</p> <p>You would need an <a href="http://appspot.google.com" target="_blank">appspot</a> account, understanding about how appengine works, fair understanding Java, Spring and Spring MVC. To learn about appengine you can check out <a title="http://code.google.com/appengine/docs/java/gettingstarted/" href="http://code.google.com/appengine/docs/java/gettingstarted/">http://code.google.com/appengine/docs/java/gettingstarted/</a> further to learn about Spring 3.x you can follow up <a title="http://static.springsource.org/spring/docs/3.0.0.RC3/spring-framework-reference/html/index.html" href="http://static.springsource.org/spring/docs/3.0.0.RC3/spring-framework-reference/html/index.html">http://static.springsource.org/spring/docs/3.0.0.RC3/spring-framework-reference/html/index.html</a>. I also referred to <a title="http://blog.blueshiftlab.com/2009/06/spring-3-in-appengine-guestbook-demo.html" href="http://blog.blueshiftlab.com/2009/06/spring-3-in-appengine-guestbook-demo.html">http://blog.blueshiftlab.com/2009/06/spring-3-in-appengine-guestbook-demo.html</a> to build this simple application.</p> <p>Feel free to browse the source code at <a href="http://code.google.com/p/gaesimplesite">http://code.google.com/p/gaesimplesite</a> please make comments or suggestions to improve it.</p> Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com4tag:blogger.com,1999:blog-32509975.post-59046383436119068032009-11-19T15:36:00.001+05:302009-12-29T16:43:14.317+05:30How to get Spring bean factory in Servlets<div xmlns='http://www.w3.org/1999/xhtml'><b>Problem</b> In regular web application which does not use any sort of web application framework(for whatever reason), and you need reference to bean declared in Spring Application Context. <b>Solution</b> Using dependency pull we can get reference to required beans inside Servlet Steps: 1) Declare bean context listener in web.xml<br /><pre class='brush: xml'><br /><context-param><br /> <param-name> </param>contextConfigLocation</param-name><br /> <param-value> </param>/WEB-INF/the-servlet.xml, /WEB-INF/the-service.xml</param-value><br /></context-param><br /><listener><br /> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class><br /></listener><br /></pre><br /><br />2) In servlet init declare <br /><pre class='brush: java'><br />BeanFactory context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());<br /></pre><br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=b1d0e0bd-3da6-89c7-b983-e7c6db25b60e' alt='' class='zemanta-pixie-img'/></div></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-5482319352978146902009-08-28T16:34:00.001+05:302009-08-28T16:36:20.837+05:30connecting mysql in jrubyPre-requisite: jruby, activerecord, jdbcmysql<br /><br />#jruby_mysql.rb<br />require 'rubygems'<br />require 'active_record'<br /><br />ActiveRecord::Base.establish_connection(<br />:adapter=> "jdbcmysql",<br />:host => "localhost",<br />:database=> "students",<br />:username => "root",<br />:password => ""<br />)Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-55201780570985140102009-08-09T21:03:00.001+05:302009-08-09T21:08:03.080+05:30Point and shoot camera review (India)<div xmlns='http://www.w3.org/1999/xhtml'>Searching for "best" camera seems to be a hectic thing. This search had some restrictions as below<br/>1) Sony or Canon only<br/>2) Price close to Rs. 15k or less<br/>3) Available models in India<br/>4) As on August 9, 2009<br/><br/><b>1) Canon PowerShot SX110 IS</b><br/><br/>Official page<br/><a target='_blank' href='http://www.canon.co.in/p/EN/112-Digital-Cameras/190-PowerShot/152-PowerShot-SX110-IS/'>http://www.canon.co.in/p/EN/112-Digital-Cameras/190-PowerShot/152-PowerShot-SX110-IS/</a><br/><br/>Reviews<br/><a target='_blank' href='http://www.dpreview.com/news/0808/08082603canonsx100is.asp'>http://www.dpreview.com/news/0808/08082603canonsx100is.asp</a><br/><a target='_blank' href='http://www.trustedreviews.com/digital-cameras/review/2008/10/03/Canon-PowerShot-SX110-IS/p1'>http://www.trustedreviews.com/digital-cameras/review/2008/10/03/Canon-PowerShot-SX110-IS/p1</a><br/><br/>Flickr photos<br/><a target='_blank' href='http://www.flickr.com/cameras/canon/powershot_sx110_is/'>http://www.flickr.com/cameras/canon/powershot_sx110_is/</a><br/><br/><b>2) Canon IXUS 100 IS</b><br/><br/>Official page<br/><a target='_blank' href='http://www.canon.co.in/p/EN/112-Digital-Cameras/191-IXUS/842-Digital-IXUS-100-IS/'>http://www.canon.co.in/p/EN/112-Digital-Cameras/191-IXUS/842-Digital-IXUS-100-IS/</a><br/><br/>Reviews<br/><a target='_blank' href='http://www.cameralabs.com/reviews/Canon_PowerShot_SD780_IS_IXUS_100_IS/'>http://www.cameralabs.com/reviews/Canon_PowerShot_SD780_IS_IXUS_100_IS/</a><br/>Flickr photos<br/><a target='_blank' href='http://www.flickr.com/cameras/canon/digital_ixus_100_is/'>http://www.flickr.com/cameras/canon/digital_ixus_100_is/</a><br/><br/><b>3) Sony DSC t77</b><br/><br/><a target='_blank' href='http://www.sony.co.in/product/dsc-t77'>http://www.sony.co.in/product/dsc-t77</a><br/><a target='_blank' href='http://www.sonystyle.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=10551&storeId=10151&langId=-1&productId=8198552921665495060'>http://www.sonystyle.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=10551&storeId=10151&langId=-1&productId=8198552921665495060</a><br/><br/>Review<br/><a target='_blank' href='http://www.trustedreviews.com/digital-cameras/review/2008/09/15/Sony-Cyber-shot-DSC-T77/p1'>http://www.trustedreviews.com/digital-cameras/review/2008/09/15/Sony-Cyber-shot-DSC-T77/p1</a><br/><br/>Flickr page<br/><a target='_blank' href='http://www.flickr.com/cameras/sony/dsc-t77/'>http://www.flickr.com/cameras/sony/dsc-t77/</a><br/><br/><font color='#cc0000'>NOTE: I would keep updating this page.</font><br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=3a7756eb-7f88-8016-a5e7-9f11108b2d86' alt='' class='zemanta-pixie-img'/></div></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-42257734350070064212009-04-02T13:28:00.000+05:302009-04-02T13:28:01.318+05:30Unleash the power of your powershot<div xmlns='http://www.w3.org/1999/xhtml'><a href='http://chdk.wikia.com/wiki/CHDK' target='_blank'>CHKDK</a>(Canon Hacker's Development Kit) is a free firmware ADDON that may help you to do more with your Canon point and shoot camera. A quick list of things offered by CHKDK are RAW, Overrirde Camera parameters, bracketing, video overrides, motion detection live histogram, zebra mode, grids and scripting to mention a few.<br/>My opinion on CHKDK would have to wait, one for the reason that I don't own a Canon camera. Two I still have to try this stuff out. Sounds geeky enough to get my hands dirty.<br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=73e33db3-2c36-809e-b571-0a6bb53e0f59' class='zemanta-pixie-img'/></div></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-73952951859909997872009-03-19T18:41:00.003+05:302009-12-29T16:56:44.151+05:30Javascript: Object Oriented Way<div xmlns='http://www.w3.org/1999/xhtml'><span style='font-size: 130%;'>Brief</span><br />Javascript has features that enables you to write JavaScript code in OOP way. In this part I am not getting into details of OOP, understanding of OOP is prerequisite for this article. Javascript has implicit objects, for example arrays in JavaScript, Functions are objects and Objects are objects.<br /><br />For example lets refer to a class called "Boxy". Objects of Boxy are like "div" to which you can add simple text or complex DOM.<br /><span style='font-size: 130%;'>Create a class</span><br /><pre class='brush: js'><br />Boxy = function (/*String*/ id) {<br /> this.id = id;<br />}<br /></pre><br />Above code is structure of function which can be used to create objects, object creation can be done<br /><div class='code'>var boxy = new Boxy("boxy1");</div><br /><br /><big>Public and private</big><br /><br />In above example id field has public access. Something like boxy.id = 1234;<br />Private access specifier is declared using the keyword var within the function. For example<br /><br /><pre class='brush: js'><br />Boxy = function (/*String*/ id) {<br /> this.id = id;<br /> var x =0;<br /> var y=0;<br />}</pre><br />vars and constructor parameters are private members.<br /><big><br /><span style='font-size: 130%;'>Namespacing</span></big><br />This feature is not very popular yet. But if application is going to have loads of JavaScript for User interaction, this feature should be very handy. When multiple people are working on JavaScript, there is a possibility that same function name is used over and over again. This can be avoided to some extend by using namespacing.<br />My personal choice for choosing namespace follows Java way.<br />If you choose to have a namespace like com.xyz.boxy you would declare the name space as<br /><pre class='brush: js'><br />if(!com) var com={};<br />if(!com.xyz) var com.xyz={};<br />if(!com.xyz.boxy) var com.xyz.boxy={};<br /></pre><br />Further you can have a function declared in this namespace as following<br /><pre class='brush: js'><br />com.xyz.boxy = {<br />show: function () {<br /> // do something interesting here<br />}<br />}<br /></pre><br />here com.xyz.boxy wraps a function called show. This function show can be invoked by com.xyz.boxy.show()<br /><br />Pushing things little more lets consider the example below<br /><pre class='brush: js'><br />if(!com) var com={}; // package<br />com = {<br />Boxy: function (name) { // class<br /> this.boxyName = name; // public<br /> var x=0,y=0; // private<br /> this.getState = function() { // method<br /> alert ("X, Y [" + x + "," + y +"]");<br /> }<br /> function generateHash = function () {<br /> // do something about hash<br /> }<br />}<br />}<br /></pre><br />1) Here we have a package called com.<br />2) The package com has Class/function Boxy<br />3) variables name, x and y are private variables<br />4) boxyName is a public variable.<br />5) function generateHash is a private function<br /><br />Writing JavaScript in organized manner has several advantages and ease of readability is the foremost. A good thought over how to organize JavaScript would help in of maintenance of the code and make code more reusable.<br/><br/><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=72ebb47a-6b15-8598-b07f-b048e387a892' alt='' class='zemanta-pixie-img'/></div></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-45411628196030734252009-03-17T18:28:00.002+05:302009-04-02T13:32:26.758+05:30Javascript: Good things to follow<div xmlns="http://www.w3.org/1999/xhtml"><p>List of some of the things that you might want to consider while working with JavaScript. Most of them are not hard to follow. I hope to expand on each one of them.</p><br /><p><b>Keep JavaScript(s) in external file(s).</b> Its easier to find where to debug and its much easier to put break pointers. Another reason to do so is the fact that browsers can cache files and hence faster page load.JavaScript that are inlined in HTML documents get downloaded every time the HTML document is requested. This reduces the number of HTTP requests that are needed, but increases the size of the HTML document.<br /></p><p><b>Avoid Global variables.</b> Every JavaScript file included in the page runs in the same scope. If functions refer to variables in global scope, chances are that they overwrite values and interfere adversely. This can be avoided using name spacing.</p><br /><p><b>Avoid hard coding values.</b> This broadly is tendency to hard code values inside JavaScript function, for example</p><br /><div class="code">colorWarning = function(element) {element.style.color = 'red';}</div><br /><p>If you decide to chose some other sytle for warning you would need to dig into the function. Instead of above try something like this</p><br /><div class="code">colorWarning = function(element) {element.className = 'styleWarning';}</div><br /><p>Where styleWarning is a CSS class.</p><br /><p><b>Avoid creating too much content with JavaScript.</b> While page is being rendered and JavaScript tries to modify the content, you might get error "operation aborted error" (at least found on IE). You might consider using Ajax to load the data after initial page load. Another approach that you can take is to make any DOM modification post page load completion using window.onload</p><br /><div class="code">window.onload = function() {init(); doSomethingElse();}</div><br /><p><b>Define variables with keyword "var".</b> I have found script to act funny on IE when variables are not scoped with the keyword "var". Another problem of not declaring a variable with the keyword "var" is that whoever is reading your code would find it difficult to find where in the code the keyword got initialized.<br /></p><br /><br /><div class="zemanta-pixie"><img src="http://img.zemanta.com/pixy.gif?x-id=32121a21-7fc7-444f-9a8c-5877345ca4b0" class="zemanta-pixie-img" /></div></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-4356972705850848382009-02-25T13:50:00.002+05:302009-03-17T13:53:44.058+05:30Unobtrusive javascript<div xmlns='http://www.w3.org/1999/xhtml'><span style='font-size: 130%;'>What?</span><br />Separate out javascript from HTML document, while retaining intended look and interaction. Traditionally javascript are written inline with the HTML markup, for example<br /><br /><div class='code'><button onclick="alert('I am inline')">click me</button></div><br />Results in a button like like this <button onclick='alert('I am inline')'>click me</button><br /><span style='font-size: 130%;'><br />Why?</span><br />Demand for cross browser compatibility. Remember different browsers have different javascript engine or might not have javascript engine at all. Further a method available in a particular browser (or browser version) might not be available in another. For these reasonstThink of javascript as an option but not a requirement.<br /><br /><span style='font-size: 130%;'>Who?</span><br />The term was coined by Stuart Langridge in 2002<br /><br /><span style='font-size: 130%;'>How?</span><br />Expected behavior from DOM element can be added after HTML page is completely loaded inside the browser. One way of achieving it is by using window.onload method.<br />The code for expected behaviour from the DOM element can be added in the head block of the HTML or towards the end of the HTML document before the body tag closes. The method I chose to stick to is to write javascript in a separate file.<br />In my opinion this approach may lead to a bit of extra effort but this helps you to keep concerned code in one place. If something goes wrong you know where to look for.<br /><span style='font-size: 130%;'><br />And more</span><br />Apart from separating javascript from HTML structure, it is ideal to separate out CSS as well. I prefer to write CSS in a separate CSS files rather than having them in head block.<br /><span style='font-size: 130%;'><br />Find more</span><br />A link leads to another, you can find more information and more information on more information at<br /><a href='http://en.wikipedia.org/wiki/Unobtrusive_JavaScript'>http://en.wikipedia.org/wiki/Unobtrusive_JavaScript</a><br /><br /><div class='zemanta-pixie'><img src='http://img.zemanta.com/pixy.gif?x-id=09105b74-43bf-472f-8189-e087de7d0ae1' class='zemanta-pixie-img'/></div></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-90860988608695308232009-02-01T03:43:00.002+05:302009-02-01T03:52:42.335+05:30I too can click some macros!<div xmlns="http://www.w3.org/1999/xhtml">This was just another lazy afternoon, until "the fly" came by. I chased around for a while before it gave me the close up.<br /><br /><br /><a href="http://www.flickr.com/photos/ck-/3226203522/"><img class="reflect" onload="show_notes_initially();" title="" alt="compound eyes by you." src="http://farm4.static.flickr.com/3086/3226203522_60e77332bd.jpg?v=0" height="374" width="500" /></a><br /></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-28245243939572851212009-02-01T03:17:00.001+05:302009-02-01T03:17:08.132+05:30Terminator<div xmlns='http://www.w3.org/1999/xhtml'>This is one of the best macros that I have seen yet. Found <a href='http://www.dpreview.com/challenges/Entry.aspx?ID=82636&Rows=4&Order=NewFirst'>here</a> and called terminator!<br/><br/><a id='ctl00_body_lnkFullSize' href='http://c.img-dpreview.com/0082636-01.jpg'><img width='337' height='480' border='0' alt='Click here for full size original image' class='entryImgPreview' id='ctl00_body_imgEntry' src='http://c.img-dpreview.com/0082636-03.jpg'/></a><br/></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com1tag:blogger.com,1999:blog-32509975.post-63162379967824341652009-02-01T02:48:00.001+05:302009-02-01T02:51:01.700+05:30Waiting for my Best Friend<div xmlns='http://www.w3.org/1999/xhtml'>The image below is can be found at <a target='_blank' href='http://www.dpreview.com/challenges/Entry.aspx?ID=89569&Rows=25&Order=NewFirst'>http://www.dpreview.com/challenges/Entry.aspx?ID=89569&Rows=25&Order=NewFirst</a><br/><br/><a href='http://c.img-dpreview.com/0089569-01.jpg' id='ctl00_body_lnkFullSize'><img width='480' height='318' border='0' src='http://c.img-dpreview.com/0089569-03.jpg' id='ctl00_body_imgEntry' class='entryImgPreview' alt='Click here for full size original image'/></a></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-68047283811381618202008-07-31T19:01:00.000+05:302009-02-01T01:00:55.831+05:30Connecting to remote maven repository through proxy server<div xmlns='http://www.w3.org/1999/xhtml'>In .m2 folder create a file called settings.xml and add following entry.<br/><br/><settings><br/> <proxies><br/> <proxy><br/> <active>true</active><br/> <protocol>http</protocol><br/> <host>Proxy server's ip here</host><br/> <port>8080</port><br/> <username></username><br/> <password></password><br/> </proxy><br/> </proxies><br/></settings></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-67562595174800835252008-07-01T15:43:00.000+05:302009-02-01T01:00:55.831+05:30Google AJAX API<div xmlns='http://www.w3.org/1999/xhtml'>You can use following toolkits directly on your pages without bothering about where to host them.<br/><ul><li>jQuery</li><li>prototype</li><li>script.aculo.us</li><li>MooTools</li><li>dojo</li></ul><a target='_blank' href='http://code.google.com/apis/ajaxlibs/'>http://code.google.com/apis/ajaxlibs/</a></div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0tag:blogger.com,1999:blog-32509975.post-6615676532052614172008-07-01T14:09:00.000+05:302009-02-01T01:00:55.831+05:30Dojo auto popup dailog box on page load - part 2<div xmlns='http://www.w3.org/1999/xhtml'>Problem: On page load you want to pop up an existing dojo dialog<br />Solution: Use window.location.hash to get the id of the dialog which is being looked up. Unlike the previous post which talks about server side scripting, this would work with pure javascript and should work perfectly for Dojo tabs as well<br />Eg:<br />In head declare following javascript<br /><div class='code'><br /><head><br /><script><br />function autoPopupDailog (dailogId) {<br /> winHashName = window.location.hash.substr(1,window.location.hash.length);<br /> if (winHashName == dailogId) {<br /> if (dijit.byId(dailogId)) {dijit.byId(dailogId).show()};<br /> }<br />}<br />dojo.addOnLoad(function () {autoPopupDailog('dailog1');});<br /></script><br /></head><br /></div><br />Assuming that on the page there is some dialog existing with id 'dailog1, for auto popping up the url would become something like chandankumar.com/test.html#dailog1</div>Anonymoushttp://www.blogger.com/profile/02571610482511772142noreply@blogger.com0