You can download original Jupyter notebook file for this project from my Github repo US2016_Election_Donations In [1]: # By Maxim Shen July 1st 2016 # # This project tries to compare and visualize public donations # for Hilary Clinton and Donald…

# Solve Memory Leak 101

Recently, I was discussing with a few different people about memory leak. At first, for languages like C#, Java, etc, they all use managed memory and everything (managed resources) is garbage collected if those managed types are no longer reachable.…

# Web Plotting using Bokeh in Python 101

webIntegration In [1]: ################################################# # Web Plotting using Bokeh in Python # # In this tutorial, we will cover Bokeh usage # # 1. static plots # # 2. interactive plots # ################################################# ################################################# # 1. Static Plots # ################################################# import…

# Lazy Initialization Thread Safe & Auto Thread Safe for Singleton Pattern

We all know what Singleton Pattern is, one Class can’t allow more than one instance created. Now, we start from simple Singleton pattern implementation, then find different ways of making thread safe singleton class. First, basic Singleton Pattern /** *…

# Financial Time Series in Python using Pandas

high_frequency In [1]: ###################################################### # Financial Time Series in Python using Pandas # ###################################################### # This time we will cover # 1) Series in Pandas # 2) Dataframe in Pandas # 3) An example with more Pandas operations and ols regression…

# I/O operations for different data formats – using Python 3.X, Numpy, Pandas

Under construction … io_operations In [1]: # By Maxim Shen June 17th 2016 # # Python becomes more and more popular these days. Therefore, I try to # illustrate some topics covering python I/O involving different data # formats, with the…

# Elegant Algorithmic Crush – USing 1) difference array & 2) prefix sum

Today, I got a chance to come across a pretty elegant solution, involving 1) calculating difference array and 2) find ongoing prefix sum, in order to solve one problem from hackerrank.com First, here comes the problem. /* You are given…

# Better way to find all prime numbers less than N & time complexity O(log(log(N)))

Normally, when we need to find all prime numbers upto or less than user input N, we need total time complexity of O(N*sqrt(N)), because we use “trial division” to verify primality. Code as below in Java. public int countPrimes(int N){…

# Use Bitwise Operations in Java/C# and C/C++

From time to time, bitwise operation could be useful or just for fun … 1) Tell if a number is odd/even Let’s take integer 19 for example. In binary 19 is 00010011, so, 00010011 00000001 (00000001 is 1 in binary)…

# Huffman EnCoding – Greedy Compressing Algorithm

(I came across an interesting problem from Hackerank.com. Say you are given a string of “101010…00101” with fixed length and a binary tree of nodes, each node has its own left and right child, data and frequency. You are expected…