Skip to content

Instantly share code, notes, and snippets.

View m-x-k's full-sized avatar

Martin Kelly m-x-k

View GitHub Profile
@m-x-k
m-x-k / jenkinsJobConsoleOutput.py
Last active January 5, 2024 08:37
Python script to help get jenkins job console output
#!/usr/bin/env python
import re
import argparse
import requests
jenkins_url = "https://localhost:8080"
# Add new jobs here:
jobs = {
@m-x-k
m-x-k / active_directory_users.py
Created July 18, 2017 12:12
Python ldap3 active directory add and search for users
import ssl
from flask import json
from ldap3 import Server, \
Connection, \
SUBTREE, \
ALL_ATTRIBUTES, \
Tls, MODIFY_REPLACE
OBJECT_CLASS = ['top', 'person', 'organizationalPerson', 'user']
@m-x-k
m-x-k / StepsToSetupArtifactoryWithNpm
Last active December 3, 2022 04:51
Setting up JFrog artifactory for NPM
docker pull docker.bintray.io/jfrog/artifactory-oss:latest
docker run --name artifactory -d -p 8081:8081 docker.bintray.io/jfrog/artifactory-oss
# In browser open http://localhost:8081 and follow basic steps
# Add new remote repository: http://localhost:8081/artifactory/webapp/#/admin/repositories/remote
# URL: https://registry.npmjs.org
# RepositoryLayout: NPM default
# Add new virtual repository of type "Generic" using remote repository above
@m-x-k
m-x-k / pipelineChooseDockerTags.groovy
Created November 16, 2016 22:05
Jenkins pipeline - choose docker tags
/*
* Displays input dropdown select containing docker image tags
* Manage Jenkins->Script Approval (required)
*/
node {
stage('chooseDockerTags') {
def image = "IMAGE"
def url = "https://LOCAL-DOCKER-REG:5000/v2/${image}/tags/list"
def list = getDockerImageTags(url)
@m-x-k
m-x-k / outputCredentialsPipeline.groovy
Created November 18, 2016 15:36
Jenkins Pipeline sample using Credentials Binding Plugin
node {
stage('GetUserCredential') {
// Requires Credential setup (MyCredentialID)
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'MyCredentialID',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
sh '''
set +x
echo "$USERNAME" > output.txt
'''
@m-x-k
m-x-k / MyInterceptor.java
Last active July 21, 2020 08:57
Spring Boot Interceptor with annotation support
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import static java.lang.String.format;
@m-x-k
m-x-k / delete-pods.sh
Created March 15, 2019 11:33
Delete all openshift pods in a project space
#!/bin/bash
oc login
oc project $1
oc get services | awk '{print $1}' | grep -v NAME | xargs -I % oc delete all -l app=%
@m-x-k
m-x-k / map_filter_reduce_examples.py
Created January 4, 2019 15:32
Python Map Filter Reduce examples
from functools import reduce
check = [1, 2, 3, 4, 5]
if __name__ == '__main__':
print(list(map(lambda x: x * 3, check))) # OUTPUT: [3, 6, 9, 12, 15]
print(list(filter(lambda x: x < 3, check))) # OUTPUT: [1, 2]
@m-x-k
m-x-k / gist:a75afe262c8d94cdbfbe70ca285700c5
Created November 25, 2018 11:01
Spring Boot configuration: JSP access
@Configuration
@EnableWebMvc
public class WebApplicationConfig implements WebMvcConfigurer {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
registry.jsp().prefix("/WEB-INF/views/").suffix(".jsp");
}
}
@m-x-k
m-x-k / ThymeLeafConfig.java
Created August 29, 2018 14:46
Spring Thymeleaf Extension Dialect Example
@Configuration
public class ThymeLeafConfig {
@Autowired
private SpringResourceTemplateResolver templateResolver;
@Bean
public SpringTemplateEngine templateEngine(){
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setEnableSpringELCompiler(true);