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 threading import Thread | |
| from multiprocessing import Process | |
| from os import remove | |
| from time import time | |
| class IOTest: | |
| max_workers = 10 | |
| max_lines = 10000000 | |
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 concordance(string, search_term, width=25): | |
| """ | |
| Alternative implementation of NLTK's concordance() that | |
| allows printing to stdout or saving to a variable and | |
| does not require NLTK. | |
| Just feed it a raw string, JSON string, etc. with any line | |
| breaks stripped out. | |
| """ | |
| # Offset tracks our progress as we parse through the string |
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
| class JsonHandler(object): | |
| """ | |
| Handles serialization/deserialization of attributes in the JSON blob. | |
| Requires a field of type TextField named 'blob' on the source model. | |
| These are not searchable unless you do FTS on the obj.blob field! | |
| """ | |
| def __init__(self, node, *args, **kwargs): | |
| # Must set via dict interface or else it triggers __setattr__ |
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 django.test import TestCase | |
| from pandas import DataFrame | |
| from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer | |
| from sklearn.naive_bayes import MultinomialNB | |
| from sklearn.pipeline import Pipeline | |
| import numpy | |
| import os |
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
| {"Dataset name": "Alerts", "Possible values": [], "Model": "Alerts", "Expected values": [], "Data type": "string", "Description": "The application involved in the event, such as win:app:trendmicro, vmware, nagios.", "Field name": "app"} | |
| {"Dataset name": "Alerts", "Possible values": [], "Model": "Alerts", "Expected values": [], "Data type": "string", "Description": "The body of a message.", "Field name": "body"} | |
| {"Dataset name": "Alerts", "Possible values": [], "Model": "Alerts", "Expected values": [], "Data type": "string", "Description": "The destination of the alert message, such as an email address or SNMP trap. You can alias this from more specific fields, such as dest_host, dest_ip, or dest_name.", "Field name": "dest"} | |
| {"Dataset name": "Alerts", "Possible values": [], "Model": "Alerts", "Expected values": [], "Data type": "string", "Description": "The business unit associated with the destination. This field is automatically provided by asset and identity correlation features of applications like ClownS |
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 sqlalchemy import Column, Integer, String, ForeignKey, create_engine | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.orm import relationship, backref, sessionmaker, joinedload | |
| # For this example we will use an in-memory sqlite DB. | |
| # Let's also configure it to echo everything it does to the screen. | |
| engine = create_engine('sqlite:///:memory:', echo=True) | |
| # The base class which our objects will be defined on. | |
| Base = declarative_base() |
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
| { | |
| "graph": [], | |
| "links": [ | |
| {"source": 0, "target": 1}, | |
| {"source": 0, "target": 2}, | |
| {"source": 0, "target": 3}, | |
| {"source": 0, "target": 4}, | |
| {"source": 0, "target": 5}, | |
| {"source": 0, "target": 6}, | |
| {"source": 1, "target": 3}, |
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
| import cherrypy | |
| import sqlalchemy | |
| from sqlalchemy import Table, Column, ForeignKey, MetaData, Integer, String | |
| from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relationship | |
| from sqlalchemy.orm.properties import ColumnProperty | |
| from sqlalchemy.orm.util import object_mapper | |
| # The base class from which all entities will extend | |
| class BaseEntity(object): | |
| def __repr__(self): |
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, field, fields, replace, asdict | |
| _MISSING = object() | |
| @dataclass | |
| class Component(object): | |
| """ | |
| Collection of attributes. | |
| """ | |
| _key: str = field(default=None, hash=False, repr=False, compare=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
| from dataclasses import dataclass, field, asdict | |
| from enum import Enum, auto | |
| class Scale(Enum): | |
| NONE = 0 | |
| LOW = 25 | |
| MEDIUM = 50 | |
| HIGH = 75 | |
| MAX = 100 |
OlderNewer