Tech

En till Good Old Blogs webbplats

First alpha of OAuth Connector released

A module I’ve been working on for a while is OAuth Connector – a module that enables a Drupal site to easily let their users log in through OAuth API:s like Twitter’s. A short screencast of how it works: Over a year ago we needed Facebook Connect for one of our projects. Looking at the…

Läs mer

On the uselessness of array_merge_recursive()

I guess that most people have run afoul of the monstrosity that is array_merge_recursive(). In short a merge of array(‘a’=>2, ‘b’=>3) and array(‘b’=>4) gives you array(‘a’=>2,’b’=>array(3,4)) which isn’t the result that one would expect. So, as usual, I’ve created a gist that outlines the problem and gives a more sensible alternative. http://gist.github.com/271920

Läs mer

A future for Services – 3.x?

Services is a module that makes it easy to provide web services using Drupal. What services doesn’t do is to allow the definition of separate API:s. This is something we need to fix if we want to turn services into a real web-service framework. Consider the following: Today all installed services are always available on…

Läs mer

Co-Maintainers Wanted!

The list of modules that I maintain has become quite long, and in the beginning of next year I’ll have a little daughter (if the nurse guessed right on the gender). So the time that I have for being a good maintainer will be very limited. If you feel that you’d like to help maintain…

Läs mer

Copying Ubuntu VM:s and eth0

Note to self: when copying virtual Ubuntu servers between machines the MAC address will be changed and a eth1 device will be added with the new MAC address. But it won’t be properly configured. Edit `/etc/udev/rules.d/70-persistent-net.rules` and remove the old `eth0` device and rename the `eth1` device to `eth0`. Then reboot and everything should be…

Läs mer

Dynamic vhost configuration

I’ve recently tried out a new way define my virtual hosts on my development machine. I’ve always had a configuration file in my home dir (that gets included from httpd.conf) that looks something like this: NameVirtualHost *:80 ServerName drupal.local DocumentRoot /Users/hugowett/Sites/drupal/public_html AllowOverride All Order deny,allow Allow from all <VirtualHost *:80> ServerName somesite.local DocumentRoot /Users/hugowett/Sites/somesite/public_html <Directory…

Läs mer

Ensuring that values are in an array

I’ve run across situations where I want to ensure that some values exist in a non-associative array (without getting duplicates). The way I’ve usually solved it is: if (!in_array(‘nid’, $fields)) { $fields[] = ‘nid’; } if (!in_array(‘title’, $fields)) { $fields[] = ‘title’; } This is kind of ugly, and the more values you want to…

Läs mer

Convenience scripts for Solr

This is a set of convenience scripts for daily drupal use of solr in a dev environment. When you use the apachesolr module in many projects it becomes somewhat boring to set up solr again and again. And when you have a whole team doing the same thing, this script becomes a time-saver. This little…

Läs mer

Caching the results of your functions

Sometimes when you use info-hooks to collect information from a arbitrary number of modules, or perform some other expensive or ”unknown cost” operation, you’ll start to feel the need to cache your results. If your function will be called several times during one request caching in a static variable will take off some of the…

Läs mer

Terminal tips and tricks

This is a collection of terminal (not as in life-be-gone) tips and tricks – good things to do with your terminal and bash. It originates from our old google code wiki and contains things picked up from http://blog.macromates.com/2008/working-with-history-in-bash and other places. There are some good tips over here too: http://programmingishard.com/code/tags/bash Using textmate as your svn…

Läs mer