Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am blaffoy on github.
  • I am barrylaffoy (https://keybase.io/barrylaffoy) on keybase.
  • I have a public key ASD0GA_Cd5c-8EGzFCNrgdu9xfv-W8EZJ1P98Dym8abJwgo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@blaffoy
blaffoy / gist:d29170d95c3368cc58293d671bd2ca6c
Created July 3, 2017 14:04
Jenkins system groovy script to push build status to GitHub
@Grapes(
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
)
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.JSON
import static groovyx.net.http.Method.POST
import hudson.model.Result
def thr = Thread.currentThread()
@blaffoy
blaffoy / get_agents.groovy
Created February 7, 2017 12:35
get hostnames of all agents in a jenkins system (including master, if it has executors)
import jenkins.model.Jenkins
agents = Jenkins.instance.slaves
agent_hosts = agents.collect({slave -> return slave.computer.launcher.getHost() })
master_host = new URI(jenkins.model.JenkinsLocationConfiguration.get().getUrl()).getHost()
println Jenkins.instance.getNumExecutors() == 0 ? agent_hosts : agent_hosts << master_host
@blaffoy
blaffoy / gist:6880852c7d0b417ea5ccae53977b868c
Created January 15, 2017 16:35
Unlock password of AWS EC2 Windows instance, given private key. Will be prompted for key password if needed
aws ec2 get-password-data --instance-id <instance-id> | grep PasswordData | sed 's/.*"PasswordData": "\(.*\)" /\1/' | sed 's/\\r//g' | sed 's/\\n//g' | base64 -d | openssl.exe rsautl -decrypt -inkey <private key path>
@blaffoy
blaffoy / gist:e688d71f4d37ddddbae2714f91305a0f
Created January 9, 2017 15:20
Bash script to find a load running ssh-agent authorization sockets
#!/bin/bash
function check_agent_socket() {
local SOCKET=$1
SSH_AUTH_SOCK=$SOCKET ssh-add -l 2> /dev/null > /dev/null
result=$?
case $result in
0)
IDENTITIES=$(SSH_AUTH_SOCK=$SOCKET ssh-add -l 2> /dev/null | awk '{print $3}')
echo "Socket $SOCKET has $(echo $IDENTITIES | wc -w) loaded identities \"$IDENTITIES\""
salt$ sudo salt-run fileserver.update
[ERROR ] An un-handled exception was caught by salt's global exception handler:
CommandError: (1, '', '')
Traceback (most recent call last):
File "/usr/local/bin/salt-run", line 9, in <module>
load_entry_point('salt==2014.1.11', 'console_scripts', 'salt-run')()
File "/usr/local/lib/python2.7/dist-packages/salt/scripts.py", line 95, in salt_run
client.run()
File "/usr/local/lib/python2.7/dist-packages/salt/cli/__init__.py", line 362, in run
runner.run()
### Keybase proof
I hereby claim:
* I am tensorproduct on github.
* I am tensorproduct (https://keybase.io/tensorproduct) on keybase.
* I have a public key whose fingerprint is F8AD 9472 86F0 5B2A 4698 D1AD C60D 2CB0 10FE ACF4
To claim this, I am signing this object: