Smokes your problems, coughs fresh air.

Author: Rowan Rodrik (Page 23 of 27)

Rowan is mainly a writer. This blog here is a dumping ground for miscellaneous stuff that he just needs to get out of his head. He is way more passionate about the subjects he writes about on Sapiens Habitat: the connections between humans, each other, and to nature, including their human nature.

If you are dreaming of a holiday in the forests of Drenthe (the Netherlands), look no further than “De Schuilplaats”: a beautiful vacation home, around which Rowan maintains a magnificent ecological garden and a private heather field, brimming with biological diversity.

FlashMQ is a business that offers managed MQTT hosting and other services that Rowan co-founded with Jeroen and Wiebe.

Purging a MySQL database without losing meta data

When I clone a production database to a development database, I always need to empty the development database first. I could never find an SQL command to completely purge a database, bur, recently, I learned something about MySQL that surprised me: MySQL doesn’t lose the user rights for a database when you drop it. So, purging a MySQL database (without losing any access data meta data about that DB) is as simple as issuing the following statements:

DROP DATABASE my_development_db;
CREATE DATABASE my_development_db;

Happy cloning! 🙂

Separate development/production environments for WordPress

When you’re out Googling on how to maintain a separate development environment for a WordPress installation, you will only stumble across information about how to install all kinds of WAMPP packages. Well, I don’t care about WAMP (or WAMPP). I want to be able to edit my theme, change my plugins, mess with my database locally and then deploy my changes when they’re ready and well-tested (as if I ever…)

Rails was the obvious inspiration for how to do this properly. In Rails, the whole development and deployment process is very intuitive and powerful. In WordPress documentation I never even see the awareness of the need for this separation. They usually tell you to download stuff, upload it and muck about with it on the life production server. But, I’m not the mucking-about-in-live-configurations type. I’m the I-fucked-this-up-so-often-I-want-a-staging-area type. This post is about how I managed to fulfill this wish with WordPress.

Changing the environment

The first thing I had to do was to find some way to decide which environment to go into. For some reason I decided to use Apache’s mod_rewrite to set an environment variable based on the HTTP Host header. This is in fact very illogical, but we’ll get to that later.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} =bsblog [OR]
RewriteCond %{HTTP_HOST} =bsblog.molensteen
RewriteRule . - [env=WP_ENV:development]
RewriteCond %{HTTP_HOST} =blog.bigsmoke.us
RewriteRule . - [env=WP_ENV:production]
</IfModule>
 
# Keep out of WP's own block of rewrite rules below
# BEGIN WordPress 

. - looks like a needle because it’s voodoo. The dot says I match anything and the dash says I change nothing of what I match. I do set an environment variable to whether I want to be in development or in production.

So I now have an Apache environment variable available for querying from within PHP (as if PHP doesn’t have a $_SERVER['HTTP_HOST'] variable:-? ) and I can make use of that in my wp-config.php.

Multiple configurations in one file

I love configuration files that share the program’s language; wp-config.php being simple PHP code is what make this whole thing so easy:

<?php
 
if ( getenv('WP_ENV') == 'production' ) {
  // ** MySQL settings ** //
  define('DB_NAME', 'blog');             // The name of the database
  define('DB_USER', 'wordpress');        // Your MySQL username
  define('DB_PASSWORD', '[my password]'); // ...and password
  define('DB_HOST', 'bigsmoke.db');        // 99% chance you won't need to change this value
  define('WP_SITEURL', 'http://blog.bigsmoke.us');
}
elseif ( getenv('WP_ENV') == 'development' ) {
  // ** MySQL settings ** //
  define('DB_NAME', 'bsblog');          // The name of the database
  define('DB_USER', 'root');            // Your MySQL username
  define('DB_PASSWORD', '[my password]'); // ...and password
  define('DB_HOST', '127.0.0.1');       // 99% chance you won't need to change this value
  define('WP_SITEURL', 'http://bsblog');
  //define('WP_DEBUG', true);
}
 
define('WP_HOME', WP_SITEURL);
 
// You can have multiple installations in one database if you give each a unique prefix
$table_prefix  = 'wp_';   // Only numbers, letters, and underscores please!
 
// The rest of the stuff in this config file just isn't interesting
?>

