Skip to content

Instantly share code, notes, and snippets.

View NutterzUK's full-sized avatar
:octocat:

Stephen Nutbrown NutterzUK

:octocat:
View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
package com.example.demo;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
package com.example.demo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CommonsRequestLoggingFilter;
@Configuration
public class Config {
@Bean
@Component
public class LogFilter extends OncePerRequestFilter {
private static Logger LOG = LoggerFactory.getLogger(LogFilter.class);
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
LOG.info(request.getRequestURI()); // log the request path.
}
@Component
public class MDCFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
MDC.put("tracking", request.getHeader("tracking-header"));
try {
filterChain.doFilter(request, response);
} finally {
@NutterzUK
NutterzUK / VpnStack.java
Created December 24, 2018 17:01
CDK EC2 Example
package com.myorg;
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.ec2.*;
import java.util.Collections;
public class VpnStack extends Stack {
public VpnStack(final App parent, final String name, final StackProps props) {
super(parent, name, props);
@NutterzUK
NutterzUK / apache-httpd-userdata.sh
Last active December 2, 2017 19:00
apache-httpd-userdata.sh
#!/bin/bash
yum update -y
yum install httpd -y
service httpd start
chkconfig httpd on
cd /var/www/html
echo "<html>" > index.html
echo "<head>" >> index.html
echo "</head>" >> index.html
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
exports.handler = (event, context, callback) => {
// Your bucket name and key here. Note that it should be in the same region as your lambda.
var bucket = "nutbrownweight"; // TODO REPLACE THIS!
var key = "weight.txt";
// Values passed in to the Lambda