Finishing Tree Cookies

Finished Decorative Wood Piece

Finished Decorative Wood Piece

For this project, I had some tree cookies from what might have been a Mesquite tree. I wanted to smooth them over and use one for a cake stand and maybe make a clock from another. I had 5 pieces originally in case some didn’t turn out, and one was used just for testing a tung oil finish.

Unfinished Wood Cookies

Unfinished Wood Cookies

The tree slices or cookies, were pretty rough to start with. They were covered in chainsaw marks and uneven. I tried sanding them smooth using a handheld random orbit sander and a belt sander with no luck. There was too much material to take off, and they were too big for the planer or any saw. I finally had good luck using an angle grinder with a 36grit sandflap attachment to take the chainsaw marks off.

Epoxy Drying

Epoxy Drying

After smoothing out the cookies, I wanted to use epoxy to the fill the cracks in. A couple of the pieces had holes that went all the way through and could look pretty neat after being filled. On two of the pieces, I just used plain clear epoxy and the other two I mixed in some gold colored powder hoping to add a neat effect. The plain epoxy never ended up curing correctly, but the gold was fine, though the bigger piece with gold didn’t look very good afterwards.

Gold Filler

Gold Filler

The tung oil finish looked pretty splotchy on the outter parts of the wood, so on the one I really liked, I just cut off the edges to leave a funky decorative piece instead.

Unpolished
Unpolished

Gold Picture Frames

Last weekend I worked on building some picture frames from scratch. They didn’t turn out the way I hoped, but I will probably still use them.

gold frames

Gold Frames

I wanted to make some custom sized frames to hold some photos and mats for the welcome table at our wedding, one will frame an 8×8 square photo, one an 11×14, and the last was for a 3 5×7 collage photo mat. Except for the 11×14+mat, the sizes I wanted are a little odd and hard to find. I want something like a 12×12, 12×23, and 15×18.

I started with just plain 1×2 cedar boards from the Home Depot and first went over the edges with my router. I cut a slot down the back to hold the glass and photo, and then chamfered the other two sides on the front.

After edging, I cut the boards to length on the mitre saw with a 45 degree angle for each corner. Next, I glued them up with some brad nails to hold the pieces while the glue set. The corners did not come out as clean and square as last time, but that is probably because of using less sturdy brad nails instead of corner clamps.

Unpainted Frames

Unpainted Frames

I sanded them using my random orbit sander and then spray painted them all in a makeshift paint box. The paint box was made from pvc with a plastic drop cloth taped over it. Nothing special, but it worked.

Paint Box

Paint Box

I used grey primer and then metallic gold spray paints. The shinyness of the gold was impressive and better than I expected. Unfortunately, it also showed off all the defects and rough patches.

In The Paint Box

In The Paint Box

They didn’t turn out as nice as last time. I’ll probably sand them down and repaint to a flat black or other color.

Spark for ESP8266 Wifi Display

Last year I created a simple ESP8266 based Wifi display using a Wemos D1 Mini and a 4×20 character LCD – Video 1 – Video 2. I used a php script for the backend because I wanted it show the time without having to add an RTC, and I didn’t want to format messages on the board. The php script will generate a preformatted message for the board, so it just has to split out the 4 separate lines. This was great, but I want to change the messages a little bit easier.

ESP8266 WiFi Display

Instead of using php this time, I went with Java which I’m much more familiar with, and will run the server on a Raspberry Pi. I have also set the wifi board to fallback to the old php script anytime the new Java server is unavailable. Since I’m using a Pi, it will be up and down a lot as I work on other projects, and don’t want the time on the display to be too far off. The message will change when it falls back, but I don’t mind.

Change message page

Spark

I created a Java app using Spark, which is a Java web app micro framework based on statics and Lambdas. It starts up super fast, typically only a couple hundred millis, and is very lightweight. This works great on something like a Pi or shared environments where resources are limited.

Spark Helloworld

import static spark.Spark.*;

