Menu Sidebar
Menu

Ember CLI 101 Book Review

If you are looking to jump-start your learning with Ember CLI, I would highly recommend the ebook Ember-CLI 101 by Adolfo Builes.   I have played around with Ember in the past, watched a few screencasts on it, but wanted someone to hold my hand a little when I decided to learn what Ember CLI is about.

This book does an excellent job of going over the core features, and more importantly things are explained in a very human way so you are able to grasp what really is going on behind the scenes.

I already have a strong background in Ruby on Rails, so I actually felt very comfortable with Ember-CLI since it is following a very similar pattern.

ember-cli-book

 

The book guides you in building a ‘borrowing’ application.  The application is designed to help you keep track of what items you have lent out to your friends.  There is a github account setup for the application, and Adolfo was nice enough to organize the source code in a way where you can compare the code as you progress through the chapters.

ember-cli-sublime

 

To save time, there is a public API setup that you proxy to in order for your Ember application to have a JSON API to connect to:

[bash]ember server –proxy http://api.ember-cli-101.com[/blurb]

Below is a screenshot of the sample application that you learn to build using Ember CLI.

ember-cli-borrows-screenshot

 

The book covers the following topics:

Getting Started / Requirements

Working with Plugins

Components and Addons

Ember Data

Computed Properties and Observers

Testing Ember.js applications

Deployment

You also get a good idea of the various tools that are used to build a SPA like:

node.js, ember-inspector for chrome, watchman, bower, broccoli, jasmine, etc.

For anyone who wants to get started building a Ember-CLI project, I would highly recommend this book as it really helped me get an understanding of all the components and tools required to jumpstart a project.

Building a Rate Limiter using Redis

rate-limit

Designing a flexible Rate limiter is a great way to control the usage of various aspects of your application.  Probably the most common usage would be to rate limit your public API by limiting client requests to x per minute.  It is also a good idea to guard certain user interactions with your web application, such as logging in or posting content.

At first glance you might think using a database for this, but in high load or multi-tenant environments it is always a good idea avoid the database as much as possible since requests per second tend to add up fairly quickly.  In my opinion Redis is a great data store for this type of feature, since it has a good mix of data types where you can tweak your design based on your requirements.

If you want to rate limit based on a time frame like say 5 minutes, you have to keep in mind that this 5 minute window can be abused if you don’t design things correctly.  For example, if you are rate limiting to 100 operations per 5 minutes, someone might make 99 requests in the first 4:59 seconds, and then make another 99 requests in the next 10 seconds, effectively making over 100 operations in a given sliding 5 minute window.  If that sounds like I am overthinking the purpose of rate limiting, it really depends on accurate you need to be based on your SLA with your client or internal thresholds.

A good practical example is how discourse has designed their Rate Limit class.

def performed!
  return if rate_unlimited?

  if is_under_limit?
    # simple ring buffer.
    $redis.lpush(@key, Time.now.to_i)
    $redis.ltrim(@key, 0, @max - 1)

    # let's ensure we expire this key at some point, otherwise we have leaks
    $redis.expire(@key, @secs * 2)
  else
    raise LimitExceeded.new(seconds_to_wait)
  end
end

You can take a look at their implementation here.

Internally the Rate limit class is using a List, and each operation adds an item to the list and trims the list in case it contains too many items.  A ‘key’ represents an operation that you are rate limiting, like say “user_login” or “api_get_user”.   It determines a given operation (or “key”) to have reached its rate limit threshold when the list has reached its maximum allowed count and examining the age of the oldest item added to list (see the method “is_under_limit?” for details.

As much as you might love your end users, whenever you expose an API or user interaction that involves using resources on your backend, you have to guard against use patterns that might effect the health of your application.

WordPress Plugin development

Developing plugins for WordPress can be both daunting task if you don’t have a solid understanding of all the aspects of WordPress.

If you are looking for a book to jumpstart your learning process, I would suggest to take a strong look at “Professional WordPress Design and Development“.

prof-wordpress-dev-book

This book covers pretty much all aspects of WordPress, and from a development standpoint it covers:

  • Code Overview
  • Tour of the Core
  • The Loop
  • Data Management
  • Custom Post Types
  • Taxonomy
  • Plugin Development
  • Theme Development

Reading the online documentation is always a good idea, but sometimes a book fills in the gaps that you might not get when reading the documentation.

If you want to get serious, I would suggestion a combination of:

  1. Professional WordPress Design and Development
  2. Developer Documentation
  3. Forums and Stackoverflow
  4. Videos
  5. Reading WP the source code

Happy coding!

Scala books

Here are some books that will help you in your journey in learning Scala, and more importantly slowly moving towards a more functional style of programming.

I would start of with “Programming in Scala” which is written by none other than Martin Odersky who designed Scala.

programming-in-scala

 

As a 2nd more advanced book, I would take a look at “Scala in Depth” which covers more advanced topics and details best practices, idioms, functional programming core concepts, type system and Scala’s collection library.

scala-in-depth

 

If you want need help with “thinking functional”, I would recommend “Functional Programming in Scala” as it does a great job of outlining how to go about transitioning your mindset to a more functional style.  This book has allot of examples that you can work through so these concepts sink in.

functional-scala

 

If you want a book that has less theory and more HOW TO’ish, I take a look at the Scala Cookbook:

scala-cook-book

Now if you want to learn how to use Scala with the Play framework, I would grab a copy of Play for Scala:

scala-play-book

Unlike some other programming languages, I have to admit that learning Scala takes longer than usual.  If you are coming from a Java or C# background, you can normally learn a new language in fairly short order.  Scala on the other hand is a mix between a functional and OOP language and it takes times for certain concepts to sink in.

One important tip I would like to give is that reading Scala is like reading Math, if you don’t actually try it out you might trick yourself into thinking you actually understand the concepts.  The great thing is you can easily fire up a REPL and work through a program so don’t get lazy and just read without trying things out for yourself.

Keep in mind that learning Scala is a journey, and you can take things slowly at first.  Many people jump into Scala and simply write Java code but with Scala.   Writing Scala using Java idioms is perfectly fine, so long as you realize you should keep learning how to write Scala and transition yourself into a more functional approach.  In fact Martin write a nice piece on the various “Scala levels” of a Scala developer and how you should potentially go about learning.

 

Docker is the new black

docker1

I have been using docker on my VM’s lately (digital ocean) and it has been a pretty interesting ride so far.  I have used Puppet and chef in the past, and more recently I switched over too ansible because of its simplicity.  Docker takes things a step further by letting you build, ship and run your application inside of a container.

To get started I suggest you start off with a simple online tutorial here.

Installation

On Ubuntu you can quickly get docker up and running using the command:

curl -sSL https://get.docker.com/ubuntu/ | sudo sh

Here are some docker commands:

docker ps

docker logs <container_name>

docker stop <container_name>

docker version

docker help

docker ps with switches -l and -a.

docker run -d -P

docker run -d p port:port

docker rm

docker images

 

 

 

Salman.ca

Software development