<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Coffee and Contemplation</title><link>https://coffeeandcontemplation.dev/</link><description>Recent content on Coffee and Contemplation</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><managingEditor>dev@gmail.com (dev)</managingEditor><webMaster>dev@gmail.com (dev)</webMaster><lastBuildDate>Mon, 15 Jan 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://coffeeandcontemplation.dev/index.xml" rel="self" type="application/rss+xml"/><item><title>Moving to NixOs</title><link>https://coffeeandcontemplation.dev/post/2024-01-15-moving-to-nixos/</link><pubDate>Mon, 15 Jan 2024 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2024-01-15-moving-to-nixos/</guid><description>The idea of a declartive reproducible operating system is really enticing. NixOs has been popping up in my reddit feeds recently. I had an option to install Nix as a package manager on my existing linux installation. But I decided to jump in the deep end. So, this post is being written on NixOS.
There is abundant documentation on Nix. Even after ignoring all of that, I was able to setup a working installation with most of my setup from the old Arch installation.</description></item><item><title>Temperature logger improvements</title><link>https://coffeeandcontemplation.dev/post/2022-11-14-temp-logger-improvements-for-pi/</link><pubDate>Mon, 14 Nov 2022 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2022-11-14-temp-logger-improvements-for-pi/</guid><description>Part1
Part2
Using the on-board LED to monitor sensor reads The raspberry pi pico based temperature logger &amp;ldquo;hung&amp;rdquo; at times. It didn&amp;rsquo;t write anything to the file at all. But, it wasn&amp;rsquo;t obvious that it had stopped working. Initially, I had plans to turn on the on-board LED when writing to a file. But, more experienced programmers suggested that sensor_temp.read_u16() is more likely to be the blocking call. So turning on the LED before reading the sensor and turning it off after would give a clear indication.</description></item><item><title>Plotting a timeseries graph with gnuplot</title><link>https://coffeeandcontemplation.dev/post/2022-11-09-plotting-temp-timeseries/</link><pubDate>Wed, 09 Nov 2022 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2022-11-09-plotting-temp-timeseries/</guid><description>So, there was this raspberry pi contraption to log temperature to a file. The next step is to plot this in a graph. We get a single column file of recorded temperatures from the raspberry pi pico.
It is pretty easy to plot a graph from a two column file using gnuplot. If the filename is temp_log, all you need is:
plot &amp;#39;temp_log&amp;#39; with lines I was too lazy to find how to plot a single column file.</description></item><item><title>Temperature monitoring with raspberry pi</title><link>https://coffeeandcontemplation.dev/post/2022-11-06-temperature-monitoring-with-rp-pico/</link><pubDate>Sun, 06 Nov 2022 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2022-11-06-temperature-monitoring-with-rp-pico/</guid><description>We bought a new Air conditioner for the house. It doesn&amp;rsquo;t feel like the AC is able to regulate the temperature to what we set. But, humans are often wrong about these kind of things. A simple thermometer would have done the trick - but we need time-series temperature data to verify the AC function.
Enter - the Raspberry pi pico. It has a built-in ambient temperature sensor and supports micropython.</description></item><item><title>Autocomplete in neovim with built-in LSP client</title><link>https://coffeeandcontemplation.dev/post/2021-01-14-autocomplete-in-neovim/</link><pubDate>Thu, 14 Jan 2021 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2021-01-14-autocomplete-in-neovim/</guid><description>In the last blog post, we saw how to setup the built-in lsp client in neovim for diagnostics and such. Now we&amp;rsquo;ll see how to setup autocomplete.
First, install completion-nvim. Add this to your vimrc and run PlugInstall.
Plug &amp;#39;nvim-lua/completion-nvim&amp;#39; Now, in the lsp_config.lua file, you need to make some changes. The file should look like this:
lspconfig = require&amp;#39;lspconfig&amp;#39; completion_callback = require&amp;#39;completion&amp;#39;.on_attach lspconfig.pyls.setup{on_attach=completion_callback} lspconfig.tsserver.setup{on_attach=completion_callback} lspconfig.rust_analyzer.setup{on_attach=completion_callback} This should give you completion.</description></item><item><title>Language Server Client in neovim</title><link>https://coffeeandcontemplation.dev/post/2021-01-10-language-server-in-vim/</link><pubDate>Sun, 10 Jan 2021 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2021-01-10-language-server-in-vim/</guid><description>What is language server protocol? Development becomes a lot easier if all languages support features like autocomplete, linting, go-to-definition etc. within the editor of your choice. But this is a difficult task for editor devs. Each editor has to build support or integrate with tools that provide language support. Each of these tools behave in different ways making integration difficult. Language server protocol was defined by microsoft to put and end to this.</description></item><item><title>What I learned from doing dishes</title><link>https://coffeeandcontemplation.dev/post/2020-12-27-what-i-learned-from-doing-dishes/</link><pubDate>Sun, 27 Dec 2020 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2020-12-27-what-i-learned-from-doing-dishes/</guid><description>I woke up today and was welcomed by a mountain of dishes in the sink. My first reaction was - &amp;ldquo;Screw that - I&amp;rsquo;ll just go back to bed&amp;rdquo;. So, after a couple more hours of sleep, I went back to find that the mountain hadn&amp;rsquo;t magically disappeared.
Now I had to tackle this problem. This is the strategy I followed
Move everything out of the sink back into the kitchen.</description></item><item><title>Fuzzy finding in vim - vim + fzf</title><link>https://coffeeandcontemplation.dev/post/2020-11-13-fuzzy-finding-in-vim/</link><pubDate>Fri, 13 Nov 2020 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2020-11-13-fuzzy-finding-in-vim/</guid><description>FZF is the center-piece of my vim configuration. It is another excellent piece of software by Junegunn Choi.
fzf is a command line fuzzy finder.
Now, that doesn&amp;rsquo;t sound like much. But the way it can integrate with your other tools will blow your mind. The repository for FZF is located here and has extensive documentation on how to use it. Follow these instructions to install it.
To see how it works, run this command:</description></item><item><title>Vimming in 2020</title><link>https://coffeeandcontemplation.dev/post/2020-11-07-vimming-in-2020/</link><pubDate>Sat, 07 Nov 2020 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2020-11-07-vimming-in-2020/</guid><description>If you use vim, you can use h,j,k,l keys to navigate instead of the arrow keys. You won&amp;rsquo;t have to move your hands away from the home row, and you&amp;rsquo;ll end up saving a lot of time.
One of my seniors in college told me this about vim. It sounded so incredibly ridiculous at that time, that I decided to give it a shot.
For the first couple of years, my .</description></item><item><title>Context managers in python</title><link>https://coffeeandcontemplation.dev/post/2020-10-31-python-context-manager/</link><pubDate>Sat, 31 Oct 2020 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2020-10-31-python-context-manager/</guid><description>Say, you have to open and process a file in python. You can do that using a function like this
def open_and_process(filename): file = open(filename) process(file) file.close() # This is important If an exception occurs in the process function, file.close() won&amp;rsquo;t be executed.
This pattern is the same for other types of resources too:
Acquire resource Use resource Release resource If something fails during the use phase, the resource won&amp;rsquo;t be released cleanly.</description></item><item><title>Higher order functions and where to find them - Decorators</title><link>https://coffeeandcontemplation.dev/post/2020-10-23-higher-order-functions-3/</link><pubDate>Fri, 23 Oct 2020 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2020-10-23-higher-order-functions-3/</guid><description>We saw what higher order functions are and how they can be used in creating partially applied functions in previous posts. Now let us see how we can use higher order functions to implement python decorators.
Let us say you want to intercept your function call to log the arguments passed and the return value. ie.
def add(a, b): return a + b add(2, 3) # When called with 2 and 3 as arguments, it should print &amp;gt; Function add called with arguments: 2, 3 &amp;gt; Function add returned: 5 It is quite easy to do this.</description></item><item><title>Higher order functions and where to find them - Partial Application</title><link>https://coffeeandcontemplation.dev/post/2020-10-22-higher-order-functions-2/</link><pubDate>Thu, 22 Oct 2020 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2020-10-22-higher-order-functions-2/</guid><description>In the previous post, we discussed higher order functions. Ones that take functions as arguments and ones that return functions as arguments. Now let us look at some that do both.
In languages like haskell, there is a feature called Currying. When a function which takes multiple arguments is called with less than the number of expected arguments, it returns another function with the arguments &amp;ldquo;partially applied&amp;rdquo;1. For Eg:-
-- Define a function add a b = a + b -- Call the function.</description></item><item><title>Higher order functions and where to find them</title><link>https://coffeeandcontemplation.dev/post/2020-10-21-higher-order-functions-1/</link><pubDate>Wed, 21 Oct 2020 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2020-10-21-higher-order-functions-1/</guid><description>My first encounter with a higher order function was when I ran man qsort and noticed its type.
void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); For someone who had only seen primitive types like int and long and char, int (*compar)(const void *, const void *) was quite the surprise. I later found out that it was the type for a function which took two arguments and returned an int.</description></item><item><title>How to quit vim</title><link>https://coffeeandcontemplation.dev/post/2020-10-20-quitting-vim/</link><pubDate>Tue, 20 Oct 2020 00:00:00 +0000</pubDate><author>dev@gmail.com (dev)</author><guid>https://coffeeandcontemplation.dev/post/2020-10-20-quitting-vim/</guid><description>Vim has multiple modes. You normally insert text in the Insert mode. Normal mode is where you move around and give commands to vim.
Esc will take you to normal mode(usually). You can enter a command starting with a :. Quit vim with the below command:
&amp;lt;Esc&amp;gt;:qa! q - quit a - all ! - force do the operation. This will quit all the buffers including the unsaved ones.</description></item></channel></rss>