BigSmoke

Smokes your problems, coughs fresh air.

Page 47 of 52

Crane camera shots with just a tripod

When shooting footage with a motion camera, one of the most important things to achieve to avoid it looking like a home-barbecue video, is stable motion, normally achieved with a crane. A simple way to achieve this, is by retracting one leg of your tripod, and then tilt it forwards and backwards. This video gives a good demonstration. The difference between the tripod shots, and the hand-held shots (the shots made to demonstrate the technique) is astounding.


Video Cam Super Trick! – video powered by Metacafe

Remote pair programming with GNU Screen

I like pair programming. So much, in fact, that I want to do it even if I can’t look over the other person’s shoulder due to some geographical offset. Since I’m a real command-line freak, I can get what I want easily by using GNU Screen.

GNU Screen rehash

If you don’t know GNU screen yet and you ever find yourself using the command-line for an extended period of time, learn it. Now. I’ll name just a few advantages:

  1. You can manage multiple “windows” conveniently even if you don’t have a tabbed terminal emulator, or even when you’re not within a graphic environment such as X.
  2. You can “detach” and “reattach” your Screen sessions and continue exactly where you left. This is very useful if you do your work on a remote server, through SSH, for example. Never by stumped by instable connections again!
  3. But, the feature which is most useful for pair programming is the ability to attach to the same session from multiple terminals.

Starting GNU Screen is very easy. Just type screen at your shell prompt (or screen -S SESSION_NAME if you want your session to have an easy-to-remember name).

Press CTRL+A followed by d to detach. Exit your terminal. Start a new terminal, type screen -r and be amazed that you have your session back. screen -r can take as an argument the name or PID of the screen, which is useful if you have more than one screen running. To get a list of current screen sessions, type screen -ls.

Inviting your observer

The first thing you have to do is to add the following command to your .screenrc file:

multiuser on

If you don’t want to enable multiuser by default, you can also choose to type the command from within Screen each time that you need it. This is done by pressing Ctrl+A, followed by : and the command.

Myself, I prefer to have the command in my .screenrc. You need to admit users explicitly anyway. Admitting full access to a user is done by typing the :acladd USERNAME command (after pressing Ctrl+A). Then the given user can join this session by starting screen with screen -x SESSION_OWNER/ where SESSION_OWNER is the driver.

Get out of my driver’s seat! (Dealing with annoying observers)

The :acladd USERNAME command will give the observer full read-write access. Maybe, if you have to deal with an observer who insists on taking the driver seat, you want to limit his or her access to read-only. This can be done just as easily: press Ctrl+A; then type :aclchg USERNAME -w "#".

Make your terminals match

Using a shared screen, it can be kind of annoying if your terminal sizes don’t match. As an observer, I fix this by asking the driver to tell me the values of the $ROWS and $COLS environment variables. If then, for example $COLS=110 and $ROWS=40, I start my xterm with this in mind: xterm -geometry 110x40

Have fun with Screen!

I’ve only touched upon some of the things you can do with screen. The manual page contains much more information—perhaps a bit too much even. ๐Ÿ˜•

One of the things I also like to do with a shared screen session is remote system administration. If I want to perform delicate tasks as root, I find it kind of comforting if someone can stop me in time, before I do anything stupid. Besides, if you’re both root, you don’t even have to set permissions. ๐Ÿ™‚ So, it’s easy to.

Hardwood Investments Wiki

Before the company was forced by the Netherlands Authority for the Financial Markets (AFM) to seize most of its activities, Sicirec had always used it website to provide teak investors with a somewhat independent view of the hardwood investment market. It has to be said that Sicirec’s critical view on the management of various teak plantation made the company a little unpopular with said managers (such as Ebe Huizinga of Flor y Fauna fame).

Screenshot of my Hardwood Wiki

Like I said, Sicirec had to suspend most of her activities as an intermediary by mandate of the AFM. In order to survive and to continue the realization of their philosophy the company had to reorganize and focus on new projects. Where previously they had been focused on servicing the interests of a investments in third-party projects over which they had little to no control, they’re now developing their own projects (and also are still offering investments in the Sicirec Forestry Mixfund, which is the only investment option that remains of the old organization form).

As a previous Webmaster of www.sicirec.org, I had never been entirely satisfied by the limited possibility to really effectively inform all types of hardwood plantation investors within the constraints of a company website. That is why, during the final website cleanup round, before I resigned as Webmaster, I started a wiki about hardwood investments independently of Sicirec. With permission by Popko van der Molen, my dad and then director of Sicirec SA, I used much of the existing information about the various plantation companies that Sicirec maintained on their website as the seed content for this wiki.

