Skip to content

Instantly share code, notes, and snippets.

@chandraseta
chandraseta / miracle_sort.py
Last active February 5, 2022 04:30
Implementation of Miracle Sort in Python
from time import sleep
from typing import List
def miracle_sort(items: List, reverse: bool = False) -> List:
""" Sorts a list, powered by miracles
Args:
items (List): list of items to be sorted
@chandraseta
chandraseta / stalin_sort.py
Last active February 5, 2022 04:30
Implementation of Stalin Sort in Python
from typing import List
def stalin_sort(items: List, reverse: bool = False) -> List:
""" Sorts a list, some items may or may not be missing.
"A single death is a tragedy; a million deaths is a statistic."
- Joseph Stalin
Args:
@chandraseta
chandraseta / sensible.vim
Created March 12, 2021 05:03
Tim Pope's vim-sensible
" sensible.vim - Defaults everyone can agree on
" Maintainer: Tim Pope <http://tpo.pe/>
" Version: 1.2
if exists('g:loaded_sensible') || &compatible
finish
else
let g:loaded_sensible = 'yes'
endif
@chandraseta
chandraseta / environment.yml
Created September 27, 2020 16:13
Example of unsorted complex conda environment
name: complex_env
channels:
- defaults
dependencies:
- pip=20.2.2
- python=3.8.5
- pip:
- numpy==1.19.1
- pandas==1.1.1
- tensorflow==2.3.0
@chandraseta
chandraseta / environment.yml
Last active September 27, 2020 12:48
Example of simple Miniconda environment
name: simple_env
dependencies:
- python
- pip:
- flask
- numpy
- pandas
- pylint
- redis
- requests
@chandraseta
chandraseta / environment.yml
Last active September 27, 2020 12:48
Example of complex Miniconda environment
name: complex_env
channels:
- defaults
dependencies:
- pip=20.2.2
- python=3.8.5
- pip:
- flask==1.1.2
- numpy==1.19.1
- pandas==1.1.1
@chandraseta
chandraseta / terminal_upgrade.sh
Last active August 2, 2021 05:40
MacOS Terminal upgrade script
#!/bin/bash
# homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# zsh
brew install zsh zsh-completions
# oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
@chandraseta
chandraseta / process_files_v2.py
Last active July 15, 2020 13:11
Python script to read and write files with program chaining
import sys
lines = []
for line in sys.stdin:
lines.append(line.rstrip('\n'))
outputs = []
for line in lines:
# process line
@chandraseta
chandraseta / process_files.py
Last active July 15, 2020 11:01
Python script to read and write files with argument
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-i','--input', type=str, help='input filepath', required=True)
parser.add_argument('-o','--output', type=str, help='output filepath', required=True)
args = vars(parser.parse_args())
lines = []
with open(args['input']) as ff:
@chandraseta
chandraseta / process_file.py
Last active July 15, 2020 11:02
Python script to read and write file
lines = []
with open('data/input01.txt') as ff:
lines = [line.rstrip('\n') for line in ff]
outputs = []
for line in lines:
# process line
outputs.append(line)
with open('out/output01.txt') as ff: