I have spent almost all my professional career using RSpec to test Ruby code. I have seen some debates comparing it to Minitest, but I have never had a strong opinion either way. Now I am in a Minitest-based project and sometimes I wish there was a bit more documentation on it. But perhaps the reason there is not is because the answer, however the question, tends to be "just use Ruby". Say you…
Last year I took some time to review my Neovim setup. In particular, the integration with LSP servers was mostly a blind copy&paste from articles online, patching together plugins that I didn't really understand. I wanted to know what was what, and why it was there. This is a writeup of what I got out of it, if only so that I can refer to it when I forget again. This article covers setting up LSP…
A quick guide on how to install Calibre in your $HOME directory. A user-local setup with no sudo involved. It can be done by reciting these two incantations: 1 ### Download 2 $ curl https://download.calibre-ebook.com/linux-installer.sh \ 3 > ~/Downloads/calibre_linux_installer.sh 4 5 ### Install 6 $ sh ~/Downloads/calibre_linux_installer.sh \ 7 install_dir=~/Applications/ \ 8 bin_dir=~/.local/bin/…
At a recent project, my colleague Oliver Barnes and I were brought in to help with a very slow web app. Search requests were taking many seconds to complete, causing a bad user experience as well as endangering SLAs with partner clients. These are two specific changes we made to the app that together made a significant improvement to latency and scalability. TL;DR In short: Group together…
I got a question from a mentee recently, and I quote: How do you improve on talking about how efficient a code is? Say I have an idea on how to do something, so I can’t actually test how long it takes or how much memory it takes exactly. Right now the only way I think about it is like how many loops it has to do. But generally I find it quite hard to visualise so did you have any tips on that? I'm…
10 July 2025 : updated final section with answer from RuboCop maintainers. I recently came across this error in a Ruby project: 1 SyntaxError: foo.rb:123: void value expression After some digging and simplifying, I isolated the issue to something like the following: 1 def void_assignment 2 a = 3 begin 4 return 1 5 end 6 end The method includes an assignment, but it is never realised: the code hits…
If you are seeing the error Unable to access CD Drive when trying to play a game on DOSBox, this guide may be able to help you. These caveats apply: I am referring to DOS games as distributed by GOG.com . I do not know whether this can generalise to other game stores. My distro is currently Debian 11 (Bullseye). This is typically a good indicator that it should work on other current distributions,…
HTTP Strict Transport Security, or in short HSTS , is a mechanism that forces web browsers to use secure connections (HTTPS) in order to access websites. It is a good idea and websites should use it. However there are some very niche cases where you do not want it. I manage one of those cases. I run http://referrer-policy.info , a website that allows you to test how your browser implements the…
If you are using VCR and Selenium Webdriver in your project, there are a couple of common errors that you might see. "Cassette" icon by Maxim Kulikov from the Noun Project. The quick fix Before I go into detail, this is the configuration I'm using for VCR on my current Rails project, which fixes the issues described below. Note the comments: 1 require " vcr " 2 3 VCR .configure do |config| 4…
A prime number, twins with 43. The sum of the first 6 primes: 2 + 3 + 5 + 7 + 11 + 13. And also of these: 11 + 13 + 17. Niobium. Mozart's last symphony. Hopefully not my last.
So you made some commits with Git, and then you realised that you were not on the correct branch. Perhaps you made the commits on master , when they were intended for a branch. Or you were on some other unintended branch, it doesn't matter. What to do? This is a common question when you are learning the ropes of Git. I hope this guide can get you out of that problem, while helping you understand…
This week I was trying to get this Docker-based development environment set up for a project, on macOS. However I was getting this error: 1 ERROR: for XYZ Cannot start service XYZ: error while creating mount source path '/Users/pablobm/Documents/foo/bar/baz': mkdir /Users/pablobm/Documents: file exists After trying a few things, it turned out that the problem was with having the project files in…
25 May 2020 : did more research, added more detail, changed my recommendation, and linked to the new test site. What is the Referer header? To understand referrer policies, first you must understand the Referer header. The Referer header is sent by browsers as part of HTTP requests. They are a friendly indicator of which website we came from that we ended up requesting a given URL. So for example:…
Given a test like this one: 1 expect(page).to have_css( " [data-search-results] " ) 2 click_on " Hide results " 3 expect(page).not_to have_css( " [data-search-resutls] " ) # Typo! Something like this may pass in your code… but it is not testing what you think it is testing. There is a typo in the second expectation, so of course it is not going to find [data-search-resutls] , regardless of whether…
During a mentoring session recently, I had a conversation about using mocks in unit tests: when and how they are appropriate, when I feel they enhance tests, and what I don't like about them. Here are my thoughts in writing for future reference. First, I use several mocking-related terms here, and I go by George Meszaros's definitions for those words . Here they are in a snappier form as they…
As part of a larger experiment, I recently played around a bit with CouchDB. Soon I had to run some map/reduce queries and realised that CouchDB handles these in a way that is significantly different from what many developers like me expect. For those of us who have done simple map/reduce work with JavaScript, Ruby, Elixir, Python, etc, the model used by CouchDB can be surprising and confusing.…
Developing with Ember.js, we are used to dealing with the Store service which many of us associate with Ember Data. It was while I was doing some research on how Ember integrates with data layers that I realised that the Store is part of an integration glue that exists in Ember even when Ember Data is not present. Moreover, you can create a light integration with a data layer by simply hooking…
I found myself yak-shaving pretty deeply into a problem today, wondering why Ember was refusing to pluralize the word "beta" as "betas". Ultimately I wound up at the list of pluralization rules for ember-inflector . Among them, I found the culprit: 1 // ... 2 inflect.plural( / (buffal|tomat)o$ / i , ' \1 oes ' ) 3 inflect.plural( / ([ti])um$ / i , ' \1 a ' ) 4 inflect.plural( / ([ti])a$ / i , ' \1…
The other day I saw this on a pull request: 1 start(appointment) <= now && end(appointment) >= now I find this a bit jarring to read and avoid it in my code. Instead I prefer something like the following: 1 start(appointment) <= now <= end(appointment) This predicate, closer to the mathematical predicate, reads better to me. It's easier to see that now needs to be in between two limits. This…
Added the Appendix section on 6 March 2018 . I've been thinking about map and reduce lately. Nothing too erudite though. Something that I have realised is that it's sometimes too easy to conflate the two into just the reduce , when instead it might be clearer to have a very dumb map followed by a very dumb reduce . Here's a simple example: 1 [ ' a ' , ' b ' , ' c ' ] 2 .reduce((acc, k) =>…
11 June 2018 : updated with some errors fixed. I did a terrible job the first time around. NOTE: I use the term "URI" here as I consider it the correct one for the context, despite the API using the term "URL". Maybe I'm just being pedantic, dunno… For info on the difference between URL and URI, check out https://danielmiessler.com/study/url-uri . Coming from Ruby on Rails and other similar…
If you are starting out a new webapp using Express on Node.js, do not use express-session unless you really know what you are doing. Like: really know what you are doing and why. In any other case, use cookie-session . Original image by Robbgodshaw CC BY-SA 3.0 License The paragraph above may sound disparaging, but that's not where I'm going here. There are perfectly good use cases for…
Back in early 2016, I ran into a problem while customising a Debian Live CD that I maintain. I wanted it to include a piece of third-party, proprietary freeware, in a way that didn't break the terms of the license, while keeping the process automated. Ultimately, I found a solution that, while slightly overcomplicated, did the job pretty nicely. I documented it at on an article titled Large files…
There are a few resources online explaining how to reboot a machine using Ansible which didn’t work for me. My task would always time out and I had no idea why. Finally I figured it out. The tasks I was using looked roughly like these: 1 --- 2 - name: Restart machine 3 shell: shutdown -r now "Maintenance restart" 4 async: 0 5 poll: 0 6 7 - name: Wait for server to come back 8 local_action: 9…
I find it funny, how concerts in London tend to run like clockwork. So much so that they rarely stray from this schedule: Time 19:00 Second support starts 19:30 Second support ends 19:45 Main support starts 20:30 Main support ends 21:00 Headliner starts 22:30 Headliner ends Doors normally open at 7, so it's not unusual that you have missed most of the first act by the time you enter the venue.…
I ran into the following error this morning, using the Pass utility: 1 $ pass -c foo/bar 2 gpg: starting migration from earlier GnuPG versions 3 gpg: WARNING: server 'gpg-agent' is older than us (2.0.30 < 2.1.21) 4 gpg: error: GnuPG agent version "2.0.30" is too old. 5 gpg: Please make sure that a recent gpg-agent is running. 6 gpg: (restarting the user session may achieve this.) 7 gpg: migration…
You have a float variable, and you want a quick boolean expression to tell if the value has any decimals. To put it differently, to tell whether a float variable is currently holding an integer value or not. Divide by 1, check if the remainder is 0: 1 number % 1 == 0 # => true for integer, false for rational Which makes perfect sense if you think of it. If you divide 9.5 apples among 5 children,…
Many years ago, I wrote (bad) code that sent a single marketing email, repeatedly, to addresses in a subscribers list. Imagine your inbox filling up with copies of the same email because some idiot got their code wrong. On the bright side, I realised of what I had done quickly enough that most recipients only received 4 copies of the email (I think). At the time, I had 3 years of experience as a…
If you use a VPN, be aware that it may not be filtering inbound ports. Effectively, this opens up your computer to port scanning and attacks on vulnerable network services. In this scenario, it doesn’t matter if you are behind a NAT: the VPN virtually grants you a public IP address reachable by all. A few months ago I had a simple HTTP server open on port 8000 of one of my machines. At some point,…
Updated on 15 October 2017 to support Babel 6. I've been doing some research on how to set up an asset pipeline using Broccoli, which is part of the toolset provided by Ember.js. The official website shows a good example of use, but I wanted to do something a bit more advanced. Here's the result. At the end of this text, we'll have an asset pipeline able to read these inputs: ES6-flavoured…
There are too many JavaScript frameworks out there, and I am not a JavaScript expert. I have neither the time nor the inclination to put all them to the test and come up with rational, experience-based arguments as to which one is superior, be it in general or for a specific task. Similarly, if I look for opinions of experts, I am always going to find articles praising one over the others, in all…
Playing around with GarageBand recently, I had a metal guitar track (a software instrument, not recorded), and I wondered how to make it sound like it was palm muted. There are many tutorials on YouTube on many GarageBand-related topics, but I couldn’t find anything on this. Finally, I stumbled across it mostly by accident, so here it is for anyone who may be having the same problem. In short: use…
For some time, I had noticed some people taking my name and spelling it as “Bablo”. This was more common with, say, couriers than with cafe baristas, probably because the former tend to be from countries where English is a first language, whereas the latter tend to be from Southern European countries. Or at least that’s my perception, in my specific bubble in London. I could be wrong. I would love…
The computers where I install Debian Live are used to access a relatively limited set of websites. The default browser on the builds is Iceweasel, Debian’s rebranding of Firefox which came to be circa 2004-2006 due to esoteric legal reasons. The version number is 38, which is an ESR : a long-term support version scheduled by Mozilla to receive security updates for a extended period of time. Now…
As part of my effort to learn Ember.js, I built a relatively simple app that used the TFL API to fetch bus arrival times at nearby stops. It can also do tube, DLR and overground, and eventually I may include other means of transport. It’s called London Waits . All this was built in Ember 1.13, and only now I decided to upgrade it to Ember 2. It wasn’t trivial, but in the process I gathered some…
TLDR: Ember.js implicitly creates an index child route for you when you nest under a route This appears to be not so well known on the Ember community, and I don’t think it’s documented anywhere. I should have a go at clarifying this on the official docs (through a pull request on the project), but for the moment I’ll dump it here. This is how it works. Say you declare a route in router.js : 1…
On 19 November 2017 I wrote about a better, simpler way of doing this. Check it out at Third party files on a custom Debian Live installer . Following with my work on a custom Debian distribution, there was a third-party package I wanted to include in it. Unfortunately, this was proprietary software, it wasn’t included in Debian non-free, and it was a pretty large download (about 1GB). Debian Live…
Twice in the last three weeks, I have stumped into a relatively recent addition to Ruby’s syntax: a new way to define symbol keys in a Hash literal. Since Ruby 2.2, the following syntax is legal: 1 { "foo": "bar" } The weird thing here is that the above literal doesn’t mean what I thought it meant. This is what I expected it to be equivalent to: 1 { "foo" => "bar" } And this is what it actually is…
I own an inexpensive netbook that I take with me when I travel. Specifically, an MSI Wind U135. It’s been serving me well for almost 5 years, and the other day I decided to upgrade it a bit, by adding some memory. After some online research, it was clear I could only upgrade from the builtin 1GB to a total of 2GB, adding a 1GB memory module. What was not so clear though is what specific model of…
Just yesterday I learned a little something in Ruby that I found interesting. It’s the difference between __method__ and __callee__ . Both are supposed to return the name of the current method, but there’s a subtle difference: __method__ : returns the name of the method as defined __callee__ : returns the name of the method as called I put together an example that illustrates the difference: 1…