<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog</title>
	<atom:link href="http://www.adamish.com/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://www.adamish.com/blog</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 21:01:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Ubuntu 12.04 &#8211; minor updates</title>
		<link>http://www.adamish.com/blog/archives/453</link>
		<comments>http://www.adamish.com/blog/archives/453#comments</comments>
		<pubDate>Tue, 15 May 2012 21:01:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[mythtv]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.adamish.com/blog/?p=453</guid>
		<description><![CDATA[Slight change in syntax to mythfilldatabase, not really ubuntu 12.04 related, but that&#8217;s when the version changed. # before ubuntu 11.10 /usr/bin/mythfilldatabase --file 1 grab.xml # after ubuntu 12.04 /usr/bin/mythfilldatabase --file --sourceid 1 --xmlfile grab.xml]]></description>
			<content:encoded><![CDATA[<p>Slight change in syntax to mythfilldatabase, not really ubuntu 12.04 related, but that&#8217;s when the version changed.</p>
<pre class="console">
# before ubuntu 11.10
/usr/bin/mythfilldatabase --file 1 grab.xml

# after ubuntu 12.04
/usr/bin/mythfilldatabase --file --sourceid 1 --xmlfile grab.xml
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.adamish.com/blog/archives/453/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postgresql hello world &#8211; part 3</title>
		<link>http://www.adamish.com/blog/archives/443</link>
		<comments>http://www.adamish.com/blog/archives/443#comments</comments>
		<pubDate>Fri, 11 May 2012 00:48:57 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://www.adamish.com/blog/?p=443</guid>
		<description><![CDATA[So how about some JPA? First get a JEE eclipse build, and install JPA tools and eclipse link. Next download a postgres JDBC driver, eclipse JPA implementation and OpenJPA &#8211; JPA support for J2SE. You should now be able to &#8230; <a href="http://www.adamish.com/blog/archives/443">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So how about some JPA? First get a JEE eclipse build, and install JPA tools and eclipse link. Next download a <a href="http://jdbc.postgresql.org/download.html">postgres JDBC driver</a>, <a href="http://www.eclipse.org/downloads/download.php?file=/rt/eclipselink/releases/2.3.2/eclipselink-2.3.2.v20111125-r10461.zip">eclipse JPA implementation</a> and OpenJPA &#8211; JPA support for J2SE.</p>
<p>You should now be able to use the New&#8230; Other&#8230; JPA&#8230; &#8220;Entities from tables&#8221; option. Create a database connection and enter username/password etc. and the JDBC driver jar etc.</p>
<p>Here we&#8217;ve created an entity for Horse and Rider.</p>
<pre class="code language-java">
@Entity
@Table(name = "horses")
public class Horse {

    @Id
    @Column(name = "id")
    private int id;

    @Column(name = "name")
    private String name;

    @Column(name = "size")
    private int size;

    @OneToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "horses_riders", joinColumns = @JoinColumn(name = "hid"), inverseJoinColumns = @JoinColumn(name = "rid"))
    private Collection&lt;Rider&gt; riders;

    public Horse() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Collection&lt;Rider&gt; getRiders() {
        return riders;
    }
}</pre>
<pre class="code language-java">@Entity
@Table(name = "riders")
public class Rider {
    @Id
    @Column(name = "id")
    private int id;

    @Column(name = "name")
    private String name;

    @OneToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "horses_riders", joinColumns = @JoinColumn(name = "rid"), inverseJoinColumns = @JoinColumn(name = "hid"))
    private Collection horses;

    public Rider() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Collection&lt;Horse&gt; getHorses() {
        return horses;
    }
}</pre>
<p>A fairly basic setup would be as follows:</p>
<pre class="code language-java">    EntityManagerFactory factory = Persistence.createEntityManagerFactory(
            "horses", System.getProperties());

    EntityManager em = factory.createEntityManager();

    Query horseQuery = em.createQuery("SELECT h FROM Horse h");

    for (Horse horse : (List&lt;Horse&gt;) horseQuery.getResultList()) {
        System.out.println(horse.getName() + horse.getRiders());
    }</pre>
<p>The META-INF/persistence.xml file defines the entities and postgres connection info.</p>
<pre class="code">
&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"&gt;
&lt;persistence-unit name="horses"&gt;
&lt;provider&gt;org.apache.openjpa.persistence.PersistenceProviderImpl
&lt;/provider&gt;

&lt;class&gt;hellojpa.Horse&lt;/class&gt;
&lt;class&gt;hellojpa.Rider&lt;/class&gt;

&lt;properties&gt;

&lt;property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver" /&gt;
&lt;property name="openjpa.ConnectionURL" value="jdbc:postgresql://localhost:5432/horsedb" /&gt;

&lt;property name="openjpa.ConnectionUserName" value="horse" /&gt;
&lt;property name="openjpa.ConnectionPassword" value="password" /&gt;

&lt;property name="openjpa.DynamicEnhancementAgent" value="true" /&gt;
&lt;property name="openjpa.RuntimeUnenhancedClasses" value="supported" /&gt;
&lt;/properties&gt;
&lt;/persistence-unit&gt;

&lt;/persistence&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.adamish.com/blog/archives/443/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postgresql hello world &#8211; part 2</title>
		<link>http://www.adamish.com/blog/archives/428</link>
		<comments>http://www.adamish.com/blog/archives/428#comments</comments>
		<pubDate>Wed, 25 Apr 2012 22:33:51 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://www.adamish.com/blog/?p=428</guid>
		<description><![CDATA[So we&#8217;ve got a table of horses. Let&#8217;s make another table, and get get busy with an association table and some JOINs. First we have to add a primary key to our horse table so we can reference it elsewhere. &#8230; <a href="http://www.adamish.com/blog/archives/428">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So we&#8217;ve got a table of horses. Let&#8217;s make another table, and get get busy with an association table and some JOINs. First we have to add a primary key to our horse table so we can reference it elsewhere.</p>
<p>The easy way:</p>
<pre class="code">
ALTER TABLE horses ADD COLUMN id SERIAL;
</pre>
<p>The hard way: This explains how auto-increment really works in postgres &#8211; it actually uses a sequence owned by the table column that uses it.</p>
<pre class="code">
# Steps to make a sequence.
ALTER TABLE horses ADD COLUMN id INT UNIQUE;
ALTER TABLE horses ALTER COLUMN id NOT NULL;
ALTER TABLE horses ADD PRIMARY KEY (id);
CREATE SEQUENCE horses_id_seq;
ALTER TABLE horses ALTER COLUMN id SET DEFAULT NEXTVAL('horses_id_seq');
ALTER SEQUENCE horses_id_seq OWNED BY horses.id;
</pre>
<p>Now let&#8217;s create table of riders.</p>
<pre class="code">
CREATE TABLE riders (name VARCHAR(255), id SERIAL PRIMARY KEY);
INSERT INTO riders (name) VALUES ('adam');
INSERT INTO riders (name) VALUES ('bob');
INSERT INTO riders (name) VALUES ('charlie');
</pre>
<p>Now we create an association table linked horses with riders.</p>
<pre class="code">
CREATE TABLE horses_riders (hid INT REFERENCES horses(id),
                            rid INT REFERENCES riders(id));

INSERT INTO horses_riders (hid, rid) VALUES (1,1);
INSERT INTO horses_riders (hid, rid) VALUES (2,3);
</pre>
<p>Using the association table. First the naive, inefficient way. This is bad because it makes all possible comparisons.</p>
<pre class="code">
SELECT r.name,h.name FROM horses h, riders r,horses_riders ass
                     WHERE ass.hid = h.id AND ass.rid = r.id;
  name   |     name
---------+--------------
 adam    | Mr Ed
 charlie | glue factory
</pre>
<p>Now joins, there are various varieties, but the simplest to understand is simple &#8220;table1 JOIN table2 ON condition&#8221;.</p>
<pre class="code">
SELECT * from (horses h JOIN horses_riders ass ON ass.hid = h.id);
     name     | size | id | hid | rid
--------------+------+----+-----+-----
 Mr Ed        |  456 |  1 |   1 |   1
 glue factory |  123 |  2 |   2 |   3

SELECT * from (riders r JOIN horses_riders ass ON ass.rid = r.id);
  name   | id | hid | rid
---------+----+-----+-----
 adam    |  1 |   1 |   1
 charlie |  3 |   2 |   3
</pre>
<p>We can combine two joins to see who owns which horses.</p>
<pre class="code">
SELECT r.name, h.name from
      (horses_riders ass JOIN horses h ON ass.hid = h.id)
      JOIN riders r ON ass.rid = r.id;

  name   |     name
---------+--------------
 adam    | Mr Ed
 charlie | glue factory
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.adamish.com/blog/archives/428/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postgresql hello world</title>
		<link>http://www.adamish.com/blog/archives/419</link>
		<comments>http://www.adamish.com/blog/archives/419#comments</comments>
		<pubDate>Wed, 11 Apr 2012 21:16:54 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://www.adamish.com/blog/?p=419</guid>
		<description><![CDATA[1. Download and build it. wget http://ftp.postgresql.org/pub/source/v9.1.3/postgresql-9.1.3.tar.bz2 tar xjf postgresql-9.1.3.tar.bz2 cd postgresql-9.1.3 sudo apt-get install libreadline-dev zlib1g-dev ./configure --prefix=$(pwd)/local make install 2. Initialize and run. Setup a database, with a root user, prompt for password. export LD_LIBRARY_PATH=local/lib:$LD_LIBRARY_PATH export PATH=local/bin:$PATH initdb &#8230; <a href="http://www.adamish.com/blog/archives/419">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>1. Download and build it.</p>
<pre class="console">
wget http://ftp.postgresql.org/pub/source/v9.1.3/postgresql-9.1.3.tar.bz2
tar xjf postgresql-9.1.3.tar.bz2
cd postgresql-9.1.3
sudo apt-get install libreadline-dev zlib1g-dev
./configure --prefix=$(pwd)/local
make install
</pre>
<p>2. Initialize and run. Setup a database, with a root user, prompt for password.</p>
<pre class="console">
export LD_LIBRARY_PATH=local/lib:$LD_LIBRARY_PATH
export PATH=local/bin:$PATH
initdb -U root -W datadir
postgres -D datadir
</pre>
<p>3. Create a regular user and a database.</p>
<pre class="console">
createuser -U root horse -W
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
createdb horsedb -U root -O horse
</pre>
<p>4. Connect as regular user, create a table and insert some data, then select it.</p>
<pre class="console">
psql horsedb -U horse
CREATE TABLE horses (name VARCHAR(255), size INT);
INSERT INTO horses (name, size) VALUES('glue factory', 123);
INSERT INTO horses (name, size) VALUES('Mr Ed', 456);
SELECT * FROM horses;
     name     | size
--------------+------
 glue factory |  123
 Mr Ed        |  456
\q
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.adamish.com/blog/archives/419/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ffmpeg x11grab compilation</title>
		<link>http://www.adamish.com/blog/archives/415</link>
		<comments>http://www.adamish.com/blog/archives/415#comments</comments>
		<pubDate>Sun, 18 Mar 2012 09:37:57 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.adamish.com/blog/?p=415</guid>
		<description><![CDATA[For the x11grab input device to be compiled you need to run ./configure with &#8211;enable-x11grab. When you&#8217;ve run ./configure x11grab should be listed in the indev section like this. Enabled indevs: dv1394 lavfi v4l2 fbdev oss x11_grab_device If x11grab was &#8230; <a href="http://www.adamish.com/blog/archives/415">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For the x11grab input device to be compiled you need to run ./configure with &#8211;enable-x11grab.</p>
<p>When you&#8217;ve run ./configure x11grab should be listed in the indev section like this.</p>
<pre class="console">
Enabled indevs:
dv1394			lavfi			v4l2
fbdev			oss			<strong>x11_grab_device</strong>
</pre>
<p>If x11grab was not listed, then it is most likely  Xfixes.h and/or XShm.h files are not in your compiler include path. These are validated in the ./configure script, and x11grab is disabled if they are not available. This is the check inside the configure script:</p>
<pre class="code language-bash">
enabled x11grab                         &#038;&#038;
check_header X11/Xlib.h                 &#038;&#038;
check_header X11/extensions/XShm.h      &#038;&#038;
check_header X11/extensions/Xfixes.h    &#038;&#038;
check_func XOpenDisplay -lX11           &#038;&#038;
check_func XShmCreateImage -lX11 -lXext &#038;&#038;
check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
</pre>
<p>On ubuntu 11.10 the libraries are available, but the headers are not installed. XShm.h is in the libxext-dev package and Xfixes.h is in libxfixes-dev</p>
<pre class="console">
sudo apt-get install libxfixes-dev
sudo apt-get install libxext-dev
</pre>
<p>When compiling for RHEL 4u4 I discovered the headers were available, but in non-standard locations not on the default compiler/linker include paths. It was necessary to point ./configure in the right direction.</p>
<pre class="console">
# first locate the headers.
find / -name "Xfixes.h"
/usr/foo/bar/X11/extensions/Xfixes.h

# next locate the libs
find / -name "libXfixes.so"
/lib/foo/bar/libXfixes.so

# call configure with the compiler + linker locations
./configure \
 other options ... \
 --extra-cflags="-I/usr/foo/bar" \
 --extra-ldflags="-L../lib/foo/bar"
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.adamish.com/blog/archives/415/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chaining builders in Java</title>
		<link>http://www.adamish.com/blog/archives/405</link>
		<comments>http://www.adamish.com/blog/archives/405#comments</comments>
		<pubDate>Fri, 09 Mar 2012 23:14:00 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.adamish.com/blog/?p=405</guid>
		<description><![CDATA[JavaFX uses chaining builders as a kind of syntactic sugar. Here&#8217;s an example. The first create() creates the builder (and inner text object), the subsequent calls set attributes on the the object, and finally it is returned via .build(). final &#8230; <a href="http://www.adamish.com/blog/archives/405">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>JavaFX uses chaining builders as a kind of syntactic sugar. Here&#8217;s an example. The first create() creates the builder (and inner text object), the subsequent calls set attributes on the the object, and finally it is returned via .build().</p>
<pre class="code language-java">
final Text text = TextBuilder.create()
    .text("hello")
    .x(50).y(100)
    .fill(Color.RED)
.build();
</pre>
<p>Advantages.</p>
<ul>
<li>Slightly less code.</li>
<li>Safer (as self-documenting) than complicated constructors with same type e.g. (String, int, int, int, int)</li>
<li>No need for intermediate object if we were just passing it to another method.</li>
</ul>
<p>I think they&#8217;re can be useful than that&#8230; What if the builder was the only way to create a new instance of your class&#8230; What if you were creating an immutable type&#8230;.</p>
<p>Here&#8217;s a standard immutable type.</p>
<pre class="code language-java">
public class Horse {
    private String name;
    private int height;
    public Horse(String name, int height) {
      this.name = name;
      this.height = height;
    }
    public String getName() {
        return name;
    }
    public int getHeight() {
        return height;
    }
}
</pre>
<p>It looks harmless enough, but what happens when someone adds a new field, say age, weight? We have to extend the constructor, and because we already have code using the old constructor we end up with many different constructors leading to confusion.</p>
<pre class="code language-java">
public Horse(String name, int height) {
    this.name = name;
    this.height = height;
}
public Horse(String name, int height, int age) {
    this(name, height);
    this.age = age;
}
public Horse(String name, int height, int age, int weight) {
    this(name, height, age);
    this.weight = weight;
}
</pre>
<p>So how can we make this more future-proof using chaining builders. Well here&#8217;s the same class with a built in builder. Using the builder is the only way to instiate a new horse.</p>
<pre class="code language-java">
public class Horse {
    private String name;
    private int height;
    private Horse() {
    }
    public static class Builder {
        private Horse horse = new Horse();
        public Builder name(String name) {
            horse.name = name;
            return this;
        }
        public Builder height(int height) {
            horse.height = height;
            return this;
        }
        public Horse build() {
            return horse;
        }
    }
    public static Builder create() {
        return new Builder();
    }
    public String getName() {
        return name;
    }
    public int getHeight() {
        return height;
    }
}
</pre>
<p>So we create a horse as follows.</p>
<pre class="code language-java">
Horse h = Horse.create().name("ed").height(123).build();
</pre>
<p>So how do we support future attributes? We just add new sections to the builder&#8230; We also have a clear single point of construction, the build() method. This could contain additional logic to finish the job. </p>
<pre class="code language-java">
public Builder weight(int weight) {
    horse.weight = weight;
    return this;
}
public Builder age(int age) {
    horse.age = age;
    return this;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.adamish.com/blog/archives/405/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac wake up from Linux</title>
		<link>http://www.adamish.com/blog/archives/399</link>
		<comments>http://www.adamish.com/blog/archives/399#comments</comments>
		<pubDate>Fri, 09 Mar 2012 22:40:24 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://www.adamish.com/blog/?p=399</guid>
		<description><![CDATA[On the Mac (Intel iMac 10.7), system preferences, energy saver, wake for ethernet network access. On Linux (Ubuntu 11.04) # Grab the MAC address out of the ARP table (assuming still on) ping horse.lan /usr/sbin/arp -a horse.lan (10.5.1.62) at 00:12:23:34:45:56 &#8230; <a href="http://www.adamish.com/blog/archives/399">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On the Mac (Intel iMac 10.7), system preferences, energy saver, wake for ethernet network access.</p>
<p>On Linux (Ubuntu 11.04)</p>
<pre class="console"># Grab the MAC address out of the ARP table (assuming still on)
ping horse.lan
/usr/sbin/arp -a
horse.lan (10.5.1.62) at 00:12:23:34:45:56 [ether] on eth0

# install etherwake
sudo install etherwake
etherwake -i eth0  00:12:23:34:45:56

# now awake
ssh horse.lan

# do stuff
horse:$ scp /Users/AnnaChapman/Desktop/secret_docs.tar.gz julian@wikileaks.org:/home/julian/nextrelease

# power off again
horse:$ pmset sleepnow</pre>
<p>This works, the mac powers on. However the screen stays off, but you can still ssh in, do whatever and put it back to sleep.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamish.com/blog/archives/399/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Obscure changes in Ubuntu 11.10</title>
		<link>http://www.adamish.com/blog/archives/392</link>
		<comments>http://www.adamish.com/blog/archives/392#comments</comments>
		<pubDate>Sat, 03 Mar 2012 20:25:31 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://www.adamish.com/blog/?p=392</guid>
		<description><![CDATA[I came to resurrect a year old project last week, which previously worked fine, under Ubuntu 11.10. BOOM! nothing works. The project is a CLI TCP server to control a USB opendmx widget using FTD2XX with an Android app client. &#8230; <a href="http://www.adamish.com/blog/archives/392">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I came to resurrect a year old project last week, which previously worked fine, under Ubuntu 11.10. BOOM! nothing works. The project is a CLI TCP server to control a USB opendmx widget using FTD2XX with an Android app client.</p>
<p>First a random g++ fail.</p>
<pre class="console">
g++ -I. -lpthread -lstdc++ -lftd2xx  *.cpp -o opendmxserver
DmxTransmit.cpp:(.text+0x38): undefined reference to `FT_ListDevices'
DmxTransmit.cpp:(.text+0xdb): undefined reference to `FT_Open'
/tmp/cccTckgn.o: In function `Mutex::Mutex()':
Mutex.cpp:(.text+0x1e): undefined reference to `pthread_mutexattr_init'
/tmp/ccs5TdOM.o: In function `System::currentTimeMillis()':
System.cpp:(.text+0x15): undefined reference to `clock_gettime'
/tmp/ccCEDMng.o: In function `Thread::start()':
Thread.cpp:(.text+0x6c): undefined reference to `pthread_create'
</pre>
<p>So what&#8217;s that all about, well it turns out now you have to put the linker switches after the *.cpp. So this works.</p>
<pre class="console">
g++ -I. *.cpp -o opendmxserver -lpthread -lstdc++ -lftd2xx
</pre>
<p>Next fail. Runtime weirdness, assert fail. </p>
<pre class="console">
opendmxserver: tpp.c:63: __pthread_tpp_change_priority: Assertion `new_prio == -1 || (new_prio &gt;= __sched_fifo_min_prio &#038;&#038; new_prio &lt;= __sched_fifo_max_prio)' failed.
</pre>
<p>YFKM, it turns out that out that you need to call pthread_mutexattr_init on the pthread_muxexattr_t structure. This did not used to be the case, although it makes sense to initialize all your structs&#8230;</p>
<pre class="code language-cpp">
pthread_mutexattr_t attr;
pthread_mutexattr_init(&amp;attr); // not previously required
pthread_mutex_init (&amp;this->mutex, &amp;attr);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.adamish.com/blog/archives/392/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scrolling waterfalls in HTML5</title>
		<link>http://www.adamish.com/blog/archives/352</link>
		<comments>http://www.adamish.com/blog/archives/352#comments</comments>
		<pubDate>Sat, 03 Mar 2012 18:07:04 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.adamish.com/blog/?p=352</guid>
		<description><![CDATA[A number of technical domains use scrolling data displays, like the COTS octopus-760 sonar system. A typical implementation would involve a cyclic buffer (BufferedImage, pixmap etc) and two paint operations for efficiency. The means data can be inserted cheaply without &#8230; <a href="http://www.adamish.com/blog/archives/352">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A number of technical domains use scrolling data displays, like the COTS <a href="http://www.codaoctopus.com/octopus-760-series/specifications/">octopus-760</a> sonar system.</p>
<p><a href="http://www.adamish.com/blog/wp-content/uploads/2012/03/octopus-760-dualview.jpg"><img src="http://www.adamish.com/blog/wp-content/uploads/2012/03/octopus-760-dualview-150x150.jpg" alt="" title="octopus-760-dualview" width="150" height="150" class="alignnone size-thumbnail wp-image-386" /></a></p>
<p>A typical implementation would involve a cyclic buffer (BufferedImage, pixmap etc) and two paint operations for efficiency. The means data can be inserted cheaply without the need to move the existing data.</p>
<p>For example, this is what a cyclic buffer of size 3 would look at each stage, as lines of data {A,B,C,D,E,F,G} are received.</p>
<pre class="console">
. . C C C F F
. B B B E E E
A A A D D D G
Time ===&gt;
</pre>
<p>So we can paint directly from the cyclic buffer into the main image. First we paint from {insert pos..buffer end}, and then the wrapped section {start pos .. insert pos}. The wrapped section will not occur until the buffer has &#8220;overflowed&#8221;.</p>
<p>So our painted image looks like this, giving the illusion of scrolling.</p>
<pre class="console">
A B C D E F G
. A B C D E F
. . A B C D E
Time ===&gt;
</pre>
<p>So all that boring background info over, can we implement using HTML canvas tag. Of course we can.</p>
<p>Here it is <a href="http://adamish.com/lab/html5waterfall">http://adamish.com/lab/html5waterfall</a> working, and the code <a href="http://adamish.com/lab/html5waterfall/waterfall.js">waterfall.js</a> </p>
<p>This wasn&#8217;t entirely straightforward to implement. I could not find out how to create an anonymous image primitive to use as a back cyclic buffer. As a workaround I inserted a canvas element with matching dimensions as the &#8220;front&#8221; buffer, I then obtained the and used it as a source image in the drawImage() operation onto the front context.</p>
<p>So job done. This same technique could be used in HTML5 game programming, random effects etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamish.com/blog/archives/352/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBA macros &#8211; word has insufficient memory</title>
		<link>http://www.adamish.com/blog/archives/369</link>
		<comments>http://www.adamish.com/blog/archives/369#comments</comments>
		<pubDate>Sat, 03 Mar 2012 17:48:04 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://www.adamish.com/blog/?p=369</guid>
		<description><![CDATA[Following error message seen when manipulating bookmarks with VBA in Word. Word has insufficient memory. You will not be able to undo this action once it is completed. Do you want to continue?&#8221; Fix: Clear the undo buffer as you &#8230; <a href="http://www.adamish.com/blog/archives/369">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Following error message seen when manipulating bookmarks with VBA in Word.</p>
<p>Word has insufficient memory. You will not be able to undo this action once it is<br />
completed. Do you want to continue?&#8221;</p>
<p>Fix: Clear the undo buffer as you go along.</p>
<pre class="code">
ActiveDocument.UndoClear
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.adamish.com/blog/archives/369/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

