NOTE: More coming soon! I will gradually tag articles. šŸ™‚

js

Transactional tests with Mocha.js

This week, while working on the email change scenario on my side project, I realized that my tests are not transactional, which meant that their changes to the DB could persist across test runs and so tests could influence each other. Hmā€¦ I thought I fixed this before.

JS hoisting gotcha

I have written why I like function hoisting in JS, but the other day I got a bite in the back in the context of function hoisting. šŸ˜ø

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 ↑

coding

Angular tip of the week: parametrized templates

On my 30-th week of Angular, I learned something that I was looking for since the first week: a lightweight way to get a ā€œparametrizedā€ piece of view. Coming from a couple of years of React, I was used to having function components to abstract away noisy bits of a view, and for some time I thought the only way to get that is to get such a thing.

Speeding up my TypeScript build

I was cleaning up my NPM modules on my side project. Since almost from the beginning, I have had 2 ā€œchildā€ package.json files, one for the backend and one for the frontend, and the ā€œmainā€ one in the project root.

Transactional tests with Mocha.js

This week, while working on the email change scenario on my side project, I realized that my tests are not transactional, which meant that their changes to the DB could persist across test runs and so tests could influence each other. Hmā€¦ I thought I fixed this before.

Simple indefinite asset caching

In my last post about my side project I have mentioned that I have extracted 2 shared bundles to increase my build speed, and one downside of that is that now have two more requests for every page, and this week I have implemented a small tweak that will compensate to that: indefinite caching.

One reason to prioritize the feature work over tech work

A couple of weeks ago I wrote about the P/PC Balance, and while thinking about it some more, a kind of comic realization stroke me: I realized that one good reason to prioritize feature work above technical work on a project is that the former is finite, while the latter is potentially infinite.

Simpler architecture

On the side-project that Iā€™ve mentioned before, Iā€™m making a priority of 2 things: (1) use the least amount of libraries and frameworks, and (2) organize the code in a way that reflects the logical structure of the app.

JS hoisting gotcha

I have written why I like function hoisting in JS, but the other day I got a bite in the back in the context of function hoisting. šŸ˜ø

Switching from tape to Mocha

I have a side-project where I use tape for testing. A few days ago I stumbled on a test that I thought should fail, but passed.

On testing UIs

I have heard that people resist testing UIs because ā€œthey change oftenā€, and my oppinion is that from the perspective of ā€œtests as safety netā€ UI testing is as valuable as any other kind of testing.

My way to test web UIs

I remember how amazed I was while reading Kent Beckā€™s ā€œTest Driven Development: By Example.ā€ Automated regression tests sounded very useful. But it was not obvious how to apply that in the context of web UIs.

My explanation of DCI

In the episode 21 of ā€œGiant Robotsā€ podcast Jim Gay is invited to talk about the DCI concept. The original document explains it with an example about saving accounts. Jim tries to explain it with an app user. I find both examples somewhat unhelpful, and thinking about this subject a little more, I think I found a better one.

Trail maps

I donā€™t have a CS degree, and most of what I know Iā€™ve learned along the way because I found it interesting or because I needed to solve a problem. It worked pretty well so far, but sometimes I feel like I need a bit of structure around it, usually when Iā€™m trying to make sense of a bigger picture.

Me is back to work

This my first day back to my day-job at Assembla. My plan is to find an hour every day to work on my project.

My own hackathon: day 7/14

Monday. In the morning I have watched the React video course on FrontendMasters, by Ryan Florence. Pretty good. I canā€™t say I found a ton of new things but itā€™s good to get confirmation that what I know are about the right things, and also give the whole thing a bit of structure in my mind. Fundamental things are well explained. There was a nice quick intro to Flux, which clarified by vague view on it.

My own hackathon: day 5/14

Today itā€™s a different day, itā€™s Saturday: until afternoon I dug channels for our drainage system in the back-yard. I did my best to escape out of there around 16:00 and got to the office.

My new notion of web app

One of my side projects that Iā€™ve been toying with, is a productivity app for bailiffs. And since Iā€™m reading ā€œLean Customer Developmentā€ by Cindy Alvarez, a few days ago I went with my partner to interview a bailiff ā€” a former college teammate of his.

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 ↑

tdd

Transactional tests with Mocha.js

This week, while working on the email change scenario on my side project, I realized that my tests are not transactional, which meant that their changes to the DB could persist across test runs and so tests could influence each other. Hmā€¦ I thought I fixed this before.

Switching from tape to Mocha

I have a side-project where I use tape for testing. A few days ago I stumbled on a test that I thought should fail, but passed.

On testing UIs

I have heard that people resist testing UIs because ā€œthey change oftenā€, and my oppinion is that from the perspective of ā€œtests as safety netā€ UI testing is as valuable as any other kind of testing.

My way to test web UIs

I remember how amazed I was while reading Kent Beckā€™s ā€œTest Driven Development: By Example.ā€ Automated regression tests sounded very useful. But it was not obvious how to apply that in the context of web UIs.

Me is back to work

This my first day back to my day-job at Assembla. My plan is to find an hour every day to work on my project.

Back to Top ↑

hackathon

My own hackathon: day 7/14

