Skip to content

Instantly share code, notes, and snippets.

View asjadathick's full-sized avatar
👨‍💻

Asjad Athick asjadathick

👨‍💻
View GitHub Profile
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"net/http/httputil"
"regexp"
)
@asjadathick
asjadathick / painless-distance-from-geopoint.java
Created June 16, 2021 23:51
Find the distance in KM from 2 geo points
double deg2rad(def deg) {
return deg * (Math.PI/180)
}
double getDistanceFromLatLonInKm(def lat1,def lon1,def lat2,def lon2) {
def R = 6371; // Radius of the earth in km
def dLat = deg2rad(lat2-lat1); // deg2rad below
def dLon = deg2rad(lon2-lon1);
def a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
@asjadathick
asjadathick / winlogbeat-index-template.json
Created January 19, 2021 03:14
winlogbeat-index-template.json
{
"index_patterns": [
"winlogbeat-7.10.1-*"
],
"mappings": {
"_meta": {
"beat": "winlogbeat",
"version": "7.10.1"
},
"date_detection": false,
@asjadathick
asjadathick / gcloud-stop.sh
Created March 17, 2020 02:51
Stop all gcloud compute instances with a prefixed name
#!/bin/bash
INSTANCE_PREFIX="asjad"
read -r -p "Stop all instances with prefix $INSTANCE_PREFIX? [y/N] " response
response=`echo "print('$response'.lower())" | python`
if [[ "$response" =~ ^(yes|y)$ ]]
then
for i in `gcloud compute instances list --filter $INSTANCE_PREFIX | awk '{print $1}' | sed 1,1d`; do gcloud compute instances stop "$i"; done
@asjadathick
asjadathick / gist:5a975fdb92739727d74472ad6472186a
Created October 23, 2019 02:43
Docker stop and remove everything
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@asjadathick
asjadathick / kube-secret-generator.sh
Created October 14, 2019 13:24
Bash script to generate a secret manifest for k8s secrets. Everything in ./CREDS/ gets picked as a credential
#!/bin/bash
#removes secrets manifest file if already available
rm secrets.yaml
echo "
apiVersion: v1
kind: Secret
metadata:
name: metricbeat-secrets
@asjadathick
asjadathick / Metricbeat aws module permissions
Last active May 28, 2020 08:44
AWS IAM policy for metricbeat aws module metricsets
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ec2:DescribeRegions",
"cloudwatch:GetMetricData",
{
"Right Option Key Sends" : 0,
"Tags" : [
],
"Ansi 12 Color" : {
"Red Component" : 0.44313725829124451,
"Color Space" : "sRGB",
"Blue Component" : 0.94901961088180542,
"Alpha Component" : 1,
@asjadathick
asjadathick / sqrt.go
Last active March 18, 2018 06:45
Go code using Newton's method to find the Square Root of an integer
package main
import (
"fmt"
"math"
)
const (
TOLERANCE=0.00001
)