Be a (unit-testing) minimalist

An article, posted about one month ago filed in , , , & .
Be a (unit-testing) minimalist

Still (2013) a great talk by Sandy Metz on testing, and how to do it right, without getting too theoretical. While this talk is on ruby, and it uses a Rails framework for testing, it really is applicable to any other language (only the syntax will probably be a wee bit shittier ;))

Watch Rails Conf 2013 The Magic Tricks of Testing by Sandi Metz on YouTube

(and while unit-testing is between brackets, in general, being a minimalist when writing code really is a good idea)

Continue reading...

JavaScript & Rails: a `webpacker` evaluation

An article, posted 9 months ago filed in , , , , , , , & .

Webpacker is still opt-in for new Rails projects. But this might change. The JavaScript ecosystem is moving fast and new JavaScript frameworks are pushing customer’s expectations to higher levels. To use these frameworks with your Rails app, you had a few options:

  • Include the JavaScript manually; which requires you to manually copy the files in place
  • Use a gem-wrapper to to install the JavaScript library; but this required quite some maintenance on the Gem-author’s side.
  • Try to mangle npm or yarn into the asset pipeline yourself
  • Use Rails Assets (an automagic Gem-wrapper)

A small praise for Rails Assets

I have been using rails-assets.org the past few years to keep my JavaScript dependencies up to date. It thought it was smart solution; instead of requiring individual developers to maintain Gem-wrappers, Gem wrappers are created on the fly by RailsAssets.org. It was smart and light weight on the developers side and worked perfectly with the Rails' Asset p…

Continue reading...

PHP revisited

An article, posted 12 months ago filed in , , , , , , , , & .

I've been able to stay away from PHP-based projects for quite some time. Until recently. I needed a small API. The idea was that the API would be transferred to a relatively old server that had been running stable for years and the client didn't want to risk installing additional script interpreters on it. It might even have been my own suggestion, it would be a really small API, requiring no special changes on an already operational 24x7 managed server. On top of it I'd write a modern style front-end, running entirely in the browser.

Of course the API that was intended to be simple got a bit more complex. I wanted the API to output clean JSON messages, which required some data mangling, as data was stored in CSV's, TSV's, and misused XML-files or only accessible through crappy soapy API's. So what does present-day (well, the Red Hat PHP version I was able to use is still in 5.x-series) PHP look like? TL;DR: sometimes it was definitely ugly, but at I can happily live with the cod…

Continue reading...

Getting started with Rails ActionCable (1/2)

An article, posted about 2 years ago filed in , , , , , , & .

As the lead developer at HeerlijkZoeken.nl I wanted to try the new Rails ActionCable technology for a new feature: shopping lists. The idea is that you can walk in a store or on a market, mark an ingredient as checked when you add it to your (physical) basket and continue shopping. ActionCable can make the experience nicer because it, based on WebSockets, allows for real time notifying other viewers and editors of the same shopping list. No more shouting around in the supermarket: I’ve got the milk! Sure, nothing essential, but I needed an excuse ;)

(Note that we recently migrated from Rails 4, so not everything was in place in our app, just ignore the bits Rails already made for you; everything has been tested with Rails 5.0.0.1)

Getting the basics right

To start: You need a web server that can open multiple threads, so if you’re still using Webrick in development (which can’t rece…

Continue reading...

Rails and elasticsearch for beginners - follow up

An article, posted about 3 years ago filed in , , , , , , , , & .

In a previous post I described how simple integrating elasticsearch is with Rails for beginners. You could've been happy with the fact that you now have implemented full text search, but that too basic set up probably doesn't work that much better than adding a column to your model, throwing in all text in it and running a LIKE query (although elasticsearch does try to rearrange the results a bit).

In this post I will learn you two things that makes elasticsearch worth it.

Analyzers

Analyzers add some fuzziness to your searches. First, make sure your analyzer is in the right language, this will improve your results. You add the following bit to your model (I typically place it just below where the scopes and validation are defined).

settings index: { number_of_shards: 1 } do
  ...

Continue reading...

Rails and elasticsearch for beginners

An article, posted about 3 years ago filed in , , , , , , , , & .

I don't like complexity. Adding new items to your stack increases complexity. But sometimes it is worth it. When you need proper search and filtering, elasticsearch is worth it. Mostly because it isn't hard to set up at all, as you'll learn in this post.

Installing it on a Debian server is easy, simply follow their instructions (you'll add their package-server, and run apt-get install. On OS-X you can install it easily with HomeBrew (brew install elasticsearch), but do make sure you have installed a JDK (e.g. openjdk-8-jre-headless)

If you're not using something like Docker, you probably have to repeat the steps on your dev machine, your staging server and your production environment.

Note: When running on a low memory server, which isn't recommended for production, you should make sure that the configured heap size isn't too high, edit `/et…

Continue reading...

Introducing Workbook, a new rubygem

Sorry non-techies, this is really for (ruby-)techies.

For some time I've been working on a ruby gem that helps me on my project work, and may also help other ruby programmers, to work with table imports and exports more easily. Although there are other gems that allow you to read and write to different formats, of which the roo-gem is probably the most well know, I was particularly interested in writing Excel files based on templates.

I wanted to offer my clients more user-friendly Excel files that used some of the more advanced functionality of modern Spreadsheets (AutoFilter, printer styles) that couldn’t be offered by just manipulating styles and formatting using the existing rubygems. Which got me started to think about creating templates to start from, instead of starting from scratch using one of the Gems. Using another Excel file, however, wasn’t as easy as expected and here is where the Workbook gem comes in: to make that easier. Ad…

Continue reading...

Computer says yes

An article, posted about 6 years ago filed in , , , , , , , , , & .

Al weer 7 jaar geleden liet Robert Dijkgraaf in Zomergasten zien hoe alles weer uit van alles bestaat. Kleine onderdelen die samen weer grotere gehelen vormen die samen weer nog grotere gehelen vormen en zo verder, en terug. Hij illustreerde dit aan de hand van een alweer 30 jaar oud filmpje: powers of 10.

Powers of 10: Van 100 tot 1024 naar 10-14

Op hun eigen schaal lijken alle onderdelen waaruit iets bestaat weer mooie afgeronde dingen. En op een afstand lijken al deze onderdelen ook nog eens perfect samen te hangen.

Integrated Circuit (public domain image)

Ook in ontworpen zaken zie je dergelijke herhaling en samenhang. Een chip lijkt in detail wel een metropool. En de printplaat waarop deze bevestigd zit eveneens. En in een echte metropool bevinden zi…

Continue reading...

Viral software

An article, posted about 7 years ago filed in , , , , , , , , , , , & .

When you are in the business of creating software you'll have to know that not all software and business models allow for what you've probably done before you were making money in this field, basically copy & pasting & reusing software from all over the web. When you're working professionally you might be confronted with the fact that not all open-source libraries are as free, as in libre (or as in anarchy) as you would like them to be.

(btw I'm not a lawyer, but I do understand language and code)

Richard Stallman; License: Creative Commons Attribution-Share Alike Some rights reserved by jeanbaptisteparis

The famous GPL requires you to license your derivative works with the same GPL as well. Not only your modifications to the library you are using need to be open-sourced, but also the code that you wrote using that other project as a library without which your project wouldn't work. …

Continue reading...

Embedded development

An article, posted more than 7 years ago filed in , , , , , , , , , , & .

Hyper agile development, yeah! Nee, ik ga het niet hebben over ontwikkeling voor embedded systems (systemen zoals pinautomaten tot magnetrons). Maar over ontwikkelen midden in een organisatie die werkt. Zoals journalisten in het leger, op die manier embedded. Niet Kennismaking, Ontwerp, Bouw, Testen, en uiteindelijk de Grote Oplevering (waarbij iedere stap een vertaalslag is zonder de bron om op terug te vallen). En zelfs niet het iteratieve ontwikkelen zoals dat in Scrum gangbaar is. Nee, iedere dag te maken krijgen met verzoeken: “Nu wil ik dit graag kunnen.” “Kun je dit voor mij doen.” En dan beslissingen nemen. Dat is embedded development voor mij.

Slow Train Coming - Bob Dylan Albumhoes

Hyper agile. Beetje (erg) hectisch, maar daarom des te leuker. M’n code is van tijd tot tijd een rotzooi, in de loze minuutjes proberen op te schonen. En het moet blijven draaien, want ieder moment kan er een nieuw verzo…

Continue reading...

Hacking versus doing things ‘correctly’

An article, posted about 8 years ago filed in , , , , , , , , & .

Although in mainstream media hacking is considered as something bad, something criminals would do, hacking has really nothing to do with bad things. Hacking in software is about building a bazaar instead of building a cathedral (Raymond, 1999). Hacking is central to the idea of agile programming and the free software movement. While building a cathedral is about planning things properly, the bazaar way is the shacky way of hacking things together. Being able to build something cheaply, quickly. The it-just-works approach. Others counter this notion of hacking it together as something being unstable. In the long run, they argue, hacking will be more expensive. But think about it… how often have you worked on something great, something really complex, something you’ve tried to release perfectly, and a) how often have you succeeded in actually releasing something and b) how much better has it become through this careful process of discussing, planning and crafting - doing it the right …

Continue reading...

My first JSF: Stateless vs. stateful

An article, posted about 10 years ago filed in , , , , , , , & .

I've started working in a company that creates web applications. I discovered a new way of looking at websites, that of websites as an application…."Hello, have you been sleeping? Wasn't 'RIA' (Rich Internet Application) one of the buzzwords (a few years ago)?"Yes yes yes, but only recently I found out that the application view differs quite a lot from the view, my initial view, that websites are in essence only a source of information. In my opinion, information should be bookmarkable (and thus be unaffected by the state of things; stateless). But what about applications running on the web, which are essentially still sites on the world wide web?JSF, a tool I only recently started working with is a tool that is focussed at creating webapplications… and it definitly seems to prefer the stateful approach in creating such web applications (the resulting html pages rely on a session managing the state of things). Originally, I found the output of JSF rather …

Continue reading...

murb blog