There’s a few things to note here. You have to use getenv() or $_SERVER instead of $_ENV because variables set by Apache end up in the former two. Another thing to note is that I should have just checked $_SERVER['HTTP_HOST'] instead of resorting to mod_rewrite voodoo. For the rest it’s all very straight-forward: I make some database settings depend on which environment I’m in and I set the URL accordingly.

Development URLs

I had some trouble putting the pieces back together when newer WordPress versions started doing automatic redirects for URL that didn’t match siteurl in the wp_options. This change meant that when going to http://bsblog/ (the development URL for this weblog) for example, I’d inevitably end up at http://blog.bigsmoke.us/.

Links had always been constructed according to this setting, so I had already been planning a plug-in to transform production URLs to development URLs. But, I learned (a little late) that this is completely unnecessary since wp-config.php supports the configuration of a base URL. I had wrongly assumed that settings that weren’t in the sample config file, simply didn’t exist.

Thus, after adding WP_SITEURL and WP_SITEHOME to wp-config.php, everything was working.

Ideas to further enhance your configuration

  • Don’t limit yourself to one development environment if you have more than one development server.
  • Automate your deployment process. I use rsync for this.
  • Write a script to clone your production database to your development database. There’s no substitute for actual data.

Converting Monkey Audio to WAV in Gentoo

I had the bad luck that a CD image I acquired from the Internet consisted of a .ape file for the audio and a .cue file for the track offsets. cdrdao has no problem with .cue files but .ape is the file extension for Monkey Audio files. Monkey Audio is the awkwardly licensed monkey brother of Flac. (They’re both lossless audio encoding formats.)

This is one of those I-want-to-remember-this-for-later posts which I should really do more often if I wander about investigating various technicalities. Although such posts aren’t the most comprehensive and useful to the reader, they’re invaluable to myself six months from now.

mac is a tool capable of converting .ape files to .wav files. But first, .Ape’s awkward licensing problem meant I had to find an ebuild for mac to put in my Portage overlay in $PORTDIR_OVERLAY at $PORTDIR_OVERLAY/media-sound/mac. Through references in the Gentoo Forum and the Gentoo Wiki, I came across two different bug reports with ebuilds for mac attached. Bug 52882 had the newest ebuilds attached.

$ mkdir -p /usr/local/portage/media-sound/mac
$ cd /usr/local/portage/media-sound/mac
$ wget http://bugs.gentoo.org/attachment.cgi?id=154775
$ ebuild mac-3.99.4.5-r2.ebuild manifest
$ emerge -av mac

Now, I could convert any .ape files to WAV:

$ mac CDImage.ape CDImage.wav -d

Alternatively, I could have done this using shntool, a handy front-end for all sorts of lossless audio programs:

$ emerge -av shntool
$ shntool conv -o wav CDImage.ape

Now, I could have just gone into the CDImage.cue file and change the reference to the .ape file to a reference to the .wav file:

$ sed -i -e 's/.ape/.wav/' CDImage.cue
$ cdrdao write CDImage.cue

But, first I was sidetracked to splitting the tracks (until realizing that wodim wouldn’t burn the correct pregaps).

Just grepping for “INDEX 01” didn’t generate the indexes in a format that shntool split would eat, leading to the emergence of yet another package: cuetools.

$ emerge -av cuetools
$ cuebreakpoints CDImage.cue | shntool split CDImage.wav

Using diff and patch to upgrade web application installations

Update (July 30, 2008): I added information about making sure that the patch was successful.

When you install a big-ass web application such as WordPress or MediaWiki, you usually end with a bunch of configuration files and customizations (skins/themes, extension/plugins, uploads, etc.). This makes upgrading the files that come with the application a bit tricky. There’s a simple solution, however, which work regardless of whether you use a revision control system or not.

First of all, you do, of course, always need a revision control system. I personally recommend Git or Subversion, which are both excellent tools. But, that’s not what this post is about. I’m going to use two simple tools which are uniformly available on all (Unixy) platforms: diff and patch.

The procedure is simple:

  1. Download the version of the application which you’re currently running. For our example, we pretend that this version is extracted into the directory webapp-1.4.3.

  2. Then, download the version to which you’d like to upgrade. (We’re assuming that this version is extracted into the webapp-1.6.2 directory.)

  3. Compare the two versions to create a patch file:

    $ diff --unified --recursive --new-file webapp-1.4.3 webapp-1.6.2 > webapp-upgrade.diff
    
  4. Apply the patch to the installation of said web app:

    $ cd webapp-installed
    $ patch --strip=1 --remove-empty-files < ../webapp-upgrade.diff || echo "Some failures!"
    

