NOTE: More coming soon! I will gradually tag articles. đ
- js 22
- writing 9
- vim 5
- dev 4
- make 3
- unit-testing 3
- unix 3
- grep 2
- learning 2
- scripting 2
- css 1
- development 1
- docker 1
- ease-into-it 1
- email 1
- git 1
- google apps script 1
- hackathon 1
- jekyll 1
- shell-scripting 1
- webapp 1
js
JS finding of the week: event.code
This morning I was working on a DropdownButton
widget:
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.
Thoughts on Redux
Last weekend Iâve watched the free introduction on Redux and I think I got it. Redux has:
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.
The promise handler pattern
The common way Iâve seen JS promises being explained is something like this:
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.
writing
My new use for Workflowy: rambling
I usually keep my project notes in Workflowyš and today I found a new handy thing I can do within it: ramble.
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.
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: recursive iabbrev
TLDR: Although Vim documentation says âAbbreviations are never recursive,â you can get abbreviations to recurse by escaping to the command mode.
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.
dev
Book review: Practicing Rails
A few days ago I have finished reading âPracticing Railsâ by Justin Weiss. I liked it so much that I wanted to write about it.
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:
make
make watch-app
My name Vlad, and I still like to make
things in 2022, as in GNU Make. đ
Make is still alive and kicking
I do most of my work in the console, and when I work on a task, I
usually have a task-specific Makefile
.
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.
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.
Testing trumps encapsulation
At some point I have heard Uncle Bob saying that:
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.
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.
make watch-app
My name Vlad, and I still like to make
things in 2022, as in GNU Make. đ
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:
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:
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.
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:
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.
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.
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.
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.
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.
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.
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.
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.
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
.
shell-scripting
make watch-app
My name Vlad, and I still like to make
things in 2022, as in GNU Make. đ
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.