Skip to content

Instantly share code, notes, and snippets.

View SureshKL's full-sized avatar

Suresh K L SureshKL

  • Sony India Software Centre Private Limited
  • Bangalore
View GitHub Profile
@SureshKL
SureshKL / Microservices.md
Last active November 18, 2018 14:13
Microservices

Microservices

Microservices are architectural style in which large & complex software applications are composed of one or more smaller services.

Microservices are design principles for an application

Four main characteristics:

  1. Loosely Coupled: The microservices are not tightly dependent on each other
  2. Small & Focused: Each microservice focus on smaller & single task
  3. Language Neutral: One microservice can be written in JAVA for performance benefits and other in Python for quicker deployment
@SureshKL
SureshKL / Design Patterns.md
Last active November 22, 2018 17:27
Design Patterns

Design Patterns

Definition

Design Patterns are solutions to to commonly occurring problems.

We need design patterns to ensure our work is consistent, reliable and understandable.

Examples

  • Building Architecture
  • Electrical and plumbing
@SureshKL
SureshKL / thread_vs_process.py
Created November 21, 2018 18:44
Python Concurrency
import threading
import time
import random
import concurrent.futures
numbers = list(range(1, 11))
def product(num):
for i in range(1, 10000000):
@SureshKL
SureshKL / abstract_factory.py
Created November 22, 2018 17:28
Design Patterns
from __future__ import print_function
from abc import ABCMeta, abstractmethod
class Button:
__metaclass__ = ABCMeta
@abstractmethod
def paint(self):
@SureshKL
SureshKL / generators.ipynb
Created November 22, 2018 18:02
Generators
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SureshKL
SureshKL / python_topics.md
Last active December 7, 2018 02:23
Python Topics Quick Reference

Python Important Topics

Fundamentals

  • list
  • tuple
  • dict
  • set
  • frozen set
  • Builtin functions: map, filter, reduce, vars, zip, enumerate
  • lambda
@SureshKL
SureshKL / get_lines.py
Created December 11, 2018 12:04
Get specified no. of lines from file
def get_lines_in_chunks(file_path: str, chunks: int = 1) -> list:
"""Get specified no. of lines from file
:param chunks: No. of lines (Default=1)
:param file_path: Absolute path to file
:return: list of lines from the file
"""
with open(file_path) as f:
def _get_lines(chunks):
return [f.readline() for _ in range(chunks)]
@SureshKL
SureshKL / method_overriding.py
Created December 11, 2018 12:09
Demonstrating method overriding by custom list concatenation
class ListAddition:
def __init__(self, numbers):
self.x = numbers
def __add__(self, other):
return [self.x, other.x]
x = ListAddition([1, 2, 3])
@SureshKL
SureshKL / bottle_demo.py
Last active December 28, 2018 09:41
Bottle: Login/Logout/File Upload/Download Demo
"""Bottle framework demonstration
Below items are demonstrated here:
==================================
- Login/Logout using cookies
- File upload/download
- Hooks
- Plugins
- 404 error handling
- Jinja2 template usage
@SureshKL
SureshKL / getter.py
Created December 18, 2018 03:48
Attribute Lookup
import sys
class CommonAttributes:
def __init__(self):
self.name = 'common'
class MissingAttributes:
def __init__(self):