Brian Mesa

Web Development – Becoming Great – Getting Lost

Hunting Bugs with MongoDB

MongoDB Bug Hunt Meetup
As MongoDB prepares for its release of 3.4, they offered an amazing opportunity to enthusiastic developers a chance to catch some bugs. Along side several engineers to aide those of us less comfortable, the bug hunt was a very intense and rewarding experience. Ramon Fernandez-Marina the Director, Build & Release Engineer for MongoDB gave us a very detailed orientation into MongoDB and not only the tools we would be using but just how to use them.

Almost immediately we had our first bug! Installing the development release of MongoDB 3.3.12 using homebrew (a package manager for OS X) was impossible. Homebrew did not recognize the –devel block typically used. This might not be a large bug as MongoDB can be very easily installed by other means. However, something that doesn’t work as intended is still a bug.

As the night progressed you could definitely feel and see the concentration in everyone. Those from MongoDB were equally focused if not more focused assisting everyone from the easiest task up to some very detailed issues. From first hand experience each person helping there was incredibly knowledgeable and more than eager to help. We all really wanted to find some bugs, unfortunately we didn’t. However I am more than positive the search wont stop at this meetup as I’m still trying to find a bug.

What Did I Learn at MongoDB?

Tons! I mean seriously what I learned in a couple of hours at MongoDB was astonishing. Considering I had never used MongoDB, I had a firm grasp on basic CRUD operations. I also had some time with importing and exporting other datasets from JSON and CSV files. I even got to play with MongoDB’s aggregation framework. MongoDB’s text search feature was also incredibly cool and useful.

From my first ever install of MongoDB to aggregating/reducing a database it was all an unforgettable experience. MongoDB is user friendly, easy to comprehend and grasp. All this on top an amazing team working with you on all your questions is well worth every visit.

How Can I Attend These Super Awesome MongoDB Meetup?

That’s a great question! Check out MUG, The MongoDB User Group, on Which I have include below

MongoDB Meetup

Also it’s not too late to find your own bugs! Download MongoDB and try it out for yourself.

MongoDB Download

A huge thanks to Alim S. Gafar, Ramon Fernandez-Marina and All the MongoDB team for an such a great experience.

Events in Backbone.js

Importance of Events

Whether this is an obvious question or not, events in javascript and the type of events are crucial to any website. They also allow the control of flow through events at the programmers liking.

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.

Types of Events


object.on(event, callback, [context])

this binds a callback function to an object. This callback will be invoked whenever the event is fired.

off[event], [callback], [context])

Will remove a previously bounded callback function from an object. Things to keep in mind. If no context is given for the specific callback are given when calling off then all callbacks will be removed pertaining to this object. In a similar fashion if no callback is specified when passing off all callbacks for this object will be removed.


object.trigger(event, [*args])

This trigger callbacks for the given event or any list of event passed. The arguments specified to trigger will then be passed along to the vent callbacks.


object.once(event, callback, [context])

this event method is very similar to that of on. However, as its name implies it will bound the callback to fire only once and then will be unbound. It is a very powerful tool if you want a specific event to be bound only once in a program and then have it removed.


object.listenTo(other, event, callback)

This method tell one particular object (the first one) to “listen to” a particular even of a different object. This has it advantages instead of calling on for an object since it will allow the object to be aware of the events of another object.


object.stopListening([other], [event], [callback])

As the name may have implied it unbinds listenTo from a specific object. You have the option of not passing in any arguments which will tell the object to stop listening to all events. However, you may pass along particular arguments to tell this objects to only stop listening  to a select amount of events of another object.


object.listenToOnce(other, event, callback)

Exactly like once it will bind listenTo to an object. It will then only fire once as specified and then remove itself from the object.



There are several other built in Backbone.js events which are cataloged. You even have the option of specifying your own events which you can also see here:

Backbone.js Events

Javascript’s This

Differences in Strict mode vs. Non-strict mode

First off, the This function always refers to an object. It’s value being completely dependent on how a function is called in Javascript. Knowing this it may be apparent that when using strict mode as opposed to non-strict mode the way This works will also change.

Strict mode makes several changes to normal JavaScript semantics. First, strict mode eliminates some JavaScript silent errors by changing them to throw errors. Second, strict mode fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that’s not strict mode. Third, strict mode prohibits some syntax likely to be defined in future versions of ECMAScript.

In the global execution context (outside of any function), this refers to the global object, whether in strict mode or not.

In functions where the values are not defined, using this and not using strict. This is the object itself. However when using strict and this where the value of a function has not been set. Instead of the result being the object the result is undefined.


This  basics

When a function is called as a method of an object, its this is set to the object the method is called on. The this always refers to and contains the value of the object and it is usually used inside a function.

This keyword  is not assigned a value until an object invokes the function where this is defined. The value This is assigned is based only on the object that invokes the this Function. this has the value of the invoking object in most circumstances. However, there are a few scenarios where this does not have the value of the invoking object. I touch on those scenarios later.


Sources on This

This with Clarity- Javascript is Sexy

What does this mean? – StackOverflow

This – JavaScript | MDN



Things you may want to consider when using jQuery

As I begin to learn jQuery, I have taken it upon myself to read the documentation first. Attempting to learn several methods that can in the future help me or anyone reading this, solve problems that might arise, by using more applicable methods. Here are a few I have found across the web.

.data(key, value) or .data(obj)

As jQuery puts it allows us to “Store arbitrary data associated with the matched elements or return the value at the named data store for the first element in the set of matched elements.” What is cool about this type of method is that it allows the user to store these values with keys or as objects while being safe of circular references.

Circular references are instances in which the data in question is dependent upon another set of data. However, that data is dependent on the first set of data to begin with. Here is the example for using .data() and calling it respectively.

Screen Shot 2015-10-19 at 8.53.19 AM

Here what would be shown is : “The values stored were 16 and pizza!


I found this one to be incredibly interesting. Although I haven’t been able to implement it myself as of now, viewing and playing with several examples it seems very useful in animations and functionality. “When .stop() is called on an element, the currently-running animation (if any) is immediately stopped. If, for instance, an element is being hidden with .slideUp() when .stop() is called, the element will now still be displayed, but will be a fraction of its previous height. Callback functions are not called.”

Screen Shot 2015-10-19 at 9.12.22 AM

Screen Shot 2015-10-19 at 9.13.30 AM

This buttons use the animate and stop functions above. I have removed most of the code provided by jQuery as to make it a brief read but stop is very interesting. When the button STOP! is clicked it will call the .stop() method and immediately stop the entire animate. It will resume once another function is called such as Go or Back.

.delay(duration[, queueName])

As with the .stop() function above this will render some really cool functionality and effects that you may want to use to make your code particularly useful. Instead of making your code completely stop you can have it delay or pause for the duration inputted in milliseconds.

“.delay() method allows us to delay the execution of functions that follow it in the queue. It can be used with the standard effects queue or with a custom queue. Only subsequent events in a queue are delayed; for example this will not delay the no-arguments forms of .show() or .hide() which do not use the effects queue.

Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings ‘fast’ and ‘slow’ can be supplied to indicate durations of 200 and 600 milliseconds, respectively.”

Screen Shot 2015-10-19 at 9.26.52 AM

Screen Shot 2015-10-19 at 9.27.10 AM

Useful Materials

I have also gone ahead and added several sources including the examples given by jQuery.

jQuery “.delay()”

jQuery “.data()”

Commonly used snippets for jQuery

Input Fields on Rails

First! Make an app to test our awesome forms!

When trying to get a rails app up and running as quickly as possible, I have found generating a controller with specific views to be most useful. Example. Using new and result will automatically set a ‘get’ for new and result as well as a “new.html.erb” and “result.html.erb”.

Screen Shot 2015-10-02 at 8.20.10 AM

Simple Form Tag

You can manipulate this in very simple ways. It can be used to create and post or simply do a search. The options are very diverse for this type of form and for sake of demonstration I have simply created a ‘get’ method and passed the value so you may see what is occurring. It is very easy to create a post method but for sake of brevity only ‘gets’ was used. Using the ‘gets’ allows me to easily just have the results page open when submit is clicked. Rails allows for builders to take in a specific path and method using <%= form_tag(“form/result”, method: “get”) do %>. 

Screen Shot 2015-10-02 at 8.56.47 AM

Screen Shot 2015-10-02 at 8.58.23 AM

