Skip to content

Instantly share code, notes, and snippets.

View riteshshrv's full-sized avatar
🎯
Focusing

Ritesh Shrivastav riteshshrv

🎯
Focusing
  • Zerodha
  • Bangalore
View GitHub Profile
@riteshshrv
riteshshrv / mon.sh
Created July 23, 2019 07:45 — forked from rosshadden/mon.sh
Mixed non/HiDPI monitors in X
#!/usr/bin/env bash
numDisplays=$(xrandr --current | grep '\bconnected' | wc -l)
outputs="--output eDP1 --primary --mode 2880x1620 --pos 2880x0 --dpi 96 --scale 1x1"
xrandr --output HDMI1 --off
xrandr --output DP2 --off
if xrandr | grep "HDMI1 connected"; then
outputs+=" --output HDMI1 --auto --mode 1920x1080 --pos 0x0 --right-of eDP1 --scale 1.5x1.5"
@riteshshrv
riteshshrv / read-access.sql
Created February 20, 2019 08:11 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@riteshshrv
riteshshrv / Xresources
Created July 17, 2018 06:03
my xresources
Xft.dpi: 96
Xft.antialias: true
Xft.hinting: true
Xft.rgba: rgb
Xft.autohint: false
Xft.hintstyle: hintslight
Xft.lcdfilter: lcddefault
XTerm*background: #222D31
XTerm*foreground: #d8d8d8
@riteshshrv
riteshshrv / Private-pypi-howto
Created June 18, 2018 16:37 — forked from Jaza/Private-pypi-howto
Guide for how to create a (minimal) private PyPI repo, just using Apache with directory autoindex, and pip with an extra index URL.
*
@riteshshrv
riteshshrv / csvdta.go
Created June 7, 2018 18:28 — forked from stevedonovan/csvdta.go
A Go package which reads structure data from CSV data using reflection
package csvdata
// csvdata complements the csv package by allowing you to map a custom structure to
// the columns of data in a CSV file. The struct needs to be annotated so that each
// field can match a column in the data
//
// type Person struct {
// FirstName string `field:"First Name"`
// Second_Name string
// Age int
// }
@riteshshrv
riteshshrv / Free O'Reilly Books.md
Created October 24, 2017 17:18 — forked from augbog/Free O'Reilly Books.md
Free O'Reilly Books

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.
@riteshshrv
riteshshrv / byobuCommands
Created July 11, 2017 08:49 — forked from jshaw/byobuCommands
Byobu Commands
Byobu Commands
==============
byobu Screen manager
Level 0 Commands (Quick Start)
------------------------------
<F2> Create a new window
@riteshshrv
riteshshrv / tmux.md
Created July 11, 2017 08:49 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@riteshshrv
riteshshrv / print_table.py
Created March 3, 2017 05:14 — forked from lonetwin/print_table.py
print out ascii tables in python using data in the form: [ ('column 0 title', 'column 1 title' ..), ('row 0, column 0 data', 'row 0, column 1 data' ...) ...]
# I needed to print out ascii tables from data in the form:
# [ ('column 0 title', 'column 1 title' ..),
# ('row 0, column 0 data', 'row 0, column 1 data' ...) ...]
#
# and surprisingly it got complicated because of variable lengths of the data.
# I googled for 'standard' ways of doing this and I found suggestions like:
# http://stackoverflow.com/questions/5909873/python-pretty-printing-ascii-tables
# ...which were a bit dated and hard to read or full scale modules like:
#
# http://pypi.python.org/pypi/texttable/

Keybase proof

I hereby claim:

  • I am riteshshrv on github.
  • I am riteshshrv (https://keybase.io/riteshshrv) on keybase.
  • I have a public key ASDWkpzpQntCgL2DtmZRmberbNh4im_yCeCLwm5upM75hQo

To claim this, I am signing this object: