Skip to content

Instantly share code, notes, and snippets.

@shelvacu
shelvacu / hass-remove-colorlog.patch
Created May 27, 2024 23:20
Remove dependency on colorlog in home-assistant core
diff --git a/homeassistant/scripts/check_config.py b/homeassistant/scripts/check_config.py
index d38e24a2..b3c9f59c 100644
--- a/homeassistant/scripts/check_config.py
+++ b/homeassistant/scripts/check_config.py
@@ -28,8 +28,6 @@ import homeassistant.util.yaml.loader as yaml_loader
# mypy: allow-untyped-calls, allow-untyped-defs
-REQUIREMENTS = ("colorlog==6.8.2",)
-
@shelvacu
shelvacu / flake.lock
Last active April 10, 2024 20:32
simple bug repro for jovian-nixos
{
"nodes": {
"jovian": {
"inputs": {
"nix-github-actions": "nix-github-actions",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
@shelvacu
shelvacu / dl.sh
Created March 12, 2022 11:46
Just download all google ngrams eng 2020
for f in {1-000{00..23}-of-00024,2-{00000..00588}-of-00589,3-{00000..06880}-of-06881,4-{00000..06667}-of-06668,5-{00000..19422}-of-19423}.gz
do
if [ -f "$f" ]
then
echo "Skipping $f"
else
wget 'http://storage.googleapis.com/books/ngrams/books/20200217/eng/'$f || break
fi
done
@shelvacu
shelvacu / Constitution.md
Created May 4, 2021 17:57
The CONstitution of the CONsortium

IN PROGRESS

The CONstitution of the CONsortium

Fungibles

Fungibles are indivisible units of currency that may be useful for other purposes.

Fungibles can not be created or destroyed.

@shelvacu
shelvacu / diesel_composite_macro.rs
Last active August 21, 2019 17:37
Simple macro for making types to interface with postgres composite types in diesel.
// diesel_composite_macro.rs - Simple macro for making types to interface with postgres composite types in diesel.
// Written in 2019 by Shelvacu <shelvacu@gmail.com>
// To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
// You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
/// Columns **must** be in the same order as database
// based on https://github.com/diesel-rs/diesel/issues/1732
macro_rules! composite_type {
(
@last=1;END{(@last<6) ? puts(6): ''}
@last.nil? ? puts((@last=2)-1): @last=2
(3-@last>1) ? puts((@last+=2)-1): @last=3
(4-@last>1) ? puts((@last+=2)-1): @last=4
(5-@last>1) ? puts((@last+=2)-1): @last=5
(6-@last>1) ? puts((@last+=2)-1): @last=6
# CC0: To the extent possible under law, Shelvacu has waived all copyright and related or neighboring rights to Reddit Place Event Recorder. This work is published from: United States.
# A ugly but simple logger for every event (pixel placements, participation number updates) on www.reddit.com/place
# First you need to `gem install websocket-client-simple`
require 'websocket-client-simple'
require 'open-uri'
$logprefix = "pixel-placement"
$lines = 0
@shelvacu
shelvacu / gist:d6621fb90248846f64c8a2a765076d5d
Last active February 15, 2017 11:31 — forked from liaohuqiu/gist:4ee77b9b03afcdecc80252252378d367
Find out the full duration time of a YouTube playlist
var list = document.getElementsByClassName('pl-video-time');
var time = 0;
function toS(hms) {
var a = hms.split(':');
while (a.length < 3) {
a.unshift(0);
}
var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
return seconds;
DtHIqH18R0IqH13R1K0FbjH2=+K-4b)RtKJsmtdr1QJ-QJ
DtH Define method t with argument H
IqH18 If H is equal to 18
R0 Return 0 (implicitly ends If block)
IqH13 If H is equal to 13
R1 Return 1
K0 Set variable K to 0
Fb For every value in 'jH2', set variable b to that value and execute block
jH2 Convert H to base 2 as an array of integers
=+K Set K to K + '-4b'
# WARNING: VERY UGLY CODE AHEAD
#
# Documentation of sorts:
# This is a library, so you have to require it eg require 'parker-chainfinder2.rb'
# The functions are:
#
# - translate(number)
# This translates from an integer to its english representation
# translate(5) #=> "Five"
# translate(5352) #=> "Five Thousand Three Hundred Fifty Two"