Skip to content

Instantly share code, notes, and snippets.

View santosh's full-sized avatar
:octocat:

Santosh Kumar santosh

:octocat:
View GitHub Profile
@santosh
santosh / Qt5_Whatsnew.md
Created June 1, 2018 21:16
What's new in Qt 5?
@santosh
santosh / decorators.py
Last active May 21, 2018 19:33
Procedurally learning the decorators.
def greeting(expr):
def greeting_decorator(func):
def function_wrapper(x):
print(expr + ", " + func.__name__ + " returns:")
func(x)
return function_wrapper
return greeting_decorator
@greeting("καλημερα")
def foo(x):
@santosh
santosh / zip.py
Created May 9, 2018 03:04
Zip module test case
import zipfile
zip = zipfile.ZipFile('Archive.zip', 'r')
print(zip.namelist())
for meta in zip.infolist():
print(meta)
print(zip.read(("wishlist.txt")))
@santosh
santosh / itertool.py
Created May 9, 2018 02:47
Itertools module test use.
import itertools
for x in itertools.count(50, 5):
print(x)
if x == 80:
break
for x in itertools.count(50):
print(x)
if x == 80:
@santosh
santosh / rand.py
Created May 9, 2018 02:33
Random module use cases.
import random
print(random.sample(range(100), 5))
print(random.sample(["Fish", "Dog", "Cat"], 1))
print(random.choice(["Fish", "Dog", "Cat"]))
pets=["Fish", "Dog", "Cat", "Parrot"]
random.shuffle(pets)
print(pets)
@santosh
santosh / js_global_functions.txt
Last active May 8, 2018 03:09
List of #JavaScript global functions.
length() : specifies the string length
split(char) : splits the string by char
trim() : trims whitespaces from start and end
toUpperCase() : upper cases the entire string
toLowerCase() : lower cases the entire string
Mathematical:
parseInt() :
parseFloat() :
toFixed(int) : pads with zero else acts as round(); returns string
@santosh
santosh / pythonBuiltInfunction.txt
Last active April 29, 2018 22:18
Python's builtin functions.
Interpreter candy
help() - help for specified object
dir() - like ls for a class
type() - object type
print() - print object
len() - length of object
id() - returns id of an object
input() - takes input from stdin
exec()
range() - sequence type
@santosh
santosh / animPipeline.py
Created March 14, 2018 11:13
Creates pipeline structure for common vfx works. v0.1
# Upgrade to Python 3.
import os
os.makedirs("plates/jpg", exist_ok=True)
os.makedirs("plates/exr", exist_ok=True)
os.makedirs("roto/renders", exist_ok=True)
os.makedirs("matchmove", exist_ok=True)
@santosh
santosh / logging_in_python.py
Created January 23, 2018 04:04
Simplest form of logging in Python.
import logging
# logging levels
# https://docs.python.org/3.6/library/logging.html#logging-levels
# https://docs.python.org/3.6/library/logging.html#logrecord-attributes
logging.basicConfig(filename='logger.log',
filemode='w',
format='%(lineno)d %(levelname)s: %(asctime)s %(funcName)s %(message)s %(thread)d',
level=logging.WARNING)
import threading
import time
def calc_square(numbers):
print("calculate square numbers")
for n in numbers:
time.sleep(0.2)
print('square', n*n)
def calc_cube(numbers):