Skip to content

Instantly share code, notes, and snippets.

View artemrys's full-sized avatar
:octocat:

Artem Rys artemrys

:octocat:
View GitHub Profile
@artemrys
artemrys / cisco_meraki_custom_rh.py
Last active September 6, 2022 13:20
Splunk Add-on for Cisco Meraki custom rest handler with input validation
#
# SPDX-FileCopyrightText: 2021 Splunk, Inc. <sales@splunk.com>
# SPDX-License-Identifier: LicenseRef-Splunk-8-2021
#
#
import import_declare_test # noqa: F401 # isort: skip
import logging
@artemrys
artemrys / splunk_hec_send.py
Created June 17, 2022 21:37
Splunk HEC correct example
import json
import time
import requests
while True:
event = {
"index": "main",
"event": {"name": "goodbye", "value": "こんにちは世界"},
}
@artemrys
artemrys / splunk_hec_send.py
Created June 17, 2022 21:29
Splunk HEC example 1
import json
import time
import requests
while True:
event = {
"index": "main",
"event": {"name": "goodbye", "value": "こんにちは世界"},
}
@artemrys
artemrys / main.py
Last active September 11, 2019 00:27
Github Repository Traffic Monitoring Google Cloud Function
import os
from datetime import date, datetime
from flask import jsonify
from typing import Generator, List
from github import Github
from github.Referrer import Referrer
from github.Repository import Repository
from google.cloud import firestore
@artemrys
artemrys / top_30.csv
Created July 22, 2019 20:26
Top 30 capitals sorted by number of Starbucks cafes
Country Capital Quantity
United States Washington D.C. 155
Philippines Manila 141
Mexico Mexico City 120
Kuwait Kuwait City 118
Indonesia Jakarta 110
Japan Tokyo 104
Chile Santiago 103
Malaysia Kuala Lumpur 103
Thailand Bangkok 103
@artemrys
artemrys / starbucks_city_search.py
Last active July 21, 2019 23:53
Search Starbucks by coords
import collections
CountryCityCoords = collections.namedtuple(
"CountryCityCoords", ["country_name", "capital_name", "capital_lat", "capital_lng"]
)
class StarbucksCitySearcher(object):
def __init__(self, e: CountryCityCoords):
self.lat = float(e.capital_lat)
@artemrys
artemrys / near_coords.py
Created July 21, 2019 23:47
Get near coordinates
def get_near_coords(lat: float, lng: float, offset=0.1):
for r in [offset, -offset]:
yield (lat + r, lng)
for r in [offset, -offset]:
yield (lat, lng + r)
@artemrys
artemrys / pipeline.py
Last active February 24, 2019 20:44
Scrapy Item Pipeline that publishes to RabbitMQ
import json
import pika
from scrapy.utils.serialize import ScrapyJSONEncoder
class RabbitMQItemPublisherPipeline(object):
def __init__(self, host, port, user, password, virtual_host, exchange, routing_key, queue):
self.host = host
self.port = port
@artemrys
artemrys / app.py
Last active January 20, 2019 20:16
Celery External Call using RabbitMQ
import json
from celery import Celery
from celery import bootsteps
from kombu import Consumer, Exchange, Queue
queue = Queue("input.queue", Exchange("default"), "input.key")
app = Celery(broker="amqp://")
@artemrys
artemrys / celery_app.py
Last active January 10, 2019 00:15
Simple celery application
from celery import Celery
app = Celery(
"app",
broker="amqp://guest@localhost//",
backend="rpc",
)
@app.task
def add(x, y):