I'm going to Paris this September for DrupalCon; as a professional Drupal developer it is an extremely useful event, and as a full-time web geek it's a great place to socialize with other people who do the same kind of work. I would also like the chance to present on some of the Drupal-as-a-GeoCMS work that has been happening this spring in front of a large audience who will ask sharp questions and then go use our work in their own projects.
I've entered a video contest for a conference ticket refund-- I've been wanting to make a movie with these toys since Easter:
Fairly often in Drupal I get handed arrays that have significant keys, but the values are either a label or false-y. I generally don't care about the items with empty values, or I specifically want to remove them. The solution is to use array_filter($arr) to remove any array items with false-y values. In fact, sometimes I don't even care about the labels at all, in which case I might do array_keys(array_filter($arr)). Examples below.
array_filter() can also take a callback as the second argument, which lets you filter out items on your own terms. See the array_filter() documentation.
I develop with Drupal 6 at work. One of the things I've been finding useful recently is writing field formatters. Field formatters are handy because they're used to format CCK field content when it gets displayed in nodes and also to format fields in Views. You can choose between formatters for each field of a node type under the 'Display' tab in the node type's settings. In Views, if you choose a display type that uses fields, you can select a different field formatter when you add each field.
To write your own field formatters, you implement hook_field_formatter_info(), then create theme functions for your formatters and add them to your hook_theme() implementation. At one point this was documented in examples packaged with CCK, but it seems the examples are no longer part of the CCK download.
A simple hook_field_formatter_info() implementation looks like this:
Your formatter should have a unique handle, in this case "myformatter". Using "x_formatter" or "x_module_name" here makes the theme key name confusing.
The 'field types' array contains the names of cck field types applicable to this formatter.
'multiple values' determines the way field content is passed to the theme function. It may be either of two values:
CONTENT_HANDLE_CORE means that the formatter is called separately for each value in the field. If a field contains multiple values, then the formatter is called multiple times. Field content is passed to the formatter in $element['#item']. This is the default.
CONTENT_HANDLE_MODULE means that the formatter is called only once for a field, and the theme formatter gets all the field values at once. In this case, field content is passed to the formatter in $element[0]['#item'], $element[1]['#item'], $element[2]['#item'], etc. Note that the $elements array contains other information about the field, such as $element['#field_name']
You will need to add the field formatter theme function to your hook_theme() implementation:
The theme array key, in this case 'example_formatter_myformatter' is constructed from {module name}_formatter_{formatter name}.
You don't need to include the 'function' => 'theme_myformatter' line; the default theme function name in this case would be 'theme_example_formatter_myformatter'.
The formatter function itself should return a stuff that is ready to output to the browser:
/**
* Theme function for myformatter from hook_field_formatter_info().
* @param $element
* Array of formatter info and the item to theme. Field contents will either be
* in $element['#item'] or $element[$i]['#item'].
*/
function theme_example_formatter_myformatter($element) {
return strtoupper($element['#item']['safe']);
}
This field formatter simply displays the contents of the text field in all caps. You'll need to clear your cache before your new formatter shows up in the field display choices.
I've been trying to think of a snappier way to introduce my birthday list this year, but nothing is surfacing. So: I'm turning 25 next week, this is a list of things I want for my birthday. If you send something via email, put "birthday list" in the subject line and I will not open it until the 18th.
The "dew point" is the temperature where water vapor condenses into dew; it changes based on the amount of water in the air. When the dew point drops below the air temperature, you get dew.
When the dew point drops below freezing, it is called the "frost point"; when the air temperature drops below freezing and the dew/frost point drops below the air temperature, you get frost.
more about frost. I've been waiting for the first frost here but I don't think it has come yet.
Robbie is saving a piece of railroad rail because "you can chunk it up into pieces about this long [2 ft] and it's useful for banging other pieces of metal on"--an improvised anvil. To cut up something like a rail, you would use an acetylene torch. (I had to ask, so I figured I'd write it down).
apparently in apple farming one organic alternative to chemical pesticides is clay. I am guessing that would mean that they make a light slurry of clay and water and spray it on the apples.
cron is deprecated under Mac OS X 10.4 and 10.5; it is replaced by launchd. You can schedule tasks with launchd by making a .plist, putting the plist in ~/Library/LaunchAgents/, and running something like launchd load ~/Library/LaunchAgents/my-task.plist. Cron is still present on the system, though. If you still want to use cron, just set up your crontab as usual with crontab -e and cron will automagically be turned on (launchd will load com.vix.cron, which tells it to check the crontab). a couple more details on launchd and cron, see also crontab.
wtf is PDO? -- a PHP extension that gives you a class with a standard set of methods for working with data in databases. Why? You can use that standard set of methods. And apparently PDO MySQL operations are faster than native PHP MySQL operations, at least in some cases. The catch? Comes with PHP 5.1. You might have to compile PHP with the pdo_mysql driver (exhibit a, exhibit b).
Today I installed Eclipse. Like my ubuntu-eee install notes, the following is not a how-to. I'm documenting my experiences so that knowlegeable users can compare (and correct me), and so that I have a reference for future Eclipsy activities.
Update:2008-09-10 Eclipse has not really worked out for me at all. Checking stuff out of SVN and setting up projects worked fine, but when I went to write code, the code-completion features did not work at all--in fact, they crashed Eclipse entirely. I turned them off... and Eclipse still crashed. So maybe the following should serve as a "what not to do"...
First of all I knew I needed to use PDT (PHP Development Tools for Eclipse). So I installed the Eclipse 3.3/PDT 1.0.3 bundle--Eclipse + PDT all pre-packaged. While this was labeled "stable", it turned out to be seriously crashy. So I went all cybermen and deleted it.
The second time around, I installed plain Eclipse (Ganymede), and used Eclipse's internal "update manager" to install...
Eclipse's update manager is under the help menu as "Software Updates..." (at least on the Mac). The first two plugins I downloaded as .zips and added within the Update Manager via Add Site... > Local... > path/to/unzipped/plugin. Subclipse I installed by adding the update site directly: Add Site... > http://subclipse.tigris.org/update_1.4.x (the other two were less clear about their Eclipse update manager URLs). yay, PHP and SVN support.
I work with Drupal, which uses the .module and .install extensions for some php files, and I had tell Eclipse to treat files with those extensions as PHP. how to force php syntax highlighting in Eclipse--you get more than just syntax highlighting with this.
When I first checked out my project from svn using subclipse, Eclipse didn't set it up as a PHP project, meaning that no code features were available. This FAQ was helpful: How do I manually assign a project Nature or BuildCommand? Project "nature" I guess has some sort of "project type" implications that make various project features and behaviors available, and "build commands" are "parse-y things that report php warnings and errors". As the link above specifies, I went into the .project file in my project's base directory and added the right "nature" and "build commands"; I got the correct values by creating a fresh php project and looking at its .project file.
It remains to be seen whether I actually like working in Eclipse, but I've resolved to give it a good try.
Last week I got an Asus Eee 1000H, and this weekend I installed Ubuntu on it (this is the "Windows" version and came with XP installed--NewEgg had a $100 instant rebate on the 1000H). Thanks to some fantastic software and how-tos from the community, it was mostly straightforward.
The following is not a how-to. I'm documenting my experiences so that knowlegeable users can compare, and so that I have a reference for future linuxy exploits.
I got a 4 GB flash drive and turned it into an Ubuntu Live USB. Right on the Eee, I downloaded the Ubuntu ISO via bittorrent (linked on the get Ubuntu Eee page) and UNetbootin, and used UNetbootin to put the ISO stuff on the flash drive. I also downloaded the Ubuntu Eeee kernel from these installing the Ubuntu-eee kernel manually which should fix Eees with Ubuntu but no internet access.
I saw instructions to hit escape during startup to switch the boot device, but it wasn't working for me, so hitting f2 (over and over) let me enter the BIOS and switch the boot device.
Originally I couldn't seem to boot to the flash drive... to make it work I dumped the contents of the USBTest.zip file from this Pen Drive Linux boot test on my freshly formatted flash drive, running the makeboot.bat file (from the flash drive only!) and then putting the Ubuntu ISO on again with UNetbootin (and choosing to overwrite the exisiting syslinux). So that worked, but may not have been necessary, because I also twiddled some BIOS settings--I'm a total PC noob, and I wasn't exactly sure what needed to be changed.
In the BIOS I also disabled "quick boot" and "quiet boot" for the time being. I re-enabled "quick boot" but I haven't paid attention to any difference it might make.
I installed Ubuntu over the whole Windows partition.
Once I rebooted into my new Ubuntu installation, my flash drive refused to automount--it kept saying "Invalid mount option". It turned out that the fstab (a file that describes how the OS should deal with mounting devices) was messed up. Apparently a bunch of Ubuntu users were having similar issues after installing 8.04.1. My fstab had my USB devices trying to mount as a CDROM (I suspect because Ubuntu assumed that my install device was a CDROM rather than a flash drive).
First of all I read this page on understanding and editing fstab. fstab is a plain text file located at /etc/fstab. You can only edit it with root permissions, because messing it up can prevent your system from booting.
/dev/sdb1 /media/usb auto auto,user,exec,rw,utf8 0 0
I examined the fstab with:
tail /etc/fstab
I confirmed the device path (in this case, "/dev/sdb1") by plugging in my USB drive, opening a terminal, and typing:
sudo fdisk -l
This will prompt for a password, then spit out a block of info about each available drive; the block describing my 4 GB flash drive looked like this (note the "device" and "system", which in this case are "/dev/sdb1" and "W95 FAT32" respectively):
Disk /dev/sdb: 4009 MB, 4009754624 bytes
255 heads, 63 sectors/track, 487 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 488 3915733+ b W95 FAT32
Partition 1 has different physical/logical endings:
phys=(1023, 254, 63) logical=(487, 124, 63)
I created the mount point (/media/usb), made a backup, then edited my fstab with vi (for gui, use gedit):
sudo mkdir /media/usb
sudo cp /etc/fstab /etc/fstab.bak
sudo vi /etc/fstab
Patience is a virtue. I think that after installing AMP via tasksel, you can stop and start Apache and MySQL via the Services panel (in the menus at System > Administration > Services).
Since I won't be able to get the MSI Wind before I go out of the country at the end of the month, I need to get something else to travel with (am not taking my main laptop out of the country with current border policies). I almost got the HP Mini-Note, but then I settled on the larger/faster Asus eee 1000. Pros: ships now. Cons: having to settle.
I think the fallacy here is that the mall construction is fundamentally shitty. First, malls are built with a short lifespan in mind--I'd guess 20 years or so. Second, they're built without considering environmental factors; for example, they have flat roofs and the plan for dealing with snow is to heat the building enough to melt it off; they don't take advantage of solar energy for heat and light, or of trees for shade. If the power is out, you can't heat, cool, or light a mall. Runoff has nowhere to go. Third, many of them aren't accessible without a car: they're surrounded by acres of baking asphalt and have their own exit off the freeway. Unfortunately, malls are a sunk cost, the results of a series of horrible decisions that we need to move past rather than investing ourselves in revitalizing. Rip it up, recycle the parts, and put something green and growing there.
free topographical maps - kmz layer for google earth, also pdfs of USGS topo maps. Also mentions "Teslin paper", which is extra-durable and waterproof paper, perfect for printing maps and probably plenty of other things, too. thx kb.
I haven't found a way to import m3u playlists into iTunes and have them come through in the correct order. This afternoon I wrote an AppleScript to do it for me. AppleScript makes me crazy--a PDF manual? "natural language"? seriously?
Anyway, this script:
takes a .m3u playlist file that contains relative paths to the music in the playlist--generally, the playlist file will be in the same directory as the music--creates a playlist in iTunes, imports the tracks, and adds them to the new playlist.
may be used by
drag-and-dropping m3u files on the script from the Finder
double clicking the script and then choosing a file
or putting this script in your "~/Library/iTunes/Scripts" folder (create it if it doesn't exist) and accessing it via iTunes' scripts menu.
may be edited by you--open it with the Script Editor application that comes with Mac OS X (in /Applications/AppleScript)
This script is provided without warranty! It is not necessarily well-implemented!
An 18th century philosopher named Hegel had the idea that you can evolve an idea into an absolute, perfect idea. You do this by taking a thesis and it's antithesis and finding another thesis that addresses both... rinse and repeat. This idea is called the "Hegelian Dialectic"; a diagram may be somewhat helpful.
Hegel also had other ideas... wikipedia, lazybones.
oEmbed was introduced recently (beginning of this month) as a standardized way to get enough info about a resource to embed it; ie, get the format, dimensions, url, title, etc., so that you can build an <img> or <embed> tag for rendering the resource on your page. This is an extremely useful idea; it would let people paste a URL places rather than the youtube embed codes or whatever. However! This scheme requires two URLs to represent the same resource; a more RESTful approach would simply ask the resource's URL for a particular HTTP response. Backdrifter explains: oEmbed FAIL! Represent RESTfully.
Ponoko lets you design stuff to get cut by a laser cutter. I think that the way industrial tools like laser cutters are becoming more and more available to people is very cool.
"If you want to use open source, you have to learn to stop being a customer...you have to become a collaborator" -- from a talk on Plone given by Steve McMahon here at NetSquared.
I'm looking for a good bicycle repair book: one that talks about tools, has a ton of diagrams (preferably hand drawn), and plenty of description and best practices. Today I came across a book called "Fix Your Bicycle", by Eric Jorgensen and Joe Bergman, put out by Clymer Publications between 1972 and 1979. It is full of diagrams and photos, from photos describing how to patch tires to technical illustrations of exploded bottom brackets. It also describes bicycle tools and how to use them. In short: I want it. I'm trolling Amazon's used sellers for it this very moment (there are several misspellings, for example).
Also looking good: Anybody's Bike Book, by Tom Cuthbertson (kb has a 1979 edition).
MEC is a Canadian outdoor gear company that is a little bit like a slimmer, hipper LLBean with all the flannel-fireside-lifestyle crap trimmed away. They have a very good backpack selection, too. As a simple, minimalist overnight pack or travel bag, I liked the 30 liter Brio Crag daypack. Also the tiny Pika daypack is almost exactly like the tiny simple bag I inherited (translation: appropriated) from my mother, exactly right for casual hikes.
[6:32pm] becw: DRY?
[6:32pm] eads: Don't repeat yourself.
[6:32pm] t-dub: Don't Repeat Yourself
[6:32pm] t-dub: Or eads
...
[6:33pm] nikCTC: oh, it gets better...
[6:33pm] nikCTC: let me double-check my logs
[6:36pm] nikCTC: from April 10th of this year: (02:13:28 PM) becw: DRY, t-dub?
I just took a personality test which asked if I "prefer to stick with things that I know", which I do, but the corollary is that I prefer to know a lot of things.
I wish there was more outdoor gear designed like this Lafuma "Eco" backpack. It's hemp plus recycled polyester, and designed with less fabric and fewer plastic bits. Plus, they don't have weird brightly colored panels like most packs. The color of the pack on Lafuma's site is pretty flash: mottled grey with red tabs.
The other pack I'm looking at is the Osprey Stratos 40, which has a bunch of straps for compression and gets universally awesome reviews. Also, I can go check this bag out in person at REI. If I were to get a new pack this spring (doubtful: I already have a pack), this would probably be the one.
Books that I have started recently but have not finished, oldest to newest:
Feminism and Science Fiction, by Sarah Lefanu. This needs to be read with a good SF library at hand.
Skin, by Dorothy Allison.
Trampoline, a short story anthology edited by Kelly Link.
The Best American Short Stories, 2006, edited by Ann Patchett. I haven't gotten past the table of contents.
The Body in Pain, by Elaine Scarry.
Tin House, Vol. 9, #3: Off the Grid.
Learning Python, by Mark Lutz.
The SFWA European Hall of Fame, a scifi short story collection edited by James Morrow and Kathryn Morrow.
This stack is only seven inches high but feels overwhelming. I probably won't need any more books until at least July; I won't have finished the stack by then, only gotten more impatient with it.
UMass soil testing service. $9, tests for heavy metals, among other things. Important for anyone gardening in cities or next to houses that may have been painted with lead paint! If there's lead in the soil and you're a long-term resident, you can do plant-based remediation (so cool).
Materials Monthly -- a monthly publication from Princeton Architectural Press that includes actual material samples. For example, issue 11 has "Prismatic Stainless Steel", "Hand-finished Acrylic Floor", and "Silver Reflective Film". It comes in a box! via kottke.
Got a fancy new cell phone tonight (thanks ben!) and found that the only ring tones it will play are .mmf format. Converted my aiffs to wav, then used a crunky but free and handy tool from Yamaha to turn those into mmfs. The phone is a Samsung T509, and the converter software is Yamaha's "Wave to SMAF Converter". mmf!
My friend Rachel posted a potato recipe on her lj a few weeks ago, and I made it and it turned out really well. My variation goes like this:
Preheat the oven to 450°.
Put in two tablespoons or so of flour, some adobo powder, and some cumin in a little bowl and mix it up. (alternatively, use flour, salt, pepper, paprika, and onion and garlic powder)
Rinse and dry a couple of potatoes (Yukon golds are delicious of course) and slice them into eighths, lengthwise. Put the slices in a big bowl, drizzle with olive oil and mix up. Drop the flour mixture on top and stir the slices 'till they're coated. Set them skin-down in a pan, then stick 'em in the oven and cook for 15-20 minutes or until they start to get brown.
These are kind of like home-spicy-fries, crispy and spicy on the outside. I think I ate an entire cookie sheet of them.
Tonight's dose of thinking: possibly alternating "rock o'clock" with my current response, "ain't got no job o'clock" would save a little sanity for anyone who has ever asked me the time twice. (If you ask three times, I guess there's nothing I can do for you.)
Noting the above, it would be an extremely bad idea for me to own this tshirt.
North Pole Speed Record. This blows me away. This guy is trying to set a speed record for the trip to the North Pole, which he is doing unsupported (carrying all his own food and gear), on skis, and hopefully in 30 days. The standing record is 37 days, set in 2005 by a team using dog sleds and resupplying multiple times. (via kottke I think.)
Asaph - a very light 'microblogging' tool with a neat posting interface: apparently all posts are made via a javascript bookmarklet that interacts with the current page (post currently selected text, interactively select a picture, or just post the url). via.
... I do think it's a pity they didn't ship AS with both English and Programmer dialects. The English syntax is ideal for inferring the intent of a script, even without knowing the language, while the Programmer syntax's explicit, unambiguous semantics would have been better for understanding the actual mechanics. Users could then switch between the two on the fly to provide whichever view they find most appropriate at the time. ...
Applescript's 'English' makes me crazy every time I use it, I don't even necessarily agree that it is good for 'inferring the intent of a script', but the idea of having 'dialects' that you could just toggle between... that's pretty interesting/funny. (via)
p.s. applescript's 'programmer' dialect was developed but never part of shipped versions of applescript.
apparently someone named last friday as Talk Like a Physicist Day ("because we're at least as cool as pirates"), which is awesome, except that friday was Pi Day and I have to insist that talk like a physicist day have its own date.
I hate it when new little bands only have a myspace page with a couple non-downloadable tracks. I want them to have a real web page from which I can download their two or three tracks as mp3s, so that I can put the tracks in playlists and remember who they are five months from now when they may eventually be releasing an album.
p.s. dear bands: take a night off from beering and spend $30 to set up a real site. have someone go grab an account for you at nearlyfreespeech.net, where you can get domain names and feature-complete pay-as-you-go hosting. have them throw Wordpress or Chyrp on your new site, or even use a Blogger account. Post your songs, and the occasional narcissistic photo of yourself looking impossibly hip. If you bother to do it yourself, this can even turn into your post-music-dreams career (see: 25% of the web designer-developers who think they're hot shit).
I'm surprised that I didn't mention Equation Service here years ago; it's a sweet little service for Mac OS X that lets you write LaTeX equations just about anywhere (TextEdit, Keynote, etc.) and render them to images in place with a keyboard shortcut (or item in the Application->Services menu). This was one of my favorite utilities when I was in school, but I haven't set it back up on Leopard yet.
interesting note on geographic resolution of postal codes--in the US, the five-digit postal code covers a largish land area, whereas in some places (like Canada and the UK) postal codes resolve to a block, sometimes even indicating the side of the street or the building.
any food blog ever (see Simply Recipes or 101 Cookbooks; almost any photo on any food blog will illustrate depth of field abuse, but A-list food blogs are extremely consistent about it).