Skip to content

Instantly share code, notes, and snippets.

View chocksaway's full-sized avatar

Miles Davenport chocksaway

View GitHub Profile
@chocksaway
chocksaway / ListenerConfig.java
Created November 11, 2024 17:28
Spring Boot Session Expiry - using Undertow webserver
import com.chocksaway.session.listener.SessionTimeoutListener;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ListenerConfig {
@Bean
public ServletListenerRegistrationBean<SessionTimeoutListener> sessionTimeoutListener() {
@chocksaway
chocksaway / MyRuleExample.java
Created October 6, 2024 14:49
Easyrules example which uses a SimpleClass to validate against SimpleRule. Facts which have passed are stored in passedFactsList.
package com.chocksaway.imager.easyrules;
import org.jeasy.rules.api.*;
import org.jeasy.rules.core.*;
import java.util.List;
public class MyRuleExample {
record SimpleClass(String name, boolean status) {
}
package reverse;
import org.apache.log4j.Logger;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
/**
@chocksaway
chocksaway / gist:32697777f8bb05998ab64be756f44543
Created September 6, 2016 10:51
Date filtering using Lamdba, and Iterator
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.stream.Collectors;
public class FilterStartAndEndDate {
private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
package com.chocksaway.util;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
import com.amazonaws.services.dynamodbv2.document.*;
import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec;
import com.amazonaws.services.dynamodbv2.document.spec.ScanSpec;
import com.amazonaws.services.dynamodbv2.document.utils.NameMap;
import com.amazonaws.services.dynamodbv2.document.utils.ValueMap;
import com.amazonaws.services.dynamodbv2.model.*;
import com.fasterxml.jackson.core.JsonFactory;
@chocksaway
chocksaway / gist:7ee7f163fa4505a70cc918ad09af6043
Created April 25, 2016 15:33
A very simple gulp task runner
var gulp = require('gulp'),
gutil = require('gulp-util');
// create a default task and just log a message
gulp.task('default', function() {
return gutil.log('Gulp is running!')
});
while true
do
echo "click"
cliclick m:+0,+0
sleep 60
done
import logging
import boto3
def create_dynamo_table(table_name, key_schema, attribute_definitions, provisioned_throughput):
dynamodb = boto3.resource('dynamodb', region_name='eu-west-1')
try:
dynamodb.create_table(
package com.example.milesd.atestapp;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
@chocksaway
chocksaway / gist:958d49abfb02703b6a6d
Created March 4, 2016 15:39
Python dynamo-db boto3
import boto3
from boto3.dynamodb.conditions import Key, Attr
TABLE_NAME = 'int-mobileSubscriptionsTable'
dynamo_db = boto3.resource('dynamodb', endpoint_url='http://localhost:8090', region_name='us-east-1')
table = dynamo_db.Table(TABLE_NAME)
response = table.query(