Skip to content

Instantly share code, notes, and snippets.

@leonmak
leonmak / set_gopath.sh
Created June 11, 2018 02:07
go environment setup for gotchas
# . set_gopath.sh
export GOPATH=`pwd`
export PATH="$GOPATH/bin:$PATH"
# for mac osx
# export GOBIN=$GOPATH/bin
# unset if `flogo build`
git config --global --unset alias.gb
@leonmak
leonmak / setup.md
Last active November 2, 2018 00:56
Setup ssh in remote VM

In VM

sudo adduser ubuntu
sudo su ubuntu
cd /home/ubuntu

mkdir .ssh
chmod 700 .ssh

cd .ssh
@leonmak
leonmak / alien_dict.py
Created January 30, 2019 07:58
269. Alien Dictionary
from collections import defaultdict
class Solution(object):
def alienOrder(self, words):
"""
:type words: List[str]
:rtype: str
"""
graph = defaultdict(list)
@leonmak
leonmak / lc-locked.csv
Created February 1, 2019 05:41
leetcode locked questions
id difficulty title
253 Medium Meeting Rooms II
269 Hard Alien Dictionary
681 Medium Next Closest Time
159 Hard Longest Substring with At Most Two Distinct Characters
642 Hard Design Search Autocomplete System
158 Hard Read N Characters Given Read4 II - Call multiple times
683 Hard K Empty Slots
716 Easy Max Stack
755 Medium Pour Water
@leonmak
leonmak / udfs.py
Created March 4, 2019 03:18
Union Disjoint Find Set
# if not root, find parent, set parent, return parent
p = map(chr, range(n))
def find(p, x):
if p[x] != x:
p[x] = find(p, p[x])
return p[x]
def union(p, i, j):
pi, pj = find(p, i), find(p, j)
@leonmak
leonmak / udfs.py
Created March 4, 2019 03:18
Union Disjoint Find Set
# if not root, find parent, set parent, return parent
p = map(chr, range(n))
def find(p, x):
if p[x] != x:
p[x] = find(p, p[x])
return p[x]
def union(p, i, j):
pi, pj = find(p, i), find(p, j)
@leonmak
leonmak / udfs.py
Created March 4, 2019 03:18
Union Disjoint Find Set
# if not root, find parent, set parent, return parent
p = map(chr, range(n))
def find(p, x):
if p[x] != x:
p[x] = find(p, p[x])
return p[x]
def union(p, i, j):
pi, pj = find(p, i), find(p, j)
@leonmak
leonmak / mac_word_move.plist
Last active May 30, 2019 05:59
iterm2 mac profile - word movement, deletion and pane selection
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AlternateMouseScroll</key>
<true/>
<key>AppleAntiAliasingThreshold</key>
<integer>1</integer>
<key>AppleScrollAnimationEnabled</key>
<integer>0</integer>
@leonmak
leonmak / pecs.java
Last active May 26, 2020 06:07
Producer extend Consumer super
import java.util.ArrayList;
import java.util.List;
class Scratch {
class Shark {
private final String name = "Sharkie";
public String getName() { return name; }
}// A
class HammerShark extends Shark{
@leonmak
leonmak / auth.js
Last active May 24, 2021 14:05
chrome extension login id token
// need to use launchWebAuthFlow in chrome extension
// can't use gapi in extension
// https://github.com/google/google-api-javascript-client/issues/64
async function getIdTokenInfo(id_token: string) {
const resp = await fetch(
`https://oauth2.googleapis.com/tokeninfo?id_token=${id_token}`
);
return resp.json();
}