Mittwoch, 16. Dezember 2015

Running Oracle in a Docker container on OS X

This guide provides a step-by-step introduction for getting up and running with the Oracle database in a Docker container on OS X.

Step 1: Install Docker

Grab the Docker toolbox  and install it

Step 2: Startup Docker

Run Docker Quickstart Terminal (e.g. by searching for "Docker" in Spotlight)

Step 3: Get the image

We'll use the excellent Docker image by alexeiled - it contains some modifications to make our life easier.

Inside our Docker shell, run

docker pull alexeiled/docker-oracle-xe-11g

to get the image from DockerHub.


Step 4: Startup container

To launch a new container from our image, run

docker run -d -p 49160:22 -p 49161:1521 -p 49162:8080 alexeiled/docker-oracle-xe-11g

You can check which containers are running with

docker ps

Step 5: Connect to our Docker container via SSH

There's a gotcha here: most Docker tutorials assume you're running on a Linux box, where Docker client and Docker server are the same machine. But on OS X, your Docker server is a VirtualBox VM, so none of the usual commands work without modification.

E.g. to connect to our Docker image via SSH, we'd normally use

ssh root@localhost -p 49160

but we'll have to connect to our Docker server instead of localhost:

ssh root@192.168.99.100 -p 49160

(this assumes that the Docker server uses the IP address 192.168.99.100 - when the Docker VM is starting up, it'll tell you which IP address it uses).

Step 6: Logon to Oracle APEX

Now, you can use your Oracle installation. E.g. to log on to APEX, simply open

http://192.168.99.100:49162/apex

in your web browser.


Samstag, 12. Dezember 2015

Sonntag, 6. Dezember 2015

Cooking recipe for GitHub

Simple bugfix / pull request

If you want to help an open source project on GitHub and have a simple bugfix that you would like to see integrated, here's the most straightforward way to do it:

- fork the repo on GitHub
- clone your repo locally
- create a new local branch (let's call it doc-fix-1)
      git branch doc-fix-1
- switch to this branch
      git checkout doc-fix-1
- change the code :-)
- commit it
      git commit -a -m "simple doc fix"
- push it to github, creating a new branch
      git push origin doc-fix-1
- create a pull request on GitHub

(Just a personal note: how I wish that git would at least try to be as user-friendly as hg is...)

Syncing a fork

If you've forked a repository and want to keep it up-to-date, do this:

Add the original repo (just once)

git remote add upstream

Sync with original (whenever you like)


git fetch upstream
git checkout master
git merge upstream/master

Extract values via pattern matching in Elm/Haskell

Haskell


Suppose you have a simple data definition for a direction and want to add a delta of type Int to it:

data Direction = Direction Int deriving Show
let d = Direction 7
 

Obviously, this doesn't work:

d + 5

because the types are not compatible. The solution is pattern matching:

let 
  (Direction value) = d
in
  d + 5


Elm


type Direction = Direction Int

update :: Direction -> Int -> Direction
update dir delta =
  let 
    (Direction value) = dir
  in
    Direction (value + delta)