Skip to content

Instantly share code, notes, and snippets.

View aljorhythm's full-sized avatar
💻
👥

Joel Lim aljorhythm

💻
👥
View GitHub Profile
@aljorhythm
aljorhythm / kubectl-shortcuts.sh
Created March 9, 2022 09:19 — forked from tamas-molnar/kubectl-shortcuts.sh
aliases and shortcuts for kubectl
alias kc='kubectl'
alias kclf='kubectl logs --tail=200 -f'
alias kcgs='kubectl get service -o wide'
alias kcgd='kubectl get deployment -o wide'
alias kcgp='kubectl get pod -o wide'
alias kcgn='kubectl get node -o wide'
alias kcdp='kubectl describe pod'
alias kcds='kubectl describe service'
alias kcdd='kubectl describe deployment'
alias kcdf='kubectl delete -f'
@aljorhythm
aljorhythm / merge.go
Created June 30, 2021 02:40
golang merge json raw messages / maps
package merge
// quick and dirty merge of two json raw messages
// does not merge two json arrays
// MergeJson merges two json raw messages. If key
// exists in both maps, value from first argument will take precendence.
func MergeJson(json1 *json.RawMessage, json2 *json.RawMessage) (*json.RawMessage, error) {
map1 := map[string]interface{}{}
map2 := map[string]interface{}{}
@aljorhythm
aljorhythm / window.py
Created May 24, 2020 16:11
Maximum number of vowel letters in any substring of string 's' with length 'k'
class Solution(object):
def maxVowels(self, s, k):
"""
:type s: str
:type k: int
:rtype: int
"""
maxCount = 0
lastCount = -1
lastSubstrFirstLetterIsVowel = False
@aljorhythm
aljorhythm / Leetcode 1455.py
Created May 24, 2020 15:58
python generators for iteration
def isPrefixOfWord(sentence, searchWord):
"""
:type sentence: str
:type searchWord: str
:rtype: int
"""
words = sentence.split(" ")
for i, word in enumerate(words):
if word.startswith(searchWord):
return i + 1
class Solution(object):
def peopleIndexes(self, favoriteCompanies):
indices = []
favoriteCompanies = map(set, favoriteCompanies)
for i, person in enumerate(favoriteCompanies):
has_subset = False
for j, otherPerson in enumerate(favoriteCompanies):
if i == j:
continue
is_subset = True
class Solution(object):
def arrangeWords(self, text):
result = " ".join(sorted(text.lower().split(),key = lambda w: len(w)))
return result[:1].upper() + result[1:]
io = [
[
[[[-2,0],[2,0],[0,2],[0,-2]], 2], #input
4 #output
],
[
[[[-3, 0], [3, 0], [2, 6], [5, 4], [0, 9], [7, 8]], 5],
5
]
]
@aljorhythm
aljorhythm / function-on-iterables.py
Last active May 17, 2020 10:45
leetcode-20200517
class Solution(object):
def busyStudent(self, startTime, endTime, queryTime):
return len(filter(lambda se: queryTime >= se[0] and queryTime <= se[1], zip(startTime, endTime)))
@aljorhythm
aljorhythm / tabinate-ls.sh
Created November 27, 2017 09:28
Output filenames in directory, delimited by tabs
ls > list.txt.temp ; awk {'printf ("%s\t\n", $0) > "list.tsv";'} list.txt.temp; rm list.txt.temp
@aljorhythm
aljorhythm / delete-eclipse-macos.sh
Last active November 27, 2017 09:23
Delete Eclipse Nano on macOS Sierra
rm ~/Library/Preferences/org.eclipse.oomph.setup.installer.product.plist
rm ~/Library/Preferences/org.eclipse.platform.ide.plist
rm -rf ~/eclipse
rm -rf ~/Library/Caches/org.eclipse.oomph.setup.installer.product
rm -rf ~/Library/Saved\ Application\ State/org.eclipse.oomph.setup.installer.product.savedState/
rm -rf ~/Library/Saved\ Application\ State/org.eclipse.platform.ide.savedState/