Skip to content

Instantly share code, notes, and snippets.

@yogeshlonkar
yogeshlonkar / gist:15ec2441e27c0fac3dbf10fbe4cf36bc
Last active June 8, 2017 15:54 — forked from rb2k/gist:8372402
A jenkins script to clean up workspaces on slaves
// Check if a slave has < 10 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import jenkins.branch.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
@yogeshlonkar
yogeshlonkar / re-attach-gauke.sh
Created August 3, 2017 05:20
guake goes missing in ubuntu window stack. This re attaches it to window and F12 now brings it up
guakeRootId=`xwininfo -name "Guake!" -int -tree | awk 'FNR == 4 {print $4}'`
xdotool search --name "Guake!" windowreparent $guakeRootId
echo "Re-attached guake with rootid $guakeRootId"
@yogeshlonkar
yogeshlonkar / generate.sh
Last active September 12, 2018 16:36
aws ear generate dockerconfigjson
aws ecr get-authorization-token --output json | \
jq -n 'input.authorizationData | {auths: (reduce .[] as $d ({}; . + {($d.proxyEndpoint|sub("https?://";"")): {auth:$d.authorizationToken}}))}'
@yogeshlonkar
yogeshlonkar / commit_trigger_refresh.sh
Last active October 23, 2018 06:08
On Current directory change Git commit & push, Trigger Jenkins and refresh current tab
#!/bin/bash -e
GREEN='\033[0;32m'
# watch current directory for change
fswatch -o ./* | while read -d 1; do
# commit and push
git add . && git commit --no-status -m "jenkins-test" && git push -q
printf "\n${GREEN}-> commit & push done\n"
# Jenkins trigger
@yogeshlonkar
yogeshlonkar / getChangeLog
Last active October 26, 2018 13:41
Jenkins currentBuild getChangeLog as a string
@NonCPS
def getChangeLog(currentBuild) {
def changeLogSets = currentBuild.changeSets
def changeLogToReturn = ''
currentBuild
.changeSets
.each { changeLogSet ->
changeLogSet.items.each { changeSet ->
def commmitDate = new Date().format("EEE MMM dd yy HH:mm:ss", TimeZone.getTimeZone('GMT+5:30'))
changeLogToReturn += "<${changeLogSet.browser.repoUrl}commit/${changeSet.commitId}|${changeSet.msg}> by ${changeSet.author} on ${commmitDate}, commit details below\n"
@yogeshlonkar
yogeshlonkar / CentOS-Base.repo
Created March 15, 2019 10:21
CentOS 5.x yum repos
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
@yogeshlonkar
yogeshlonkar / dazn-useful-bash-functions-scripts.sh
Last active September 30, 2019 12:42
Useful bash scripts functions in dazn workspace
# requires oathtool configuration
function mfa() {
echo valid $(expr 30 - $(date +%s) % 30)s
oathtool --totp --base32 <mfa-secret-key> | tee /dev/tty | pbcopy
}
# set env for terraform
function dazn_aws_set_env()
{
mfa
@yogeshlonkar
yogeshlonkar / signals_for_process.py
Created June 4, 2019 10:49
get all signals being listen by process - credit to https://unix.stackexchange.com/a/85365/48479
import subprocess
ALL_SIGNALS = {}
for sig in range(64):
sig += 1
sig_cmd = "kill -l " + str(sig) + " 2>/dev/null"
ALL_SIGNALS[sig] = subprocess.Popen(sig_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).communicate()[0].strip()
def getSignals(pid, sigCat):
signal_cmd = "grep \"^" + sigCat + ":\" \"/proc/" + str(pid) + "/status\" | cut -c 9-"
@yogeshlonkar
yogeshlonkar / Abc.js
Last active July 3, 2019 08:51
Smart ES6 class mock, Create method proxies on module for easier mocking
class Abc {
func1() {
return 'This is function 1'
}
func2() {
return 2;
}
func3() {
return Promise.resolve('three');
}
@yogeshlonkar
yogeshlonkar / example-handler.go
Last active February 8, 2020 19:07
AWS Golang monorepo lambdas example-handler.go
package handlers
import (
"context"
)
func RequestHandler(ctx context.Context) (string, error) {
return "some-string", nil
}