logo

Fish and pipestatus

Fish and $pipestatus Note: This morning I answered a Reddit post about $pipestatus, and after learning that there’s not a lot of good information out there, I thought making a blog post might be helpful for other future Fish users wanting to know more about using Fish’s $pipestatus. What’s an exit status? In Fish, like other shells, you can tell whether a command failed via its return value, sometimes called an exit code or an exit status.
6 minutes to read

Better git shell aliases

Better git shell aliases: using an external shell script 10 years ago, I read this blog post on GitHub Flow git aliases by Phil Haack. From it, I learned a few really clever tricks. Even though I never much cared for using ‘GitHub Flow’ as a git workflow, I used some of those tricks for my own git aliases. One of those being this basic pattern: [alias] foo = "!f() { echo "foobar: $@"; }; f" This lovely little mess of an alias embeds a one-line shell function tersely named “f” directly into a git command.
8 minutes to read

Finding common bigrams

Find common bigrams Bigrams are 2-letter combos. When designing a keyboard layout, it’s common to optimize for comfort and speed by analyzing bigrams. Here’s a simple shell script to do a quick-and-dirty bigram analysis. Start with a corpus Download Shai’s corpus for Colemak: cd ~/Downloads curl -fsSLo corpus.txt.xz https://colemak.com/pub/corpus/iweb-corpus-samples-cleaned.txt.xz Extract the .txt file: unxz corpus.txt.xz Split into individual words Separate that corpus into individual words, one per lined, and all lowecase letters:
One minute to read

Using awk to colorize go output

From my StackOverflow answer on the subject of colorizing Golang test run output: I like piping to a simple awk script to colorize output from other shell commands. That way, you can customize with whatever colors/patterns suit you. You want to colorize an output unique to your project? Go for it. Simply save this awk script to ./bin/colorize in your project, chmod u+x ./bin/colorize, and customize to your needs: #!/usr/bin/awk -f # colorize - add color to go test output # usage: # go test .
One minute to read

SQLite UDF in Python

From my StackOverflow answer on the subject of parsing SQLite string dates: Python makes it pretty easy to add a user-defined function to a SQLite query. Let’s demonstrate this by populating a table full of text reprensentations of dates, and then use a simple Python UDF we write here called date_parse to attempt to parse the text date into a real date. First, we need to do some basic setup. Let’s do some standard Python imports firsts.
3 minutes to read

.NET DST Calculator

I have a common .NET library written in C# that I use everywhere. I call it mattmc3.Util, and it contains helper methods (static classes or extension methods) that correspond to Microsoft’s BCL. So, for example, I have a DateTimeHelper with static methods that corresponds to the System.DateTime class. The DateTime class is one of the most anemic in the .NET library, mainly because MS has to deal with international customers, so methods like DateTime GetMemorialDay(int year) are too regional and clutter the BCL, but are essential in the American business world.
3 minutes to read

jQuery to the rescue!

I had a thought today as I was posting - I like to link out from my blog, but it’s really inconvenient for my readers to click on those links and have it open that link over top of the post they’re reading. And I don’t want to have to go back to my previous posts to update the links manually. Blogger should just handle it for me. A quick Google search brought me to these posts , but that isn’t quite what I wanted.
2 minutes to read

Embedded Resources

In the .NET world, ORMs are only just now beginning to see the light of day. Though nHibernate has been around for awhile, it has not seen much uptake from mainstream .NET devs. It may have to do with typical FUD stuff, like its roots in the Java world, its reliance on XML for the mappings, its learning curve, or the lack of books and beginner’s resources. I’m not judging - I’ve read this book and I think nHibernate’s offerings are the most mature and robust available for .
4 minutes to read