Skip to content

Instantly share code, notes, and snippets.

brew install fish
sudo grep -qxF $(which fish) /etc/shells || echo $(which fish) | sudo tee -a /etc/shells
chsh -s $(which fish)
fish
fish_add_path /opt/homebrew/bin
fish_update_completions
@leonidpodriz
leonidpodriz / luhn.go
Created November 17, 2023 13:04
Luhn validation
package utils
func isValidLuhn(number string) bool {
var sum int
double := false
for i := len(number) - 1; i >= 0; i-- {
digit, err := strconv.Atoi(string(number[i]))
if err != nil {
@leonidpodriz
leonidpodriz / ua-banks.json
Created November 17, 2023 12:45
BINs of Ukrainian banks
{
"Приватбанк": [
410653,
413051,
414939,
414943,
414949,
414960,
414961,
414962,
@leonidpodriz
leonidpodriz / rtl88x2bu_setup.sh
Last active May 9, 2022 13:24
rtl88x2bu drivers setup
mkdir drivers
cd drivers
git clone https://github.com/cilynx/rtl88x2bu.git
cd rtl88x2bu
VER=$(sed -n 's/\PACKAGE_VERSION="\(.*\)"/\1/p' dkms.conf)
echo $VER
sudo rsync -rvhP ./ /usr/src/rtl88x2bu-${VER}
sudo pacman -S dkms
sudo dkms add -m rtl88x2bu -v ${VER}
sudo pacman -Ss headers
@leonidpodriz
leonidpodriz / string_to_snake_case.py
Created December 28, 2021 13:02
Convert any string to snake case
# Source: https://www.w3resource.com/python-exercises/string/python-data-type-string-exercise-97.php
from re import sub
def snake_case(string: str) -> str:
return '_'.join(
sub(
'([A-Z][a-z]+)', r' \1',
sub(
'([A-Z]+)', r' \1',
@leonidpodriz
leonidpodriz / camel_to_snake_case.py
Created May 5, 2021 16:20
Convert string in CamelCase to string in snake_case.
import re
def camel_to_snake_case(name: str) -> str:
"""
Convert string in CamelCase to string in snake_case.
Example: CamelCase -> camel_case
:param name: string in camel case
:return: string in snake case
@leonidpodriz
leonidpodriz / sort.js
Created July 29, 2020 09:45
Simple sort algorithm
const testArray = [1, 6, 4, 2, 6, 4];
function sortArray(array) {
let needToSortAgain = false;
for(let index = 0; index < array.length -1; index++) {
let firstNumber = array[index];
let secondNumber = array[index + 1];
array[index] = firstNumber < secondNumber ? firstNumber : secondNumber;