Dockerize a React App

This post will be my notes on dockerizing a React application. You can find the original post by Michael Herman at Dockerizing a React App. I use a dedicated node user in my approach, instead of running the container as root user. For detailed explanations, go to Michael’s post. Requirements Docker v19.03 docker-compose 1.25 Node v12.13.1 Project Setup Create the application, for example, via create-react-app: npx create-react-app dockerized-react && cd dockerized-react Docker Add a Dockerfile to your project directory (a file without extension):
Read more →

Vim Trick: Map CTRL+S to Save

Vim is very customizable. You can adjust key-bindings to your liking. For example, if you want to save a file, you’ll type :w or :up in command mode. But maybe you’re used to press CTRL+S to save a file? You could add a custom key-mapping to your configuration file (~/.vimrc or similar): nnoremap <silent><c-s> :<c-u>update<cr> The command works in normal mode. You can also bind CRL+S for other modes (visual mode and insert mode):
Read more →

Vim Undo And Redo

Today I learned about Vim undo and redo. Undo changes: in normal mode: u to undo latest change, U to undo all changes in Ex mode (command mode): :u to undo latest change Use :u {N} to undo a number of changes. For example, :undo 5 reverts the latest 5 changes. Redo changes: in normal mode: Ctrl+r in Ex mode: :re or :redo In Vim, undo is a tree:
Read more →

Pipe a Terminal Command to Vim

How can you run a command in your normal shell and then pipe it to Vim? A typical use case could be to run a find command and open the found file in Vim. Answer: You can use command substitution. vim $(find . -name example.txt) Here’s a useful command that I’m using now: nvim (fd | fzy) (I’m using fish as my interactive shell. Thus I don’t need to use $.
Read more →

Tool: fd - The Faster Alternative to find

fd is a “simple, fast, and user-friendly alternative to find”. This neat tool offers a more intuitive syntax for finding files and operating on them. The author wrote fd in Rust. Thus, it’s quite fast. Let’s say we want to find all mp3 files in a directory. With find, you have to do something like this: find -name "*.mp3" fd looks simpler: fd -e mp3 Here’s an example command that converts all jpg files to png files:
Read more →

Friday Picks 026

Here are some useful links for you: Colors And Fonts: a curated library for front-end developers and designers RxJS with React Hooks for state management: a beginner-friendly tutorial Barebones AWS Amplify + React + GraphQL App: get started quickly with this tutorial Building a payments system with React and Stripe: this tutorial shows you how to use Stripe in your React.js application React, Redux and JavaScript architecture: a post from 2018 that’s still helpful in understanding the basic concept of Reat.
Read more →

Create a Post Template in Hugo

Hugo offers the ability to create template files for your project. These Archetypes will make your life easier by pre-filling a blog post for you. How To Create A New Template In your Hugo project, create a new Markdown file in the archetypes folder in the project directory, for example, archetypes/posts.md. Here’s a template that creates a new draft post with the current date in a specified format. For the title section we parse the filename and use a regular expression to convert dashes to whitespace.
Read more →

Start Vim With Terminal Command

Today I learned that you can start Vim with a terminal command. Vim has the -c flag, which you can use for running an Ex command. The same is true for NeoVim, which also has an inbuilt terminal. So you can either start NeoVim inside the terminal like so: nvim +te or like that: nvim -c ‘:terminal’ The second option allows you to run another command afterwards. Example:
Read more →

Move To Hugo With Netlify

I’ve moved this blog from Gatsby.js to Hugo. My build times have gone down from more than 7 minutes to a few seconds! The slow build times with Gatsby have been an ongoing concern for me. I’ve slowly been creeping towards Netlify’s free 300-minutes-build-time cap. Hugo runs a magnitude faster, and it integrates well with Netlify. Hugo is a static site generator built with Golang. The project’s selling points are incredible speed, ease of use, and the ability to configure tons of settings.
Read more →

First Thoughts About ReasonML vs TypeScript

Today I finished my first TypeScript experiment with React. Here are some thoughts after using ReasonReact first, and now TypeScript second. Setup Is Not Better Than ReasonReact I used Create React App to bootstrap the app. npx create-react-app <project-name> –typescript But then I had to setup ESLint and Prettier with TypeScript. ReasonML & BuckleScript: npm install -g bs-platform bsb -init <project-name> -theme react-hooks After that you’re done.
Read more →