Skip to content

Instantly share code, notes, and snippets.

View ZviBaratz's full-sized avatar

Zvi Baratz ZviBaratz

  • Tel Aviv
View GitHub Profile
@ZviBaratz
ZviBaratz / sync-passwords.sh
Last active December 2, 2022 00:53
Simple passwords file synchronizer using Rclone
#!/bin/bash
# Important note:
# If you don't synchronize but then edit the other file,
# the newer modification time on the second file edited
# will cause data to be overridden.
# The solution would be to merge manually
# (Database --> Merge from database).
@ZviBaratz
ZviBaratz / knn.py
Last active December 4, 2020 16:24
Naive implementation of a k-NN estimator. This code is written entirely for educational purposes and should not be relied upon in practical applications.
class KNearestNeighbors:
"""
Simple implementation of a k-NN estimator.
"""
def __init__(self, n_neighbors: int = 1) -> None:
self.k = n_neighbors
self.X_train = None
self.y_train = None
def fit(self, X_train: np.ndarray, y_train: np.ndarray) -> None:
##########################################################################
# Automated OpenSSH Server configuration for Windows through the Windows #
# Subsystem for Linux (WSL). #
##########################################################################
#
# Before this script can be run successfully, please make sure WSL is
# installed and enabled by running the following command in the PowerShell:
#
# wsl --install
@ZviBaratz
ZviBaratz / oddball.py
Last active November 23, 2022 09:41
Utility function for auditory oddball stimulus generation.
"""Utilities for generating an auditory oddball stimulus."""
import os
from pathlib import Path
from typing import Iterable, Optional, Tuple, Type, Union
import librosa
import numpy as np
import soundfile as sf
# Exceptions.
@ZviBaratz
ZviBaratz / buggy_oddball.py
Last active November 23, 2022 08:37
This gist contains a buggy version of a utility function created for the purpose of auditory oddball stimulus generation. There are a total of 13 issues you will have to detect and correct for the `generate_oddball_stimulus()` function to work correctly and without linting problems. Good luck!
"""Utilities for generating an auditory oddball stimulus."""
import os
from pathlib import Path
from typing import Iterable, List, Optional, Tuple, Type, Union
import librosa
import numpy as np
# Exceptions.
LENGTH_MISMATCH: str = (
@ZviBaratz
ZviBaratz / buggy_oddball.md
Last active November 23, 2022 09:41
Buggy oddball debugging exercise solution

Buggy Oddball

This list details the bugs found in buggy_oddball.py. For the correct version, see oddball.py.

  • normalize_distance_parameters()
  1. Incorrect weights normalization, should be divided by sum() rather than mean().
  2. The function returns only weights, instead of distances, weights.
  3. The expression: