Smokes your problems, coughs fresh air.

Category: Technology (Page 44 of 47)

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.

Setting up a domaincontroller with Samba

I occasionally have to set up a domain controller using Samba. There are a lot of guides and howto’s available, but I made a step-by-step howto just for myself, and I thought it’d be smart to make it available on the internet for me to access anywhere.

These commands have only been tested on Debian. Some distro’s may do thing a little differently, especially when it comes to adding/modifying users and groups.

  • Create a Unix group for ntadmins:
    # groupadd ntadmins
  • And assign root to that group:
    # usermod –append –groups ntadmins root
  • Add the root user to the smb users (use a different password than the Unix root password!):
    # smbpasswd -a root
  • Map Samba groups (the rid is important!):
    # net groupmap add ntgroup=”Domain Admins” unixgroup=ntadmins rid=512 type=d
    # net groupmap add ntgroup=”Domain Users” unixgroup=users rid=513 type=d
    # net groupmap add ntgroup=”Domain Guests” unixgroup=nobody rid=514 type=d
  • Add normal user accounts which can login in the domain controller (without home dirs or shells):
    # useradd -d /dev/null -s /bin/false example_username
    # smbpasswd -a example_username

When adding a machine to the domain, it will ask for a username and password. Use the root username you’ve added to smbusers here. The normal user accounts are for when the machine is successfully added to the domain, and asks for user login.

The following is an example config file, with some comments:

[global]
  ; When using domains, the workgroup is the domain name
  workgroup = my_domain
  server string = my_server (Samba server %v)
  security = USER
  encrypt passwords = true
  os level = 65
  domain master = yes
  local master = yes
  preferred master = yes
  domain logons = yes
  panic action = /usr/share/samba/panic-action %d
  guest account = samba
  log file = /var/log/samba/log.%m
  max log size = 1000
  syslog = 0
  dns proxy = no

  ; Location of NT/2000/XP profiles. %L expands to the servername, %u to the user.
  ; You may also want to put in %m, which expands to the machine name, to have a 
  ; separate account for each machine. With only identical machines, it's useful to have
  ; a "roaming" profile, but you can imagine what happens when you login on a Windows 
  ; 2000 machine with an account that actually belongs to a Windows XP machine...
  ; or, even simply on machines with different versions of software packages installed.
  ; update: I think it should actually be %U. And, you may want the machine name in the path:
  logon path = \\%L\profiles\%m\%U
  ; logon path = \\%L\profiles\%u ; old one, before update.
  logon script = logon.bat

  time server = yes

  ; I don't let useradd create home dirs. I prefer to do that myself. 
  add user script = /usr/sbin/useradd -d /dev/null -s /bin/false %u
  ; I intentionally leave out -r (remove home dir) because I don't accidentally
  ; want to remove home dirs when I happen to remove domain users 
  ; which are also unix users. Also, it means that if a user is recreated, 
  ; its data is accessible again.
  delete user script = /usr/sbin/userdel %u
  add group script = /usr/sbin/groupadd %g
  delete group script = /usr/sbin/groupdel %g
  add user to group script = /usr/sbin/usermod -a -G %g %u
  ; how does one delete a user from a group...? There doesn't seem 
  ; to be a command for that...
  ;delete user from group script = /usr/sbin/ %u %g
  add machine script = /usr/sbin/useradd -s /bin/false -d /dev/null %u

[netlogon]
  ; You can add netlogon.bat here, the logon script executed by the client.
  path = /var/lib/samba/netlogon
  writable = no
  browsable = no

[profiles]
  ; This path should be chmod 777
  path = /home/samba-nt-profiles/
  browsable = no
  writable = yes
  ; You can choose to make these 0660 and 0770. If you force group = samba and put all your samba users in it, that can be convenient. It is a must when you have the machine name in the profile path, otherwise, only the first user can login on a machine.
  create mask = 0600
  directory mask = 0700

The useradd commands are for when a domain admin asks for users to be created and such. The only one I’ve needed in practice, it would seem, is the add machine script. When I add a machine called “butter” to the domain controller, this command will automatically create a user called “$butter” in your /etc/passwd, and the machine can login.

An example command to put in the netlogon.bat, is:

net use o: "\\server\networkshare"

The reason is obvious, I would say :).

An example network share accessible to anyone is:

[our_documents]
  comment = Central storage for all our documents
  path = /home/samba-our-documents
  guest ok = yes
  writeable = yes
  browseable = yes
  force group = samba
  create mask = 0660
  directory mask = 0770

And, a network share for an individual domain user with full access for that user, but read-only to the rest:

[Johns_documents]
  path = /home/samba-john-documenten
  guest ok = yes
  writeable = yes
  browseable = yes
  force group = samba
  create mask = 0640
  directory mask = 0750

I believe this is it. I will update the post with relevant info in the future.

Playing Quake3 in Linux with Skype or Teamspeak

I wanted to play a game of Quake3 against someone, and have Skype or Teamspeak open at the same time, for obvious reasons. Somehow, it reported the sound device being in use: “device or resource busy”. This doesn’t make any sense, because my card can do hardware mixing, and also because all other games work fine with Skype or Teamspeak active.

I don’t know exactly what’s going on, but this is how it can be fixed:

# echo "quake3.x86 0 0 direct" > /proc/asound/card0/pcm0p/oss
# echo "quake3.x86 0 0 disable" > /proc/asound/card0/pcm0c/oss
# echo "quake3-smp.x86 0 0 direct" > /proc/asound/card0/pcm0p/oss

Happy fragging ๐Ÿ™‚

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