I already wrote about sending mails with ssmtp, a simple alternative to sendmail. But since I got a few questions (and I tend to forget myself) how to use ssmtp’s revaliases-file, here is a short reminder:
/etc/revaliases, allows you to map a local user to a specific ‘From:’ address on outbound mail and to route that mail through a specific mailhub. But it will not rewrite the ‘To:’ address according to the local user who should receive the mail.
Usually, you would add aliases to /etc/aliases to ensure that a local user (receiving a mail) is mapped to a valid eMail address. But as the documentation clearly says (if you actually read it), ssmtp does not use /etc/aliases.
The solution turns out to be letting mail handle the alias – which is done by configuring aliases in /etc/mail.rc
set ask askcc append dot save crt
ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via Delivered-To
alias root root<yourname@domain.com>
alias localuser localuser<yourname@domain.com>
You can test it with with:
# echo test | mail -s "testing ssmtp" localuser
The mail will actually be delivered to yourname@domain.com (since ‘localuser’ is mapped to this address in /etc/mail.rc).
Enjoy!
Resources:
http://www.linux.com/archive/feature/132006
http://greybeardedgeek.net/?p=17
Well, there is no native command (at least, afaik), but you can use find to easily identify empty folders (which maybe helpful for maintenance, etc.):
# find /path -type d -empty
Find empty folder and list
# find /path -type d -empty -exec ls -ld {} \;
Find empty folder and save as temporary file
# find /path -type d -empty -exec ls -ld >> /tmp/savefiles.txt {} \;
Find empty folder and delete
# find /path -type d -empty -exec rmdir {} \;
q.v. find manpage
If you run mythfrontend 0.22 from RPMfusion, it will automatically try to disable pulseaudio and use the default ALSA output instead. This leads (in most cases) to no audio output at all.
Changing mythtv’s audio output device in the frontend (Utilities/Setup -> Setup -> General -> Audio System -> Audio Output Device) from ‘ALSA:default’ to ‘ALSA:spdif’ worked for me, but then the volume control (internal as well as external) was broken.
But you can easily tell mythtv to stop disabling pulseaudio by setting EXPERIMENTALLY_ALLOW_PULSE_AUDIO=1 in your environment before running mythfrontend.
For example, add an export statement to your .bashrc
echo "export EXPERIMENTALLY_ALLOW_PULSE_AUDIO=1" >> ~/.bashrc
(Of course, if you use another shell, YMMV!)
Set mythtv’s default audio output device to ‘ALSA:default’ and the volume control to Master (instead of PCM) and voilà, sound!
Unfortunately, the Folderpane Tools-plugin I used for rearranging my accounts in Thunderbird isn’t TB3 compatible (yet?!). Although it claims to work with all Thunderbird versions starting from 1.0 it just throws out parsing errors with the current Tunderbird beta.
But the plugin doesn’t do any magic tricks, of course. It simply reorders the accounts in the corresponding preferences file prefs.js. Open the file (usually located in with ~/.thunderbird/[profileName]/prefs.js) with your favourite editor and look for a line like
user_pref("mail.accountmanager.accounts", "account1,account2...
Rearrange the accounts manually and your done.
Note: You may want to close Thunderbird and make a backup of the file before editing it. Just in case…
Resources:
https://addons.mozilla.org/en-US/thunderbird/addon/258
http://advancingsf.blogspot.com/2006/11/reorder-accounts-in-thunderbird.html
Deep down in the Java-API:
http://java.sun.com/javase/6/docs/api/java/io/FileWriter.html
Convenience class for writing character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are acceptable. To specify these values yourself, construct an OutputStreamWriter on a FileOutputStream.
So, if you want to write you XML-Document to a file, for the love of god, don’t use the FileWriter like this:
BufferedWriter bufout = new BufferedWriter(new FileWriter(OUTFILE));
bufout.write(out);
bufout.close();
or you might end up with an XML-file that has a UTF-16 header (encoding="UTF-16") but is encoded completely differently (plain ASCII?! Not sure…).
Insted, use
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(OUTFILE),"UTF-16");
out.write(s);
out.close();
Resources: http://www.malcolmhardie.com/weblogs/angus/2004/10/23/java-filewriter-xml-and-utf-8/
If you don’t need a scaled instance of your BufferedImage in the memory, you can use “on-the-fly scaling”. For example, this custom JComponent can be used to display a BufferedImage and zoom it with the setScaleFactor(..)-method
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
public class ZoomableImage extends JComponent {
private float scaleFactor;
private BufferedImage originalImage;
public ZoomableImage() {
this.scaleFactor = 1;
this.setSize(0, 0);
}
public void setImage(BufferedImage image) {
this.originalImage = image;
this.setSize(image.getWidth(), image.getHeight());
//setSize does repainting, no need to call repaint()
//this.repaint();
}
public void setScaleFactor(float scaleFactor) {
this.scaleFactor = scaleFactor;
this.repaint();
}
@Override
public void paintComponent(Graphics g) {
if (this.originalImage != null) {
Graphics2D g2 = (Graphics2D) g;
int newW = (int) (originalImage.getWidth() * scaleFactor);
int newH = (int) (originalImage.getHeight() * scaleFactor);
this.setPreferredSize(new Dimension(newW, newH));
this.revalidate();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
//RenderingHints.VALUE_INTERPOLATION_BILINEAR);
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
//RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2.drawImage(originalImage, 0, 0, newW, newH, null);
}
}
}
For some benchmarking on the different RenderingHints values see Chris Campbell’s great article The Perils of Image.getScaledInstance()
Resources:
http://java.sun.com/docs/books/tutorial/2d/advanced/quality.html
http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
In short: setSize(..) doesn’t work at all, you’ll need setPreferredSize(..) followed by revalidate()
if (changed) {
//Update client's preferred size because
//the area taken up by the graphics has
//gotten larger or smaller (if cleared).
drawingArea.setPreferredSize(/* the new size */);
//Let the scroll pane know to update itself
//and its scroll bars.
drawingArea.revalidate();
}
Resources: http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html#update
Netbeans’ GUI builder is great. It’s one of the essential features that made me drop eclipse.
But designing accurate GUIs can be a pain in the arse. Especially, when you use the GUI builder with a certain preview Look and Feel (e.g. GTK+) but you application later runs with a completely different L’n'F (e.g. Nimbus). It’s almost certain, that your design will look rather ugly. Unless you want to design your GUI manually (which isn’t a bad idea, btw.), you have to make sure, your design preview and application match.
While changing the L’n'F in your application is quite simple, changing Netbeans’ L’n'F (and therefore the GUI builder’s L’n'F ) is rather tricky. The easiest way is probaly the --laf flag:
$ netbeans --laf Nimbus
If you want to start Netbeans in Nimbus-mode per default, just add --laf Nimbus to netbeans_default_options in ~/.netbeans/6.5/etc/netbeans.conf.
If the file doesn’t yet exists
mkdir -p ~/.netbeans/6.5/etc/
echo netbeans_default_options=\"--laf Nimbus\" >> ~/.netbeans/6.5/etc/netbeans.conf
This is as straightforward as setting up a network printer from Windows.
Go to Start → Settings → Printers and Faxes. Click on Add a printer. Tell the wizard that you wish to add a network printer. Specify that you want to Connect to a printer on the Internet or on a home or office network. Specify the URL of your printer:
http://192.168.0.1:631/printers/printer-name
Where in printer-name you should replace the name of your printer. Complete the installation of your printer by specifying the driver to be used. You should now be able to print from your Windows.
Don’t forget to adjust your /etc/cups/cupsd.conf to allow remote printing or use system-config-printer an click on Server → Settings → Settings → Publish shared printers[...] → Allow printing from the Internet
Resources: http://www.giannistsakiris.com/index.php/2007/11/05/share-printer-connected-to-ubuntu-from-windows-xp-on-virtualbox/
Because CentOS doesn’t pull all dependencies correctly, here is my little memory hook for installing phpmyadmin (and mysql, of course)
rpm -Uvh http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum install php phpmyadmin php-mcrypt php-mbstring mysql-server
After installing the packages, edit /etc/httpd/conf.d/phpmyadmin.conf and add the IP of your admin workstation to the line that begins with Allow from.
For using phpmyadmin with cookie auth, you have to set a blowfish secret in /usr/share/phpmyadmin/config.inc.php:
[...]
$cfg['blowfish_secret'] = 'Secret_Password';
[...]
Update: Added php-mbstring