So, I'm basically liking Windows 7. Take everyone's advice and skip Vista. Of course go to http://www.howtogeek.com/howto/windows-vista/disable-caps-lock-key-in-windows-vista/ and disable the stupid CAPS LOCK key. When I needed to add a HP LaserJet 1020 attached to a Mac Mini, I needed to download the "Adobe Universal Postscript Printer Driver" and specify "Generic Postscript Printer" and "http://192.168.1.100:631/printers/HP_LaserJet_1020". Also, Adobe's reader didn't do a good job of printing a pdf to that printer, but foxit it did. Strange.
I'd love to hear the logic behind not being able to do an upgrade from XP to W7 without saving all one's files and doing a clean install.
Friday, November 20, 2009
Wednesday, November 4, 2009
dansguardian on OSX
sudo port install dansguardian
sudo launchctl load -w /Library/LaunchDaemons/org.macports.dansguardian.plist
sudo mkdir /opt/local/var/run
sudo port install squid
sudo launchctl load -w /Library/LaunchDaemons/org.macports.Squid.plist
Once this is done, one has to force the browsers to go through Dans. For Safari, System Preferences -> Network -> Advanced -> Proxies and set localhost and port 8080 to what you want filtered:
For firefox, it's a little more complicated
1) in /Applications/Firefox.app/Contents/MacOS, create a file named firefox.cfg that contains:
//
lockPref("network.proxy.http", "127.0.0.1");
lockPref("network.proxy.http_port", 8080);
lockPref("network.proxy.ssl", "127.0.0.1");
lockPref("network.proxy.ssl_port", 8080);
lockPref("network.proxy.ftp", "127.0.0.1");
lockPref("network.proxy.ftp_port", 8080);
lockPref("network.proxy.type", 1);
2) edit /Applications/Firefox.app/Contents/MacOS/greprefs/all.js and add these two lines:pref('general.config.obscure_value', 0);
pref('general.config.filename', 'firefox.cfg');
You'll need to check these every time you upgrade firefox...
Tuesday, November 3, 2009
MySQL upgrade for FC10 to FC11
I, and many other people apparently, ran into a MySQL bug while upgrading from FC10 to FC11. The error messages included "Fatal error: Can't open and lock privilege tables: Incorrect key file for table 'host'; try to repair it". It looks like there were MySQL v4 tables, and not running an upgrade for 5.0 created a problem for 5.1. Googling found one answer to be downgrading to 5.0, upgrading the tables, upgrading to 5.1 and doing another upgrade. Why either MySQL or FC couldn't do the right thing is beyond me. Anyway, removing the 5.1 libs breaks a lot of other programs, so I took the approach of building and installing 5.0 in /usr/local, doing the upgrade using that set of binaries, then going back to using the 5.1 binaries in /usr. This did the trick. I might have been able to use "rpm --prefix-", but didn't try. Here is the approximate incantation.
cd /usr/local/src
wget mysql-5.0.87.tar.gz
# from http://dev.mysql.com/downloads/mysql/5.0.html#source
gunzip mysql-5.0.87.tar.gz
tar xf mysql-5.0.87.tar
cd mysql-5.0.87
./configure --prefix=/usr/local
make
make install
P=$PATH
export PATH=/usr/local/bin:$PATH
/usr/local/bin/mysqld_safe
mysql_upgrade --socket=/var/lib/mysql/mysql.sock
/usr/local/bin/mysqladmin shutdown
export PATH=$P
/usr/bin/mysqld_safe
mysql_upgrade --socket=/var/lib/mysql/mysql.sock
Thursday, September 17, 2009
pptpconfig on ubuntu
One thing that fedora does better out of the box than ubuntu is PPTP VPN configuration. That dang Network Manager just doesn't work. pptpconfig does, and on FC8 yum installs it no problem. No such luck in Ubuntu 9.04. I was able to work around it all, but it wasn't easy. I retrieved the following:
http://sourceforge.net/projects/pptpclient/files/pptpconfig/pptpconfig-20060821/pptpconfig-20060821-1.noarch.rpm/download
http://sourceforge.net/projects/pptpclient/files/pptpconfig%20dependencies/php4-pcntl-4.4.1-2/php4-pcntl-4.4.1-2.i386.rpm/download
http://sourceforge.net/projects/pptpclient/files/pptpconfig%20dependencies/php4-pcntl-gtk-1.0.2-2/php4-pcntl-gtk-1.0.2-2.i386.rpm/download
Did "sudo alien" and "dpkg --install" for each. Same thing for both of:
ftp://195.220.108.108/linux/ASPLinux/i386/RPMS.7.3/libglade-0.17-5.i386.rpm
ftp://195.220.108.108/linux/ASPLinux/i386/updates/9.1/i386/libxml-1.8.17-9.2.i386.rpm
Used synaptics to install libgtk1.2. Did "sudo pptpconfig" and was off and running, except I had to add a route by hand:
sudo route add -net 192.168.1.0 netmask 255.255.255.0 dev ppp0
Really shouldn't have been that hard...
http://sourceforge.net/projects/pptpclient/files/pptpconfig/pptpconfig-20060821/pptpconfig-20060821-1.noarch.rpm/download
http://sourceforge.net/projects/pptpclient/files/pptpconfig%20dependencies/php4-pcntl-4.4.1-2/php4-pcntl-4.4.1-2.i386.rpm/download
http://sourceforge.net/projects/pptpclient/files/pptpconfig%20dependencies/php4-pcntl-gtk-1.0.2-2/php4-pcntl-gtk-1.0.2-2.i386.rpm/download
Did "sudo alien" and "dpkg --install" for each. Same thing for both of:
ftp://195.220.108.108/linux/ASPLinux/i386/RPMS.7.3/libglade-0.17-5.i386.rpm
ftp://195.220.108.108/linux/ASPLinux/i386/updates/9.1/i386/libxml-1.8.17-9.2.i386.rpm
Used synaptics to install libgtk1.2. Did "sudo pptpconfig" and was off and running, except I had to add a route by hand:
sudo route add -net 192.168.1.0 netmask 255.255.255.0 dev ppp0
Really shouldn't have been that hard...
Sunday, September 6, 2009
Universal Transverse Mercator (UTM) to GPS Lat/Long
I often use "WGS84" maps for accessing the backcountry. Their measurements are in "Easting" and "Northing", meters from the equator and prime meridian, approximately. The page at http://www.rcn.montana.edu/resources/tools/coordinates.aspx does a great job of converting for me.
Wednesday, July 15, 2009
Java and financial calculations
In general, Java isn't designed for financial calculations, but scientific ones. Java's float and double types don't have the rounding (to cents) and necessary precision for financial calculations. I wrote a small program to illustrate this that calculates monthly mortgage payments and the total payment. Here is the output:
The first two lines are what should be produced. The second and third sections are what Java's float and double types produce, leading to one overpaying their loan. The third section uses Java's BigDecimal class, setting all the precision and rounding values. It's messy to say the least, but this is what it takes to get the values correct. Here is the program:
Actual monthly payment = 2704.65
Actual total payment = 973674.00
---------- float ----------
Float monthly payment = 2704.654
Float total payment = 973675.44
---------- double ----------
Double monthly payment = 2704.6540626894594
Double total payment = 973675.4625682053
---------- BigDecimal ----------
BigDecimal monthly payment = 2704.65
BigDecimal total payment = 973674.00
The first two lines are what should be produced. The second and third sections are what Java's float and double types produce, leading to one overpaying their loan. The third section uses Java's BigDecimal class, setting all the precision and rounding values. It's messy to say the least, but this is what it takes to get the values correct. Here is the program:
import java.math.BigDecimal;
import java.math.MathContext;
public class Amort
{
public static void main (String args[])
{
System.out.println ("Actual monthly payment = 2704.65");
System.out.println ("Actual total payment = 973674.00");
System.out.println ("---------- float ----------");
floater();
System.out.println ("---------- double ----------");
doubler();
System.out.println ("---------- BigDecimal ----------");
bigger();
}
static void doubler()
{
double principal = 417000.00;
double annual = .0675;
double rate = annual / 12.0;
double years = 30;
double months = 12 * years;
double monthly = (principal * rate) /
(1.0 - (Math.pow ((1.0 + rate), -months)));
System.out.println ("Double monthly payment = " + monthly);
System.out.println ("Double total payment = " + monthly * months);
}
static void floater()
{
float principal = 417000.00F;
float annual = .0675F;
float rate = annual / 12.0F;
float years = 30.0F;
float months = 12.0F * years;
float monthly = (principal * rate) /
(float) (1.0F - (Math.pow ((1.0 + rate), -months)));
System.out.println ("Float monthly payment = " + monthly);
System.out.println ("Float total payment = " + monthly * months);
}
static void bigger()
{
MathContext mc2 = new MathContext (2);
MathContext mc4 = new MathContext (4);
MathContext mc6 = new MathContext (6);
MathContext mc8 = new MathContext (8);
BigDecimal principal = new BigDecimal (417000.00, mc8);
BigDecimal annual = new BigDecimal ("0.0675", mc4);
BigDecimal twelve = new BigDecimal ("12", mc2);
BigDecimal rate = annual.divide (twelve);
BigDecimal years = new BigDecimal ("30", mc2);
BigDecimal months = years.multiply (twelve);
BigDecimal monthly = principal.multiply (rate).divide
(BigDecimal.ONE.subtract
(power (BigDecimal.ONE.add (rate), -360, 10)),
2, BigDecimal.ROUND_HALF_UP);
System.out.println ("BigDecimal monthly payment = " + monthly);
System.out.println ("BigDecimal total payment = " +
monthly.multiply (months));
}
static BigDecimal power (BigDecimal a, int p, int scale)
{
boolean negative = p < 0;
if (p == 0)
return (new BigDecimal ("1"));
else if (p == 1)
return (a);
if (negative)
p = -p;
BigDecimal result = a;
for (int i = 2; i <= p; i++)
result = result.multiply (a);
if (negative)
result = BigDecimal.ONE.divide
(result, scale, BigDecimal.ROUND_HALF_UP);
return (result);
}
}
Monday, June 29, 2009
Remote X11 via ssh and Xnest
One of the coolest things I've found recently is Xnest. I can "ssh -X" into a UNIX box and do "Xnest :1 -query 127.0.0.1" to get the XDMCP general login window. Slick. Apple-Click gives me a right click from my OSX box.
Subscribe to:
Posts (Atom)