Posts

Coding on my RPI3B from my regular machine over ssh

This weekend I've set up my rpi3B. My main goal is to see if I can use it for CI/CD, I hope it'll survive Jenkins. To do any ops work I want to be able to edit code on the rpi. Though the pi desktop environment is fine for regular browsing, but the pi is not exactly fast enough to code comfortably (vim's not my thing). There's a solution for this; just code on your regular machine (mac/laptop etc.) onto your rpi (set up as a remote environment). I remembered an ops guy at my previous job to use VS Code to edit code on a server, I've wanted to do this for a while. Turns out that VS Code makes this really easy. Follow these steps (not dummy proof): -Set up an ssh connection between your machine and your rpi -Install VS Code Insiders on your regular machine (this version offers experimental support for the rpi3B (arm7I) -Install the Remote SSH plugin -Restart VS Code (before restart the plugin only spat errors in my face) -Create a ~/.ssh/config file -Fill...

Angular 7 (formerly Angular 2) - The Complete Guide by Maximilian Schwarzmüller Chapter 3 video 6 fix

So I ran into some issues, due to the tutorial using an older version of Bootstrap. A bit sad that apparently Bootstrap makes breaking changes to it's library. Using the code in the tutorial did not get me the menu as shown in the video. Here a possible fix: < nav class ="navbar navbar-expand-sm navbar-light bg-light" > < div class ="container-fluid" > < div class ="navbar-header" > < a href ="#" class ="navbar-brand" > Recipe book </ a > </ div > < div class ="collapse navbar-collapse" > < ul class ="nav navbar-nav" > < li >< a href ="#" class ="nav-link" > Recipes </ a ></ li > < li >< a href ="#" class ="nav-link" > Shopping List </ a ></ li > </ ul > < ul class ="nav navbar-nav ml-auto" > ...

git info over actuator

<!-- generates a resources/git.properties file that exposes git properties over /actuator/info endpoint --> <plugin> <groupId> pl.project13.maven </groupId> <artifactId> git-commit-id-plugin </artifactId> <version> 2.2.5 </version> <executions> <execution> <goals> <goal> revision </goal> </goals> <phase> initialize </phase> </execution> </executions> <configuration> <dotGitDirectory> ${project.basedir}/.git </dotGitDirectory> <generateGitPropertiesFile> true </generateGitPropertiesFile> <generateGitPropertiesFilename> ${project.basedir}/src/main/resources/git.properties </generateGitPropertiesFilename> <prefix> git </prefix> <format> properties </format> <failOnUnableToExt...

Java Midi

I'm a musician in my spare time. When I started programming I wanted to make music with code. I managed to produce some notes through the java Synthesizer class. So I thought it would be fun to revisit it after working as a software engineer for almost a year. I started with the same set of websites, with StackOverflow as hub to more resources. It's amazing to see the paralels between midi and present day async web messaging. Especially if you realize that MIDI was standardized in 1983, :D. MIDI basically works through a MidiEvents triggering sounds on a MidiSynthesizer. A MidiFile is thus a Sequence of MidiEvents that you can play through a Sequencer on a Synthesizer. This is reflected in the data structure of the relevant classes. Here is some code to get started: /* Create a new Sythesizer and open it. Most of * the methods you will want to use to expand on this * example can be found in the Java documentation here: * https://docs.oracle.c...

Getting the Type from generic type parameter, Within a class

Guava makes it easier to get the type of a generic type parameter. I personally feel it's ugly to request the Class given through the generic interface <T>, even though the class should already be aware of it. Even though browsing seems to turn up that asking for Class<T> in your constructor seems like the most standard way. protected Class< T > clazz ; protected final MongoTemplate mongoTemplate ; protected ExtendedMongoTemplate (MongoTemplate mongoTemplate) { this . mongoTemplate = mongoTemplate ; final TypeToken<? extends T > typeToken = new TypeToken<>( this .getClass()){} ; final Type type = typeToken.getType() ; if (type instanceof Class) { clazz = (Class< T >) type ; } else { throw new RuntimeException( this .getClass() + ": failed to retrieve generic parameter  class in " + ExtendedMongoTemplate. class .getSimpleName() + "." ) ; } } /** * if the present way o...

Spring boot batch & MongoDB

Spring boot batch is too opinionated out of the box to gel well with mongodb, it ads the sql focussed jpa and jdbc dependenties. Excluding it will at least make your application run again, I haven't tested batching yet in this context. <dependency> <groupId> org.springframework.boot </groupId> <artifactId> spring-boot-starter-batch </artifactId> <exclusions> <exclusion> <groupId> org.springframework.boot </groupId> <artifactId> spring-boot-starter-jdbc </artifactId> </exclusion> </exclusions> </dependency>

Spring Metrics histogram

If you want to use the nice histograms from spring, it does not work out of the box. HistogramGauges. registerWithCommonFormat (timer , registry ) ; The actuator does activate a simple reporter, this seems to be the reporter that allows you to see all the meters over /actuator/metrics. This does not however include the nice quantile functionality of histograms, timers and distribution summaries. I expected to see these quantiles after using the above method, but no... For richer metric data it's thus better to use one of the third party solutions: https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html#production-ready-metrics-endpoint Prometheus is the only one of these solutions that just exposes the metrics over /actuator/ to scrape (as a .yml), the rest of the dependencies require a separate metric db to be presented to push the data to.