For Science Keyboard

I recently built the “for-science” keyboard following this guide: https://github.com/peej/for-science-keyboard. Bill of Materials DIY kit: 1800 INR Arduino Pro Micro compatible x2: 908 INR Soldering Station: 1305 INR Soldering wire from Robocraze: 21 INR Digital Multimeter from Robocraze: 199 INR Key Switches from stackskb - Gateron G Pro 2.0 Brown KS-9 Tactile Switch - 50 pieces: 1000 INR Key Caps from stackskb - Cherry Profile Pudding Keycaps - 130 caps: 1000 INR TRRS cable from a local shop in Hyderabad: 200 INR Desoldering Flux from a local shop in Hyderabad: 350 INR Desoldering Wick from a local shop in Hyderabad: 300 INR Journey During the keyboard assembly, I initially followed the aforementioned guide but found it lacking in detail. I supplemented it with another guide for the Lily58. ...

March 6, 2024 · 3 min · Upendra Upadhyay

Nix Snippets

I use direnv to automatically get into flake shell as soon as I entre the directory which contain the flake.nix, the content of .envrc file is: use flake Most of the time I just need to use the package available in my shell for my dev work and the snipet that I use is: { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; buildInputs = with pkgs; [ # package1 # package2 ]; in with pkgs; { devShells.default = mkShell { inherit buildInputs; }; } ); } Sometime I write custom scrips that I need access to, I can create a nixified version using the writeShellApplication which is one of the trivial builders. Bottom is just a simple shell script to get the authentication code simlar to google-authenticator: ...

March 4, 2024 · 2 min · Upendra Upadhyay

Benchmarking Clojure Application

This is a snippet for benchmarking clojure application which I have used quite often in clojure applications at my job. First an introduction to the tools: clj-asyc-profiler: for flamegraphs and call graph. criterion: for statistically correct benchmarking. tufte: application level profiling. from this we can keep both #1 and #2 in separate profile just for benchmarking and #3 must be included in the :default profile, otherwise it would defeat its purpose. ...

March 3, 2024 · 5 min · Upendra Upadhyay

Exploring Resource Directory in Clojure

I was trying to explore the files available in resource directory and read only the .txt files available. suppose that I have these files in resources: resources/ └── hello ├── a.txt ├── b.txt └── c.not-txt and this is the clojure code that I have to read the files: (ns jar-resource-read.core (:require [clojure.java.io :refer [resource file]]) (:gen-class)) (defn read-all-txt-files [] (let [txt-files (->> (resource "hello") (file) (file-seq) (filter #(-> %1 (.getName) (.endsWith ".txt"))))] (for [f txt-files] {:name (.getName f) :content (slurp f)}))) (defn -main [& args] (doseq [{file-name :name content :content} (read-all-txt-files)] (println (format "%s:" file-name)) (println content) (println "---------------"))) and running lein run actually returns the correct result: ...

March 2, 2024 · 2 min · Upendra Upadhyay

Haskell Sudoku

Last time, I mentioned that I tried to write sudoku solver in haskell and it was using too much memory and time. So I tried to solve it again and this time I was able to do it, I guess I just needed more motivation. We will be using this file format as input to our suodku program: 92634.7.1 .5..264.9 .7.8.1... ...9..2.7 342.....5 1.....8.. 6854...12 ..4..29.. .1.538.7. and it will be represented as an array of numbers and . will be represented as 0, so for our repl, the sudoku will be [[Int]] ...

November 29, 2022 · 11 min · Upendra Upadhyay