Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Having Fun

Durga Swaroop Perla durgaswaroop

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

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 Apr 12, 2020
Mocking with Pytest-mock articles
View application1.py
# application1.py
from time import sleep
def is_windows():
# This sleep could be some complex operation instead
sleep(5)
return True
View pandas_groupby_recipes.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View image_resizer.py
#!/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 Oct 28, 2018
Resizes images in one directory and saves them in another directory.
View image_resizer.py
#!/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]):
View image_resizer.py
#!/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 Oct 22, 2018
Sync all dotfiles together starting with vim
View Sync_Dotfiles.md

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 Sep 8, 2018
C-Programming 25 - Building a Calculator with functions
View calculator.c
#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 Jun 13, 2018
Matplotlib related things
View matplotlib_stuff.md

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 Jan 6, 2018
Remove duplicate elements from an array
View remove-duplicates.java
/* 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
You can’t perform that action at this time.