Skip to content

Instantly share code, notes, and snippets.

@menski
menski / jenkins-decrypt.py
Created April 7, 2015 20:51
Decrypt jenkins password hashes
#!/usr/bin/env python3
# original: https://raw.githubusercontent.com/tweksteen/jenkins-decrypt/master/decrypt.py
# requires: pycrypto
import re
import sys
import base64
@peterflynn
peterflynn / Useful GitHub bookmarklets
Last active December 28, 2024 15:09
GitHub comment thread bookmarklets
To use: create a new bookmark and paste into the URL field.
In Chrome, you can paste the full multiline code as shown below.
In other browsers, you may need to minify the code into one line first.
@iocanel
iocanel / jenkins-keygen.sh
Created September 1, 2015 09:05
Jenkins key generation
#Generate master.key and secret
MAGIC="::::MAGIC::::"
mkdir -p /var/jenkins_home/secrets
openssl rand -hex 128 > /var/jenkins_home/secrets/master.key
openssl dgst -sha256 -binary /var/jenkins_home/secrets/master.key > /tmp/master.hashed
HEX_MASTER_KEY=`head -c 16 /tmp/master.hashed | xxd -l 16 -p`
openssl rand 259 > /tmp/base
echo $MAGIC >> /tmp/base
openssl enc -aes-128-ecb -in /tmp/base -K $HEX_MASTER_KEY -out /var/jenkins_home/secrets/hudson.util.Secret
@iocanel
iocanel / jenkin-encrpyt.sh
Last active October 2, 2020 19:14
Jenkins Encrypt Script
#!/bin/bash
IN=`echo $1 | base64`
SUFFIX="::::MAGIC::::"
MASTER_KEY=`cat /var/jenkins_home/secrets/master.key`
HASHED_MASTER_KEY=`echo -n $MASTER_KEY | sha256sum | cut -d " " -f 1`
HASHED_MASTER_KEY_16=${HASHED_MASTER_KEY:0:16}
openssl enc -d -aes-128-ecb -in /var/jenkins_home/secrets/hudson.util.Secret -K $HASHED_MASTER_KEY -out /tmp/hudson.key
HUDSON_KEY=`cat /tmp/hudson.key`
HUDSON_KEY_TRIMMED=${HUDSON_KEY:0:-16}
HUDSON_KEY_16=${HUDSON_KEY_TRIMMED:0:16}
@MrNice
MrNice / blogpost.md
Last active February 17, 2023 09:46
Explain how to think about ansible and how to use it

Ansible

Understanding Ansible

Ansible is a powerful, simple, and easy to use tool for managing computers. It is most often used to update programs and configuration on dozens of servers at once, but the abstractions are the same whether you're managing one computer or a hundred. Ansible can even do "fun" things like change the desktop photo or backup personal files to the cloud. It can take a while to learn how to use Ansible because it has an extensive terminology, but once you understand the why and the how of Ansible, its power is readily apparent.

Ansible's power comes from its simplicity. Under the hood, Ansible is just a domain specific language (DSL) for a task runner for a secure shell (ssh). You write ansible yaml (.yml) files which describe the tasks which must run to turn plain old / virtualized / cloud computers into production ready server-beasts. These tasks, in turn, have easy to understand names like "copy", "file", "command", "ping", or "lineinfile". Each of these turns into shell comma

@Faheetah
Faheetah / Jenkinsfile.groovy
Last active April 25, 2025 15:35
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"
@Darep
Darep / no-comments.js
Created May 30, 2016 07:01
Remove all comments from GitHub Pull Request
// Sometimes it's necessary to do a bit of clean-up
Array.prototype.forEach.call(document.querySelectorAll('.js-comment-delete button'), function(el, i) {
el.removeAttribute('data-confirm');
el.click();
});
@robertpainsi
robertpainsi / README.md
Last active May 16, 2025 14:38
How to reopen a pull-request after a force-push?

How to reopen a pull-request after a force-push?

Precodinitions

  • You need the rights to reopen pull requests on the repository.
  • The pull request hasn't been merged, just closed.

Instructions

  1. Write down the current commit hash of your PR-branch git log --oneline -1 <PR-BRANCH>
  2. Write down the latest commit hash on github before the PR has been closed.
  3. git push -f origin :
@scrain
scrain / update-all-jenkins-jobs-jdks.groovy
Last active June 3, 2020 09:52
Jenkins script to update the JDK for all jobs
import hudson.model.*
String newJdkName = "JDK 1.7.0_80"
boolean dryRun = true
def h = Hudson.getInstance()
Set jdks = new HashSet()
def newJdk = h.getJDK(newJdkName)
assert newJdk, "unable to find a configured jdk named ${newJdkName}"
@konradkonrad
konradkonrad / 01-esc-dot.py
Last active September 14, 2016 13:44
restore yank-last-arg in ipython 5
# ~/.ipython/profile_default/startup/01-esc-dot.py
from IPython import get_ipython
from prompt_toolkit.enums import DEFAULT_BUFFER
from prompt_toolkit.keys import Keys
from prompt_toolkit.filters import HasFocus, HasSelection, ViInsertMode, EmacsInsertMode
ip = get_ipython()
insert_mode = ViInsertMode() | EmacsInsertMode()