productivity

Git-NumberedAdd for PowerShell

30 Aug 2018

After copying file paths from git status output and pasting them after a git add quite a few times by now, I’ve written a small PowerShell script to stage the files by index.


Less for your git pager

18 Aug 2018

A git diff or git log starts the less program. Perhaps not the fanciest tool but more powerful than you might expect.

This post details the arguments that can be passed to less and also how to navigate once less is running. Things not relevant for git are omitted.

Your current configuration:

git config --get core.pager

If this returns nothing, there is room for improvement there!

TL&DR:

Configure something sensible:

# Short version
git config --global core.pager "less -eFiJM~ -j3 --tabs=3"

# Not so short version
git config --global core.pager "less --LONG-PROMPT --tabs=3 --quit-at-eof --quit-if-one-screen --tilde --jump-target=3 --ignore-case --status-column"
h : See all less commands.

Yaml tutorial

13 Aug 2018

Everyone happy when the downfall Xml was a fact with the widespread use of Json. Less tags, more data. What’s there not to like. It’s also just so much easier for a human to read.

If it wasn’t so straightforward to parse JSON in the omnipresent JavaScript, Yaml might have had a good chance to take over the world being the most readable data serialization language.


Autohotkey Tutorial - hotkeys

2 May 2018

First we’ll cover the basic Autohotkey hotkey syntax. Which is arguably already pretty confusing for newcomers in and by itself.

But we don’t stop there as after adding more and more hotkeys, it will also become harder and harder to think of new key combinations that are somehow still memorable. There is only so much you can do with the # (Windows) key etc.

Time for some creative hotkey combinations! ‘Advanced Hotkeys’ covers code snippets on how to run different scripts on single, double or triple key presses as well as how to differentiate between long(ish) key presses or mouse clicks. And more…

Example

; Single line hotkey
^#D::MsgBox Pressed Control + Win + D (%A_ThisHotKey%)

; Control + Win + C: Multi line script
^#C::
Run, notepad.exe
WinWait, Untitled - Notepad, , 3
Send, Dear sir,{enter}{enter}
Return

Advanced Windows Explorer

22 Apr 2017

A listing of handy but less known shortcuts in Windows Explorer and some Autohotkey examples on how to add extra functionality.

Open Windows Exporer, the most direct way:

Win + E : Open Windows Explorer



PowerShell and Git for the colorblind

21 Apr 2017

My PowerShell, Posh-Git and .gitconfig color configuration because of some red-green troubles with the default configurations.


Managing Environment Variables with PowerShell

12 Apr 2017

Working with environment variables in Windows is as easy as:

Win + Pause > "Advanced system settings" > "Environment Variables..."

After which you get a tiny, unresizable, form where you can view and manage them. Something better eventually arrived with Windows 10 but still, PowerShell :)

Use Autohotkey to open the window with Left Alt + Pause:

LAlt & Pause::Run % "rundll32 sysdm.cpl,EditEnvironmentVariables"

PowerShell profiles

11 Apr 2017

Reload PowerShell profile

. $profile

Package Manager Console Entity Framework 6 Migrations profile

10 Apr 2017

This tutorial is about adding the following functionality to the Entity Framework Migrations CLI:

  • Execute commands against the project containing the migrations by providing the most likely -Project parameter value
  • Allow updating the database using a numeric TargetMigration (-2 = migrate to the third last migration)

dotnet

NSubstitute Tutorial

12 Aug 2018

The creators of NSubstitute craved a mocking framework with comparable capabilities to the alternatives but with a shorter, more succinct syntax. They have not failed to do so and I loved the NSubstitute syntax right away.


Excel formulas cheat sheet

28 Mar 2018

Companion to the EPPlus series, specifically to Part 2: Formulas.
Covering the EPPlus syntax and implemented functions.


Create Excels with C# and EPPlus: Miscellaneous

2 May 2017

Miscellaneous features

EPPlus can do a whole lot more for you. This post covers some interesting stuff that didn’t really fit anywhere else.


Create Excels with C# and EPPlus: Import

1 May 2017

IEnumerable objects

Exporting data to an Excel doesn’t get easier than this

using (var package = new ExcelPackage())
{
	var sheet = package.Workbook.Worksheets.Add("IEnumerable");
	var data = new[]
	{
		new {Name = "A", Value = 1},
		new {Name = "B", Value = 2},
		new {Name = "C", Value = 3},
	};
	sheet.Cells["A1"].LoadFromCollection(data);
	sheet.Cells["A1"].SetHeaders("Name", "Value");
	package.SaveAs(new FileInfo(@""));
}

NSubstitute vs Moq

30 Apr 2017

Comparing NSubstitute syntax with Moq, probably the most used mocking framework out there at the moment.


Create Excels with C# and EPPlus: Formulas & DataValidation

27 Apr 2017

In case your users want to continue working with the Excels after generation.

Not a problem for EPPlus. Instead of calculating values and writing them to an excel, leverage the power of Excel formulas.


Create Excels with C# and EPPlus: A tutorial

26 Apr 2017

Quick tutorial about creating xlsx Excels with C# and the EPPlus nuget package.

EPPlus Excel addresses are not zero based: The first column is column 1!

Also, before writing any loops, you might want to check out the LoadFromXXX methods. They are explained in depth in part 3 Import.


.NET Number and Date Formatting

20 Apr 2017

A cheat sheet with everything there is to know about formatting the primitive types, DateTimes and TimeSpans in .NET.


VB.NET vs C# Syntax differences

15 Apr 2017

A cheat sheet outlining the syntax differences between VB.NET and C#. This post is written specifically for advanced C# developers with little to no VB.NET knowledge who need to do some VB.NET coding.

Because some things are just so similar but still confusingly different in VB.NET vs C#…

Along the way we’ll make some amazing discoveries like:

  • There are things VB.NET just can’t do (pointers, …)
  • There are a few cases where VB.NET code is shorter than it’s C# counterpart (gasp!)
  • VB.NET defaults are not what you might expect from a strongly typed language due to its VB6 legacy (Option Strict, Explicit)
  • There is some VB.NET only stuff that comes in handy from time to time

javascript

JavaScript Testing: Jasmine plugins

6 Aug 2017

What would we be without some extra plugins. There are over 1000 Jasmine npm packages and we’ll cover them all here.


JavaScript Testing: Jasmine customization

5 Aug 2017

Make your Jasmine experience even more luscious with custom matchers and global convenience methods.
Mock global variables in your modules with jasmine.getGlobal().pi = 3.14.


JavaScript Testing: Jasmine async syntax

31 May 2017

Need to test async code? No problem for Jasmine. There is done() to inform Jasmine a test has finished running.

With jasmine.clock(), the value of new Date() can be manipulated.

Finally instructions on how to configure Babel for async/await in tests.


JavaScript Testing: Jasmine Spies

30 May 2017

Spies, the Jasmine implementation for mocks featuring spyOn and the new spyOnProperty aswell as jasmine.createSpy(Obj) and how to inspect calls made.


JavaScript Testing: Jasmine syntax

30 May 2017

The basic example contains the general test suite structure and the two most used matchers toBe() (===) and toEqual() (deep compare), followed by all the other matchers that come out of the box.

To finish some helpers for your workflow: how to only have certain tests run and how to exclude tests.


JavaScript Testing: Getting started with Jasmine

29 May 2017

Probably the most widely used JavaScript testing framework.

This tutorial covers installation, configuration and execution only. For the Jasmine syntax, see parts 2 to 4!