Greg Remiasz's avatar

Slow response times with .local domains

I recently started to research why my local Rails environment was experiencing slow response times. After some digging around on Stackoverflow I came to find out that the .local domain is normally reserved for the Bonjour service on Macs. After updating my local hosts file from xxx.xxx.local to xxx.local.xxx I saw a major increase in response time in my Rails app.

Greg Remiasz's avatar

Gang of Four Javascript Design Patterns

If you’ve ever researched design patterns you’ve certainly come across the Gang of Four (GoF). While books such as JavaScript Patterns do a good job at explaining all of the most commonly used patterns, I’ve found a good, well organized and free alternative by the team at dofactory.com. They do a good job at clearly explaining the different implementations with clear examples and use cases.

dofactory Design Patterns

Greg Remiasz's avatar

JS Prototypal Inheritance

Early on I had a difficult time understanding Javascript inheritance (sometimes I still scratch my head), mainly I think of the fact of how it differs from the classic model. I’ve heard several different answers some short and some long mostly because of the prototypal caveats. My take is fairly straightforward (in my mind at least…). In javascript we use objects (Obj) to implement inheritance, each object has a prototype (Obj.prototype), each of these prototype objects will have its own .prototype all the way up to Object.prototype. In this way we create a prototype chain. The code below exemplifies basic javacript inheritance

We have two objects Cat and Animal, Cat.prototype = new Animal() sets Cat’s prototype to Animal. The prototype link acts only in retrieval. This means that you can now access Animal’s properties and values when creating a new Cat object but making any change to inherited properties will not effect Animal.

After the prototypal inheritance has been set you can still modify the parent constructor and the changes will be visible on all the objects which contain that prototype in the prototype chain (such as Animal.prototype.isAnimal = function() { return true; }).

When attempting to access a property of an object such as fluffly.isAnimal() the prototype link is used (also known as Delegation). Since .isAnimal doesn’t exist in Cat we move up the prototype chain and check Animal, since Animal.isAnimal exists it is returned. If we attempt to call a property which does not exist we still move up the prototype chain up to Object.prototype and return undefined. It is also generally not a good idea to not have a very long prototype chain as this can impact performance.

We can also create inheritance using Object.create in more modern browsers. Stay tuned for a more detailed explanation.

Greg Remiasz's avatar

Speed up your Mac with purge

I tend to keep my work laptop powered on for sometimes weeks at a time, only putting it to sleep when moving between locations. At times even with 16gb of RAM it can slow down quite a bit from constantly open applications and starting and shutting down VMs. I came across the “purge” command when searching for answers and it appears to do the job. While this is not something you should constantly refer to I found it useful to run every other week or so.

To free up space simply run the “purge” command in Terminal (you may need to run this with sudo if permission is denied). This process can take a minute or two depending on the amount of space which needs to be inspected. You can open up the Activity Monitor and watch the “Free” memory rise and the “Inactive” memory drop.

Greg Remiasz's avatar

IE8 Background Opacity Issue

I recently came across an issue where opacity would not be applied to large containers in IE8. This came about attempting to add a large overlay behind custom modals/dialogs. Even with the addition of the Microsoft <pre>-ms</pre> prefix when scaled large enough it would fail. I couldn’t find much information about this except for a comment on a Lightbox plugin on the Drupal website.

Greg Remiasz's avatar

Welcome!

Started this blog in an attempted to write down my learning experiences. I will be most likely be posting on other topics as time allows.