Marius van Witzenburg Remember yesterday, dream over tomorrow. But live to day!

10May/130

How to optional include config files in Apache

Posted by mariusvw

If you want to easy manage sites in separate configurations it might become handy to simply include them in the httpd.conf instead of defining the VirtualHosts in your httpd-vhosts.conf every time.

The following will include all files not starting with a hash character in the sites directory.

# Only include files not starting with a hash
Include /usr/local/etc/apache22/sites/[^.#]*.conf

Of course you still need to check for configuration errors using apachectl -t

My advice for naming the config files is as follows:

  • nl_kitara.conf
  • nl_kitara_subdomain.conf
  • nl_kitara_sub-domain.conf

You might notice that I write the names in reverse, I do this so all the configs of one domain are sorted next to each other.

Of course you can make your own way of writing it down :-)

9May/130

How to fix greyed out directories after a failed copy in Finder

Posted by mariusvw

Ever had that you were copying some files over network and the connection failed and you get stuck with some directories who are greyed out and inaccessible?

By default Mac OS X first locks the directories until the content is fully copied. When the network drops the copy stalls and those directories sometimes remain locked.

Use the following command to fix one of those directories:

SetFile -d `date +"%m/%d/%Y"` DirName

Or use the following to fix it for all directories on the first level.

find . -maxdepth 1 -type d ! -path './.*' | xargs SetFile -d `date +"%m/%d/%Y"`
9May/130

How to format a USB stick in FreeBSD

Posted by mariusvw

Usually I only use 2 types to partition an USB drive, UFS or Fat32.

For UFS2 you run the following where da0 is your USB drive.

gpart destroy -F da0
gpart create -s gpt da0
gpart add -t freebsd-ufs da0
newfs /dev/da0p1

And for FAT32 you almost run the same commands.

gpart destroy -F da0
gpart create -s mbr da0
gpart add -t fat32 da0
newfs_msdos -L FILES -F 32 /dev/da0s1

Notice that you can change the label of the drive to your own preferred name.

9May/131

How to use regular expressions (regex) in MySQL

Posted by mariusvw

Sometimes it might be useful to use regular expressions instead of using a LIKE statement.

Here some examples how you can use it.

Load data where the data only may contain alpha characters:

SELECT `id`, `field` FROM `table` WHERE `field` REGEXP '[a-z]';

Load data where the data only may only contain lowercase alpha characters:

SELECT `id`, `field` FROM `table` WHERE binary `field` REGEXP '[a-z]';

Load data where the data only may only contain digits:

SELECT `id`, `field` FROM `table` WHERE `field` REGEXP '[0-9]';

Load data where the data only may contain uppercase alpha characters:

SELECT `id`, `field` FROM `table` WHERE binary `field` REGEXP '[A-Z]';

For some more examples and information you might want to visit the MySQL website.
See: 12.5.2 Regular Expressions.

3May/130

How to lower-/uppercase characters of content in MySQL tables

Posted by mariusvw

Only uppercase first character

UPDATE `theTable` SET `theContent` = CONCAT(UPPER(SUBSTRING(`theContent`, 1, 1)), SUBSTRING(`theContent`, 2));

Lowercase all and only uppercase the first character.

UPDATE `theTable` SET `theContent` = CONCAT(UPPER(SUBSTRING(`theContent`, 1, 1)), LOWER(SUBSTRING(`theContent`, 2)));
Page 1 of 4312345678910...203040...Last »
%d bloggers like this: