Skip to content

Instantly share code, notes, and snippets.

View ateska's full-sized avatar

Ales Teska ateska

View GitHub Profile
@ateska
ateska / streaming_tar.py
Last active March 26, 2024 17:57
Streaming asynchronous non-blocking tar using Python and asyncio
import os.path
import aiohttp.web
async def get_tar(request):
'''
AIOHTTP server handler for GET request that wants to download files from a `directory` using TAR.
'''
directory = <specify the directory>
response = aiohttp.web.StreamResponse(
import os
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
# Initialize a Web API client with your bot token
slack_bot_token = 'xoxb-your-bot-token'
client = WebClient(token=slack_bot_token)
# Define the message text
message_text = 'Hello, this is a message with a PDF attachment'
@ateska
ateska / asyncio-subprocess.py
Last active October 14, 2022 07:57
Simultaneously read stdout and stderr from Python `asyncio` create_subprocess_exec
import asyncio
async def run():
proc = await asyncio.create_subprocess_exec(
'/bin/ls', '/etc', '/not-exists',
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
)
# Prepare set of asynchronous readline() tasks for `stdout` and `stderr` streams
@ateska
ateska / llvmdemo.py
Created December 14, 2020 13:00
Demo of LLVM in Python
import sys
from llvmlite import ir
import llvmlite.binding as llvm
import ctypes
# All these initializations are required for code generation!
llvm.initialize()
llvm.initialize_native_target()
llvm.initialize_native_asmprinter() # yes, even this one
@ateska
ateska / sa-perftest.py
Created July 22, 2019 17:52
BitSwan Session Analyzer Performance Test
import bspump.trigger
import bspump.random
import bspump.common
import bspump.analyzer
import time
import random
class MyApplication(bspump.BSPumpApplication):
def __init__(self):
@ateska
ateska / perftest.py
Created July 19, 2019 17:17
BitSwan TWA perf. tester
from bspump import BSPumpApplication, Pipeline
import bspump.trigger
import bspump.random
import bspump.common
import bspump.analyzer
import time
import numpy as np
import random
import logging
@ateska
ateska / bspump-unittest.py
Last active June 4, 2019 22:53
Unit test for BitSwan
import unittest
import bspump
import bspump.common
import bspump.trigger
###
class MyProcessor(bspump.Processor):
@ateska
ateska / ecies.py
Created April 11, 2019 06:53
Python / cryptography.io decryption compatible with iOS ECIES encryption
import binascii
import cryptography.hazmat.backends
import cryptography.hazmat.primitives.asymmetric.ec
import cryptography.hazmat.primitives.hashes
import cryptography.hazmat.primitives.kdf.x963kdf
import cryptography.hazmat.primitives.ciphers.aead
import cryptography.hazmat.primitives.serialization
# Alice (with iOS) is sending encrypted message to Bob (Python)
//
// mini_asn1_der.swift
// miniasn1
//
// Created by Ales Teska on 18.2.19.
// Copyright © 2019 TeskaLabs. All rights reserved.
//
import Foundation
//
// mini_asn1_der.swift
// miniasn1
//
// Created by Ales Teska on 18.2.19.
// Copyright © 2019 TeskaLabs. All rights reserved.
//
import Foundation