Skip to content

Instantly share code, notes, and snippets.

@svavassori
svavassori / powerbi_extractor.py
Last active July 1, 2024 19:42
PowerBi Extractor in Python
import sys
import csv
import json
# Converts the JSON output of a PowerBI query to a CSV file
def extract(input_file, output_file):
input_json = read_json(input_file)
data = input_json["results"][0]["result"]["data"]
dm0 = data["dsr"]["DS"][0]["PH"][0]["DM0"]
@svavassori
svavassori / counter.c
Last active November 9, 2021 15:52
Bee counter that is based on state transition instead of elapsed time
#include <stdio.h>
#include <stdint.h>
#include <string.h>
typedef enum {
EMPTY,
START_ENTERING, // bee is entering the gate from outside, so it's entering
MIDDLE_ENTERING,
END_ENTERING, // bee is almost all inside
START_EXITING, // bee is entering the gate from inside, so it's exiting
@svavassori
svavassori / raw_sensor_read.ino
Created June 24, 2021 16:24
Raw sensor read for Gate 0
/*
*
* gate 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13 || 14 || 15 || 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23
* inside 1 || 3 || 5 || 7 || 9 || 11 || 13 || 15 || 17 || 19 || 21 || 23 || 25 || 27 || 29 || 31 || 33 || 35 || 37 || 39 || 41 || 43 || 45 || 47
* outside 2 || 4 || 6 || 8 || 10 || 12 || 14 || 16 || 18 || 20 || 22 || 24 || 26 || 28 || 30 || 32 || 34 || 36 || 38 || 40 || 42 || 44 || 46 || 48
*
*
* HOW long can we drive the LEDs ON without current limiting resistors?
* LED timed pulse (tp) allowance vs period (T)
* with increasing forward current the IR LED cutsheet says max tp/T = 0.01
@svavassori
svavassori / raw_sensor_read_2gate.ino
Last active July 9, 2021 13:53
raw_sensor_read_2gate.ino
/*
*
* gate 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13 || 14 || 15 || 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23
* inside 1 || 3 || 5 || 7 || 9 || 11 || 13 || 15 || 17 || 19 || 21 || 23 || 25 || 27 || 29 || 31 || 33 || 35 || 37 || 39 || 41 || 43 || 45 || 47
* outside 2 || 4 || 6 || 8 || 10 || 12 || 14 || 16 || 18 || 20 || 22 || 24 || 26 || 28 || 30 || 32 || 34 || 36 || 38 || 40 || 42 || 44 || 46 || 48
*
*
* HOW long can we drive the LEDs ON without current limiting resistors?
* LED timed pulse (tp) allowance vs period (T)
* with increasing forward current the IR LED cutsheet says max tp/T = 0.01