Setting up Arch Linux from scratch in 2021

Few days back my long time running system broke due to some inconsistent package and I was forced to reinstall Arch. There are many tutorials and how-to pages to do so, but I found none to be exhaustive or seemless, so I decided to write my own. Here are the steps to install Arch Linux from scratch Make a bootable drive Download Arch Linux from here If using Windows, download Rufus and create a bootable drive....

March 14, 2021 · 5 min · wilspi

Introduction to Elm with 2048 game

In this post I will be creating a small game, 2048 in Elm. 2048 is a game created by gabrielecirulli which went viral in 2014. I chose 2048 because the game is simple which will help me/us understand Elm clearly. Also, I didn’t want to make another todo app. You can play here. Whats the game? There are some number tiles on the board (4x4). The number on the tile will be a power of 2 with minimum being 2....

August 8, 2020 · 5 min · wilspi

Variables and Memory management in Rust

In every programming language, understanding how variables are stored in memory is a crucial point to make your program fast and efficient. Let’s look at how Rust does it. Note: These are quick short notes, if you want to look in deep check out rustlang docs. Ownership In programming languages, either a garbage collector is used which will clean up the memory used by the unused variables or the memory is explicitly freed by the programmer in the code....

August 5, 2020 · 6 min · wilspi

Structured Logging using Slog in Rust

Slog is a structured logging library for rust-lang. Structured logging is a concept that puts events over messages, events are logged with associated key-value data, not plain string messages. This helps in: processing log files for analytics searching and debugging (example: search log statements for particular user or request) Basic Logging with Slog Lets create a simple logger: #[macro_use] extern crate slog; extern crate chrono; fn main() { let drain = slog::Discard; let root_logger = slog::Logger::root(drain, o!...

August 3, 2020 · 3 min · wilspi

Setup multi user nix for Arch Linux

On multi-user setup, from nix’s page: To allow a Nix store to be shared safely among multiple users, it is important that users are not able to run builders that modify the Nix store or database in arbitrary ways, or that interfere with builds started by other users. If they could do so, they could install a Trojan horse in some package and compromise the accounts of other users....

August 1, 2020 · 2 min · wilspi

Jinja template Inheritance using Database

Jinja is a web template engine for the Python programming language. A Jinja template is simply a text file and can generate any text-based format (HTML, XML, CSV, LaTeX, etc.). A template contains variables and/or expressions, which get replaced with values when the template is rendered, thus serving dynamic content. Commonly, templates are stored as files, either in git-repo or s3 buckets. Depending on your use case, you can store the templates in the database as well....

July 31, 2020 · 2 min · wilspi

Virtual Environment with Nix shell

Last year while working with @amitu, I came across this wonderful tool called Nix. About Nix, its wiki says: Nix is a package manager and build system that parses reproducible build instructions specified in the Nix Expression Language, a pure functional language with lazy evaluation Nix maintains the package versions including system libraries across OS environments and, hence never uses dependencies from the host system. All the version information is saved in your nix recipe (which you invoke through nix-shell command, we will see below)....

July 30, 2020 · 3 min · wilspi

Log requests and responses with Django Middleware

From Django’s context: Middleware is a framework of hooks into Django’s request/response processing. It’s a light, low-level “plugin” system for globally altering Django’s input or output. Middleware is like a layer which processes every request and response. Instead of logging requests and responses in resp. views, its better to do at middleware layer which will log every incoming request. Why better? it will log unhandled requests/views one time job, no need to configure for every request/view Here, we are using Django’s middleware semantics to construct a middleware which will log all requests and corresponding responses....

July 29, 2020 · 2 min · wilspi

Save the production with Nginx hack

Quick nginx hack to save your production web server in case the web service starts crashing. If you have been working in a production environment, you know at certain times your web service can crash due to some unknown reason (code failure). It will take some time to do the RCA and fix the issue. A quick hack is to have multiple web services running on different ports resp. that can take the load off if any of them goes down....

March 12, 2020 · 2 min · wilspi

nix recipes

...

March 9, 2020 · 0 min · wilspi