Skip to content

Instantly share code, notes, and snippets.

@liam-russell
liam-russell / Readme.md
Last active May 6, 2024 23:30
TP-Link Kasa Smart Plug - get energy consumption statistics as a CSV file

TP-Link Kasa Smart Plug - get energy consumption statistics as a CSV file

Background

The TP Link Kasa smart switches log energy consumption data over time, however the app is very limited and won't let you get out data, graph it or see historical usage. This script extracts and saves to a CSV file.

The python-kasa library is used to communicate with the Kasa switch.

Requirements

  • Python must be installed
  • You must be on the same wifi network as the Kasa switch
@russellmcc
russellmcc / fish.el
Last active May 6, 2024 23:29
How to use fish shell paths from emacs
(let*
((fish-path (shell-command-to-string "/opt/homebrew/bin/fish -i -c \"echo -n \\$PATH[1]; for val in \\$PATH[2..-1];echo -n \\\":\\$val\\\";end\""))
(full-path (append exec-path (split-string fish-path ":"))))
(setenv "PATH" fish-path)
(setq exec-path full-path))
@theskumar
theskumar / restricted_usernames.py
Created April 9, 2015 06:48
Restricted usernames
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
'''
List of reserved usernames (pre-defined list of special banned and reserved keywords in names,
such as "root", "www", "admin"). Useful when creating public systems, where users can choose
a login name or a sub-domain name.
__References:__
1. http://www.bannedwordlist.com/
2. http://blog.postbit.com/reserved-username-list.html
@MyITGuy
MyITGuy / file01.ps1
Last active May 6, 2024 23:21
PowerShell: Get-MsiProducts / Get Windows Installer Products
function Get-MsiProducts {
function Get-MsiUpgradeCode {
[CmdletBinding()]
param (
[System.Guid]$ProductCode
,
[System.Guid]$UpgradeCode
)
function ConvertFrom-CompressedGuid {
@zytek
zytek / README.md
Last active May 6, 2024 23:16
Terraform to manage AWS RDS PostgreSQL databases, users and owners

Terraform vs PostgreSQL RDS

Thanks to new resources (postgresql_default_priviledges) and some fixes Terraform can now add new databases and manage ownership / access to them.

This example creates new database and two users. You can use owner to create new tables and run migrations and user for normal read/write access to database.

@mrispoli24
mrispoli24 / setting-up-heroku-and-cloudflare.md
Created October 15, 2018 18:41
Setting up Heroku and Cloudflare (the right way)

Setting up Heroku and Cloudflare (the right way)

The following outlines how to setup Heroku + Cloudflare with a full SSL certificate. What this means is that communication between the browser and the Cloudflare CDN is encrypted as well as communication between Cloudflare and Heroku’s origin server. Follow these steps exactly and the setup is a breeze.

Step 1: Set up domain names in Heroku

First you want to add the root domain and the www domain to heroku. You do this by clicking into your production application, then going to settings and then scrolling down to Domains and certificates.

Here you will add <your_domain>.com and www.<your_domain>.com. This will give you two CNAME records. They will look something like <your_domain>.com.herokudns.com and www.<your_domain>.com.herokudns.com.

Step 2: Add CNAME records to Cloudfare.

@wojteklu
wojteklu / clean_code.md
Last active May 6, 2024 23:15
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules