development

Pascal Triangle

def generate(self, numRows): “”” :type numRows: int :rtype: List[List[int]] “”” answer = [] if numRows == 0: return [] row = [1] answer.append(row) for x in range(2, numRows+1): # Prepare the row row = [1]*x # The first and last element on each row is 1, so skip those # indexes. for y in range(1, […]

Read more
development

Notes on Memory Mapped Files using mmap

Introduction mmap maps a file to a process virtual address space. The file blocks are loaded as needed, in units of the system page size. Each I/O must align with the page size. A block load is handled as a page fault. mmap() can provide a private or shared mapping of a region. mmap() to […]

Read more
development

Check Two Strings are Anagrams?

class Solution(object): def isAnagram(self, s, t): “”” :type s: str :type t: str :rtype: bool “”” # Keep a frequency array frequency = {} for c in s: if c not in frequency: frequency[c] = 1 else: frequency[c] += 1 # Go over the other string for d in t: if d in frequency: frequency[d] […]

Read more
development

Top 5 VSCode Extensions for Vim Lovers

Vim Extensions vscodevim: Vim emulation for Visual Studio Code Better Align (: + = in visual mode) Language Specific Extensions C/C++ C/C++ IntelliSense, debugging, and code browsing. Better C++: better-cpp-syntax Golang Go Microsoft Go Group Imports Go Critic Python Python Microsoft Python Extension Pack Ruby Ruby for Visual Studio Code Rubocop Ruby Solargraph Themes Github […]

Read more
development

Simplistic API Rate Limiter in Python

The Rate Limiter is a per-minute request limiter. It allows up to 1000 events in a minute and does not roll over the underutilized capacity to the next minute. It uses a Hashmap to keep track of per second requests. The idea is to extend the code for roll-over capacity to the next minute. from […]

Read more