Archive

Archive for the ‘os’ Category

Redshift to reduce eye strain from nightly computer use

January 11, 2017 3 comments

Note: This tutorial is mainly for Linux users. For other operating systems you could consult the article “Best Automatic Display Adjustment Software for Mac, Windows, iOS and Android“.

Redshift is a little Free and Open Source tool that can reduce the blue component in the light emitted by your computer screen. By default, it does so between sunset and sunrise based on your latitude / longitude coordinates, but you can also use a permanent fixed light temperature.

The underlying idea is that too much blue light can strain your eyes, especially at night.

Permanent candle light

On Debian and derivatives like Ubuntu, the redshift command line version can be installed like this:

sudo apt-get install redshift

I personally like a “permanent candlelight” setting at all times. This simple example sets a relatively low fixed light temperature of 2200K and a slightly dimmed brightness (see man redshift for more details):

redshift -r -O 2200 -b 0.8

If you like this approach, you can run this command at X session start, similar to what is shown under “Autostart after Login” below.

Emulating Day and Night

If you want redshift to distinguish between day and night, it is convenient to use the GUI version with a config file that specifies your latitude and longitude as shown below.

On Debian and derivatives like Ubuntu, redshift with the GTK UI can be installed like this:

sudo apt-get install gtk-redshift

You can determine your coordinates by googling for the name of your town or city, combined with the words “longitude” and “latitude”, for example for the German town of “Rodgau” this would be: https://google.com/search?q=rodgau+longitude+latitude

Note that latitudes south of equator and longitudes west of Greenwich must be specified as negative values. The following shows an example ~/.config/redshift.conf for Halifax (44.65° North, 63.58° West):

[redshift]
location-provider=manual

[manual]
lat=44.65
lon=-63.58

You can visit the Redshift website for more details about installation and configuration, etc.

Run the tool for the first time either via Start Menu – Accessories – Redshift on Debian systems, or as redshift-gtk on the Linux command line. You should then be able to see a reddish light-bulb icon in the system tray (aka “notification area”) of your desktop system. Clicking on it gives you options to temporarily disable the tool or view info about your configured geo-location and whether redshift thinks it is currently night-time. If so, you should notice a reddish screen color temperature.

Autostart after Login

To have redshift-gtk start up on every X session, add an entry to the Autostart mechanism of your desktop environment or window manager. For XFCE on Debian, open Start Menu – Settings – Session and Startup – Application Autostart tab and add an entry like this:

add-redshift-to-xfce-autostart

Categories: debian, linux, xfce 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

Install portable JDK on Windows without admin rights

September 15, 2016 Leave a comment

I found the basic idea here, the exact steps are:

iron-java-mug_120x120

  1. Install Portable 7zip
  2. Download Oracle JDK installer for Windows (*.exe)
  3. Run 7-ZipPortable.exe from your Portable 7zip
  4. In 7zip find and right-click the jdk installer exe file
  5. From the context menu use 7-Zip – Open Archive and then Extract
  6. Now extract the resulting “tools.zip” to a folder that is writable for you
  7. Open a cmd.exe, cd into the folder and execute this:
for /R %f in (.\*.pack) do @"%cd%\bin\unpack200" -r -v -l "" "%f" "%~pf%~nf.jar"

Kudos to Nick Russler for figuring out this tricky unpack200 command line!

Categories: dev-tools, java, windows Tags: , ,

Determine which Tomcat version is running

August 6, 2016 7 comments

Determine process id

First we determine the process id(s) of the running Tomcat instance(s).

We can grep the running process list for ‘catalina.home’:

pgrep -f 'catalina.home'

This might yield more than one pid.

Or we can search by port (8080 is the default, adjust if necessary). The following commands will likely require root privileges:

lsof -t -i :8080

Alternatively, for example if lsof is not installed:

fuser 8080/tcp

Or yet another way, using netstat (or its “ss” replacement):

