Skip to content

Instantly share code, notes, and snippets.

View armsp's full-sized avatar
👋

Shantam Raj armsp

👋
View GitHub Profile
@armsp
armsp / script.py
Created May 6, 2018 07:29
Automate certificate conversion from .cer to .pem via openssl using Python. An automated solution for Docker issue error x509: certificate signed by unknown authority
import os
path = "C:/Users/username/path/to/your/folder"
file_list = os.listdir(path)
file_list_no_extension = [os.path.splitext(x)[0] for x in file_list]
for i,j in zip(file_list,file_list_no_extension):
command_list = []
command1 = "openssl x509 -inform der -in "
command2 = " -out "
command3 = ".pem"
command_list.append(command1)
@armsp
armsp / doublyLinkedList.c
Last active May 9, 2018 18:16
Doubly linked list implemented in C without any global variables.
#include <stdio.h>
#include <stdlib.h>
#include "doublyLinkedList.h"
Node* createnode(){
Node* node = malloc(sizeof(*node));
return node;
}
void addNode(Node** head, int info){
@armsp
armsp / download pdf.py
Created May 12, 2018 05:00
Script that automates downloads of a certain set of pdf documents from http://www.ti.com/analog-circuit/circuit-cookbook.html
# pdf File downloader for TI Links
from bs4 import BeautifulSoup
import requests
import urllib3
import re
import os
DOWNLOAD_FOLDER = os.path.join("D:",os.sep,"electronics","TI_pdfs")
os.mkdir(DOWNLOAD_FOLDER)
@armsp
armsp / resume_upload.py
Created July 4, 2018 04:54
Resuming file uploads in flask
import hashlib
full_file = 'isd-inventory.csv'
part_file = 'isd-inventory.csv.part'
m = hashlib.md5()
with open(full_file, 'rb') as f:
for chunk in iter(lambda: f.read(128*m.block_size), b''):
m.update(chunk)
print(m.hexdigest())
@armsp
armsp / Dockerfile
Last active August 25, 2018 10:03
Dockerfile to install python, pandas, sklearn, numpy, scipy on a ubuntu 18.10 container (works under restricted ssl certificate environments too)
FROM ubuntu:18.10
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends apt-utils software-properties-common wget \
&& apt-get install -y build-essential python3 python3-distutils \
&& wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py \
&& python3 get-pip.py --trusted-host pypi.org --trusted-host files.pythonhosted.org
#RUN apt-get install python3.6 python-pip
#RUN python -m pip install pip --upgrade
#RUN python -m pip install wheel
#RUN apt-get install -y python3-numpy
@armsp
armsp / HTTP status codes.md
Created August 26, 2018 09:57
Proper way to return HTTP status codes with custom messages when a restful API on Flask server fails while processing inputs.

HTTP Error Codes

  • 1xx : Informational
  • 2xx : Success
  • 3xx : Redirection
  • 4xx : Client Error
  • 5xx : Server Error

HTTP Status Codes from MDN

200 OK

@armsp
armsp / punch.py
Created August 29, 2018 16:04 — forked from koenbollen/punch.py
Proof of Concept: UDP Hole Punching
#!/usr/bin/env python
#
# Proof of Concept: UDP Hole Punching
# Two client connect to a server and get redirected to each other.
#
# This is the client.
#
# Koen Bollen <meneer koenbollen nl>
# 2010 GPL
#
@armsp
armsp / Poetry_magazines.md
Last active September 9, 2018 06:06
A list of curated magazines that accept poetry. Work in progress.

Poetry Foundation

  • Year round submissions
  • Provide handsome compensation
  • Submissions
  • Response Time : 7 months

VQR

  • Peading Period: July 1-31
  • Very handsome Compensation
  • Submissions
@armsp
armsp / docker-compose.yaml
Last active September 16, 2018 19:03
Experiments with docker-compose
version: '3'
services:
client:
#image: ubuntu:18.10
# build : This directive can be used instead of image. Specifies the location of the Dockerfile that will be used to build this container
build: ./
container_name: Chat_client
volumes:
- ./:/code
class fish:
def __init__(self,name):
self.name = name
self.skeleton = "bones"
def swims(self):
print(self.name, "swims")
def eyes(self):
print(self.name, "has eyelids")
class salmon(fish):