Skip to content

Instantly share code, notes, and snippets.

@matt2005
matt2005 / plextoken.ps1
Created September 15, 2017 21:28
Plex x-token
$Credential=Get-Credential -Message 'Plex Credentials'
$url = "https://plex.tv/users/sign_in.xml"
$BB = [System.Text.Encoding]::UTF8.GetBytes($('{0}:{1}' -f $Credential.GetNetworkCredential().Username,$Credential.GetNetworkCredential().Password))
$EncodedPassword = [System.Convert]::ToBase64String($BB)
$headers = @{}
$headers.Add("Authorization","Basic $($EncodedPassword)") | out-null
$headers.Add("X-Plex-Client-Identifier","HASS") | Out-Null
$headers.Add("X-Plex-Product","Home Assistant") | Out-Null
$headers.Add("X-Plex-Version","V1") | Out-Null
[xml]$res = Invoke-RestMethod -Headers:$headers -Method Post -Uri:$url
@matt2005
matt2005 / _readme.md
Created September 13, 2017 19:46 — forked from ajfisher/_readme.md
Auto WiFi detection and hotspot creation in boot for RPI

Auto WiFi detection or wifi hostpot creation during boot for RPI

Note: These are rough notes and there may be some variance as versions of raspbian get updated but should be pretty reliable as a guide.

This gist provides some instructions and config in order to have your Raspberry PI automatically connect to a roamed network, however if it fails to discover an available network it will set itself up as a wireless access point for you to connect to.

test_sensors:
module: testsensors
class: TestSensors
heating_test:
module: heatinglogic
class: HeatingLogic
sensor_temperature_flow_actual: sensor.heating_flow_temp
sensor_temperature_outside_actual: sensor.heating_outside_temp
input_temperature_inside_setpoint: input_slider.heating_setpoint_temp
switch_heating: switch.heating
@matt2005
matt2005 / Get-RegistryKeyType.ps1
Created August 1, 2017 12:03
Get-RegistryKeyType
Function Get-RegistryKeyType
{
# https://msdn.microsoft.com/en-us/library/windows/desktop/ms724884(v=vs.85).aspx
param(
$Path,
$key
)
$SplitRegPath = $Path.Split(':\')
$Path = $Path.Replace($('{0}:\' -f $SplitRegPath[0]),'')
Switch -regex ($SplitRegPath[0]){
@matt2005
matt2005 / add-function-with-param.ps1
Created June 23, 2017 09:17 — forked from sayedihashimi/add-function-with-param.ps1
PowerShell: Add a function with a parameter to an object
$result | Add-Member -MemberType ScriptMethod ExpandString -Value {
[cmdletbinding()]
param(
[Parameter(
Mandatory=$true)]
[string]
$unexpandedValue
)
process{
if($this.ProjectInstance){
@matt2005
matt2005 / sort_photos.ps1
Last active July 28, 2017 20:40
sort photos via powershell
$srcFolder = "$env:USERPROFILE\Desktop\testing\New folder"
$targetFolder = "$env:USERPROFILE\Desktop\testing\sorted"
$files = Get-ChildItem -Path $srcFolder -include *.* -Recurse
foreach ($file in $files){
try{
$path = $file.FullName
$shell = New-Object -COMObject Shell.Application
$folder = Split-Path -Path $path
@matt2005
matt2005 / Attiny85_batteryMonitor.ino
Created March 18, 2017 21:24 — forked from dwhacks/Attiny85_batteryMonitor.ino
Attiny battery monitor with tiny core.
/*
Attiny85_batteryMonitor
Ideas borrowed from: https://github.com/unixbigot/Flat-Mate
modified for arduino tiny core by DWhacks
*@@ Voltage trigger levels.
*
@matt2005
matt2005 / configuration
Created January 13, 2016 23:22 — forked from carmolim/configuration
My last configuration.yaml file for my Home Assistant setup (HA, HASS)
homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: ******
longitude: ******
# C for Celcius, F for Fahrenheit
temperature_unit: C
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: America/Sao_Paulo
homeassistant:
name: Home
latitude: <LATITUDE>
longitude: <LONGITUDE>
# C for Celcius, F for Fahrenheit
temperature_unit: C
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: Europe/Copenhagen
customize:
device_tracker.mads_desktop:
@matt2005
matt2005 / configuration.yaml
Created January 13, 2016 23:16 — forked from tomduijf/configuration.yaml
Home Assistant configuration
#################################################################
## Main and component setup
#################################################################
homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: [REDACTED]
longitude: [REDACTED]
# C for Celcius, F for Fahrenheit