avatar

pbrisbin dot com

Dzen

Apr 29, 2012
Here’s for a small change of pace… I’d like to talk about a tool I’ve all but forgotten I’m even using (and that’s a compliment to its stability and unobtrusiveness). dzen is a great little application from the folks at suckless. It’s one of those do one thing and do it well types of tools. It’s probably not useful at all for anyone with a bloated –ahem, excuse me– featureful desktop environment or window manager (or both).

Git Submodule Config

Apr 27, 2012
Git submodules are pretty great. They allow you to have nested git repositories so that modular parts of your app can exist as separate repos but be worked with as one file tree. Another benefit is that when submodules are pushed to github they appear simply as links to the repos they represent. If your not familiar, go ahead and google then come back – how submodules work overall is not the point of this post.

Beware Never Expectations

Apr 8, 2012
Mocha expectations are incredibly useful for ruby unit testing. You can stub out all kinds of functionality you depend on, specify exactly what values those dependencies return, and validate that the object under test behaves exactly as you want it to, right down to the methods it does or doesn’t call. Unfortunately, I’ve bumped up against one glaring case where this can get you into trouble. To make matters worse, the symptom of this situation is that your tests just always pass.

Anonymous Classes In Ruby

Mar 24, 2012
Often times, I find myself wanting something anonymous. This occurs quite frequently in code when you need to define, pass or call some functionality which is usually very short and only useful in this moment. Many languages provide anonymous functions (usually called lambdas) for this sort of thing: haskell has \x y -> x + y and ruby has lambda {|x,y| x + y}, Proc.new and the new ->(x,y) syntax which I’m actually not very fond of.

Dont Do That

Mar 24, 2012
I use Arch linux for a number of reasons. Mainly, it’s transparent and doesn’t hold your hand. You’re given simple, powerful tools and along with that comes the ability to shoot yourself in the foot. This extends to the community where we can and should help those newer than ourselves to manage this responsibility intelligently, but without holding their hand or taking any of that power away through obfuscation. The Problem 🔗There’s always been the potential for a particular command to break your system:

Escalate Your Scripts

Mar 24, 2012
Anyone who knows me knows I love the shell. I got my “start” in bash and still have a plethora of scripts lying around doing all sorts of useful and fun things for me. Recently, however, I tackled a task that I had attempted many times in shell script always to be met with frustration. How did I finally figure it out? I made it a rake task and did it in ruby.

Maybe Is Just Awesome

Mar 6, 2012
In Haskell, functions must always return the same consistent type. There is also no concept of nil or null built into the language. This is not meant to handicap you, and the expressiveness and polymorphic-ness of Haskell’s types mean it certainly does not. One way to handle such situations where functions (conceptually) may or may not return a value is through the Maybe type. data Maybe a = Just a | Nothing Maybe is a perfect and simple solution for this situation. It says that, for all values of type a, we can construct values that are either Just that or Nothing.

The Github Effect

Feb 24, 2012
Recently I’ve come across a stretch of similarly themed articles. Articles discussing the increasing shift of all business to be tech-based. The conclusion for business owners is often the same: hire talented developers. I don’t disagree. Every business that expects to have any staying power whatsoever needs some level of development. If not for their core product itself, surely for some sort of web and/or smart-phone presence. And for the former, the level of developer talent required to stay afloat can be tremendous.

Table links

Feb 9, 2012
Often you might want to present a table of items, each of which links to its own page. Typically you might add an additional cell with a link to go to the item-specific page. Wouldn’t it be better if the entire row was itself clickable? Well, I did the googling, and here’s one easy way I’ve found to accomplish that. You’ll need a little jQuery: $(function() { $('tbody.link tr').click(function() { window.location = $(this).find('a').attr('href'); }).hover(function() { $(this).toggleClass('pointer'); }); }); Of course, you can choose to put this only on pages that need it, but it’s not very heavy and if it’s on your site-wide template, you can quickly apply this method to any table you want by just adding a class to the tbody tag (all of your tables do have thead and tbody tags, right?)

Live Search (part 2)

Jan 30, 2012
In my last post I went over setting up sphinx full-text search using an xml data source from a yesod application as well as hooking into sphinx to return search results for a given query as a JSON data feed. In this (shorter) post, I’ll go over the front-end javascript that I used to implement a fairly simple search-as-you-type interface. Object oriented 🔗Now, I could have easily defined some simple functions in the global namespace to execute the search, display the results, then attach an event handler to the changes to the input box, but I’d rather not.