Skip to content

Instantly share code, notes, and snippets.

View shantanoo-desai's full-sized avatar

Shan Desai shantanoo-desai

View GitHub Profile
@shantanoo-desai
shantanoo-desai / influxdb-python.inc
Last active September 27, 2018 14:41
[Working Recipes] pynmea2 and influxdb-python recipes created using devtool. Structure followed like that of the meta-python branch in openembedded.
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully func
# (Feel free to remove these comments when editing.)
#
# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=046523829184aac3703a4c60c0ae2104"
HOMEPAGE = "https://github.com/influxdb/influxdb-python"
@shantanoo-desai
shantanoo-desai / udf_test.py
Last active March 15, 2019 18:04
Custom Python UDF Example for Kapacitor
from kapacitor.udf.agent import Agent, Handler
from kapacitor.udf import udf_pb2
import logging
import json
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s:%(name)s: %(message)s')
logger = logging.getLogger()
class GeoTestHandler(Handler):
@shantanoo-desai
shantanoo-desai / udf_alert.tick
Created March 15, 2019 18:32
TICK Scripts for Kapacitor v1.5. Log critical alerts in a file + store updated data in Database + send data to HTTP Endpoint
var data = batch
|query('SELECT * FROM "telegraf_test"."autogen"."humid"')
.period(20s)
.every(20s)
data
@hash()
.field('v')
|alert()
.crit(lambda: TRUE)
@shantanoo-desai
shantanoo-desai / Data.json
Last active October 9, 2019 10:03
Data Quality Factors for QualiExplore
{
"text": "Platform information quality",
"checked": false,
"value": {
"description": null
},
"children": [{
"text": "Collection quality",
"checked": false,
"value": {
@shantanoo-desai
shantanoo-desai / Filters.json
Last active September 24, 2019 09:47
Filters for QualiExplore
{
"categories": [
{
"name": "Goals",
"labels": [
{
"id": 1,
"name": "I want to track other’s products.",
"checked": false
},
@shantanoo-desai
shantanoo-desai / CISS.py
Created July 15, 2019 21:15
Code Snippet from cissflux repository
class ciss:
"""CISS Class"""
# parsing methods
# other necessary codes
def parse_payload(self, accepted_data):
data_type = {'measurement': 'ciss',
'fields':
{
'accX': 0.0,
'accY': 0.0,
@shantanoo-desai
shantanoo-desai / config.toml
Last active July 21, 2019 11:35
Batch Uploader InfluxDB Configuration File
[local]
# Local Instance of InfluxDB
host = 'localhost'
port = 8086
database = 'CISS'
[cloud]
# Cloud Instance of InfluxDB
# NOTE: doesn't have to InfluxDB it could be
# any technology stack that you wish to upload
@shantanoo-desai
shantanoo-desai / uploader.py
Last active July 21, 2019 14:19
Data Query Function Snippet for the Uploader Script
def get_points(conf):
# We use the configuration in the TOML file
# to get the data points using `influxdb-python`
# Refer to Repository for complete code
# create the query string
dict_str = ''.join('"{}"=\'{}\''.format(key,value) for key, value in conf['tags'].items())
QUERY = 'SELECT "{}" FROM "{}" WHERE "status"=0 AND {} LIMIT {}'.format(
'","'.join(conf['fields']),
conf['measurement'],
@shantanoo-desai
shantanoo-desai / uploader_cont.py
Created July 21, 2019 14:38
upload_data function logic for Batch Uploader InfluxDB
def upload_data(batch_data):
if connected_to_cloud():
try:
if CLOUD_DB.write_points(batch_data, time_precision='ms'):
logger.info('Write Successful to Cloud')
logger.info('Updating local database with status=1 field')
# for each point add `status=1` field
for point in batch_data:
@shantanoo-desai
shantanoo-desai / MQTT_GraphQL_IoT.ino
Created August 11, 2019 15:28
Arduino Sketch to publish BME280 sensor data in JSON Format to an MQTT Broker
#include<Wire.h>
#include<PubSubClient.h>
#include<WiFi.h>
#include<Adafruit_BME280.h>
#include <ArduinoJson.h>
/*
* WLAN Configuration
*/
const char* ssid = "YOUR_SSID"; // FILL THIS ACCORDINGLY