Bit flags, commonly referred to as Bit fields are an efficient way of storing several related boolean values in a single primitive type.
Internally represented in binary, you can decide on how large the storage type needs to be - for example, a Java integer will provide you with space for 31 flags.
Being a 32 bit type you would assume to have access to this many flags, however, due to it being a signed value the most significant bit is reserved to store its +/- sign.
I recently wanted to create a simple function in JavaScript which allowed me to generate a random background colour for a small experiment I was working on.
The implementation I came up with worked very well, but the decimal-hexadecimal representation conversion was all wrapped up in one ‘toString(16)’ function call.
I was very interested in how I could go about creating this method myself and decided on the Java language for the attempt.
The discussed functionality is already present in the Java language to, within the ‘java.lang.Integer’ class as ‘toHexString’.
Continuing on with my exploration of the Scala language I decided to solve the widely documented problem of evaluating a mathematical Reverse Polish notation string.
Popularised by its use in the HP-10C series of calculators from the 1980’s, the notation requires that every operator follow its operands (otherwise called postfix notation).
Git has two different types of timestamp associated with a commit.
Although both may typically hold the same value they are used in subtly different ways.
The author (GIT_AUTHOR_DATE) is the user who originally created the work (i.e. a patch), where as the committer (GIT_COMMITTER_DATE) is the user who last applied the work (i.e. applied patch or rebase).
The author date is the one displayed when the log is accessed, however, the commit date is used when given the filter (–since, –until) options, which seems a little odd.
To avoid confusion you can include the committer date within your log display by setting the –format option.
Having to use password authentication each time you wish to access your server can be a serious pain.
Not only does it require extra keystrokes, it is also less secure and far more susceptible to successful brute-force attacks.
Enter public-key authentication, were instead you use asymmetric cryptography.
The first thing to do is generate a key-pair on your client machine, you can optional provide a passphrase to unlock the private key if you so wish.