Select 5 most recent items from some categories
Ever needed to build a list which "sub-selects", say, 5 items from a given list of categories? This snippet should help.
Assume the following schema…
Ever needed to build a list which "sub-selects", say, 5 items from a given list of categories? This snippet should help.
Assume the following schema…
Isn't it a pain when you have dozens of Views setup and they are all marked as "overridden" because you just pulled in an updated feature file from somewhere. Features doesn't always notice when the Views on your site aren't up to date.
The following snippet (which you should use with caution) will batch "delete" (or Revert, once the view is in code) all Views which are marked as Overridden. This took a few seconds to run on our development machine.
So, Drupal 7 is out. Have you heard? It was a bit of a quiet launch really. ;-)
When it came to upgrading by blog, I decided (eventually) that I needed to do a cleanup as the Database had been upgraded from 4.7, to 5 and then to 6 - with many modules added and removed in between. New year, new drupal, new blog (kinda)!
It's also a good excuse to test out that some of the modules I maintain actually work in Drupal 7 (such as Page Title and GlobalRedirect). It's also a kick up the arse to get Relevant Content ported to Drupal 7!
Sometimes, when you're running coder on a module, you'll get a lot of errors complaining about Windows line endings. This is because you should set your editor to use Unix Line endings to be consistent with all developers. See the Drupal Coding Standards for more details.
Below is a handy bash script which will help you batch convert many files from DOS to Unix line endings.
I use a cron script on this server which fires up Drush to run Cron (rather than the standard wget method). There is nothing wrong with using wget, however it does tie up an apache or lighttpd process while cron is running. It also means it's harder to control process priority. Drush, on the other hand, runs in CLI mode, so controlling process priority is easier (using nice). But then I started seeing odd errors…
I run XCache on the server that powers this site. XCache is cool. Out of the box, it allows caching of PHP compile code in memory, after all once a file is compile you shouldn't keep needing to compile it on every page load, should you?
I like little wins. I was just looking through the CSS file for this site and noticed that - for some reason - I'd used 0px instead of a LOT of times. Most values need numbers (10em, 10px, 10% and 10pt are all very difference sizes) however 0 is one of the few valeus which is the same in all cases (0px, 0pt, 0% and 0 are all zero!). This adds up to wasted data and bandwidth; admitedly not a lot, but still Every Little Helps!
So I fired up Vim. Initially, I just did: