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 / 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);
@m-x-k
m-x-k / archiveDockerData.groovy
Created March 16, 2018 13:18
Jenkins Pipeline To Archive Docker Data For All Nodes
def nodeName
stage("ArchiveDockerData") {
def nodeNameList = nodeNames()
for (String n : nodeNameList) {
nodeName = n
echo "Docker info for ${nodeName}"
timeout(time: 5, unit: 'SECONDS') {
try {
node(nodeName) {
@m-x-k
m-x-k / generate_web_sequence_diagram.py
Created March 9, 2018 08:54
Generate web sequence diagram example
import urllib
import re
def getSequenceDiagram(text, output_file, style ='default'):
request = {}
request["message"] = text
request["style"] = style
request["apiVersion"] = "1"
url = urllib.urlencode(request)
@m-x-k
m-x-k / JavaRedisCSVUploadExample.java
Created February 22, 2018 13:35
Java Redis CSV Upload Example
import redis.clients.jedis.Jedis;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import static java.lang.System.getenv;
public class JavaRedisCSVUploadExample {
@m-x-k
m-x-k / getPythonPipLocations.sh
Created February 19, 2018 08:06
Get Python PIP Locations
python -c "import site; print(site.getsitepackages())"
@m-x-k
m-x-k / periodic_check_mongodb_collection_names.py
Created January 3, 2018 09:57
python 3 asyncio example: periodic check mongodb collection names
import asyncio
from pymongo import MongoClient
@asyncio.coroutine
def periodic(wait_seconds=2):
while True:
names = client['local'].collection_names()
for name in names:
print(name)
yield from asyncio.sleep(wait_seconds)
@m-x-k
m-x-k / OptionalOrExample.java
Created January 2, 2018 20:08
Java 9 Optional.or example
Optional<String> name = Optional.empty();
Optional<String> alternativeName = Optional.of("john");
name = name.or(() -> alternativeName);
name.get(); // Outputs "john"