Sevenforge RSS

Personal Blog of Curtis Spencer

Going to initially use this as a way to remember all the weird tech stuff I experiment with all day long

Archive

Feb
17th
Tue
permalink

Add Duration to FLV using flvtool2

I have been messing around with the Open Source FLV Player, and I have found that the FLV’s i was pointing it to didn’t have duration meta data.  That can remedied by this simple shell command (as long as you have flvtool2 installed):
sudo gem install flvtool2
cat movie.flv | flvtool2 -U stdin movie.flv
Feb
4th
Wed
permalink

Converting a Virtual PC .vhd to a Virtual Box .vdi

I had some Virtual PC images in .vhd that I wanted to convert to Virtual Box .vdi files.  After some tracing through a few Google searches and some experimentation of my own, the best way seems to be:

qemu-img convert -O raw start.vhd intermediate.bin
vboxmanage convertdd intermediate.bin final.vdi
vboxmanage modifyvdi final.vdi compact

Once you have the .vdi, I found that I had to enable APIC and IO-APIC to avoid a blue screen of death in my windows Virtual PC images on startup.

Feb
1st
Sun
permalink

Unicode Line Separator

U+2028

This little Unicode character gave me a run for my money today.  Hard to see, it shows up as a space in every editor I tried, yet it caused JS unterminated string errors when it was used in a JS string in Firefox.  Moral of the story, if you are using strings in Javascript, you gotta make sure to remove this little buggers.

Dec
18th
Thu
permalink

How Rails Calculates the Cache-Busting Asset ID

In asset_tag_helper.rb, you find this code:
def rails_asset_id(source)
  if asset_id = ENV["RAILS_ASSET_ID"]
    asset_id
  else
    path = File.join(ASSETS_DIR, source)

    if File.exist?(path)
      File.mtime(path).to_i.to_s
    else
      ''
    end
  end
end
Dec
8th
Mon
permalink

Debugging bjam's configuration

bjam --debug-configuration

This is useful if you think you are loading up a site-config.jam or a user-config.jam that you shouldn’t be. I was getting the following error after an upgrade to Intrepid Ibex:

error: at /usr/share/boost-build/build/project.jam:825 
error: duplicate initialization of gcc with the following parameters: 
error: version = 4.3.2

Then I was able to find that the site-config.jam file in /etc/ was initializing gcc.

Nov
25th
Tue
permalink

Ubuntu Developer Man Pages

apt-get install manpages-dev
Simple as that.
Nov
20th
Thu
permalink

fopen giving "Value too large for defined data type"

Was working with some large data files from Wikipedia in C, and got a NULL pointer from fopen.  After checking strerror, I got the “Value too large for defined data type.”  error.  The solution.  Put

#define _FILE_OFFSET_BITS 64

at the top of your .c file and it will set you straight.

Oct
29th
Wed
permalink

Rendering an .rhtml file to a string without a controller

Sometimes you need to pierce the MVC veil and render a view somewhere lower level without the HTTP rails stack, such as refreshing a cache without a client request, or outputing rhtml to a static html file.   To preserve some of the “Don’t repeat yourself mantra”, it would be nice to have a way to render an .rhtml without a request/response.

av = ActionView::Base.new(Rails::Configuration.new.view_path)
av.assigns[:item] = @item
output = av.render('controller/view')

Thanks to these blog posts: Choonkeat and  acts_as_renderer for the inspiration.

Oct
22nd
Wed
permalink

Forcing JMeter to use an IP Address for a Master

I was working on using JMeter with a few remote machines, but they were having trouble returning results to the Listener’s on the Master.  I saw in the logs that there was a java.rmi.ConnectException: Connection refused to host: 127.0.0.1, so naturally the master was somehow sending 127.0.0.1 to the slaves somehow.  You can either take out the loopback address from your /etc/hosts, which I didn’t really want to do, or use this useful property on the command line to your jmeter.

bin/jmeter -Dsun.rmi.server.hostname=192.168.0.100

Now it works like a charm

Oct
20th
Mon
permalink

Tidy up XML on the command line

This is a useful snippet if you ever encounter some XML using curl or wget that you want to format on the fly just for readability purposes.

curl http://myxml.com/myxml.xml | tidy -xml -i -w 0

Don’t know how many people need to read XML on the command line out there, but if you are doing any sort of XML parsing it may come in handy.