This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Script to enable dead keys in any keyboard layout. | |
; Source: https://stackoverflow.com/questions/37641744/autohotkey-dead-key-remap-stopped-working | |
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
; #Warn ; Enable warnings to assist with detecting common errors. | |
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
#SingleInstance force | |
#InstallKeybdHook | |
#NoTrayIcon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Tuple, Dict, Set, List | |
AdjacencyList = Dict[int, Set] | |
EdgeList = List[List[int]] | |
class Solution: | |
def buildAdjacencyList( | |
self, numCourses: int, prerequisites: EdgeList | |
) -> Tuple[AdjacencyList, Dict[int, int]]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Dict, List, Any | |
WILDCARD = '?' | |
class Trie: | |
def __init__(self) -> None: | |
self.children: Dict[str: Trie] = {} | |
self.isLeaf: bool = False | |
def insert(self, key: str) -> None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol Notifier: class { | |
func notify(_ data: Any) | |
} | |
protocol Destroyable { | |
func destroy() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UnionFind: | |
def __init__(self): | |
self.id = {} | |
self.size = {} | |
def setdefault(self, p: int): | |
self.id.setdefault(p, p) | |
self.size.setdefault(p, 1) | |
def root(self, i: int) -> int: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any, Dict | |
class Trie: | |
def __init__(self) -> None: | |
self.children : Dict[str, Trie] = {} | |
self.value : Any = None | |
def find(self, key: str) -> Any: | |
node = self | |
for char in key: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def buildGrid(self, stones): | |
gridSize = max(map(max, stones)) + 1 | |
grid = [[0 for i in range(gridSize)] for i in range(gridSize)] | |
for x, y in stones: | |
grid[x][y] = 1 | |
return grid, gridSize | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UnionFind: | |
def __init__(self): | |
self.id = {} | |
self.size = {} | |
def setdefault(self, p: int): | |
self.id.setdefault(p, p) | |
self.size.setdefault(p, 1) | |
def root(self, i: int) -> int: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def windows(array, window_size, overlap=0): | |
""" Generator of windows from an audio file to short-time analysis | |
Keyword arguments: | |
array -- Array of audio samples | |
window_size -- Size of the window that will be generated | |
overlap -- Overlap of windows to be accounted for when generating new ones | |
""" | |
overlap_factor = (1 - overlap) | |
head, tail = 0, window_size |