Skip to content

Instantly share code, notes, and snippets.

View werneckpaiva's full-sized avatar

Ricardo Paiva werneckpaiva

View GitHub Profile
#include <IBusBM.h>
IBusBM ibusRc;
HardwareSerial& ibusRcSerial = Serial1;
HardwareSerial& debugSerial = Serial;
void setup() {
debugSerial.begin(74880);
ibusRc.begin(ibusRcSerial);
@werneckpaiva
werneckpaiva / LookupTest.scala
Created May 9, 2020 21:35
Comparison between lookup or match case
package switchlookup
import collection.JavaConversions._
object LookupTest {
val VALUES = List(
"GJMYQBNbtxUYhxInkbXB", "izZogfwZcWJOMnKfVmiR", "feCfeVlfbsNPskdOOxfa", "jgNqcbyRHVfycmFtFdpH", "vzqmtfbiwclduviXpTaw",
"cIQStdcUWiVuXTcGfdFK", "ppbiVAlciZhUjnowMCId", "AdckbDaDZXwZnwODhPnb", "goXpVCWiJMkaEnqSgSWU", "sjRgGBgfBXHUfnpNiwas",
"DACFkzLdmqmZZKcSXltF", "QpXOtUTUjXXSJqUKZIBW", "RbxYRleFYtnYUpQnIxlx", "AwQlmDfmJHLwxsQOUMvt", "cHvkUVGdOxrflgJBXgcu",
@werneckpaiva
werneckpaiva / rc-arduino.ino
Last active April 24, 2024 11:55
Read RC channels from Arduino
#define CH1 3
#define CH2 5
#define CH3 6
#define CH4 9
#define CH5 10
// Read the number of a given channel and convert to the range provided.
// If the channel is off, return the default value
int readChannel(int channelInput, int minLimit, int maxLimit, int defaultValue){
int ch = pulseIn(channelInput, HIGH, 30000);
@werneckpaiva
werneckpaiva / KafkaSeekByTimestamp.java
Last active May 4, 2023 17:12
Kafka Consumer - seek by timestamp
// Get the list of partitions
List<PartitionInfo> partitionInfos = consumer.partitionsFor(topicName);
// Transform PartitionInfo into TopicPartition
List<TopicPartition> topicPartitionList = partitionInfos
.stream()
.map(info -> new TopicPartition(topicName, info.partition()))
.collect(Collectors.toList());
// Assign the consumer to these partitions
consumer.assign(topicPartitionList);
// Look for offsets based on timestamp
### Keybase proof
I hereby claim:
* I am werneckpaiva on github.
* I am ricardopaiva (https://keybase.io/ricardopaiva) on keybase.
* I have a public key whose fingerprint is 7077 2CBA 173A 255D 5C46 797F 196F C35C A239 0E12
To claim this, I am signing this object: