Time: The most precious commodity

It does not take a movie, or reading a book to realize that our most precious asset or commodity is time…

I ran into this viral video about the topic of time scarcity:

I loved the metaphor in that movie. Here’s the full transcript:

Imagine there is a bank account that credits your account each morning with $86,400.
It carries over no balance from day to day.
Every evening the bank deletes whatever part of the balance you failed to used during the day.
What would you do?
Draw out every cent, of course?
Each of us has such a bank, its name is time.
Every morning, it credits you 86,400 seconds.
Every night it writes off at a lost, whatever of this you failed to invest to a good purpose.
It carries over no balance. It allows no over draft.
Each day it opens a new account for you. Each night it burns the remains of the day.
If you fail to use the day’s deposits, the loss is yours.
There is no drawing against ‘tomorrow.’
You must live in the present on today’s deposits. Invest it so as to get from it the utmost in health, happiness, and health.
The clock is running.

Make the most of today.

 

You might also like:

Did you like the Wonder Woman’s theme? Here’s why!

After Wonder Woman’s first appearance in Batman vs Superman movie, Wonder Woman theme was first revealed in the last battle against Doomsday. That theme was so awesome that I loved it immediately.

Little did I know that the theme is not very original, in fact it sounds similar to other songs and in particular the one from Led Zeppelin’s Immigrant song.

In all cases, this video explains all of this better than me:

 

Watch the theme performed by the fabulous and most talented Tina Guo here:

flower separator

flower separator

You might also like:

strtok() C++ wrapper

In this article, I share with you a simple C++ class that wraps the string tokenization function strtok(). The QuickTokenizer class makes it easy to tokenize and enumerate the tokens in a thread-safe manner.

The class code

//////////////////////////////////////////////////////////////////////////
class QuickTokenizer
{
private:
  char *buf;
  char *token;
  char *ctx;

  void FreeBuffers()
  {
    if (this->token != NULL)
    {
      free(this->token);
      this->token = NULL;
    }
    if (this->buf != NULL)
    {
      free(this->buf);
      this->buf = NULL;
    }
  }

public:
  QuickTokenizer() : buf(NULL), token(NULL)
  {

  }

  const char *Tokenize(
    const char *str,
    const char *tok)
  {

    this->buf = _strdup(str);
    this->token = _strdup(tok);

    return strtok_s(buf, token, &ctx);
  }

  const char *NextToken()
  {
    return strtok_s(NULL, token, &ctx);
  }

  ~QuickTokenizer()
  {
    FreeBuffers();
  }
};

Continue reading “strtok() C++ wrapper”

Detect executable format using Python

In this article, I am sharing with you a small Python script that lets you detect if a file is an executable file and what platform the executable is targeting.

The following formats for 32 bits and 64bits processors are supported:

  • Mach-O files: both regular and universal formats
  • Windows PE files
  • Linux ELF files

The script

#---------------------------------------------------------------------
EXEFLAG_NONE        = 0x0000
EXEFLAG_LINUX       = 0x0001
EXEFLAG_WINDOWS     = 0x0002
EXEFLAG_MACOS       = 0x0004
EXEFLAG_MACOS_FAT   = 0x0008
EXEFLAG_32BITS      = 0x0010
EXEFLAG_64BITS      = 0x0020

# Keep signatures sorted by size
_EXE_SIGNATURES = (
    ("\x4D\x5A", EXEFLAG_WINDOWS),
    ("\xCE\xFA\xED\xFE", EXEFLAG_MACOS | EXEFLAG_32BITS),
    ("\xCF\xFA\xED\xFE", EXEFLAG_MACOS | EXEFLAG_64BITS),
    ("\xBE\xBA\xFE\xCA", EXEFLAG_MACOS | EXEFLAG_32BITS | EXEFLAG_MACOS_FAT),
    ("\xBF\xBA\xFE\xCA", EXEFLAG_MACOS | EXEFLAG_64BITS | EXEFLAG_MACOS_FAT),
    ("\x7F\x45\x4C\x46\x01", EXEFLAG_LINUX | EXEFLAG_32BITS),
    ("\x7F\x45\x4C\x46\x02", EXEFLAG_LINUX | EXEFLAG_64BITS)
)

def get_exeflags(filepath):
    try:
        with open(filepath, "rb") as f:
            buf = ""
            buf_len = 0
            for sig, flags in _EXE_SIGNATURES:
                sig_len = len(sig)
                if buf_len < sig_len:
                    buf += f.read(sig_len - buf_len)
                    buf_len = sig_len

                if buf == sig:
                    return flags
    except:
        pass

    return EXEFLAG_NONE

Continue reading “Detect executable format using Python”

Gun with a tracking device from the “Dreamcatcher” movie

I watched the Dreamcatcher movie a while back. It is a nice movie involving young boys, now adults, who have been gifted psychic abilities by an alien. That alien, in the hiding, looks like a human being and waits for the right moment to defend the Earth from other hostile aliens.

In the movie we see a gun with a tracking device in it, I like the concept (not that this is something new). You would never suspect that your gun is traceable:

Speaking of dreamcatchers, I found this nice dreamcatcher on Amazon, check it out:

Dreamcatcher

You might also like: