Sunday, November 1, 2009
removing the texture of old pictures with FFTs
Imagej (http://rsbweb.nih.gov/ij/) has an awesome feature that allows you to perform an FFT on an image, edit it, and then do an inverse FFT. This is very useful for eliminating patterns from an image, such as the texture of old photographs.
Full size images for further comparison:
http://www.flickr.com/photos/ftzdomino/4065410668/sizes/o/
http://www.flickr.com/photos/ftzdomino/4064662889/sizes/o/
Monday, October 12, 2009
Booting to a raid volume using jfs
While upgrading an older debian server, I had to make some modifications to get the kernel booting. This shouldn't normally be necessary, but for some reason the hardware was not getting auto detected. I'm almost 100% sure I messed up some other step in order to require this. The system's root drive is raid1 and uses jfs. The following changes were done:
Added: /etc/initramfs-tools/modules:
jfs
raid1
md
Created:
/etc/initramfs-tools/scripts/local-top/probes
#!/bin/sh
modprobe raid1
modprobe md
modprobe jfs
mknod /dev/md2 b 9 2
mknod /dev/md0 b 9 0
mknod /dev/md1 b 9 1
mdadm --assemble --scan
The above script must be chmod +x'd. I copied to it /etc/initramfs-tools/scripts/local-top/probe/local-premount/ just to make sure it ran.
Modified /usr/sbin/mkinitramfs in the #modutils section:
copy_exec /sbin/mdadm /sbin
copy_exec /sbin/fsck.jfs /sbin
mkdir -p "${DESTDIR}/etc/mdadm"
cp -a /etc/mdadm/mdadm.conf "${DESTDIR}/etc/mdadm/"
The above changes were done by booting into the rescue mode of a debian installer and mounting.
Added: /etc/initramfs-tools/modules:
jfs
raid1
md
Created:
/etc/initramfs-tools/scripts/local-top/probes
#!/bin/sh
modprobe raid1
modprobe md
modprobe jfs
mknod /dev/md2 b 9 2
mknod /dev/md0 b 9 0
mknod /dev/md1 b 9 1
mdadm --assemble --scan
The above script must be chmod +x'd. I copied to it /etc/initramfs-tools/scripts/local-top/probe/local-premount/ just to make sure it ran.
Modified /usr/sbin/mkinitramfs in the #modutils section:
copy_exec /sbin/mdadm /sbin
copy_exec /sbin/fsck.jfs /sbin
mkdir -p "${DESTDIR}/etc/mdadm"
cp -a /etc/mdadm/mdadm.conf "${DESTDIR}/etc/mdadm/"
The above changes were done by booting into the rescue mode of a debian installer and mounting.
Tuesday, August 25, 2009
Installing Windows Server 2008 in VirtualBox
Today I installed a beta Windows Server 2008 onto a virtual machine on my Mac using VirtualBox. After some trial and error, the following settings seem to have allowed it to work:
System:
OS Type: Windows 7 (64 bit)
Base Memory: 500 MB
Processors: 1
VT-x/AMD-V: Enabled
Nested Paging: Enabled
Display:
Video Memory: 12MB
3D Acceleration: Enabled
System:
OS Type: Windows 7 (64 bit)
Base Memory: 500 MB
Processors: 1
VT-x/AMD-V: Enabled
Nested Paging: Enabled
Display:
Video Memory: 12MB
3D Acceleration: Enabled
Thursday, August 20, 2009
Blocking spam from Yahoo! Personals
I get approximately 10 messages a day from Yahoo! Personals, which pass through spamassassin because they're DKIM signed. As far as I can tell, there's no way to opt out on Yahoo's end, so I had to resort to blocking every message with their telltale subject. Here's the rule:
header SUBJECT_YAHOO_PERSONALS Subject =~ /Dating 101: Reviving Your Relationship/i
score SUBJECT_YAHOO_PERSONALS 20.0
header SUBJECT_YAHOO_PERSONALS Subject =~ /Dating 101: Reviving Your Relationship/i
score SUBJECT_YAHOO_PERSONALS 20.0
Thursday, June 25, 2009
Debian Installation on Servers With Broadcom 5708/5709 NICs using the bnx2 driver
Installing Debian on a system with Broadcom network interfaces can be quite annoying because the firmware is no longer included. If you load the firmware onto a usb disk as suggested, you run into other problems when using scsi drives resulting in a system which requires hacking menu.lst after install to boot. This approach doesn't work if you're using iLO/DRAC/iDRAC to install as they only allow one remote media connection at a time.
An easy workaround is to modify your install iso to contain the drivers. Here's how:
You can now burn this iso to a CD or use it as virtual media.
There's one final step, which is getting the OS to see the firmware drivers.
Once booted to the new ISO, you need to immediately switch to another console and copy the files over before the installer looks for them:
An easy workaround is to modify your install iso to contain the drivers. Here's how:
- Download a newish Debian install iso.
- Mount the install iso:
- mkdir cdrom
- mount -o loop debian-testing-amd64-CD-1.iso cdrom
- Copy the files:
- mkdir isocopy
- cp -av cdrom isocopy
- Download the appropriate firmware package for your installation, such as http://packages.debian.org/squeeze/all/firmware-bnx2/download
- Extract the drivers and copy into your new iso:
- dpkg-deb -x firmware-bnx2_0.16_all.deb firmware
- cp firmware/lib/firmware/* isocopy/cdrom
- Build a new iso:
- cd isocopy/cdrom
- mkisofs -o ../modified-debian.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V disks .
- Done, let's look at our new iso:
- cd ..
- ls modified-debian.iso
You can now burn this iso to a CD or use it as virtual media.
There's one final step, which is getting the OS to see the firmware drivers.
Once booted to the new ISO, you need to immediately switch to another console and copy the files over before the installer looks for them:
- mkdir lib/firmware
- cp /cdrom/*.fw lib/firmware
Monday, June 15, 2009
php utf-8 chr() and ord() equivalents
As far as I can tell, PHP provides no built in methods of working with multi byte characters.
Here is a simple function for turning an integer value into a character:
function unichr($intval) {
return mb_convert_encoding(pack('n', $intval), 'UTF-8', 'UTF-16BE');
}
A uniord() function can be found in the comments of the PHP manual:
http://us.php.net/manual/en/function.ord.php
Here is a simple function for turning an integer value into a character:
function unichr($intval) {
return mb_convert_encoding(pack('n', $intval), 'UTF-8', 'UTF-16BE');
}
A uniord() function can be found in the comments of the PHP manual:
http://us.php.net/manual/en/function.ord.php
Monday, May 25, 2009
"This PDF document contains an Adobe XML form. Such files cannot be optimized."
To fix this problem:
- Save the document in LiveCycle with PDF compatibility
- Use the drop_xfa command with pdftk
Tuesday, March 31, 2009
Some useful MegaCli commands/quick debian howto
MegaCli and MegaCli64 are the LSI utility used for Dell Perc 5 and other adapters isn't well documented. Here's some commands:
MegaCli -AdpEventLog -GetEvents -f logfile -aALL
What it does: Dump all events from the adapters event log to a file named logfile
MegaCli -PDList -aAll | less
What it does: Dump information about all Phsyical Disks (hence the PD), paged with less
MegaCli -LDInfo -LAll -aAll | less
What it does: Dump information about all Logical Disks on all adapters, paged with less
MegaCli -LdPdInfo -aAll | less
What it does: Dump information of all logical and physical disks on all known adapters
Currently these can be obtained from LSI at http://www.lsi.com/DistributionSystem/AssetDocument/support/downloads/megaraid/miscellaneous/linux/1.01.39_Linux_Cli.zip
You don't need to actually install the packages, both the MegaCli and MegaCli64 (64 bit build) are statically linked within. In order to access them in a non RPM environment, you can extract the files with the following command:
rpm2cpio MegaCli-1.01.39-0.i386.rpm | cpio -idmv
This will extra the MegaCli and MegaCli64 executables.
Alternately, you can try to convert the rpm to a .deb via alien.
MegaCli -AdpEventLog -GetEvents -f logfile -aALL
What it does: Dump all events from the adapters event log to a file named logfile
MegaCli -PDList -aAll | less
What it does: Dump information about all Phsyical Disks (hence the PD), paged with less
MegaCli -LDInfo -LAll -aAll | less
What it does: Dump information about all Logical Disks on all adapters, paged with less
MegaCli -LdPdInfo -aAll | less
What it does: Dump information of all logical and physical disks on all known adapters
Currently these can be obtained from LSI at http://www.lsi.com/DistributionSystem/AssetDocument/support/downloads/megaraid/miscellaneous/linux/1.01.39_Linux_Cli.zip
You don't need to actually install the packages, both the MegaCli and MegaCli64 (64 bit build) are statically linked within. In order to access them in a non RPM environment, you can extract the files with the following command:
rpm2cpio MegaCli-1.01.39-0.i386.rpm | cpio -idmv
This will extra the MegaCli and MegaCli64 executables.
Alternately, you can try to convert the rpm to a .deb via alien.
Sunday, March 29, 2009
Tuesday, March 10, 2009
One cause of "Fatal error: Exception thrown without a stack frame in Unknown on line 0"
"Fatal error: Exception thrown without a stack frame in Unknown on line 0" can be quite hard to debug.
php -r '
register_shutdown_function("a");
function a() {
$b = new DateTime("02/40/2009");
} '
Results in:
Fatal error: Exception thrown without a stack frame in Unknown on line 0
The problem is that PHP does not allow exceptions to be thrown in a shutdown function or anything called by a shutdown function. Initializing a DateTime object with an invalid date throws an exception, leading issues similar to above.
php -r '
register_shutdown_function("a");
function a() {
$b = new DateTime("02/40/2009");
} '
Results in:
Fatal error: Exception thrown without a stack frame in Unknown on line 0
The problem is that PHP does not allow exceptions to be thrown in a shutdown function or anything called by a shutdown function. Initializing a DateTime object with an invalid date throws an exception, leading issues similar to above.
Friday, February 27, 2009
Fun with PHP implicit scoping on static calls
class a {
public $a = "yay!";
func call_b()
{
b::b();
}
}
class b {
function b()
{
echo $this->a;
}
}
$a= new a();
$a->call_b();
Prints:
yay!
This is because if you statically call a method that is not declared as static in PHP, it inherits the class scope of the caller. Note that if you had declared function b as a static method, you'd get a different behavior.
public $a = "yay!";
func call_b()
{
b::b();
}
}
class b {
function b()
{
echo $this->a;
}
}
$a= new a();
$a->call_b();
Prints:
yay!
This is because if you statically call a method that is not declared as static in PHP, it inherits the class scope of the caller. Note that if you had declared function b as a static method, you'd get a different behavior.
Wednesday, February 25, 2009
Apple Wireless Keyboard + Ubuntu Intrepid
I had some trouble pairing at first, but found this to work:
- Turn keyboard off
- Open up the new bluetooth device wizard
- Turn the on
- Select the keyboard
- Click Next
- While the wizard is waiting, enter 0000 and Enter on the keyboard
- Enter 0000 and Enter a second time.
Tuesday, February 10, 2009
Fun with implict type conversions in PHP
PHP requires extreme care while programming. For example:
'1,234' * 1 == 1
0 == false
false == ''
0 == '0'
false != '0'
'1,234' * 1 == 1
0 == false
false == ''
0 == '0'
false != '0'
Subscribe to:
Posts (Atom)