Skip to content

Instantly share code, notes, and snippets.

View clydebarrow's full-sized avatar

Clyde Stubbs clydebarrow

View GitHub Profile
@clydebarrow
clydebarrow / .gitignore
Last active November 1, 2024 20:42
ESPHome LVGL samples
# Gitignore settings for ESPHome
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml
/wifi.yaml
@clydebarrow
clydebarrow / .gitignore
Last active October 27, 2024 09:48
LVGL watch face in ESPHome yaml
# Gitignore settings for ESPHome
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml
/wifi.yaml
@clydebarrow
clydebarrow / lvgl.yaml
Created November 16, 2023 21:00
Sample YAML for LVGL config in ESPHome.
color:
- id: color_back
hex: FF0000
- id: color_blue
hex: 0000FF
lvgl:
color_depth: 16
bg_color: 0xFFFFFF
style_definitions:
@clydebarrow
clydebarrow / deta_6922ha_2.yml
Last active May 27, 2023 22:48
Libretiny/ESPHome config for Deta 6922HA Series 2 smart dual outlet
# Note that the passwords etc. in this example are completely bogus.
substitutions:
name: "deta-6922ha-01"
friendly_name: "Dual outlet"
project_name: "DETA.6922HA"
project_version: "1.0"
device_description: "Indoor 2 gang outlet"
esphome:
name: "${name}"
@clydebarrow
clydebarrow / modescode.py
Created December 21, 2022 02:19
Convert VH aircraft registration code to ICAO mode-S identifier
import sys
def getVal(ch):
if ch >= 'A' and ch <= 'Z':
return ord(ch) - ord('A')
if ch >= '0' and ch <= '9':
return ord(ch) - ord('0') + 26
return -1
@clydebarrow
clydebarrow / greatcircle.c
Last active June 19, 2022 08:37
Command line utility to calculate great circle distance using the spherical law of cosines
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
static double getRadians(const char * str, double limit, const char * msg) {
char * endptr;
double val = strtod(str, &endptr);
if(endptr != str && val < limit && val > -limit)
return val * 0.0174533; // convert to radians
fprintf(stderr, "Invalid value for %s: %s\n", msg, str);
@clydebarrow
clydebarrow / MyViewController.kt
Last active October 18, 2021 23:21
XLayout sample
package com.mycompany.myapp
import com.controlj.layout.FrameGroup
import com.controlj.layout.Gravity
import com.controlj.layout.HorizontalGroup
import com.controlj.layout.IosUxHost
import com.controlj.layout.Layout
import com.controlj.layout.VerticalGroup
import com.controlj.layout.VerticalGroup.Companion.verticalGroup
import com.controlj.shim.IosCxFactory
@clydebarrow
clydebarrow / listProfiles.py
Last active July 12, 2021 06:33
List Apple provisioning profiles with certificate information
import os
import plistlib
import hashlib
from cryptography import x509
profileLib = os.getenv("HOME") + "/Library/MobileDevice/Provisioning Profiles"
for filename in os.listdir(profileLib):
stream = os.popen('security cms -D -i "' + profileLib + '"/' + filename)
input = stream.read()
@clydebarrow
clydebarrow / IosSchedulers.kt
Created May 18, 2021 10:39
Main thread scheduler for RxJava on iOS. Used with RoboVM.
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@clydebarrow
clydebarrow / NetworkStatus.kt
Last active March 5, 2021 02:50
Check network reachability on iOS using RoboVM in Kotlin
package com.controlj.framework
import com.controlj.rx.DisposedEmitter
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.ObservableEmitter
import io.reactivex.rxjava3.schedulers.Schedulers
import org.robovm.apple.dispatch.DispatchQueue
import org.robovm.apple.foundation.NSOperatingSystemVersion
import org.robovm.apple.foundation.NSProcessInfo
import org.robovm.apple.network.NWPathMonitor