Skip to content

Instantly share code, notes, and snippets.

View NF1198's full-sized avatar

Nicholas Folse NF1198

  • Albuquerque, NM
View GitHub Profile
@NF1198
NF1198 / timer.cpp
Created January 19, 2023 03:01
Timer Class for Arduino or other Embedded System
/*
* Copyright (c) 2022, 2023 Nicholas Folse
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
use std::sync::mpsc::SendError;
use std::sync::mpsc::{self};
use std::thread;
use std::time::Duration;
#[derive(Debug)]
enum MonitorCommand {
Stop,
}
#
# process_handler.py
# Copyright 2020 Nicholas Folse <nickfolse@gmail.com>
#
# This module defines a subprocess handler capable of managing
# multiple simultaneous subprocess.Popen calls. Results of each subprocess
# are processed in parallel. Each subprocess is injected with a line handler
# which is responsible for handling input from each call. Line handlers
# are called as line_handler(proc, line). If multiple handlers are injected for
# a given subprocess, the output of a handler is passed as the input to the next
@NF1198
NF1198 / README.md
Last active August 27, 2023 11:11
Simultaneously read from multiple subprocesses in Python 3 using {select, threads} (select, epoll, thread, subprocess, PIPE)

Reading from multiple subprocesses in Python: epoll vs threads

The following performance results were generated using a 2300 line file with output piped directly to a file instead of the console. (All awk delays were set to 0 for the benchmark) Processor Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 1992 Mhz, 4 Core(s), 8 Logical Processor(s)

The epoll solution is the clear winner, but is only available on Unix and Linux.

Approach 1: epoll

  • real 0m24.954s
@NF1198
NF1198 / tag_db.sql
Last active January 19, 2023 04:17
A simple tag database with logging backed by MySQL
-- --------------------------------------------------------
-- Host: 127.0.0.1
-- Server version: 10.4.6-MariaDB - mariadb.org binary distribution
-- Server OS: Win64
-- HeidiSQL Version: 10.2.0.5611
-- Author: Nicholas Folse
-- Copyright (c) 2020-2023 Nicholas Folse
-- --------------------------------------------------------
@NF1198
NF1198 / gist:985175e80f1ec0ae089d3cccb3824591
Last active August 23, 2018 20:47
git daemon server on-liner - current directory
git-serve() {
echo git daemon: $PWD && git daemon --verbose --export-all --reuseaddr --port=9090 --base-path=$PWD $PWD
}
@NF1198
NF1198 / SingleTreadedSQLiteManager.java
Created July 18, 2018 23:30
SQLiteSingleThreadedManager
/*
* Copyright (c) 2018, tauTerra, LLC; Nicholas Folse
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
@NF1198
NF1198 / CSVObjectReader.java
Last active March 18, 2018 04:12
A utility class that makes it easy to build objects from rows in a CSV file
/*
* Copyright 2017 tauTerra, LLC.
*
* Licensed 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
*
* Unless required by applicable law or agreed to in writing, software
@NF1198
NF1198 / StAXObjectBuilder.java
Last active May 11, 2020 14:41
An object builder for StAX
/*
* Copyright 2017 Nicholas Folse <https://github.com/NF1198>.
*
* Licensed 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
*
* Unless required by applicable law or agreed to in writing, software
@NF1198
NF1198 / Xsetup
Last active October 27, 2017 21:12
Set DPI in Linux VM before login screen starts
# find / -name Xsetup 2>/dev/null
# -or-
# find / -name Default 2>/dev/null (e.g. /etc/gdm3/Init/Default) -- doesn't work in gdm3 ...
# vim <path to file>/Xsetup
# verify with $ xdpyinfo | grep -B 2 resolution
# add line:
# xrandr --dpi <dpi>