We saw in chapter 1 and chapter 2 that we can move values to registers (using
movinstruction) and add two registers (using
addinstruction). If our processor were only able to work on registers it would be rather limited.
At its core, a processor in a computer is nothing but a powerful calculator. Calculations can only be carried using values stored in very tiny memories called registers. The ARM processor in a Raspberry Pi has 16 integer registers and 32 floating point registers. A processor uses these registers to perform integer computations and floating point computations, respectively. We will put floating registers aside for now and eventually we will get back to them in a future installment. Let’s focus on the integer registers.
In my opinion, it is much more beneficial learning a high level language than a specific architecture assembler. But I fancied learning some ARM assembler just for fun since I know some 386 assembler. The idea is not to become a master but understand some of the details of what happens underneath.
Some weeks ago the site I work on started having severe outages. It looked like the system was not able to fulfill the incoming requests fast enough, making the passenger queue to grow faster than new requests could be served.
Looking at the rails logs it looked like some Chinese bot was crawling the entire site, including a long list of dynamic pages that took a long time to generate and that are not usually visited. Those pages were not yet cached, so every request went through the rails pipeline. Once you start having the dreadful problem of your passenger queue to grow faster and faster you are usually doomed.
Since you can’t expect some of the malicious bots out there to respect the
robots.txtfile, I had to filter those requests at the Apache level so they did not even reach the application level. This past few months I’ve been learning a lot of systems administration, basically because it’s us, the developers, who also handle this part of the business.
Since all those requests came from the same
user agent, I looked for a simple way to filter the requests based on this criteria. It can be easily done if you use the
mod_accessApache module. All you need to do is make use of the
Denydirectives. Here’s a simple example to filter the
What this piece of code does is very self explanatory. The first line tells Apache to set up an environment variable called
user agentof the request matches the “
ezooms” string. Then you tell Apache the order it has to evaluate the access control to the directory: it first has to evaluate the
Allowdirective, and then the
Denyone. After that you set up both directives.
Allow from allbasically allows everything in.
Deny from env=BlockUAdenies all requests in which the environment variable
BlockUAhas been set. Since that variable is set up when the
user agentmatches our desired string, the config will basically deny access to the application to all requests with the “
ezooms” user agent.
This way you can easily protect yourself from basic bot attacks.
tl;dr: make sure you add
PATHwhen installing node.js to be able to access the package binaries.
Developing in Ruby on Rails on a Mountain Lion environment can be a pain. Although it’s a UNIX-like environment, most of the tools created for web development have been made with Linux in mind, and making the switch from a Linux box to Mac OS X is far from harmless.
Anyway, the other day I needed to tweak Bootstrap to make the default grid wider, and instead of using the Bootstrap web site customiser, I decided to download the source code from GitHub and build it myself.
In order to do this, you need node.js and some of the packages that come with it. I’ve never developed or even played with node.js before, so I needed to install it on the computer. And that was fairly easy thanks to homebrew by simply issuing the command
brew install node.
After node has been installed you have access to
npm, the node package manager. Following the Bootstrap instructions, I installed the necessary packages:
After that I thought I was ready to build Bootstrap, but the make command complained about not being able to find some of the node.js binaries I’ve just installed a minute ago.
The solution to the problem, though, was rather simple. It turns out the default formula for nodejs on homebrew doesn’t tell you the folder in which the node.js binaries will be installed in. Without adding this folder to the path, obviously the system can’t find the files it’s supposed to execute.
Simply add the folder
PATHenvironment variable and you’ll be good to go.