Skip to content

Instantly share code, notes, and snippets.

View amitt001's full-sized avatar

Amit Tripathi amitt001

View GitHub Profile
@amitt001
amitt001 / subprocess
Created April 6, 2016 04:30
Python subprocess module details
Subprocess:
One class Popen and others are wrapper over it.
shell=True: This argument spawns a new intermediate process and run the command. If False, the command run in current process.
Popen: non blocking
subprcess call vs Popen:
call: is a wrapper over Popen and takes all the pamaters of popen. It is blocking and does not return until process has finished.
@amitt001
amitt001 / REST.rst
Last active April 27, 2016 17:02
REST API design principals

REST Design Important Points:

1. Use Nouns but no Verbs
Ex: /cars, /cars/23 ... Correct

/getCarData, /get/car/data ... wrong

  1. GET method & query parameter should not alter the state use PUT, POST and DELETE for changing the state
  2. Do not mix up singular and plural nouns use only plural nouns
@amitt001
amitt001 / Scala.rst
Last active May 19, 2016 12:57
Scala Notes

Functions

List Operations:

++ == extends

:+ == append

OOP and Design Pattern:

Association, Aggregation and Composition:

The distinction between aggregation and composition goes to old times for language like C++ where there is manual memory management. For languages with dynamic memory management everything is compositon.

Association: Multiple objects have their own life cycle and there is no owner. Ex teacher and student, independent life cycle.

Copy(resume) data from localhost to server:

rsync --partial --progress dump.tar.gz wkalt:wkdump

@amitt001
amitt001 / Devstack
Created September 24, 2016 18:01
Set up devstack
VBox: http://linoxide.com/linux-how-to/setup-centos-7-vagrant-base-box-virtualbox/
OR
Vagrant centos: https://atlas.hashicorp.com/relativkreativ/boxes/centos-7-minimal
@amitt001
amitt001 / gist:3b2c3996784d1e32786044a4f15f99eb
Created February 23, 2017 07:44 — forked from drorata/gist:146ce50807d16fd4a6aa
Minimal Working example of Elasticsearch scrolling using Python client
# Initialize the scroll
page = es.search(
index = 'yourIndex',
doc_type = 'yourType',
scroll = '2m',
search_type = 'scan',
size = 1000,
body = {
# Your query's body
})
OpenSubtitles.org has apparently updated their servers. That uncovered latent bugs in the very dumb HTTP support of the VLSub extension.
To work around the problem (you might need administrator privileges):
Go to the VLC installation directory.
Look for the file named lua/extensions/VLSub.luac.
Open that file in a binary or hexadecimal editor. (DO NOT USE a text editor.)
Look for the character sequence "HTTP/1.1" (without quotes).
Replace the last one by a zero: "HTTP/1.0".
Repeat the procedure; there should be a second occurence in the file.
Save the file.
import sys
import time
from kubernetes import config, client
class KubeControl:
def __init__(self):
# config.load_kube_config(context='staging')
config.load_kube_config()
@amitt001
amitt001 / docker-compose.yaml
Created March 22, 2019 08:25
Kafka Cluster Docker compose
version: '2'
services:
zookeeper-1:
image: confluentinc/cp-zookeeper:latest
hostname: zookeeper-1
ports:
- "12181:12181"
environment:
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_CLIENT_PORT: 12181