Archive

Archive for the ‘coding’ Category

Summing up numeric values using bash

March 22, 2017 Leave a comment

For example to add up the disk usage at several disjoint locations:

me@box$ numfmt --to=iec $[$(du -s /home/*/docs | cut -f 1 | paste -sd+)]
101K

The $[..] is for arithmetic evaluation in bash.
Alternatively pipe to the bc command.

Categories: bash, coding

Simplest Dependency Injection

January 17, 2017 Leave a comment

diy

Note to self: If you create a Java application and think you need DI but not AOP, then do not automatically reach for containers like Spring, CDI, Guice. Just do all construction and wiring in the standard main method.

Example: https://github.com/odoepner/bagh-chal/blob/master/src/main/java/net/doepner/baghchal/Main.java

Schedule wireless availability using ddwrt

January 7, 2017 Leave a comment

Sometimes I have problems ending my internet use in time to get enough quality sleep.

So I decided to set up a schedule that automatically disables our wireless home network during certain night hours for “nights before work/school day” and slightly longer hours for “night before weekend day”. Luckily this is quite easily done with the ddwrt firmware that I run on my router.

I couldn’t use the “Radio Time Restrictions” feature under Wireless – Advanced Settings, because it only supports one uniform schedule for all days of the week. Instead I used ddwrt’s cron support and the wl command.

I configured the following entries under Administration – Management – Cron. This turns on the wireless every morning at 6am, shuts it down at 10:30pm on Sunday to Thursday and shuts it down at 11:45pm on Friday and Saturday:

00 06 * * *   root wl radio on
30 22 * * 0-4 root wl radio off
45 23 * * 5-6 root wl radio off
Categories: coding Tags: , , ,

Convert mpc to mp3 on Linux

January 1, 2017 Leave a comment

You need the lame and mpcdec commands. On Debian, mpcdec is in the musepack-tools package:

sudo apt-get install lame musepack-tools

Then to convert all mpc files in the current directory to matchingly named mp3 files:

for x in *.mpc; do mpcdec "${x}" - | lame -r - "${x%.mpc}.mp3"; done
Categories: bash, coding, debian, linux, music

bash : Loop over lines in file with user prompt

December 8, 2016 Leave a comment

I used the following to loop over the lines in a file, while prompting the user for a key press on each iteration:

while read -u 3 line ; do 
  #clear the screen
  printf "\033c" 
  echo "$line"; echo

  # do something with the $line here

  read -n 1 -s -p "[Press any key to continue]"
done 3< "some-file.txt"

The reading of the lines is done via file descriptor 3 to avoid interference with the reading of the user’s key presses.

Categories: bash, coding Tags: ,

Slightly better looking oliver.doepner.net ?

October 24, 2016 Leave a comment

My resume website http://oliver.doepner.net/ now has a new scaling background image and uses the Open Sans web font. I hope it looks nice. Any feedback is welcome.

Categories: coding, css, doepner.net Tags: ,

Java EE 8 Roadmap and Update from JavaOne 2016

September 22, 2016 Leave a comment

Anil Gaul’s keynote showed a JEE8 plan with new scope and release targets.
Oracle says JEE must adjust to trends like cloud and microservices.

The ambitious roadmap aims for JEE8 release in 2017 and JEE9 in 2018:
jee-roadmap

The scope changes include two new JSRs: “Configuration” and “Health Check”:
jee8-revised

Surprisingly, Oracle wants to remove MVC and JMS 2.1 from JEE8 scope.
Allegedly they are “no longer very relevant in the cloud”.
Unfortunately, the roadmap also no longer mentions JCache.

The proposed JEE8 architecture stack is very focused on Java for light-weight web services:
jee8-architecture

More details are in the “Java EE 8 Update” by Linda DeMichiel:

Categories: conference, java, javaone Tags: , ,