- Write functions() in lower case, KEYWORDS in upper.
STARTeach keyword clause
ONa new line.- Use either
camelCaseorsnake_casefor node identifiers but be consistent. - Relationship type names should use
UPPER_CASE_AND_UNDERSCORES. - Label names should use
CamelCaseWithInitialCaps. MATCH (clauses)-->(should)-->(always)-->(use)-->(parentheses)-->(around)-->(nodes)- Backticks `cân éscape odd-ch@racter$ & keyw0rd$` but should be a code smell.
This file contains hidden or 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 itertools import cycle, islice | |
| def round_robin(*iterables): | |
| """ Cycle through a number of iterables, returning | |
| the next item from each in turn. | |
| round_robin('ABC', 'D', 'EF') --> A D E B F C | |
| Original recipe credited to George Sakkis | |
| Python 2/3 cross-compatibility tweak by Nigel Small |
This file contains hidden or 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 is_collection(obj): | |
| """ Returns true for any iterable which is not a string or byte sequence. | |
| """ | |
| try: | |
| if isinstance(obj, unicode): | |
| return False | |
| except NameError: | |
| pass | |
| if isinstance(obj, bytes): | |
| return False |
This file contains hidden or 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
| try: | |
| unicode | |
| except NameError: | |
| # Python 3 | |
| def ustr(s, encoding="utf-8"): | |
| if isinstance(s, str): | |
| return s | |
| try: | |
| return s.decode(encoding) | |
| except AttributeError: |
This file contains hidden or 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 deprecated(message): | |
| """ Decorator for deprecating functions and methods. | |
| :: | |
| @deprecated("'foo' has been deprecated in favour of 'bar'") | |
| def foo(x): | |
| pass | |
| """ |
This file contains hidden or 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 | |
| # -*- encoding: utf-8 -*- | |
| from __future__ import print_function | |
| import random | |
| from time import time | |
| from py2neo import Graph, GraphError |
This file contains hidden or 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 | |
| # coding: utf-8 | |
| # Copyright 2017, Nigel Small | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or 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 dataclasses import dataclass, fields | |
| def neodataclass(_cls=None, *, init=True, repr=True, eq=True, order=False, | |
| unsafe_hash=False, frozen=False): | |
| """ Provides a wrapper around dataclass that silently filters out | |
| any keyword arguments provided to __init__ that do not exist as | |
| fields for that class. | |
| """ |
This file contains hidden or 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
| package tech.nige.demo; | |
| import javax.net.ssl.SSLContext; | |
| import javax.net.ssl.SSLSocket; | |
| import java.io.IOException; | |
| import java.net.InetSocketAddress; | |
| import java.security.NoSuchAlgorithmException; | |
| import java.security.cert.Certificate; | |
| public class SocketDemo { |
This file contains hidden or 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 | |
| # -*- coding: utf-8 -*- | |
| # Copyright 2012-2015, Nigel Small | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 |
OlderNewer