Sunday, May 24, 2015

On C Programming: Some Pitfalls

I have programmed in C for almost 20 years, and over the years, I have my fair share of lessons learned. Here are some of the pitfalls that are very common. Learn these and you don't have to spend hours or even days to debug

  • = and == confusions
 The '=' operator is for assignment, while '==' is for comparison. Mix these up and you will have a major headache as the variable has been changed (or not)
  •  The 'if' block
Consider the following, assume x, y, and z are defined somewhere else:
if (x == 3)
  y = 43;
  z = 0;

{do something more}

Guess what? if x is equal to 3, only the statement 'y = 43;' will be executed, while 'z = 0' will be executed no matter what, which isn't the initial intention.

There are a list of programming pitfalls here

Studying Notes on Elixir

Elixir is a Erlang VM (BEAM) based language (http://elixir-lang.org/). This post serves as a note and thoughts while exploring this language.

On Installation

  1. It is much easier to install Erlang and Elixir via Homebrew, if you are using Mac, you definitely should consider this route
brew install elixir
brew install erlang

On Syntax

  1. true and :true are the same, same goes to false and :false. These have data type of booleans
  2. Constants, or symbols are called atoms. For example :hello is an atom.
  3.  The atom version of booleans (i.e. :true and :false) are special cases, and will be treated as booleans.  As can be shown below by the interactive output of Elixir. Note :hello is an atom, but not a boolean
  4. iex(7)> is_boolean :true
    true
    iex(8)> is_boolean :false
    true
    iex(9)> is_atom :true
    true
    iex(10)> is_atom :false
    true

    iex(11)> is_boolean :hello
    false
    iex(12)> is_atom :hello 

Saturday, May 23, 2015

Some Beers That Consistently Make Me Feel Bad The Next Day



I did this through trial-and-error over the years, so far there are certain brands of beer that consistently cause me to feel bad/weak/shitty the next day, while some don't.

Here are the lists

Beers that cause me to feel sick (in no particular order)
  • Tiger beer
  • Carlsberg
  • Heineken

Beers that are OK after drinking (in no particular order)
  • Guinness Stout (foreign export and draft)
  • Bavaria

Disclaimer: This comes from my own personal experience, and I really don't know why these three international brands will have such effect on me.