Month: March 2015

| 2 Comments

This weekend while rummaging through my old stuff which I saved all these years, I happened to come across a yellowing vanilla envelope in which I found this picture from the distant past. See if you recognize anyone in it.

shs-golf-team-1974.jpg
Salinas High Golf Team 1974.

Those were the days my friend, and back then I had a blast playing the wonderful sport of golf with my friends. We were a pretty strong team and played well against the other posh high schools who thought they were so great.

In Elixir, the pipe operator '|>' takes the output of the expression on the left of it, and feeds it in as the first argument to the function on the right of it.

You can even tag on additional functions together in an endless chain to form a pipeline of functions to be called, very similar to the Unix method of piping command utilities together, e.g. 'ps ax|grep vim|awk '{ print $1 }'.

In other words, the following statement using the pipe operator |> :

f( a ) |> g( b ) |> h( c )

is equivalent to:

h( g( f( a ), b ), c )

This can be extended to include functions with multiple parameters like this:

f( a, b ) |> g( c, d )

being equivalent to:

g( f( a, b ), c, d )

See if you can figure out what the following does:

-5 |> abs |> Integer.to_string |> IO.puts

Here's a small hint to help you along:

IO.puts(Integer.to_string(abs(-5)))

Here are some references in which you might be interested:

No I didn't forget. The answer is 5 of course.

| 4 Comments

geminiIII-grissom-and-white.png

Wow, has it already been fifty years ago since the launch of Gemini III? Those were the very first steps on our way to landing on the moon. For me it seems like it was just yesterday.

Poor Gus Grissom died later in the awful Apollo fire (God bless his soul), but John Young ended up living a very successful life as an astronaut undertaking many more missions (he's now 84 believe or not).

Gemini IV impressed me so much that I drew a picture of the Gemini capsule floating in space above the Earth and sent it to astronauts Ed White and Jim McDivitt. Below the letter they sent back to me:

letter-gt4-mcdivitt-and-white.png

Some interesting links:

One should not take the precise definition of 'undefined' too non-nonchalantly as it forms an important basis for understanding the JavaScript fundamentals. I'd be curious to know how many so-called expert JavaScript developers really understand what it is. In my many years of learning the ins and outs of the JavaScript programming language, this is perhaps the best explanation of 'undefined' that I've ever heard.

"When I declare 'var a', 'a' is placed into memory during the creation phase. So the execution context saw 'var a' and setup 'a' in memory. And so even though I haven't set it to a value, the JavaScript engine, which is doing more than what I'm just writing in my code, already set it to the special value called 'undefined'. So 'undefined' is not like empty, or doesn't exist, it doesn't literally not exist. It's actually a value, it's actually taking up memory space. It's a special keyword, a special value that means this is the value that was initially set by JavaScript. And that leads to a little bit of a warning... Never set yourself a variable equal to 'undefined'. Because actually you can... That's perfectly valid JavaScript, but it's a little dangerous. It's better to let 'undefined', that special keyword, mean I, the programmer, never set the value..."

undefined-javascript.png

"... That will really help you when debugging code. If you make a habit of setting values equal to 'undefined', then it's really hard to tell if something is 'undefined' because you set it or because the JavaScript engine set it and you never set it to anything else. It's always better to let 'undefined' mean I never set this value. That's really useful, and it will help you in your debugging. So 'undefined', this is a special value, that is also a special keyword in JavaScript, and it's the value that variables receive during the creation phase, the first phase of creating an execution context, sets up the memory of the variable, and in that memory space puts the value called 'undefined'. I would have called it something else personally like 'not set' but that's what JavaScript calls it, 'undefined'. And if you don't in your code set it to anything else, that is what it will be. Or if you set it to something else later, and use it beforehand that is what it will be. Alright, so that's JavaScript and 'undefined'."

JavaScript: Understanding the Weird Parts, Lecture 11: Conceptual Aside: JavaScript and 'undefined'

Dit heb ik gekocht bij http://bol.com : Uni Inbouw Stopcontact - 3-voudig - Rond - Crème - http://go.bol.com/tb/9200000010588167 ...

inbouw-stopcontact.jpg

Life is full of fun and interesting surprises which make it all worthwhile.

| 2 Comments

lucky-golf-tees.png

I cherish these golden tees and save them for very special moments. For example, an important golf tournament or a difficult and important tee shot on a par three.

When working with ember-cli and things seem to get messed up and you cannot figure out for the life of you what's wrong you can always resort to nuking it all and refreshing the environment.

This often helps me alot, and although I do not know for sure the exact details behind the reason it fixes things, I don't care as long as it works.

In my ~/.bash_aliases I've added the following aliases, a "regular" fix nom and a "nuke-it-all-and start-over-again" fix nomallas follows:

alias nom='rm -rf node_modules && npm cache clear && npm install'
alias nomall='rm -rf node_modules && npm cache clear && npm install && rm -rf bower_modules && bower cache clean && bower install'
...
alias realias='$EDITOR ~/.bash_aliases; source ~/.bash_aliases'

Just run realias to make the required changes and you're all set.

The Erlang notation [ F(X) || X <- L] means "the list of F(X) where X is taken from the list L."

1> L = [1,2,3,4,5].
[1,2,3,4,5]
2> [2*X || X <- L ].
[2,4,6,8,10]

Thus, [2*X || X <- L ] means "the list of 2*X where X is taken from the list L."

There's tons of other really really cool stuff you can do. Like qsort(L) for quick sorting lists:

qsort([]) -> [];
qsort([Pivot|T]) ->
	qsort([X || X <- T, X < Pivot])
	++ [Pivot] ++
	qsort([X || X <- T, X >= Pivot]).

Or perms(S) for generating all possible permutations of a string:

perms([]) -> [[]];
perms(L)  -> [[H|T] || H <- L, T <- perms(L--[H])].

Or pythag(N) for generating all Pythagorean triplets (sets of integers {A,B,C} where A2 + B2 = C2):

pythag(N) ->
    [ {A,B,C} ||
        A <- lists:seq(1,N),
        B <- lists:seq(1,N),
        C <- lists:seq(1,N),
        A+B+C =< N,
        A*A+B*B =:= C*C 
    ].

Ad infinitum into the wee hours of the morning...

Random entries

Here are some random entries that you might be interested in:

Recent Assets

  • shs-golf-team-1974.jpg
  • letter-gt4-mcdivitt-and-white.png
  • geminiIII-grissom-and-white.png
  • undefined-javascript.png
  • my-desk.png
  • inbouw-stopcontact.jpg
  • lucky-golf-tees.png

Recent Comments

  • Long time no see: I remember them, as well. I remember Donald was my ...
    - Charles
  • Bridge to the moon: Yes it was a drawing and my older brother told me ...
    - jpmcfarlane
  • Bridge to the moon: Wow, that's quite a coincidence that we both sent ...
    - Kiffin
  • Bridge to the moon: Hello I was in my teens when Gemini 4 went up that ...
    - jpmcfarlane
  • Back to work: Congratulations Kiffin, I hope it is something you ...
    - KathleenC

Golf Handicap

Information

This personal weblog was started way back on July 21, 2001 which means that it is 7-21-2001 old.

So far this blog contains no less than 2498 entries and as many as 1877 comments.

Important events

Graduated from Stanford 6-5-1979 ago.

Kiffin Rockwell was shot down and killed 9-23-1916 ago.

Believe it or not but I am 10-11-1957 young.

First met Thea in Balestrand, Norway 6-14-1980 ago.

Began well-balanced and healthy life style 1-8-2013 ago.

My father passed away 10-20-2000 ago.

My mother passed away 3-27-2018 ago.

Started Gishtech 04-25-2016 ago.