Skip to content

Instantly share code, notes, and snippets.

@imranity
imranity / get-api-token-of-user-jenkins-groovy.md
Last active June 7, 2021 14:24
jenkins groovy get API token of a user

This is pretty simple snippet to get API Token of a user , lets say "MYUser" in jenkins.
its pretty useful when you are working with 'jenkins-job-builder' to update jobs in jenkins, and you need to get the api token which JJB needs inorder to update jobs to ..
run this code in either jenkins script console , or as i prefer, in form of init.groovy.
so when jenkins master starts, i create a user for JJb.
after that i get the token right away and pass it to my JJB jobs folder to file 'jenkins_jobs.ini' :)_ .

///////////////////////////////////////////////////////////////////////
@robcowie
robcowie / suds_to_json.py
Created April 8, 2015 13:42
Serialising Suds objects to json
from suds.sudsobject import asdict
def recursive_asdict(d):
"""Convert Suds object into serializable format."""
out = {}
for k, v in asdict(d).iteritems():
if hasattr(v, '__keylist__'):
out[k] = recursive_asdict(v)
elif isinstance(v, list):
out[k] = []

Python

lxml dependencies on ubuntu/mint: sudo apt-get install libxml2-dev libxslt-dev python-dev lib32z1-dev

Misc

Test if a port is open: nc -zv ADDRESS PORT telnet ADDRESS PORT

@deefour
deefour / deefour-request-handling.md
Last active November 11, 2016 19:22
A work-in-progress attempt to explain how a few small packages aide me in application development.

NOTE: Some recent, major refactoring has made some sections of this document inaccurate. It will be updated soon.

Handling Requests in Laravel With the Help of Ruby-Inspired Packages

I am a PHP developer that has done a lot of Ruby on Rails development over the last few years. There are a few gems I found especially useful again and again.

@gtallen1187
gtallen1187 / scar_tissue.md
Created November 1, 2015 23:53
talk given by John Ousterhout about sustaining relationships

"Scar Tissues Make Relationships Wear Out"

04/26/2103. From a lecture by Professor John Ousterhout at Stanford, class CS142.

This is my most touchy-feely thought for the weekend. Here’s the basic idea: It’s really hard to build relationships that last for a long time. If you haven’t discovered this, you will discover this sooner or later. And it's hard both for personal relationships and for business relationships. And to me, it's pretty amazing that two people can stay married for 25 years without killing each other.

[Laughter]

> But honestly, most professional relationships don't last anywhere near that long. The best bands always seem to break up after 2 or 3 years. And business partnerships fall apart, and there's all these problems in these relationships that just don't last. So, why is that? Well, in my view, it’s relationships don't fail because there some single catastrophic event to destroy them, although often there is a single catastrophic event around the the end of the relation

import jenkins.model.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import org.jenkinsci.plugins.plaincredentials.*
import org.jenkinsci.plugins.plaincredentials.impl.*
import hudson.util.Secret
import hudson.plugins.sshslaves.*
@tailhook
tailhook / patch_package.sh
Last active May 1, 2017 10:07
Arch vagga
#!/bin/sh -ex
CONTRIBUTOR="Roman Rader <[email protected]>"
OVERLAYFS_PATCH="http:\\/\\/people.canonical.com\\/~apw\\/lp1377025-utopic\\/0001-UBUNTU-SAUCE-Overlayfs-allow-unprivileged-mounts.patch"
sed -i.bak "s/# CONFIG_USER_NS is not set/CONFIG_USER_NS=y/" config
sed -i.bak "s/# CONFIG_USER_NS is not set/CONFIG_USER_NS=y/" config.x86_64
sed -i.bak "/source=/,/)/s/)$/\n$OVERLAYFS_PATCH)/" PKGBUILD
sed -i "s/\# add upstream patch/\# add upstream patch\n patch \-p1 \-i \"\$\{srcdir\}\/`basename $OVERLAYFS_PATCH`\"/" PKGBUILD
sed -i 's/^pkgbase=linux.*$/pkgbase=linux-user-ns-enabled/' PKGBUILD
@emkay
emkay / build-grub-osx.sh
Last active June 10, 2025 18:49
Build Grub on OSX
#!/bin/sh
set -e
# First we are going to make sure that you understand this is sort of experimental and we will be compiling stuff.
# by default CONTINUE will be false
CONTINUE=false
echo ""
echo "You are about to download, compile, and install stuff on your computer."
@sdorra
sdorra / keys.go
Created April 17, 2016 19:31
Golang RSA Key Generation
/*
* Genarate rsa keys.
*/
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
@cecil
cecil / twopass.py
Created May 7, 2016 07:58
Python script to generate a hash for /etc/shadow (SHA512) and LDAP (SSHA1)
#!/usr/bin/python
#
# Python script to generate a hash for /etc/shadow (SHA512) and LDAP (SSHA1)
# In case you needed to support a hypothetical environment that had both auth mechanisms in play.
#
import hashlib
from base64 import urlsafe_b64encode as encode
from base64 import urlsafe_b64decode as decode
from getpass import getpass