Skip to content

Instantly share code, notes, and snippets.

Durga Swaroop Perla durgaswaroop

View GitHub Profile
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
@durgaswaroop
durgaswaroop / tweeter.py
Created Dec 31, 2017
Tweet from Python
View tweeter.py
import tweepy
import os
import re
import CommentParser
import sys
import subprocess
import yaml
def tweet(html_file, post_url):
@durgaswaroop
durgaswaroop / medium_publish.py
Created Dec 31, 2017
Publish post on Medium
View medium_publish.py
import json
import requests
import os
import sys
def publish(html_file, title, labels):
access_token_file = '~/.medium-access-token'
expanded_path = os.path.expanduser(access_token_file)
print(expanded_path)
@durgaswaroop
durgaswaroop / blogger_modifications.py
Created Dec 31, 2017
Modifications needed to be done on html generated by pandoc for blogger
View blogger_modifications.py
import sys
import os
import fileinput
# alias modifications="python ~/Desktop/30DaysOfBlogging/modifications.py"
# Run the script with `modifications <markdown file>`
def modify(html_file):
# If file doesnot exist, just exit
You can’t perform that action at this time.