Check if everything was patched perfectly

Now, if the patch command returned a non-zero status (printing Some failures! in the above example), it's time to check which chunks of which files failed. Get a summary by searching all files with an .rej or a .orig suffix:

$ find . -name "*.rej"

After manually applying any failed hunks, what's left is to compare your directory containing the patched application to the directory with the contents of the new application archive which you've used to create the patch:

$ cd ..
$ diff --unified --recursive --new-file webapp-1.6.2 webapp-installed

Version management

Your upgrade is done. Now, if your using a revision control system, you just need to check in new files and check out deleted files. In Subversion, I do this quickly using the following command sequence:

$ svn status|sed -e '/^\?/!d; s/^\?//'|xargs svn add
$ svn status|sed -e '/^\!/!d; s/^\!//'|xargs svn del

If you'd been using Git, you could do this all a little bit more sophisticatedly, but my Git skills are not advanced enough to go around giving others advice. Also, it's nice to learn a generic method before learning more specific tools.

Hi, My name is Witchbane and I like witches

2017-12-30: The below post was my first post on www.worldwide-wilderness.com, a project I abandoned in the form it was then intended to take: a series of blog posts and hopefully videos to enthusias young people about wilderness. Here, for posterity’s sake…
My name is Rowan. The Rowan tree is a common tree carrying small red berries of a bitter taste. Because the tree got ascribed many magical properties in the past, it used to be planted in front of farms as a protective from witches and other evil things. Hence, the old folk name witchbane. Myself, I can better identify with another folkloric name for this tree: witch wood. Druids used to lean on their witch wood staffs for support and power. Similarly, I want to support the growth of a new generation of witches by promoting the world of wilderness.
The Rowan Tree: From the misty coils of morning / there rises on the hill / In hesitating sunlight / and tendrils clinging still / Crowned it is, for power / and magic drapes its lee / In all the hues that red may show / the Rowan-berry tree

The Rowan Tree: From the misty coils of morning / there rises on the hill / In hesitating sunlight / and tendrils clinging still / Crowned it is, for power / and magic drapes its lee / In all the hues that red may show / the Rowan-berry tree

Witches to me are a symbol of unkempt wilderness, their repression a symbol of the illusion of the tamability of our wild nature. When I think of witches, I think of women—of course, enough witches are men but, as a male, I prefer to think of witches as (preferably sparsely-clad and sexy) females—women who live in the periphery of our neatly combed culture, beyond the edge of our cultivated fields and forests, in the realm of the unknown where they’re performing their unfamiliar rites and rituals. Different and deviating from the known, witches are repressed, because, for long, there has been just one right way to think about and to perceive the world in which we live. But, the world has been shrinking lately. Also, increasingly, time has been compressed and we’ve been shown that people have lived long before us, all of them in different ways. We’ve even been shown that some people are still living independently from the authoritarian belief structures which we’ve built. The evidence against the divinity of our species keeps piling up and it gets harder and harder to keep believing that anyone’s particular version of what is right and what is wrong is correct. In the right time, Darwin would have been a witch. In this time, to many, I am also a witch because my relation with wilderness is not sterile. You could even call it dirty. It’s an unhygienic blood bond, overgrown with mosses and fungi, a link rooted in ancient times which ought to not even have existed. Luckily, in this time, there are many who feel that witches are o.k. There are many witches too. So many, that soon they’ll disappear. Soon, we’ll all be witches. According to some, soon, the exploration of the unknown will (have to) move from the periphery to the mainstream. To make this a little sooner, I’m going to convince you that embracing the wilderness within and around us is stimulating and exciting. Yes, exciting! Better prepare yourself for some barely-clad, sexy hexes whom are waking up wilderness together. And now for one of those sexy witches: (You can look safely; the witch wood wizard’s staff is carefully covered with a cloth.
Rowan is moving sand from point A because he want more flowers at point B

Rowan is moving sand from point A because he want more flowers at point B: The photograph is courtesy of and copyrighted by Jeroen Dekker, 2007

Wilderness

2018-01-03. The below was originally published by Myrna on www.worldwide-wilderness.com. I copied it here while discontinuing that site in its current form. The deepest love of my life is the World on which we live. She gave us all we have in her abundance, she will take us back into her bosom, into her breath, at the end of our lives and make us into yet another of her creations. She deserves our love and respect; our fear and disregard of her are clearly harmful to her and ourselves. The disconnect that is caused by our way of (not) looking at the World begets so many of the problems that we can observe around us. The fear of people for our Earth has its roots in a fundamental misunderstanding of her nature, mistakingly thinking of Wilderness as destructive, dangerous and brutal in her untamed state. The fear has scared out of our heads the understanding that this is just one side of the duality, overshadowing the positive and creative, which lies not only at the opposite of the destructive side, but is also to be found within it. My understanding of Wilderness is of resillience and strenght, because in that, both priciples are recognized. I often take pictures of mushrooms, flowers and insects on the roadside or in the middle of the city. It proves to me the power of Nature to incorporate and generate even in the most difficult circumstances. My preference for taking pictures of mushrooms also stems from this idea. A thing as beautiful and special as a mushroom (remember that it does not need it’s possible bright colours to attract insects for polination or anything else …) can only grow where there is dead material to feed on. This is also why I love taking pictures at my father’s place. Fifteen years ago it was a spotless garden and three meadows, and now, after much digging, piling, planting and pulling down trees, it has become a piece of Wilderness akin to my idea of paradise, where rare flowers and animals can be found. All that can be seen there depends on something else to die or live for its own journey through life, into death. Without use of massive amounts of dead plant and tree material it is a long and arduous task to stimulate the growth of new life, patiently waiting for Nature itself to undertake the task of accumulating the wealth of death on which to grow. Seeing these things, and taking part in helping them along, has taught me some of the most important things that I now know about the power of the Wilderness that brought fourth a species as strange as us humans. It has also given me the precious insight that this Wilderness lives on inside of us, its creatures, with both its destructive and creative sides showing in our actions. Accepting the dominance of Wilderness in our creation makes it easier to understand our dual nature, and steer away from the emphasis on our destructive side that is so prevalent in our current culture of fear. Recognizing, accepting and dealing with this fear should, in my view, be the main priority of our culture in the decades to come. Stimulating this in myself and others is the main motivation in everything that I do. The sight of the Earth and her human inhabitants recoiling from each other in horror is one that I long to replace by a rapt fascination for everything that is and shares our World, and through that, have all conciousness around us marvel at the beauty and wholeness of us as a part of this marvellous creation that is our World.

Moved from Mnemosyne to FlashcardDB

When I was studying Spanish last year, I had to choose a flashcard program to memorize new words. At the time, I couldn’t find any on-line program that just did the job and did it well. In a comment on my blog post from last year, however, I was pointed by Jeff to his amazing FlashcardDB.

The program I ended up with last year was Mnemosyne. Mnemosyne is not based on your regular Leitner system, but rather on a concept where, after each card, you have to indicate yourself how well you have remembered it. I found that, in the end, having to tell the system in which box to put the card instead of just saying if my answer was right or wrong was taking me more effort than the actual recollection of the information. Also, as someone who rarely remains at one place for very long, a desktop program just isn’t as practical for me as an online program.

Mnemosyne
With Mnemosyne, I had to constantly remind myself of a complicated grading system.

Now to FlashcardDB. The site is pretty social, which means that you can study (and sometimes even edit) card sets made by other users. When you sign up, you can also create card sets yourself. Card sets can be tagged and you can study these tags instead of individual card sets if you wish. If you already have cards somewhere else, import is easy as well.

The user interface is very slick, especially for such a new program. Thoughtful usage of AJAX means that you’re never distracted by page reloads when this would interrupt your flow of thought. Simple key bindings making studying an easier affair than in most desktop programs. The right arrow is used to show the answer, the up arrow (thumbs up) to mark the answer as correct, the down arrow (thumbs down) to mark the answer incorrect and the left arrow to go back to the previous card. Also the interface for adding cards is very pleasant. It’s just a matter of filling in the front of the card, pressing Tab, filling in the back of the card, pressing Tab, then Enter and on the next card.

Before going on to the conclusion, I want to add that also the Leitner system is very well implemented in FlashcardDB, including pretty diagrams to make it instantly clear to everyone how the system works. Now for my conclusion: My advice if you ever need to make flashcards yourself is that you really should take a look at FlashcardDB before looking at anything else.

Finally, the following Ruby code is a quick hack I used to convert Mnemosyne’s XML export to CSV data which can be imported by FlashcardDB:

#!/usr/bin/ruby
 
require 'rexml/document'
require 'csv'
 
xmldoc = REXML::Document.new($stdin)
 
CSV::Writer.generate($stdout) do |csv|
  xmldoc.each_element('//item') do |el|
    csv << [  el.elements[1,'Q'].text, el.elements[1,'A'].text  ]
  end
end

Upgraded WordPress from 2.1 to 2.3.1

I’m now on WordPress 2.3.1. It was about time too; I was still on 2.1.

Importing the tags from Ultimate Tag Warrior worked fine. Before upgrading and importing, I quickly patched my local version of WP with a little help from Subversion:

$ svn diff http://svn.automattic.com/wordpress/tags/2.1/ http://svn.automattic.com/wordpress/tags/2.3.1/ > wp.diff
$ blog.bigsmoke.us
$ patch --remove-empty-files -p0 < ../wp.diff
$ svn revert wp-config.php
$ svn add `svn status|grep '^?'|sed -e 's/\?//'`
$ svn rm `svn status|grep '^!'|sed -e 's/!//'`

Then, after a few changes to my template files to play nice with WP’s new built-in tagging system, everything was running again.

BigSmoke.US is no longer mine

Since my three previous posts [1, 2, 3], I’ve made over 7 phone calls to the US, alternating between Wild West Domains and NeuStar. And it turned out that, no, I’m not allowed to have a dot-US domain. So I gave it away.

My father has a great cousin, Roel, who has been a US citizen for the greatest part of his life. Having spent his career wiring mainframes for IBM, he can also be called computer literate. I gave my domain to him and he was kind enough to allow me to keep using it for my websites.

It was the first phone call with NeuStar when I was told that I would, under no circumstances, be allowed to own a .US domain myself. I was also told that this could easily be emended if I could find a US representative for myself to whom I could transfer the domain if I would be lucky enough that the domain wasn’t locked.

That led me to my father’s cousin Roel from Maryland. He’s an absolutely great guy who’s always friendly and willing to help. He accepted ownership of what was then still my domain.

Naively, I tried to transfer my domain using Wild West Domains (WWD). Because it had previously been locked on authority of NeuStar, I tried to unlock it but nothing happened. A call with WWD quickly revealed the cause: NeuStar had put a hold on my domain, meaning that nothing could be done to it until NeuStar removed the hold.

When explaining my situation during my next call with NeuStar, I was first being told that transferring my domain wasn’t allowed. When I brought into recollection that I had been told that it was a proposed solution, my friendly helper disappeared from the phone to talk to other support workers. The outcome was that they would remove the hold if I would fax them a statement of my intend to transfer along with a copy of Roel’s driver’s license to once and for all settle the problem of American citizenship.

Roel went to all the trouble of installing an unused scanner of his to send me his license and I faxed the documents to NeuStar and went to bed. It was AM already.

July 26. The next afternoon, I noticed that, when I tried to unlock the domain, it would again remain stuck in the pending unlock state.

Willy at NeuStar told me that, yes, they had received the papers and, yes, they would remove the hold. (Or they had already removed it; it wasn’t quite clear to me which it was.) Back to WWD: Had I someone screwed up the process by trying to unlock before knowing for sure if the hold had been released? They didn’t know, but they thought it wise to wait a few hours for eventual delays and then see if it still hadn’t been released.

More than a few hours later, I got back to WWD because the unlock was still pending. They couldn’t make sense of it so the issue got reported to technical support and they passed it on to advanced technical support.

A day or so later, the issue still wasn’t resolved, so I made another call. They were working at it and I would be notified as soon as it was resolved. Of course, a few days later I harassed them again to be sure this issue wasn’t somehow forgotten.

Finally, the issue was resolved on August 1:

Dear Sir/Madam,

Our advanced tech support has reviewed the domain bigsmoke.us. We have made the necessary updates to ensure this domain is active and resolving correctly. Please let us know if we can assist you further.

Regards,
David S.
Advanced Technical Support

I quickly updated all the contacts for what is now no longer my domain. Thanks for letting me use your new domain, cousin Roel!

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