NOTE: More coming soon! I will gradually tag articles. 🙂

js

Testing location change in JS

Every now and then I come across a scenario where I need to unit-test some code that navigates across pages by directly changing location. Some time ago I have accidentally stumbled upon a solution: the location.assign() function.

Expressive JS: askToConfirm

The other day at my day job I needed to change some buttons to ask for confirmation before executing the actual action.

Wheel re-inventing: executeInParallel

At my day job we often need to write low-level JS code without any framework or library handy, and we often end up re-inventing some of the wheels. executeInParallel is one of those wheels:

The indexOf problem

I have recently read this article “Don’t Make Me Remember Things” where the author complains about string’s indexOf method having less-than-ideal API. Specifically, about the case when the sought substring is not found: indexOf usually returns a nonsense value like null or -1, and the developer has to remember that, which leads to bugs.

FP-style conditional callbacks

The other day I was putting together a little UI to collect emails: an input and a button. So I wanted the email to be take in when the user clicks the button:

JS promise recursion

The other day I wanted to get some data from an API. The API is giving the information paginated, so I have to fetch it page by page.

OOP and FP nicely mixed in JS

OOP wants together behavior and data that change together. FP wants behavior and data separate so that the behavior can be used with more than one kind of data. JS makes the two collaborate well “for a greater good.”

My new old JS module system

A few months ago I’ve switched one of my side projects from CommonJS modules to plain JS namespaces, and in this post I’ll explain why.

My JS enum type

For my PersonSection widget I needed to have a PERSON_TYPES constant.

Why I like function hoisting in JS

There is this phenomenon in JS called “function hoisting.” It’s regarded as odd to newcomers but I found it improving code readability and use it every day.

FP vs. OOP: input

I often think about how Functional Programming (FP) compares to Object Oriented Programming (OOP).

Oiling promise chains

When working with asynchronous procedures in Node, I find promise chains help me write pretty readable linear-looking code:

Promises as before filters

The Firebase JS library is callback-based, which feels pretty cumbersome after I got used to promises. So, the other day I wanted to have a FirebaseClient object that given a Firebase URL and credentials would give me a simple way to read and write data to it, something like this:

Timing promises

I have a deeply nested loop of promises that query a remote API, and I had them logging their time by default, like this:

Timing out JS promises

When wrapping an API client I found myself wanting to set a timeout for promise-based methods. I first used setTimeout to reject the deferred promise after a given amount of time, like this:

Fake chain pattern

I have recently read “Smalltalk Best Practice Patterns” and since the idea of pattern is fresh in my mind, I want to share a function naming trick that I use many times.

Testing promise-based JS code

One tricky thing about testing promises is that they handle errors thrown by their .then() callbacks. So I have a test like this:

On Testable JavaScript

After I watched and shared Mark Trostler’s presentation “Testable JavaScript” three times, at intervals of about a year. And for me, the experience was like reading one of those books that you find out more each time you re-read it.

My 3 “Why Angular”s

In a previous post I said that I recently went to a JS meet up, and I was left with the impression that the presentations would have been more useful if they were more narrowly focused: maybe take a specific problem and explain how a particular framework helps in solving it. Then I thought, what exactly do I mean by that? So here is what.

Back to Top ↑

writing

One tip on writing: be concrete

Every now and then, I set out to write an article about some Grand IdeaÂŽ that just came to me. It usually happens when I read something dramatic rant on something.

How did I get unstuck this weekend

For the past few weeks I got a bit stuck with one of my side project’s UI. I have had some vision of how that particular form should look like — which sections there were and how they were positioned, looked quite nice and it worked well so far — but now I’ve got to a point where I needed something else to fit in, and it won’t let me. And there I was stuck.

My intentful writing

I have recently shared a link to the one of the recent episodes of “Late Nights with Trav and Los” podcast: “Why You Should Be A Publisher.” I’m mentioning this because I find writing is a very interesting subject in how it affects how I understand things, and how I see and understand myself.

My awkward writing

My articles here so far are more awkward than not, and I was a bit confused about why would that be. I was wondering about that because, if I look at my emails, I generally consider them as coherent and well put together, I even take some kind of pride in that.Then how come my articles are not that good? I think I have an answer and it’s in a way similar to my theory about why public speaking is generally considered hard.When I write an email, I generally have a clear subject, and a known audience—a specific person—and I write about a specific aspect about the subject. And I believe these two knowns is what makes it relatively easy to write a clear and coherent message.On the other hand, in case of blogging this is not the case. Although I may know the subject, I don’t know the audience at all, and whether they are interested or not in the specific aspect of the subject that I’m trying to talk about.I think this is what makes it hard: if I don’t know you’re interested to hear about X, I will be reticent speaking about it, and I will probably fall sideways into other things that I guess may be more interesting to you.So my theory is that this is what makes blogging—or public speaking—hard, and from here I think it’ll be easier to find a way out. Yay!

One reason to write

As I mentioned in my previous article, I just finished reading the book “On Writing Well” by William Zinsser. I want to clarify a bit why am I so excited about the subject of writing.

On the book “On writing well”

I just finished reading “On Writing Well” by William Zinsser. I enjoyed most of it. I’ve skipped the chapter on sports writing because sports is not a subject I find particularly interesting (but I’m reading it now). I feel a bit disoriented now: I’ve read a lot of good advice from a such master, and I can’t say that I know the precise next steps to improve my writing. I think I should have took notes.

On Writing Well

This morning I got to the “Business Writing: Writing in Your Job” chapter in the “On Writing Well” book by William Zinsser. I found many things I wanted to write down and share, but instead of retelling it I thought I will just quote a good chunk of it and let you enjoy the original. It’s pretty long for a blog article, but it’s an easy and pleasant reading. I’ll start with the second paragraph since I think it goes straight to the point. Here it goes.

On blogging

One thing that I found interesting in the “Apprenticeship Patterns” book is the emphasis it puts on blogging. It’s not that this surprised me, I have heard about this many times, and I think I understand its benefits, but one notable thing is that it gives ideas on what to write about, and one good reason: to use it as a tool towards a better understanding for yourself.

Back to Top ↑

vim

Vim tip of the day: C-a and C-x

They say that in Ruby if you think “I’m wondering if there is a function that does X” then it probably exists. More and more I find that is true about Vim too.

Vim macro of the week

The other day I was putting together an ad-hock eslint configuration where I had just one JS file for a prototype page. I was inside a git repo and I didn’t want to have additional files, so I kind of resisted the idea to have a .eslintrc file, but I can have a Makefile — I have that in my ~/.gitignore, so I can easily add one here and have all the messy bits hidden inside it:

Input for vim abbrevs

I got into React.js lately, and one thing that I have noticed right away is the boilerplate that I have to type for every component. For example, if I have a Button component, I have to type this:

My practical Vim

Last night I have finished re-reading Drew Neil’s “Practical Vim” and I gathered a whole lot of little things that I want to try, and include in my workflow if they fit.

Back to Top ↑

dev

My today’s view on code

This morning I have finished watching a course on Frontend Masters. It’s called “Hardcore Functional Programming in JavaScript.” Functional programming (FP) is interesting to me. It’s partly because I hear people speaking very passionately about it. It’s like an exotic thing that I don’t completely understand, but I’m curious to find out what it is.

Simple .env

I’ve seen .env being used in Heroku projects, and also in a RubyTapas episode about Dotenv gem, and I kind of liked it. But I’m reticent to add more libraries or tools to my toolset, especially if they’re language specific like Dotenv.

Keeping secrets in a node app

For some time I was looking for a way to safely store my app secrets like API keys. Environment variables are OK, they work, but I found it cumbersome. I had a Heroku project where this worked with a .env file that looked like this:

Back to Top ↑

make

My make

About a year ago I wanted to jshint only files that have changed since the last run, and with Grunt I had to write custom code to do that. I used to be able to find my way through Makefiles in FreeBSD ports when I was a kid, so decided to try make.

Back to Top ↑

unit-testing

Testing location change in JS

Every now and then I come across a scenario where I need to unit-test some code that navigates across pages by directly changing location. Some time ago I have accidentally stumbled upon a solution: the location.assign() function.

Why I code test-after now

On my front-end side-projects I mostly did test-first development and it worked pretty well. But for my new job that I began recently I found myself struggling really hard to do TDD, and eventually gave up and coded test-after.

Back to Top ↑

unix

Make a bot list from access.log and use it

The other day, after playing a bit with GoAccess I found that the numbers didn’t add up with my in-app tracking, and I decided to take a slice of access.log and eyeball it to see what’s going on. What I found was discouraging: lots an lots of bot and crawler requests. As disappointing as it was, it was still good to find this out and adjust my perception to reality.

