Tuesday, September 2, 2014

Internet Explorer 11 debugging gotchas

If you are using Internet Explorer 11 for software development, you will probably encountered the following two gotchas when debugging locally:

Friday, August 29, 2014

Git Cheatsheet

Workflows

Get latest master (origin/master)

  1. Optional: git stash
  2. git checkout master
  3. git fetch
  4. git rebase
  5. git checkout branchname
  6. Optional: git stash pop

Update latest master into current branch

  1. Optional: git stash
  2. git checkout master
  3. git fetch
  4. git rebase
  5. git checkout branchname
  6. git rebase master
  7. Optional: git stash pop

Could also git rebase origin/master instead of git rebase master

Note: When using diff tools during a rebase, remote is branchname, master is local.

Work on new feature branch

  1. Optional: git stash
  2. git checkout master
  3. git fetch
  4. git rebase
  5. git checkout -b branchname

Share new feature branch to origin

  1. Optional: git stash
    • Before upstream is set: git push --set-upstream origin branchname
    • After upstream is set: git push

Push current feature branch after rebase

  1. Optional: git stash
  2. git push -f
  3. Only do this in a feature branch that has not been merged. It is rude to re-write public history.

List files changed in HEAD vs master

  • git --no-pager diff --name-only HEAD $(git merge-base HEAD master)

See local branches

  1. git branch

See remote branches

  1. git branch -r

Find deleted files

  • git log --diff-filter=D --summary

Configuration

Avoid fetching all remote branches

  • git config --local remote.origin.fetch +refs/heads/master:refs/remotes/origin/master

This changes your fetch refspec for the remote named origin. You will have to fetch remote branches with git fetch origin remotebranchname:localbranchname after applying this change.
You can use git ls-remote --heads to see all remote heads. (This includes non-tracked "remote branches")

Make git push easier

  • git config --global push.default simple

Useful aliases

  • git config --global alias.co checkout
  • git config --global alias.st status
  • git config --global alias.br branch
  • git config --global alias.ci commit
  • git config --global alias.last 'log -1 HEAD'
  • git config --global alias.unstage 'reset HEAD --'
  • git config --global alias.ll 'log --oneline --abbrev-commit --all --graph --decorate --color'

Cleanup after merge

  • git config --global mergetool.keeptemporaries false
  • git config --global mergetool.prompt false
  • git config --global mergetool.keepbackup false

I use P4Merge for merging and diffing.

Friday, August 8, 2014

Setup TraceSource logging in a console application

Quick setup for getting tracing an XML file that can be loaded in Microsoft Service Trace Viewer

Create a console application in Visual Studio

Create a TraceSource in your application

namespace TraceDemoApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var traceSource = new TraceSource("TraceDemoApp");

            // TODO: write to the above TraceSource

            Console.ReadLine();
        }
    }
}

Write to said TraceSource

namespace TraceDemoApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var traceSource = new TraceSource("TraceDemoApp");

            traceSource.TraceEvent(TraceEventType.Verbose, 0, "This is a verbose message");
            traceSource.TraceEvent(TraceEventType.Information, 0, "This is an informational message");
            traceSource.TraceEvent(TraceEventType.Warning, 0, "This is a warning message");
            traceSource.TraceEvent(TraceEventType.Error, 0, "This is an error message");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "This is a critical message");

            // Flush the trace source (if autoflush is not enabled) to ensure that data is written
            traceSource.Flush();

            Console.ReadLine();
        }
    }
}

Configure trace source in application configuration file

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <system.diagnostics>
    <sources>
      <!-- Turn on all traces for the TraceDemoApp trace source -->
      <source name="TraceDemoApp" switchValue="All">
        <listeners>
          <add name="console"/>
          <add name="xmlListener"/>
          <!-- Optionally remove the default trace listener -->
          <!--<remove name="Default"/>-->
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <!-- Log traces to XML file that can be opened with Microsoft Service Trace Viewer -->
      <add name="xmlListener"
        type="System.Diagnostics.XmlWriterTraceListener"
        initializeData="C:\Logs\xmlWriterListenerLog.svclog"/>
      <!-- Log traces to console -->
      <add name="console"
           type="System.Diagnostics.ConsoleTraceListener"/>
    </sharedListeners>
  </system.diagnostics>
</configuration>

Run application and examine output in console and Microsoft Service Trace Viewer

Console Output
Microsoft Service Trace Viewer

Troubleshooting

No output

Verify that the trace source has a listener that is not the DefaultTraceListener
Only the DefaultTraceListener is listening to the trace source
The default trace listener uses Win32's OuputDebugString method, which will only log to an attached debugger or DebugView.

Wednesday, December 19, 2012

LED Sign TFS Changeset Ticker

A while back, I built a real-time TFS Changeset Ticker that uses the Dream Cheeky LED sign for output.  It displays each user followed by a spark-line like graph of the number of changesets each individual has created over the past 21 days.

Source is at: https://github.com/rpwjanzen/blinken  under the TfsConsoleApplication project.