Skip to content

Instantly share code, notes, and snippets.

@AlexDiru
AlexDiru / gist:3959450
Created October 26, 2012 15:31
Extract mantissa and exponent from a float
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//holds one bit
struct sbit
{
unsigned b : 1;
};
typedef struct sbit BIT;
@betrcode
betrcode / README.md
Created June 24, 2014 06:36
Using Python to check if remote port is open and accessible.
@aeroaks
aeroaks / sudoSample.py
Last active April 8, 2025 05:56
Run Sudo command using Python
import subprocess
# run command using Popen and provide password using communicate.
# password requires byte format.
# sudo -S brings password request to PIPE
proc = subprocess.Popen(['sudo', '-S', 'nano', 'test.txt'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate(input=b'password\n')
# Print output and errors
print(proc)
@nobodyguy
nobodyguy / tracker.ino
Last active September 21, 2022 03:13
GpsLoRaWANTracker using Arduino, RN2483 and L86/neo-m8n GPS module
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <avr/sleep.h>
#include <avr/power.h>
// ----------------------------------------------
// DEFINES
// ----------------------------------------------
#define rxGpsPin 10
#define txGpsPin 11
@lucabuka
lucabuka / gist:4601e0fa137f7b6873c47d220f82b23f
Created January 14, 2018 18:56
Test program to check WIFI CLOSE + RECONNECT on DOIT ESP32 DEVKIT V1
/**
* @file esp32_reconnect_demo.ino
* @brief Test program to check WIFI CLOSE + RECONNECT on DOIT ESP32 DEVKIT V1
*
* The program connect to the WiFI network and than to a NTP server
* It prints in the loop "getEpochTime()" response from NTP server.
* If the WiFI connection is lost, it reconnects.
* After printing 15 times "getEpochTime()", it DESCONNECT WiFi
* to test reconnect capabilities.
*
//==============================================================================
// ModbusRTU.cpp
//==============================================================================
/*-------------------------------------------------------------------------------
MODBUS RTU COMMUNICATION
Description:
Partial implementation of the Modbus RTU communication protocol.
@radames
radames / README.md
Last active March 4, 2024 06:44
How to connect to your Google Colab Notebook via SSH!

Connect to your Google Colab Notebook via SSH

Using this amazing project tmate.io you can SSH tunnel to your colab notebook machine. You can with few lines of code download the binary, run an instance in the background and output the generated SSH address.

!wget -nc https://github.com/tmate-io/tmate/releases/download/2.4.0/tmate-2.4.0-static-linux-i386.tar.xz &> /dev/null
!tar --skip-old-files -xvf tmate-2.4.0-static-linux-i386.tar.xz &> /dev/null
!rm -f nohup.out; bash -ic 'nohup ./tmate-2.4.0-static-linux-i386/tmate -S /tmp/tmate.sock new-session -d & disown -a' >/dev/null 2>&1
!./tmate-2.4.0-static-linux-i386/tmate -S /tmp/tmate.sock wait tmate-ready
@robidev
robidev / smv_publisher.ino
Last active August 5, 2025 00:56
An IEC 61850 sampled value publisher using an arduino mega and ehternet shield 2 for testing purposes. Period=250us, standard deviation is 3us max=10us
/*
SMV transmit:
This sketch sends sampled values
This code is in the public domain.
*/
#include <Ethernet.h>
#include <utility/w5100.h>
@robidev
robidev / smv_subscriber.ino
Created February 11, 2021 20:56
IEC 61850 SMV 9-2LE subscriber - this code uses the whiznet w5100 with interrupt-pin to accurately timestamp the moment a packet arrives, and allows to measure latency
/*
SMV receive
This sketch receives sampled values, and timestamps them
This code is in the public domain.
*/
#include <Ethernet.h>
#include <utility/w5100.h>
@dzonesasaki
dzonesasaki / xiao_sleepRtc.ino
Created May 19, 2021 07:02
sample of sleep and wakeup on RTC using seeeduino xiao and Arduino-IDE
// sleep and wake test using RTC
// for seeeduino xiao
#include "RTC_SAMD21.h" //install seeed_arduino_RTC : https://github.com/Seeed-Studio/Seeed_Arduino_RTC
#include "DateTime.h"
#include <EnergySaving.h>
EnergySaving myPowSave;
RTC_SAMD21 myRtc;
#define PIN_LED 13