Disable INFO logging from AWS Java SDK

June 22, 2011 Leave a comment

We’re using the AWS Java SDK and had an incredibly difficult time figuring out how to disable INFO-level logging.

This is probably particular to our configuration, but I think it is a fairly common setup: Jetty on Ubuntu on EC2.

The problem is that Jetty uses SLF4J, and includes the default slf4j-simple.jar which logs everything. In order to fix it, you have to remove the symlink in /usr/share/jetty/lib/jsp2.1 and create a new symlink to slf4j-jdk14.jar (and the configure java logging to not log at INFO).

Step by step:

  1. cd /usr/share/jetty/lib/jsp2.1
  2. sudo rm slf4j-simple.jar
  3. sudo ln -s ../../../java/slf4j-jdk14.jar slf4j-jdk14.jar
  4. create /usr/share/jetty/webapps/root/WEB-INF/logging.properties with
    .level=WARNING
  5. cd /etc/defaults
  6. edit jetty and add:
    JAVA_OPTIONS=-Djava.util.logging.config.file=/usr/share/jetty/webapps/root/WEB-INF/logging.properties
Tags: , , ,

How to convert an OpenType font (.otf) to TrueType (.ttf)

October 17, 2010 Comments off

I wanted to show the new STIX fonts on FileFormat.Info, but they are only available in a flavor of OpenType that doesn’t load in Java. This is how to convert them to TrueType. It may lose some of the more advanced typographic features, but I am only showing a single character at a time, so it does not really matter for my purposes.

tl;dr version: use FontForge. Open the .otf file and then File->Generate, and select TrueType

Automated/scripted version:
Install the required software:

sudo apt-get install fontforge python-fontforge

Create a tiny python file:

#!/usr/bin/python
import fontforge
font = fontforge.open(“STIXGeneral.otf”)
font.generate(“STIXGeneral.ttf”)

Pretty simple. I wrote a otf2ttf.py script for converting a directory full of fonts all at once.

DNS in client-side JavaScript

July 25, 2010 Comments off

I needed to do detailed DNS lookups in client-side JavaScript. I didn’t find anything existing, so I whipped up a simple gateway that resolves DNS queries submitted via HTTP and returns the answers in JSON.

documentation | script

Parameters for tcpdump

July 21, 2010 Comments off

I recently needed to run tcpdump and these are my notes on getting it to work correctly.

Parameters:

  • -s 0 (capture the complete packet)
  • -n (don't try to convert numeric ip/port)
  • -w filename.pcap (save to file)
  • port nnnn (capture anything going to or from port nnnn)

Use Control-C to stop the capture (it closes the file gracefully).

Use WireShark to open the .pcap file.

How to extract a table from a Microsoft Access .mdb file

April 4, 2010 Comments off

I recently needed to get a list of area codes mapped to states in csv format. The NANPA has the data (for free), but only as a Microsoft Access .mdb. Here’s how to extract the data using mdb-tools.

First, figure out the table name from a dump of the schema:

mdb-schema database.mdb

Then export it:

mdb-export database.mdb tablename

The NANPA table has spaces in the name, so you have to put double-quotes around it.

Fix for Google AppEngine “ImportError: cannot import name os_compat” on Linux

March 14, 2010 1 comment

This is a permissions problems. Probably because I like to install software as root in /usr/local, rather than in my /home directory. The solution is to make it readable for everyone:

cd /usr/local/google_appengine
sudo chmod -R ugoa+r *

I would recommend Google switching from a .zip file to a .tar.gz file (which can have specific permissions in it).

Migrating from Google AppEngine to Linode

February 20, 2010 Comments off

When Google AppEngine (GAE) first came out, I thought it would be a great way to host some side projects that I had on FileFormat.Info that were too small to be worth setting up a whole server for, but could really use their own domain name & identity.

Unfortunately, GAE has some pretty severe limitations in terms of the standard Java classes. I use the iText library, and managed to get it to work in AppEngine, but the missing classes mean custom colors and fonts don’t work. Since the point of LabelMakr was to print nice looking labels, including colors and fonts, I never really used the GAE version. Finally I saw an article comparing VPS hosts and decided to give Linode a try. Well, it has worked out very well. The signup process at Linode was trivial. Ubuntu installation was a breeze and the server is setup exactly the way I want. And the kicker is performance. This is a graph from Google’s Webmaster Tools, showing how long GoogleBot takes to download a page:

Performance on Google AppEngine vs Linode

Performance on Google AppEngine vs Linode

MySQL Setup on Ubuntu Hardy Heron

November 30, 2009 Comments off

These are the instructions I use to setup a MySQL database server. Note that WordPress is insisting on screwing up the quotes, so you cannot cut-and-paste the text. If anyone knows how to disable this in (hosted) WordPress, please let me know (and I’m already using the non-GUI editor).

Install Ubuntu Server, do not select a profile at the end.

Install ssh and mysql. It will ask for a root password.

apt-get install ssh mysql-server

Grant the root user access from across the network

mysql -p
GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'password';

Tweek the config to listen on the network and to store each table in a separate file. Edit /etc/mysql/my.cnf and in the [mysqld] section, comment out the existing bind-address and add one with the server’s IP address, and add a line innodb_file_per_table

Restart the server daemon

Tags:

Fix for VMWare time drift problems

November 3, 2009 Comments off

I have a VMWare image that does some processing and then upload the results to Amazon S3. The upload has a crypto signature that includes a timestamp, and if the time of the machine is too far from reality, the upload fails. The VMWare instance was drifting by more than 10 seconds per minute.

Both the host and the guest are Debian 4.0 (Etch), and the host has multi-core with multiple CPUs.

Switch the guest to look at a different clock source: Edit /boot/grub/menu.lst and add divider=10 clocksource=acpi_pm to the line that starts with # kopt=.

Run update-grub. This re-does the menu entries to have the new options.

Set the guest to sync to the host’s time using VMWare Tools’ time sync. On the host edit the guest.vmx file and add/change tools.syncTime = "TRUE" and tools.syncTime.period = 60.

Restart the VM. cat the file /sys/devices/system/clocksource/clocksource0/current_clocksource to make sure it is in fact using acpi_pm.

Side note: it may be better to use NTP to sync the time, but only if you add tinker panic 0 to the top of /etc/ntp.conf. I didn’t find this until after I had the VMWare host time sync working, so I have not tried it.

References: VMWare KB article on Linux settings, VMWare KB article on timekeeping

Cursor keys for VMWare Server 2.0

September 24, 2009 Comments off

I upgraded to VMWare Server 2.0. It has a web-based admin console, which is nice, but isn’t as reliable or peppy as the old fat client. The viewer is a browser plug-in, which is okay, but the cursor keys (and page-up, page-down, etc.) do not work (though the ones on the number pad do).

Anyhow, I found the solution! Edit (or create) ~/.vmware/config and add the line

xkeymap.nokeycodeMap="TRUE"

Follow

Get every new post delivered to your Inbox.