Screen Shot 2015-10-02 at 8.58.35 AM


If you wanted to make a checkbox and grab its value its super simple. By default using rails to generate a check box sets values automagically to the value of 1. You my change its value by simply adding a parameter right after replacing the 1.

Screen Shot 2015-10-05 at 8.08.36 AM


Screen Shot 2015-10-05 at 8.08.47 AM

Screen Shot 2015-10-02 at 9.37.37 AM

Screen Shot 2015-10-05 at 8.07.31 AM

Radio Button

Much like a checkbox radio buttons give you a range of options but only allows you to check one option.

Screen Shot 2015-10-05 at 8.21.34 AM

Screen Shot 2015-10-05 at 8.20.55 AM

Screen Shot 2015-10-05 at 8.20.59 AM

Select Form

Screen Shot 2015-10-05 at 8.53.41 AM

Screen Shot 2015-10-05 at 8.53.49 AM

Screen Shot 2015-10-05 at 8.53.58 AM

Password Field

Screen Shot 2015-10-05 at 8.57.46 AM

Screen Shot 2015-10-05 at 8.57.56 AM

Screen Shot 2015-10-05 at 8.58.00 AM

Password Field

Screen Shot 2015-10-05 at 9.01.14 AM

Screen Shot 2015-10-05 at 9.23.01 AM

Screen Shot 2015-10-05 at 9.23.04 AM

I Was Paying Attention…Like..4 Seconds Ago.

Congratulations Everyone You Are Now Dumber Than A Goldfish!!


You. Yes You According to Microsoft Have a Significant Chance of Losing a Staring Contest to Your Pet Goldfish! WOOHOO!

Microsoft surveyed 2,000 people and used electroencephalograms (EEGs) to monitor the brain activity of another 112 in the study, which sought to determine the impact that pocket-sized devices and the increased availability of digital media and information have had on our daily lives.

Among the good news in the 54-page report is that our ability to multi-task has drastically improved in the information age and mobile internet, but unfortunately attention spans have fallen.

In 2000 the average attention span was 12 seconds, but this has now fallen to just eight. The goldfish is believed to be able to maintain a solid nine. The report by Microsoft is very significant. As it also determined that people of our relative age at about a 75% go and reach for our phones as soon as something loses our attention. On the other hand people of aged about 65 only reach for there mobile phones at approximately 10%.

Not to fear Ladies and Gentlemen fortunately for us the study was test solely on Canadian’s and well we all know we are significantly more awesome so we might have a chance at defeating the almighty Goldfish to a staring contest…. maybe.


Bombardment of Information

Remember we live in an unexplored age in the Human history. We will go down as the pioneers of the information age and we will shape the future to come. We have been born at a tipping point of Human brain activity where the need for holding more attention on one solid task is not nearly as important as being able to multi-task. Microsoft admits that although our attention spans have decreased ever so slightly, our ability to engage in multiple task at once and successfully complete them has spiked dramatically.  I can almost feel that I’m reaching the peak of my intelligence where I can answer your question without even listening!


Improving Our Attention

These tips have been taken from several sources. Mostly and Which have been linked bellow.

  • Do Not Email First Thing in the Morning or Last Thing at Night “The former scrambles your priorities and all your plans for the day and the latter just gives you insomnia,” says Ferriss, who insists “email can wait until 10am” or after you check off at least one substantive to-do list item.
  • Do Not Check Email Constantly Batch it and check it only periodically at set times (Ferriss goes for twice a day). Your inbox is analogous to a cocaine pellet dispenser, says Ferriss. Don’t be an addict. Tools like strategic use of the auto responder and Boomerang can help.
  • Do Not Carry a Digital Leash 24/7 At least one day a week leave you smartphone somewhere where you can’t get easy access to it. If you’re gasping, you’re probably the type of person that most needs to do kick this particular habit.
  • Get Exercise                                                                                                                        It’s a great way to increase your focus. The chemicals released from exercise have been shown to increase memory. Not only that but its a great tool to relax and release nervous energy.    
  • Drink Water                                                                                                                           Often times we forget how important hydration is in regards to alertness, focus and overall happiness. Drink more water you’ll thank me.
  • Be Mindful of What’s Important
  • Focus and Then ReFocus

Using ruby to perform terminal commands.

