adsense szeles

Thursday, January 22, 2015

Oracle? No.

No ILIKE, no boolean column datatype, no usable error messages. Instead of an 'incompatible types in the where condition' message I got something like the string buffer is too small. What kind of string buffer?
Why people still tend to buy Oracle? Because something is expensive, it must be good?

Wednesday, January 14, 2015

Super simple public read-only share with Samba 4

Beware when checking out tutorials for Samba. Samba 4 was released on 11th December 2012, and it's configuration schematics has major differences compared to Samba 3.

Let's see a very simple scenario: you want to share a public read-only folder for other devices on the local network (e.g. with CIFS/SMB protocol because of Windows hosts) using Linux/BSD or pretty anything that can run Samba. The configuration (smb.conf) is as follows:

[global]
   workgroup = WORKGROUP
   server string = Samba Server
   guest account = myuser
   log file = /var/log/samba/%m.log
   max log size = 50
   security = user
   map to guest = bad user

[media]
   path = /data
   guest ok = yes

Notes:

  • This is tested (and in daily use) with Arch Linux
  • Replace myuser with your username, workgroup and server string if you want to
  • This configuration allows any client to read the share without authentication of any kind
  • The path to be shared must be readable for the user running samba on the host system. For optimal result, add the directory open right to all directories recursively on /data and read right on files
  • The share will be accessible on Windows hosts without network discovery on: \\ip_address\media. With CIFS clients, just use the IP address and the sole shared directory will be listed
  • The directory name of the share will be 'media' which can be altered of couse

Sunday, October 19, 2014

Android "Lollipop" for Nexus 4 confirmed

I'm very happy because I don't have to return to the hacky, smelly, dirty homebrew ROM stuff. While Nexus 4 is at least two years old, I still feel that it's hardware is quite decent (easily overtakes the recent "cheap but strong as hell" MediaTek SoC's), and because the newest major Android release is on the way to my device, I think I can postpone the phone buying project for at least 1 year.
We will see how Lollipop performs. As a fact, I did not factory reset or whatever my phone since the end of 2013, and it's still very fast and responsive. Hope Lollipop also does this job.
(I'm using the full factory software stack by google, not even CWM is installed).
This is a clear evidence that Android phones doesn't need factory resets from time to time - it's not Windows 98 or something. One just have to avoid crappy phones (and Android phone companies often create crappy builds. Still don't understand why they slow down AOSP).

Tuesday, July 22, 2014

Friday, July 4, 2014

Java reflection: get value of nested fields

Scenario: we have a bean with singular and associated fields. Associated fields have nested fields, too. We have two instances of the bean, some original and a modified version. We created two annotations, @Audited and @NestedAudit. The first is used for singular fields, the others for associated fields. We want to write some log information of the updated fields in both level. The code is as follows.

for(Field f : class.getDeclaredFields()) {
   if(f.isAnnotationPresent(Audited.class)){
    try {
     f.setAccessible(true);
     Object a = f.get(original);
     Object b = f.get(updated);
     if(!Objects.equal(a, b)) {
      // log change audit
     }
    } catch (IllegalAccessException e) {
     throw new RuntimeException(e);
    }
   }

   if(f.isAnnotationPresent(NestedAudit.class)){
    for(Field g : f.getType().getDeclaredFields()) {
     if(g.isAnnotationPresent(Audited.class)){
      try {
       f.setAccessible(true);
       g.setAccessible(true);
       Object a = g.get(f.get(original));
       Object b = g.get(f.get(updated));

       if(!Objects.equal(a, b)) {
        // log nested change audit
       }
      } catch (IllegalAccessException e) {
       throw new RuntimeException(e);
      }
     }
    }
   }
  }

Monday, June 23, 2014

JPA/Hibernate single table inheritance

Here is a correct annotation configuration for the following scenario:
- abstract (mapped) super class (this means the super class is not an entity itself but inherited entites gets its fields)
- two or more subclasses

On the DB layer, we want a single table, so we use a discriminator column.

@Entity
@Inheritance
@DiscriminatorColumn(name="TYPE")
@Table(name="TABLE")
public abstract class AbstractEntity implements Serializable { ... }

@Entity
@DiscriminatorValue("TYPE1")
public class ConcreteEntity1 extends AbstractEntity { ... }

@Entity
@DiscriminatorValue("TYPE2")
public class ConcreteEntity2 extends AbstractEntity { ... }

Thursday, June 12, 2014

OpenJDK: Java SE reference implementation since Java SE 7

People.

The era of "nice but malfunctional/incomplete" OpenJDK and the "not so nice, but functional, usable and fast" Oracle JDK is end by the GA release of Java SE 7.
I know OpenJDK6 was not production ready (although I created production systems with that), but that's over.

If you need official verification, please read this announcement directly from Oracle: https://blogs.oracle.com/henrik/entry/moving_to_openjdk_as_the

OpenJDK 7 is the reference implementation. It actually is what you download from Oracle (plus some closed stuff like the installer itself, browser plugin and some other things not so important that I can't recall exactly, but please fix me in comments).
If you use Linux and need a JDK, just stick to the OpenJDK package. You don't need to add (wishfully) maintained PPAs, download binaries by hand and all the stuff. OpenJDK licensing conforms distribution with other software, so it is packaged (and security-maintained) just like all your other parts of the system.
I see a general confusion on this topic. Poor Oracle failed to spread this good news.

The same applies for Java SE 8 and all future releases.

Tuesday, June 10, 2014

LinkedIn

Everybody endorses me for PostgreSQL. Still, I don't know how they know.