See also: Heapify

Pages: 1 2 3 4 5 6

Build hsdis for JDK 1.11 on Ubuntu 18.04.2 LTS

The following instructions are valid for a default installation of Ubuntu 18.04.2 LTS preinstalled with gcc make perl

For JDK 12 the same works except I've only confirmed it with binutils-2.29 and binutils-2.32

...

Read more

There are no comments on this post.

Build hsdis for JDK 1.8 on Ubuntu

I wanted to build hsdis for my Ubuntu system. Virtually all of the instructions out there are slightly wrong. As per the comment on this gist a recent change (bbd1da3f538f) to the HotSpot source to be compatible with binutils 2.29 broke all the prior instructions. So literally.. my contribution here is to publicly point this out and offer copy and pasta instructions to solve it.

Gist: https://gist.github.com/kay/ec70aa7469d216ab88eb411d8dab187d

...

Read more

There are no comments on this post.

Setting up Windows Internet Name Service (WINS) on Linux

This is helpful if you've a network involving a Windows host that you want to be able to resolve the hostname of your Linux hosts.

For Debian based distros, Ubuntu etc:

apt-get install libnss-winbind winbind samba

...

Read more

There are no comments on this post.

Look guys, let's revise electricity

How are Watts, Ohms, Aamps, and volts related?

...

Read more

There are no comments on this post.

JUnit testing System.exit: A small framework

To add to my post on unit testing code that calls System.exit() I've wrote a little JUnit @Rule that allows you to set expectations in a simplified way.

The code is available on github.com/kay/assert-exit

Usage:

...

Read more

There are no comments on this post.

Testing code that calls System.exit in Java

It sometimes comes up in the course of unit testing where a unit of code calls System.exit(status). If you've a sane codebase this is normally within a main class. Consider an insane codebase:

Consider

public class DisgruntledPenguin {
    public static boolean happy() {
        System.exit(5);
    }
}

...

Read more

There are no comments on this post.

Detecting, locating and fixing referenced based heap memory leaks (Java)

A common problem we all have to deal with is fixing memory leaks. In garbage collecting languages like Java we typically expect not to ever need to worry about memory management. However the limitations of how a garbage collector works means that we can still create leaks. Which defeats the advantage of a garbage collector.

How do leaks get formed?

The Java GC determines which objects to collect by looking for references to the object. If there is no references, then the object is no longer in use and can be safely destroyed without making the application unstable. If an object is now unused but still referenced, a leak occurs. Let's create a leak:

...

Read more

There are no comments on this post.

Strong, Soft, Weak and Phantom References (Java)

There are four distinct forms of references in the JVM, and indeed many of these apply to other garbage collected languages.

  • Strong references
  • Soft references
  • Weak references
  • Phantom references

It's important to know the differences, what affect they have on the collector and when you should be using them.

...

Read more

There are 2 comments on this post.

Rename all jpeg files by their exposure date (Bash)

I like to organise my files by when they were taken. So I wrote a script to do it for me. You will need the jhead tool installed. On Debian/Ubuntu/etc this is in the jhead package.

#!/bin/bash
 
rm renameJPEG.restore.sh
 
for file in *.jpg *.jpeg *.JPG *.JPEG; do
        if [ ! -e "$file" ]; then
                continue
        fi
        echo "Inspecting $file"
        DateTime=`jhead "$file" | grep "Date/Time"`
        FoundCount=`jhead "$file" | grep "Date/Time" | wc -l`
        if [ $FoundCount -gt 1 ]; then
                echo "Found too many results for: $file"
                continue
        elif [ $FoundCount -eq 0 ]; then
                echo "No valid headers found."
                continue
        else
            BaseFile=`echo $DateTime | awk '{ print $3 }' | tr ':' '-'`
            for i in `seq 1000`; do
                if [ ! -e "$BaseFile - $i.jpg" ]; then
                    echo "New file: $BaseFile - $i.jpg"
                    mv "$file" "$BaseFile - $i.jpg"
                    echo "mv '$BaseFile - $i.jpg' '$file'" >> renameJPEG.restore.sh
                    break
                fi
            done
        fi
done

This will rename all the files to the format YY-MM-DD - i.jpg where i is a uniquifier. Note that if you've some files with bad headers then you will get the wrong output.

...

Read more

There are no comments on this post.

Web Designers vs Web Developers

It's been a long time. We deserve a post! Even if merely a link.

This is so true. Web Designers vs. Web Developers. Combat trousers are awesome. The principle reason I dislike suits is that there's never enough pockets. When you have more than 10 pockets in your trousers all of your development life, then you put on a suit and are restricted to 4. It the bane of my professional life.

...

Read more

There are no comments on this post.

Pages: 1 2 3 4 5 6

RSS
Powered by Debian, Guinness, and excessive quantities of caffeine and sugar.