Monday, March 11, 2013

Managing git remote branches

When working with remote repositories with many branches, sometimes git bash responds a bit sluggishly. 

Fortunately there are few steps which can help to overcome problems with huge branches.

Clone with --single-branch

             git clone --single-branch [remote URL] [local folder]

With this git will not try to get references of all remote branches. As such getting all remote references is not an issue as git brings just references. However when checking for branches and inspecting remote, output gets cluttered with lot of references which are hardly of interest. More over with '--single-branch' remote spec is configured for default branch(master) only.  Further 'git remote update' will not try to check all references.
And to get to check all branches on remote repository 'git ls-remote [origin]' can be used. This just gets a view of all remote references rather than populating them.

However this comes with a slight discomfort. To be able to get a another branch, it is required to update refspec manually in config. Say to checkout remote branch b1, that branch should be added in config under remote.

            [remote "origin"]
            url = [remote url]
            fetch = +refs/heads/master:refs/remotes/origin/master
            fetch = +refs/heads/b1:refs/remotes/origin/b1

Then 'git remote udpate' updates b1. And it can be checkout as usual with 'git checkout b1'.

Similarly when remote branches are not of use but can not be removed from host repository they can be deleted locally

            git branch -r -d origin/b1

And pull, push and tracking for b1 goes normally.


Thursday, December 13, 2012

printf instead of echo-e

It is a common need to echo content to files in scripts. But it could turn out a bit tricky to handle escape sequences like new line.

echo is provided as part of binutils but shell can provide its own too. Default handling of escape sequence varies from shell to shell. In case of Ubuntu default shell is dash(debian shell). It handles escape sequences by default. Thus sh -c "echo -e 'foo\nbar'" could end up as "-e foo\nbar" instead of foo followed bar in new line.

But printf is more portable and reliable than echo-e. Something with print is

sh -c 'printf "%b\n%b\n" "for" "bar"'

This yields consistent and more reliable results across mostly used shell variants.

Sunday, November 18, 2012

Windows 8 on Desktop - Review 1

This week end I could upgrade my desktop with Windows 8 released version.
There are mixed feelings about it. Thought of sharing my experience and opinions.

Installation

After it booted from DVD, there is some violet screen without any picture or text for a while. I thought it is hung but that is OK, it is just drive spinning too hard. I installed on an old 2006 desktop with ASUS P5B Deluxe WIFI AP with 2 GB DDR2 RAM. It detected most of the drivers except ATI Radeon video controller and Realtek RTL 8187 WIFI adapter. But after connecting network cable it could download appropriate driver for WIFI. 

It couldn't pickup time from internet. I had to set it manually.

It didn't ask for key during installation. Also it failed to update key from system settings. I had to manually set from command prompt using slui.exe 3.

Otherwise installation is quick and simple. I would say MS engineers did fairly good job here.

Login Screen

When there are more users instead of adding rows, it expects user to scroll right. In this case expecting user to do horizontal scrolling is meaning less. This should be scrolling vertical.

Start screen

This is the view user gets to see after logging in.
Tiles
  • Live tiles are good.
  • Right click options(live off, big/small, uninstall) are handy.
  • Manual arrangement is not so naturally predictive. it needs some used to for users and some improvements from MS
Navigation
  • Left Top thumbs down, so confusing
    Irrespective of what app user is viewing, it shows preview of first app out of those running. It doesn't show preview of desktop apps like cmd (However Alt+Tab works). Only when user moves cursor down from top left it shows all apps. I don't know it is a bug or intended design.
  • Left Bottom OK
    It is a quick way to navigate between start menu and last accessed app.
  • Left Bottom(Right mouse) Good
    It is a quick launch for professional users. But there should be an option to add items to it. And styling of this menu can greatly improve.
  • Right Bottom Placing mouse at right bottom for menu is not so obvious but not so difficult to get used to. It is good that it changes background colour once menu is shown. But there is absolutely no need for date, time and network connection status here. It is so out of context here. Also options inside this menu are so discrete.
    • Search - thumbs up, well done
      It gets context of active app by default though user can change it. List of apps is a bit confusing at first glance but now I am OK with that. Clicking on an app need not launch it as the intention here is to search not to launch it.
    • Share - May be useful for some apps. Kind of nice to have.
    • Start - So confusing. Difficult to get used to.
      When user is working on an app it opens start screen else last app. It doesn't serve context of any app. MS should consider to rework on this.
    • Devices - OK Basically for quick printing etc..
    • Settings - Interleaving app settings and pc settings is confusing. But it can be corrected by providing a more distinctive separation like heading or background colour.
  • Lack of close button thumbs down.
    Lack of close button is a major departure from natural experience of windows
    1. Mouse on left top shows mere last window preview
    2. And sliding down mouse form left top shows banner where all opened apps are listed
    3. Now user got to right click on preview apps to get to close option

