Life happens

I haven't written a post in over two years but to be fair, life happens. So cliche I know... So what's happened?

I started a new job

I started working at Buddy Media in 2011 which has since been acquired by Salesforce on August of 2013. It's been really exciting and challenging learning about new technologies and how to scale application and infrastructure. I really feel it's important to challenge yourself everyday. That's how we grow as individuals and improve our skill-sets. So do yourself a favor, try not to remain stagnant in anything you do. If you aren't being challenged, it's time for something to change.

I bought a house

Home ownership is very exciting. It's probably one of the biggest investments you can make in life. My only regret is not doing it sooner. My daughters are in better schools, we have a better life, we are building equity and we aren't contributing to paying off someone else's mortgage. Often, we are reluctant to make such a big commitment. After-all, it is 30 years. There's also fear of not being able to afford all of the expenses that come with home ownership.

In my case, this was so far from the truth. I realized that I was spending money on foolish things and could cut-back on some expenses. When my wife and I decided to buy instead of renting, we took some time to go over our finances and see what our expenditures were to determine what we could afford (this is important to do at least once a year). We realized things that we could sacrifice for the sake of home ownership. We did it, and couldn't be happier!

I unplugged

I went off the grid for several months. I didn't use any social networks and stayed off-line. Spending quality time with those that are important to you is necessary.

One Of The Best Arguments Ever!

An atheist professor of philosophy speaks to his class on the problem science has with God, The Almighty. He asks one of his new students to stand and…..

Prof: So you believe in God?

Student: Absolutely, sir.

Prof: Is God good?

Student: Sure.

Prof: Is God all-powerful?

Student: Yes…

Prof: My brother died of cancer even though he prayed to God to heal him. Most of us would attempt to help others who are ill. But God didn’t. How is this God good then? Hmm?
(Student is silent.)

Prof: You can’t answer, can you? Let’s start again, young fella. Is God good?

Student: Yes.

Prof: Is Satan good?

Student: No.

Prof: Where does Satan come from?

Student: From…. God…

Prof: That’s right. Tell me son, is there evil in this world?

Student: Yes.

Prof: Evil is everywhere, isn’t it? And God did make everything. Correct?

Student: Yes.

Prof: So who created evil?
(Student does not answer.)

Prof: Is there sickness? Immorality? Hatred? Ugliness? All these terrible things exist in the world, don’t they?

Student: Yes, sir.

Prof: So, who created them?
(Student has no answer.)

Prof: Science says you have 5 senses you use to identify and observe the world around you. Tell me, son…Have you ever seen God?

Student: No, sir.

Prof: Tell us if you have ever heard your God?

Student: No, sir.

Prof: Have you ever felt your God, tasted your God, smelt your God? Have you ever had any sensory perception of God for that matter?

Student: No, sir. I’m afraid I haven’t.

Prof: Yet you still believe in Him?

Student: Yes.

Prof: According to empirical, testable, demonstrable protocol, science says your GOD doesn’t exist. What do you say to that, son?

Student: Nothing. I only have my faith.

Prof: Yes. Faith. And that is the problem science has.

Student: Professor, is there such a thing as heat?

Prof: Yes.

Student: And is there such a thing as cold?

Prof: Yes.

Student: No sir. There isn’t.
(The lecture the after becomes very quiet with this turn of events.)

Student: Sir, you can have lots of heat, even more heat, superheat, mega heat, white heat, a little heat or no heat.. But we don’t have anything called cold. We can hit 458 degrees below zero which is no heat, but we can’t go any further after that. There is no such thing as cold. Cold is only a word we use to describe the absence of heat. We cannot measure cold. Heat is energy Cold is not the opposite of heat, sir, just the absence of it .
(There is pin-drop silence in the lecture theater.)

Student: What about darkness, Professor? Is there such a thing as darkness?

Prof: Yes. What is night if there isn’t darkness?

Student: You’re wrong again, sir. Darkness is the absence of something. You can have low light, normal light, bright light, flashing light… But if you have no light constantly, you have nothing and it’s called darkness, isn’t it? In reality, darkness isn’t. If it were you would be able to make darkness darker, wouldn’t you?

Prof: So what is the point you are making, young man?

Student: Sir, my point is your philosophical premise is flawed.

Prof: Flawed? Can you explain how?

Student: Sir, you are working on the premise of duality. You argue there is life and then there is death, a good God and a bad God. You are viewing the concept of God as something finite, something we can measure. Sir, science can’t even explain a thought.. It uses electricity and magnetism, but has never seen, much less fully understood either one.To view death as the opposite of life is to be ignorant of the fact that death cannot exist as a substantive thing. Death is not the opposite of life: just the absence of it.
Now tell me, Professor. Do you teach your students that they evolved from a monkey?

Prof: If you are referring to the natural evolutionary process, yes, of course, I do.

Student: Have you ever observed evolution with your own eyes, sir?
(The Professor shakes his head with a smile, beginning to realize where the argument is going.)

Student: Since no one has ever observed the process of evolution at work and cannot even prove that this process is an on-going endeavor, are you not teaching your opinion, sir? Are you not a scientist but a preacher? (The class is in uproar.)

Student: Is there anyone in the class who has ever seen the Professor’s brain?
(The class breaks out into laughter.)

