Wednesday, February 11, 2015

Netty server is incompatible with ObjectOutputStream on the client side

Recently I faced with the following problem while playing with Netty:

1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
io.netty.handler.codec.TooLongFrameException: Adjusted frame length exceeds 1048576: 2901213193 - discarded
at io.netty.handler.codec.LengthFieldBasedFrameDecoder.fail(LengthFieldBasedFrameDecoder.java:493)
at io.netty.handler.codec.LengthFieldBasedFrameDecoder.failIfNecessary(LengthFieldBasedFrameDecoder.java:469)
at io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:404)
at io.netty.handler.codec.serialization.ObjectDecoder.decode(ObjectDecoder.java:68)
at io.netty.handler.codec.LengthFieldBasedFrameDecoder.decode(LengthFieldBasedFrameDecoder.java:351)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:231)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:131)
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:372)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:780)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:99)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:497)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:465)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:359)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Thread.java:745)

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");
        }
    }
}

Tuesday, February 3, 2015

Useful installations for Fedora to keep in mind

Creating a bootable USB

$ sudo dd if=/path/to/Fedora-Live-xxx.iso of=/dev/sdc

where sdc can be found by inserting the usb drive and executing:

$ dmesg | tail

yum plugin which helps to choose the fastest mirrors

$ sudo yum install yum-plugin-fastestmirror

RPM fusion reposetories

# su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm'

Codecs

$ sudo yum install gstreamer1-libav gstreamer1-plugins-bad-free-extras gstreamer1-plugins-bad-freeworld gstreamer1-plugins-good-extras gstreamer1-plugins-ugly gstreamer-ffmpeg xine-lib-extras xine-lib-extras-freeworld k3b-extras-freeworld gstreamer-plugins-bad gstreamer-plugins-bad-free-extras gstreamer-plugins-bad-nonfree gstreamer-plugins-ugly gstreamer-ffmpeg

E-book management tool

$ sudo yum install calibre

UI package manager

$ sudo yum install yumex

Nvidia Optimus (Bumblebee installation)

Visit: http://fedoraproject.org/wiki/Bumblebee

Move applications in tray to the top bar

Install TopIcons Gnome Extension