Default Metro apps

System comes with decent set of apps.
Here is how they fare
  1. Bing - Not bad
  2. Camera - Not so impressive
  3. Finance - Good enough
  4. Games - OK
  5. Mail, Calendar, People and Messaging - Good
  6. Maps - Pretty good actually They are from Nokia. Far better than Apple maps and catching up towards Google maps.
  7. Music - Below expectation
  8. News - Good enough
  9. Photos - Fails to impress
  10. Reader - Neat and simple
  11. SkyDrive - OK
  12. Sport - Could be made a potential area for app developers if MS intends to do so
  13. Travel - Good one. Social media integration is desirable
  14. Video - Very primitive. Practically useless
  15. Weather - Impressive. Sourced from Weather Decision Technologies

Desktop apps and tasks

Mostly used default desktop apps compared with Win 7
  1. file explorer - Retained most of Win 7 features. Ribbon is OK. Otherwise nothing worth mentioning
  2. Notepad - Nothing changed
  3. cmd - Pathetic. MS can't build a decent terminal. Really a shame on their part.
  4. mspaint - Nothing changed
  5. snipper tool - Nothing changed
  6. compress & extract - Nothing changed
  7. calculator - Nothing changed
  8. task manager - Worthy improvements. It is better and useful
  9. control panel - Retailed most of Win 7 features
  10. Internet Explorer - Disappointing.
    It has two modes. Metro mode and Desktop mode. Metro mode worked for few hours after installation. After that it always opened in desktop mode. I am not going to inner details like HTML5 etc. but as a user I will continue to use chrome as my default browser.
Mostly used system options
  1. Printer/Scanner handling - Nothing changed. Installs if printer is connected during installation.
  2. User management - Nothing worthy changed
  3. Add/Remove programs - Nothing changed
  4. Screen resolution - Nothing changed
  5. Service start/stop - Nothing changed
  6. Device Management - Nothing changed
  7. Disk Management - Nothing changed
  8. Event Viewer - Nothing changed
  9. File system hierarchy - Nothing significant
  10. Turn on/off windows features - Nothing changed

Store

Store is most anticipated and a welcome change in Windows 8. Though there are many rough edges, I get a sense that it started scripting a success story. There are few (9372 as on this writing) apps now, but some of them surely proving a point; that a great deal of vacuum still exists in otherwise chocked app space. Store can fill it with worthy apps and also attract substantial user base considering volume of current desktop users. But it is obvious that desktop can not contribute to progressive revenue growth in coming years. This is a unique challenge for MS. But, fingers crossed, I feel there isn't any magic wand that MS can shake to sustain deceleration of those desktop numbers in coming quarters. However if MS can offer unparalleled web service offerings to those desktop customers, then it can restrict them from drifting away for other tablet options. In my opinion, "Store" got ultimate mandate to achieve this intricate task.

With that background, I looked at Store as an app rather than content(apps) in store. I felt it is way behind expected overall experience.

