Tuesday, January 15, 2013


This blog is moving to unit201.net

Friday, November 9, 2012

Sympa and Active Directory

Some basic steps on running sympa on Ubuntu 12.04 and using Active Directories Global Directory to auto-populate groups.

Ubuntu Notes 
  • apt-get install sympa will give you a 'mostly' working version
  •  Chown -R /var/lib/sympa sympa 
  • The suid wrapper does not work on 12.04. You will need to create a sudo wrapper instead:
  • set use_fast_cgi 1 in /etc/sympa/wwsympa.conf
  • /usr/lib/cgi-bin/sympa/wwsympa_sudo_wrapper.fcgi
  • #!/usr/bin/perl
    exec '/usr/bin/sudo', '-E', '-u', 'sympa', '/usr/lib/cgi-bin/sympa/wwsympa.fcgi';
  • In apache/conf.d/sympa, change:
    ScriptAlias /wws /usr/lib/cgi-bin/sympa/wwsympa_sudo_wrapper.pl
  • add the following line to your sudoers file:
    www-data ALL = (sympa) SETENV: NOPASSWD: /usr/lib/cgi-bin/sympa/wwsympa.fcgi
  • References:
 LDAP/AD Bound Lists
  • If you only have one domain, then you can just use the following and point at one of your domain controllers.
  • If you want to use forest-wide groups, you have two options for accessing those groups.
  • This will work this either security or distribution groups, however will NOT include nested membership.
    • In the ldap config for the group, point at the dc the group resides in. CHange suffix, host and user as appropriate, set use_ssl to yes, drop the :3268
    • Make the group universal and use the global directory (route I chose)
  • LDAP Configuration
    attrs mail
    filter memberof=Some Group,OU=...,OU=...,DC=research,DC=domain,DC=org
    ssl_ciphers ALL
    name any_name
    host dc1.mydomain.org:3268
    use_ssl no
    passwd your_password
    timeout 30
    suffix DC=domain,DC=org
    user   CN=Read Account,OU=...,DC=domain,DC=org
    ssl_version sslv2
    scope sub
    select first
    ssl_version tls
  • References

Thursday, July 21, 2011

SmartClient and Jersey/JAX-RS

Here's a good tutorial on using jax-rs to return smartclient compatible data sources.

Thursday, July 14, 2011

Fun with DC's gis data, part 1

It looks like DC has kindly released quite a bit of gis data for public consumption. One of the more interesting sets is the regularly updated Owner Polygon dataset available from data.dc.gov. This is a shapefile containing current property records for everything in the District. Unfortunately, it's not available kml for easy display in google's tools. However the 70MB esri shapefile is available. Using Open Layers, PostGIS, and and GeoServer, we can get start displaying everything, but what if we want to use google maps and do things the hard way? To solve that, there's a few simple steps to allow polygon querying, selection, and display on google maps.
  1. Import data into PostGIS
  2. Create GIS servlet
  3. Draw the data on google maps
  4. Query PostGIS for google's lat/long
  5. Select Properties from the map
We're going to work on step one today, import your data into PostGIS.
Prepare PostGIS
I'm running Ubuntu 11.04, PostgreSQL 8.4 with postGIS 1.5.1 installed from the default software repo.
  1. PostGIS 1.5 manual
  2. nad 83, maryland projection
psql (8.4.8)
Type "help" for help.

postgres=# create database propertymap;
postgres=# \q
~$ createlang plpgsql propertymap;
~$ cd /usr/share/postgresql/8.4/contrib/postgis-1.5/
postgis-1.5$ psql -f postgis.sql propertymap
postgis-1.5$ psql -f ../postgis_comments.sql propertymap;
postgis-1.5$ psql -f spatial_ref_sys.sql propertymap;
Convert Shapefile
Create a ton of insert statements using shp2pgsql:
poly$ shp2pgsql -s 926985 OwnerPly.shp ownertable > inserts.sql
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
If we look at the .prj file included, we see that the projection for the data is NAD_1983_StatePlane_Maryland_FIPS_1900. We need to add the projection from spatialreference.org in to our database
propertymap=# INSERT into spatial_ref_sys (srid, auth_name, .......66666666],UNIT["Meter",1.0]]');
propertymap=# \i inserts.sql
Run your first query
propertymap=# select ownername,square,lot,premiseadd from ownertable where premiseadd like '%1600 PENNSYLVANIA%';
        ownername         | square | lot  |       premiseadd        
First, a little background on what we asked for. DC property records are based on square, suffix, and lot. Square generally refers to a city block and goes all the way back to the original city planning in the old part of the city. Lot is a lot within a square/suffix. For the most part, you can ignore suffix as it's rarely used. Next time, create a simple servlet to expose all of this.

Monday, July 11, 2011

Isolating Big Blue Button Video

This is a quick how to on manually connecting to a BBB video stream. Before we begin, here's a very, very quick background.
  • Video streams are grouped under a conference-room specific url that has for format rtmp://host/video/roomID
  • Each streaming component under BBB is available as a separate stream (ie, video, desktop, sip/audio, etc)
  • BBB uses red5 under the hood to manage these streams
  • Grab flowplayer here and the flowplayer rtmp client here
  1. Connect to your room and start your webcam.
  2. Tail /usr/share/red5/log/bigbluebutton.log and uou should see the following log lines:
    2011-07-11 18:14:54,871 [NioProcessor-1] DEBUG o.b.c.s.p.ParticipantsEventRecorder - A participant's status has changed 141 streamName 640x480141
    2011-07-11 18:14:54,919 [NioProcessor-1] DEBUG o.b.c.s.p.ParticipantsService - Setting participant status ec0449a0-b5d1-4ca5-bfdf-d118d8bc2299 141 hasStream true
    • ec0449a0-b5d1-4ca5-bfdf-d118d8bc2299 or similar is the room id
    • 640x480141 is the stream id you need
  3. Download and place flowplayer-...swf, flowplayer.rtmp-...swf, and flowplayer-...min.js into a directory.
  4. Create a web page as follows:
  5. <meta equiv="content-type" content="text/html; charset=UTF-8">
           <script type="text/javascript" src="flowplayer-3.2.6.min.js"></script>
           <title>Minimal Flowplayer setup</title>
    <div id="player"></div>
    <script language="javascript">
    $f("player", "flowplayer-3.2.7.swf",
    clip: {
            url: '640x480141',
            live: true,
            autoBuffering: false,
            bufferLength: 1,
            provider: 'rtmp'
           plugins: {
                   // here is our rtpm plugin configuration
                   rtmp: {
                           url: 'flowplayer.rtmp-3.2.3.swf',
                           netConnectionUrl: 'rtmp://your_server/video/ec0449a0-b5d1-4ca5-bfdf-d118d8bc2299'
  6. Load up your web page and you should see the streaming video.

Friday, May 6, 2011

log4j and Pivot

Here's a simple way to consume log4j messages in pivot for use in a log console or similar. First create a custom appender which sents a log message to the pivot message bus.
public class MessageBusAppender extends AppenderSkeleton {
    protected void append(LoggingEvent event) {
        MessageBus.sendMessage(new LogMessage(layout, event));

    public boolean requiresLayout() {
        return true;

    public void close() {


public class LogMessage {

    private Layout logLayout;
    private LoggingEvent event;

    public LoggingEvent getEvent() {
        return event;

    public Layout getLogLayout() {
        return logLayout;

    public LogMessage(Layout logLayout, LoggingEvent event) {
        this.logLayout = logLayout;
        this.event = event;
In any component needs to display log messages, just listen for the messages and update as appropriately. Here's an example updating a textpane:
public class LogPane extends Border {

    private TextPane logTxt;
    private PushButton clearBtn;
        logTxt.setDocument(new Document());

        MessageBus.subscribe(LogMessage.class, new MessageBusListener() {

            public void messageSent(final LogMessage message) {
                ApplicationContext.queueCallback(new Runnable() {

                    public void run() {
                        String text = message.getLogLayout().format(message.getEvent());
                        logTxt.getDocument().add(new Paragraph(text));
                        if (message.getEvent().getThrowableInformation() != null)
                            StringBuilder sb = new StringBuilder();
                            for (String s : message.getEvent().getThrowableInformation().getThrowableStrRep())
                                sb.append("  ");
                            logTxt.getDocument().add(new Paragraph(sb.toString()));

        clearBtn.getButtonPressListeners().add(new ButtonPressListener() {

            public void buttonPressed(Button button) {
                logTxt.setDocument(new Document());

Now tie it together in your log4j config:
log4j.rootLogger=ERROR, Pivot

log4j.appender.Pivot.layout.ConversionPattern=%-6r [%15.15t] %-5p %30.30c %x - %m%n

Monday, March 14, 2011

Counting bits

Here's a simple input stream which will tell you the current position. You should insert this after any buffered input streams if you want an accurate position after a read.
public class CountingInputStream extends PushbackInputStream {

    private long bytesRead;

    public CountingInputStream(InputStream is) {
    public CountingInputStream(InputStream is,int len) {

    public long getPosition() {
        return bytesRead;

    public void unread(byte[] b, int off, int len) throws IOException {
        bytesRead -= len;
        super.unread(b, off, len);

    public void unread(int b) throws IOException {

    public void unread(byte[] b) throws IOException {
        bytesRead -= b.length;

    public boolean markSupported() {
        return false;

    public synchronized void reset() throws IOException {
        throw new IOException("Mark not supported");

    public int read() throws IOException {
        int rd = super.read();
        if (rd != -1) {
        return rd;

    public int read(byte[] b) throws IOException {
        int read = super.read(b);
        if (read != -1) {
            bytesRead += read;
        return read;

    public int read(byte[] b, int off, int len) throws IOException {
        int read = super.read(b, off, len);
        if (read != -1) {
            bytesRead += read;
        return read;

    public long skip(long n) throws IOException {
        long skipped = super.skip(n);
        bytesRead += skipped;
        return skipped;