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
#lang racket/base | |
(require plot) | |
(require racket/gui) | |
(define temp-readings (make-hash)) | |
(define (list-thermal-zones) |
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 SelectiveRetryPythonOperator(PythonOperator): | |
""" | |
Allows only retrying certain types of exception by altering max_tries | |
""" | |
def __init__(self, | |
retry_for=None, | |
func_args=None, | |
func_kwargs=None, |
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 ProbeOperator(PythonOperator): | |
def __init__(self, *args, attempts=None, interval=None, probe_timeout=None, **kwargs): | |
assert isinstance(attempts, int) | |
assert isinstance(interval, timedelta) | |
assert isinstance(probe_timeout, timedelta) | |
self.probe_timeout = probe_timeout | |
self.attempts = attempts | |
kwargs['retries'] = attempts |
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 datetime import datetime | |
from airflow.models import DAG | |
from airflow.operators.dummy_operator import DummyOperator | |
from airflow.operators.python_operator import PythonOperator | |
from airflow.operators.subdag_operator import SubDagOperator | |
DAG_NAME = 'example_subdag_operator' | |
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
" Run cypher query and return result | |
function! EvalCypher() | |
let src = expand("%") | |
let dst = tempname() | |
execute ":silent !cat " . src . " | cypher -f json -H localhost &> " . dst | |
execute ":pedit! " . dst | |
execute ":redraw!" | |
wincmd P | |
setlocal syntax=javascript | |
retab |
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
# nodes.csv | |
category name age size | |
Person | |
Company | |
Google 1000 | |
Amit Gupta 15 | |
# rels.csv | |
start end type __instance__:boolean | |
1 4 PERSON true |
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 neomodel import StructuredNode, StringProperty, IntegerProperty | |
class Person(StructuredNode): | |
facebookid = StringProperty(unique_index=True) | |
age = IntegerProperty(index=True, default=0) | |
Person(facebookid="f434234ef", age=8).save() | |
Person(facebookid="f434234ef", age=8).save() # raises a UniqueProperty exception |
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 .. import RelationshipTo, StructuredNode, StringProperty | |
from .core import NodeIndexManager | |
class Language(StructuredNode): | |
code = StringProperty(unique_index=True) | |
name = StringProperty() | |
class LocalisedIndex(NodeIndexManager): | |
""" Only return results in current language """ |
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
START country_cat = node:Category(category="Country"), | |
nationality_cat = node:Category(category="Nationality"), | |
passport_cat = node:Category(category="Passport") | |
CREATE UNIQUE | |
(country_cat)-[:COUNTRY {__instance__: true}]->(country {code: 'GB'}) | |
-[:NATIONALITY]-> | |
(nationality {code: 'GB-GB'}) | |
-[:PASSPORT]-> | |
(passport {code: 'GB-GB-P'}), |
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
@classmethod | |
def lookup(cls, uid=None): | |
lang = translation.get_language().replace('-', '_') | |
query = """ | |
START lang = node:Language(code:{lang}), | |
node = node:%s(uid:{uid}) | |
MATCH (node)-[:LANGUAGE]->(lang) | |
RETURN node | |
""" % (cls.__name__) | |
r = cls.category().cypher(query, {'uid': uid, 'lang': lang})[0] |
NewerOlder