Monday. In the morning I have watched the React video course on FrontendMasters, by Ryan Florence. Pretty good. I canā€™t say I found a ton of new things but itā€™s good to get confirmation that what I know are about the right things, and also give the whole thing a bit of structure in my mind. Fundamental things are well explained. There was a nice quick intro to Flux, which clarified by vague view on it.

My own hackathon: day 5/14

Today itā€™s a different day, itā€™s Saturday: until afternoon I dug channels for our drainage system in the back-yard. I did my best to escape out of there around 16:00 and got to the office.

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 ↑

productivity

One reason to prioritize the feature work over tech work

A couple of weeks ago I wrote about the P/PC Balance, and while thinking about it some more, a kind of comic realization stroke me: I realized that one good reason to prioritize feature work above technical work on a project is that the former is finite, while the latter is potentially infinite.

My view of motivation

In the last post on Travis Neilsonā€™s mailing list, heā€™s sharing his thoughts about motivation and proposes some solutions.

Two days

This week I had a couple of harsh days.

Back to Top ↑

side-projects

Speeding up my TypeScript build

I was cleaning up my NPM modules on my side project. Since almost from the beginning, I have had 2 ā€œchildā€ package.json files, one for the backend and one for the frontend, and the ā€œmainā€ one in the project root.

Transactional tests with Mocha.js

This week, while working on the email change scenario on my side project, I realized that my tests are not transactional, which meant that their changes to the DB could persist across test runs and so tests could influence each other. Hmā€¦ I thought I fixed this before.

One reason to prioritize the feature work over tech work

A couple of weeks ago I wrote about the P/PC Balance, and while thinking about it some more, a kind of comic realization stroke me: I realized that one good reason to prioritize feature work above technical work on a project is that the former is finite, while the latter is potentially infinite.

My new notion of web app

One of my side projects that Iā€™ve been toying with, is a productivity app for bailiffs. And since Iā€™m reading ā€œLean Customer Developmentā€ by Cindy Alvarez, a few days ago I went with my partner to interview a bailiff ā€” a former college teammate of his.

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 ↑

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.

Trail maps

I donā€™t have a CS degree, and most of what I know Iā€™ve learned along the way because I found it interesting or because I needed to solve a problem. It worked pretty well so far, but sometimes I feel like I need a bit of structure around it, usually when Iā€™m trying to make sense of a bigger picture.

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 ↑

architecture

Simpler architecture

On the side-project that Iā€™ve mentioned before, Iā€™m making a priority of 2 things: (1) use the least amount of libraries and frameworks, and (2) organize the code in a way that reflects the logical structure of the app.

Back to Top ↑

css

On testing UIs

I have heard that people resist testing UIs because ā€œthey change oftenā€, and my oppinion is that from the perspective of ā€œtests as safety netā€ UI testing is as valuable as any other kind of testing.

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 ↑

dependencies

Simpler architecture

On the side-project that Iā€™ve mentioned before, Iā€™m making a priority of 2 things: (1) use the least amount of libraries and frameworks, and (2) organize the code in a way that reflects the logical structure of the app.

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 ↑

peace

Choice is a search

From time to time I stumble upon yet another article mentioning that humans are just bad at choices. I think accepting it as a truth is detrimental, and Iā€™d like to disprove it.

My view of motivation

In the last post on Travis Neilsonā€™s mailing list, heā€™s sharing his thoughts about motivation and proposes some solutions.

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 ↑

angular

Angular tip of the week: parametrized templates

On my 30-th week of Angular, I learned something that I was looking for since the first week: a lightweight way to get a ā€œparametrizedā€ piece of view. Coming from a couple of years of React, I was used to having function components to abstract away noisy bits of a view, and for some time I thought the only way to get that is to get such a thing.

Back to Top ↑

balance

One reason to prioritize the feature work over tech work

A couple of weeks ago I wrote about the P/PC Balance, and while thinking about it some more, a kind of comic realization stroke me: I realized that one good reason to prioritize feature work above technical work on a project is that the former is finite, while the latter is potentially infinite.

Back to Top ↑

build

Speeding up my TypeScript build

I was cleaning up my NPM modules on my side project. Since almost from the beginning, I have had 2 ā€œchildā€ package.json files, one for the backend and one for the frontend, and the ā€œmainā€ one in the project root.

Back to Top ↑

clarity

Choice is a search

From time to time I stumble upon yet another article mentioning that humans are just bad at choices. I think accepting it as a truth is detrimental, and Iā€™d like to disprove it.

Back to Top ↑

constraints

My new notion of web app

One of my side projects that Iā€™ve been toying with, is a productivity app for bailiffs. And since Iā€™m reading ā€œLean Customer Developmentā€ by Cindy Alvarez, a few days ago I went with my partner to interview a bailiff ā€” a former college teammate of his.

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 ↑

dns

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 ↑

infrastructure

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 ↑

smtp

Back to Top ↑

tech

Two days

This week I had a couple of harsh days.

Back to Top ↑

ts

Speeding up my TypeScript build

I was cleaning up my NPM modules on my side project. Since almost from the beginning, I have had 2 ā€œchildā€ package.json files, one for the backend and one for the frontend, and the ā€œmainā€ one in the project root.

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 ↑