Skip to content

Instantly share code, notes, and snippets.

@jfjlaros
jfjlaros / myRandom.cpp
Created December 11, 2022 19:33
Generate a random number, but disallow the previous result.
/* Generate a random number, but disallow the previous result.
*
* \param low
* \param high
*
* \return Random number.
*/
long myRandom(long const low, long const high) {
thread_local long previousValue {random(low, high)};
@jfjlaros
jfjlaros / sample.tcc
Last active December 11, 2022 19:41
Sample from an array without replacement.
/* Sample from an array without replacement.
*
* \tparam T Array type.
* \tparam arraySize Array size.
*
* \param a Array.
*
* \return Element of `a`.
*/
template <class T, size_t arraySize>
@jfjlaros
jfjlaros / sample.tcc
Last active December 29, 2022 16:39
Sample from an array, but disallow the last `historySize` results.
/* Sample from an array, but disallow the last `historySize` results.
*
* \tparam historySize History size.
* \tparam T Array type.
* \tparam arraySize Array size.
*
* \param a Array.
*
* \return Element of `a`.
*/
@jfjlaros
jfjlaros / 01_timing.cpp
Last active January 23, 2021 12:46
Snippet for timing analysis.
#define SLOTS 100
unsigned long _last[SLOTS];
size_t _index = 0;
void set(void) {
_last[_index] = millis();
_index++;
}
@jfjlaros
jfjlaros / patch.py
Last active January 10, 2021 10:06
Monkey patch for timing issue.
from serial.urlhandler import protocol_socket
protocol_socket.time.sleep = lambda x: None
@jfjlaros
jfjlaros / windows_batch_install.md
Last active August 29, 2015 14:14
Installation instructions for running the Mutalyzer Batch Checker in Windows.

Running the automated Batch Checker

Installation

Python core libraries

Go to the Python website. In the Downloads tab, click the Python 2.7.9 button. Go to your downloads folder and start the installation by double clicking on the package python-2.7.9.msi.