Batmobile Logic – A New Podcast

So I wanted to make everyone aware that I have started a podcast with a friend of mine. If you are interested checking out our podcast about technology and random tech stuff feel free to checkout Batmobile Logic. I hope it is interesting, funny and informative.

http://www.batmobilelogic.com

Atom

Atom Text Editor

So I am a bit slow on noticing this announcement but earlier this month the Atom Text Editor that the guys at GitHub have been working on was open sourced. Now this has been my favorite editor for the Mac since I got into the beta for it and so far is better than most text editors I have used. The one editor that would be compared to it is Sublime Text which I think Atom beats very easily for two reasons.

First, Atom has an actual screen for settings. This is one of my biggest issues with sublime the fact that is uses a text file as its settings. Sorry not user-friendly. Instead Atom has a well thought out settings GUI and includes an amazing package manager. It even has a way for the packages (plugins and themes) to tell you shortcuts they have. Now I have only use sublime lightly so maybe it has some of these things buried but I cannot stand Sublime Text long enough to use it whereas I have enjoyed Atom every time. (even the old version which caused my fan to run on my MacBook).

Second, they licensed it under the MIT license. Now this is even more an opinion then the first. Personally I love the openness of the MIT license so I am happy they went with that over GPL. It is even better then Sublime Text since they want you to pay. You would expect there to be many more features if your paying but really it’s just a plugin engine.

So if you’re using a Mac I recommend you checkout Atom at atom.io and if you’re using Windows or Linux well you can build it yourself or just wait I am sure the packages will be out soon.

And I’m back on WordPress

Well as some might have noticed I tried to move my blog over to ghost.org. It has been living there for the last 3 months or so. While I love the user interface and the simplicity of ghost.org I missed the built-in comments and stats. At the same time I also missed the fact that WordPress allows you to upload images to WordPress. Instead for Ghost you have to upload your files to another site and link to it. That means a lot of extra work for something like just adding a photo. In any case while Ghost may some day be an alternative it is not ready at least from an ease of use perspective so I’m back.

Named Pipes in C

If you happen to be programming in C at some point and you want to pass messages between two processes named pipes is an option. What you are doing is defining a node on the filesystem as a FIFO node and then piping messages through it. In the examples below I create a reader which reads from a named pipe. The pipe is defined as DEFAULT_PIPE in test.h. The writer application will write out a single line to named pipe.

//
// test.h
//

#ifndef test_h
#define test_h

#define DEFAULT_PIPE "/Users/nick/pipetest"

#endif
//
//  NamedPipeReader
//

#include
#include
#include
#include
#include
#include "test.h"

int main(void)
{
    FILE *fp;
    char readbuf[128];

    // Try creating pipe if it doesn't exit.
    mknod(DEFAULT_PIPE, S_IFIFO|0666, 0);

    // Lets say what is going on.
    fprintf(stdout, "Pipe %s created!\n", DEFAULT_PIPE);
    while(1)
    {
        // Open the named pipe.
        fp = fopen(DEFAULT_PIPE, "r");
        if (fp == NULL)
        {
            // Print error if an issue shows up.
            perror("fopen error");
            exit(1);
        }

        // Get string from the pipe.
        fgets(readbuf, 128, fp);
        // Print the pipe data to stdout (console).
        fprintf(stdout, "Received string: %s\n", readbuf);
        // Close the named pipe.
        fclose(fp);
    }

    return(0);
}
//
//  NamedPipeWriter
//

#include
#include
#include "test.h"

int main(int argc, char *argv[])
{
    FILE
        *pipe;
    char
        buffer[128];

    // Open existing pipe.
    if((pipe = fopen(DEFAULT_PIPE, "w")) == NULL) {
        perror("error from fopen");
        exit(1);
    }

    // Read a line from stdin (console).
    fgets(buffer, sizeof(buffer), stdin);

    // Write the line to the pipe.
    fputs(buffer, pipe);

    // Close the pipe.
    fclose(pipe);
    return(0);
}

Podcasts! Wait Wait Don’t Tell Me

Wait Wait Don’t Tell Me is the second of the two NPR podcasts which I listen to. It is a comedy/news podcast. They cover the news of the week while making fun of it and in generally being quite entertaining. If you’re looking for some general news or just a funny podcast I would recommend this one.

Link: NPR

Podcasts! This American Life

At this point in my Podcasts! series we enter the realm of NPR related podcasts. There are actually a few podcasts put out which I have found to be quite enjoyable. We will begin with This American Life. The only really good way I have ever found to describe This American Life is as the Readers Digest of podcasts. What do I mean by this? Basically it is an eclectic collection of stories. Every week it is generally some nice and timeless topic which is covered. It is always covered in such a way that anyone can approach it and still find it interesting. So I recommend this podcast to anyone out there looking for something simple and informative to fill some time. One note is that this podcast does tend to sway bit to the liberal side. This though is not to bad so far I have only felt the need to skip one episode due to these opinions. If you are curious it was an episode about guns which was put out when the media was being flooded with anti-gun propaganda and I really did not need to hear the same thing from yet another place.

Link: This American Life

rabbitmq

Install and Secure RabbitMQ

First follow the simple instructions on the RabbitMQ site. I recommend using their Apt repo if your using Ubuntu like me.

Next you will want to install the management console. To do that you just need to run the following command:

rabbitmq-plugins enable rabbitmq_management

Now the part where we divert from the simple install. We next will want to generate the some certificates. Personally I used the /opt/cert/rabbitmq/ directory that I created to store these in. To do that run the openssl command you see below:

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes

Now this is a self-signed cert which should be fine for most development. If you want to do something in production I recommend making your own internal CA so that you can load the CA into your browsers and not get the self-signed error all the time. As this should not be used by 3rd parties getting a 3rd party signed certificate seems a bit over board.

Next is to configure RabbitMQ to use these certificates.

[
    {rabbit, [
              {ssl_listeners, [5671]},
              {ssl_options, [{cacertfile, "/opt/certs/rabbitmq/key.pem"},
                             {certfile, "/opt/certs/rabbitmq/cert.pem"},
                             {keyfile, "/opt/certs/rabbitmq/key.pem"},
                             {verify, verify_peer},
                             {fail_if_no_peer_cert, fasle}]}
     ]},
     {rabbitmq_management, {
              {listener, [{port, 15672},
                          {ssl, true}]}
     ]}
].

Now you should just be able to run the following command to restart the server:

service rabbitmq-server restart

After the  server reboots you should be able to access it via AMQP over SSL via port 5671 and get to the management console via https on port 15672.

Next we should lock down the management interface. First login using the guest account (guest/guest). Once you are logged in click on the Admin tab.

selectAdmin

Then click on the “Add a user” section. At this point fill in the username you want, add a password, and select the admin tag.

addUser

You should now see the user in the list. This user though will still have no access off the bat. Click on the user name to get more information about the user and to edit it.

newUser 

Once you’re in the user’s information go to the “Set permission” section and you can just set the default. This will give the user full access to the default virtual host.

setPermission

At this point you can click on the guest user and delete it. At this point got a server setup to use SSL for connections and without the default user. You are set with a decently secure setup. Have fun developing with RabbitMQ.