Author: abhijit

ruby Open3 module

What a fantastic module!

Every once in a while I get to know a bit more of Ruby and I feel the joy which Matz talks about!

From: The Philosophy of Ruby

For me the purpose of life is partly to have joy. Programmers often feel joy when they can concentrate on the creative side of programming, So Ruby is designed to make programmers happy.

Today I was looking for executing a program from within Ruby. Now this program takes command line input and gives some output as well. So, I went around trying the usual %x(program.rb) but obviously that didn’t work.

Finally I came across Open3 which is a core module of Ruby!

Continue reading

pipe localhost to the internet using inlets over Nginx

Many times during developing some application it becomes important to show the progress to someone over the internet.

Most of the time we end up using some screen sharing software. That, however, can only show my screen to the other person. They cannot really interact with the application.

We can use some software for remote desktop sharing but then I cannot work while the other person is using my screen.

One very nice solution is ngrok, which essentially creates a tunnel from the local system to ngrok’s servers and gives a nice URL.

ngrok

However, I was a bit concerned since all my traffic was getting redirected via ngrok’s servers.

I was looking around for something which would do the same thing but via my servers and finally came across inlets. This is an open source project, written in Go, which can be easily self hosted.

Continue reading

nginx auto-index styling

modified nginx index list

I’ve always been envious of the directory listing that Caddy has for serving files. Nginx also has the capability to list directories and files.

This is extremely useful to serve a directory out quickly over LAN or even where it is required to serve a directory listing instead of a web page.

However, the default Nginx styling leaves a lot to be desired!

Continue reading

ruby Classes and Modules

Classes and Modules in ruby have always intrigued me!

So, I thought I’ll write some code to understand what they were.

Besides the standard Class aspects of ruby, there are a lot of interesting things that can be done with them – like singleton objects.

Modules, of course, give another level of flexibility.

Continue reading

different ways to run program as root

I discovered that there are many different ways to run a program as root.

The most well known way is to use the sudo command

$> sudo run_as_root_program.sh

This, of course, prompts for the password which you need to then enter.

But what if we need to run the program itself from another program so that the password prompt doesn’t appear?

I came across this requirement recently and it took quite a few iterations before I got it right.

Continue reading

Copyright © 2024 the möbius trip

Theme by Anders NorenUp ↑