Skip to content

Instantly share code, notes, and snippets.

View pmgupte's full-sized avatar
🤠
busy! I may be slow to respond.

Prabhas Gupte pmgupte

🤠
busy! I may be slow to respond.
View GitHub Profile
@pmgupte
pmgupte / index.html
Last active June 1, 2022 03:50
Qualys is hiring Super-Heroes! Access it here: http://cmx.io/#c92164c632953742506d90bfc58f0c0c
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
<label t="translate(0,346)">
@pmgupte
pmgupte / jenkins_plugins_license_stats.sh
Last active September 10, 2019 13:30
A script to get count of Jenkins plugins by license type. It downloads data about all plugins published to Jenkins Update Center, then downloads their pom.xml from SCM link mentioned in update-center.json, and finally counts occurrences per license name and prints stats. Referred this gist: https://gist.github.com/michaellihs/a844a93cb3575beb269…
#!/bin/bash
JQ=$(which jq)
CURL=$(which curl)
XPATH=$(which xpath)
$CURL -s https://updates.jenkins.io/current/update-center.actual.json -o update-center.actual.json
$JQ '.plugins[] | .scm' update-center.actual.json > plugin_repos.txt
input_file="plugin_repos.txt"
@pmgupte
pmgupte / eci.sh
Created May 23, 2019 09:43
Get results for General Election in India 2019
#!/bin/bash
RED="\033[1;31m"
GREEN="\033[1;32m"
NOCOLOR="\033[0m"
YELLOW="\e[33m"
BLINK="\e[5m"
NOBLINK="\e[25m"
echo "Getting result from http://results.eci.gov.in..."
@pmgupte
pmgupte / servicenow_getNode.js
Created January 9, 2018 07:14
Sample Servicenow script showing how to handle case of non existing XML tag.
/*
* Checks if given node indeed of given tag.
* Params:
* tag - String, name of tag to check
* node - XMLNode, node in which to check for the tag
* Returns:
* true, if tag is present
* false, otherwise
*/
function isNodeOfTag (node, tag) {
<?php
function print_api_ai_response($speech, $display_text = null, $followup_event = null, $context=null) {
$for_api_ai = array();
$for_api_ai['speech'] = $speech;
if ($display_text != null) {
$for_api_ai['displayText'] = $display_text;
} else {
$for_api_ai['displayText'] = $speech;
}
@pmgupte
pmgupte / Qualys_TA_HostDetection_RESULTS.md
Last active October 10, 2017 09:45
How to get RESULTS field into the Host Detection feed

How to get RESULTS field into the Host Detection feed

for Qualys TA version 1.2.2+

To get the RESULTS field indexed in host detection input, do the followings:

  1. On TA Setup page, in VM Detection extra parameters, set show_results=1
  2. Open <TA DIR>bin/qualysModule/splunkpopulator/detectionpopulator.py and find class HostDetectionPopulator.
  3. In this class, find _process_root_element(self, elem) method.
  4. In that method, we have a list named HostDetectionPopulator.detection_fields_to_log. Its a list of fields to parse from detection tag.
  5. In that list, add "RESULTS" at the end. As a best practice, add a comment describing why you edited this list. This will tell code to parse that XML tag as well and output it while printing the event data.
@pmgupte
pmgupte / get_plaintext.py
Last active August 21, 2017 05:40
How to get plain text inside any XML tag. This code is explained at https://pgbase.blogspot.in/2017/08/how-to-get-plain-text-inside-any-xml.html
try:
import xml.etree.cElementTree as ET
except ImportError:
import xml.etree.ElementTree as ET
def get_plaintext(elem):
inner_plaintext = ''
text_iterator = elem.itertext()
for text in text_iterator:
inner_plaintext = inner_plaintext + text
@pmgupte
pmgupte / add_eggs_dynamically.py
Created March 23, 2017 05:22
Python code to dynamically add .egg files to sys.path
import sys
import os
"""
dynamically load all the .egg files.
Put all your .egg files in a directory named "eggs".
Following code will add all of them to sys.path,
so that you can import from those .egg files directly.
"""
@pmgupte
pmgupte / all_zero_values_in_dict.py
Created February 28, 2017 10:04
Python code to check if all the values in dictionary are zero.
d = {'a': 0, 'c': 0, 'b': 0, 'd': 0}
l = d.values()
s = set(l)
if len(s) == 1 and list(s)[0] == 0:
print "all 0"
else:
print "not all 0"
@pmgupte
pmgupte / expand_shrink_ip_range.php
Last active October 12, 2016 06:25
PHP functions to expand and shrink IPv4 range. Includes sample calls. This code is explained at https://etcsrc.blogspot.in/2016/10/expand-and-shrink-ipv4-range.html
<?php
/**
* Copyright (C) 2016 Prabhas Gupte
*
* This is free script: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This script is distributed in the hope that it will be useful,