Undo git reset –hard

To remove some unhappy commits I executed a git reset –hard. Unfortunately the hangover of missing some files was shortly after. I’ve read this post about undoing it. And it worked.

This listed a lot of files and commits.

git fsck --cache --unreachable $(git for-each-ref --format="%(objectname)")

I tried a few and was lucky to find what I needed in the top 4 commits.

git show COMMIT HASH

Recovered my files with cherry picking.

git cherry-pick COMMIT HASH

Posted in Tooling | Tagged | Leave a comment

TDD for JavaScript

My TDD workshop is a demo with Visual Studio 2012, Team Foundation Express and C#. The concept of Test Driven Development goes beyond the tooling or language. Here is a toolset to do TDD for JavaScript.

The Yahoo library (YUI) can be used to write unit tests for JavaScript. This is best explained with an example. In the code below I create a TestCase containing 3 unit tests. Every unit test is a function. Inside the function/unit test I can do asserts like on every other unit test framework. Complete working project at end of this post.

// setup of YUI with modules
YUI().use("console-filters", "console", "test", function (Y) {
    // TestCase with 3 unit tests
    var ericTestCase = new Y.Test.Case({
        name: "String.prototype.eric Tests",

        // this is a unit test
        "test eric function should exist":
        function () {
            // assertions like in any other framework
            Y.Assert.areEqual("function", typeof "".eric);
        },

        "test eric should replace leading white-space":
        function () {
            Y.Assert.areEqual("erica string", "    a string".eric());
        },

        "test eric should replace trailing white-space":
        function () {
            Y.Assert.areEqual("a stringeric", "a string    ".eric());
        }
    });

    // create the console
    (new Y.Console()).render('#log');

    // run the tests
    Y.Test.Runner.add(ericTestCase);
    Y.Test.Runner.run();
});

These unit tests will run when added to a script block inside a page. The output is rendered in a div and looks like the screenshot below.

yui.console

To run the unit tests in an automated manner there is Yeti. You’ll need node.js for that. After the installation of node.js run the npm i -g yeti command to install yeti. Now lets run the example from above that is added to index.html. You can do this with yeti index.html and than start any browser at localhost:9000, then press enter in the node.js console. Look at the magic 😉

yeti.console

Now you can Red – Green – Refactor on JavaScript.

References

Posted in Test | Tagged , , , , , , | Leave a comment

Renew certificate

In my post Resolve certificate error for Synology Diskstation part 3 of 4 I created a SSL certificate for my NAS. Today I received an e-mail notifying me about the expiration of that certificate. Following my original post I created a new certificate. Uploaded it to the NAS and now I’m good for another year.

certificate valid until 2015
I know what I’ll be doing about this time in 2015.

Posted in Security | Tagged , , , | 1 Comment

Week roundup

Last week recap an links:

Image courtesy of kanate / FreeDigitalPhotos.net

Image courtesy of kanate / FreeDigitalPhotos.net

What are your best reads this week? Leave them in the comments below.

Posted in Uncategorized | Tagged , , , , | Leave a comment

I’m Eric Tummers, Technical Consultant at Valid, and this is how I work

me and big chick
Eric Tummers likes challenges and sharing the solutions with others. His work is focused on the Microsoft .NET framework. He writes unit tests when he develops. Not all developers he has worked with share this necessity for unit tests and he has made it his task to convince them otherwise.
For 2014 Eric hopes to participate in a big Windows Azure project. That would give him enough to write about on his blog. We’ll see what comes his way.

Location: Sittard, NL

Current Gig: Technical Consultant, Valid

Word that best describes how you work: unittesting.

Current mobile device: iPhone 5

Current computer: HP Probook 6570b

What apps/software/tools can’t you live without? Why?

As a Microsoft developer I can’t work without Visual Studio. Recently we started using http://visualstudio.com for our projects, before we used on-premise Team Foundation Server. I like that SAAS (Software as a service) takes the sting out of staying up-to-date.

The entire family of Evernote (clipper, clearly, iPhone app) Since last november I’m a premium user to keep me from running out of upload allowance. I log interesting articles, emails I need to hold on to and scan most of the paper that comes in.

iSmoothrun is my preferred activity tracking app. My recent half marathon is a result of the history of captured data. Just logs everything I want and syncs with other online services like runkeeper.

What’s your workspace setup like?

Work setup

Work setup

Docking station with external monitor, keyboard and mouse. Powers my laptop (I don’t even carry my adapter in the bag anymore)

As a consultant I’m mostly on the go and this is a flex desk, so no papers laying around.

Good coffee is a must.

Home setup

Home setup

At home I have a wireless keyboard / mouse setup. The laptop is tilted and raised for better viewing. This is where my power adapter lives.

More clutter here, but I don’t mind.

What’s your best time-saving shortcut/life hack?

Avoid traffic by starting early. Also gives you a good hour of silent working before everybody gets in screaming about the horrible commute.

What’s your favorite to-do list manager?

Actually I use different to-do lists for my tasks. I use Trello for daily taskboard and for projects. Wunderlist for recurring tasks/chores like clean the sink or check the fire alarm. For longer running tasks, or tasks with content/documents The Secret Weapon in Evernote.

Besides your phone and computer, what gadget can’t you live without and why?

My Apple TV2 (jailbroken) hooked up to my NAS for movies and series. Also hooked to my stereo for music streaming. Awesome device!

What everyday thing are you better at than everyone else? What’s your secret?

Unit testing. Is that an everyday thing? Yes. The advantage of unit testing is the work it saves in the end. But you’ll have to put in the extra work in the beginning. With my experience from other projects I think “How can I unit test this” every time I program something. Reviewing code from others gives me great ideas how to do things better.

What do you listen to while you work?

When everything is working out like planned, silence is the working sound I prefer. But when the sh*t hits the fan: I’m a drum-and-bass fan. My latest powersong is also my ringtone: Run riot by Camo & Krooked.
run riot on soundcloud

What’s your sleep routine like?

My alarm clock is set to 7 AM when I’m working from home, to beat traffic it is set to 6 AM. When I wake before that my day is great. Also in the weekends I tend to get up as soon as I awake and it’s light outside.

Fill in the blank: I’d love to see _________ answer these same questions.

Have to go with Scott Hanselman. He’s the guy that gets 27 hours out of a day.

What’s the best advice you’ve ever received?

someecards.com - Make a shit first draft you cannot edit a blank page
I believe this is a variant on a Hemingway quote.

Original idea from Lifehacker.com.

Posted in Uncategorized | Tagged , , , , , , , , , | Leave a comment