Skip to content

Instantly share code, notes, and snippets.

View durgaswaroop's full-sized avatar
💭
Having Fun

Swaroop durgaswaroop

💭
Having Fun
View GitHub Profile
@durgaswaroop
durgaswaroop / description.md
Created November 8, 2020 15:11
Making a git like command line application with argpase in python

This is just to show how to use argparse to create a git like command line structure. It does not have any actual functionality right now.

Output of --help is shown below in this file. The actual code with argparse will be in the other file of this gist.

 % python git_clone_cmd.py clone --help
usage: git_clone_cmd.py clone [-h] [--template <template_directory>] [--local]
                              <repository> [<directory>]

positional arguments:
@durgaswaroop
durgaswaroop / application1.py
Last active April 12, 2020 17:32
Mocking with Pytest-mock articles
# application1.py
from time import sleep
def is_windows():
# This sleep could be some complex operation instead
sleep(5)
return True
@durgaswaroop
durgaswaroop / pandas_groupby_recipes.ipynb
Last active May 19, 2019 12:37
Pandas Groupby Recipes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@durgaswaroop
durgaswaroop / image_resizer.py
Created October 28, 2018 21:53
Image Resizer.
#!/usr/bin/env python
# coding: utf-8
# Run this from the directory where you see data/.
# %%sh
# ls -F
# data/
# Also create directory data_resized with test and train subdirectories
# %%sh
@durgaswaroop
durgaswaroop / image_resizer.py
Last active October 28, 2018 22:03
Resizes images in one directory and saves them in another directory.
#!/usr/bin/env python
# coding: utf-8
from PIL import Image
from resizeimage import resizeimage
import os
def resize_image(directory, image_name, new_directory, new_dims=[256, 256]):
@durgaswaroop
durgaswaroop / image_resizer.py
Created October 28, 2018 21:53
Image Resizer.
#!/usr/bin/env python
# coding: utf-8
# Run this from the directory where you see data/.
# %%sh
# ls -F
# data/
# Also create directory data_resized with test and train subdirectories
# %%sh
@durgaswaroop
durgaswaroop / Sync_Dotfiles.md
Created October 22, 2018 11:54
Sync all dotfiles together starting with vim

Create directory hard links in Windows:

# Link .vim in the users directory to the .vim in Drive
mklink /J .vim GoogleDrive\DotFiles\.vim # Run from user home directory

# Link vim directories in vimfiles directory to corresponding folders in Drive
mklink /J "C:\Program Files (x86)\Vim\vimfiles\autoload" GoogleDrive\DotFiles\.vim\autoload
@durgaswaroop
durgaswaroop / calculator.c
Created September 8, 2018 20:07
C-Programming 25 - Building a Calculator with functions
#include <stdio.h>
//-- Function Signatures --//
int add(int a, int b);
int sub(int a, int b);
int mul(int a, int b);
int div(int a, int b);
float rdiv(int a, int b);
main() {
@durgaswaroop
durgaswaroop / matplotlib_stuff.md
Last active June 13, 2018 10:33
Matplotlib related things

In Jupyter notebooks %matplotlib notebook sets up the backend to render the visualizations into the browser.

There are several backends for matplotlib including even those that render to hardcopies like svg or png.

Matplotlib's naming conventions are matlabish than pythonic. We use getters and setters.

Layers:

  1. Artist Layer
@durgaswaroop
durgaswaroop / remove-duplicates.java
Created January 6, 2018 17:38
Remove duplicate elements from an array
/* Remove duplicate elements from an array */
// Code inside the method is presented here
int[] numbers = {1, -2, 3, 1, 0, 9, 5, 6, 4, 5};
System.out.println("Input array: " + Arrays.toString(numbers));
Arrays.sort(numbers);
int j = 0; // Slow moving index