Skip to content

Instantly share code, notes, and snippets.

@kkashyap1707
kkashyap1707 / aws-ec2-redis-cli.md
Created November 7, 2023 19:34 — forked from todgru/aws-ec2-redis-cli.md
AWS redis-cli on EC2
@kkashyap1707
kkashyap1707 / enable_alerting.py
Created June 30, 2021 19:02 — forked from miketheman/enable_alerting.py
A simple script to enable GitHub's Data Services & Vulnerability Scanning on a given Organization's Repositories
from github import Github
gh = Github('SET_GITHUB_ACCESS_TOKE_HERE')
org = gh.get_organization('SET_ORG_NAME_HERE')
repos = org.get_repos()
for repo in repos:
if repo.archived:
@kkashyap1707
kkashyap1707 / security-group-cleanup.py
Created June 30, 2021 19:00 — forked from pet0ruk/security-group-cleanup.py
Security Group Cleanup using boto3
#!/usr/bin/env python
import boto3
import argparse
def lookup_by_id(sgid):
sg = ec2.get_all_security_groups(group_ids=sgid)
return sg[0].name
@kkashyap1707
kkashyap1707 / Jenkinsfile.groovy
Created June 30, 2021 15:37 — forked from nihitjain11/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@kkashyap1707
kkashyap1707 / boto3_listinstances_example.py
Created June 7, 2021 00:26 — forked from mda590/boto3_listinstances_example.py
Example using boto3 to list running EC2 instances
import boto3
ec2 = boto3.resource('ec2')
def lambda_handler(event, context):
# create filter for instances in running state
filters = [
{
'Name': 'instance-state-name',
'Values': ['running']
@kkashyap1707
kkashyap1707 / pandas.py
Created June 2, 2021 02:38 — forked from joelhoro/pandas.py
Pandas dataframe with bootstrap styling
#!/usr/bin/env python
# coding: utf-8
# In[1]:
data = [
{"name": "Argentina", "year": 2005, "continent": "South America", "form": "Republic", "gdp": 181.357, "oil": 1.545, "balance": 4.699},
{"name": "Argentina", "year": 2006, "continent": "South America", "form": "Republic", "gdp": 212.507, "oil": 1.732, "balance": 7.167},
{"name": "Australia", "year": 2012, "continent": "Australasia", "form": "Constitutional monarchy", "gdp": 1542.055, "oil": 22.596, "balance": -62.969},
<div class="polls3">
<table>
<thead>
<tr>
{% for c in cols[:5] %}
<th><div {% if c.lower() in ('grade', 'sample', 'weight') %}
style="text-align: center"
{% endif %}>
{{c}}</div>
@kkashyap1707
kkashyap1707 / pdf-report.py
Created May 31, 2021 18:42 — forked from chris1610/pdf-report.py
PDF Report Generation - pbpython.com
"""
Generate PDF reports from data included in several Pandas DataFrames
From pbpython.com
"""
from __future__ import print_function
import pandas as pd
import numpy as np
import argparse
from jinja2 import Environment, FileSystemLoader
from weasyprint import HTML
@kkashyap1707
kkashyap1707 / grafana_pdf_via_snapshot.md
Created May 30, 2021 13:11 — forked from svet-b/grafana_pdf_via_snapshot.md
PDF export of Grafana dashboard via snapshot

Get PDF export of Grafana dashboard

Note

As currently described, this approach does not work. The reason for that is that creating a snapshot via the API does not actually populate any data, as described in e.g. https://community.grafana.com/t/snapshot-using-http-api-does-nothing/. An alternative approach which does work described in https://gist.github.com/svet-b/1ad0656cd3ce0e1a633e16eb20f66425.

Prerequisites

Packages:

  • The jq JSON processing command line tool, which is available for most distributions (https://stedolan.github.io/jq/, sudo apt install jq)
  • NodeJS, and the puppeteer package (npm install puppeteer), which is used to run headless Chrome
@kkashyap1707
kkashyap1707 / .gitlab-ci.yml
Created March 3, 2021 20:13 — forked from superjose/.gitlab-ci.yml
This is an example of a .gitlab-ci.yml that is required for Continuous Integration on GitLab projects.
# Reference: https://www.exclamationlabs.com/blog/continuous-deployment-to-npm-using-gitlab-ci/
# GitLab uses docker in the background, so we need to specify the
# image versions. This is useful because we're freely to use
# multiple node versions to work with it. They come from the docker
# repo.
# Uses NodeJS V 9.4.0
image: node:9.4.0
# And to cache them as well.