Skip to content

Instantly share code, notes, and snippets.

Avatar

Sri Vishnu Totakura tsrivishnu

View GitHub Profile
@tsrivishnu
tsrivishnu / tags_display.php
Created Sep 15, 2012
displaying the unique tags in a XML RSS Feed using PHP
View tags_display.php
<?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>');
@tsrivishnu
tsrivishnu / uniq_addr_imap
Last active Aug 29, 2015
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 http://stackoverflow.com/a/9661504/976880
self[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1]
end
end
@tsrivishnu
tsrivishnu / setup_pgis_server
Last active May 31, 2016
Script to setup pgis on a new ubuntu machine. https://github.com/OpenGridMap/pgis
View setup_pgis_server
#!/bin/bash
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
tsrivishnu / gitignore_already_tracked_file.md
Last active May 9, 2021
Git: Ignore already checked in file
View gitignore_already_tracked_file.md

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 config.py):

  • Add it to .gitignore:

       $ echo "config.py" >> .gitignore
@tsrivishnu
tsrivishnu / click_allow.scpt
Last active Jul 16, 2018 — 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
tsrivishnu / sed-extract-matched-strings-from-file.md
Last active Feb 11, 2021
`sed` to extract matched strings from a file
View sed-extract-matched-strings-from-file.md

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
tsrivishnu / ubuntu_thinkpad_trackpoint_scrolling.md
Last active Feb 16, 2021
How to enable Middle button (plus Trackpoint) scrolling on Thinkpad T440p running Ubuntu 16.04
View ubuntu_thinkpad_trackpoint_scrolling.md

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
tsrivishnu / usefull-web-links-germany.md
Last active Oct 22, 2020
Useful links when you live in Germany
View usefull-web-links-germany.md
@tsrivishnu
tsrivishnu / docker-increase-inotify-max-user-watches.md
Last active Jun 8, 2021
Increase inotify watchers in Docker images during build
View docker-increase-inotify-max-user-watches.md

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
tsrivishnu / resources-to-get-familiar-with-webpacker-webpack-rails.md
Last active Jul 26, 2020
Resources to get familiar with Webpacker, Webpack and Rails
View resources-to-get-familiar-with-webpacker-webpack-rails.md

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?