Skip to content

Instantly share code, notes, and snippets.

View vjayajv's full-sized avatar
🏠
Working from home

vjayc vjayajv

🏠
Working from home
View GitHub Profile
@vjayajv
vjayajv / api_logger.py
Created October 11, 2023 18:54
Log to stdout and an API
# api_logger.py
import logging
import json
import requests
import sys
import os
import argparse
@vjayajv
vjayajv / report.tmpl
Last active May 26, 2023 16:22
Grype report template
<!-- Go template for grype report -->
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Vulnerability Report</title>
<style>
---
apiVersion: v1
kind: ConfigMap
metadata:
name: filebeat-config
labels:
k8s-app: filebeat
data:
filebeat.yml: |-
@vjayajv
vjayajv / containerd-filebeat.yml
Created March 21, 2023 12:36
Filebeat.yml for the death of dockershim
---
apiVersion: v1
kind: ConfigMap
metadata:
name: filebeat-config
labels:
k8s-app: filebeat
data:
filebeat.yml: |-
filebeat.inputs:
@vjayajv
vjayajv / switch_case.py
Created February 3, 2022 07:51
Switch Case using a JSON map in python
def foo(bla):
print(str(bla)+" from foo method")
# your statements
def bar(bla):
print(str(bla)+" from bar method")
# your statements
action_map = {
"dofoo": foo,
@vjayajv
vjayajv / mongo_metrics.py
Created February 2, 2022 14:42
Python script to fetch mongo metrics from atlas and store them to influx
import time
from datetime import datetime
import json
import requests
from requests.auth import HTTPDigestAuth
from influxdb import InfluxDBClient
client = InfluxDBClient(host='localhost', port=8085)
client.create_database('writetest')
@vjayajv
vjayajv / bit-bucket-pr-manager.sh
Created January 19, 2022 06:43
A shell-script to create and merge pull-requests in bit-bucket.
#!/bin/bash
function usage
{
echo "This script is used to create a PR for a specified branch"
echo "usage: ./pull-requests.sh [-h --help] | [-u --username] USERNAME | [-p --password] PASSWORD | [-w --workspace] WORKSPACE | [-r --repo] | [-s --source] SOURCE_BRANCH [-d --destination] DESTINATION_BRANCH [-a --action] ACTION_TYPE | [--desc] DESCRIPTION"
echo "-a --action Allowed values : create (create), merge(create and merge) , default is create"
echo "Example: ./pull-request.sh -r myrepo -s develop -d master"
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mongo-CRD</title>
<link rel="shortcut icon" type="image/jpg" href="http://mongodb-js.github.io/leaf/mongodb-leaf_512x512.png"/>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<title>Mongo-CRD</title>
<link rel="shortcut icon" type="image/jpg" href="http://mongodb-js.github.io/leaf/mongodb-leaf_512x512.png"/>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
</head>
from flask import Flask, flash, render_template, request, redirect, url_for
from pymongo import MongoClient
from bson.objectid import ObjectId
import os
# we're passing mongo's IP as env variable to docker run command
mongohost = str(os.environ['MONGOHOST'])
DEBUG = True
app = Flask(__name__,template_folder='./templates')