Skip to content

Instantly share code, notes, and snippets.

View armsp's full-sized avatar
👋

Shantam Raj armsp

👋
View GitHub Profile
@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 / 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 / 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 / Steps.md
Last active May 6, 2019 15:49
Steps to run ARM containers on x86
  • Install qemu-arm-static
  • Pull arm32v7/debian:jessie
  • docker run -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static --rm -it arm32v7/debian:jessie --name rpi-test
  • apt-get update
  • apt-get upgrade
  • apt-get install nano
  • apt-get install binutils apt-utils
  • apt-get install build-essential build-essential in turn installs the following- binutils bzip2 cpp cpp-4.9 dpkg-dev fakeroot g++ g++-4.9 gcc gcc-4.9 ifupdown isc-dhcp-client
@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
@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 / 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())
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):
@armsp
armsp / voice.py
Last active April 3, 2023 17:47
Identifying sentences with passive voices (english) using Spacy
import spacy
from spacy.matcher import Matcher
Active = "Harry ate six shrimp at dinner.\
Beautiful giraffes roam the savannah.\
Sue changed the flat tire.\
We are going to watch a movie tonight.\
I ran the obstacle course in record time.\
The crew paved the entire stretch of highway.\
Mom read the novel in one day.\
@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)