Michel P. Macedo

Switching From Zsh to Fish

| Comments

Not long ago I heard of fish (friendly interactive shell) and I decided it was worth a test drive. I have a decent configuration for zsh, with most credits to Oh My Zsh!, but I was determined to get rid of most my dotfiles, as it is one of my greatest excuses to procrastinate, however tidy. Fish comes with lots of things out of the box, so I decided to replace zsh even if it meant to lose a thing or two.

Iterating Collections in JavaScript

| Comments

When I iterate in any language, I like to have a list of somethings to iterate because I can use more idiomatic code and have more explicit initial state, state changes and exit conditions. Most languages have a slightly different for/foreach that iterates over things that are considered enumerable by the language. In JavaScript we have two types of enumerable objects: array-like objects, also known as collections or simply arrays; and objects, also known as object hashes or associative arrays, even though they are just any JavaScript object that is used for that purpose.

Javascript Not Minus One Operator

| Comments

In most languages if you want to check if something is in a array or string, you use functions named indexOf or any variant thereof. The signature and contract don’t usually deviate much, specially in languages with zero-based indexes.

In Javascript, both Array’s and String’s indexOf return minus one (-1) for not found. Minus one isn’t particularly semantic, and checking for it tends to produce the most verbose and technical bits of otherwise cleanly written code.

Formatting Strings in .NET

| Comments

You may want to format some scalar value as a string, since default ToString functionality is possibly not what you want the user to see.¬†You may want to do some occasional tool or toy console app. Not only these but perhaps any other reason may inspire you to code some string art. With C# there is no string interpolation, but there is a string formatting framework with a reasonable power. Let’s see about that.

F# Coding Dojo

| Comments

I am an active member of a .NET user group in the city I live. We have monthly meetings that usually combine a lecture followed by an one hour coding dojo. August this year we had our monthly meeting and I spoke for an hour or so about F# and then challenged the other participants to translate to F# a small problem already codified with C#.

I Spun Off Linux From My Dev Machine

| Comments

Some weeks ago I started to learn Rails and I decided to make my dev machine the right way. By that I mean I had to make myself proficient with Git, Vim, Shell, TDD and every other skill I thought a smart programmer would master. At first I didn’t want to get rid of my state of art Windows 7 installation with awesome Microsoft Word 2010, Microsoft Visual Studio 2010 full of useful plugins and all that browsers installed to test web pages. I think I had everything a .NET developer would hope for, even had msysgit to play once in a while and pretend my OS was POSIX compliant.

Initializing Things in C#

| Comments

The C# team have introduced some nifty syntax sugars since C# 1.0. Among these new features are some to declare anonymous methods and delegates and initializers for objects and collections. They are are there for a while now and still are relatively unknown or misunderstood by the majority of C# programmers.

I will try and clarify them a bit.