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};
import treq
from twisted.internet import defer, task
def testD():
def makeRequest():
d = treq.get('http://example.com/')
d.addErrback(handleError)
return d
class Foo():
@classmethod
def _fetch(cls, data):
response = requests.get("http://example.com/my/fun/data", data=data)
return cls(response.json())
class ChildFoo(Foo):
@classmethod
def get_latest(cls):
return cls._fetch({'fleeb':'farb', 'can':'dog'})
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')