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
rules: [ | |
{ | |
"description": "hyper + d inserts datetime", | |
"manipulators": [ | |
{ | |
"from": { | |
"key_code": "d", | |
"modifiers": { | |
"mandatory": [ | |
"left_shift", |
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
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
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 numpy as np | |
# Time complexity: O(n), where n is the number of pixels in image | |
# Space complexity: O(n) | |
def label_connected_components(image: np.uint8) -> np.int: | |
nrow = image.shape[0] | |
ncol = image.shape[1] | |
component_map = np.full((nrow, ncol), -1, dtype=np.int) | |
current_comp_id = 1 | |
for r in range(nrow): |
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
// | |
// SequenceExtensions.swift | |
// Swift6006 | |
// | |
// Created by Barış Deniz Sağlam on 10.08.2020. | |
// Copyright © 2020 BDS. All rights reserved. | |
// | |
import Foundation |
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 quotient_remainder(a, b): | |
# returns quotient and remainder of a division b | |
# a = q*b + r | |
q = 0 | |
while a >= b: | |
q += 1 | |
a -= b | |
return q, a |
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 expm(x, order=10): | |
''' | |
nth-order Taylor approximation of matrix exponential | |
''' | |
if order < 1: | |
raise ValueError("order cannot be smaller than 1") | |
I = torch.eye(x.shape[-1], dtype=x.dtype, device=x.device) | |
result = I | |
nom = I |
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
# Credits: https://gist.github.com/nguyenkims | |
import logging | |
import sys | |
from logging.handlers import TimedRotatingFileHandler | |
FORMATTER = logging.Formatter("[%(asctime)s][%(name)s][%(levelname)s] - %(message)s") | |
LOG_FILE = "app.log" | |
def make_console_handler(): |
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 pathlib | |
import hydra | |
hydra._internal.hydra.GlobalHydra().clear() | |
config_dir = pathlib.Path('/path/to/configs/') | |
hydra.experimental.initialize(config_dir=config_dir) | |
cfg = hydra.experimental.compose(config_file='config.yaml', overrides=[]) | |
print(cfg.pretty()) |
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
data/ | |
# Jupyter notebook checkpoints | |
notebooks/ | |
*.ipynb_checkpoints/ | |
# PyTorch Lightning | |
*lightning_logs/ | |
# PyCharm files |
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 conv_output_size(in_size, kernel, stride=1, padding=0): | |
return (in_size - kernel + 2*padding) // stride + 1 |
NewerOlder