Skip to content

Instantly share code, notes, and snippets.

@JediKnightChan
JediKnightChan / yc_env_parser.py
Created July 17, 2023 09:55
Parser for Yandex Cloud environmental variables (as they didn't make copy paste in browser)
from bs4 import BeautifulSoup
with open("test.html", "r") as f:
soup = BeautifulSoup(f.read(), features="html.parser")
keys = soup.select("input[placeholder='Ключ']")
values = soup.select("input[placeholder='Значение']")
for k, v in zip(keys, values):
print(k.get("value"), "=", v.get("value"), sep="")
@JediKnightChan
JediKnightChan / discord_serverless_bot_yandex.py
Created June 23, 2023 10:19
A working Serverless Yandex Cloud Function for a discord bot
import json
import os
import logging
from nacl.signing import VerifyKey
from nacl.exceptions import BadSignatureError
PUBLIC_KEY = os.getenv("PUBLIC_KEY", "")
@JediKnightChan
JediKnightChan / GildorUE4ViewerMaterialPropsTxtToJson.py
Last active October 27, 2022 12:28
For UE Viewer Gildor's Tool (https://github.com/gildor2/UEViewer) material .props.txt files, convert to .json format
import json
import re
def get_line_key(line):
"""Get key from line or return None if not found.
EG from 'VectorParameterValues[1] = \n' return 'VectorParameterValues[1]',
from 'ParameterName = Emissive Color' return 'ParameterName'
"""
res = re.search(r"(?P<key>[a-zA-Z\d\[\]\s]+)=", line)
@JediKnightChan
JediKnightChan / web_parser.py
Created May 24, 2022 13:58
A simple website (HTML, CSS, JS) parser
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin, urlsplit
import os
save = True
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1)'}
base_dir = "./parse-results/"
import json
import re
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
from Bio import SeqIO
# CHANGEME
json_filepath = "./output/NC_015434.json"
with open(json_filepath, "r") as f:
"""
_____ _____ _____ _____ _____ _____ _____ _____
/\ \ /\ \ /\ \ /\ \ /\ \ /\ \ /\ \ /\ \
/::\ \ /::\____\ /::\ \ /::\ \ /::\ \ /::\ \ /::\ \ /::\ \
\:::\ \ /:::/ / /::::\ \ /::::\ \ /::::\ \ \:::\ \ \:::\ \ /::::\ \
\:::\ \ /:::/ / /::::::\ \ /::::::\ \ /::::::\ \ \:::\ \ \:::\ \ /::::::\ \
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pandas as pd
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
import os
from sklearn.model_selection import train_test_split
import pyhmmer
def generate_dataset():
import os
import re
import requests
import urllib.parse
from bs4 import BeautifulSoup
common = "https://www.example.com/"
start_url = "https://www.example.com/index.html"
@JediKnightChan
JediKnightChan / playerjs_base64.py
Last active December 16, 2018 11:04
Functions for video link protection in PlayerJS (Python)
from base64 import b64encode, b64decode
import random
pjs_b64_separator = b"//"
pjs_b64_keys = ["", "", "", "", ""]
def pjs_b64_encrypt(string):
"""
Encrypts given string using base64 and pjs_b64_keys,
returns the encrypted string