Skip to content

Instantly share code, notes, and snippets.


Pedro Lamas pedrolamas

View GitHub Profile
pedrolamas / test.yaml
Created May 21, 2021
Home Assistant sensor for IKEA Tradfri feed update check
View test.yaml
- platform: command_line
name: IKEA Tradfri OTA feed
command: >-
python3 -c "import hashlib, json, requests; response = requests.get(''); 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 }}'
- Date
- ETag
scan_interval: 10800
pedrolamas / _headers
Created Mar 24, 2021
Netlify headers generated by gatsby-netlify-plugin for 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
Content-Type: application/manifest+json
pedrolamas /
Created Aug 18, 2020
Script to fix Docker iptables on Synology NAS
while [ $currentAttempt -lt $totalAttempts ]
currentAttempt=$(( $currentAttempt + 1 ))
echo "Attempt $currentAttempt of $totalAttempts..."
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 /
Last active Mar 10, 2021
Script to fix Docker iptables on Synology NAS
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 -j DOCKER
stop() {
iptables -t nat -D PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
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
var dispatcher = Window.Current.Dispatcher;

GPG Cheat Sheet

Generating a new key

gpg --gen-key

gpg --expert --full-gen-key
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;

Keybase proof

I hereby claim:

  • I am pedrolamas on github.
  • I am pedrolamas ( on keybase.
  • I have a public key ASC1NVaCf8XHix-iLfc6BG864vBxGvmzdRB6cBG36TdCowo

To claim this, I am signing this object:

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