This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 || { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use linux; | |
use log; | |
use core::fmt::Write; | |
use core::fmt; | |
use log::{LogRecord, LogLevel, LogMetadata}; | |
#[derive(Default)] | |
struct DMesgLogger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import treq | |
from twisted.internet import defer, task | |
def testD(): | |
def makeRequest(): | |
d = treq.get('http://example.com/') | |
d.addErrback(handleError) | |
return d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
NewerOlder