Skip to content

Instantly share code, notes, and snippets.

View ateska's full-sized avatar

Ales Teska ateska

View GitHub Profile
@ateska
ateska / bc_hello_world_1.c
Last active February 8, 2017 20:05
Hello world for BigClown Core Module.
#include <bc_common.h>
#include <bc_usb_cdc.h>
#include <bc_button.h>
static bc_button_t button;
void button_event_handler(bc_button_t *self, bc_button_event_t event, void *event_param)
{
if (event == BC_BUTTON_EVENT_PRESS)
{
#include <bc_common.h>
#include <bc_scheduler.h>
#include <bc_usb_cdc.h>
void application_on_tick(void *event_param)
{
// Send 'Hello world!' string to USB
char buffer[] = "Hello world!\r\n";
bc_usb_cdc_write(buffer, strlen(buffer));
import Foundation
func asn1_int_to_bytes(length: UInt) -> Data {
var l = length
var d = Data()
while (l > 0) {
let b: UInt8 = UInt8(l & 0xFF)
d.append(contentsOf: [b])
l = length >> 8
}
//
// 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
@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 / 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 / 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 / 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 / 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