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

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
development

consul-vault: Fun with CLI

consul-vaulttools have a graphical and command line interfaces. I found CLI faster for development. So I’m sharing how to setup and use consul. Steps Set consul and vault path. export VAULT_ADDR=https://xxxx export CONSUL_HTTP_ADDR=xxxx Login to vault vault login -method=github -path=github Install consul-template. Run the template. consul-template -vault-renew-token=false -template “./config.tmpl:/tmp/out.json” -log-level debug You can also access […]

Read more