Skip to content

Instantly share code, notes, and snippets.

View sagarr's full-sized avatar
👨‍💻
% no comment %

Sagar Rohankar sagarr

👨‍💻
% no comment %
View GitHub Profile
@sagarr
sagarr / zoom.1s.scpt
Created June 25, 2022 10:05
swiftbar for mac mute status bar
#!/usr/bin/osascript
# <bitbar.title>Mute/Video/Screen State for Zoom</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>nickjvturner</bitbar.author>
# <bitbar.author.github>nickjvturner</bitbar.author.github>
# <bitbar.desc>Mute/Video/Screen State for Zoom</bitbar.desc>
# <bitbar.dependencies>Applescript</bitbar.dependencies>
# <swiftbar.hideAbout>true</swiftbar.hideAbout>
@sagarr
sagarr / LRUCache.py
Created April 27, 2021 19:51
LRUCache
#
#
# Implement a LRU cache
# key, value
# bounded -> not more than 'n' entries
# If cache is full, and you want to add another key value pair,
# oldest accessed entry will be removed
#
# Operations like get, put, remove are constant time.
#
@sagarr
sagarr / read-access.sql
Created October 5, 2018 09:49 — 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;
@sagarr
sagarr / howto_gis_ubuntu.md
Created August 25, 2018 10:12 — forked from ansell/howto_gis_ubuntu.md
Ubuntu-16.04/Mint-18 GIS hackery

Add ubuntugis PPA:

$ sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable

Add POSTGIS repository:

$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
package com.rohankar.tourist;
import io.vavr.Tuple3;
import io.vavr.collection.Stream;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.List;
@sagarr
sagarr / cuda-dl-setup.sh
Last active January 11, 2018 08:45 — forked from payshangjj/waya-dl-setup.sh
Install CUDA Toolkit v8.0 and cuDNN v6.0 on Ubuntu 16.04
#!/bin/bash
# install CUDA Toolkit v8.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network))
CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb"
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG}
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-get update
sudo apt-get install cuda-8-0
package com.rohankar.problem;
public class WallAndWater {
public static int findWaterFilled(int[] walls) {
int maxWallIndex = findMaxWallHeightIndex(walls);
int volOnLHS = findWaterFilledOnLHS(walls, maxWallIndex);
int volOnRHS = findWaterFilledOnRHS(walls, maxWallIndex);
return volOnLHS + volOnRHS;