Writing on software technologies, job hunting, and fun stuff in life.

All of my thoughts on programming, product design, interviews, and more, collected in chronological order.
Article's Thumbnail

ROS 2 Setup with Docker and Virtual Machines

In my latest post, I shared a ROS 2 setup using Docker. If you encounter issues running NoVNC, don't worry - there are alternative GUI options for Docker. Several solutions are available for you to explore. Now, I'd like to introduce a new setup using a Virtual Machine instead of Docker. You might wonder why. While Docker is fast, flexible, and easy to configure, it does have some drawbacks. One significant challenge is setting up bridged networking mode, which is notoriously difficult in Docker due to the lack of community support and documentation. However, bridged networking is essential when connecting to a real Turtlebot4 discovery server (such as a Raspberry Pi). With a virtual machine, it's a breeze to choose the bridged networking option. You can still find the same repository here: https://github.com/doanhtu07/test-ros2-docker I've updated the README to direct users to the appropriate setup instructions. For the Virtual Machine setup, the repository supports both VMWare (Fusion + Workstation) and VirtualBox. If you're concerned about the complexity of setting up a VM, don't be - I use Vagrant, a tool similar to Docker Compose but designed for managing multiple virtual machines. With my configuration file, all you need to do is to run a single command vagrant up , and the entire VM environment will be ready for you. That said, while Vagrant is great, be aware that virtual machines can be quite slow when it comes to initializing and preparing dependencies for ROS 2 and Turtlebot 4. It took me around 9 to 10 minutes to install everything, which made the development cycle for the config file quite slow. Feel free to try it out and reach out if you run into any issues!
Read article >

Hadoop on Docker

This semester, I am taking a Big Data class where I am exploring various aspects of handling distributed data systems and working with some Hadoop tools. As always, I like experimenting with different ideas and tools, so I prefer doing this in an isolated Docker container. To accomplish this, I thoroughly researched how to set up Hadoop in Docker. Setting up Hadoop is a bit more complex than other setups because it supports different modes, such as a pseudo-distributed cluster and a fully distributed cluster. In my Docker setup, I aimed to achieve both of these modes and successfully created environments for each. I'm sharing my setup here so that anyone with similar interests can replicate it or further extend it. Here is the GitHub link: doanhtu07/test-hadoop-docker: Setup simple Hadoop image with Docker Feel free to let me know how it goes, and if there are any issues, please report them in this GitHub repository.
Read article >

ROS 2 on Docker

Recently, I began exploring robotics programming and working with the ROS 2 stack. I use a Mac, which is somewhat compatible with ROS 2, but I prefer using Linux since it is a fully supported platform. Additionally, I want an isolated environment so I can experiment with different ideas and tools. To achieve this, I thoroughly researched how to set up ROS 2 in Docker and successfully created such an environment. I'm sharing it here so that anyone with similar interests can replicate this setup or further extend it. Here is the GitHub link: doanhtu07/test-ros2-docker: Setup ROS 2 inside Docker Feel free to let me know how it goes, and if there are any issues, please report them in this GitHub repository.
Read article >

Kivy with Scipy on Android

I've recently tackled an incredibly challenging problem while building a Python mobile app, and it's been quite an adventure! A friend asked for help with an app using Kivy as the mobile framework, and what was supposed to be a smooth process turned into a crazy puzzle when the project needed to integrate the Scipy library. Essentially, Scipy depends on Lapack, written in Fortran—a language not supported by default in the latest Android NDK. This meant I had to leap over numerous hurdles, like building a Makefile to pull Fortran binaries and crafting a Dockerfile to replicate the necessary Linux dependencies for seamless app building. For more details on the issue, check out this link: https://lnkd.in/gPBNTD2B . If you're encountering the same issue with Kivy and Scipy, check out my repo: https://lnkd.in/gvBjVzTV . I'm confident it will be a big help! This project marked my return to using Makefile, Dockerfile, and Pipenv after a long time, and I'm still amazed that I overcame all these challenges in just a few days. It just shows that nothing is impossible if you dedicate enough time and effort to it!
Read article >
Article's Thumbnail

Vim Motions in VSCode

My post imported from https://medium.com/yoyoshortcut/vim-motions-in-vscode-d616c1db6ea5 Photo by hannah cauhepe on Unsplash Vim, well… is definitely something. But I’m not going to talk too much about Vim here. Today, I want to quickly go through some settings in VSCode to make life smooth like butter for beginners (like me) to start their journeys with Vim Motions. Let’s wait no longer and jump right in! Gif by cwervo What is Vim Motions? Vim is an open-source and cross-platform text editor. If you go to your terminal, Vim is probably there available for you. Just simply type vi <text_file> , and it will take you into the Vim editor space. Vim Motions is a big part of Vim, specifically dictating the way you navigate around in your document and edit with varied commands and shortcuts right on your keyboard. Why Vim Motions? I think this essentially boils down to your own taste when it comes to editing text or code. But here are a few things to consider: Blazingly fast: If you get used to all the shortcuts and commands, navigating or jumping around in your code is a piece of cake! But do note that it does take quite some time to get used to Vim Motions. Minimal mouse interaction: With Vim Motions, most of the time, you will use your keyboard and won’t touch your mouse. Unless you switch to the browser or some other apps to debug, Vim Motions will keep your hands busy on the keyboard. Feel connected with your workflow: Vim Motions allows an extremely high degree of customization. So, after some small configurations below, VSCode will become your ultimate workspace working in your favor. Have fun: If you get past the hard part of practicing, using Vim Motions will feel like playing a mind game! It is well-known that Vim Motions is NOT beginner-friendly, but it is user-friendly. Once you can sub-consciously move around your code with Vim Motions, your experience only exponentially improves from there. What is the setup? Now comes the core components: VSCode + Vim Motions Step 1: Install the Vim extension in VSCode When you type vim in the extension market, the Vim extension should appear as the first item. Step 2: Follow my repo for details on settings in VSCode The full link for settings is here: doanhtu07/vscode-vim-settings ( github.com ) If there are any problems, let me know. I’ll look into them. But do note that I’m also a beginner in Vim, so there might be problems that are out of my scopes. Here in Medium, I’ll attach the two most important snippets: // settings.json { // Most of this config is from https://github.com/VSCodeVim/Vim // Some mappings are from https://github.com/VSCodeVim/Vim/#key-remapping // Another example full config to look at: https://gist.github.com/safinakib/cc081218b73139ee81e5cb96dbc8e5db "vim.easymotion": true, // https://github.com/easymotion/vim-easymotion "vim.incsearch": true, // Show the next match while entering a search "vim.useSystemClipboard": true, // Use the system clipboard register (*) as the default register "vim.useCtrlKeys": true, // Enable Vim ctrl keys overriding common VS Code operations such as copy, paste, find, etc. "vim.hlsearch": true, // Highlights all text matching current search "vim.leader": "<Space>", "vim.visualModeKeyBindingsNonRecursive": [ { // In visual mode, delete WITHOUT putting content into clipboard register "before": ["leader", "d"], "after": ["\"", "_", "d"] }, { // In visual mode, paste over WITHOUT putting content under cursor into clipboard register "before": ["leader", "p"], "after": ["p", "g", "v", "y"] } ], "vim.normalModeKeyBindingsNonRecursive": [ { // In normal mode, same like in visual mode, but can use with MOTION (w, b, ...) "before": ["leader", "d"], "after": ["\"", "_", "d"] }, { // To scroll down and center the cursor to the middle of screen "before": ["<C-d>"], "after": ["<C-d>", "z", "z"] }, { // To scroll p and center the cursor to the middle of screen "before": ["<C-u>"], "after": ["<C-u>", "z", "z"] }, { // Turn off highlight if necessary after search "before": ["<C-n>"], "commands": [":nohl"] }, { // Add line break shortcut "before": ["K"], "commands": ["lineBreakInsert"], "silent": true }, // https://github.com/Melkeydev/vscode_bindings/blob/main/settings.json // Split panes (by vertical and by horizontal) { "before": ["leader", "v"], "commands": [":vsplit"] }, { "before": ["leader", "s"], "commands": [":split"] } ], "vim.handleKeys": { // Avoid Vim overriding VSCode default keybindings like find or select all in Windows // These two keybindings below shouldn't matter in Mac "<C-a>": false, "<C-f>": false }, // To improve performance" "extensions.experimental.affinity": { "vscodevim.vim": 1 } } // keybindings.json [ // For better Vim experience // https://hoitz.medium.com/improved-vim-setup-in-visual-studio-code-bc579501b80c // Navigate around panes { "key": "ctrl+h", "command": "workbench.action.focusLeftGroup", "when": "editorTextFocus && vim.active && vim.mode != 'Insert'" }, { "key": "ctrl+l", "command": "workbench.action.focusRightGroup", "when": "editorTextFocus && vim.active && vim.mode != 'Insert'" }, { "key": "ctrl+k", "command": "workbench.action.focusAboveGroup", "when": "editorTextFocus && vim.active && vim.mode != 'Insert'" }, { "key": "ctrl+j", "command": "workbench.action.focusBelowGroup", "when": "editorTextFocus && vim.active && vim.mode != 'Insert'" }, // https://gist.github.com/safinakib/cc081218b73139ee81e5cb96dbc8e5db // Navigate inside suggestions and autocompletion popups { // "ctrl+j": Selects the next suggestion in the suggestions widget when the widget is visible. "key": "ctrl+j", "command": "selectNextSuggestion", "when": "suggestWidgetVisible" }, { // "ctrl+k": Selects the previous suggestion in the suggestions widget when the widget is visible. "key": "ctrl+k", "command": "selectPrevSuggestion", "when": "suggestWidgetVisible" }, { // "ctrl+j": Selects the next item in the Quick Open dialog when it is open. "key": "ctrl+j", "command": "workbench.action.quickOpenSelectNext", "when": "inQuickOpen" }, { // "ctrl+k": Selects the previous item in the Quick Open dialog when it is open. "key": "ctrl+k", "command": "workbench.action.quickOpenSelectPrevious", "when": "inQuickOpen" }, // https://github.com/Melkeydev/vscode_bindings/blob/main/keybindings.json // Some shortcuts for file tree { "key": "n", "command": "explorer.newFile", "when": "filesExplorerFocus && !inputFocus" }, { "key": "r", "command": "renameFile", "when": "filesExplorerFocus && !inputFocus" }, { "key": "shift+n", "command": "explorer.newFolder", "when": "explorerViewletFocus" }, { "key": "d", "command": "deleteFile", "when": "filesExplorerFocus && !inputFocus" } ] Copy the content of these files and paste properly into your VSCode settings.json and keybindings.json files. In my Github repo above, I’ve shown how you can access these files on your VSCode. I also bonus some useful shortcuts I like to use for moving around different panels of VSCode. Step 3: Take some time to practice and get used to Vim Motions It is not magical that you can automatically use Vim Motions smoothly right after setting up. It took me around 2–3 days to only get used to basic Vim Motions and could actually use it to edit my code. It could take even longer to become fast and comfortable with all the shortcuts. Practicing, I have to say, is the hardest part. At first, it will be very slow and discouraging, but it will quickly get easier and easier, I promise. View it as a journey. Have some fun. And the water will eventually push you there! Photo by Roberto H on Unsplash Here are some resources that helped me along the way: Use vimtutor on Mac Terminal. I believe this exists on Windows too. It provides lessons and exercises right from your terminal. I also watch parts of the series Vim as your editor on YouTube by ThePrimeagen , where he suggests some cool tricks for Vim Motions. A few minutes ago, I found this Vim cheatsheet, so I’ll share it here too: My vi/vim cheatsheet ( worldtimzone.com ) BONUS !!! Besides the code editor, the browser is my second workplace I use for almost all of my tasks including researching, studying, and doing projects. Links are a big part of all these tasks. Being able to navigate and search for links quickly is a must! My favorite browser extension to use is Yoyo Shortcut . It’s a bookmark manager tool that supports attaching keyword shortcuts to links and organizing your links into neat dashboards. Check it out if you’re curious. If you have any further questions, let me know in the comments. Happy motioning! Photo by Benjamin Voros on Unsplash
Read article >
Article's Thumbnail

Basic Node Back-end Boilerplate

What is the difference between a back-end and a front-end? Back-end usually indicates the servers that can serve any type of requests from clients, while front-end usually points to the user interface codes. To write a complete service / application, developers will need to utilize both of these concepts. Both concepts have further tech stack and terms you might need to be aware of. For front-end, you might have heard of common terms like Javascript / HTML / CSS . You might also hear Client-Side Rendering or Server-Side Rendering if you work with React. For back-end, there are terms like Database / HTTPS Protocol / API . Back-end Boilerplate In this article, I want to share a simple back-end boilerplate using ExpressJS as the API handler and PostgreSQL as the database that I have always used whenever I work with a NodeJS server. Feel free to check it out and clone for your project. Remember to read the README file first as there, I explain the tech stack this boilerplate uses, the tools you will install, and the topics you might be interested in when you expand your server's capabilities. Link: doanhtu07/backend-express-frame (github.com)
Read article >

Feel like learning full-stack website development but don't know where to start?

When I first learn making websites, I wish for a post somewhere that shows me what I should know. But documentations online are all over the place. This post hopefully shows a brief overview of a full-stack website/application. A full-stack application always has at least two parts: front-end (client) and back-end (server). React is a famous library for component-based user interfaces, so I will mention it here too. Tech Stack Gerneral Knowledge NPM / Yarn: Manage packages Git: Version control Environment files (e.g: .env, .env.local (Next.js), ...) Deployment CI / CD (Optional) Front-end (Client-side) HTML CSS Javascript / Typescript Front-end with React Class / Functional component: Lifecycle + States + Props Hook Server-side / Client-side rendering Query hook + cache Back-end (Server-side) CORS API endpoint + HTTPS protocol Middleware Connect with a database: Query + Mutation Cache / Quick storage (e.g: Redis) (Optional) Cron jobs + Message queue (Optional) Webhook (Optional) Socket / PubSub (Optional) Conclusion This list shows most of the important things you need to know in order to build a full-stack application all by yourself. With that being said, it might take some time to learn everything on that list. For new developers, I recommend building a simple web portfolio first. This will not only raise interest but also helps improve HTML / CSS / Javascript skills. If you want to touch on some other cool front-end topics, consider Next.js. If you want to practice writing a simple back-end server, try Express.js. For a fun challenge, build a full authentication flow from front-end to back-end that is able to: Save user sessions Invalidate all sessions when user changes password Cheers!
Read article >

© 2024 Anh Tu Do. All rights reserved.