This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from os import system | |
import requests | |
import json | |
import traceback as tb | |
import re | |
## Please install ffmpeg before running this script and make sure it's in your PATH | |
## brew install ffmpeg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Format Style Options | |
--- | |
BasedOnStyle: WebKit | |
AllowShortIfStatementsOnASingleLine: WithoutElse | |
BreakBeforeBinaryOperators: None | |
BreakBeforeBraces: Attach | |
ColumnLimit: 250 | |
ContinuationIndentWidth: 2 | |
Cpp11BracedListStyle: true | |
IndentWidth: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function generateOneTimePassword(rawKey: Uint8Array, counter: number): Promise<number> { | |
const data = new DataView(new ArrayBuffer(8)); | |
data.setBigUint64(0, BigInt(Math.floor(counter)), false); | |
const algo = { name: 'HMAC', hash: 'SHA-1' }; | |
const key = await crypto.subtle.importKey('raw', rawKey, algo, false, ['sign']); | |
const hmacHash = new Uint8Array(await crypto.subtle.sign(algo, key, data.buffer)); | |
const offset = hmacHash[hmacHash.byteLength - 1] & 0x0f; | |
const hotp = (hmacHash[offset] & 0x7f) << 24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open the Terminal by pressing Ctrl+Alt+T. | |
# Type the following command to edit the power management configuration file: | |
sudo nano /etc/systemd/logind.conf | |
# Find the following line in the file: | |
#HandleLidSwitch=suspend | |
# Uncomment the line by removing the "#" at the beginning of the line and change "suspend" to "ignore": | |
HandleLidSwitch=ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import base64 | |
files_size_under_1MB = { | |
"file_name_1": "file-1_encoded_base64", | |
"file_name_1": "file-2_encoded_base64" | |
} | |
for keys in files_size_under_1MB: | |
try: os.remove(keys) # remove the old file | |
except: pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fmt_num(1000) | |
# result: 1M | |
# type(fmt_num(1000)) | |
# result: <class 'str'> | |
def fmt_num(num): | |
suffixes = ["", "K", "M", "B", "T"] | |
suffix_index = 0 | |
while abs(num) >= 1000 and suffix_index < len(suffixes)-1: | |
suffix_index += 1 # increment the suffix index | |
num /= 1000.0 # divide by 1000 to get the number in the next magnitude |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import base64 | |
# replace with your personal access token(classic) | |
github_pat = "ghp_abcdfeghi......" | |
# encode pat using base64 | |
encoded = base64.base64encode(github_pat.encode()) | |
# check the encoded base64 |