As project 1 unfolded both my team-mate and I had our minds racing with ideas.  We took on a pretty big task and we still didn’t fully understand in what direction we were going.

CLI is fun and a great place to start but I wanted some visuals I wanted to see all the information that I was scraping.  I told my partner Damian “What if we have it open up like chrome or something”   To which he responded along the lines of that’s cool and all but good luck doing that but if you do let me know.

Almost if by magic,  as if the gods of Ruby docs had heard my cry for help. I stumbled upon magic characters that would make all my troubles disappear.

Using %x or backticks

Under the kernel class in Ruby are execute commands that you can use to have ruby interact with your terminal. There are many functions and uses but I will cover one that I found particularly useful and that might come in handy for someone later on.

Screen Shot 2015-08-19 at 9.18.19 AM

Using backticks (`) or (%x) will allow ruby to execute the command you have placed within the backticks through the terminal.  This an example of our project code in which we ask one of our variables to open up in terminal.

Screen Shot 2015-08-19 at 9.24.22 AM

This is the same as if you were to type in the following ruby command in irb:


In fact any command that can be executed within the terminal. From creating directories, to creating files to moving files can all be executed as long as they are within %x` ` the backticks.

Two Very Helpful Links

Ruby-Doc`cmd` → string

Executing commands in ruby

What is Object-Oriented Programming

Object-Oriented Programming

Just a brief history on what I thought I knew…


I had just recently switched my major to Computer Science and well the first thing I ever learned about computer science was….you guessed it… proofs. Wait, is that correct? The math course in logics and proofs? Yup. I spent the beginning of my journey to becoming a programmer in a discrete mathematics course. I learned the ins and outs of permutations and combinations. I learned everything there was about logical operators and lattices. I even learned just about everything on boolean, logarithms, ordered sets and modules. To be honest i thought I was wasting my time. I spent countless hours trying to figure out the proofs of so many things, I was driving myself mad. Towards the end of the course, I firmly believed, my logic was so sound it could easily rival Plato. What does all this logic have to do with object-oriented programming? Nothing. Well it does but not how I had originally assumed.

Its About The Objects Not The Logic

The link bellow does some great points in summarizing what I feel I am attempting to say so it might be cool to check it out. I credit them with most of my content since they nailed it on this explanation.

Object-Oriented Programming

So originally programming was a very linear process. I was in college brought up on C++ and well it taught me a lot. Mostly that it takes me about 7 lines to create “hello world” while ruby takes me 1. Secondly that a receipt generator in C++ took me about 35,000 lines, I have yet to try it in ruby but I’m positive it wont take nearly as long.  Anyways back to my point, historically a program has been viewed as a logical procedure that takes input data, processes it, and produces output data.

The idea was very simple, as programmers we care more about the “object” the things we are trying to manipulate rather than how to manipulate them. I’m not going to pretend I was a pioneer in OOP but I’m going to assume that they took their discrete mathematics course and understood the logic and math so well they just wanted to manipulate more complex pieces of information to make programming more useful.

When we say object, literally think of an object, something identifiable with a structure ect. These objects that we wish to manipulate could be generalized to a specific group. For example a lion to animals or a table to furniture. These generalizations could be classified into classes, in a almost similar fashion as we categorize living things. This creation of classes allow many benefits to programming and probably the most importantly is that you can generalize manipulations to classes making things quicker, faster and more complex. Among these benefits are the following:

The concepts and rules used in object-oriented programming provide these important benefits:

  • The concept of a data class makes it possible to define subclasses of data objects that share some or all of the main class characteristics. Called inheritance, this property of OOP forces a more thorough data analysis, reduces development time, and ensures more accurate coding.
  • Since a class defines only the data it needs to be concerned with, when an instance of that class (an object) is run, the code will not be able to accidentally access other program data. This characteristic of data hiding provides greater system security and avoids unintended data corruption.
  • The definition of a class is reuseable not only by the program for which it is initially created but also by other object-oriented programs (and, for this reason, can be more easily distributed for use in networks).
  • The concept of data classes allows a programmer to create any new data type that is not already defined in the language itself.

Things To Keep In Mind


It’s completely made up but its real.


Wiki to the rescue! “its an informal high-level description of the operating principle of a computer program or other algorithm. It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading. Pseudocode typically omits details that are essential for machine understanding of the algorithm, such as variable declarations, system-specific code and some subroutines. The programming language is augmented with natural language description details, where convenient, or with compact mathematical notation. The purpose of using pseudocode is that it is easier for people to understand than conventional programming language code, and that it is an efficient and environment-independent description of the key principles of an algorithm. It is commonly used in textbooks and scientific publications that are documenting various algorithms, and also in planning of computer program development, for sketching out the structure of the program before the actual coding takes place.”

Mindfulness. It important when creating something beautiful to keep that thing in mind. Psuedo-code allows us to keep a track of all the things we must accomplish systematically in order to make somethings work. Its simply good practice to know exactly what you’re trying to accomplish and exactly how we are trying to accomplish it.

Lastly remember to stay up. Its not easy…. but nothing worth having ever comes easy.

Object Oriented Pogramming

Dude, where’s my sleep?


I love my sleep. I love sleeping, napping, lounging, resting and just about anything that involves some sort of inactivity. Unfortunately like most of the things we love we don’t get to experience those things often. WSJ is quick to point out that we have no idea what we are doing when it comes to our sleep. They agree that our day is incredibly busy and believe it or not we aren’t that special. Apparently, most Americans aren’t getting enough sleep with an average of about 6 hours or less every single night. Something has got to change because I’m tired (literally) of feeling like my friend down below. Here is some advice and things to bear in mind.


Why is sleep important?

Umm… because. No, seriously it is possibly the single most important thing we can do to remain functional and overall healthy. Sleeping is your own personal reset button, so USE it. Sleeping pretty much allows the body to correct all the damage we have caused it throughout the day.

If you don’t sleep enough you are setting yourself up for failure. A sleep deprived body acts very similar to an intoxicated one. Motor skills are less accurate and overall less coordinated. Body responses are also more delayed. This hinders just about all of our daily activities especially learning, attention and retention. There is also even a high correlation between lack of sleep and increased body fats percentages. You are just asking your metabolism to give up one you. I was saw this documentary on the man that flew a hot air ballon across the world in the fastest time possible. Long story short, he sacrificed sleep to get to places faster. His body eventually collapsed and he went straight to sleep. All this sleep deprivation causes a delay in our processing skills and reflexes. He had a little bell to ring if he lost too much altitude. When it had rung as he was not piloting he recalls how he frantically jumped and climbed out of the hot air ballon basket. He describes that how out of pure luck he managed not to lose a grip on the basket and fall right out of the sky. He had slept towards the beginning of his trip and never once reacted that way but this time it was different because he was simply not himself

Sleep improves everything about us. It increases or creative and problem solving abilities as well as our attention. Sleep has been shown to affect athletic performance. Sleeping alleviates stress and improves our ability to tolerate stress. Sleeping even makes us healthier, people that sleep properly tend to get sick less often especially small things like a cold.

Power Nap!

Napping is a great way to boost our productivity and ensure that we are not being less productive than we want to be. A nap must be deliberately taken and for a controlled amount of time. A nap is NOT more than 90 minutes long, you’re just sleeping at that point. Napping has been studied and certain naps are for certain scenarios which we must be aware of.

10-20 minutes is the golden rule. It will jumpstart your brain and give you that energy you were so laking a few minutes ago

30 minutes is a dangerous place to be. There is such a thing as sleep inertia, inertia is a lack of energy or movement in an object and sleep inertia is the process by which we actually slow down or make ourselves much more tired than we were to begin with.

60 minutes is a great place to feel well rested but you will feel slightly tired and grouchy it happens when we don’t sleep enough.

90 minutes. You might as well go to sleep, this is very light and non-deep sleep. Overall it causes more harm than good.

Things to remember don’t nap long it will cause more harm than good. Sleep deliberately and time your nap. Try to nap slightly seated up it will help prevent falling into deep-sleep and help avoid sleep inertia. Lastly, one should not be dreaming during naps, this is a sign of some heavy sleep deprivation.



  • Track Your Sleep
  • Be Consistent with sleeping patterns
  • No Screens or TVs at night
  • Read a book
  • Sleep in a dark and cold space.
  • Download a blue light filter like “f.lux”. It help protect your circadian rhythm.

Blog at

Up ↑