Debian and Ubuntu Networking Configuration /etc/network/interfaces with a Static IP Address

This is easy to find anywhere, and it’s here too. This one includes the dns-* lines that will be read by resolvconf(8).

root@server:/etc/network# cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.251
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254
dns-nameservers 192.168.1.250
dns-search mydomain.local

Also, here’s a cheatsheet for setting that netmask:

255.255.255.252  /30    2  nodes
255.255.255.248  /29    6  nodes
255.255.255.240  /28   14  nodes
255.255.255.224  /27   30  nodes
255.255.255.192  /26   62  nodes
255.255.255.128  /25  126  nodes
255.255.255.0    /24 "Class C" 254 nodes

Note that the number of nodes is the total number of addresses, less two. It’s less two because the lowest value is the address of the entire network. The highest value is the broadcast address. So if the netmask is 0, then the lowest value is 0, and that’s the address of the network, and the highest value is 255, which is the broadcast address.

Make Meme/LOLCats Text with the GIMP

This tutorial explains how to make the “LOLCats” or “Meme” font so popular with the kids today. You can see a lot of these on the 4Chan /b/ channel, but don’t go there if you have any illusions that our society isn’t full of degenerates. The meme font is Impact Condensed, but to get the right “look”, you need to create a black outline around the regular font letters. Continue reading “Make Meme/LOLCats Text with the GIMP”

Magic Folder to Convert DOC and OpenOffice to PDF

Most of the information in this post is derived from http://www.tech-faq.com/convert-word-to-pdf.html. The code’s reposted here as a service, because the code there needs some editing.

Also, a useful thread about executing OOo macros is at http://www.oooforum.org/forum/viewtopic.phtml?t=2619.

Here’s the code to automate the opening and saving of a file as PDF, using Open Office. Paste this into your standard macros.

[code]
Sub ConvertWordToPDF(cFile)
cURL = ConvertToURL(cFile)
‘ Open the document.
‘ Just blindly assume that the document is of a type that OOo will
‘ correctly recognize and open — without specifying an import filter.
oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array(MakePropertyValue("Hidden", True), ))
cFile = Left(cFile, Len(cFile) – 4) + ".pdf"
cURL = ConvertToURL(cFile)
‘ Save the document using a filter.
oDoc.storeToURL(cURL, Array(MakePropertyValue("FilterName", "writer_pdf_Export"), ))
oDoc.close(True)
End Sub

Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function

sub test()
ConvertWordToPDF("file:///home/johnk/Desktop/cooking websites article.odt")
end sub
[/code]

To use this macro, you should execute it from the command line. Here’s a shell script that helps.

[code]
#!/bin/sh
DIR=$(pwd)
DOC=$DIR/$1
/user/bin/oowriter-invisible "macro://Standard.Module1.ConvertWordToPDF($DOC)"
[/code]

And last but not least, my addition – a script that watches a folder called pdeffer and converts DOC files to PDF. The only problem is that only simple, textual files with graphics will work. More complex layouts will fail.

To use it, execute it in the background or start it in a “screen” session. It’s not a full-fledged service (and won’t be).

[code]
#! /usr/bin/perl

chdir ‘/home/johnk/pdeffer’;

use Cwd;

%docs = ();
%pdfs = ();

sub main() {
print "checking\n";
opendir DH,’.’;
while( $file = readdir(DH) ) {
if ($file =~ /.doc$/) {
$docs{$file} = 1;
}
if ($file =~ /.pdf$/) {
$pdfs{$file} = 1;
}
}
closedir DH;

foreach $d (keys(%docs)) {
print "$d\n";
$p = $d;
$p =~ s/.doc/.pdf/;
next if ($pdfs{$p});

$filename = getcwd().’/’.$d;
print "$filename\n";

system(‘oowriter -invisible "macro:///Standard.Module1.ConvertWordToPDF(‘.$filename.’)"’);
}
}

for(;;) {
&main();
sleep 10;
}
[/code]