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
input { | |
http_poller { | |
urls => { | |
wunderground => "https://api.weather.com/v2/pws/observations/current?stationId=IDULLI1&format=json&units=m&apiKey={{ api_key }}" | |
} | |
request_timeout => 60 | |
schedule => { cron => "0,15,30,45 * * * * UTC"} | |
codec => "json" | |
# A hash of request metadata info (timing, response headers, etc.) will be sent here | |
metadata_target => "http_poller_metadata" |
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 yaml | |
from dotmap import DotMap as DD | |
class DataManager: | |
""" Manages YAML data representation where members are accessible with dot notation. | |
""" | |
data_map = DD() |
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 qs(k : int) -> int: | |
s = 0 | |
while k: | |
s = s + k % 10 | |
k = k // 10 | |
return s |
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 math import gcd | |
def φ(z): | |
return sum([gcd(z,k)==1 for k in range(1, z+1)]) |
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 | |
from numbers import Number | |
from unittest import TestCase | |
class Expression: | |
def derive(self, variable): | |
return 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
#!/bin/bash | |
# | |
## CURL the kibana endpoint | |
## Use the kibana dev console to validate query json | |
curl -i --insecure --user User:Password -XPOST \ | |
--header "kbn-version: 5.6.0" \ | |
'https://kibana.yourdomain/api/console/proxy?path=_search&method=POST' \ | |
--data '{"query":{"match_all":{}}}' |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.define "controlplane", primary: true do |controlplane| | |
config.vm.box = "centos/7" | |
config.vm.hostname = "haithabu" | |
end |
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
""" Underscores in number literals are ignored: """ | |
>>> ten_billion = 10_000_000_000 | |
>>> ten_billion | |
10000000000 | |
""" In output formatting, you can insert thousands separators: """ | |
>>> f"{ten_billion:,}" | |
'10,000,000,000' |
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 Singleton(type): | |
_instances = {} | |
def __call__(cls, *args, **kwargs): | |
if cls not in cls._instances: | |
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) | |
return cls._instances[cls] | |
class Registry(metaclass=Singleton): | |
"""Management for plugins as a singleton. |
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 sys, logging | |
from unittest import TestCase | |
from tracer import trace, profile, log, slow_down, timer, debug | |
class TestTrace(TestCase): | |
def setUp(self): | |
root = logging.getLogger() | |
root.setLevel(logging.DEBUG) |