AngularJS formatter/parser is (not) type sensitive

I have a small AngularJS (1.x) directive so my input field does not show the value the is in the model, but formats it before (and parses the user input from the input field’s format):

angular.module('appModule')
       .directive('fooformat', function() {

    function parse(formattedValue) {
        return formattedValue.replace('foo', '');
    }

    function format(value) {
        return value + "foo";
    }

    return {
        restrict: 'A',
        require: 'ngModel',
        link: function(scope, element, attr, ngModel) {
            ngModel.$parsers.push(parse);
            ngModel.$formatters.push(format);
        }
    };
});

This does not seem to work, the fields always get empty, even though that debugging shows that the conversions are done as expected. E.g. for the string "1" the return value would become "1foo".

What seems to work is, if the changes are numerical. E.g.:

function parse(formattedValue) {
    return formattedValue - 1;
}

function format(value) {
    return value + 1;
}

This would format "1" as 2, and suddenly it would work.

Well, it’s not AngularJS formatter/parser which is sensitive to the types, but the HTML5 input field where I use it:

<input fooformat type="number ng-model="" />

needs to be changed to

<input fooformat type="text" ng-model="foo" />

Bitbucket pipeline dependency

My Bitbucket pipeline failed with the error message:

+ bundle exec hanami db prepare
sh: 1: sqlite3: not found
/usr/local/bundle/gems/hanami-model-1.2.0/lib/hanami/model/migrator/adapter.rb:214:in `block in execute'
/usr/local/bundle/gems/hanami-model-1.2.0/lib/hanami/model/migrator/adapter.rb:216:in `block in execute'
...

Apparently the Ruby Docker image is based on Debian, so I can just add

...
script:
- apt-get update && apt-get install sqlite3
... 

to my bitbucket-pipelines.yml file.

A program with an incorrect format

Server Error in '/Web.Api' Application.
Could not load file or assembly 'Oracle.ManagedDataAccessDTC' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: Could not load file or assembly ‘Oracle.ManagedDataAccessDTC’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

In my case this isn’t really an issue with the Oracle dependencies. The key here is the An attempt was made to load a program with an incorrect format part. The problem occurs on my local Windows 10 (x86_64) machine with IIS 10. And yes, the project builds for 32 bit, not 64 bit. Setting “Enable 32-bit applications” in the “Advanced settings…” of the web site (“Default Web Site” in my case), in the “Application Pools” solves the problem.

Cherry-picking changes from a file to a different file

I have a file.
I have another file on a different path on a different branch with mostly the same content.
I have changes in my first file.
I want to move these changes to my second file.
The files have the same name, only the path differs.
(I also need to ignore changes in whitespace, because consistency.)

Solution:

git show SHA_HASH --relative=original/path/ -- original//path/file.name | git apply --directory=new/path/ --ignore-space-change -

Removing annoying Cisco Jabber thingy

Cisco Jabber 11.7 on Windows 10. It has a small, somewhat hidden grey bar at the top of my screen, that shows some buttons and a search field if I put the mouse over it. I didn’t know the name of it, and it’s a bit hard to find a solution for removing it without that. In the settings nothing seems to do the trick or to be at least somewhat related.

Apparently, this is the “docked window”. On the main window, after clicking the gear button, there is a checkbox for “Show docked window”, that does remove it.

Atom dependencies on openSUSE

An RPM package is provided for download on the Atom website, however, installing it on openSUSE Tumbleweed won’t install all of its dependencies. Running it from the console will give:

/usr/share/atom/atom: error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory

According to the error message installing gconf2 will be required too.

sudo zypper install gconf2

After that Atom should work on openSUSE.

H.264 on openSUSE (round 2)

My previous post about this may be useful, but this one also works with gstreamer.

First from the official wiki for giving Firefox H.264 capabilities:

sudo zypper addrepo -f -n packman http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Tumbleweed/ packman 

adding the packman repositories

sudo zypper install libavcodec56 libavcodec57 libavformat56 libavformat57 libavdevice56 libavdevice57

installing the codecs.
Now this only makes it available for Firefox so we also need (inspired by the unofficial multimedia codec guide):

sudo zypper install gstreamer-plugins-libav 

enables it for gstreamer too.

SSH connection problem

bmiklos@workstation:~> ssh my.server.com
channel 0: open failed: connect failed: Connection timed out
ssh_exchange_identification: Connection closed by remote host

In cases like the one above this page gives good hints for solving the problem. They’re missing my case though:
The ~/.ssh/config file can contain host rules which accidentally apply to the host. E.g.:

Host *serv*.com
    ProxyCommand ssh my.service.com -W %h:%p
    User bmiklos

in my case.

Make sure that if you use wildcards in the host name, be specific enough!

(Connecting with the -v flag can also help determining what options are applied to the connection.)

H.264 on openSUSE

I’ve installed openSUSE Tumbleweed.

For some licensing reasons it doesn’t contain the necessary codecs for playing H.264 files. Following neither the official, nor the unofficial documentation solved this problem for me, so for future reference, here are the exact steps that helped for me:

    1. Adding the Packman repositories:
      sudo zypper ar -f -n packman http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Tumbleweed/ packman
    2. Installing mplayer and all its dependencies:
      sudo zypper install mplayer

But this is still not enough, there are still errors like


==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 57.64.101 (external)
Cannot find codec 'h264' in libavcodec...
VDecoder init failed :(
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Cannot find codec 'h264' in libavcodec...
VDecoder init failed :(
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Cannot find codec 'h264_crystalhd' in libavcodec...
VDecoder init failed :(
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Cannot find codec 'h264_vda' in libavcodec...
VDecoder init failed :(
Requested video codec family [coreavcwindows] (vfm=dshow) not available.
Enable it at compilation.
Cannot find codec matching selected -vo and video format 0x34363248.
==========================================================================

  1. Doing a full repository vendor change, whatever that is:
    sudo zypper dup --from packman

mplayer is able to play all kind of files now on my system. For a bit easier control I’m using gnome-mplayer:
sudo zypper install gnome-mplayer

Tests with gradle from IntelliJ

I’m trying to run tests as gradle tasks from IntelliJ with specifying which tests do I actually want to run.

From the console the tests run fine:
./gradlew myTestTask --tests 'com.mycompany.MyTestClass'

But if I create a new run/debug configuration in IntelliJ with myTestTask as the task and --tests 'com.mycompany.MyTestClass' as the script parameters then the runs produce errors like:

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myProject:myTestTask'.
> No tests found for given includes: ['com.mycompany.MyTestClass']

Apparently IntelliJ puts singe quotes around the task + script parameters, as it can be seen from the third line of the output and this seems to cause problems

1:16:34 PM: Executing external task 'myTestTask --tests 'com.mycompany.MyTestClass''...

Using double quotes instead of single ones solves the problem, and the configuration runs fine:
--tests "com.mycompany.MyTestClass"