Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Whyte MWhyte

View GitHub Profile
@MWhyte
MWhyte / App.kt
Last active Sep 10, 2021
Post: Creating Google Cloud Functions with Kotlin (https://github.com/mwhyte-dev/kotlin-google-cloud-function)
View App.kt
@file:Suppress("unused")
package dev.mwhyte.function
import com.google.cloud.functions.HttpFunction
import com.google.cloud.functions.HttpRequest
import com.google.cloud.functions.HttpResponse
import mu.KotlinLogging
import java.io.IOException
View build.gradle.kts
plugins {
java
application
}
repositories {
mavenCentral()
}
dependencies {
@MWhyte
MWhyte / SimpleRetry.kt
Created Aug 11, 2020
A simple resilience4j retry example written in kotlin
View SimpleRetry.kt
import io.github.resilience4j.retry.Retry
import io.github.resilience4j.retry.RetryConfig
import io.github.resilience4j.retry.RetryRegistry
import java.time.Duration
import java.util.function.Supplier
var x = 0
fun main() {
@MWhyte
MWhyte / ApplicationTests.java
Last active Jul 14, 2019
spring-security-basic-login-form
View ApplicationTests.java
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class ApplicationTests {
@Autowired
private MockMvc mockMvc;
@Test
public void loginWithValidUserThenAuthenticated() throws Exception {
@MWhyte
MWhyte / WebSecurityConfig.java
Created Jul 14, 2019
spring-security-basic-login-form
View WebSecurityConfig.java
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers( "/css/**").permitAll()
.anyRequest().authenticated()
.and()
@MWhyte
MWhyte / MvcConfig.java
Created Jul 14, 2019
spring-security-basic-login-form
View MvcConfig.java
@Configuration
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("login");
registry.addViewController("/index").setViewName("index");
registry.addViewController("/login").setViewName("login");
}
}
@MWhyte
MWhyte / pom.xml
Last active Jul 14, 2019
spring-security-basic-login-form
View pom.xml
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.codenerve</groupId>
<artifactId>spring-security-basic</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-security-basic</name>
View src_main_java_com_codenerve_ArasmDao.java
package com.codenerve;
public class ArasmDao implements ArasmDaoInterface {
private TimeSource timeSource;
@Override
public void setTimeSource(TimeSource timeSource) {
this.timeSource = timeSource;
}
@MWhyte
MWhyte / Recovery.java
Last active Oct 14, 2015
Potential reconnect methods
View Recovery.java
package com.code.util;
public class Recovery {
private long SLEEP_TIME = 3000;
public void connectToTp(){
try {
@MWhyte
MWhyte / MainActivity.java
Last active Sep 30, 2015
Using lambda's with android. With help from gradle-retrolambda
View MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
loginBtn = (Button) findViewById(R.id.login_btn);
loginBtn.setOnClickListener((View) -> login());
Log.i(TAG, "onCreate finished");
}