Skip to content

Instantly share code, notes, and snippets.

@o-az
o-az / emoji.plist
Last active July 17, 2021 03:54
MacOS Full Emoji List Text Replacement
<?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">
<array>
<dict>
<key>phrase</key>
<string>🀄</string>
<key>shortcut</key>
<string>:mahjong:</string>
</dict>
@o-az
o-az / linked_list.py
Created July 17, 2021 14:19
credit to parkershamblin
class ListNode:
def __init__(self, val):
self.val = val
self.next = None
class LinkedList(object):
def __init__(self):
"""
Initialize your data structure here.
@o-az
o-az / index.tsx
Last active July 17, 2021 14:21
React Theme Switch Using CSS
import * as React from 'react';
import ReactDOM from 'react-dom';
import './theme.css'
export enum Icon {
DARK = '🌘',
LIGHT = '🌦'
}
export enum Theme {
@o-az
o-az / two_sum.py
Last active July 21, 2021 20:04
Two TwoSum implementations
# x + y = target
def twoSum(array, targetSum):
seen = {}
for index, x in enumerate(array):
y = targetSum - x
if y in seen:
return [x, y]
else:
seen[x] = index
return []
@o-az
o-az / dfsBTree.py
Created July 26, 2021 19:38
Binary Tree DFS Traversal - Inorder / Preorder / Postorder
"""
Traversing
"""
class Node:
def __init__(self, key):
self.left = None
self.right = None
self.value = key
@o-az
o-az / commands.txt
Created July 27, 2021 23:45
Useful macOS CLI commands
1. SHOW HIDDEN FILES IN FINDER BY DEFAULT:
defaults write com.apple.finder AppleShowAllFiles true
killall Finder
# To switch back, do the same but substitute false for true.
# Alternatively you can use CMD + SHIFT + period in a specific Finder folder
___________________________________________________________________
"""
Example: strOne = dingReviewCo, strTwo = CodingReview
Here rotation is after "ReviewCo"
Suppose we split strTwo at the rotation point into a and b
where a = "Co" and b = "dingReview"
Then, strOne would be ba and strTwo would be ab
strOne = dingReviewCo = b + a = ding + ReviewCo
strTwo = CodingReview = a + b = Co + dingReview
@o-az
o-az / dfs_btree_traverse.py
Created August 4, 2021 19:24
DFS Binary Tree Traversal – Inorder, Postorder, and Preorder
class Node:
def __init__(self, key):
self.left = None
self.right = None
self.value = key
def inOrder(root, visited=[]):
if root is not None:
inOrder(root.left, visited)
function treeHeight(tree) {
if (tree === null) return 0;
let subHeights = Array.from(tree.children).map(treeHeight)
return Math.max(...subHeights, 0) + 1
}
// Another option is to traverse DOM layer by layer
function treeHeight2(tree) {
if (tree === null) return 0;
const queue = [tree]
{
"openapi": "3.0.1",
"info": {
"title": "Swagger Petstore",
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "apiteam@swagger.io"
},
"license": {