Skip to content

Instantly share code, notes, and snippets.

@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.
"""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):
@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 || {
@habnabit
habnabit / playground.rs
Last active September 28, 2017 02:57 — forked from anonymous/playground.rs
Rust code shared from the playground
use linux;
use log;
use core::fmt::Write;
use core::fmt;
use log::{LogRecord, LogLevel, LogMetadata};
#[derive(Default)]
struct DMesgLogger;
for location in locations:
for mode in ['driving', 'transit']:
row = [place, mytime, mode]
for i in range(10):
mytime += timedelta(minutes=20)
row.append(get_directions(location, (lat,lon), mytime, mode, gmaps))
csv_file.writerow(row)
use sodiumoxide::crypto::box_::{SecretKey, PublicKey};
use typemap::TypeMap;
use std::sync::{Arc, RwLock};
use llsd::frames::{Frame, FrameKind};
use llsd::session::server::Session;
use llsd::session::Sendable;
use llsd::sessionstore::SessionStore;
use llsd::authenticator::Authenticator;
use errors::{AWResult, AWErrorKind};
from ometa.grammar import OMeta
from ometa.interp import TrampolinedGrammarInterpreter
from parsley import makeGrammar
import sys
grammar = """
hex_digit = digit | 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
import sqlite3
from collections import defaultdict
DATABASE = 'C:/Misc/myscripts/workprototype/workprototype.db'
conn = sqlite3.connect(database=DATABASE)
curs = conn.cursor()
prod_dict = {}
curs.execute('select name, desc from companies')
# -*- coding: utf-8 -*-
#
# Copyright 2013 Liftoff Software Corporation
#
# For license information see LICENSE.txt
# Meta
__version__ = '1.0.0'
__version_info__ = (1, 0, 0)
__license__ = "Apache 2.0"
@habnabit
habnabit / tcp-proxy.py
Last active December 11, 2015 22:38 — forked from fiorix/tcp-proxy.py
import sys
from twisted.internet import defer, protocol, task, endpoints
from twisted.python import log
class ProxyClientProtocol(protocol.Protocol):
def connectionMade(self):
log.msg("Client: connected to peer")