Blog posts
Below you can skim through the 226 blog posts written over the years.
Browse by tag
nvm
not loading node
and npm
.Rightfully in my session I was getting command not found: node
when trying to run node
or npm
.
Most likely it’s an issue related to my previous installation with brew
…
I’ll touch on Process.register/2
and GenServer.start_link/3
.
In this post I’ll go through the basic idea, implementation and examples to set up a blog search for Eleventy, Hugo, Jekyll and other static-site generators.
> a list of Unicode code points
⌘
+ <
.Decided to explore the GitHub CLI and make good use of some fancy GitHub CLI commands to improve my Git(Hub) workflow.
I have also attached some more sources for further inspiration.
Developed in the late 1990’s, the rules of simple design are:
Applications were not listed and generally it didn’t seem to work properly.
These are the steps that helped me to fix Spotlight indexing on Big Sur.
Focus is on Web Development with JavaScript, TailwindCSS, node.js + npm, some personal templating choices and Material skin.
This allows me to use it on the login screen to enter my password in Manjaro Linux.
I’m a JavaScript Developer, and I’m currently navigating the web with JavaScript disabled.
WTF? Why? How? But seriously, WHY?
I got a few comments, but I came to the conclusion that it’s not worth it.
Here are my findings.
Here I want to outline how I deploy and manage my self-hosted services on Linode with nginx, docker-compose and CloudFlare
Here is an example of how I used this functionality in Minimal Analytics
Below I’m going to illustrate how to lazy load images using Eleventy plugins.
In my case, the function returned the milliseconds until midnight.
Here is a simple way to test the function msUntilMidnight
.
This is my approach to a self-hosted, simple web analytics solution.
It also helped me to get back to Full stack web development, using a clean and testable approach.
Nothing so weird so far.
Out of curiosity I checked if the user wanted to make a decent PR and improve something in the code.
The user in fact made a new commit on their fork and added a new file. A new GitHub action.
Let me explain what happened.
Namely from a combination of AWS S3 + CloudFlare, to only CloudFlare Pages.
Will get into hiccups, overall experience and ease of use.
Che cos’è?
> The Lean Validation Playbook è una raccolta di metodi per testare idee e soluzioni legate alla creazione di prodotti digitali e affronta il lato operativo che manca a molte strategie di business.
In questo post descrivo come abbiamo messo online un sito statico con 11ty
e altri strumenti utilizzati per organizzare il lavoro.
I am currently using this under /posts to let readers search through my blog posts.
Read more below about how to integrate it in your site.
The solution is having separate connections for your Wireguard VPN or Pi-hole instance, alongside your usual network you connect to.
Can you use them to reduce dark/direct traffic and label RSS subscriptions?
Especially containing emails and contacts saved in my account.
Received a 3GB zip file containing a 10GB mbox file.
This is how I managed to read it, either in the terminal (mutt
) or with Thunderbird.
Who knows, maybe this can be helpful for you too.
Comments are back, and I’m curious to see if this can spark some interesting discussions and be worth the hassle of self-hosting the comments.
Please, put that in the URL, ok?
70k visitors / 100k pageviews (excluding those with analytics blockers installed) reached this very website in the last year.
From joinmastodon.org
> it’s a network of thousands of communities operated by different organizations and individuals that provide a seamless social media experience
Assembly: done 👍️
Filament: ready ✔️
STL file: affirmative ✳️
You put your SD card in and hit "Print" 🖨️
I am switching from Mac to Linux.
This is how the adventure started to find the best linux distro, with a seemless user experience and minimum maintenance.
In the past months I experimented with various distros:
- bare debian
- Pop!_OS
- Ubuntu
- Elementary OS
- Manjaro
I didn’t even want to get my hands dirty with bare Arch. To each their own, right?
Read below to read my experience and to which distro I settled using.
I hesitated to write this for a while.
Why?
Because it means talking about many failures.
And I’m just thinking about personal things: not even mentioning the political or healthcare landscape.
Achievements and things learned are small, but still noteworthy and I’m proud for trying my best.
This “2020 in review” will be in form of a retrospective, namely the 4 questions retrospective".
At the end of November I came across this Green sustainability challenge for Madrid: https://challenge.greemta.eu/
GreeMta is a project of Bruno Kessler Foundation promoted by EIT Climate-KIC’s Cross-KIC Sustainable Cities program together with the municipality of Madrid.
After taking a look at the datasets and the Madrid Open Data Portal, I decided to particate.
I highly recommend following the step by step course to convert your blogging from a waste of time to a source of potential customers and sales.
Anything about your code and development environment that slows you down.
It’s a cost that you sustained in the past (be it time, money, energy, whatever) and cannot be reversed, cancelled or undone.
The fallacy is that yet knowing about the sunk cost of a project, you are often tempted to justify your future investments because of your past (most likely lost) investments.
The sunk cost should not influence your future decisions, yet it does. And the outcomes are often delusion, sadness and stress.
The gist:
- every 20min
- scrape hackernews frontpage items
- save them in
hn.json
- commit and push
Find the git repository here at christian-fei/hn-history
As a pure exercise or kata if you want, I tried to apply Clean code, Refactoring and Testing priciples for this small npm module.
The task is simple:
Get the posts on the front page of https://news.ycombinator.com and parse them.
This was the perfect opportunity for me to implement an idea I had long time ago: (Privacy-friendly) Polls with Plausible Analytics!
The idea is to use Plausible’s Custom props and hook them up to a simple poll component in JavaScript!
Let’s get started 🚀
"Suddenly", after updating some npm packages, my npm install was "not working".
It exited abrubtly with status code 137, with the error message "Killed".
I managed to
- add an application to the Bangle.js (with
create-bangle-app
) - send accelerometer data over Bluetoot Low Energy
- discover & connect to BLE devices with Node.js
- read accelerometer data with Node.js (coming from the watch)
It’s a pretty awesome, open-source watch based on Espruino and Node.js, and much more! 🤓
Read about my experiments here especially for creating a mouse-watch app with Node.js and Bluetooth Low Energy!
plausible.io is my favourite Analytics service out there. It’s open-source and you have the ability to self-host it.
The recording of the talk can be found here on yewtu.be
Video can be found here on yewtu.be
Recently I stumbled upon this paper about “I’ve Got Nothing to Hide” and Other Misunderstandings of Privacy by Daniel J. Solove
Do yourself a favor and read it here
Learn what a retrospective is, Prime directive and the four questions retrospective
My current PC is a 10 year old Macbook Pro 13" 2010, which is sluggish sometimes.
So I want to offload some heavy tasks (ffmpeg time-lapse creation, long-running tasks and services) to the Raspberry Pi and connect to it either via LAN or Wi-Fi.
Below you can read my findings about performance, applications and general issues I encountered and tried to solve.
Using an ESP8266 for IoT projects makes me go fast while prototyping.
The compact format is perfect for small DIY devices.
Wi-Fi connectivity is built-in, and it’s super affordable.
> The ESP8266 is a low-cost Wi-Fi microchip, with a full TCP/IP stack and microcontroller capability (wikipedia)
Had a spare Raspberry Pi Zero W catching dust, you can purchase one for ~ 25$ and the related Raspberry Pi Camera module for < 20$.
Name | CPU | RAM |
---|---|---|
Chuwi Herobox | Intel Gemini-Lake N4100 | 8GB LPDDR4 |
Intel NUC | Intel Core i3 8109U | Max 32GB DDR4 2400 MHz |
AcePC AK1 | Intel Celeron Apollo Lake J3455 | 8GB DDR3 SDRAM |
Coofun CJ34 | Intel Apollo Lake Celeron J3455 | 8GB LPDDR4 |
And I fell for it, as many, many others:
I use this super simple organizational trick / habit when signing up for newsletters.
SEO is as important as a good mailing-list to reach your (potential) audience.
Over the past 10 years, I’ve made some mistakes and also took home some knowledge about SEO for blogs and websites.
Below I’ve compiled a list of techniques and code-snippets that I personally use (hint: view-source
) to improve for organic website traffic and SEO.
To make your content more enjoyable by users (social media sharing, RSS, search results) and descriptive to machines (SEO).
- 152,906 trackers blocked
- 2,26GB of bandwidth saved
- "2,1 hours saved" (no clue how this is calculated)
But more importantly, I made some bucks!
From the official documentation you can trigger custom events via JS, by including a small utility function plausible
:
html <script> window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) } </script>
Whenever you call plausible(‘…event…’)
you put a tracking event in a queue (window.plausible.q
) and will be tracked.
Resumed the course, this time for real, and I’m trying to motivate myself by taking notes about my learnings.
Buy it here Marketing for Developers – advice for programmers, software, and SaaS
items
:E.g. in the form of count
, sum
and average
for each field
Let’s say you have the following documents in the items
collection:
js db.items.find() { "_id" : ObjectId("5f034ce90b15686f5d78baed"), "subDocument" : { "field1" : 42, "field3" : 10 } } { "_id" : ObjectId("5f034ce90b15686f5d78baee"), "subDocument" : { "field2" : 14, "field3" : 6 } } { "_id" : ObjectId("5f034ce90b15686f5d78baef"), "subDocument" : { "field1" : 6, "field4" : 11 } } { "_id" : ObjectId("5f034cea0b15686f5d78baf0"), "subDocument" : { "field3" : 3, "field4" : 26 } }
How would you solve the use-case of aggregating each field of the subDocument
's dynamically?
Event without actually "knowing" which fields are contained in subDocument
?
> Open source home automation that puts local control and privacy first
I recommend installing the Hass OS on a Raspberry Pi 4 with an SD Card of at least 32GB.
When: 2020/05/28 - 2020/05/29
Where: On the interwebz
Schedule: code-beam-v#schedule
> To upgrade an existing MongoDB deployment to 4.2, you must be running a 4.0-series release.
So, a little bit of context:
Let’s say you are currently running on version 3.6.
You want to upgrade to the latest version.
You would be inclined to directly upgrade from 3.6 to 4.2.
Not so fast.
The issue was that the requests that started from the HTML document were served and requested over HTTPS, but "inner" resources (AJAX calls, images, etc.) were configured as HTTP.
I’m going to outline an example to make the concept clearer:
You need to send a recurring email to some users (a newsletter for example), based on some business logic.
The business logic / user story could say:
"As a user
I want to receive an email every week
So that I can stay up to date with the latest news."
This is intentionally a contrived example to reduce the scope of the exercise.
Topics, Approaches and Tools
Concepts discussed below are
- SOLID principles
- Single Responsibility Principle
- Open-Closed Principle
- Dependency Inversion Principle
- Reason for a software component to change
- Test doubles like Spies and Stubs
- Collaborators in tests
- User Acceptance tests
- Unit tests
On the technical side, I am going to use the following tools
- sinon for easy Test Doubles
- ava for running the tests
- MongoDB as an example, but of course the persistence can be changed at your liking
- no real email API service, to keep it simple
Clean My Mac wasn’t an option. I don’t want to spend 40$ for a cleaning tool, if you’re so inclined feel free to do it.
And you’re running a Node.js HTTP server, like express or fastify?
npm
registry goes down, it's wise to have a backup registry.Motivation
I tried to do a self-examination, reflecting on what matters to me about Privacy.
Being more aware of what you share while browsing the web comes with experience and can be seen as a journey.
I knew there was something called Observer
, but couldn’t remember exactly how to do it.
Taking a look at the doc, I found this debugging page that mentioned :observer.start()
.
The suggested usage was with iex -S mix
and then running :observer.start()
in the mix
shell manually.
I don’t like manual things that much.
ASAP after work I checked the validity through validator.w3.org/feed/ and in fact there were some issues with it.
But if you want to roll your own, for fun or for whatever reason, continue reading to understand how I did it.
µcompress
is a lovely utility by WebReflection that compresses common static files.> A micro, all-in-one, compressor for common Web files
Using it since commit ce0a9e on this very website, in my GitHub Actions workflow.
Do you have a Raspberry Pi (4, 3, or even a Zero like me) laying around collecting dust and you want to make use of it?
Use it for ad-blocking in your home network and to finally browse the web, watch videos etc. without annoying ads.
falsy
.Falsy values are undefined
, null
, false
, 0
, NaN
, and ‘’
in JavaScript, and sometimes you want to retain those values, explicitly excluding null
and undefined
.
Topics I want to explore in this exercise are:
- Elixir Supervision trees
- HTTP calls with Elixir (with HTTPoison)
- TDD and Refactoring
Thanks to the help of some dear colleagues I had the opportunity to get valuable feedback and learn even more concepts about GenServers, the BEAM virtual machine, ETS and Erlang+Elixir in general.
I also went to my first Erlang+Elixir conf, and had the chance & honour to meet Joe Armstrong, #rememberingjoe.
On 2020/04/22, during quarantine, I decided to get back to Elixir (who knows: maybe even dabble with Erlang directly).
I post-poned this too much now, it’s time to get back to the distributed programming world.
Without further ado, below my journey (in form of a daily journal) about learning more about Elixir (again), the BEAM, plausible analytics and things discovered along the way!
devblog
is yet another lightweight static site generator.Although there are widely used SSG like 11ty (which this blog was previously based on), Jekyll (also previously used), GatsbyJS and many others, I wanted to get my hands dirty and understand how to make the process of building a static blog even simpler, if possible.
Even simpler in the sense of "it does just what I need and nothing more".
Install via npm i -g devblog
or create a blog with a one-liner npx devblog init my-new-blog
, cd my-new-blog
and serve with npx http-server _site 8080
. It’s that easy.
Rebuild the blog by running npx devblog
(or npm i -g devblog
and then just run devblog
in the main directory)
Continue reading my story of building devblog
.
Below my favourite Visual Studio Code theme I’ve come to like over time.
remote
to an existing repository or you create a new branch, you have to set up the remote branch tracking yourself.browserless.io is a neat service for hosted puppeteer scraping, but there is also the official Docker image for running it locally.
I was amazed when I found out about it 🤯!
Find the whole source code on Github christian-fei/browserless-example!
At christian-fei/twitter-oauth-login-in-nodejs on GitHub you can find the whole source code.
Learn how to create a Twitter OAuth Application
Since my process of trying to understand and make sense of OAuth has been both fun and rough, I wanted to summarize a full example in a single JavaScript file and document other findings along the way.
> Programming language, editor, and infrastructure for building backends
Functional / imperative hybrid language is influenced by Elm, Rust, OCaml, Swift, Ruby on Rails, Clojure, TypeScript.
It is like finding a treasure for me because I was looking for an official list of supported domains on Cloudflare, since I own a few .cc
, .ninja
, .xyz
domains.
raspistill
is the command line tool for capturing still photographs with the camera module.Here you can find the official docs.
.npmrc
in the root of the project (same level as package.json
).Read more about how to do it with Node.js
Learn how to create Twitter login with OAuth 1.0a.
As much as it hurts, this action had to be taken due to apparent trademark issues with the word pomodoro.
pomodoro.cc has to close.
~ 50 lines of generic JavaScript will suffice.
dotenv
to handle different environments in my Node.js applications.It gives you the ability to specify a .env
file (generally provisioned on each environment with the corresponding environment variables), along these lines:
An example of connecting to mongodb with the Monk NPM module.
The alternative title could be Lazy loading images in 900B.
lerna
while trying to publish packages from a mono-repo.The problem was that lerna
, sometimes, failed while publishing the changed packages (with the command lerna publish --conventional-commits
)!
The code snippets below are taken from pomodoro.cc api source code.
Having trouble SSH’ing to your Raspberry Pi over Wi-Fi?
Same here…
Here some troubleshooting steps that may solve your issue:
Web scraping […] is used for extracting data from websites
- pandoc 👉 11ty (static site generator)
- cypress (uat)
- github actions (cd)
- aws s3 (hosting)
- cloudflare (dns + cdn + ssl)
Let’s get straight to the point.
After reading this, you’ll be able to send a telegram message to a chat_id
with one command.
I finally managed to get the deployment of an eleventy - 11ty site (namely this one) and sync with AWS S3, where this blog is hosted.
trying to work on your pc in 2019 is the worst if you are experiencing a slow internet connection.
Do you need to upgrade from MongoDB version 3.4 / 3.6 to version 4.0 ?
bash fatal: [52.28.21.116]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: ‘ansible_distribution’ is undefined\n\nThe error appears to have been in ‘…/tasks/main.yml’: line 1, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- debug:\n ^ here\n"}
Following this [Machine Learning - Crash Course](https://developers.google.com/machine-learning/crash-course/
License)
tldr;
conda
or anaconda-navigator
available in your shell, you'll need to edit your ~/.config/fish/fish.config
and add the directory where the commands are located.If you’re using Anaconda with Python 2.x, the path will be /anaconda2/bin/
.
For Python 3.x and up: /anaconda3/bin/
Here the methods I follow to clean my Android device in 2018.
Whatever!
I came across the only documentation about cloning a git repo with the [–depth
option](https://git-scm.com/docs/git-clone#git-clone
Today I attended an event about "Blockchain for Smart Communities" during the Trento Smart City Week.
The topics discussed are:
- the impact on citizens, businesses & public administration
- new opportunities offered by blockchain technology and smart contracts
- use cases like automating insurances, providing transparency and resilience on administrative tasks and much more
A simple way to achieve this (and that I use all the time) is to combine Promise.all
with an npm package called p-limit
.
p-limit
is used to run multiple promise-returning & async functions with limited concurrency.
After some time, I picked up a project where LaTeX was involved, to find out it didn’t work anymore.
I couldn’t run the script with the pandoc
command, a few errors came up.
stdin
input in a command line script.Market data is generally represented as an array of arrays, and each entry is a data point that represents a "snapshot" of the market in a given period of time.
Hey https://t.co/zZprrZ7UDA users, we are glad to announce a more usable and sustainable version of pomodoro.cc!
— Pomodoro.cc (@pomodoro_cc) October 21, 2017
using github projects to keep track of activities and being public about it has been a very pleasant experience.
in the next sections you’ll understand what changed.
I want to talk a little bit about my dotfiles
.
You can find them on Github (obviously).
- not to read ahead
- not to "spoil" me any links (maybe it’s just me)
- to reflect on how to learn the most out of each issue of Hacker Newsletter
- a Jekyll blog (of course)
s](https://twitter.com/joebew42) [daily activity log concept](https://github.com/joebew42/daily-activity-log-concept). It was very interesting to see [his progress](http://joebew42.github.io/events) and keeping track of his studies and interesting reads over the course of over 4 months! [Here
s my take.Now I want to try it and to see it as a log and motivation/reminder to study regularly. I will also use it probably as a aid to review the studies and to visualize the progress.
Finally I will also find a way to integrate it with pomodoro.cc, I`m sure about that…
What I found is that lots of intelligent people were talking about idiomatic solutions they found to write maintainable AngularJS applications, and some similarities caught my attention.
One of them was the preference to use the controller as syntax, I definitely do too, and here is why.
AppCache is a nice guy when it comes to caching stuff, but at the end of the day it is just a fucking douchebag.
For me AppCache is a smelly, almost invisible, annoying little parasite.
If you’re having trouble cleaning up the mess this guy did (aka invalidate the cache), these simple steps will lessen your burden and throw this douchebag out of the parents’ house.
[1,2,3,4,5,6]
should become [1,3,5]
.One way to solve this problem in a functional fashion is to provide an odd
filter function, that is internally composed by a negation of an even
filter on those numbers.
You need to install hub, which is a tool that will wrap your git cli tool with some useful utility functions to interact with GitHub.
If you’re trying to finish a coding kata in a pomodoro, you’ll most likely have a hard time.
I was sick of almost never finishing a kata, but then this idea hit me:
It would be awesome if you could start a kata from a fresh, already set up workspace, with preconfigured test framework and boilerplate classes.
I found two options suitable to support this workflow.
First of all I would like to explain why:
In my opinion sometimes you can write some of your E2E tests and your User-acceptance tests in one go, together.
I’m not saying all of them, some E2E tests can cover exceptional cases and often are on the sad path in terms of UAT.
Both of them are rather flaky in terms of feedback and can’t give any detailed hint where the test failed, except the approximate region of your application.
Both hit the application in the running state, so why not write some of them in the language of the business while testing technical aspects hidden behind?
It’s just a thought, probably I’m totally wrong and should read more about both aspects :)
Anyways:
You want to provide to your user the ability to select two things from this array.
If you use the <select>
tag you won’t be able to select multiple options from this list unfortunately. You can either come up with a new directive that handles this, use somebody else’s plugin, or roll your own Angular filter (probably for learning purposes).
Drone listens on port 80
by default.
If you want to host your application on the same server, then that’s an issue.
Fortunately I came across a nice tool that exists since the archaic times of computers (for me at least), since 1999, that gives me very handy commands to solve this workflow. It’s called ImageMagick.
I was fascinated about the simplified API that Angular provides to make DI happen and the ability to create testable, modular code out of the box.
Anyways we are here to look what’s behind Angular’s DI, so here we go.
In the Collection a gamefield document has the following structure:
Getting permission errors when installing a module?
Are ‘sudo: node: command not found’ errors taking away your precious sleeping hours?
But if you want to get your hands dirty with the Github API, this article is for you.
Let me show you how many Kilobytes you can save by compressing files with Gzip (a real world example):

Disqus is definitely one of the best commenting systems out there (not to mention that it is responsive).
As a speed freak I’m always concerned how much assets a website needs to load, affecting the overall load time of it.
Let’s get straight to the point:
First you need to find out the device file of the partition you want to automatically mount on start up.
You need to replace a string with special characters (like http://) and don’t want to do that manually?
I’ve found the solution.