public class HelloWorld {
    public static void main(String[] args) {
        get("/hello", (req, res) -> "Hello World");
    }
}

Thymeleaf

Spark also works with template engines so in addition to services, you can generate html pages. I used Thymeleaf to create a basic message editing page that will display the current message.

To send a Thymeleaf template response with Spark, create a Thymeleaf TemplateEngine and return the result of the engine.render method in your response:

private static final TemplateEngine thymeleaf = new ThymeleafTemplateEngine();
...
Spark.get("/yourPath", (req, res) -> {
  Map<String, Object> model = new HashMap<>();
  model.put("templateVariableName", value);
  model.put("variable2", message2);
  return thymeleaf.render(
      new ModelAndView(model, "templateFileName")
  );
});

build.gradle Dependencies

compile group: 'com.sparkjava', name: 'spark-core', version: '2.6.+'
compile group: 'com.sparkjava', name: 'spark-template-thymeleaf', version: '2.5.5'

Basic Auth

I didn’t want just anyone to be able to change the message, so I added an HTTP Basic Auth filter using QMetrics Spark Authentication library to require a username and password. This was the easiest route to get a minimal level of security, but please note that basic auth is not safe for plain text http connections and should only be used over https. Basic auth actually sends the username and password as a Base64 encoded header string, so without https anyone can decode them. In this case though, there is minimal risk.

Spark.before(new BasicAuthenticationFilter(
		"/*", new AuthenticationDetails(user, pass)));

build.gradle Dependencies

compile 'com.qmetric:spark-authentication:1.4'

Fatjar

I wanted this app to be easy to run. Spark uses Jetty as an embedded http server, so it starts fast and there are only library dependencies, with nothing extra to install. A standard build will generate one jar with your code in it, but all the other libraries still need to be packaged together somehow. In the past, these would have been bundled together in a folder inside of a zip file, but a better approach is to use a fat jar.

Gradle helps make this easy. You need to create a new build task to tell Gradle to include all the dependencies in the built jar, and to set the main class in the Manifest to make it a runnable jar. Now there is just one self contained jar to distribute which could be run with java -jar your-fat-jar.jar

Gradle fatJar task

