evilissimo's rumblings

Love for C++, Go and Python - Developer by heart. OpenSource is my bread and butter.

Read this first

DevConfCZ 2018: Microcontainerize your apps the easy way

My first talk at a conference about my current work, LEAPP:
Find out more about LEAPP at https://leapp-to.github.io

Slides:

Demo

Continue reading →


Using cloud-init in oVirt

What is cloud-init

cloud-init provides the capability of early initialization of a virtual machine.
This usually happens during the startup of the guest operating system on the virtual machine.

What can I do with it in oVirt?

oVirt allows you to configure:

  • an initial user account including password and your SSH key
  • a hostname
  • the timezone of the virtual machine
  • DNS settings and networks on the virtual machine

Additionally it allows you to pass a custom cloud-init script, which should give you the full flexibility cloud-init provides.

Virtual machine requirements

In order to use cloud-init with a virtual machine the cloud-init package has to be installed on the VM in question. For most distributions packages for cloud-init should be available in their respective package repositories.

So the VM, you would like to use cloud-init with, needs to have preinstalled the cloud-init...

Continue reading →


Using MySQL / MariaDB via SSH in Golang

In this post I will show how easy it is to connect to MySQL/MariaDB on a server via SSH using the local SSH-AGENT or password

package main

import (
    "database/sql"
    "fmt"
    "net"
    "os"

    "github.com/go-sql-driver/mysql"
    "golang.org/x/crypto/ssh"
    "golang.org/x/crypto/ssh/agent"
)

type ViaSSHDialer struct {
    client *ssh.Client
}

func (self *ViaSSHDialer) Dial(addr string) (net.Conn, error) {
    return self.client.Dial("tcp", addr)
}

func main() {

    sshHost := "example.com"   // SSH Server Hostname/IP
    sshPort := 22              // SSH Port
    sshUser := "ssh-user"      // SSH Username
    sshPass := "ssh-pass"      // Empty string for no password
    dbUser := "dbuser"         // DB username
    dbPass := "dbpass"         // DB Password
    dbHost := "localhost:3306" // DB Hostname/IP
    dbName := "database"       // Database name

    var agentClient
...

Continue reading →


Using Postgres over SSH in Golang

In this post I will show how easy it is to connect to postgres on a server via SSH using the local SSH-AGENT or password

package main

import (
    "database/sql"
    "database/sql/driver"
    "fmt"
    "net"
    "os"
    "time"

    "github.com/lib/pq"
    "golang.org/x/crypto/ssh"
    "golang.org/x/crypto/ssh/agent"
)

type ViaSSHDialer struct {
    client *ssh.Client
}

func (self *ViaSSHDialer) Open(s string) (_ driver.Conn, err error) {
    return pq.DialOpen(self, s)
}

func (self *ViaSSHDialer) Dial(network, address string) (net.Conn, error) {
    return self.client.Dial(network, address)
}

func (self *ViaSSHDialer) DialTimeout(network, address string, timeout time.Duration) (net.Conn, error) {
    return self.client.Dial(network, address)
}

func main() {

    sshHost := "example.com" // SSH Server Hostname/IP
    sshPort := 22            // SSH Port
    sshUser := "ssh-user"
...

Continue reading →


Mac OS X Keyboard Bindings for Home and End Keys

For my work I am using a physical keyboard which has Home and End keys, having switched to a Mac only quite recently there are still things that aren’t really obvious to me yet or I still feel them annoying in regards to cursor movements.
One of the things I that has been confusing me now for quite some time is the reaction of the Home and End keys on my keyboard. Instead of moving to the beginning of the line or the end of the line and selecting it when using the Shift modifier the cursor jumped around to the beginning or the end of the file respectively.

The solution came to mind when I found out about the ~/Library/KeyBindings/DefaultKeyBinding.dict file which lets you customize the keybindings to your liking.

My customization looks like that:

{
"\UF729"  = "moveToBeginningOfLine:";
"\UF72B"  = "moveToEndOfLine:";                        
"$\UF729" =
...

Continue reading →


How to get your kerberos tickets being used in Google Chrome on Mac OS 10.11 El Capitan for a selected domain

With MacOS 10.11 (El Capitan) (maybe even 10.10 not sure about this) you run the following commands in your Terminal:

$ defaults write com.google.Chrome AuthServerWhitelist "*.example.com"
$ defaults write com.google.Chrome AuthNegotiateDelegateWhitelist "*.example.com" 

Then you restart (if it is running) Google Chrome and et voila it should accept the Kerberos ticket on your system.

This should persist updates.

HTH :-)

View →


Simple connection fowarder in golang

Just a quicky. I love the simplicity how you can solve issues in golang.
I was trying to port forward something but had to have it on a public IP.
ssh did not do what I want so I just wrote a quick and dirty version in golang:

package main

import (
    "io"
    "log"
    "net"
    "os"
)

func forward(conn net.Conn) {
    client, err := net.Dial("tcp", os.Args[2])
    if err != nil {
        log.Fatalf("Dial failed: %v", err)
    }
    log.Printf("Connected to localhost %v\n", conn)
    go func() {
        defer client.Close()
        defer conn.Close()
        io.Copy(client, conn)
    }()
    go func() {
        defer client.Close()
        defer conn.Close()
        io.Copy(conn, client)
    }()
}

func main() {
    if len(os.Args) != 3 {
        log.Fatalf("Usage %s listen:port forward:port\n", os.Args[0]);
        return
    }    

    listener, err := net.Listen("tcp",
...

Continue reading →


Meet pypa, libpypa

For quite a while, I have been playing with the thought of writing a parser for a programming language. I have never written one before and therefore I somehow had to scratch an itch in that regards.
That itch however was never that much disturbing that I would just go ahead and write an arbitary programming language parser.

To be honest, back in 2004 I have been ‘contributing’ to a language parser project, namely OpenC++ but that was a massive project (at least for my perception at that time). I was overwhelmed by it and additionally very new to programming in general so I did not really do much on that project. At the same time the OpenC++ project also lost its drive, unfortunately, what eventually led to the fact that I let go of it and followed other interests.

Fast-forward 10 years. It’s 2014 and the pyston project by dropbox was announced. It took a while until I had a look at...

Continue reading →


Back again

Once upon a time I used to have a blog. This blog was ugly old and full of random information. Let’s change this to just random information ;-)

Good to be back.

View →