Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Stephen Nutbrown NutterzUK

:octocat:
View GitHub Profile
View gist:7b40d5c8d6fc2d4e7bb0b9118d89c9ea
<?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>
View gist:8c908e8d64b9410f055b5b76799c26b1
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;
View gist:cf3e9ff02b17454cf2a5bc28610c051c
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
View Logging filter
@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.
}
View Filter example
@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 {
View VpnStack.java
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 Dec 2, 2017
apache-httpd-userdata.sh
View 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
View WeightToS3
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