Skip to content

Instantly share code, notes, and snippets.

View juliancheal's full-sized avatar

Julian Cheal juliancheal

View GitHub Profile
# https://github.com/auto3000/RPi.GPIO_NP/blob/master/create_gpio_user_permissions.py
import grp
import subprocess
def ensure_gpiogroup():
try:
grp.getgrnam('gpio')
except KeyError:
print('GPIO group does not exist - creating...')
subprocess.call(['groupadd', '-f', '-r', 'gpio'])
@juliancheal
juliancheal / user-data-wifi.yml
Created March 15, 2019 15:10 — forked from DieterReuter/user-data-wifi.yml
HypriotOS cloud-init configuration for RPi3 WiFi Client
#cloud-config
# vim: syntax=yaml
#
# The current version of cloud-init in the Hypriot rpi-64 is 0.7.9
# When dealing with cloud-init, it is SUPER important to know the version
# I have wasted many hours creating servers to find out the module I was trying to use wasn't in the cloud-init version I had
# Documentation: http://cloudinit.readthedocs.io/en/0.7.9/index.html
# Set your hostname here, the manage_etc_hosts will update the hosts file entries as well
@juliancheal
juliancheal / toggle.py
Last active September 22, 2022 01:58
Sonoff light switch toggle via MQTT
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
import paho.mqtt.publish as publish
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
button_on = False
while True:
if GPIO.input(10) == GPIO.HIGH and button_on == False:
@juliancheal
juliancheal / A Hypriot K8S install.md
Created January 3, 2019 22:24 — forked from elafargue/A Hypriot K8S install.md
K8s (v1.10.5) on Hypriot (July 2018)
@juliancheal
juliancheal / sonoff.rb
Created August 30, 2018 13:26 — forked from krtschmr/sonoff.rb
controll a sonoff-tasmota device via ruby
# Free to use. if you modify it, pls let me know, i might need your code aswell :-)
# github: krtschmr
# tim@krtschmr.de
# USAGE
# Straightforward
# Sonoff.on!("192.168.1.53")
# Sonoff.off!("192.168.1.53")
@juliancheal
juliancheal / LoadConfig.rb
Created November 1, 2017 22:19 — forked from guyhughes/LoadConfig.rb
Ruby: Load the best available config file using ::YAML, of course
require 'thor'
class_option :config, :type => :string, :aliases => "-c", :desc => "Use an alternative YAML config file."
def initialize(*args)
super
config_files = Array.new
config_files.push(options[:config]) if options[:config]
config_files.push("#{ENV['XDG_CONFIG_HOME']}/awesomeness/awesomeness.yaml") if ENV['XDG_CONFIG_HOME']
config_files.push("#{ENV['HOME'] || '~'}/.config/awesomeness.yaml")
@juliancheal
juliancheal / extract_ovirt.sh
Created May 9, 2017 18:30 — forked from durandom/extract_ovirt.sh
extract a provider
#!/usr/bin/env bash
~/src/scratch/manageiq/extract_provider_gem.sh \
-n ovirt \
-d "app/models/manageiq/providers/redhat spec/models/manageiq/providers/redhat spec/vcr_cassettes/manageiq/providers/redhat" \
-l \
-e ~/src/manageiq \
-r \
-g ~/src/manageiq \
-p durandom \
@juliancheal
juliancheal / api_structure.md
Created November 17, 2016 23:24
API Structure of the Yeelight BLE lamp bits and bobs

API

UUID Character Length Permission Description
0xFFF1 Control 18 Read/Write Control the color/light/on/off of LED
0xFFF2 Delay On/Off 8 Read/Write Set delay on/off for LED
0xFFF3 Delay On/Off Status 2 Read/Write Query the status of delay on/off Query
0xFFF4 Delay On/Off Status 10 Notify Notify the status of delay on/off Response
0xFFF5 Status Query 1 Read/Write Query the status of LED
0xFFF6 Status Response 20 Notify Notify the status of LED
@juliancheal
juliancheal / sonic_synth.rb
Created October 26, 2016 22:49
Simple Tune in Sonic Pi controlling three analog synths
require 'drb/drb'
DRb.start_service
synth = DRbObject.new_with_uri('druby://localhost:9999')
use_bpm 135
live_loop :drums do
2.times do
synth.note(36,:volca_beats)
sleep 0.5
@juliancheal
juliancheal / dabblet.css
Last active March 28, 2016 17:15
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(0deg, yellow, #f06, red, purple);
min-height: 100%;