Skip to content

Instantly share code, notes, and snippets.

View nbeirne's full-sized avatar

Nick nbeirne

  • Zscaler
  • Toronto, ON
View GitHub Profile
@nbeirne
nbeirne / fizzbuzz_pretty.py
Last active November 28, 2024 22:58
fizzbuzz_pretty.py
# define true and false values as function application. f(a,b): a is true, f(a,b): b is false
true = lambda a: lambda b: a
false = lambda a: lambda b: b
# define a number `n` as a function `f` applied n times. 0 == f is called no times
_0 = lambda f: lambda x: x
# given a number we can get the next one or previous one with function application
succ = lambda n: lambda f: lambda x: f(n(f)(x))
@nbeirne
nbeirne / fizzbuzz.py
Last active October 8, 2025 02:56
fizzbuzz.py
c=lambda a: lambda b: a
d=lambda n: lambda f: lambda x: f(n(f)(x))
e=lambda n: lambda f: lambda x: n(lambda a: lambda b: b(a(f)))(lambda y: x)(lambda y: y)
g=lambda a,b: lambda f: lambda x: a(f)(b(f)(x))
h=lambda a,b: lambda f: lambda x: a(b(f))(x)
i=lambda a,b: b(e)(a)
j=lambda n: n(lambda x: lambda a: lambda b: b)(c)
k=d(lambda f: lambda x: x)
l=d(k)
m=d(l)
@nbeirne
nbeirne / fix_tlv.py
Created November 8, 2024 22:41
Homeassisant TLV fix
#!/usr/bin/env python3
import binascii
import json
import sys
# This is a temporary fix for this github issue: https://github.com/home-assistant/core/issues/127601
# Instructions:
# 1. MAKE A BACKUP OF YOUR HOMEASSISTANT. This changes system files.
# 2. Share your credentials using the ios app. You should make the apple thread credentials your preferred network.
https://${ip}/httpapi.asp?command=%@
https://${ip}/httpapi.asp?command=%@
https://${ip}/httpapi.asp?command=%@:%@
https://${ip}/httpapi.asp?command=%@:%d
https://${ip}/httpapi.asp?command=%@setTimezoneEx:%@:%d:%@
https://${ip}/httpapi.asp?command=Cast:DisableUsageReport
https://${ip}/httpapi.asp?command=Cast:EnableCast
https://${ip}/httpapi.asp?command=Cast:EnableUsageReport
https://${ip}/httpapi.asp?command=EQChangeFX:http://moddevices.com/plugins/caps/Eq10HP
https://${ip}/httpapi.asp?command=EQChangeFX:http://moddevices.com/plugins/caps/Eq4p
@nbeirne
nbeirne / prepare-commit-msg
Created March 26, 2022 13:35
A prepare-commit-msg git hook to prepend JIRA tickets to commit messages.
#!/bin/bash
# Put this into .git/hooks/prepare-commit-msg and mark it as executable
# This hook will prepend JIRA ticket numbers to your commit messages. It works with -m and with the plain `git commit`.
# This expects your branches to be in one of these formats:
# 1. `(feature|bug|fix)/JIRA-XXX-some-description`
# 2. `(feature|bug|fix)/JIRA-XXX`
# 3. `JIRA-XXX-some-description`
# 4. `JIRA-XXX`