Skip to content

Instantly share code, notes, and snippets.

@habnabit
habnabit / ircbot.py
Last active January 26, 2023 09:09
an example IRC bot using twisted
import sys
from twisted.internet import defer, endpoints, protocol, reactor, task
from twisted.python import log
from twisted.words.protocols import irc
class MyFirstIRCProtocol(irc.IRCClient):
nickname = 'MyFirstIrcBot'
@habnabit
habnabit / wake-up-light-alarm-with-sunrise-effect.yaml
Last active December 24, 2022 18:30 — forked from sbyx/wake-up-light-alarm-with-sunrise-effect.yaml
Home Assistant Blueprint: Wake-up light alarm with sunrise effect
blueprint:
name: Wake-up light alarm with sunrise effect
description: 'A wake-up light alarm with a brightness and color temperature sunrise
effect. Note: Requires date_time_iso sensor in configuration, not manually executable!'
domain: automation
input:
light_entity:
name: Wake-up light entity
description: The light to control. Turning it off during the sunrise will keep
it off. Color temperature range is auto-detected.
@habnabit
habnabit / chatserver.py
Created September 29, 2012 20:10
one expression chatserver
main = lambda port: (lambda dt: (lambda mm: (lambda n: (map(lambda r: (lambda
rr: setattr(n, *rr) if (type(rr) is tuple and len(rr) == 2) else None)(r()),
[lambda: map(setattr, *zip(*[(n, m, __import__(m)) for m in mm.m.decode('ba'
'se64').split()])), lambda: map(n.s['signal.signal'], (n.s['signal.SIGINT'],
n.s['signal.SIGTERM']), [lambda s, f: (n.s['sys.exit']() if n.f else [n.sa(
mm.l[0], n.o)] and n.u('f', True) or n.fc(n.l))] * 2), lambda: setattr(mm,
'l', mm.l.decode('base64').split('~~~')), lambda: ('sw', n.s['types.Functio'
'nType'] (compile("try:\n\tv = n.select.select(n.so, n.w(), [])\nexcept n.s"
"elect.error, e:\n\tif e[0] != n.errno.EINTR: raise\nelse:\n\tn.u('sr', v)",
'', 'exec'), dict(n=n, OSError=OSError))),lambda: ('l', n.s['socket.socket']
--> habnabit__ (32f0dc45@50-240-220-69-static.hfc.comcastbusiness.net) has joined #freenode-chit
<@ChitBot> [126] Chit posted by habnabit__ https://chit.freenode.net/u/habnabit__/126.html
[#freenode-chit] [126] help #python is under attack by freenode management&mdash;we're all on libera.chat now [habnabit__]
--> rasengan (rasengan@freenode/staff/rasengan) has joined #freenode-chit
-- Mode #freenode-chit [+o rasengan] by ChanServ
<@rasengan> del 126
<@ChitBot> Chit [126] has been deleted.
<@ChitBot> [127] Chit posted by habnabit__ https://chit.freenode.net/u/habnabit__/127.html
<@ChitBot> Chit [127] has been deleted by the original chitter.
<@ChitBot> [128] Chit posted by habnabit__ https://chit.freenode.net/u/habnabit__/128.html
@habnabit
habnabit / .gitignore
Last active May 20, 2021 11:15
resume
*.pdf
@habnabit
habnabit / _output.txt
Last active August 23, 2020 08:42
cffi with numpy example
[2.99616175+5.54885256j 2.50767967+4.65893257j 4.13392399+1.69048949j
0.93860821+1.46470066j 5.6235234 +2.36071585j 2.28013476+4.78671259j
3.34736328+4.25295228j 5.7851614 +5.63424175j 1.90595192+2.16040048j
1.62844748+0.06384722j 0.89949666+4.65337538j 1.95680565+2.67681418j
5.78686059+5.3124304j 1.9592114 +0.16909678j 2.01095818+3.03112179j
4.20331404+3.13157214j 0.05917195+2.77188645j 5.47970406+1.40063894j
2.05722142+2.48133127j 4.59507957+5.93884264j 0.17166239+4.79953363j
5.44861648+1.22816477j 3.39911951+2.21297174j 0.01094132+0.19348674j
0.82714832+1.73206116j]
[0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j
@habnabit
habnabit / pebble.rs
Last active September 28, 2019 18:52
// https://www.youtube.com/watch?v=kZRFlgV5KVU
#![crate_type="staticlib"]
#![no_std]
#[macro_use]
extern crate pebble;
use pebble::Layer;
"""Please, let me know which child is calling me: 'parent' ? """
class A:
"""This is a mixin class to share code for DRY"""
def __init__(self, var=None):
super().__init__()
self.override_me()
def override_me(self):
21:02:38 < Owner> who is this loser in the press conference
21:02:49 < Owner> what a clown
21:03:19 < Owner> somehow this guy gets 4 bullshit questions in a row
21:07:52 < Owner> https://nypost.com/2018/07/16/swimsuit-model-breastfeeds-on-the-catwalk/
21:07:59 < Owner> liberal flipout in 3...2...
21:11:37 < Owner> 1. she didnt abort the baby
21:11:41 < Owner> 2. she is being a mother
21:11:46 < Owner> 3. she is a real woman and not a tranny
21:11:59 < Owner> thats enough reason to make them flip out hard
21:19:50 < Owner> lol https://i.redd.it/tylfuzfd5ba11.jpg
@habnabit
habnabit / playground.rs
Created July 2, 2018 03:45 — forked from rust-play/playground.rs
Code shared from the Rust Playground
let pipeline = framed_reader
.map(move |b| {
let message: proto::Message = bincode::deserialize(&b).unwrap();
let file;
let blocking_future;
match message {
proto::Message::Request(m) => {
file = m.file.clone();
if m.file == Path::new("/root/test/file").to_path_buf() {
blocking_future = poll_fn(move || {