Actually, most of the seed content was in Dutch, so after translating some of it for the English language wiki, I started a Dutch language version sister wiki and copied most of the content there. Since then (May, 2007), the Dutch version has grown to 500 pages, while the English version has remained at a meager 77 pages.

If you have anything you want to know or say about hardwood investments, you might like one of my wikis:

Using Caps Lock as an extra Control key

With me mostly posting about computer stuff on this weblog, it might surprise you that, until May this year, I hadn’t owned a personal computer in years while the last one that I did own was a slow pig grown from some old parts of an even slower pig and some second-hand replacements. So, you can image my joy when I got a shiny, new Lenovo Thinkpad 61 this spring.

One of the joys of once more owning a personal computer is that I don’t have to live through PuTTY anymore. (I used to SSH to the local Debian server here if I wanted to get anything done.) I’ve reacquainted myself with Gentoo and I’m loving it. Of course, there’s a lot more to configure than with Ubuntu (which supports the T61 very neatly out of the box), but that’s the whole point; I want to be able to configure everything my way and I want to update my knowledge about how Linux systems are made up these days. Control.

On the topic of control, the Control key on the Lenovo keyboard, as with many laptop keyboards that I’ve encountered, is in a bit of an awkward position, squeezed to the right by the Function key. Since, I very much depend on the Control key for shortcuts (in just about anything, but especially in libreadline-based programs), I decided to change the Caps Lock key to be an extra Control key. I’ve never actually used the CapsLock key in my life, I probably never will, older keyboards used that very spot for the Control Key, and why not? It’s a much better spot, requiring less gymnastics for my little pinky to reach. Once I considered this I was actually puzzled about why I’ve always wasted such an well-accessible key position.

X

On to the configuration. I wanted this to work in both Console mode and in X. But first X. In the xorg.conf, I went to the InputDevice section for my keyboard and added ctrl:nocaps to XkbOptions. The full XkbOptions line now reads:

Option "XkbOptions" "ctrl:nocaps,altwin:menu,compose:ralt,eurosign:e"

That’s it. I had to take a few more steps to get it to work in the console also.

Console

First, I created a file called “/etc/extra-key-conf” with the following contents:

keymaps 0-15
keycode 58 = Control

Then I added the following to /etc/conf.d/local.start. This is a Gentoo specific script that is loaded by /etc/init.d/local.

[ -z "$DISPLAY" -a -e /etc/extra-key-conf ];
        loadkeys /etc/extra-key-conf &>/dev/null

What this does is to check if the $DISPLAY variable isn’t set (of which we can be sure in this context, but may be useful if you plan to copy this snippet). It also checks if /etc/extra-key-conf exists. If both conditions are satisfied, loadkeys is called with that file as its argument.

In conclusion

I can really recommend this configuration even if your Control key is not awkwardly positioned on your keyboard. Do you use your Caps Lock key? Regularly? If you don’t, this will make your keyboard use more effective.

Reference

If you want to read into this more extensively, I recommend the Remap Caps Lock article from the Portland Pattern Repository.

My CD-RW drive can read everything it writes

The HL-DT-ST CD-RW/DVD drive in my Lenovo T61 laptop, has a certain peculiarity. I was burning an ISO image, wich exceeded the supported size of a standard 80 minute CD by 7 MB. (The image was 707 MB.) Using cdrecord with the -overburn option seemed to work, until I tried to mount the CD-ROM. It would inevitably—

# mount /dev/cdrom /mnt/cdrom -t iso9660
mount: block device /dev/sr0 is write-protected, mounting read-only

Well, that is unexpected! I was going to write that it would refuse with some errors in dmesg about trying to access data beyond some boundary. But I probably messed up something very trivial, because I just can’t seem to reproduce the error in any way as the mount result above shows.

Let’s backtrack everything I did to try to fix this problem.

First, after numerous attempts to mount the 700 MB sized CD, I gave up and asked my little sister to bring me my stack of 800 MB CDs next time she’d come. Of course, over a week went by without her remembering to take the CDs. But eventually, I picked them up myself.

Having retrieved the 800 meg CDs, it came time to test them. Burning went well. Then mounting… A failure with dmesg showing the familiar error (which I now can’t look up because I can’t reproduce the problem ๐Ÿ˜› ). Mounting it in the local server’s drive worked fine, though, leading me to think that my burner can’t read CD-ROMs it has written with overburn enabled.

