Showing posts with label Blogger. Show all posts
Showing posts with label Blogger. Show all posts

Wednesday, July 26, 2023

Starting a new adventure...

I started this blog back in 2011 as a sandbox for my occasional HOWTOs. I have grown since then as a person and an engineer. I decided it is time to move from this platform and start a new adventure.

rdiachenko.com is a new place where I'm going to post and keep new writings.

I'll keep the current blog as it is. There is still value in few posts. However, nothing will be published here anymore.

Wednesday, February 11, 2015

How to insert code blocks in Blogger posts

I didn’t find any setting which would allow me to insert code blocks in Blogger posts but I managed to overcome this problem.

Here’re two simple and handy online converters of code to html:

markup
pros: language auto-detection, small html in the output
cons: no line numbers support, no horizontal scrolling
styles I liked: Slush & Poppies, iPlastic

hilite.me
pros: line numbers support, horizontal scrolling in case of long lines
cons: big html in the output
styles I liked: friendly, default, colorful
CSS I used: border:none;

Let’s say we have the following piece of code which is desirable to insert as a code block:

public class RowSocketClient {

    public static void main(String[] args) throws Exception {
        String host = "localhost";
        int port = 4446;

        try (Socket socket = new Socket(host, port);
                ObjectOutputStream out
                    = new ObjectOutputStream(socket.getOutputStream())) {
            out.writeObject("ping");
        }
    }
}