Incorrect characters in the list of audio devices in Java

Every­one knows, that audio devices are list­ed in Java with AudioSystem.getMixerInfo(). Mac users know, that the only sound device they have for Mac­in­tosh is Built-in Input, Built-In out­put and Java Sound Audio Engine, ver­sion 1.0. And only the ones who use non-latin sym­bols in OS, know about the prob­lem with this func­tion: Cyril­lic let­ters looks like a habra­cadabra with it. I’m not sure about Japan­ese ones, has to be checked still..
Like this:
It hap­pens because get­Mix­erIn­fo() returns device data in Win­dows-1252 charset, but tries to out­put it in Win­dows-1251. We have to help it some­how
It might be cool to write a wrap­per for javax.sound.sampled.Mixer.Info, but toString() and get­Name() meth­ods in this class are final. Let’s use helper func­tions:
public class Shared {
 private static String OS = null;
 public static String getOsName()
  if(OS == null)
   OS = System.getProperty("");
     return OS;
 public static boolean isWindows()
    return getOsName().startsWith("Windows");
 public static String toLocalString(Object info)
   return info.toString();
  String defaultEncoding = Charset.defaultCharset().toString();
   return new String(info.toString().getBytes("windows-1252"), defaultEncoding);
  catch(UnsupportedEncodingException ex)
   return info.toString();
Then we use Shared.toLocalString(item.getName()) for every such an instance. All of the titles are ok now:


Free and open-source software licenses

There’re plen­ty of free and open-source soft­ware licens­es and not all of them are as sim­ple as Do What the Fuck You Want to Pub­lic License. And even if you col­lect­ed all 4 free­doms and 650 poke­mons, it isn’t enough.

The main thing a devel­op­er has to know about free and open-source licens­es – some of them let the code be linked from code in anoth­er lan­guage, and some of them don’t.

For exam­ple, if you use some­thing licensed as GNU GPLyour project has to be under GNU GPL too. In oth­er hand, if you use BSD license, you can sell it to Apple to make OS X from it.

Please, check the license before using some­thing from GitHub or Google Code.

Google Code allows only OSI-Approved licens­es. You have to remem­ber this table to be safe using projects from it:

License Link with code using a dif­fer­ent license Release changes under anoth­er license
Apache License + +
Artis­tic License + !
Eclipse Pub­lic + -
GNU GPL 3 - -
GNU GPL 2 - -
GNU Less­er + -
Mozil­la Pub­lic + !
New BSD + +
Microsoft Pub­lic License* + -

+ – allowed
— – not allowed
! – lim­it­ed
* Microsoft Pub­lic License isn’t includ­ed in offi­cial list on Google Code, but is approved by OSI too and is very pop­u­lar on Code­plex.


Git: How to rename a GitHub repo

GitHub allows to rename your repos. I real­ly like this solu­tion.

Install curl if you haven’t and use ter­mi­nal (or cyg­win under win­dows):

newName='{"name": "NewNameForRepo"}'
curl -u "$user:$pass" -X PATCH -d "$newName"$user/$oldName

QT: error: cannot find -lQtMultimedia

The QtMul­ti­me­dia library is not avail­able in Ubun­tu. If you’re try­ing to cre­ate in Qt a project that uses it, it will fail with fol­low­ing error:

error: can­not find -lQt­Mul­ti­me­dia

To fix it, you have to install qtmo­bil­i­ty and use mul­ti­me­dia items from this lib. Install qtmo­bil­i­ty-dev and lib­de­clar­a­tive-mul­ti­me­dia. Then remove QT += mul­ti­me­dia from .pro file and add INCLUDEPATH to QtMo­bil­i­ty and QtMul­ti­me­di­aK­it direc­to­ries.