Skip to content

Instantly share code, notes, and snippets.

View alekssamos's full-sized avatar
🎯
Focusing

alekssamos

🎯
Focusing
View GitHub Profile
@alekssamos
alekssamos / conversation.py
Created January 25, 2022 06:34 — forked from MohammadHosseinGhorbani/conversation.py
Conversations in pyrogram (no extra package needed)
from pyrogram import Client, filters
app = Client('CONVERSATION_EXAMPLE')
conversations = {}
infos = {}
def conv_filter(conversation_level):
def func(_, __, message):
return conversations.get(message.from_user.id) == conversation_level
@alekssamos
alekssamos / ym_recognition.py
Created December 4, 2021 09:50 — forked from teidesu/ym_recognition.py
small script that (ab)uses Yandex Music Recognition.
"""
This is small script that (ab)uses Yandex Music Recognition.
I hope the code is self-documented <3
Notice! Input file should be .ogg file, preferably with libopus encoder
(untested with other encoders)
(c) teidesu, 2019. This script is licensed under GPLv3 license.
"""
import lomond
import uuid as uuid_py
@alekssamos
alekssamos / taskpool.py
Created October 20, 2021 10:15 — forked from mdellavo/taskpool.py
asyncio task pool
import asyncio
from asyncio.queues import Queue
TERMINATOR = object()
class TaskPool(object):
def __init__(self, loop, num_workers):
self.loop = loop
self.tasks = Queue(loop=self.loop)
@alekssamos
alekssamos / asyncio_pool.py
Created October 20, 2021 09:43 — forked from njam/asyncio_pool.py
Limit number of concurrently running asyncio tasks
import asyncio
from collections import deque
class AsyncioPool:
def __init__(self, concurrency, loop=None):
"""
@param loop: asyncio loop
@param concurrency: Maximum number of concurrently running tasks
"""
@alekssamos
alekssamos / download_multiple.py
Created October 7, 2021 05:36 — forked from Hammer2900/download_multiple.py
Use asyncio and aiohttp to asynchronously download multiple files at once and handle the responses as they finish
import asyncio
from contextlib import closing
import aiohttp
async def download_file(session: aiohttp.ClientSession, url: str):
async with session.get(url) as response:
assert response.status == 200
# For large files use response.content.read(chunk_size) instead.
@alekssamos
alekssamos / a.js
Created September 21, 2021 16:33 — forked from Dobby233Liu/a.js
my messing w/ msedge dev read aloud. ONLY RUN IN edge dev. i give up, so it wont work properly
var ARRAY_LENGTH = 16;
var MIN_HEX_LENGTH = 2;
class UUID {
static createUUID() {
const array = new Uint8Array(ARRAY_LENGTH);
window.crypto.getRandomValues(array);
let uuid = '';
import wx
import urllib.request
import json
import webbrowser
API_KEY = ''
class NewsPanel1(wx.Panel):
def __init__(self, parent):
@alekssamos
alekssamos / arrayBufferToBase64.js
Created June 5, 2020 06:33 — forked from Deliaz/arrayBufferToBase64.js
Convert array buffer to base64 string
function arrayBufferToBase64(buffer) {
let binary = '';
let bytes = new Uint8Array(buffer);
let len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
@alekssamos
alekssamos / clipboard_image_post_js.html
Created March 13, 2020 20:38 — forked from kidatti/clipboard_image_post_js.html
Upload clipboard image to server (HTML5 / JavaScript / AJAX)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<script>
@alekssamos
alekssamos / SqliteStore.php
Last active September 22, 2024 11:17 — forked from erikeldridge/SqliteStore.php
a simple key/val store using php & sqlite3
<?php
// a simple key/val store using php & sqlite3
// license: http://gist.github.com/375593
// edited by alekssamos
/* Added multithreading: https://habr.com/ru/articles/204438/ */
class SqliteStore {
protected $db;
public function __construct($tableName, $filePath = 'db.sqlite') {