Skip to content

Instantly share code, notes, and snippets.

View AtmaMani's full-sized avatar

Atma Mani AtmaMani

View GitHub Profile
@AtmaMani
AtmaMani / mac-terminal-colors.md
Last active February 26, 2025 12:29
Mac Terminal colors

Get your mac terminal to utilize full color palette

Steps:

1. Edit bash_profile

The color profile of your terminal is stored in .barsh_profile in your home directory. Lets edit that in your terminal:

$ cd ~
$ nano .bash_profile

or if you have sublime text installed using homebrew then:

@AtmaMani
AtmaMani / command_line_args.py
Last active November 3, 2022 23:00
Command line arguments in Python
## just a file to try out command line parsing
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('url', help="Enter portal url of the form: \
https://portalname.domain.com/webadaptor")
#Create optional args by prefixing it with --
#Create short names for same by prefixing it with -
#Specify default values using 'default' argument
@AtmaMani
AtmaMani / dir_walk.py
Last active March 29, 2017 22:24
Walking a directory and collecting all files
import os
data_root = r'root dir to walk down'
for directory, subdir_list, file_list in os.walk(data_root):
print(directory)
print("\t", end="")
print(subdir_list)
print("\t\t", end="")
print(file_list)
===============================================================
@AtmaMani
AtmaMani / new_mac_setup.md
Last active April 30, 2017 14:18
New Mac setup for developers

New Mac setup for developers

How to install applications

I prefer installing app managers and getting apps from them. For instance, it is a lot easier to install apps from Mac App store, however, not all apps are distributed that way. Hence, get brew and cask for brew. brew is a Homebrew project which gives a CLI for installing and updating apps. In no time, you can update and manage apps like you manage Python or Java packages using conda or maven.

Installing brew

Get brew by pasting

@AtmaMani
AtmaMani / fetch_pyvideo.py
Created May 21, 2017 22:21 — forked from codeinthehole/fetch_pyvideo.py
Fetch PyCon videos from pyvideo.org and convert them to M4V so they can be synced to your iPhone
# Hacky script for downloading videos from PyVideo and converting them to m4v
# format so they can be synced onto your apple device. Useful if you
# want to see everything that happened at PyCon while commuting.
#
# Requirements:
# * pip install requests BeautifulSoup
# * youtube-dl (from https://github.com/rg3/youtube-dl/) - add this to the
# directory where this script runs and ensure its execute bit is set.
# This was the only YouTube downloader I found that worked. It doesn't
# really have a good Python API so I call it through os.system.
@AtmaMani
AtmaMani / python-ftp-file-downloader.py
Created May 25, 2017 20:19
python-ftp-file-downloader
import ftplib
# connect to the server
ftp = ftplib.FTP('ftp.ncdc.noaa.gov') #pass the url without protocol
ftp.login() #pass credentials if anonymous access is not allowed
# switch to the directory containing the data
ftp.cwd('/pub/data/swdi/database-csv/v2/')
ftp.pwd()
@AtmaMani
AtmaMani / module_walker.py
Created August 4, 2017 17:51
Python Module walker
# simple python script to walk a module and print publicly accessible identifiers
#Import your library
from arcgis.gis import GIS
import inspect
#instantiate your root object
gis = GIS()
#build up a list of primitive/builtin types to ignore. You can add your custom types as well.
@AtmaMani
AtmaMani / parallel-downloader.py
Created September 11, 2017 23:55
Script to download images in parallel
import requests
from pathlib import Path
import multiprocessing
#read the download file
with open('./download_links.txt','r') as fhandle:
files = fhandle.readlines()
def downloader(url):
img_name = Path(url).name.rstrip('\n')
@AtmaMani
AtmaMani / python-shortcuts.py
Last active August 8, 2022 18:46
Python shortcuts and optimizations
#flatten a list of list
extent = [[-84.28620418884404, 33.98540048952816], [-84.09769613557806, 34.090609514767856]]
flat_list = [element for sublist in extent for element in sublist]
# [-84.28620418884404, 33.98540048952816, -84.09769613557806, 34.090609514767856]
#stringify a list of numbers
stringified_flat_list = ','.join(str(e) for e in flat_list)
# '-84.28620418884404,33.98540048952816,-84.09769613557806,34.090609514767856'
@AtmaMani
AtmaMani / git-pr-review-workflow.md
Last active July 23, 2019 20:54
Push up changes to a PR while reviewing

How to checkout a branch from a fork of your repo?

git remote add <name> <url.git>

This adds the forked repo as a remote. You don't need this if you have merge privileges. You can then fetch and checkout the branch of your choice

git fetch <name or remote>
git checkout  # allow tab completion to help you here.