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 / BaseTest.java
Created December 22, 2016 08:03
Junit assert log statements
public class BaseTest {
final Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
@Mock
protected Appender mockAppender;
@Captor
protected ArgumentCaptor<LoggingEvent> captorLoggingEvent;
@Before
@m-x-k
m-x-k / index.html
Last active April 8, 2018 01:22
ChatBot with reveal design pattern
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="keywords" content="design patterns">
<title>Mastering Javascript</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
@m-x-k
m-x-k / DebianDockerPrivateRegistryAccessSetup.txt
Created December 30, 2016 09:06
Debian docker private registry access setup
Go to private repository in browser (e.g. https://<PRIVATE_REG>:5000/v2/_catalog)
Download the certificate (e.g. View Cerificate > Details > Export (PEM format))
Copy crt certificate to: /usr/local/share/ca-certificates/
sudo update-ca-certificates --verbose
systemctl restart docker
Confirm it all works by trying to pull down a docker image from the private registry:
@m-x-k
m-x-k / circleGeneratorSingleton.js
Last active April 8, 2018 01:22
Javascript singleton pattern
(function(win, $) {
var CircleGeneratorSingleton = (function() {
var instance;
function init() {
var _aCircle = [],
_stage = $('.advert');
function _position(circle, left, top) {
@m-x-k
m-x-k / circleFactory.js
Last active April 8, 2018 01:22
Create circles with Factory Pattern javascript
(function(win, $) {
var RedCircle = function() {
this.item = $('<div class="circle"></div>');
},
BlueCircle = function() {
this.item = $('<div class="circle" style="background:blue"></div>');
},
CircleFactory = function(color) {
this.create = function(color) {
if (color === 'blue') {
@m-x-k
m-x-k / build.gradle
Created December 22, 2016 08:31
gradle register java custom annotations with intellij
apply plugin: 'groovy'
apply plugin: 'idea'
repositories {
jcenter()
}
idea {
project {
ipr {
@m-x-k
m-x-k / index.html
Created December 26, 2016 23:05
ChatBot with module design pattern
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="keywords" content="design patterns">
<title>Mastering Javascript</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
@m-x-k
m-x-k / AppWebMvcConfiguration
Created December 31, 2016 20:38
Spring boot Gson converter
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.GsonHttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.List;
@Configuration
public class AppWebMvcConfiguration extends WebMvcConfigurerAdapter {
@m-x-k
m-x-k / rx_simple.py
Created January 21, 2017 17:42
Reactive for python. Simple example using lambda's
from rx import Observable, Observer
letters = Observable.from_(['Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon'])
letters.subscribe(on_next=lambda s: print(s),
on_completed=lambda: print('Done'),
on_error=lambda e: print(e))
@m-x-k
m-x-k / gitAlias
Created July 17, 2016 17:52 — forked from ParkinT/gitAlias
A list of example git alias shortcuts from the "Mastering Git" [ISBN 978-1-78355-413-3] book by Packt Publishing. This is described in Section 7.
### Common Commands
ssb = status -sb
logo = log --oneline
c = commit -m
a = add
cob = checkout -b
st = status -s
co = checkout
stat = status
cl = clone