Monday, December 23, 2013

BASH scripting GIT branch creation

This creates a develop branch if it doesn't exist already

create_develop_branchifNotExists() {
branch="develop"

if git show-ref --verify --quiet "refs/heads/$branch"; then
#echo >&2 "Branch '$branch' exists."
echo ""
else
#read -p "Do you really want to create branch $branch " ans
#echo $ans
echo "Creating $branch branch"
git branch $branch
git branch -a #show all branches
fi
}


# And the following lines assume you've already checked in all your changes. It will switch to develop branch and merge your changes from master into develop branch and go back to master branch.

create_develop_branchifNotExists
echo "========== MERGING Current branch into develop branch ============="
git checkout develop
git merge master

git checkout master

Thursday, December 12, 2013

AudioBook Resources

I am an avid Podcast listener and found it so refreshing to find http://www.booksshouldbefree.com/ that I am blogging about it so I don't forget it. What I find most useful about it is its use of RSS to allow you to add the ebook to your favorite RSS podcast program. For example,

Moby Dick is available here and here's a screenshot of the many options it gives you to consume it:

Thursday, August 15, 2013

A groupby example in Linq


This is an example of applying a group by on a Name object. I started off grouping by just first name, and decided to add Age and do a group by using multiple fields.

class Name {
 public string FirstName;
 public string LastName;
 public int Age;
}
void Main()
{
 var names = new List{ new Name{ FirstName="Joe", LastName="A", Age=11}, new Name{ FirstName="Joe", LastName="B", Age=11}
  , new Name{ FirstName="Timmy", LastName="Pumpurdink"}, new Name{ FirstName="Timmy", LastName="Doheenee"},  new Name{ FirstName="Timmy", LastName="Doheenee", Age=1}
 };
  
  var grouped = names.GroupBy (n => new {n.FirstName, n.Age}).Select (n => new {Key=n.Key, Count=n.Count(), LastNames=string.Join(", ", n.AsEnumerable().OrderBy (x => x.LastName).Select (x => x.LastName).ToList())}).Dump();
  
}

Here's the result:

Friday, August 09, 2013

As I Grew Older


It was a long time ago.
I have almost forgotten my dream.
But it was there then,
In front of me,
Bright like a sun-

read full poem by Langston Hughes here...

Make linqpad show sql print statement in the console by doing this

Throw this baby on the top of your linqpad code and enjoy print goodness.

((System.Data.SqlClient.SqlConnection)this.Connection).InfoMessage += (object obj, SqlInfoMessageEventArgs e)=>{
    if (e.Message.Length < 200)  string.Format("    TSQL PRINT: {0}", e.Message).Dump();

};

Monday, July 29, 2013

Nice C# Helper Class for working with POST or GET web requests

You need the following namespaces:

System
System.Collections.Generic
System.IO
System.Linq
System.Net
System.Text

The code is here, shared as via LinqPad's instant share feature.

Saturday, July 20, 2013

Nice task management tool

I've been using Google Tasks for a long time but needed something better and am glad I stumbled across Trello. I wanted to use a kanban board style list and collaborate with other people.  Thanks Trello for a great product.

Monday, May 13, 2013

Examine sp_who2 with LinqPad

This script gets for you just the list of blockers and the list of blockees separately

Prerequisite: Make sure you check Include System Views and SPs in the SQL connection dialog.


var v= sys.sp_who2().Tables[0].AsEnumerable();//.Dump("SP_WHO2");

var blockers = v
 .Where(x=>x.Field("BlkBy") != "  .")
 .Select (x => x.Field("BlkBy")).Distinct();//.Dump("Blockers");  
  
var blockerDetails = v
 .Where (x =>blockers.Contains(x.Field("SPID")) ).Dump("Blockers");
 
var blockees = v.Where(x=> x.Field("BlkBy") != "  .").Dump("Blockees");