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 / installMiniShiftMacOS.sh
Created December 25, 2017 13:41
Install MiniShift on MacOS
#!/bin/bash
echo "Install MiniShift on MacOS: "
echo " Note: assumes machine not pre-setup with prerequisites!!!"
brew update
echo "Install Homebrew Casks:"
brew install caskroom/cask/brew-cask
@m-x-k
m-x-k / jshellAliasMacOS.sh
Created December 30, 2017 18:47
JShell Alias MacOS
#!/bin/bash
echo "Add the following to your ~/.bashrc file and run 'source ~/.bashrc'"
alias jshell=`echo $(/usr/libexec/java_home)`/bin/jshell
@m-x-k
m-x-k / ExampleJShell.java
Created December 31, 2017 17:18
Custom JShell Implementation
import java.io.ByteArrayInputStream;
import java.io.Console;
import java.util.List;
import jdk.jshell.*;
import jdk.jshell.Snippet.Status;
class ExampleJShell {
public static void main(String[] args) {
Console console = System.console();
try (JShell js = JShell.create()) {
@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"
@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 / 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 / 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 / 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 / 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 / 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);