Skip to content

Instantly share code, notes, and snippets.

View jO-Osko's full-sized avatar

Filip Koprivec jO-Osko

View GitHub Profile
@jO-Osko
jO-Osko / salt_transcoding.py
Created June 30, 2022 13:27
Salt transcoding
import string
import base64
# bcrypt uses a strange base64 encoding, which is incompatible with the common one, go figure...
B64_CHARS = ''.join((string.ascii_uppercase, string.ascii_lowercase, string.digits, '+/')).encode("utf-8")
B64_CHARS_BCRYPT = ''.join(('./', string.ascii_uppercase, string.ascii_lowercase, string.digits)).encode("UTF-8")
B64_TO_BCRYPT = bytes.maketrans(B64_CHARS, B64_CHARS_BCRYPT)
B64_FROM_BCRYPT = bytes.maketrans(B64_CHARS_BCRYPT, B64_CHARS)
import requests
import re
import threading
import time
import random
import queue
STEVILO_STRANI = 50
@jO-Osko
jO-Osko / hasher.py
Last active March 25, 2022 20:29
Hasher
from typing import List
from web3 import Web3
import eth_abi
def submit_price_hash(ftsoIndices: List[int], prices: List[int], random: int, address: str) -> str:
assert len(ftsoIndices) == len(prices)
assert list(sorted(ftsoIndices)) == ftsoIndices and len(set(ftsoIndices)) == len(ftsoIndices), "Indices are non increasing"
return Web3.keccak(eth_abi.encode_abi(
@jO-Osko
jO-Osko / readme.md
Created September 17, 2021 10:30
Inlining test
@jO-Osko
jO-Osko / package.json
Last active September 14, 2021 13:28
esy package
{
"dependencies": {
"ocaml": "4.12.x",
"@opam/ocaml-lsp-server": "*",
"@opam/ocamlfind-secondary": "*",
"@opam/reason": "*"
}
}
import random
def seed():
random.seed(2021)
def prazna_mreza(w, h):
return [
[0 for j in range(w)] for _ in range(h)
]
"label": "OCaml",
"type": "shell",
"command":
"C:\\OCaml64\\usr\\local\\bin\\ocaml-env.exe exec -- C:\\OCaml64\\home\\???\\.opam\\4.11.1+mingw64c\\bin\\ocaml.exe -init \\\"${file}\\\""
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am jo-osko on github.
  • I am j00sko (https://keybase.io/j00sko) on keybase.
  • I have a public key ASCRfzaqktPSkQ_ubPT57r0dq1JsSRcByseVUjAYwJKYiwo

To claim this, I am signing this object:

Evklidov algoritem

Evklidov algoritem je učinkovit algoritem za izračun največjega skupnega delitelja dveh števil in ga označimo z gcd(a,b), kjer predpostavimo, da a >= b. Na kratko ga lahko opišemo kot:

  • gcd(a,0) = a
  • V nasprotem primeru zapišemo a kot: a = b*q + r. gcd(a,b) je v tem primeru enak kot gcd(b, r). Vidimo, da po nekaj časa bo r = 0 in to bo končni rezultat.

Implementiraj funkcijo gcd(a,b), ki vrne največji skupni deljitelj števil a in b. Poskrbi, da bo funkcija delovala pravilno, tudi če uporabnik poda argumenta v poljubnam vrstnem redu.

Primeri: gcd(15, 5) = gcd(5, 15) = 5, gcd(1234, 23456), gcd(12, 56) = 4, gcd(14, 21) = 7