Showing posts with label General. Show all posts
Showing posts with label General. Show all posts

Friday, February 26, 2010

Git - check your config

If you are working with various projects; say work project and a sideline fun project or a open-source project for that matter. It's important that you get author name or author email id right when you commit.

You don't want your marty@localhost or xxx1337.AT.yahoo.COM to be showing in as author id in the corporate repository. Some opensource projects reject the commits if it is not from the registered email id.

You normally would have updated the git global config to a username/email id and forgot about it. So the tips is that

1) Set the global config to a name/id to the primary purpose you use that machine to, like home machine set to your personal id. office machine set to your office id.

git config --global user.name "My name is..."
git config --global user.email my_email@domain.com


2) Use git local config on sensitive projects to override global config settings. The easiest way to override to config is to run
git config user.name "My name for this project is..." on your local project folder.

You can edit the whole config file in vi/command line editor easily by using the command
git config --global -e
git config -e (to edit local config)


Finally use git config -l on the project folder to see merged config information that will be used when you commit.

N.B.
Install bash completion for git if you are not using it already.
http://justamemo.com/2009/02/09/bash-completion-along-with-svn-and-git-tab-completion/

Friday, December 25, 2009

It's time to git

Every now and then a new technology comes, but few gather momentum and finally get adapted by masses. Git is certainly on the right track. GitHub certainly fueled the adaptation of git to masses.

Git is mainly effective/faster when used at command line. There are efforts in building UI around it like Eclipse plugin, but they aren't completely done. I am more comfortable at terminal, so haven't checked the UI progress lately.

With agile practices like pair programming, combined with distributed development - people want a distributed source control system that is snappier and comes with tools.

Couple of interesting things I liked from git are:

Git-Daemon: git-daemon utility bundled with the git release is a quick way to share your code across the network. Say you are at a barcamp or a cofee talk meet with a friend. he can share his local git repository over the network just by running

git-daemon --base-path=parent_path_to_the_repo

And you could clone his repository to your local by

git clone git://server-location/repo

Git-SVN: Those who are using SVN as production repository for your source code could still use git locally. git-svn helps you to sync the current workspace code into SVN directly. This is another reason for people to start using git locally, to get all the benefits of it; and still check into SVN as corporate needs you to.

Git-Stash: Git stash could be said as a coding context, say you have modified couple of files to fix bug 121 - you could create a context that store the files that were changed. Then it reverts the code to the HEAD (clean) state, so you could attack bug 75 and commit it before merging back the code for bug 121. These contexts are easy to create and so convenient in labeling them correctly.

The Dilemma:

For those still saying - 'yeah, git is cool. but with the whole distributed thing - isn't there a chance that I loose control of the code my developers do for me? How do I track them?'

Checking the code into the repository often is a practice of discipline, it could happen with use of any repository. With git you could ask your new developer to share his local git repository so you could give an overview, rather waiting until he gets access to the central repository & checks in his crap. In fact git gives the ability to pull code/feedback earlier, than until something gets checked in.

Getting developer access to central repository is a longer process normally in any corporate, instead of waiting for that time the developer can start coding, and as a lead you could keep track on progress.

Those who are looking for patterns to control the repository effectively look at this presentation: http://www.slideshare.net/err/git-machine starting from slide no.72 the author have pointed out several patterns (Anarchy, Blessed, Lieutenant, & Centralized) to manage the repository.

With all said, its time everyone should consider a distributed source control system - because it enables developers, and with a pattern you chose to control your repository its a win-win.

