Oracle UTF8 encoding check

You can pretty easily see the raw bytes used for encoding a string:

This can be useful for comparing two strings — as one knows just because two strings are rendered in the same way, it does not mean that the UNICODE characters they are made of are the same, the actual UNICODE graphemes can be different.

Now that we have the raw representation of the string we can convert it back to UTF8. This can also serve as confirmation that the string was correctly encoded and that the encoding was UTF8 to start with.

A more automated way to check that the strings are correctly encoded is below (thanks StackOverflow). It relies on the fact that incorrect encoding to UTF8 results in the following characters (hex): “EFBFBD”.


TimerManager is in STOPPED state

Did you ever encounter the exception below?

I found that just removing the caches from your weblogic solves the problem. So go to $SERVER_ROOT/servers/AdminServer/cache and remove all the files in that directory.

The correct JPA provider for hibernate

While working with hibernate you will sometimes have an error message like the following:

javax.persistence.PersistenceException: No Persistence provider for EntityManager named <YOUR PERSISTENT UNIT NAME>

One of the possible causes for this is that the provider for hibernate in your persistence.xml is wrong. In various places on the web it is suggested that it should be: org.hibernate.ejb.HibernatePersistence

Putting the one above results in the obscure exception above.

To fix this enter the correct provider for hibernate: org.hibernate.jpa.HibernatePersistenceProvider

JUnit Argument Captor — enhance your mock testing

When writing mock tests it is, sometimes, more convenient to assert the values with which the methods were called using the ArgumentCaptor
class instead of the more usual mock verify.
Let’s see both in action.

We’ll take as sample a mock of the List interface.

Let’s see how verify-ing would work:

Or since we expect those to be called in that same exact order we could also:

Now let’s use ArgumentCaptor instead:

That seems more streamlined and readable IMO. As you can see the ArgumentCaptor will catch all arguments with which it was called.

If you expect a single value to be captured or if you’re only interested in the last value with which your method was called you can also call:

In our case that call will return “three”.

My Swift strings cheatsheet

The Swift strings support representing Unicode strings natively. As such it is no longer possible to have random access inside the string because some characters might be represented on more than one byte.

I always forget how to do basic things so I put together a cheatsheet that might be useful to others too.

Counting characters



Iterating through the string characters


Indexes inside the string


Is string contained in another string


Split a string by separator, iteratively



Split a string by separator, recursively


Fix UITabBar icon images as alpha-channel

Apple asks that your UITabBar icons be pure alpha-channel images with added anti-alias. That means that usual RGB channel images will just show as a blue square.

So how to go from a normal RGB channel image to a pure alpha-channel. I use Photoshop and there is probably¬†more than one way, but what works best for me is creating a “Gradient map” adjustment layer.

To create a gradient map adjustment layer go to the “Layers” tab and click “Create fill or adjustment layer…” like below.

Screen Shot 2016-01-31 at 18.50.15

Afterwards save your image and all should be fine.

Fix putty garbled text after window resize

So you resized your putty window. When going through history, if there are lines which are longer than 80 chars, the default putty window, then just going through the will show the text garbled.

The fix is simple: tell the terminal the new window size. Arguably this should be automatically done by putty, but hey, there’s a workaround. Checkout the stty command.

Pass the cols parameter to specify the new width of the window in columns.

Find your home directory in the iPhone simulator

This is huge.

Start your application, then “Debug/Pause” it.

Then type this magic into your lldb console (the debugging pane should be at the bottom of the Xcode window).

Your debugger console should now show the local directory where your application has its home.

WatchKit simulator displays spinner, willActivate is not called

So you developed your first WatchKit app, except when you’re testing it in the simulator all it does is display the spinner.

iOS Simulator Screen Shot - Apple Watch 06 Apr 2015 11.19.35

More over, method willActivate from WKInterfaceController is never called. That means the app is never displayed on the watch for the user to see. It’s as if the display was locked.

In my experience there is nothing wrong with the app, might be just small bugs that will be fixed in the later versions of XCode/simulator. You can force display on the watch. With the Simulator in focus go to menu “Hardware” and choose “Lock”. At this time your phone/watch is locked. Now, do the same thing “Hardware” then “Lock” and unlock the phone by dragging on the screen. Method “willActivate” should no be called and your app screen will be displayed on the watch display.