Product Sketches

Update: For more sketches and updates on this post, check my notes here Cook me Feedback To have a better food experience with your cook, you have to constantly tell him about your likes and dislikes. Sometimes he/she might cook you a fantastic dinner (something new) and never know if you liked. Whatsapp is good for chatting but not remembering, also your food habits are not structured and easily accessible within whatsapp and other note taking platforms.

Rust: Closures and Threads

Closures Closures are a function that has access to variables in the same scope in which it is defined. Annotating types in closure definition are not required, types can be inferred by the compiler. Closures in Threads When using a closure, variables defined in the same scope as the closure, are accessible inside the closure. But the same accessibility changes when closure runs in threads. Let’s look at the examples below.

Nix Recipe: Setup Python

This is a nix recipe for building and running python in a virtual nix environment. Create shell.nix with following: let nixpkgs = import (builtins.fetchTarball { overlays = []; config = {}; }; in with nixpkgs; stdenv.mkDerivation { name = "python-env"; nativeBuildInputs = [ zsh vim python37 python37Packages.pip python37Packages.virtualenv ]; # ENV variables PROJDIR = "${toString ./.}"; # Post Shell Hook shellHook = '' echo "Using ${}" [ !

Learning Elm: 2048 game in Elm

Elm is a front-end programming language optimized for developer’s happiness. Elm basics are very straightforward, which is just the Elm Architecture. The Elm Architecture Model — the state of your application View — a way to turn your state into HTML Update — a way to update your state based on messages You can read more about Elm here. Here, we will construct the famous game: 2048 in Elm.

Nix Recipe: Setup Nodejs

This is a nix recipe for building and running nodejs in a virtual nix environment. In your project folder, create a new file nodejs.nix and add following: { nixpkgs ? import <nixpkgs> {}, version, sha256 }: let inherit (nixpkgs) python37 utillinux stdenv autoPatchelfHook fetchurl binutils-unwrapped patchelf xcbuild; inherit (stdenv) mkDerivation; in mkDerivation { inherit version; name = "nodejs-${version}"; src = fetchurl { url = "${version}/node-v${version}${if stdenv.isDarwin then "-darwin-x64" else "-linux-x64"}.

Rust: Variables in Memory

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.

Nix Recipe: Setup Rust

This is a nix recipe for building and running rust in a virtual nix environment. Create a file rust-toolchain with following: 1.43.0 We are specifying rust version to install, here using 1.43.0. If using heroku, rust-toolchain file will determine which version will be used to build the application. Create shell.nix with following: let # Mozilla Overlay moz_overlay = import ( builtins.fetchTarball "" ); nixpkgs = import (builtins.

Rust: Slog and multiple drains

Slog is a structured logging library for Rustlang. 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) Logging 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!

Nix Recipe: Setup Postgresql

This is a nix recipe for building and running postgresql-12 in a virtual nix environment. Create your project folder and save the following file as shell.nix let nixpkgs = import (builtins.fetchTarball { overlays = []; config = {}; }; in with nixpkgs; stdenv.mkDerivation { name = "postgres-env"; buildInputs = []; nativeBuildInputs = [ zsh vim geos gdal nixpkgs-fmt # postgres-12 with postgis support (postgresql_12.withPackages (p: [ p.postgis ])) ]; postgresConf = writeText "postgresql.

Setup multi user nix for Arch Linux

Here we are setting up nix for Arch Linux. 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.