I keep all my Drupal sites up-to-date by updating a single Drupal core instance and one install profile. And I keep Drupal core and all modules in this install profile updated through CVS. But then a problem poses: what if a file was added to or removed from CVS? Until now, you'd have to manually svn add or svn rm the file. And in the case of some modules (e.g. Views), that's a lot of files you'll have to check.
I'm aware that this probably isn't the best name, but it gets the job done :).
It has bothered me since day one at university that I can only use the university's SMTP server. I got by, by just letting sent messages fail, because then I'd get a pop-up which would let me pick another SMTP server. This was of course far from perfect: sometimes I thought a message was sent while it really wasn't… so it would sit in my outbox for a day.
The only real solution is for the university's network to be improved: they should find a way to limit network traffic and abuse in ways that don't affect the user so severely. (On the bright side: the wireless network was incredibly unreliable the first 2 years but is superb since this year!)
Until that happy day, I needed an interim solution. The best solution would involve an SSH tunnel to keep using the correct SMTP server. It also requires you to have a server somewhere with SSH access. I don't want to maintain that too, so I chose for a simpler solution.
I wrote a PHP script (Mac OS X only, sorry Windows/Linux users) that will change the SMTP servers of your e-mail accounts depending on the SSID of the wireless network you're currently connected to. This is sufficient in my case, but it could easily be extended to also change the default printer or change your "network location" (each "network location" in Mac OS X can have its own per-network interface settings).
Whenever your network settings change, this script will run (thanks to launchd). This means it will work completely transparently.
I found the crucial parts in this similar tutorial. I think my code is much easier to understand and adapt, not in the least because mine isn't written in Perl
First, the actual script: download it below and update it to suit your needs. The part you'll want to update is this one:
//---------------------------------------------------------------------------- // Configuration. You should update this. // Default location. 'private' => 'smtp.gmail.com:private@example.com', 'work' => 'smtp.gmail.com:work@example.com', ), ); // UHasselt. $uh_smtp = 'student.uhasselt.be:0623800'; SSID => 'UHasselt-Public', 'mail' => $uh_smtp, 'work' => $uh_smtp, ), );
Obviously, you can update the configuration to as many accounts as you want.
The SMTP server identifier is of the format <server>:<username>.
Now put this in ~/scripts/ (or wherever you store your scripts) and chmod +x it to make it executable. Then test it: ~/scripts/locationchanger. In case your PHP interpreter cannot be found, use type -a php to find out its location and update this in the first line of the script.
Finally we want this script to run automatically whenever our network environment changes. This is possible through the power of launchd's watchpaths:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>wimleers.com.locationchanger</string> <key>ProgramArguments</key> <array> <string>/Users/wimleers/scripts/locationchanger</string> </array> <key>WatchPaths</key> <array> <string>/Library/Preferences/SystemConfiguration</string> </array> </dict> </plist>
You'll want to put this file (can also be downloaded below) in ~/Library/LaunchAgents. To make it work, either reboot or use launchctl load ~/Library/LaunchAgents/LocationChanger.plist
I hope this proves useful to some people that share the same frustrations. If you've made improvements to the script, let me know in the comments or through pingbacks so I can update this post!
For several courses at the university, we've got projects going on (actually, 5 simultaneously…) and for most of them, we have to write fairly large documents. We also have to work in groups of 2, 3 or 5. So collaborative writing becomes a necessity. Finally, in the group of 5, we work on 4 different operating systems. So whichever solution we pick, it must seamlessly work on any platform as well.
We chose LyX.
Is it also for you a routine to look up the documentation for Drupal hooks at api.drupal.org?
If you also use TextMate and are sick of having to command-tab to your browser to get to the documentation, then you'll have a much better alternative in about 15 seconds.
Go to Bundles > Bundle Editor > Show Bundle Editor. There, click the plus-button in the bottom left corner to add a new command. Set the input to None, the output to Show as Tool Tip and the scope selector to source.php. Copy/paste the command below and assign a shortcut -- I use CTRL + D.
if grep <<<${TM_CURRENT_WORD:-!} -Esq '^[a-zA-Z0-9_]+$'
then
FILENAME=${TM_FILEPATH##*/}
BASENAME=${FILENAME%%.*};
if [ `echo "$TM_CURRENT_WORD" | grep -E "${BASENAME}_[0-9A-Za-z_]"` ]
then
HOOK=${TM_CURRENT_WORD##${BASENAME}}
URL="http://api.drupal.org/apis/5/hook${HOOK}"
else
URL="http://api.drupal.org/apis/5/${TM_CURRENT_WORD}"
fi
exit_show_html "<meta http-equiv='Refresh' content='0;URL=$URL'>"
else echo "Nothing to lookup (hint: place the caret on a function name)"
fiIf you now place the cursor above a Drupal core function and press the shortcut, you'll be presented with a direct lookup of that function at api.drupal.org. Better even, if you place the cursor on a hook implementation, e.g. mymodule_menu, then you'll get the documentation of hook_menu. Note that your file must be saved for this to work (and it must be named according to Drupal conventions, i.e. mymodule.module).
Add these lines to your ~/.bash_profile if you're using the Bash shell:
alias ddiff="cvs diff -u -F^f -N > "
alias dhead="cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal checkout drupal"
alias dupdate="cvs update -dP"Now you have three new commands at your disposal:
ddiff patchfile.patch, creates a patch file.dhead, checks out Drupal HEAD in the current directory.dupdate, updates the current directory recursively.