Skip to content

Instantly share code, notes, and snippets.

@LarsBergqvist
LarsBergqvist / systemmonitor.py
Created March 15, 2017 04:03
Make MQTT messages from system monitoring values on a Raspberry Pi
#!/usr/bin/env python3
import paho.mqtt.publish as publish
from subprocess import check_output
from re import findall
import psutil
import sys
def get_temp():
temp = check_output(["vcgencmd","measure_temp"]).decode("UTF-8")
return(findall("\d+\.\d+",temp)[0])
@LarsBergqvist
LarsBergqvist / subscriber_mongodb.py
Last active October 9, 2022 12:42
An MQTT subscriber client that persists data in a MongoDB database
#!/usr/bin/env python3
import paho.mqtt.client as mqtt
import datetime
from pymongo import MongoClient
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
client.subscribe("Home/#")
@LarsBergqvist
LarsBergqvist / platformio.ini
Created August 8, 2017 10:34
Platform IO ini-file example
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html
@LarsBergqvist
LarsBergqvist / automation.yaml
Last active November 8, 2021 18:02
Home Assistant automation for turning lights on and off based on sunset and sunrise
automation:
- alias: Turn on garden lights when sun sets
trigger:
platform: sun
event: sunset
action:
service: switch.turn_on
entity_id: switch.garden_lights
- alias: Turn off garden lights when sun rises
@LarsBergqvist
LarsBergqvist / cd.yml
Created July 28, 2021 18:23
GitHub Actions workflow for the memory card game
name: Continuous Deployment
on:
push:
branches: [master]
jobs:
test-build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
@LarsBergqvist
LarsBergqvist / .travis.yml
Created July 28, 2021 18:17
Old travis-file for the memory card game appplication
dist: xenial
sudo: false
language: node_js
node_js:
- "10"
cache:
directories:
- ./node_modules
name: Continuous Deployment
on:
push:
branches: ['**']
jobs:
test-and-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
@LarsBergqvist
LarsBergqvist / cd.yaml
Created July 28, 2021 11:08
deploy job
deploy:
needs: test-and-build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: build-artifacts
name: Continuous Deployment
on:
push:
branches: ['**']
jobs:
yarn-install-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
const initialState = {
moves: 0,
gameComplete: false,
imageNumber: 1,
tiles: [],
size: undefined,
gameId: undefined,
gameName: undefined
};