Freitag, 30. Dezember 2016

Chromecast setup - not as easy as promised

Today, I bought a Google Chromecast for a friend of mine. The leaflet promises setup in three easy steps:
  • connect to power and TV (via HDMI) => ok, no problem
  • switch the source on your TV to the chromecast => ok, the splash screen asks you to open chromecast.com/setup to complete the setup
  • open chromecast.com/setup => doesn't work at all - apparently, the chromecast fails to perform a DNS lookup for itself (sic!)
The only reliable way to get it to work seems to be to install the Google Home app and use that to setup the Chromecast - which is okay, but the leaflet and the Chromecast itself explicitly recommend doing it the other way. It's a shame that Google fails to provide correct information regarding such a basic thing.

Freitag, 9. Dezember 2016

Unit testing PL/SQL stored procedures with JRuby (Part I)

Synopsis

My PL/SQL code that's running on Oracle doesn't have proper unit tests so far. The main reasons for this are
- lack of tooling (neither utplsql nor QuestCodeTester nor the SQL Developer built-in has satisfied me so far)
- lack of time (lame excuse, I know)

So I decided to once more tackle the problem.

Past experiences

Until now, I've tried the following approaches:

utPLSQL

Pro

- runs directly in the database => no additional setup necessary
- syntax errors in the unit tests / procedure calls are caught by the compiler
- same language for Code Under Test and unit tests

Con

- PL/SQL is quite limited in its expressiveness
- Integration in a CI environment for automatic builds / reporting build failures requires additional work

MRI Ruby with oci8 and Cucumber Spec files

Pro

- Ruby (it's such a wonderful language, really)
- Gherkin syntax for spec files

Con

- complicated deployment in CI environment (requires at least an Oracle instant client installation)
- even more complicated to set up on Windows (requires Devkit to compile the native extension oci8)

.NET with SpecFlow

Pro

- excellent IDE (Visual Studio)
- Gherkin syntax for spec files

Con

- Windows only (although Mono might be viable, but setting this up with ODP.NET / Oracle client seems quite complicated)
- C# is quite verbose (F# might be an alternative, though)

Java with Maven, JUnit / Cucumber-JVM

Pro

- real cross-platform
- easy deployment (no need for the Oracle client - just include ojdbc7.jar)
- Gherkin syntax for spec files

Con

- Java is incredibly verbose (Scala / Kotlin might be an alternative, though)
- Maven (enough said)

A new horizon

Requirements

My new solution should be:
- easy to deploy (no full-blown Oracle client necessary)
- really cross-platform (Windows, Linux, Mac OS X; Docker integration not strictly necessary, but would be very nice)
 - joyful (this excludes Java as a language, Maven as a build tool, and several others)

Choice

For now, I'll go with:
- JRuby (Ruby + JVM = dream team)
- Gradle (although I might switch to Rake)
- RSpec (although I might switch to Cucumber if I want a more high-level solution)

Dienstag, 19. Juli 2016

Oracle JDBC + Maven - how (not) to do it

Warning

This post is somewhat of a rant - if you are affiliated with Oracle corp, you might want to avoid reading the rest.

The goal

I wanted to write a simple Java application that demonstrated property based testing for a PL/SQL function in an Oracle database.

The facts, and some assumptions

Oracle database is owned by Oracle corp.
Java is owned by Oracle corp. 
Maven is the de-facto standard for building Java applications.

Therefore, one might assume that using Maven to build a Java application that connects to an Oracle database is pretty straightforward - just include the relevant dependency in your POM. After all, it's just a JDBC client, right?

RIGHT?

Nope.

Welcome to the wonderful world of Oracle, where lawyers, usage restrictions and stupid license agreements are king and developers are ... not really welcome.

You either have to
- download the jar file from Oracle's website (and acknowledge that you're legally entitled to download it), register with Oracle and say yes to their proprietary license agreement
- install the jar file locally with maven

or
- use the Oracle maven repository (which - again - requires you to register with Oracle and acknowledge their proprietary license agreement)
- store your username + encrypted password in a settings file

The conclusion

Never use Oracle products for hobby projects, especially not the database. It's just not worth the hassle.


Dienstag, 24. Mai 2016

vim Cheatsheet

Code formatting

gg=G format current file

Processing text through external commands 

Use the ex command ! for this

Example

:!sort
This will sort the current selection.


Donnerstag, 18. Februar 2016

Getting rid of those pesky non-breaking spaces (U+00A0) on MacOS X

A problem that's been bugging me for quite some time was that for no obvious reasons, source code I entered broke on space characters. Removing the space characters and re-entering them usually fixed the problem.

Finally, iex (the interactive Elixir shell) gave me a clue to what was really going on:

iex(11)> [ 65 ]
** (SyntaxError) iex:11: unexpected token: " " (column 5, codepoint U+00A0)


DuckDuckGoing for U+00A0 quickly revealed that U+00A0 is a non-breaking space (or nbsp). To show the offender in vim, put this in your .vimrc:

" show those darn non-breaking spaces   aka U+00A0
set list
set listchars=nbsp:.


But to really get rid of the problem, you can just remap the combination Alt+Space (which inserts the nbsp) to a plain ol' space (shamelessly copied from StackExchange):
- create the directory ~/Library/KeyBindings/
- create a new file DefaultKeyBinding.dict in this directory
- add the following entry to this file:
{
    "~ " = (insertText:, " ");
}



Montag, 25. Januar 2016

Getting rid of the Docker error "ConnectEx tcp: No connection could be made because the target machine actively refused it.."

Out of the blue, the Docker setup on my company-provided Windows laptop stopped working; I could launch the "Docker Quickstart Terminal" just fine, but every attempt to run a docker command (e.g. "docker ps") resulted in the error message:

ConnectEx tcp: No connection could be made because the target machine actively refused it..
 
Re-installing VirtualBox and Docker didn't help - the setup worked exactly once,
 but after the next reboot, the dreaded error message appeared again.
 
The root cause was my corporate VPN client; whenever I establish a VPN connection, the client seems to cut off all other NICs, thereby disabling connections to the DockerHost VirtualBox VM.

So right now, I can either work offline with Docker or work online without Docker. That kind of sucks :-/

Samstag, 9. Januar 2016

Docker cheatsheet

Remove all containers

docker ps -a -q | xargs docker rm


Mittwoch, 6. Januar 2016

Elm cheatsheet

A simple cheatsheet containing basic Elm stuff; will be updated regularly

Package management

E.g. to install the basic HTML package:

elm-package install evancz/elm-html