moreutils ifne run function

There is this lil program in moreutils called ifne. I use it in shell pipelines, to execute a given command when there is some output. A quick example:

Back to Top ↑

grep

Make a bot list from access.log and use it

The other day, after playing a bit with GoAccess I found that the numbers didn’t add up with my in-app tracking, and I decided to take a slice of access.log and eyeball it to see what’s going on. What I found was discouraging: lots an lots of bot and crawler requests. As disappointing as it was, it was still good to find this out and adjust my perception to reality.

moreutils ifne run function

There is this lil program in moreutils called ifne. I use it in shell pipelines, to execute a given command when there is some output. A quick example:

Back to Top ↑

learning

Project-based learning

Recently I was discussing with a friend that was thinking about developing some programming skills.

My Git trail map

In my last article I said that I have started a little study by following thoughtbot’s trail maps. After Heroku, I’ve picked Git, and today I will write about the things I’ve learned from it.

Back to Top ↑

scripting

Make a bot list from access.log and use it

The other day, after playing a bit with GoAccess I found that the numbers didn’t add up with my in-app tracking, and I decided to take a slice of access.log and eyeball it to see what’s going on. What I found was discouraging: lots an lots of bot and crawler requests. As disappointing as it was, it was still good to find this out and adjust my perception to reality.

moreutils ifne run function

There is this lil program in moreutils called ifne. I use it in shell pipelines, to execute a given command when there is some output. A quick example:

Back to Top ↑

css

The “C” in CSS

One of the first things that I learned about CSS is that it cascades. Cascading is a lot like inheritance in OOP. It’s useful for the same reasons, and, for the same reasons leads to CSS fragility when misused.

Back to Top ↑

development

My own hackathon: day 1/14

I wrote about this app for bailiffs that I started to build and failed. I also wrote that some a couple of weeks ago I went with my partner to a former colleague of his — a bailiff — to interview him and see how he actually works and if there would be any value in building an app for them.

Back to Top ↑

docker

Simple log aggregation for Docker containers

The Why

The Docker composition on one of my side projects has recently got to 6 containers: SMTP-in, SMTP-out, app, subscription, website, and certbot. Since I have deployed a 0.1.0 version to DigitalOcean a couple of weeks ago, I caught myself feeling increasingly anxious about losing logs every time I deployed a new version of the container.

Back to Top ↑

ease-into-it

My simple meditation routine

My current meditation practice is a sort of mindfulness meditation: it’s intended as a way of training attention, focus, and self-awareness.

Back to Top ↑

email

MTA of the week: sSMTP

I fiddled with a couple of servers in the past weeks and one of the things I needed immediately was email. I wanted to allow cron and the webapps to send out emails.

Back to Top ↑

git

My Git trail map

In my last article I said that I have started a little study by following thoughtbot’s trail maps. After Heroku, I’ve picked Git, and today I will write about the things I’ve learned from it.

Back to Top ↑

google apps script

Google Apps Script

For a while, I was collecting the DMARC reports, just in case I can find something useful in them. I didn’t, but I liked the lil script that I wrote in this Apps Script from Google. It’s like VBA for Microsoft Office — if you ever heard of it. If not, it’s automation for Google apps and services.

Back to Top ↑

hackathon

My own hackathon: day 1/14

I wrote about this app for bailiffs that I started to build and failed. I also wrote that some a couple of weeks ago I went with my partner to a former colleague of his — a bailiff — to interview him and see how he actually works and if there would be any value in building an app for them.

Back to Top ↑

jekyll

Jekyll post alias

I’ve launched a new Jekyll website recently, and one thing that I wanted to be able to do on the very first days is to be able to have different URLs for a single post. 🤔

Use-case: I’ve published an article on the blog, but the topic is one that comes up frequently enough that I want to have it on the FAQ page, but also have a simple one- or two-word permalink that I would be able to tell someone on the phone, for example /socializare.

Back to Top ↑

shell-scripting

Back to Top ↑

webapp

My own hackathon: day 1/14

I wrote about this app for bailiffs that I started to build and failed. I also wrote that some a couple of weeks ago I went with my partner to a former colleague of his — a bailiff — to interview him and see how he actually works and if there would be any value in building an app for them.

Back to Top ↑