task fatJar(type: Jar) {
	manifest {
        attributes 'Implementation-Title': 'ESP8266 Wifi Display',
          'Implementation-Version': version,
          'Main-Class': 'com.mikelduke.java.wifidisplay.WifiDisplay'
    }
    baseName = 'spark-wifi-display-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}

Gradle Build Command

./gradlew fatJar

Run it

I created a shell script to start the spark-wifi-display on my pi which can be run on startup. This script starts the java app in the background so it doesn’t need a user session and sets the property the app uses to set what port the server runs on.

#!/bin/bash

nohup java -Dserver.port=8081 -jar git/ESP8266WifiDisplay/spark-wifi-display/build/libs/spark-wifi-display-all-1.0.0.jar &

Run on Heroku

The spark-wifi-display app can even be deployed and run on Heroku. It’s probably not a good choice for a free dyno though, because the wifi module will hit it repeatedly. Heroku will sleep (turn off) free dynos for 6 hours a day, so it won’t be always on and will eat up the free pool of hours doing something which is fairly pointless, but it is possible.

To enable running on Heroku, I had to add a stage task to the gradle build and create a Procfile to hold the run command.

Gradle Build Task

task stage(dependsOn: ['build', 'clean'])
build.mustRunAfter clean
stage.dependsOn(fatJar)

Procfile

web: java -Dsecured=true -Dserver.port=$PORT -jar spark-wifi-display/build/libs/spark-wifi-display-all-1.0.0.jar

The secured property is set to true since this will be available on the internet after it’s deployed. The username and password can be set in the Heroku settings page as environment variables.

Use it

The edit message page is on the root ‘/’ for example http://your-ip:8080/ and the message formatted for the display is on ‘/message’ or as an example http://192.168.1.1:8080/message

Converting to Jekyll from WordPress

Converting from WordPress to Jekyll was pretty easy. My wordpress was self hosted, so I had access to the database info I needed to export my old site.

Export

I followed the Jekyll guide where you run the ruby jekyll-importer with your database info. You might need to update ruby and install the jekyll-import gem and some other dependencies, and may need sudo for some environments.

apt-get install ruby-full
gem install jekyll
gem install jekyll-import
gem install mysql2
gem install bundler
ruby -rubygems -e 'require "jekyll-import";
    JekyllImport::Importers::WordPress.run({
      "dbname"   => "",
      "user"     => "",
      "password" => "",
      "host"     => "localhost",
      "port"     => "3306",
      "socket"   => "",
      "table_prefix"   => "wp_",
      "site_prefix"    => "",
      "clean_entities" => true,
      "comments"       => true,
      "categories"     => true,
      "tags"           => true,
      "more_excerpt"   => true,
      "more_anchor"    => true,
      "extension"      => "html",
      "status"         => ["publish"]
    })'

I couldn’t get this to run from the Dreamhost shell, but I had a Raspberry Pi I could run it on instead, since I didn’t want to have to run through the Windows Jekyll install process. Now I use a Docker container to build on my Windows machine instead. No install needed.

After exporting, I was able to build the site using all the default settings and had a folder called _posts

The wordpress posts all exported as html files containing the html from each post. Some of these might need additional jekyll plugins or include files to display properly, or some manual tweeking. In my case, a lot of the html links didn’t format correctly, and the youtube embeds didn’t display.

cd export-folder
jekyll new .
bundle exec jekyll build

This should create a _site folder in the current directory with the build site. Now start looking for new themes and customizing the site.

Customize

The first thing I did was to configure some of the settings in _config.yaml like title, email, and baseurl. I also deleted a lot of the stub pages that were exported from WordPress. Those were just there to hold the links on my title bar, but jekyll made them into empty pages.

After that, look for a theme or customize one. I didn’t see any premade ones I really liked so I just made some tweaks to the default minima theme. To modify the current theme, you copy the files you want to override from theme’s install to your project in a corresponding folder. As an example, Minmina has _includes/header.html, if you have your own _includes/header.html it will be used instead.

Youtube Embeds

One thing that was missing was the youtube video embeds I had. Using wordpress you only had to include a link to the video on it’s own line and it would automatically add the html required.

Adding extra html for use in the markdown files is straight forward. I added an include file_includes/youtubeEmbed.html with the youtbe html inside:

<iframe width="560" height="315" src="https://www.youtube.com/embed/" frameborder="0" allowfullscreen></iframe>

And can include it in a post like this:

<iframe width="560" height="315" src="https://www.youtube.com/embed/VcFI91r2zU4" frameborder="0" allowfullscreen></iframe>

Use Docker for builds

If you are on Linux/macos this might not be needed, since ruby installs are pretty easy.

  1. Install Docker for your os
  2. Share the windows folder path with your site to VirtualBox if needed
  3. Run the Docker builddocker run -it --volume PATH_TO_PROJECT:/srv/jekyll jekyll/builder jekyll build
  4. If on linux/mac and not using a VM, you can cd to the jekyll folder and use $PWD insteaddocker run -it --volume $PWD:/srv/jekyll jekyll/builder jekyll build

This will generate the _site, now you can either scp/ftp it to a webhost or run it locally from any http server.

If you want to run the site from the Docker image using the jekyll server:

docker run -it --volume /git/jekyll-temp:/srv/jekyll -p 4000:4000 --expose 4000 jekyll/builder sh -c "bundle install && bundle exec jekyll serve --host=0.0.0.0"
VirtualBox Port-Forward

If using VirtualBox, remember to enable port forwarding for port 4000 

Github pages

If you dont want to have to build anything, you can just push the git repo to git hub with a name like username.github.io and they will autodetect and build the site out for you at https://username.github.io

It is nice to build locally first to preview the changes. Having a build setup also lets you deploy the site to any other webhost too.