Skip to content

Instantly share code, notes, and snippets.

@dnozay
dnozay / buildname.groovy
Created January 22, 2015 01:34
build-flow-plugin, change existing builds' displayName to include the git branch's name where applicable.
// for all builds from build-flow-plugin whose parameters include a GIT_BRANCH paramater,
// change the displayName to include branch and build number
import com.cloudbees.plugins.flow.*;
jobs = Jenkins.instance.getAllItems(BuildFlow);
jobs.each { it ->
it.builds.each { b ->
GIT_BRANCH = b.envVars['GIT_BRANCH']
( GIT_BRANCH =~ /(?:refs\/remotes\/)?(.+)/ ).each { full,branch ->
@dnozay
dnozay / lastaborted.groovy
Created January 22, 2015 18:39
jenkins - scan jobs and find if last build was aborted (e.g. maintenance) and who aborted it.
// scan all jobs and check if the last build was aborted (e.g. maintenance)
// and output user / timestamp
jobs = Jenkins.instance.getAllItems()
lastabort = null
jobs.each { j ->
if (j instanceof com.cloudbees.hudson.plugins.folder.Folder) { return }
numbuilds = j.builds.size()
if (numbuilds == 0) { return }
lastbuild = j.builds[numbuilds - 1]
@dnozay
dnozay / new-pass.sh
Created February 18, 2015 19:30
change slapd manager password.
#!/bin/bash
# License: MIT
# You can find a copy of the license here: http://opensource.org/licenses/MIT
# This simple script lets you change the LDAP admin password from
# a console on the LDAP server.
cd /tmp
set -o errexit
PASSWORD=$(slappasswd -h {SSHA})
@dnozay
dnozay / testldaps.rb
Created March 3, 2015 22:02
test LDAPS connection using TLS 1.1 and internal CA certificate validation.
# test LDAPS connection using TLS 1.1 and internal CA certificate validation.
require 'rubygems'
require 'net/ldap'
# refs:
# https://gist.github.com/jeffjohnson9046/7012167
# https://github.com/ruby-ldap/ruby-net-ldap/blob/master/lib/net/ldap.rb
def get_ldap_response(ldap)
@dnozay
dnozay / test_ldap.py
Created May 13, 2015 17:25
python-ldap simple test script
#!/usr/bin/env python
import ldap, sys
LDAP_SERVER = 'ldaps://ldap.example.com:636'
LDAP_BASE = 'dc=example,dc=com'
try:
conn = ldap.initialize(LDAP_SERVER)
except ldap.LDAPError, e:
@dnozay
dnozay / centos-minion.ks
Created July 22, 2015 03:14
centos 6 kickstart file.
install
#cmdline
text
skipx
reboot --eject
# we're using a VM
unsupported_hardware
# please remember to change this
@dnozay
dnozay / test_email.py
Created July 22, 2015 03:17
test email script (using python)
#!/usr/bin/env python
# simple script to test that email (internal relay) is working.
import smtplib
import argparse
from uuid import uuid4
from email.mime.text import MIMEText
def smtp_mail(subject, message, addr_from, addr_to, smtp_host):
msg = MIMEText(message.encode('utf-8'), 'plain', 'utf-8')
@dnozay
dnozay / no-SSL3-poodleattack.ldif
Created July 22, 2015 03:21
LDAP disable SSL3 poodle attack
dn: cn=config
changetype: modify
add: olcTLSCipherSuite
olcTLSCipherSuite: SECURE256:-VERS-SSL3.0
@dnozay
dnozay / gist:1525886
Created December 28, 2011 02:32
@cache_condition, @cache_last_modified, @cache_etag
# decorators to leverage cache based on conditional view processing.
# cache_condition decorator based on django.views.decorators.http.condition
# cache_last_modified, cache_etag shortcuts.
# settings.py
# -----------
# you may or may not want this.
# CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
@dnozay
dnozay / gist:1530205
Created December 28, 2011 22:43
discover url patterns in django project
#
# discover all url patterns in django project
#
def discover_urls(urllist, parent):
for entry in urllist:
item = parent.setdefault(entry.regex.pattern, {})
if hasattr(entry, 'url_patterns'):
discover_urls(entry.url_patterns, item)