Store app
  1. Navigation is not so impressive. A single row with long scroll is mediocre. It doesn't sense height of screen and build up visual experience when it is showing all categories. However once can click on a category to get zoom up view of all categories.
  2. It lacks multi/cross dimensional navigation and thus fails to offer experience-based choice.
  3. That minus at right bottom corner is rather absurd.
  4. It isn't very obvious that category header is actually a link.
  5. Apart from 'Top Free' and 'New Releases' I expected 'Top Rated' there. It is however available inside each category.
  6. Navigation through Sub-categories(where available) is not so intuitive with that lengthy combo box.
  7. It is not so obvious that apps can be searched as there isn't any box to type text. Users need to hover mouse at right bottom corner to get main menu and user search option there.
  8. It shows prices in local currency which is commendable.
  9. There is no way to uninstall an app from app store
  10. There is no way to launch an app while viewing at details of app.
  11. It is not so obvious that user need to click on right mouse and select "Your apps" to get to see installed apps. But it is not difficult to get used to this.
  12. There is no to clear uninstalled apps. Thus when user installs an app and feels that it isn't so impressive and uninstalls, it still remains in your apps list. There is no way to clear it. And clear button in Your apps doesn't serve any meaning full purpose except to deselect.
  13. Combo box in Your apps section is buggy. "Apps installed on xxx" shows apps not installed also.
  14. Experience of paying for an app is OK. And user can change a setting to always ask for password when buying an app. I couldn't find any option for redemption.
  15. It is not necessary to add payment information to use free apps.
Store Categories(as on this writing)
Games (1401), Social (198), Entertainment (1219), Photo (228) Music & Video (332), Sport (303), Book & Reference (655), News & Weather (272), Health & Fitness (339), Food & Dining (292), Lifestyle (370), Shopping (57), Travel (373), Finance (98), Productivity (511), Tools (853), Security (65), Business (142), Education (1633), Government (31)

Performance

I wrote all this using "Markpad" markdown app in Store. I spent around 4 hours. And machine crashed and forcibly restarted three times while writing this article with error IRQL_NOT_LESS_OR_EQUAL. That indicates a issue with a driver, I suspect it to be ATI Radeon ATI. Otherwise boot up is pretty fast. I just got basic OS and VS2012. I am yet to have a check on VS2012 on Windows 8.

Sunday, May 27, 2012

Global Keyboard shortcut to launch terminal in Mac OS X

I had to restore my Mac as it screwed up while upgrading to OS X 10.7.4. After restoring from scratch I had to setup few common things like global short cut for terminal.

I followed this http://forums.macrumors.com/showthread.php?t=171464

For quick reference here are the steps.

1. Launch Automator from the Applications folder

2. Choose Service

3. The line that states "Service receives selected" change it to "no input"

4. From the Action side drag to the workflow side "Launch Application"

5. For the pull down in the Launch Application action select the application you would like to launch. For Terminal you will have to go to the bottom and select "Other" and find it in the Utilities folder.

6. Save the Service giving it a unique name like Launch Terminal

7. Goto Keyboard Shortcuts tab within the Keyboard System Preferences

8. Select Services from the left pane and scroll down to General in the right pane. You should see your Service.

9. It's not so obvious, but double click to right side of your Services row. This allows you to enter a key combination for the shortcut. 

10. Enter a key combination and close System Preferences.

 

*Note*    

1. As this shortcut is for all applications. Atleast one application should be running for keyboard shortcut to take effect. May be Finder. So if you just login, the short cut may not work straightaway. Start atleast one app then you are ready to go.

2. Also if custome profile is created for terminal, make sure to make it startup (First Tab)

Wednesday, December 28, 2011

adopting sass with Sinatra

I have been working on an embedded web application with Sinatra. I took enough care to keep css files clean and compact. But it is getting tougher with ever growing style sheets to be vigilant at all times. I heard about sass and less but never felt I would need such tools to handle styles. Today I could learn basics of Saas.
And now I regret for not adopting to such good frameworks from the beginning.

Though less offers dynamic stylesheets, 32kb javascript is too much of a burden for my embedded application.
As such I run a rake script to minify and compress markup and javascripts. I thought sass would be a better choice. I could simply run script to convert scss files to css.

But it would not be so much so convenient during development to convert these scss files every now and then to css. But thanks to Rack and Sinatra it was really easy to integrate sass with existing app.  Here goes sinatra file.


require 'sinatra'
require 'sass'

get '/stylesheets/:name.css' do
  content_type 'text/css', :charset => 'utf-8'
  filename = "#{params[:name]}"
  render :scss, filename.to_sym, :layout => false, :views => './public/stylesheets'
end

get '/' do
  erb :index
end


 Normally we don't need to write a get routine for resources in public folder. But in this case sass looks at "views" folder for scss files. Also during development it would be better if we could test actual css. Thus converting these scss files to css makes more sense. Now I can keep styles in more modular way using nice features of saas. Following two underscore files makes them modular as saas wont generate css for them
when they are imported.

_s1.scss

#fullname {
  p:first-child {
    color : grey;
  }

  p:last-child {
    color : lightgrey;
  }
}

_s2.scss

#communication {
  p:first-child {
    color : red;
  }

  p:last-child {
    color : lightgrey;
  }
}

also theme.scss can be made with functions and using mixins

theme.scss
@function  contact_padding($n) {
  @return ($n * 3) + px;
}


@mixin contact($bw, $bc) {
  padding:contact_padding($bw);
  border: $bw+px solid $bc;
  font-size:20px;
  font-weight:bold;
}

Now all these are imported to common.scss as

common.scss
@import "s1", "s2", "theme";

.theme1 {
  @include contact(2,orange);
}

Now when common.css is linked in html, sinatra does all hard work of importing and converting  before rendering css files.


<!DOCTYPE HTML>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="stylesheets/common.css" />    
  </head>
  <body>
    <div class="theme1">
      <div id="fullname">
        <p>Sriharsha</p>
        <p>Vardhan</p>
      </div>
      <div id="communication">
        <p>Email: mail@mydomain.net</p>
        <p>Mobile: +91 0101 010 101</p>
      </div>
    </div>
  </body>
</html>
Hope this makes it easy to get started.

Monday, December 26, 2011

HTML5 arrows

I am trying to create bar graphs with html5. As part of that I needed forward and backward arrows.

I tried to get arrows marked out of html and css3. Here is the result http://jsfiddle.net/harsha/2aq7R/1/embedded/result


Just started with arrow head. This wont show up anything as border is transparent is all sides.

      .arrow_head {
        width0pxborder-width20pxborder-stylesolid;  
        border-colortransparent transparent transparent transparent;
      }

Now to get top arrow effect let us show up bottom border.
      .top_arrow {
        border-bottom-color#E9E9E9;
      }


Similarly to get down arrow let us open up top border
      .down_arrow {
        border-top-color#E9E9E9;
      }



to get right arrow let us open up left border
      .right_arrow {
        border-left-color#E9E9E9;
      }

to get left arrow let us open up right border
      .left_arrow {
        border-right-color#E9E9E9;
      }


Now arrow body is pure border with fixed height and width. so to get right arrow


      <div style="float:right">
        <div style="width:20px; height:20px; background:#E9E9E9; float:left; margin-top:10px">div>
        <div class="arrow_head right_arrow" style="float:left">div>
      div>



Similarly all sides can be offset as shown below


HTML>
<html>
  <body>
    <div style="background:gray; width:300px; padding: 10px; height:40px">

      <div style="float:left">
        <div class="arrow_head left_arrow">div>
        <div style="width:20px; height:20px; background:#E9E9E9; margin-left:40px; margin-top:-30px">div>
      div>

      <div style="float:right">
        <div style="width:20px; height:20px; background:#E9E9E9; float:left; margin-top:10px">div>
        <div class="arrow_head right_arrow" style="float:left">div>
      div>

    div>

    <br />
    <div style="background:gray; width:300px; padding: 10px; height:40px">

      <div style="float:left; margin-top:-20px">
        <div class="arrow_head top_arrow">div>
        <div style="width:20px; height:20px; background:#E9E9E9;  margin-left:10px">div>
      div>

      <div style="float:right">
        <div style="width:20px; height:20px; background:#E9E9E9; margin-left:10px">div>
        <div class="arrow_head down_arrow">div>
      div>

    div>


  body>
html>





And here is the css


      .arrow_head {
        width0pxborder-width20pxborder-stylesolid;  
        border-colortransparent transparent transparent transparent;
      }
      .top_arrow {
        border-bottom-color#E9E9E9;
      }
      .down_arrow {
        border-top-color#E9E9E9;
      }
      .right_arrow {
        border-left-color#E9E9E9;
      }
      .left_arrow {
        border-right-color#E9E9E9;
      }