Skip to content

Instantly share code, notes, and snippets.

View csarnataro's full-sized avatar
💭
Exploring Elixir, Electron and Flutter

Christian Sarnataro csarnataro

💭
Exploring Elixir, Electron and Flutter
View GitHub Profile
@csarnataro
csarnataro / message_0.5.0.md
Last active March 4, 2026 11:54
Test markdown

Hi there

If you experience some problems with version 0.5.0, please update to 0.6.0 clicking the link below.

Click here

@csarnataro
csarnataro / countdown_counter.ex
Last active April 18, 2025 16:38
Some experiments to build a countdown counter in Elixir using :gen_statem
defmodule CountDownCounter do
@behaviour :gen_statem
@name :countdown_counter
@initial_time 6
@doc ~S"""
## Client API
### Usage:
@csarnataro
csarnataro / thingspeak_test.ino
Created December 28, 2024 14:56
Test sketch to send and receive data from Thingkspeak IoT platform
/*
WriteMultipleFields
Description: Writes values to fields 1,2,3,4 and status in a single ThingSpeak update every 20 seconds.
Hardware: ESP32 based boards
!!! IMPORTANT - Modify the secrets.h file for this project with your network connection and ThingSpeak channel details. !!!
Note:
@csarnataro
csarnataro / tooltip-with-data-title.js
Last active January 22, 2024 15:47
A tooltip with `data-title` attribute with Emotion JS
import { css } from '@emotion/react'
const dataTitle = () => css`
&[data-title]:hover:after {
opacity: 1;
transition: all 0.1s ease 0.5s;
visibility: visible;
}
&[data-title]:after {
content: attr(data-title);
@csarnataro
csarnataro / arduino-iot-api-js-client-example.js
Created December 27, 2023 08:52
How to use Arduino IoT API with JavaScript
/*
* The Arduino iot-api JavaScript client has some instructions which seem a little bit outdated.
* https://github.com/arduino/iot-client-js/blob/master/README.md
*
* E.g. in the example the now deprecated `request-promise` is used to retrive the OAuth token.
*
* This gist shows how I was able to retrieve the token using `fetch` and async/await,
* using JSON instead of urlencoded form.
*
*/
@csarnataro
csarnataro / coloring-page.js
Created August 6, 2023 15:34
How to get a coloring page from an existing image (not tested)
// from phind.com
const img = new Image();
img.src = 'path-to-your-image.jpg';
img.onload = function() {
const canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, img.width, img.height);
};
@csarnataro
csarnataro / RP2040-decibel.ino
Created April 14, 2023 15:16
Arduino sketch to read volume (as decibels) and Gyroscope data from an Arduino Connect Rp2040 and send them to the Arduino cloud
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float gyroscope_X;
float gyroscope_Y;
float gyroscope_Z;
@csarnataro
csarnataro / main.js
Last active February 14, 2022 15:25
A script (not fully working) which tries to upload a sketch on an Arduino board using the Web Serial API.
import { Buffer } from 'buffer'
// HEX is a Uint8Array with the compiled code
import { HEX } from './hex';
import { sleep } from './sleep';
// convert an address padding it with 0 when needed
import { convertAddress } from './convertAddress';
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.