Select Page

Python Tips: Instance, Class, and Static Methods

class SomeClass: def instancemethod(self): return ‘instance method called’, self @classmethod def classmethod(cls): return ‘class method called’, cls @staticmethod def staticmethod(): return ‘static method called’ Instantiate...

Linux Basics

Sed Replace the first occurrence of a string in a file, and print the result sed ‘s/find/replace/’ filename Replace all the occurrences of a string in a file, and print the result sed ‘s/find/replace/g’ filename Replace all occurrences of an...

Git Tips: git diff without a/ b/ prefixes

Intro Prefixes a/ and b/ represents source and destination file paths. git diff man page: https://git-scm.com/docs/git-diff It is typical to copy the file name with double-click select and paste or ctrl/cmd+click open directly in your favorite editor. But, prefixes a/...

JSON Parsing with jq

Considering cat file.json be any JSON input from a file or API response, etc. Read the whole file with JSON aware viewer jq ‘.’ file.json # OR cat file.json | jq ‘.’ The rest of the write-up assumes the file being read with cat format before...

Trailing slash in URLs: Slash or No-slash

Trailing slash is a forward slash at the end of the web page URL. The convention is URL ending with a slash denotes the URL pointing to a directory otherwise, it points to a file. Not having a trailing tear is preferable mainly due to ease of use. Web standards has...

Scalability Golden Rules

Clones It is a form of horizontal scaling. Public servers are hidden behind a load balancer, evenly distributing load (requests from your users) onto your group/cluster of application servers. Every server contains the same codebase and does not store user-related...

Python Tips: Dictionary

Example dict flat_hash = {   ‘key1’: ‘value1’,   ‘key2’: ‘value2’ } nested_hash = {   ‘rootkey’: {     ‘subkey1’: ‘value1’   } } Print dictionary print(flat_hash) print(nested_hash)...

Python Notes

Exception handling try:   # Do something except Exception as e:   # Handle it Print array of strings print “”\n””.join(arr) Iterating by index for i in range(len(arr)):   print arr[i] Passing CLI arguments import sys print(sys.argv[0]) Using...

Check domain availability on CLI using AWS Route53

Prerequisites AWS CLI https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html Active AWS access keys – access key ID and secret access key Configure AWS CLI Use command aws configure aws configure # AWS Access Key ID [****************MPLE]:...