Today I Learned (TIL). I try to write down what I have learned every day. They’re usually short technical notes which I find useful or interesting to me. These are some of the TIL entries which are worth sharing :

  • TIL 27.03.2017 Various
    • TIL 14.03.2017 What is the difference between `du` and `df` command?

      df

      • stands for Disk Free
      • calculates file size based on the file system meta information
      • if block size is 8kb and file size is only 1kb then file size for du is 8kb
      • is faster but not accurate


      du

      • Disk Usage
      • counts size used on the file system per file recursively (df and du giving different results)
      • does not count open files
      • does not rely on block size: 1kb file size with 8kb block size is still 1kb for du
      • is slow, but more reliable

      See this post from Mike Golvach for thorough explanation: Why DU And DF Display Different Values On Linux And Unix

      • TIL 13.03.2017 Java Enum and extract in SQL

        Java class with enum switch statement is translated to switch statement with ordinal:

        public enum  MyEnum {
            YES,
            NO;
        
            public static void main(String[] args) {
                MyEnum e = NO;
                switch (e) { // uses e.ordinal()
                    case YES:
                        System.out.println("Yes");
                        break;
                    case NO:
                        System.out.println("No");
                        break;
                }
            }
        }
        

        You can use extract() in oracle in order to get the date parts

        select
            extract(year from created_timestamp),
            extract(month from created_timestamp),
            extract(day from created_timestamp)
        from student;
        

        Source: EXTRACT

        • TIL 07.03.2017 What is the difference between 127.0.0.1 and 0.0.0.0?

          • binding 127.0.0.1 means listen to loopback interface
          • Process bound to 127.0.0.1 can only be accessed by other programs from the same machine

          • binding to 0.0.0.0 means listen to all interfaces ( e.g. all network interfaces connected to the machine )

          • on Mac 27.0.0.1 /32 is bound to loopback

          • on Windows 127.0.0.0 /8 is bound to loopback

          Source: 0.0.0.0 vs 127.0.0.1

          • TIL 05.03.2017 What is the max length of an SMS?

            • max SMS length is 1120 bit
            • 7 bit per character used for the default alphabet, which means the maximum length is 160 characters ( 1120 / 7 )
            • 8 bit is used for data-messages ( e.g. images or sound messages )
            • 16 bit for the rest of the characters using Unicode encoding, meaning max 70 characters (Websms)
            • Note: German Umlaut ( ö, ü, ä ) uses 16bit per characters
            • Note: If one character needs to be encoded with 16bit then the whole message is encoded with 16bit