Blogs

Solve mysterious Drupal initial page load delay with cron

Sometimes you'll visit your Drupal site in the morning, or after logging in as admin for the first time in awhile, and the page will take forever to load, more than 30 seconds, even longer. (First, if you're using Cloudflare CDN, it could be a problem with their servers not sending the end of the page html when it's finished and thus causing the browser to hang for a long time.)

The main cause of this kind of page load lag is Drupal's cron task! There are two ways that Drupal will run cron. The first is when you trigger it externally (by pinging the cron.php url,...

More virtual memory in Mac OS X

Virtual memory is the RAM that processes see when they're running, the memory space which the operating system allocates to them. The memory is called virtual because the addresses don't necessarily conform to physical memory addresses of the RAM hardware but instead the same address could refer to any number of possible physical addresses. It's up to the OS and the memory hardware to resolve the virtual address to a physical address, and do so transparently to each process.

Virtual memory can also refer to the data which was stored in physical memory but "paged out" to disk. The...

The .htaccess file in Drupal 7 / Drupal 8

An "htaccess" file is a configuration file read and used by the Apache web server to configure settings local to your website or even just a subdirectory in the website. These are local settings as opposed to what you would configure in .conf files in Apache's conf directory.

There should be a dot in the filename: .htaccess - and so the file will often be hidden or invisible in directory listings unless you specify that hidden or system files should appear. But the file should exist in any Drupal installation in the top-most directory of Drupal (next to the README and...

Start a separate Chrome app on OSX with flags from Terminal

Chrome can be opened from the command line. And by running it from the command line you can configure Chrome with a number of options, there are several hundred possible flags which you can start Chrome with.

First of all, just to start/open Chrome from the command line instead of the Dock (or Spotlight) all you need is the path to the Chrome app binary. This is the absolute location of Chrome on Mac OS X: /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome. You can copy and paste that to Terminal and it should open Chrome without any special options, or...

Installing Drupal 8 (with differences between Drupal 7) on your web host

Drupal 8 is out and many of the necessary modules have been ported to version 8. Drupal 8 is quite different under the hood from Drupal 7. But it's also fun to play with straight out of the box so let's spin up a new Drupal 8 demo installation. All of this assumes you have shell access, even if you don't normally use the command line, but should be applicable whether ssh'ed to a remote Linux server or testing locally on your Mac OS X laptop. To install Drupal 8 then:

  1. Download Drupal 8 (.tar.gz) and untar it in your web root. (As of publication, the most recent version is

  2. ...

Manage clearing / refreshing cache in Chrome when reloading page

Web developers are constantly clicking the refresh button in their browser to see their latest changes. It almost becomes like a nervous tick, clicking that refresh to get that fix. And it's frustrating when changes on the backend don't result in the reward-inducing changes in the page loaded by the browser.

Web page caching explained

There's two levels of caching, and we deal with them in different places. First, there's flushing any cached resources in the browser, whether in the browser's memory or in files. And then there's requesting non-cached resources from the web...

Clean up Mac ._ files on external/USB disk

Have you ever looked at an external drive with folders created on a Mac but then loaded on Windows or Linux? If you look carefully (turn on viewing of hidden and system files) you'll see a file beginning with ._ for some or many of your files, varying by file type. What are these mysterious '._xxx' files?

Mac OSX Resource Forks

Those ._ files are called resource forks. Resource forks are specific to Mac filesystems. They don't take up too much space and can contain useful data about your files. But deleting them also won't delete your files (the data...

How to watch for file changes and trigger a shell command on any modification in OS X and Linux

These days our files are everywhere, you need an advanced IDE just to track where all the code for a small software project is, and you have many background processes running as dependencies on your main application. It's not always possible to know when a particular file will be updated since it's done via a chain of automatic processes. Have you ever been waiting for a process to run and not notice that it had finished? As developers, we need ways to hook into these chains and be aware of files which change when they change in order to trigger new actions off of those "filesystem events...

Managing OS X Terminal Windows Groups

I prefer OS X's stock Terminal app to iTerm 2 because it automatically reopens and restores previous terminal windows and tabs and keeps the scrollback for each tab (although bash history is lost per tab, reasonable since bash is a separate program from Terminal). iTerm2 used to be a much better Terminal but Terminal has gotten better and is more than usable now. iTerm2 does have some cool features like instant replay/rewind, better support for the mouse for vim. [Note: xterm is also available on stock Mac OS X.]

Besides restoring, you can save your windows and tabs as a 'Windows...

Escaping special characters in markdown

These characters need to be escaped in Markdown in order to appear as literal characters instead of performing some markdown functions:

\ ` * _ { } [ ] ( ) # + - . !

Special escaping for hash (#)

You can usually escape a # with the \ character like others in the above list, but if your hash appears on the same line as an h1/h2/h3 which themselves start with #, ##, or ### then you need extra escaping for the inline #. In this case, add another # at the end...