Skip to content

Instantly share code, notes, and snippets.

Avatar

Christopher Currie christophercurrie

View GitHub Profile
@christophercurrie
christophercurrie / authenticate.java
Last active Dec 21, 2015
Example of different authenticators in dropwizard
View authenticate.java
abstract class MyPrincipal {};
class BasicAuthPrincipal extends MyPrincipal {};
class OAuthPrincipal extends MyPrincipal {};
class BasicAuthenticator implements Authenticator<BasicCredentials, BasicAuthPrincipal> {
public Optional<BasicAuthPrincipal> authenticate(BasicCredentials creds) {
return new BasicAuthPrincipal();
}
};
@christophercurrie
christophercurrie / CustomObjectMapperProvider.scala
Created Jan 8, 2014
Example of implementing a custom Jackson object mapper provider for Scala
View CustomObjectMapperProvider.scala
import javax.ws.rs.ext.{ContextResolver, Provider}
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
@Provider
class CustomObjectMapperProvider extends ContextResolver[ObjectMapper] {
def getContext(tpe: Class[_]): ObjectMapper = {
if (tpe != classOf[ObjectMapper]) null
else {
val m = new ObjectMapper()
@christophercurrie
christophercurrie / Polymorph.java
Created Feb 11, 2014
Example of Polymorphic Deserialization using Jackson
View Polymorph.java
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value=AudioAttachment.class, name="audio"),
@JsonSubTypes.Type(value=LinkAttachment.class, name="link")
@christophercurrie
christophercurrie / lazyval.txt
Created Feb 17, 2014
Lazy val synchronization bitmap is not synthetic
View lazyval.txt
Welcome to Scala version 2.11.0-M8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
scala> class Foo { lazy val foo = "bar" }
defined class Foo
scala> classOf[Foo].getDeclaredFields
res0: Array[java.lang.reflect.Field] = Array(private java.lang.String Foo.foo, private volatile boolean Foo.bitmap$0)
View gist:10691032
56k: "https://123.campfirenow.com/images/56k.gif"
bell: ":bell:"
bezos: ":laughing::thought_balloon:"
bueller: "anyone?"
clowntown: "https://123.campfirenow.com/images/clowntown.gif"
cottoneyejoe: ":notes::hear_no_evil::notes:"
crickets: "hears crickets chirping"
dadgummit: "dad gummit!! :fishing_pole_and_fish:"
dangerzone: "https://123.campfirenow.com/images/dangerzone.png"
danielsan: ":fireworks: :trophy: :fireworks:"
View keybase.md

Keybase proof

I hereby claim:

  • I am christophercurrie on github.
  • I am chriscurrie (https://keybase.io/chriscurrie) on keybase.
  • I have a public key ASCCB_YofVMqzc8YHie8ApdSQkyHJ8ERSI8g17UxbLtW3go

To claim this, I am signing this object:

View Document2.java
class Document2
{
@JsonCreator
public Document2(@JsonProperty("invalid") Double invalid)
{
// mark the value as invalid somehow
}
public void setValue1(int value1)
{
View package-lock-bad.json
{
"name": "test",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@semantic-release/commit-analyzer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@semantic-release/commit-analyzer/-/commit-analyzer-4.0.1.tgz",
"integrity": "sha512-mbyk+KPnI2UesHC1Az21CTZjzoGkzFm3w9qGKxifkmaAPMObKmbD6tPLwcFu8Bz5h08xG5yjtp1K0Pb3AKk+Dw==",
@christophercurrie
christophercurrie / package.json
Created Jul 20, 2018
Package installs with warnings
View package.json
{
"name": "test",
"version": "1.0.0",
"description": "foo",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",