Student: Is there anyone here who has ever heard the Professor’s brain, felt it, touched or smelt it? No one appears to have done so. So, according to the established rules of empirical, stable, demonstrable protocol, science says that you have no brain,sir. With all due respect, sir, how do we then trust your lectures, sir?
(The room is silent. The professor stares at the student, his face unfathomable.)

Prof: I guess you’ll have to take them on faith, son.

Student: That is it sir… The link between man & god is FAITH. That is all that keeps things moving & alive.

I believe you have enjoyed the conversation…and if so…you’ll probably want your friends/colleagues to enjoy the same…won’t you? This is a true story, and the student was none other than…

APJ Abdul Kalam, the former President of India

Create custom named events in Backbone.js

In Backbone, Events is a module that can be mixed in to any object, giving the object the ability to bind and trigger custom named events. Events do not have to be declared before they are bound, and may take passed arguments. For example:

<script>
var person = {};

_.extend(person, Backbone.Events);

person.on("scream", function(msg) {
  alert("I am " + msg);
});

person.trigger("scream", "screaming");
</script>

Show hidden files on Lion

To enable hidden files/folders in finder windows:

  1. Open Finder
  2. Open the Utilities folder
  3. Open a terminal window
  4. Copy and paste the following line in
    defaults write com.apple.Finder AppleShowAllFiles YES
  5. Press return
  6. Now hold ‘alt’ on the keyboard and right click on the Finder icon
  7. Click on Relaunch

You should find you will now be able to see any hidden files or folders. To revert:

defaults write com.apple.Finder AppleShowAllFiles NO

Taking Screenshots in Mac OS X

Command-Shift-3:
Take a screenshot of the screen, and save it as a file on the desktop
Command-Shift-4, then select an area:
Take a screenshot of an area and save it as a file on the desktop
Command-Shift-4, then space, then click a window:
Take a screenshot of a window and save it as a file on the desktop
Command-Control-Shift-3:
Take a screenshot of the screen, and save it to the clipboard
Command-Control-Shift-4, then select an area:
Take a screenshot of an area and save it to the clipboard
Command-Control-Shift-4, then space, then click a window:
Take a screenshot of a window and save it to the clipboard

In Leopard and later, the following keys can be held down while selecting an area (via Command-Shift-4 or Command-Control-Shift-4):

  • Space, to lock the size of the selected region and instead move it when the mouse moves
  • Shift, to resize only one edge of the selected region
  • Option, to resize the selected region with its center as the anchor point

Clear the terminal’s command history

Sometimes you just need to clear your history in Terminal. It’s actually pretty easy to do.

history -c

If you’d rather not have your history saved to a file at all, add the following line to your ~/.bash_profile:

unset HISTFILE

This way, your command history is limited to only those commands you used during the current session. More information and options can be found on the bash man page

man bash

Ubuntu Package Management

Chances are good that you’re already familiar with apt-get, a command which uses the “advanced package tool” to interact with the operating system’s underlying package system. The most relevant and useful commands are, (to be run as root):

apt-get install [package-name]
This command installs the package(s) specified, along with any dependencies.
apt-get remove [package-name]
This command removes the package(s) specified, but does not remove dependencies.
apt-get autoremove
This command removes any “orphaned” dependencies which remain installed but are not used by any applications.
apt-get clean
Removes downloaded package files (.deb) for software that are already installed.
apt-get purge [optional]
Combines the functions of remove and clean for a specific package. Also removes configuration files for the given package.
apt-get update
Reads the /etc/apt/sources.list file and updates the system’s database of packages available for installation. Run this after changing sources.list.
apt-get upgrade
Upgrades all packages if there are updates available. Run this after running apt-get update.

While apt-get likely provides the most often used functionality of the package management, apt provides additional information that you may find useful in the apt-cache command.

apt-cache search [package-name]
If you know the name of a piece of software but apt-get install fails or points to the wrong software, use search to look for other possible names, if you need to find out the name of a package that you know is in the system.
apt-cache show [package-name]
The search interface only provides package names. If you need to learn more about a package, including dependency information, version numbers and a basic description, run this.
apt-cache depends [package name(s)]
Lists the packages that the specified packages depends upon in a tree. These are the packages that will be installed with the apt-get install command.
apt-cache rdepends [package name(s)]
Generates and outputs a list of packages that that depend upon the specified package. This list can often be rather long.
apt-cache pkgnames
Generates a list of the currently installed packages on your system. This list is often rather long, so it is best to pipe its output through a command like less.

Get your Twitter follower count with jQuery

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script>
$(function(){
    $.ajax({
        url: 'http://api.twitter.com/1/users/show.json',
        data: {screen_name: 'rcastera'},
        dataType: 'jsonp',
        success: function(data) {
            console.log(data.followers_count);
        }
    });
});
</script>

A PHP function for the Fibonacci sequence

I was recently asked as a test to write a function that outputs the Fibonacci sequence in PHP. Here it is:

function fib() {
    $current = 1;
    $previous = 0;
    $evaluation = 0;

    while($evaluation < 100) {
        $evaluation = ($current+$previous);
        $current = $previous;
        $previous = $evaluation;
        echo $evaluation . '
'; } }