This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# ====================================================================== | |
# https://www.qt.io/ | |
# https://www.riverbankcomputing.com/software/pyqt/ | |
# ====================================================================== | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, | |
# or (at your option) any later version. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run with JDK 21 | |
// $ java -Djdk.virtualThreadScheduler.parallelism=1 -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 DemoVirtualThreads.java | |
import java.net.URI; | |
import java.net.http.HttpClient; | |
import java.net.http.HttpRequest; | |
import java.net.http.HttpResponse; | |
import java.net.http.HttpResponse.BodyHandlers; | |
import java.time.Duration; | |
import java.time.LocalDateTime; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Licensed to the Apache Software Foundation (ASF) under one | |
# or more contributor license agreements. See the NOTICE file | |
# distributed with this work for additional information | |
# regarding copyright ownership. The ASF licenses this file | |
# to you under the Apache License, Version 2.0 (the | |
# "License"); you may not use this file except in compliance | |
# with the License. You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Amazon States Language - https://states-language.net/ | |
import jsonpath_ng | |
from collections import deque, namedtuple | |
import asyncio | |
import time | |
import json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Data is transformed in a tree (parent_id, index) | |
# There are 3 types of objects: STRUCT, ARRAY, VALUES | |
# the encode() method returns a list of columns containing: | |
# (parent_id, index, name, nulls[], values[], type) | |
# for ARRAYs values[] contains the number of items per row | |
from dataclasses import is_dataclass, asdict as dataclass_as_dict, dataclass | |
import types | |
CALLABLES_TYPES = (types.FunctionType, types.MethodType) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Encode an Array of numbers using a bitmap + int-pack4 | |
import java.io.ByteArrayOutputStream; | |
import java.io.IOException; | |
import io.github.matteobertozzi.rednaco.bytes.encoding.IntDecoder; | |
import io.github.matteobertozzi.rednaco.bytes.encoding.IntEncoder; | |
import io.github.matteobertozzi.rednaco.bytes.encoding.IntUtil; | |
public final class MostlyZeroEncoder { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedOutputStream; | |
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.StandardOpenOption; | |
import java.util.List; | |
import org.apache.avro.Schema; | |
import org.apache.avro.Schema.Type; | |
import org.apache.avro.generic.GenericData; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run with JDK 21 | |
// $ java -Djdk.virtualThreadScheduler.parallelism=2 -Djava.util.concurrent.ForkJoinPool.common.parallelism=2 DemoVirtualThreads.java | |
import java.net.URI; | |
import java.net.http.HttpClient; | |
import java.net.http.HttpRequest; | |
import java.net.http.HttpResponse; | |
import java.net.http.HttpResponse.BodyHandlers; | |
import java.time.Duration; | |
import java.util.concurrent.ExecutorService; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass, is_dataclass, asdict as dataclass_as_dict, fields as dataclass_fields | |
def dataclass_from_dict(cls, src): | |
kwargs = {} | |
fields_lookup = {field.name: field for field in dataclass_fields(cls)} | |
for field_name, value in src.items(): | |
field = fields_lookup.get(field_name) | |
if not field: | |
#logger.warning('config field %s not found for class %s', field_name, cls.__name__) | |
continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial # (ubuntu python3-serial package) - https://pyserial.readthedocs.io/en/latest/ | |
def gps_read(): | |
# nROK 1031 Built-in U-blox M9N GNSS is on /dev/ttyS3 (Ubuntu 22.04 LTS) | |
with serial.Serial('/dev/ttyS3', baudrate=38400) as sd: | |
sd.flushInput() | |
sd.flushOutput() | |
while True: | |
yield sd.readline() |
NewerOlder