Skip to content

Instantly share code, notes, and snippets.

View davidmc24's full-sized avatar

David M. Carr davidmc24

  • Albany, NY, USA
  • 09:01 (UTC -04:00)
View GitHub Profile
@davidmc24
davidmc24 / .gitignore
Last active June 29, 2018 14:00
Sample project demonstrating gradle-avro-plugin validateDefaults feature
.gradle/
*.iml
*.ipr
*.iws
.idea/
out/
@davidmc24
davidmc24 / UUIDUtils.java
Created October 6, 2015 16:05
Convert Microsoft GUID to Java UUID
// Original source: https://github.com/zagyi/adsync4j/blob/master/core/src/main/java/org/adsync4j/impl/UUIDUtils.java
/*******************************************************************************
* ADSync4J (https://github.com/zagyi/adsync4j)
*
* Copyright (c) 2013 Balazs Zagyvai
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@davidmc24
davidmc24 / build.gradle
Created September 3, 2015 18:50
Multi-file avro
plugins {
id "com.commercehub.gradle.plugin.avro" version "0.4.0"
}
repositories {
jcenter()
}
dependencies {
compile "org.apache.avro:avro:1.7.7"
}
@davidmc24
davidmc24 / Example.java
Last active August 29, 2015 14:20
Pac4j example
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@davidmc24
davidmc24 / DescribingHandlers.java
Created April 4, 2015 21:56
Example class for javassist bug report
import javassist.ClassPool;
import javassist.CtBehavior;
import javassist.CtClass;
import javassist.NotFoundException;
import javassist.bytecode.ClassFile;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@davidmc24
davidmc24 / ratpack.groovy
Created April 2, 2015 15:39
Quick demo of ratpack prefix handling
@GrabResolver(name="OJO", root="https://oss.jfrog.org/artifactory/repo")
@Grab("io.ratpack:ratpack-groovy:0.9.15")
import static ratpack.groovy.Groovy.ratpack
import static ratpack.groovy.Groovy.groovyMarkupTemplate
import ratpack.groovy.template.MarkupTemplateModule
import ratpack.handling.*
@Grab("org.slf4j:slf4j-simple:1.7.12")
import org.slf4j.Logger
// You can change anything in the ratpack {} closure without needing to restart
@davidmc24
davidmc24 / gist:a45f1e9c091cf396e856
Last active August 29, 2015 14:18
Ratpack baseDir config use cases
  1. gradle build run
  • src/ratpack is on classpath, located via .ratpack marker file
  1. intellij run config
  • src/ratpack is on classpath, located via .ratpack marker file
  1. single-jar deployment (no separate filesystem)
  • assets, including .ratpack marker file, are embedded in root of jar
  1. separate file system deployment
@davidmc24
davidmc24 / ModuleConfigurationSpec.groovy
Last active August 29, 2015 14:13
ModuleConfigurationSpec
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@davidmc24
davidmc24 / BasicAuthHandler.groovy
Created January 14, 2015 18:06
Simple Ratpack BasicAuthHandler
package integration.pac4j
import chex.config.AuthConfig
import chex.util.HttpResponseCode
import com.unboundid.ldap.sdk.LDAPConnectionPool
import groovy.util.logging.Slf4j
import io.netty.handler.codec.http.HttpHeaderNames
import org.pac4j.core.profile.UserProfile
import org.pac4j.http.profile.HttpProfile
import ratpack.handling.Context
@davidmc24
davidmc24 / ConfigurationsSpec.groovy
Last active August 29, 2015 14:12
Example Config Reloading
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software