Luckily, I was wrong. But I really don’t understand why I did get the errors at first. Sure, I did notice a faulty entry in my fstab, but I had also tried mounting it without relying on the fstab (i.e., with mount -t iso9660 /dev/cdrom /mnt/cdrom), which begot me the same error… Also, I had mounted plenty of CDs before this adventure.

All I can do to explain this is to concede that this is one of those problems where you usually call a geek friend telling them you can’t get something to work. They’ll reply by asking you have you tried this and that? Of course I have, at least twice, in the exact same sequence as you describe! Well, humour me then, and try it once more… Fuck! Fuck! Fuck! And why didn’t it work 10 minutes ago?! Don’t tell me you’ve never had this happen to you. Please?

In conclusion, after finding out that the 800 MB CD did work on my laptop, I reclaimed the 700 MB CD as well (which was now serving as a hawk-deflector in the coop) to find out that, even after being exposed to lots of rain and sun for over a week, this CD also mounted without hesitation.

New theme

After upgrading to WordPress 2.5.x, I had to fall back on a stock theme because my old customization of the Sandbox theme no longer worked with the upgrade. But, then, it was time to redo my theme anyway. So here you’re looking at the first version of my new theme. I might have let it stabilize some more before putting it on-line, but who cares? My reader maybe? Let’s just hope he or she doesn’t use IE. ๐Ÿ˜‰

Screencap of my new WP theme Screencap of my new WP theme Screencap of my new WP theme Screencap of my new WP theme Screencap of my new WP theme

Vertical navigation

Ever since the first time that I saw a blog which featured vertical navigation instead of the typical columns, I’ve wanted to implement this for myself. Well, finally…

Site-wide elements use the complete width of the page. The page content is centered in the middle at 87.5%. The identity stuff in the header and the navigation in the footer sits against a back blackground while the content area has the proven black on white for easy reading. I hope that the strong color-contrast as well as the clear difference in with between site-wide elements and page content makes it easy to keep focused on either reading or navigating without distractions.

… and a talkative footer

With this theme, I didn’t want another footer which consist of the odd logo and some loose copyright statements. I wanted a footer which you can actually read, even understand. And who cares if it takes up a little space? It’s at the bottom of the page.

Related posts

I’ve written an (unpublished, unpolished) plug-in which can generate a list of posts that are chronologically related. Traditionally, most blogs have a next/previous post link at the top and bottom of each post. This works very well if you limit your blog to one subject (which is really a very good idea anyway), but if, like mine, your blog is a little bit messy, you could say that someone who stumbled here searching for an article about Subversion is not necessarily interested in the next post if this is a photo of my baby niece.

Hence the chronologically related posts plugin. With this plugin I can say wether I want a link to the first, previous and next post in the blog, within the same category, or matching a given number of tags. (The tag matching isn’t implemented yet, though. Also, matching on meta fields would be a kick-ass ass way to support explicit sequences.)

I put the list generated by this plug-in on top of a blue background besides the various context links of the post.

Issues left

I hope to have the first major revision of my theme ready soon. Here’s a list of some issues that I might address:

  • The CSS renders a bit psychedelically in MSIE 6 (only version I tested) at the moment. Sigh… Let’s just hope that IE 7 will give better results. Then I’ll gladly drop the IE 6 support.
  • When viewing a category, the tag cloud in the navigation panel at the bottom only shows tags for that category. This has to do with the use with me calling the st_tag_cloud() from within the category template.
  • Some of the elements that I just showed to you don’t really look that good and most elements that I didn’t can be said to be … hideously ugly. ๐Ÿ˜• Some highlights: the header (should really be a few cool images), the comment form, and the Next/Previous Page links.

Comment!

I’d almost forget all about the clean, new look of the comment list. And, if you register a Gravatar, your comments will be accompanied by your avatar. Try it. Please!

The joys of being well-known to Google

The “Places” system in the new Firefox 3 is great. I’m still getting more effective usage out of just the location bar every day. But, sometimes I’m on a different computer, or I haven’t been to one of my web pages for a very long time.

How cool is it then that I can just Control+K to my Google search box and enter: bypassing smart completion to get my own page on the top of the result list?

Since my blog is literally a log that I mostly use to keep track of what I think and do while problem-solving, it’s great that I can rely on Google to find my way through memory lane.

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.

Creating a bash fork bomb

Logged into a Unix machine? Does “ulimit -a” say that the max number of user processes is unlimited? Then type the following to crash the machine (provided it uses bash, or another shell with compatible syntax):

:(){ :|:& };:

What does it do? It creates a function named “:”, which calles itself, and sends the output to itself.

You’d better find out how to protect your machine if it also states that the max number of user processes is unlimited. Even a hight limit can be dangerous, such as 15000.

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