Dec 122014
 

So yesterday was a memorable day.

We gathered the Bulgarian Java User Group and, as a hands-on-lab, in 3 hours we created a pretty complex patch on a open issue in the JDK Bug System. We plan to submit a webrev patch after we polish the code and supply better tests.

We've been playing with the OpenJDK code for quite some time. We have setup an easily distributable virtual machine (actually two virtual machines - fedora and ubuntu) that can be found here:
ftp://bgjug.sty-consulting.com
They have everything in there with clear instructions on how to build the code and start IntelliJ IDEA as the IDE.

The issue is this one:
https://bugs.openjdk.java.net/browse/JDK-5050783
That has been a request for quite some time. Apache Commons Lang even has an utility method.

Here are the slides of the hackaton:
http://www.slideshare.net/IvanIvanov138/first-adoption-hackathon
And here are the instructions:
ftp://bgjug.sty-consulting.com/OpenJDK-hol.pdf

We even had some beer:
IMG_20141211_203819

The patch included a pretty heated discussion on whether we should use the Apache's Commons Lang approach:

public static String getStackTrace(Throwable throwable) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw, true);
    throwable.printStackTrace(pw);
    return sw.getBuffer().toString();
}

or we should rewrite some private classes inside java.lang.Throwable.

Here's the updated Throwable code:
First we added a method:

/**
 * Returns string representation of this throwable and it's backtrace.
 *
 * @return string representation of this {@code Throwable} and it's backtrace
 */
public String getStackTraceString() {
    final StringBuilder sb = new StringBuilder();
    printStackTrace(new WrappedStringBuilder(sb));
 
    return sb.toString();
}

We renamed the ill-named PrintStreamOrWriter to StackTraceFacade and added another implementation:

private static class WrappedStringBuilder extends  StackTraceFacade {
    private static final String NEW_LINE = System.getProperty("line.separator");
    private final StringBuilder builder;
 
    WrappedStringBuilder(StringBuilder builder) {
        this.builder = builder;
    }
 
    @Override
    Object lock() {
        return builder;
    }
 
    @Override
    void println(Object o) {
        builder.append(o).append(NEW_LINE);
    }
}

We decided to reimplement and change the private inner class, because the Commons Lang uses StringWriter that internally uses the StringBuffer which is synchronized and we don't want that, since we sync on an upper level.
Here's a small JTREG test we created:

import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import java.lang.Throwable;
/*
 * @test
 * @bug 5050783
 * @summary Basic test of serialization of stack trace information
 * @author Bulgarian JUG
 * @run testng java.lang.Throwable.GetStackTraceString
 */
public class GetStackTraceString {
    @Test
    public void doTest() {
        try{
            double a =100/0;
        }catch (Throwable t){
            assertTrue(t.getStackTraceString().length()>0);
        }
    }
}
pixelstats trackingpixel
Dec 092014
 

Download from here: https://my.vmware.com/web/vmware/details?productId=352&downloadGroup=OVFTOOL350

(requires account, they do not check the email)

then

#./ovftool ~/Desktop/MyVirtualMachine.vmwarevm/MyVirtualMachine.vmx ~/Desktop/MyVirtualMachine.ova

pixelstats trackingpixel
Dec 072014
 

Problem1: My printer's scanner does not work over the wire with OSX. So the scanner part works by cable only. Well what if I put the usb cable over the wi-fi? Well, now I have a wireless scanner.

Problem2: I have a remote backup drive that I want to keep bootable and encrypted. Was it possible before this? I couldn't make it work. Is it possible now? I think so.

VirtualHere is a commercial software. For free it allows one simultaneous device, if you disconnect the first, you can use the second. It works flawlessly.

Its server has builds for most linuxes plus OpenWrt. The client is very simple, builds for osx, win, linux.

There are FOSS alternatives. If anyone has tried them, please share some info.

pixelstats trackingpixel
Nov 252014
 

Open the config file for the app

Last login: Tue Nov 25 21:29:02 on ttys001
ff:~ steve$ sudo nano /Applications/iTerm.app/Contents/Info.plist

Add the selected text:
Screen Shot 2014-11-25 at 9.29.59 PM

Text to add:

        <!-- mihail.stoynov: the following is to hide the iTerm.app from the finder -->
        <key>NSUIElement</key>
        <string>1</string>

Then

Last login: Tue Nov 25 21:29:02 on ttys001
ff:~ steve$ killall iTerm
pixelstats trackingpixel
Nov 222014
 

1 Install tranmission

opkg update
opkg install transmission-cli transmission-daemon transmission-web

2 configuration

don't use /etc/config/transmission - it is not read by the service starter. Actually, don't use /etc/init.d/transmission start - it doesn't work for some reason - I'm too lazy to use it.

What I did is:

transmission-daemon -d >> settings.json

which doesn't work also for some reason, so copy the config info and save to settings.json or edit /root/.config/transmission-daemon/settings.json directly

3. changes to settings.json

"download-dir": "/home/ftp_user/storage/",
"rpc-authentication-required": true,
"rpc-enabled": true,
"rpc-password": "pass",
"rpc-url": "/transmission/",
"rpc-username": "user",
"rpc-whitelist-enabled": false,

4 start

if you saved a local copy of settings.json

transmission-daemon -g .

if you changed /root/.config/transmissio-daemon/settings.json

transmission-daemon
pixelstats trackingpixel
Nov 222014
 

1. Find the plugged in USB device

lsusb

to see plugged in devices.

2 Partitions

install and use cfdisk to partion the USB.

3. GPT

gdisk not implemented on OpenWRT, so if the disk is GPT, then create an empty partition and it can be formatted with mkfs.ext4.

Then to recognize which partition is which (recognize them by size), use

cat /proc/partitions

 4. ext4

Install e2fsprogs, so that you can use mkfs.ext4.

mkfs.ext4 /dev/sdb5

5. fstab

Edit /etc/config/fstab
Add:

config 'mount'
	option	target	'/mnt/sda1'
	option	device	'/home/ftp_user/8GB'
	option	enabled	'0'
config 'mount'
	option  target  '/home/ftp_user/storage'
	option  device  '/dev/sdb5'
	option  enable  '0'
pixelstats trackingpixel