Skip to content

Instantly share code, notes, and snippets.

View pkulak's full-sized avatar

Phil Kulak pkulak

View GitHub Profile
sensor:
- platform: template
sensors:
front_door_status:
value_template: >-
{%- if is_state("sensor.front_door_lock_type", "19") -%}
{%- if is_state("sensor.front_door_lock_level", "1") -%}
Matt
{%- elif is_state("sensor.front_door_lock_level", "2") -%}
Mark
@pkulak
pkulak / 100-prisoners-riddle.kt
Created July 1, 2022 21:31
100 Prisoners Riddle
fun main() {
var allUnder = 0
var anyOver = 0
repeat(500_000) {
val boxes = (0 until 100).toList().shuffled()
if (allUnderFifty(boxes)) {
allUnder++
} else {
@pkulak
pkulak / sanitizer.rs
Created April 6, 2023 02:13
Remove Segments From an Iterator
struct Sanitizer<I: Iterator> {
iter: PeekMoreIterator<I>,
needle: Vec<I::Item>,
}
impl<I: Iterator> Sanitizer<I>
where
I::Item: PartialEq,
{
fn new(haystack: I, needle: Vec<I::Item>) -> Self {
@pkulak
pkulak / kindle_download.js
Created September 30, 2024 14:46
Download all your Kindle books automation.
// How to use this?
// * Navigate to the first page of your "Digital Content -> Books" section.
// * Figure out where your kindle is in the list and update `deviceIndex` below.
// * Open up a dev console and paste all of this in.
// * Type `downloadAll(0);` into the dev console and hit enter.
// * Repeat the above step for each page of books.
//
// This is tested in latest Firefox, and will probably break the second Amazon
// changes anything on the pages used.