Skip to content

Instantly share code, notes, and snippets.

Avatar

Pedro Lamas pedrolamas

View GitHub Profile
@pedrolamas
pedrolamas / test.yaml
Created May 21, 2021
Home Assistant sensor for IKEA Tradfri feed update check
View test.yaml
sensor:
- platform: command_line
name: IKEA Tradfri OTA feed
command: >-
python3 -c "import hashlib, json, requests; response = requests.get('http://fw.ota.homesmart.ikea.net/feed/version_info.json'); ret = { 'ETag': response.headers.get('ETag'), 'Date': response.headers.get('Date'), 'Hash': hashlib.sha256(response.content).hexdigest() }; print(json.dumps(ret))"
value_template: '{{ value_json.Hash }}'
json_attributes:
- Date
- ETag
scan_interval: 10800
@pedrolamas
pedrolamas / _headers
Created Mar 24, 2021
Netlify headers generated by gatsby-netlify-plugin for pedrolamas.com website
View _headers
## Created with gatsby-plugin-netlify
/*
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: accelerometer=(), autoplay=(), ambient-light-sensor=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), usb=()
X-Content-Type-Options: nosniff
/manifest.webmanifest
Content-Type: application/manifest+json
@pedrolamas
pedrolamas / docker-iptables-fix.sh
Created Aug 18, 2020
Script to fix Docker iptables on Synology NAS
View docker-iptables-fix.sh
#!/bin/bash
currentAttempt=0
totalAttempts=10
delay=15
while [ $currentAttempt -lt $totalAttempts ]
do
currentAttempt=$(( $currentAttempt + 1 ))
echo "Attempt $currentAttempt of $totalAttempts..."
@pedrolamas
pedrolamas / elgato_cam_link_4k.txt
Last active Jun 19, 2020
Elgato Cam Link 4k output from USBView (before and after freezing)
View elgato_cam_link_4k.txt
@pedrolamas
pedrolamas / old-docker-iptables-fix.sh
Last active Mar 10, 2021
Script to fix Docker iptables on Synology NAS
View old-docker-iptables-fix.sh
#!/bin/bash
start() {
iptables -t nat -N DOCKER
iptables -t nat -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
iptables -t nat -A PREROUTING -m addrtype --dst-type LOCAL ! --dst 127.0.0.0/8 -j DOCKER
}
stop() {
iptables -t nat -D PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
@pedrolamas
pedrolamas / MultiWindowViewModelBase.cs
Last active Mar 21, 2018
Base view model that can be used in multiple windows
View MultiWindowViewModelBase.cs
public class MultiWindowViewModelBase : INotifyPropertyChanged
{
private readonly ConcurrentDictionary<CoreDispatcher, PropertyChangedEventHandler> _dispatchersAndHandlers = new ConcurrentDictionary<CoreDispatcher, PropertyChangedEventHandler>();
public event PropertyChangedEventHandler PropertyChanged
{
add
{
var dispatcher = Window.Current.Dispatcher;
View gpg-cheat-sheet.md

GPG Cheat Sheet

Generating a new key

gpg --gen-key

gpg --expert --full-gen-key
@pedrolamas
pedrolamas / CultureInfoHelper.cs
Last active Aug 15, 2021
Helper class to return the correct CultureInfo in UWP apps
View CultureInfoHelper.cs
using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
public class CultureInfoHelper
{
[DllImport("api-ms-win-core-localization-l1-2-0.dll", CharSet = CharSet.Unicode)]
private static extern int GetLocaleInfoEx(string lpLocaleName, uint LCType, StringBuilder lpLCData, int cchData);
private const uint LOCALE_SNAME = 0x0000005c;
View keybase.md

Keybase proof

I hereby claim:

  • I am pedrolamas on github.
  • I am pedrolamas (https://keybase.io/pedrolamas) on keybase.
  • I have a public key ASC1NVaCf8XHix-iLfc6BG864vBxGvmzdRB6cBG36TdCowo

To claim this, I am signing this object:

@pedrolamas
pedrolamas / Boxstarter.txt
Last active Aug 29, 2015
My personal Boxstarter script
View Boxstarter.txt
Enable-MicrosoftUpdate
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions
cinst DotNet4.5.1
cinst silverlight5developerruntime
cinst 7zip
cinst adobereader
cinst skype
cinst dropbox
cinst fiddler4