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: ZHA - Lutron Aurora Dimmer v1.3 | |
description: 'Control lights with a Lutron Aurora Dimmer | |
Pressing in the dimmer button will toggle between turning lights on | |
to full brightness, and turning the lights off. | |
Rotating the dimmer will increase and decrease the light brightness. | |
Adjust the sensitivity if updates from the dimmer are being sent too quickly | |
' | |
domain: automation |
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
def CaseClass(case_class_name, **kwargs): | |
types = {} | |
for k, v in kwargs.items(): | |
if type(v) is not type: | |
raise ValueError("{} is not a type".format(v)) | |
types[k] = v | |
class CaseClassImpl(): | |
initialized = False |
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
-- When using aws_s3.query_export_to_s3, on Aurora Postgres, version 11, data is reliably and predictably corrupted at certain positions of the payloads that land in s3. | |
-- It seems that when data falls over a certain byte length, it is reset and resent mid-stream to s3. | |
-- We have been able to reproduce this positively, as well as reproduce a negative as well; ensuring that data falls at powers of 2 on even byte lengths seems to prevent this issue from occurring. | |
-- As the length of data increases, as does the frequency of the corruption. For small data sets, it may never surface. | |
-- You will see upon running this SQL that it occurs once in 100,000 records with 128+9 byte length records, twice for 256+9, and 4 times for 512+9, and so-on, where each record looks like {"A":""}\n where \n is a new line control character, amounting to 9 extra bytes on top of the value in the JSON objects. | |
-- these queries will result in broken json in s3 | |
select * from aws_s3.query_export_to_s3( | |
'select row_to_json(test) fr |
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
#!/usr/bin/env python3 | |
import unittest | |
def flattenIntArray(arr): | |
'''Yield flattened elements from input array''' | |
for element in arr: | |
try: | |
yield from flattenIntArray(element) |
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
#!/usr/bin/env python | |
import unittest | |
from sympy import sieve | |
import numpy as np | |
def generatePrimes(num_primes): | |
""" | |
Returns an array of primes. |
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
#!/usr/bin/env python | |
import itertools | |
import unittest | |
def primeGenerator(): | |
""" | |
Yields an array of primes. | |
""" |
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
#!/usr/bin/env python3 | |
""" | |
This is a 100% self-contained script to facilitate automated creation of bidirectional UDP pinholes. | |
It should work as a non-root user assuming you use a high port number. | |
All that is necessary is an SSH server with a Python environment. | |
This script is ran on the client, and then the client runs it on the server dynamically. | |
No permanent changes are made to the server. | |
Basically we just open UDP connection from both ends, to the same port, and then exchange some tokens to verify connectivity. |
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
ModelView | |
--------- | |
# field1 (->Model1), field2 (->Model2) filtered by field1 values | |
column_filter_by = ('field2') | |
form_widget_args = { | |
'field2': { | |
'data-filter-by': 'field1', | |
} | |
} |
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
#!/usr/bin/env python | |
def str_to_hex(string): | |
return "-".join("{:02x}".format(ord(c)) for c in str(string)) | |
def chunks(s, n): | |
for start in range(0, len(s), n): | |
yield s[start:start+n] | |
delimiter = '%-12345X@PJL' |
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 FilterLowercase(BaseMongoEngineFilter): | |
def apply(self, query, value): | |
flt = {'%s__icontains' % self.column: value} | |
return query.filter(**flt) | |
def operation(self): | |
return gettext('contains') | |
class FilterLowercaseNot(BaseMongoEngineFilter): | |
def apply(self, query, value): |