Tag: arduino
Posts
Flashing QMK DFU firmware on a Pro Micro
Naming things is hard. As a software engineer, I know this all to well. The times I've puzzled, despared, cursed at whoever named some variable, only to have git blame tell me that this particular variable was added by a certain remmelt…
Either way. In this post I will document the steps I took to flash the qmk-dfu bootloader onto a Pro Micro Arduino clone.
Terms First off, here are some terms I'll be using.
Tag: code
Posts
Use Consul's KV store for Dropwizard settings
I wanted to see how hard it would be to get Dropwizard config from Consul’s key value store. Turns out it is very easy to do!
Make sure you’re using Dropwizard >= 0.8.0, this has the SubstitutingSourceProvider that we’re going to use.
Create a default Dropwizard project with the following configuration line in its config.yml:
someSetting: ${settings/someSetting}
Don’t forget to add it to the xxxConfiguration:
@JsonProperty @NotEmpty private String someSetting; Now in the xxxApplication class, register a new ConsulKVSubstitutor in the initialize method:
Posts
File upload using Dropwizard 0.8.0-rc2
Dropwizard 0.7.1 used com.sun.jersey:jersey-server:jar:1.18.1, where version 0.8.0 comes with org.glassfish.jersey.core:jersey-server:jar:2.15.
Before, when uploading files, it was enough to add the com.sun.jersey.contribs:jersey-multipart dependency like so:
<dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-multipart</artifactId> <version>1.18.3</version> </dependency> This will not work anymore and throws the somewhat cryptic exception: java.lang.IllegalArgumentException: The MultiPartConfig instance we expected is not present. Have you registered the MultiPartConfigProvider class?
The correct dependency should be
<dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-multipart</artifactId> <version>2.15</version> </dependency> Update your imports and you’re good to go.
Tag: config
Posts
Use Consul's KV store for Dropwizard settings
I wanted to see how hard it would be to get Dropwizard config from Consul’s key value store. Turns out it is very easy to do!
Make sure you’re using Dropwizard >= 0.8.0, this has the SubstitutingSourceProvider that we’re going to use.
Create a default Dropwizard project with the following configuration line in its config.yml:
someSetting: ${settings/someSetting}
Don’t forget to add it to the xxxConfiguration:
@JsonProperty @NotEmpty private String someSetting; Now in the xxxApplication class, register a new ConsulKVSubstitutor in the initialize method:
Tag: consul
Posts
Use Consul's KV store for Dropwizard settings
I wanted to see how hard it would be to get Dropwizard config from Consul’s key value store. Turns out it is very easy to do!
Make sure you’re using Dropwizard >= 0.8.0, this has the SubstitutingSourceProvider that we’re going to use.
Create a default Dropwizard project with the following configuration line in its config.yml:
someSetting: ${settings/someSetting}
Don’t forget to add it to the xxxConfiguration:
@JsonProperty @NotEmpty private String someSetting; Now in the xxxApplication class, register a new ConsulKVSubstitutor in the initialize method:
Tag: docker
Posts
Start Postgres container and connect with JDBC
Quick example of how to set up a Docker container with Postgresql, using the Spotify Docker Java client.
This supposes a running Docker installation on your local computer, for example using boot2docker.
import com.google.common.base.Strings; import com.google.common.net.HostAndPort; import com.spotify.docker.client.DefaultDockerClient; import com.spotify.docker.client.DockerCertificateException; import com.spotify.docker.client.DockerClient; import com.spotify.docker.client.DockerException; import com.spotify.docker.client.messages.ContainerConfig; import com.spotify.docker.client.messages.ContainerCreation; import com.spotify.docker.client.messages.ContainerInfo; import com.spotify.docker.client.messages.HostConfig; import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @Slf4j public abstract class PostgresContainerExample { public static Connection setUpDbContainer() throws SQLException { try { // This will only work with the DOCKER_HOST environment variable set final DockerClient docker = DefaultDockerClient.
Posts
Start Postgres container and connect with JDBC
Quick example of how to set up a Docker container with Postgresql, using the Spotify Docker Java client.
This supposes a running Docker installation on your local computer, for example using boot2docker.
import com.google.common.base.Strings; import com.google.common.net.HostAndPort; import com.spotify.docker.client.DefaultDockerClient; import com.spotify.docker.client.DockerCertificateException; import com.spotify.docker.client.DockerClient; import com.spotify.docker.client.DockerException; import com.spotify.docker.client.messages.ContainerConfig; import com.spotify.docker.client.messages.ContainerCreation; import com.spotify.docker.client.messages.ContainerInfo; import com.spotify.docker.client.messages.HostConfig; import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @Slf4j public abstract class PostgresContainerExample { public static Connection setUpDbContainer() throws SQLException { try { // This will only work with the DOCKER_HOST environment variable set final DockerClient docker = DefaultDockerClient.
Posts
Docker Swarm setup
Edit 2015-01-07: Updated article to reflect changes in swarm. Thanks Rael!
Docker Swarm was announced at the first European DockerCon. Swarm is a pluggable cluster manager with a simple scheduler.
It’s currently not super easy to set up, so here is how I did it.
Background The swarm executable discovers hosts by reading entries from the discovery url, discovery-stage.hub.docker.com/v1/clusters/TOKEN. Sample output:
["128.199.36.196:2375","128.199.50.146:2375","128.199.32.159:2375"] As you can see, this is just a list of IP/port combinations.
Posts
Service discovering Docker cluster on Digital Ocean
Jeff Lindsay wrote about “Consul Service Discovery with Docker” and Automatic Docker Service Announcement with Registrator. Using Docker’s event stream is an elegant solution to finding out which containers are running on a particular host. Despite Jeff’s documentation and videos, I couldn’t get Consul to serve up the correct locations of my services.
Here is a description of what I did to get a service discovering cluster to run on Digital Ocean.
Tag: dropwizard
Posts
Use Consul's KV store for Dropwizard settings
I wanted to see how hard it would be to get Dropwizard config from Consul’s key value store. Turns out it is very easy to do!
Make sure you’re using Dropwizard >= 0.8.0, this has the SubstitutingSourceProvider that we’re going to use.
Create a default Dropwizard project with the following configuration line in its config.yml:
someSetting: ${settings/someSetting}
Don’t forget to add it to the xxxConfiguration:
@JsonProperty @NotEmpty private String someSetting; Now in the xxxApplication class, register a new ConsulKVSubstitutor in the initialize method:
Posts
File upload using Dropwizard 0.8.0-rc2
Dropwizard 0.7.1 used com.sun.jersey:jersey-server:jar:1.18.1, where version 0.8.0 comes with org.glassfish.jersey.core:jersey-server:jar:2.15.
Before, when uploading files, it was enough to add the com.sun.jersey.contribs:jersey-multipart dependency like so:
<dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-multipart</artifactId> <version>1.18.3</version> </dependency> This will not work anymore and throws the somewhat cryptic exception: java.lang.IllegalArgumentException: The MultiPartConfig instance we expected is not present. Have you registered the MultiPartConfigProvider class?
The correct dependency should be
<dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-multipart</artifactId> <version>2.15</version> </dependency> Update your imports and you’re good to go.
Tag: hack-time
Posts
Why does hack time fail?
Google are doing it, so it must be a great idea: hack time!
In an innovative and enlightened company, everyone will be on board quickly. Reasoning along the line of, there needs to be some level of slack so people will have space to think and come up with new ideas, which will help current clients and will lead to new clients in the future. The constant display of thirst for new knowledge will also attract new employees and ultimately lead to a real engineering culture.
Tag: java
Posts
Use Consul's KV store for Dropwizard settings
I wanted to see how hard it would be to get Dropwizard config from Consul’s key value store. Turns out it is very easy to do!
Make sure you’re using Dropwizard >= 0.8.0, this has the SubstitutingSourceProvider that we’re going to use.
Create a default Dropwizard project with the following configuration line in its config.yml:
someSetting: ${settings/someSetting}
Don’t forget to add it to the xxxConfiguration:
@JsonProperty @NotEmpty private String someSetting; Now in the xxxApplication class, register a new ConsulKVSubstitutor in the initialize method:
Tag: jersey
Posts
File upload using Dropwizard 0.8.0-rc2
Dropwizard 0.7.1 used com.sun.jersey:jersey-server:jar:1.18.1, where version 0.8.0 comes with org.glassfish.jersey.core:jersey-server:jar:2.15.
Before, when uploading files, it was enough to add the com.sun.jersey.contribs:jersey-multipart dependency like so:
<dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-multipart</artifactId> <version>1.18.3</version> </dependency> This will not work anymore and throws the somewhat cryptic exception: java.lang.IllegalArgumentException: The MultiPartConfig instance we expected is not present. Have you registered the MultiPartConfigProvider class?
The correct dependency should be
<dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-multipart</artifactId> <version>2.15</version> </dependency> Update your imports and you’re good to go.
Tag: mechanical-keyboards
Posts
Flashing QMK DFU firmware on a Pro Micro
Naming things is hard. As a software engineer, I know this all to well. The times I've puzzled, despared, cursed at whoever named some variable, only to have git blame tell me that this particular variable was added by a certain remmelt…
Either way. In this post I will document the steps I took to flash the qmk-dfu bootloader onto a Pro Micro Arduino clone.
Terms First off, here are some terms I'll be using.
Tag: multipart
Posts
File upload using Dropwizard 0.8.0-rc2
Dropwizard 0.7.1 used com.sun.jersey:jersey-server:jar:1.18.1, where version 0.8.0 comes with org.glassfish.jersey.core:jersey-server:jar:2.15.
Before, when uploading files, it was enough to add the com.sun.jersey.contribs:jersey-multipart dependency like so:
<dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-multipart</artifactId> <version>1.18.3</version> </dependency> This will not work anymore and throws the somewhat cryptic exception: java.lang.IllegalArgumentException: The MultiPartConfig instance we expected is not present. Have you registered the MultiPartConfigProvider class?
The correct dependency should be
<dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-multipart</artifactId> <version>2.15</version> </dependency> Update your imports and you’re good to go.
Tag: postgrtes
Posts
Start Postgres container and connect with JDBC
Quick example of how to set up a Docker container with Postgresql, using the Spotify Docker Java client.
This supposes a running Docker installation on your local computer, for example using boot2docker.
import com.google.common.base.Strings; import com.google.common.net.HostAndPort; import com.spotify.docker.client.DefaultDockerClient; import com.spotify.docker.client.DockerCertificateException; import com.spotify.docker.client.DockerClient; import com.spotify.docker.client.DockerException; import com.spotify.docker.client.messages.ContainerConfig; import com.spotify.docker.client.messages.ContainerCreation; import com.spotify.docker.client.messages.ContainerInfo; import com.spotify.docker.client.messages.HostConfig; import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @Slf4j public abstract class PostgresContainerExample { public static Connection setUpDbContainer() throws SQLException { try { // This will only work with the DOCKER_HOST environment variable set final DockerClient docker = DefaultDockerClient.
Tag: process
Posts
Why does hack time fail?
Google are doing it, so it must be a great idea: hack time!
In an innovative and enlightened company, everyone will be on board quickly. Reasoning along the line of, there needs to be some level of slack so people will have space to think and come up with new ideas, which will help current clients and will lead to new clients in the future. The constant display of thirst for new knowledge will also attract new employees and ultimately lead to a real engineering culture.
Tag: qmk
Posts
Flashing QMK DFU firmware on a Pro Micro
Naming things is hard. As a software engineer, I know this all to well. The times I've puzzled, despared, cursed at whoever named some variable, only to have git blame tell me that this particular variable was added by a certain remmelt…
Either way. In this post I will document the steps I took to flash the qmk-dfu bootloader onto a Pro Micro Arduino clone.
Terms First off, here are some terms I'll be using.
Tag: settings
Posts
Use Consul's KV store for Dropwizard settings
I wanted to see how hard it would be to get Dropwizard config from Consul’s key value store. Turns out it is very easy to do!
Make sure you’re using Dropwizard >= 0.8.0, this has the SubstitutingSourceProvider that we’re going to use.
Create a default Dropwizard project with the following configuration line in its config.yml:
someSetting: ${settings/someSetting}
Don’t forget to add it to the xxxConfiguration:
@JsonProperty @NotEmpty private String someSetting; Now in the xxxApplication class, register a new ConsulKVSubstitutor in the initialize method:
Tag: spotify
Posts
Start Postgres container and connect with JDBC
Quick example of how to set up a Docker container with Postgresql, using the Spotify Docker Java client.
This supposes a running Docker installation on your local computer, for example using boot2docker.
import com.google.common.base.Strings; import com.google.common.net.HostAndPort; import com.spotify.docker.client.DefaultDockerClient; import com.spotify.docker.client.DockerCertificateException; import com.spotify.docker.client.DockerClient; import com.spotify.docker.client.DockerException; import com.spotify.docker.client.messages.ContainerConfig; import com.spotify.docker.client.messages.ContainerCreation; import com.spotify.docker.client.messages.ContainerInfo; import com.spotify.docker.client.messages.HostConfig; import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @Slf4j public abstract class PostgresContainerExample { public static Connection setUpDbContainer() throws SQLException { try { // This will only work with the DOCKER_HOST environment variable set final DockerClient docker = DefaultDockerClient.
Tag: swarm
Posts
Docker Swarm setup
Edit 2015-01-07: Updated article to reflect changes in swarm. Thanks Rael!
Docker Swarm was announced at the first European DockerCon. Swarm is a pluggable cluster manager with a simple scheduler.
It’s currently not super easy to set up, so here is how I did it.
Background The swarm executable discovers hosts by reading entries from the discovery url, discovery-stage.hub.docker.com/v1/clusters/TOKEN. Sample output:
["128.199.36.196:2375","128.199.50.146:2375","128.199.32.159:2375"] As you can see, this is just a list of IP/port combinations.