Skip to content

Instantly share code, notes, and snippets.

View mohit2152sharma's full-sized avatar
🏠
Working from home

Mohit Sharma mohit2152sharma

🏠
Working from home
View GitHub Profile
@mohit2152sharma
mohit2152sharma / is_python_project.sh
Last active August 20, 2024 04:28
Script to check if the given directory is a python project or not. (Assumes it to be a python project if there exists `requirements.txt` or `pyproject.toml` or any file ending with `.py`
is_python_project() {
local dir=$1
local filename
filename=$(basename "$dir")
# assumes a directory is a python project, if it has files which are usually found in python project root directory like
# requirements.txt, pyproject.toml and setup.py
if [[ -f "$dir"/requirements.txt || -f "$dir"/pyproject.toml || -f "$dir"/setup.py || "$filename" == *.py ]]; then
echo "${dir} is a python project"
return 0
@mohit2152sharma
mohit2152sharma / redis-cluster-local
Created January 18, 2024 06:10
Running Redis Cluster on macos locally
#!/bin/sh
# when installing redis from brew, it doesn't come with `utils` folder
# and because of which it's rather difficult to run redis cluster locally
# (`utils` folder has `create-cluster` script files, which automate the creation
# startup, stopping of redis cluster)
# this script is a workaround for that, basically, it checks if `utils` folder is
# there or not, if not, it downloads it and makes the necessary changes
# it assumes, you are running this on macos, with zsh shell
@mohit2152sharma
mohit2152sharma / anscombe_quartet.md
Last active September 6, 2020 11:40
anscombe quartet plotting and summarizing
library(ggplot2)
library(patchwork)
library(tidyr)
library(magrittr)
library(dplyr)

datasets::anscombe
#>    x1 x2 x3 x4    y1   y2    y3    y4
#> 1  10 10 10  8  8.04 9.14  7.46  6.58
population = rnorm(1000, mean = 10, sd = 1)

samples = replicate(100, sample(population, size = 10))

ext.confid.interval = function(s, mu){
confid.intervals = apply(s, 2, t.test, mu = mu)
n.samples = dim(s)[2]
lower.bound = vapply(confid.intervals, function(x) x$conf.int[1], FUN.VALUE = 100)
upper.bound = vapply(confid.intervals, function(x) x$conf.int[2], FUN.VALUE = 100)