More Links:
  • How Git Index/Staging Area simplifies commit - http://plasmasturm.org/log/gitidxpraise/


  • A Git Branching Model - http://nvie.com/archives/323
  • Thursday, March 20, 2008

    # tricks in url

    We all may know that # symbol in html is especially used with anchors. They mark the particular anchor within the single html page.
    For example in the seam doc reference (single html page) http://docs.jboss.com/seam/2.1.0.A1/reference/en/html_single/#d0e336

    in the url the #d0e336 marks the section 'Understanding the code' within the whole html page. If you do a view source you could see that section of the page is marked with anchor href to #d0e336

    URI combined with this #mark points to the particular section of the page, this helps people to bookmark page, and return exactly there when they come back.

    Lets get into some more interesting stuff with the # sign. Whenever you request a page with #mark in the end; the browser sends GET request only with url up to the #mark. The part that comes after the # sign is never sent to server.
    If you request for http://mypage.com/page#profile, the browser sends the request as 'http://mypage.com/page' ripping off the # sign and the text after that. Once the browser loads the page, it tries to locate the anchor with matching href '#profile' () and positions the page. If the browser cannot find the specified anchor href it just ignores it and shows the page as it is.

    Given that the text after the #mark concerns only for the client and also that browser ignores it for taking any action if the particular anchor is missing in the markup. There are some potential uses for the # sign.

    • fancy url

    • could be potentially used to maintain client-side state!

    • generate unique bookmark-able url


    fancy url:
    http://mail.google.com/mail/#inbox
    http://mail.google.com/mail/#sent

    As you see the server url is just http://mail.google.com/mail/, but the browser displaying #inbox denotes that you are in inbox view.

    maintain client-state:

    Say there are 2 tabs in a page, the user wants to bookmark the page along with the current tab that he is working with. Thereby whenever he loads the page with the saved bookmark; the page should be loaded with the same tab highlighted of the group.

    You could add an identifier with the # sign on the url, and use client side javascript to parse the location and pick the identifier to determine which tab should be highlighted.

    Some javascript libraries use this as trick to generate part of the page in the browser. The iUI library which generates iphone style webpages actually uses the same trick. It maintains client state by this identifier, and uses javascript to re-render part of the page in iphone style mock up.

    http://m.linkedin.com/#_home

    unique bookmark-able url:

    Say you use greasemonkey to customize a webpage. And you set up that custom script to run for a particular url/site. Now you want to test a new script with the same url, you could add some identifier along the pound sign to create a unique url. Map the script to be triggered for this new unique url, so the same site will be handled by different greasemonkey scripts based on the url you load.

    reference:
    http://gbiv.com/protocols/uri/rfc/rfc3986.html#fragment

    Thursday, February 14, 2008

    Understanding JBoss Seam

    We are currently working in a project using JBoss Seam extensively. The interesting and key feature of JBoss Seam is conversations. Conversation combined with bi-jection feature of Seam, just makes state management in web applications slicker and clean.


     


    On the first look you may think that seam just provides one more scope (like REQUEST, SESSION, etc) for state management. But it provides a lot more. If you really want to see how conversations can fix some common issues with web applications (like. back buttoning) I would highly recommend this blog of Jacob Orshalick.


     


    Jacob is also co-authoring the second edition of JBoss Seam: Simplicity and Power Beyond JavaEE with Michael Yuan. The second edition of their book will be released out this year.


     


     Recently preview of some of the chapters of this upcoming book is released. Even if you are already using Seam in your projects, definitely you will find this book more insightful.


     


    So better understand your conversations, before you are timed-out!


     


     

    Tuesday, January 29, 2008

    segregating environment variables

    Whenever you work with different version of a product at a single time, you run into overriding environment variables.

    lets take Java SDK as example, you may have the JAVA_HOME pointed to JDK1.5 for the project you work on production deployment. At the same time you may also need to have JAVA_HOME pointed to JDK6 for your fun projects.

    In windows you could have a batch command file that sets the correct environment variable. You could execute the batch file every time before you run any scripts that refer the JAVA_HOME variable. This is nice.

    To add to it, you can put those .bat file in system path (i.e. c:\windows\system32) so you call that bat file from any directory.

    However when you click this bat file, it executes the batch commands in it and exits. The scope of those new variables set is also exactly till it exits. This isn't of much use since you can't start working on the environment with the desired settings on the click of mouse.

    To accomplish that trick just Right Click and create a shortcut in desktop and add following lines in the target location of the shortcut.
    c:/windows/system32/cmd.exe /k c:/setenv.bat

    in this the '/k' argument to the command line application tells it to execute the script and wait for further commands.

    So by this you can click the shortcut to get a console opened and ready to accept commands.

    You could also change buffer settings and screen settings for the console, so you get desired command console as you want.

    N.B. even though windows shell is not that useful you can make it so if you add something like this.
    UNIX Utilities 

    but still UNIX rocks!

    Sunday, January 20, 2008

    listening on 0.0.0.0

    After you start your Tomacat/Apache HTTPD Server:

    just go to the command line and use netstat -an command to check the network statistics. You might have noticed
    foobar:~ nrs$ netstat -an | grep LISTEN
    tcp46 0 0 *.8080 *.* LISTEN
    tcp4 0 0 192.168.2.101.3873 *.* LISTEN

    that the listening port is listed as either *.8080 or 0.0.0.0:8080.

    Basically this means that your server is listening for connection from all the network interfaces in your machine. i.e. if you have Wi-Fi, ethernet or couple of other VirtualMachine ethernet port configured. Then you can reach the server using any of those interfaces (IP address).

    You could reach the server using 127.0.0.1 (local host), and any IP address of one of the network interfaces you have. So even when you write socket programming code, use the server host address as 0.0.0.0 if you want that your server to be reachable through all the interfaces.

    You could also use the same feature to gain precise control of how your application can be reached. When you start the server in production or other critical environments it just be better that the server listens only in single IP address that is the expected interface for reaching the service.

    In JBoss application server you can control this attribute either in the configuration file, or through system property jboss.bind.address. This property can also have multiple values separated by comma (i.e. jboss.bind.address=127.0.0.0,232.213.232.12). This helps to control precisely through which interface your service were accessible.
    C:\jboss-home\bin>.\run.bat -Djboss.bind.address=0.0.0.0 -c default

    Saturday, January 05, 2008

    Mac OS X automation in ruby

    Mac OS X ships with a tool called Automator, using automator you can create scripts to perform a task. Its kinda macro recording tool. Those who are most used to mac os x, can also write scripts which will perform any task they want. These scripts are called as applescript. Applescript has a friendly syntax so you don't have to be programmer to start with. More information @ Apple Scripting

    But why learn one more syntax, just for the sake of using it. Yes, you can control Mac application from within in ruby. you need to install Ruby OSA - Ruby bridge to apple event manager. This enables us to call any application in mac, and control them. for example: you can Open iTunes and get current playing song and you can set that as you status message in your iChat application.

    Ruby OSA, also comes with documentation tool, which creates a ruby doc, with list of available methods of a mac application. So using it you can right away know the interfaces, and methods to control any application
    rdoc-osa --name <Application-Name>

    ex:
    rdoc-osa --name Adium

    A Sample Script:

    require 'rubygems'
    require 'rbosa'
    require 'httpclient'
    require 'hpricot'


    client = HTTPClient.new
    uri = 'http://www.google.com/search?q=ind+vs+aus'
    resp = client.get uri
    doc = Hpricot.parse(resp.body.content)
    msg = doc.search("//div[@id='3po']//td[2]/[1]/div")
    app = OSA.app('Adium')

    app.adium_controller.my_status_message = msg

    The above ruby  code, retrieves latest cricket score of the match india vs australia, and set it as status message in the Adium (ver 1.1.4), chat application. Incase you are trying with different chat application/ different version of Adium you can always generate ruby docs (rdoc-osa command) and dig further.

    Some tips in getting here:

    1) You need to install XCode from optional installs of the Mac OS X dvd - this to get rid of the ruby gems updade error in Leopard.

    2) get the required ruby library using ruby gems.

    Wednesday, December 05, 2007

    How to get friendly urls

    URLs are face of an website, the urls are indexed by search engines. They are the one links your website. if your urls change, you lose any search ranking advantage you have.

    With the technology behind websites changes often, what happens to the urls?

    The items list page of an shopping site changes like:

    www.shopping.com/shoppinglist.html

    www.shopping.com/shoppinglist.jsp

    www.shopping.com/shoppinglist.php

    www.shopping.com/shoppinglist.jsf

    www.shopping.com/shoppinglist.seam

    Also most urls are not readable, or too long.. with parameters being added to the url. http://shopping.com/list.jsp?itemid=1234

    it would be more readable if it were: http://shopping.com/list/item/1234

    the advantages here is not just readable urls, you are also abstracting our urls from implementation. it protects your technology changes, protects from http get (params in url) or http post implementation..

    Samples:

    http://mail.google.com/mail/#inbox

    http://mail.google.com/mail/#sent

    also you can have permalinks like http://shopping.com/deals/today

    Enough talked on the advantages, let see how we can get that working.

    Apache http server has a module named: mod_rewrite http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html which can transform between urls, by url rewriting. It's basically can match any expression on incoming url, and replace with different pattern. It uses regular expression to find and replace patterns.

    There is a similar implementation in java, which is http://tuckey.org/urlrewrite/

    These modules are efficient, and at the same time complex to learn. So always you could implement your own url rewrite module.

    The web.xml can have servlet mapping with url-pattern=/ which acts as front controller and redirects to appropriate url.

    There are some limitations in this approach.

    to be continued..

    Friday, September 14, 2007

    Feeds and REST-ful URL Schemes

    Feeds are also known as RSS. It was once a extra feature. But now its integral part of content sharing between sites. With improvements to Google Reader interface, its getting easier to read at one place rather scattering around with multiple tabs in browser. Further you can share the favored links as rss feeds. So integrating this content in your blog, or sharing with other friends is easier.

    All this seems as a step towards semantic web.

    While mentioning about feeds, full story feeds is what I prefer, as I don't have to come out of my feed reader to get the full information. Having just the topic in the feed is not worth the feed subscription. As Scoble said FaceBook is becoming an huge aggregator, Google is also catching up will lot of feed integration between their apps. Their own social network site (Orkut) is also catching up with feeds, and other face book like changes. Yahoo has a service named pipes, which helps to create custom feeds out of web-pages.

    as the number of feeds grow, one thing I noticed id REST-Style urls are being used commonly. This might be because, rest-style url supports natural customization to feeds by adding words to the url which is intuitive rather a complex url,

    somesite.com/feed/all

    somesite.com/feed/history

    somesite.com/feed/today

    somsite.com/feed/userName/tag

    All of them use this kinda of url rather complex query parameter style. Check google picasweb feed , del.icio.us feeds, etc

    Though REST style in architecture is not widely adopted, rest-style URL is widely accepted by all and solving part of the problem in web.

    Tuesday, June 12, 2007

    Faking the performance

    Read this article to know, how applications fake their performance report.

    http://blogs.msdn.com/oldnewthing/archive/2005/03/11/394249.aspx

    Applications by adding part of their work to system start-up, terribly slow the start-up time. This is evil. The user loses time, even if he is not gonna use that application. Applications that want to gain such performance benefit should atleast consider using idle CPU cycles to do so, thereby the wait time for user to start with his work would be less.

    The application should have a process, which monitors the cpu usage and triggers the appropriate pre-loader program for its fast start-up functioning. If more applications want to preload their application, then there would be more similar processes that runs just to monitor free cpu cycle.

    If the OS provides an asynchronous loader (which loads the registered components when it finds idle cpu time) it would be easier further. This shifted work from the application to OS will benefit, not as it was in earlier case.

    Monday, March 12, 2007

    Blink!

    Today completed reading the book - Blink by Malcolm Gladwell, which I bought some months back.

    Blink is about "power of thinking without thinking"
    It's a book about rapid cognition, about the kind of thinking that happens in a blink of an eye. When you meet someone for the first time, or walk into a house you are thinking of buying, or read the first few sentences of a book, your mind takes about two seconds to jump to a series of conclusions. Well, "Blink" is a book about those two seconds, because I think those instant conclusions that we reach are really powerful and really important and, occasionally, really good.

    How our brain without much conscious effort, rapidly analyzes the information, and favors some decision. This is the reason, we judge people by their look. Sometimes what we judge is right, and at sometimes is wrong. We are mostly unable to explain why we had a gut feeling like that.
    Believe it or not, it's because I decided, a few years ago, to grow my hair long. If you look at the author photo on my last book, "The Tipping Point," you'll see that it used to be cut very short and conservatively. But, on a whim, I let it grow wild, as it had been when I was teenager. Immediately, in very small but significant ways, my life changed. I started getting speeding tickets all the time--and I had never gotten any before. I started getting pulled out of airport security lines for special attention.

    - Author

    After reading this book, you may have clear view of when to use this blink positively.

    Tipping Point - is a previous book by the author. That's too a wonderful book about social interactions, and how a news becomes hit or miss. Who makes it hit? How it transcends. Tipping Point is basically the point at which if the influences are with right person, it will become hit, if it were under the other it goes to the other end.

    Both the books are full of real and much happened social situations, and analysis of reasons behind them. That makes reading this book interesting, like: What made crime-rate increase or decrease? How graffiti on the trains influences mugging? The theory of broken window. How the not most obvious things play a greater role in the result?

    Finally, before finishing this note, I just remember how I started reading the books of this author. It's started from the forward of this article - The Art of Failure (Why some people choke and others panic), from a friend.

    Thursday, February 22, 2007

    Net Neutrality

    http://www.google.com/help/netneutrality.html
     Today the Internet is an information highway where anybody – no matter how large or small, how traditional or unconventional – has equal access. But the phone and cable monopolies, who control almost all Internet access, want the power to choose who gets access to high-speed lanes and whose content gets seen first and fastest. They want to build a two-tiered system and block the on-ramps for those who can't pay.

    Eric Schmidt (Google)

    Many industry leaders including Tim Berners Lee, had spoken on this.

     So far only some of the states USA have approved this bill. (Maryland, California, etc.,)

    Monday, December 18, 2006

    transliteration - writing in tamil

    Recently found this link from friends, thought there are some transliteration softwares available, this seems to be simple, and doesn't ask you to switch between, capital or small case while typing to get the right word.

    http://www.quillpad.com/tamil/

    this is a site from tachyon technologies is a excellant tool, for transliteration to many indian languages (tamil, telugu, malayalam, hindi, marathi, kannada).

    it easier than never before..

    It just took me 10 seconds to type this, and I got it right on the first time!!!
    anbum aranum udaithayin ilvalkai
    panbum payanum athu

    அன்பும் அறனும் உடைத்தாயின் இல்வாழ்க்கை
    பண்பும் பயனும் அது

    Saturday, November 11, 2006

    Tuesday, October 03, 2006

    Affordability pricing

    Many times I was wondered, why most foreign books, softwares, etc., were sold at such high prices in India. Many great technical books cost around 50-100$ when they are released in USA. It takes very long time to get those books in India. They can be bought from there Indian counterpart publisher or reseller, but at the same price as sold in US. Whereas in US it’s affordable for them to get a book for 100$, but its bites our hands hard to spend 5000 Rupees to get a newly released book. Instead I would like cheaper edition available in other countries too, at the time of publishing itself.

    Sometimes the cost of softwares, in Indian rupees is even higher that the converted rate from USD. :(

    With increased internet presence, and high cost of original books, and very late publishing of Indian reprint (even takes 3-4 years or never after that) most of us are forced to get a pirated PDF version.

    There should be some measures to make books available at cheaper rates only would avoid the loss by the pirated copies.

    Availability and affordability is the key to success of any product.

    Often working out the spending ability of the targeted audience and pricing them will lead to higher number of purchases, more profit and product visibility.

    Google TechTalks, where are they?

    For the past few months, I was watching the tech talk videos of presentations happening at Google. It’s a great thing for a company to share its privileged video on talks by various scholars of our time around the world. Google has done that.

    Till then, watching them is my favorite past time for me in office.

    But since August 25, 2006 there were no updates in the tech talk section in Google videos.

    I had waited over month now; still there aren’t any signs of new videos... :( It’s quite a loss.

    Hoping to see them back soon...

    ----------------------------------------

    Extensive list of google tech videos...

    http://video.google.com/videosearch?q=Google+engEDU

    http://video.google.com/googleplex.html

    Tuesday, July 04, 2006

    Live CDs - Cool !!

    What are Live CD's?

    From the Wikipedia http://en.wikipedia.org/wiki/Live_CD 
    LiveDistro is a generic term for an operating system distribution that is executed upon boot, without installation on a hard drive.  

    The term "live" derives from the fact that it does not reside on a hard drive. Rather, it is "brought to life" upon boot without having to being physically installed onto a hard drive.

    It is often said LiveDistros are a good way to demo or preview an operating system without having to install it to a hard drive.

    Suppose your Windows crashed. And there is lot of information left in you c: drive, so you want to retrieve them before you re-install Windows. How to do it? All you can do earlier is to remove your harddisk, and connect to your friend's machine, then copy the data.

    But after Live CDs, there is a easy way to do it.

    Wednesday, June 14, 2006

    How Google hires...

    http://googleresearch.blogspot.com/2006/03/hiring-lake-wobegon-strategy.html

    Any small technical startup, blows in terms of number of employees working, as it becomes successful as a market leader. How to keep the intelligent quotient of an company high, still recruiting in hundreds?

    This blog explains the google's strategy to hire people, at the same time keeping the cumulative intelligent quotient of the people in the company as high as possible.

    Monday, June 05, 2006

    Improve ur presentation

    Recently I have seen a presentation which is very clear and effective to the point. It has around 60-100 slides, but maximum 2 or 3 word in a slide. I loved it. When I checked more about these kind of presentations I came to know it is a lessig-style presentation.

    http://lessig.org

    Who is lessig? He is one who fights against copyright in creative works. He created this kind of style presentations.

    Follow this blog http://presentationzen.blogs.com/presentationzen/ to learn yourself how u can impove your professional presentation, for effectiveness.

    A lessig's presentation http://lessig.org/freeculture/free.html

    Also must to watch this presentation: http://www.identity20.com/media/OSCON2005/

    Recommended Blog Posts