Skip to content

Instantly share code, notes, and snippets.

View kashapovd's full-sized avatar
🎸

Yaroslav kashapovd

🎸
View GitHub Profile
@kashapovd
kashapovd / randstr.sh
Last active March 5, 2021 17:17
random string in bash
#!/bin/bash
#first, the most simply method to get a random number is reading embedded $RANDOM variable (range 0...32767)
#like this:
echo $RANDOM
#letters only
cat /dev/random | tr -dc 'a-zA-Z' | fold -w $(shuf -i 1-20 -n 1) | head -1
# symbol set / \ number of chars (range)
#letters with numbers
@kashapovd
kashapovd / mmi.py
Last active March 9, 2021 07:00
Modular multiplicative inverse with Python
#!/usr/bin/env python
# usage: ./mmi.py -n [NUM] -m [MOD]
import sys
import argparse
import math
def gcdExtended(a, b):
if b == 0:
return a, 1, 0