netstat -nlp | grep 8080
ss -nlp | grep 8080

Determine catalina.home

For the process id(s) determined above, we look at process details:

ps -o pid,uid,cmd -p [pidlist] | cat

For each specified pid, this shows the uid (system user) and the full command line of the process.

Typically the command line will contain something like “-Dcatalina.home=[path]” and that path is the catalina.home system property of the Java process.

Alternatively – with Java 7 and later – we can use the JDK command “jcmd” to query the JVM process for its system properties:

sudo -u [uid] jcmd [pid] VM.system_properties \
   | grep '^catalina.home' \
   | cut -f2 -d'='

Determine version

Now we can finally determine which Tomcat version is installed under the catalina.home path:

[catalina.home]/bin/catalina.sh version \
   | grep '^Server number:'

Note: Please replace [catalina.home] with the path you determined above.

The final output should be something like this:

Server number: 7.0.56.0

OpenJDK builds for Windows now available from Redhat

June 29, 2016 Leave a comment

As I mentioned in an earlier post, officially supported OpenJDK builds for non-Linux platforms have been notoriously hard to come by in the past, at least until Azul started their Zulu builds in 2013. Unofficial community builds are also available from the ojdkbuild project on Github.

Today Redhat announced that their OpenJDK offerings now include builds for the Windows platform as well.

After Google decided to use OpenJDK in Android N, I guess this is another strong indicator of OpenJDK’s value and increasingly wide adoption.

Categories: java, windows Tags: , ,

Compare two Tomcat installations using rsync

Lets assume you manage multiple servers that host Java web applications using the Tomcat web server.

To quickly compare the Tomcat installations on host1 and host2, we can use the “dry-run” mode of the rsync command.

In the following example, we assume that you have ssh access to both of your Tomcat hosts, the installations are in /opt/tomcat and the “tomcat” system user has read access to all relevant files and directories of the installation:

ssh tomcat@host1
rsync --archive --checksum --dry-run --verbose --delete \
      --exclude temp --exclude work --exclude logs --exclude webapps \
      /opt/tomcat/ tomcat@host2:/opt/tomcat/

This will list

  • All files that differ in checksum
  • All files that only exist on host2 (look for ‘deleting [filename]’)

Run the same commands with host1 and host2 switched, to also see the files that only exist on host1.

We excluded the temp, work and logs directories because they are variable in nature.
We also excluded the webapps directory because we only wanted to compare the base installation.

Categories: bash, coding, cygwin, debian, linux, mac os

Spotify on Debian GNU/Linux in Canada

March 29, 2016 Leave a comment

Today I decided to try out the free ad-sponsored Spotify music streaming service. It has been available in Canada since September 2014.

After signing up you can immediately use the flash-based web player at play.spotify.com.

Installing the client app

Alternatively you can download and install the Spotify client app. I cannot say yet what the advantages or disadvantages are, maybe reading this article can be helpful.

Anyway, if you want to try the client app, for Debian (or Ubuntu) users it works like this:

  1. Add the repo key (to verify downloaded packages)
  2. Add the spotify repo to apt sources
  3. Update apt caches
  4. Install the spotify client

Here are the shell commands (requires sudo):

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886
echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list
sudo apt-get update
sudo apt-get install spotify-client

After successful installation you will find a “Spotify” entry in the “Multimedia” section of your start menu.

Using your Facebook login

If you use your Facebook account to sign into Spotify you will probably see this question:

Spotify would like to post to Facebook for you.
Who do you want to share these posts with?

It is safe to choose “Not Now” which prevents Spotify from posting to your timeline. The login will still work.

If your are using the downloaded stand-alone client app and the Facebook login fails with an error page, then simply enter the email address and password from your Facebook account into the login fields of the Spotify client app.

Spotify says that it only uses these credentials to pass through to the Facebook authentication and won’t store your password anywhere. I hope that’s true.

Categories: bash, debian, linux, music Tags: