Skip to content

Instantly share code, notes, and snippets.

View tsrivishnu's full-sized avatar

Sri Vishnu Totakura tsrivishnu

View GitHub Profile
tsrivishnu /
Last active July 26, 2020 13:47
Resources to get familiar with Webpacker, Webpack and Rails

Being a backend developer, I only stayed on the surface with regard to frontend technologies and frameworks. When I started a new Rails project in January 2020, I started with Rails 6 and was all of a sudden presented with Webpacker as default for bundling frontend code.

It was intimidating to think of learning about Webpack and Webpacker to get the app running well while trying to build an MVP for a startup. I had so many questions:

  • how do I import Javascript and CSS into my pages?
tsrivishnu /
Last active August 21, 2023 11:31
Increase inotify watchers in Docker images during build

Increasing fs.inotify.max_user_watches for Docker images

TL;DR You can't set those for an image during build time becasue Docker takes the sysctl configuration from the Host. So, set the config on your host machine.

As in this link, to increase the maximum watchers, we need set fs.inotify.max_user_watches to a higher number in /etc/sysctl.conf.

tsrivishnu /
Last active October 22, 2020 20:07
Useful links when you live in Germany
tsrivishnu /
Last active February 16, 2021 14:09
How to enable Middle button (plus Trackpoint) scrolling on Thinkpad T440p running Ubuntu 16.04

Trackpoint scrolling on Thinkpad T440p running Ubuntu 16.04

I have moved to use Ubuntu for work after more than 6 years of using a Macbook. Like many others, I didn't really like moving away from Mac but few limitations, especially the poor performance of Docker on Mac convinced me to stick to Ubuntu. Honestly, Ubuntu, or any other linux operating system isn't that bad once you know the basics and figure out that there is a solution for almost all the problems.

With regards to build quality, I feel, Thinkpads are the next best to Macbooks. I have seen my colleagues use windows on them and use the trackpoint scroll.

tsrivishnu /
Last active September 18, 2022 10:10
`sed` to extract matched strings from a file

NOTE: This gist wasn't given so much attention while writing. So please ignore any typos or meaningless sentences.

How to match a pattern and return only a part of the lines from a file.

One might run in a case when they need to extract some information from a log file and get that information into a CSV file.

This once happened to me to look into the logs for an email sendout worked to findout the ids of users to whom we sent the emails to for a particular day. Luckily, our email service prints out to the log, the user object and the type of the email that is sent to that user object. Each line in the log file looks like this

tsrivishnu / click_allow.scpt
Last active July 16, 2018 14:51 — forked from rwest/README
Convert OS X Keychain exported entries into logins for 1Password import
View click_allow.scpt
tell application "System Events"
repeat while exists (processes where name is "SecurityAgent")
tell process "SecurityAgent"
click button "Allow" of group 1 of window 1
end tell
delay 0.2
end repeat
end tell
tsrivishnu /
Last active May 9, 2023 06:06
Git: Ignore already checked in file

Git: How can I ignore a file that is already committed to the repo?

You have a repo and quite some developers have cloned the repo and working on it. Now you want to add a file to gitignore which is already checked-in or tracked by Git.(The file is already commited into the repo)

Below are the steps on how to ignore this file (lets say the filename is

  • Add it to .gitignore:

$ echo "" >> .gitignore

tsrivishnu / setup_pgis_server
Last active May 31, 2016 14:49
Script to setup pgis on a new ubuntu machine.
View setup_pgis_server
set -e
# Install required packages
sudo apt-get update
sudo apt-get install -y git unzip \
postgresql-9.3 \
postgresql-9.3-postgis-2.1 \
postgresql-server-dev-9.3 \
tsrivishnu / uniq_addr_imap
Last active August 29, 2015 14:16
Check unique "from" addresses in an IMAP mailbox.
View uniq_addr_imap
#!/usr/bin/env ruby
require 'net/imap'
class String
def string_between_markers marker1, marker2
# Code snippet from
self[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1]
tsrivishnu / tags_display.php
Created September 15, 2012 16:50
displaying the unique tags in a XML RSS Feed using PHP
View tags_display.php
$url = $_GET['feed_url'];
ini_set( "display_errors", 0);
if(@$test = file_get_contents($url))
if($xml = simplexml_load_string($test))
$search = array('<', '>', 'red</font>&gt;');
$replace = array('&lt;<font color=red>', '</font>&gt;','red>');