Preskočiť na hlavný obsah

Príspevky

Zobrazujú sa príspevky z dátumu január, 2011

Chuck Norris jokes on Java

Chuck Norris is the super class of all classes in Java (including Object class). Chuck Norris can override a final function. Chuck Norris can make a class abstract and final both at same time. Chuck Norris never “try” any code, he directly “catch” the exceptions. Chuck Norris can divide by zero in Java. Chuck Norris can use pointers in JAVA.

When and where to use CharSequence?

CharSequence is cool interface to cover all character/string (buffer/bulder) operation, especially for cases where you want to use String parameters in the methods that are working with texts. Known Java implementing classes are CharBuffer, Segment, String, StringBuffer, StringBuilder. So whenever you are planning some new API, use the CharSequense.

How to convert aray to list and list back to array?

Working with collections, sometimes you need to get an actual array that contains the list. Sometimes in Java array should be converted to List. Check it out how to... This example code converts an array to a list: List listOfStrings = Arrays.asList(arrayOfStrings); On the fly list construction: List listOfStrings = Arrays.asList(new String[]{s1, s2}); And how to convert a list into an array: String[] arrayOfStrings = listOfStrings.toArray(new String[]{}); or String[] arrayOfStrings = listOfStrings.toArray(new String[0]);

How do disable root ssh login?

One of the biggest security holes is to allow direct logging in as root through ssh. To disable it: in /etc/ssh/sshd_config edit "PermitRootLogin no" and then `/etc/init.d/sshd restart` But remember to add some user to the "wheel" group to be able 'su'

How to use Enum in switch statements

If you wana use enums in a switch, don't google, I did... Enum switch case label must be the unqualified name of an enumeration constant. So let's understand this with a simple example: enum EnumType { INT,DATE, FLOAT} EnumType someVar; ... switch (someVar) { case (EnumType.INT): handle(EnumType.INT); ... } This looks fine, so? Unfortunately, it is wrong in two different ways. The case exp should be without the brackets and only INT should be used without the EnumType type def. Let's illustrate within a simple correction: switch (someVar) { case INT: handle(EnumType.INT); ... } Summarization: * In case statement the enum must be used without brackets. * In case only the unqualified enum name must be used.

Viete, čo je Portage?

Portage je základom distribúcie aktualizácií Gentoo Linux. Portage je vlastne utilita s mnoho funkciami pre zabezpečenie update vašej distribúcie Gentoo. Pre aktualizáciu zoznamu balíčkov stačí jednoducho použiť príkaz emerge --sync , tento príkaz povie systému portage, aby aktualizoval svoju lokálnu kópiu stromu (portage tree), samozrejme cez internet. Lokálny portage strom obsahuje kompletnú kolekciu scriptov, pomocou ktorých portage kompiluje a inštaluje najnovšie Gentoo programové baličky. Portage je zároveň silný nástroj pre úpravu, prispôsobovanie a inštaláciu systému. V súčasnosti je k dispozícii viac ako desaťtisic balíčkov a nové sú neustále pridávané. Ak chcete nainštalovať nejaký balíček, zadáte emerge name a portage automaticky skompiluje prispôsobenú verziu balíčka pre váš systém, zoptimalizuje ho pre Váš hardware a zabezpečí, aby program podporoval Vami požadované funkcie. Ttie, ktoré nechcete obsahovať nebude. Portage taktiež udržuje Váš systém v aktuáln...