| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7ce314e commit 0ae9690
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + # pip install googletrans==3.1.0a0 | ||
| 2 | + | ||
| 3 | + from googletrans import Translator | ||
| 4 | + translator = Translator() | ||
| 5 | + | ||
| 6 | + out = translator.translate("क्या हाल है", dest='en') | ||
| 7 | + print(out) | ||
| 8 | + | ||
| 9 | + mystory = '''Tell me who doesn't love baby yoda from mandolarian? | ||
| 10 | + Baby yoda has shaken me like soda. | ||
| 11 | + ''' | ||
| 12 | + out = translator.translate(mystory, dest='hi') | ||
| 13 | + print(out.text) | ||
| 14 | + | ||
| 15 | + out = translator.translate("I am learning python", dest='gu') | ||
| 16 | + print(out) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,30 @@ | |||
| 1 | + from hashlib import sha256 | ||
| 2 | + MAX_NONCE = 100000000000 | ||
| 3 | + | ||
| 4 | + def SHA256(text): | ||
| 5 | + return sha256(text.encode("ascii")).hexdigest() | ||
| 6 | + | ||
| 7 | + def mine(block_number, transactions, previous_hash, prefix_zeros): | ||
| 8 | + prefix_str = '0'*prefix_zeros | ||
| 9 | + for nonce in range(MAX_NONCE): | ||
| 10 | + text = str(block_number) + transactions + previous_hash + str(nonce) | ||
| 11 | + new_hash = SHA256(text) | ||
| 12 | + if new_hash.startswith(prefix_str): | ||
| 13 | + print(f"Yay! Successfully mined bitcoins with nonce value:{nonce}") | ||
| 14 | + return new_hash | ||
| 15 | + | ||
| 16 | + raise BaseException(f"Couldn't find correct has after trying {MAX_NONCE} times") | ||
| 17 | + | ||
| 18 | + if __name__=='__main__': | ||
| 19 | + transactions=''' | ||
| 20 | + Dhaval->Bhavin->20, | ||
| 21 | + Mando->Cara->45 | ||
| 22 | + ''' | ||
| 23 | + difficulty=4 # try changing this to higher number and you will see it will take more time for mining as difficulty increases | ||
| 24 | + import time | ||
| 25 | + start = time.time() | ||
| 26 | + print("start mining") | ||
| 27 | + new_hash = mine(5,transactions,'0000000xa036944e29568d0cff17edbe038f81208fecf9a66be9a2b8321c6ec7', difficulty) | ||
| 28 | + total_time = str((time.time() - start)) | ||
| 29 | + print(f"end mining. Mining took: {total_time} seconds") | ||
| 30 | + print(new_hash) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments