Tuesday, October 28, 2014

Endianness mnemotechnic


A long time ago I had a difficult time trying to remember the differences between Big Endian and Little Endian. I came out with this little trick to make it easier to remember: associate Low with 0.

In Big Endian, you store the most significant byte in the smallest address. In Little Endian, you store the least significant byte in the smallest address.

http://en.wikipedia.org/wiki/Endianness


Monday, October 27, 2014

Guava Files class

Sometimes you are still in the Java 1.6 land and you just to want to read the entire file into a list. Guava can help you:
File file = new File("trades_3.txt");
List<String> lines = Files.readLines(file, Charset.defaultCharset());
The Files class doc.

Saturday, October 11, 2014

Foundation and Empire


  1. Part I: The General
    1. Search for Magicians
    2. The Magicians
    3. The Dead Hand
    4. The Emperor
    5. The War Begins
    6. The Favorite
    7. Bribery
    8. To Trantor
    9. On Trantor
    10. The War Ends
  2. Part II The Mule
    1. Bride and Groom
    2. Captain and Mayor
    3. Lieutenant and Clown
    4. The Mutant
    5. The Psychologist
    6. Conference
    7. The Visi-Sonor
    8. Fall of the Foundation
    9. Start of the Search
    10. Conspirator
    11. Interlude in Space
    12. Death on Neotrantor
    13. The Ruins of Trantor
    14. Convert
    15. Death of a Psychologist
    16. End of the Search

Friday, October 3, 2014

IPTABLES

# List the rules with line numbers,
# the -n disables the DNS reverse lookup
iptables -n --list --line-numbers

# Block a specific IP
iptables -A INPUT -s 192.168.0.1 -j DROP

# Allow SSH for a specific IP
iptables -A INPUT -s 192.168.0.2 -p tcp -m tcp --dport 22 -j ACCEPT

# Delete a rule based on its number
iptables -D INPUT 8

# Insert rule before other certain one
# For example before line # 3
iptables -I INPUT 3 -s 192.168.0.2 -p tcp -m tcp --dport 22 -j ACCEPT