<?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:djberg96</id>
  <title>Testing 1,2,3...</title>
  <subtitle>(This is only a test)</subtitle>
  <author>
    <name>djberg96</name>
  </author>
  <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/"/>
  <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom"/>
  <updated>2009-11-22T14:34:23Z</updated>
  <lj:journal userid="2752056" username="djberg96" type="personal"/>
  <link rel="service.feed" type="application/x.atom+xml" href="http://djberg96.livejournal.com/data/atom" title="Testing 1,2,3..."/>
  <link rel="hub" href="http://pubsubhubbub.appspot.com/"/>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:171118</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/171118.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=171118"/>
    <title>Declarative Tests</title>
    <published>2009-11-22T14:34:23Z</published>
    <updated>2009-11-22T14:34:23Z</updated>
    <category term="ruby"/>
    <category term="testing"/>
    <content type="html">As a result of the current RoR gig I've become addicted to the declarative syntax for test-unit:&lt;br /&gt;&lt;pre style="background: lightgray; padding: 1em; border: 1px solid black; color: black"&gt;
  class TC_Foo &amp;lt; Test::Unit::TestCase
    test "foo should return the string 'hello'" do
      assert_equal('hello', @obj.foo)
    end

    # vs.

    def test_foo_should_return_hello
      assert_equal('hello', @obj.foo)
    end
  end
&lt;/pre&gt;&lt;br /&gt;When you first look at that you'll probably think it's just a silly cosmetic change. But, after using for a while I have to admit that it's had two effects on my testing, both positive.&lt;br /&gt;&lt;br /&gt;First, and foremost, I now write more descriptive test descriptions. With the old "def test_something" I found that I tended to be overly terse. With the declarative syntax I tend to be more descriptive. That's a good thing, because it's easier for me (or someone else) to look at that test later and more easily determine just what the purpose of that test is.&lt;br /&gt;&lt;br /&gt;Second, I tend to break out groups of assertions that I had previously lumped together into separate tests. This is a function of the first change, i.e. by writing more descriptive tests I limit the assertions to those that actually match my description. So, if an assertion is actually testing something *slightly* different, I feel more comfortable (for lack of a better word) writing it out into a separate test because I'm writing a more verbose description.&lt;br /&gt;&lt;br /&gt;I'm not necessarily down to one assertion per test (as some people advocate), but my average number of assertions per test definitely dropped. :)&lt;br /&gt;&lt;br /&gt;BTW, the declarative syntax has been added to test-unit 2 and will be part of the 2.0.6 release!</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:170878</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/170878.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=170878"/>
    <title>Git reality check</title>
    <published>2009-11-12T12:34:32Z</published>
    <updated>2009-11-12T12:34:32Z</updated>
    <category term="ruby"/>
    <category term="git"/>
    <content type="html">You mean the culture of git is leading to &lt;a href="http://groups.google.com/group/gemcutter/browse_frm/thread/80fd383032105250"&gt;project fragmentation&lt;/a&gt;?&lt;br /&gt;&lt;br /&gt;Gosh, there's a shock.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:170666</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/170666.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=170666"/>
    <title>The Mysteries of Life: Computer Speakers</title>
    <published>2009-10-25T15:43:16Z</published>
    <updated>2009-10-25T15:43:16Z</updated>
    <category term="speakers"/>
    <content type="html">Can someone explain to me why it's always the right speaker that flakes out with computer speakers? And why turning it off and on can sometimes make it pop back on?</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:170369</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/170369.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=170369"/>
    <title>Test::Unit 2.x, now with TAP</title>
    <published>2009-10-22T15:40:03Z</published>
    <updated>2009-10-22T15:40:03Z</updated>
    <category term="ruby"/>
    <category term="testing"/>
    <category term="tap"/>
    <content type="html">The test-unit gem now supports a &lt;a href="http://en.wikipedia.org/wiki/Test_Anything_Protocol"&gt;TAP runner.&lt;/a&gt;&lt;br /&gt;&lt;pre style="background: lightgray; padding: 1em; border: 1px solid black; color: black"&gt;
dberger@file-temp&amp;gt;ruby -Ilib test/test_file_temp.rb --runner tap
1..9
ok 1 - test_file_temp_auto_delete(TC_File_Temp)
ok 2 - test_file_temp_expected_errors(TC_File_Temp)
ok 3 - test_file_temp_name(TC_File_Temp)
ok 4 - test_file_temp_name_basic_functionality(TC_File_Temp)
ok 5 - test_file_temp_no_delete(TC_File_Temp)
ok 6 - test_file_temp_no_delete_with_template(TC_File_Temp)
ok 7 - test_file_temp_threaded(TC_File_Temp)
ok 8 - test_file_temp_tmpdir(TC_File_Temp)
ok 9 - test_file_temp_version(TC_File_Temp)
# Finished in 0.160204 seconds.
# 9 tests, 20 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
&lt;/pre&gt;&lt;br /&gt;There is also &lt;a href="http://rubyforge.org/projects/test-spec"&gt;Bacon&lt;/a&gt;.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:169988</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/169988.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=169988"/>
    <title>Back to Rails</title>
    <published>2009-10-20T20:16:44Z</published>
    <updated>2009-10-24T17:54:49Z</updated>
    <category term="ruby"/>
    <category term="rails"/>
    <content type="html">So, I'm doing RoR work again, and I'm hitting those annoying little issues that bugged me the first time around.&lt;br /&gt;&lt;br /&gt;Today, it's the fact that I have to setup separate validations to handle nils/blanks. IMO I should be able to do this:&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: lightgray; padding: 1em; border: 1px solid black; color: black"&gt;
validates_numericality_of :elevation, :allow_nil =&amp;gt; false
&lt;/pre&gt;&lt;br /&gt;Now, this works. It validates that &lt;i&gt;elevation&lt;/i&gt; is a number and it doesn't allow nulls. The problem is that, in the case of a null, it still sets the error message to "not a number". That's not what I want. I want "can't be blank". And I *only* want that error message. To get that effect I have to setup two separate validations, and add a conditional to the second one.&lt;br /&gt;&lt;pre style="background: lightgray; padding: 1em; border: 1px solid black; color: black"&gt;
validates_presence_of :elevation

validates_numericality_of :elevation,
  :unless =&amp;gt; Proc.new{ |site| site.elevation.blank? }
&lt;/pre&gt;&lt;br /&gt;What a hassle.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Update:&lt;/b&gt; Anonymous user posted a better solution. See the comments.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:169868</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/169868.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=169868"/>
    <title>More random thoughts on mixins, selector namespaces</title>
    <published>2009-10-14T19:10:33Z</published>
    <updated>2009-10-25T12:01:30Z</updated>
    <category term="ruby"/>
    <content type="html">Ovid's journal got me thinking about the multi-mixin problem again. That got me thinking about selector namespaces again, too.&lt;br /&gt;&lt;br /&gt;Consider the current mixin behavior:&lt;br /&gt;&lt;pre style="background: lightgray; padding: 1em; border: 1px solid black; color: black"&gt;
module Alpha
  def hello
    puts "Alpha"
  end
end

module Beta
  def hello
    puts "Beta"
  end
end

class Tango
  include Alpha
  include Beta
end

Tango.new.hello # =&amp;gt; "Beta"
&lt;/pre&gt;&lt;br /&gt;Possible solutions:&lt;br /&gt; &lt;br /&gt;* First method definition wins&lt;br /&gt;* Last method definition wins, raises a warning&lt;br /&gt;* No one wins, it's an error&lt;br /&gt;&lt;br /&gt;And my new, crazy idea:&lt;br /&gt;&lt;br /&gt;* First method definition wins, later methods are auto-namespaced&lt;br /&gt;&lt;br /&gt;&lt;pre style="background: lightgray; padding: 1em; border: 1px solid black; color: black"&gt;
# Let's assume this syntax actually works
t = Tango.new
t.hello       # =&amp;gt; "Alpha" (wins, first definition)
t.hello:alpha # =&amp;gt; "Alpha" (same, but explicit)
t.hello:beta  # =&amp;gt; "Beta"  (calls Beta module's method)
&lt;/pre&gt;&lt;br /&gt;Thoughts?&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Update:&lt;/b&gt; As per the comments below, you could still have "last definition wins" behavior with the above syntax. Also, "alpha" and "beta" should probably be capitalized in the last example above. I dunno, though. I kinda like the lowercase notation in that context.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:169526</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/169526.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=169526"/>
    <title>Face. Palm.</title>
    <published>2009-09-24T14:38:13Z</published>
    <updated>2009-09-24T14:38:13Z</updated>
    <content type="html">Note to self: Dir['*/**'] and Dir['**/*'] do &lt;b&gt;NOT&lt;/b&gt; do the same thing.&lt;br /&gt;&lt;br /&gt;Gawd.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:169320</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/169320.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=169320"/>
    <title>LJ Settings Change</title>
    <published>2009-09-12T18:19:45Z</published>
    <updated>2009-09-12T18:19:45Z</updated>
    <content type="html">It seems that LJ still treats OpenID users as "anonymous", so I've changed my settings so that anonymous users can post, but those posts will be screened.&lt;br /&gt;&lt;br /&gt;Happy posting!</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:169067</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/169067.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=169067"/>
    <title>Rake tasks to build gems</title>
    <published>2009-09-12T03:11:55Z</published>
    <updated>2009-09-12T03:13:56Z</updated>
    <content type="html">For gems where you may want to ship both a source bundle and a binary bundle, consider using Rake tasks instead of hard coding a gem spec directly in your Rake task. The first step is to remove this line from your .gemspec file:&lt;br /&gt;&lt;pre&gt;
Gem::Builder.new(spec).build
&lt;/pre&gt;&lt;br /&gt;Why? Because we're going to eval the gemspec file and, in the case of the binary gem, modify the spec before we build it. Here are the Rake tasks I'm using that let me use a single gemspec and build either version without a lot of fuss:&lt;br /&gt;&lt;pre&gt;
desc 'Build a standard gem'
task :build_gem =&amp;gt; :clean do
  rm_rf('lib') if File.exists?('lib')
  spec = eval(IO.read('foo.gemspec'))
  Gem::Builder.new(spec).build
end

desc 'Build a binary gem'
task :build_binary_gem =&amp;gt; [:build] do
   file = 'ext/foo.' + CONFIG['DLEXT']
   mkdir_p('lib')
   mv(file, 'lib')

   spec = eval(IO.read('foo.gemspec'))
   spec.extensions = nil
   spec.files = spec.files.reject{ |f| f.include?('ext/') }
   spec.platform = Gem::Platform::CURRENT

   Gem::Builder.new(spec).build
end
&lt;/pre&gt;&lt;br /&gt;The standard gem is pretty straightforward. In the case of the binary gem, we need to build the binary, copy it to a 'lib' directory, remove the 'extensions' specification item, remove any 'ext' files (we don't want to ship build files do we? no), set the platform to the current platform and then, finally, build the gem.&lt;br /&gt;&lt;br /&gt;Enjoy.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:168873</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/168873.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=168873"/>
    <title>Be Nice</title>
    <published>2009-09-11T05:02:57Z</published>
    <updated>2009-09-11T05:03:22Z</updated>
    <content type="html">I rarely agree with what Andy Lester has to say, but &lt;a href="http://perlbuzz.com/2009/09/dont-optimize-for-yourself-in-communities.html"&gt;this&lt;/a&gt; is one of those times. He's talking about #perl, but he could be talking about any channel. Actually, he really could just be talking about acting like a decent human being online instead of a snot.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:168519</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/168519.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=168519"/>
    <title>For you Smalltalk/Ruby fans</title>
    <published>2009-09-02T03:25:09Z</published>
    <updated>2009-09-02T03:25:09Z</updated>
    <category term="smalltalk"/>
    <category term="ruby"/>
    <content type="html">I just came across this: &lt;a href="http://smalltalk.felk.cvut.cz/projects/smallruby"&gt;http://smalltalk.felk.cvut.cz/projects/smallruby&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I've no idea what the actually compatibility is. Still, looks cool.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:168403</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/168403.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=168403"/>
    <title>FFI Blues</title>
    <published>2009-08-07T17:25:23Z</published>
    <updated>2009-08-07T19:36:33Z</updated>
    <category term="ruby"/>
    <category term="ffi"/>
    <content type="html">Lately I've been experimenting with FFI, the wrapper around libffi that let's you write C code without ever leaving pure Ruby. I figured with JRuby already using it, and Rubinius and IronRuby on their way, it might be time to start porting some of my C extensions over.&lt;br /&gt;&lt;br /&gt;Unfortunately, I've slammed into the cold hard fact that FFI just isn't the grand solution we all hoped it would be. The first problem is that libffi, the underlying source for C based implementations, isn't going to build without the gcc toolchain. That pretty much leaves everyone but Linux, FreeBSD and OS X in the dust, including two heavy hitters, MS Windows and Solaris (if you're using the Sun Studio compiler). Then there's the issue of JRuby's lack of support for certain parts of C, such as file descriptors, as my attempt to port file-temp demonstrated.&lt;br /&gt;&lt;br /&gt;So now I'm in a dilemma. If I want to write cross-platform code that will work with JRuby &lt;b&gt;and&lt;/b&gt; C based implementations, I'm relegated to keeping two (or more) separate source files, one for MRI and one for JRuby. It would more likely be 3, as I'll still need a separate source file for Windows, since the code is radically different from its *nix counterpart most of the time.&lt;br /&gt;&lt;br /&gt;On top of that I've heard disturbing reports that there is little interest in supporting FFI on Windows, in which case we may as well declare it dead in the water. Whether you like it or not, Windows is a major player and its here to stay. If it's not going to work on Windows you may as well chuck it now and stick with C extensions.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:167959</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/167959.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=167959"/>
    <title>Firefox Blues</title>
    <published>2009-08-06T00:58:27Z</published>
    <updated>2009-08-06T00:58:27Z</updated>
    <content type="html">I've gone back to IE 8 on the Vista laptop for now. Seeing Firefox (3.5.2 btw) balloon to 800 mb with 2 tabs open, doing nothing in particular, but bringing my system to a crawl is simply unacceptable.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:167709</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/167709.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=167709"/>
    <title>Hash#fetch</title>
    <published>2009-08-06T00:06:19Z</published>
    <updated>2009-08-06T00:06:19Z</updated>
    <content type="html">I generally eschew Array#fetch. It's worthless in my opinion. But what about Hash#fetch? Ah, now there's a good reason for this one. Consider this:&lt;br /&gt;&lt;pre&gt;
def foo(name)
   code = SomeHash[name]
   raise ArgumentError, "Illegal prototype '#{name}'" unless code
   return code
end
&lt;/pre&gt;&lt;br /&gt;There's one immediate problem. What if &lt;b&gt;false&lt;/b&gt; is a valid key argument? Or what if you want to merely check if a particular key has been defined even if it's nil? The above code will fail. But Hash#fetch has slightly different semantics. It checks that the key is &lt;b&gt;defined&lt;/b&gt; without concern for the actual value and so, can pick up false and nil key values &lt;br /&gt;&lt;br /&gt;Basically, you've got three options. Option 1 is to fail with an IndexError if the key isn't defined:&lt;br /&gt;&lt;pre&gt;
SomeHash.fetch(:bogus) # Boom, IndexError
# vs.
SomeHash[:bogus] # nil
&lt;/pre&gt;&lt;br /&gt;Option 2 lets you specify a default value if the key isn't found:&lt;br /&gt;&lt;pre&gt;
SomeHash.fetch(:bogus, 7) # 7
&lt;/pre&gt;&lt;br /&gt;Option 3 allows the value of a code block to serve as the value. This is generally used to re-raise a custom exception.&lt;br /&gt;&lt;pre&gt;
SomeHash.fetch(:bogus){ raise MyError, "Key not found" }
&lt;/pre&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:167591</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/167591.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=167591"/>
    <title>My libraries repackaged...from the future!</title>
    <published>2009-07-24T01:49:03Z</published>
    <updated>2009-09-15T04:12:13Z</updated>
    <content type="html">Go ahead, take a look &lt;a href="http://allgems.faithpromotingstories.org/gems/sys-uptime/0.5.3"&gt;here&lt;/a&gt;. Notice anything odd?&lt;br /&gt;&lt;br /&gt;"Released Apr 21, 2010"&lt;br /&gt;&lt;br /&gt;Huh. Pretty impressive, considering it's only 2009. I hope it includes lottery numbers, too.&lt;br /&gt;&lt;br /&gt;This was originally reported to me by Roger Pack &lt;a href="http://rubyforge.org/tracker/index.php?func=detail&amp;amp;aid=26456&amp;amp;group_id=610&amp;amp;atid=2412"&gt;here&lt;/a&gt;. I think it's the Debian folks repacking my stuff, though it's not entirely clear. It's definitely NOT a mistake in my gemspec - I double checked.&lt;br /&gt;&lt;br /&gt;Should I be mad? What should I do about this?&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Update:&lt;/b&gt; Huh, I think this might be my own fault. It looks like my Linux VM can't keep its own time straight.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:167286</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/167286.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=167286"/>
    <title>How to get a (local) user's home directory on Windows</title>
    <published>2009-07-23T02:46:38Z</published>
    <updated>2009-07-23T22:29:58Z</updated>
    <lj:music>Voices of Autumn 2006 (Beautiful)</lj:music>
    <content type="html">While getting the current user's home directory is easy enough for the current user if you're willing to rely on ENV['USERPROFILE'], obtaining the home directory of an arbitrary local user isn't so straightforward. Here's the Ruby solution:&lt;br /&gt;&lt;pre style="background: lightgray; padding: 1em; border: 1px solid black; color: black"&gt;
require 'win32/security'
require 'win32/registry'

key = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\"
usr = 'some_user'

sec = Win32::Security::SID.open(usr)
key += sec.to_s

Win32::Registry::HKEY_LOCAL_MACHINE.open(key) do |reg|
  puts reg['ProfileImagePath']
end
&lt;/pre&gt;&lt;br /&gt;While win32-registry is part of the standard library, win32-security will have to be installed.&lt;br /&gt;&lt;pre style="background: lightgray; padding: 1em; border: 1px solid black; color: black; width: 35%"&gt;
gem install win32-security
&lt;/pre&gt;&lt;br /&gt;In other news, I'm inlining CSS to get purrtier code. I'm using "style='background: lightgray; padding: 1em; border: 1px solid black; color: black'" if anyone cares.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:167021</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/167021.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=167021"/>
    <title>Mixing in singleton methods</title>
    <published>2009-07-21T12:10:33Z</published>
    <updated>2009-07-21T12:10:33Z</updated>
    <content type="html">I released facade 1.0.3 today. I don't know if I've blogged about it before so I thought I would mention it. In short, it lets you mix in (all or some) singleton methods from a class or module, and turn them into instance methods of the extending class without overriding any existing methods.&lt;br /&gt;&lt;br /&gt;For example, there are several singleton methods of the File class, such as File.basename, File.dirname, etc. What if you want to mix them into the String class directly as instance methods? Here's how you do it:&lt;br /&gt;&lt;pre&gt;
require 'facade'

class String
   extend Facade
   facade File, :dirname, :basename
end

str = '/export/home/djberge'
str.basename # =&amp;gt; 'djberge'
str.dirname  # =&amp;gt; '/export/home'
&lt;/pre&gt;&lt;br /&gt;Neat, eh?</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:166790</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/166790.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=166790"/>
    <title>Preventing massive CPU suckage</title>
    <published>2009-07-18T14:31:32Z</published>
    <updated>2009-07-18T14:31:32Z</updated>
    <content type="html">While trying to find a way to simulate &lt;i&gt;getrlimit&lt;/i&gt; and &lt;i&gt;setrlimit&lt;/i&gt; on MS Windows I realized you could do this on most Unix platforms as a way to prevent your process from sucking massive CPU cycles:&lt;br /&gt;&lt;pre&gt;
trap('XCPU'){
   puts "CPU time exceeded!"
   # Insert diagnostic code here
   exit!
}

Process.setrlimit(Process::RLIMIT_CPU, 1) # Or whatever max value you want

while true
   puts "This should exit in a few seconds..."
end
&lt;/pre&gt;&lt;br /&gt;What I'm not sure of is what a good value is for the maximum CPU time. Then again, maybe limiting RLIMIT_VMEM would be better. Or perhaps both?&lt;br /&gt;&lt;br /&gt;I've never done this in practice, btw, but it might be a good way to deal with spiking processes. Just a thought.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:166592</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/166592.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=166592"/>
    <title>More win32-process updates</title>
    <published>2009-07-16T14:20:40Z</published>
    <updated>2009-07-16T14:20:40Z</updated>
    <category term="ruby"/>
    <category term="windows"/>
    <content type="html">We've added a few methods in win32-process to the Process module that were previously unimplemented. Specifically:&lt;br /&gt;&lt;br /&gt;* Process.uid&lt;br /&gt;* Process.getpriority&lt;br /&gt;* Process.setpriority&lt;br /&gt;&lt;br /&gt;For Process.uid I decided to return the RID of the owning user's SID. This is the same value that you'll get if you look at the local user account id on your Windows box. The only difference is that I allow an optional parameter which, if set to true, will instead return the binary SID. That way you can use it directly if you need to.&lt;br /&gt;&lt;br /&gt;One use would be to use it in conjunction with the win32-security library.&lt;br /&gt;&lt;pre&gt;
require 'win32/process'
require 'win32/security'

p Process.uid # 1000
p Win32::Security::SID.open(Process.uid(true)) # Security object
&lt;/pre&gt;&lt;br /&gt;Implementing Process.getpriority and Process.setpriority was fairly trivial for processes. I just used the &lt;i&gt;GetPriorityClass&lt;/i&gt; and &lt;i&gt;SetPriorityClass&lt;/i&gt; functions. The only difference is that you can only set the priority for processes, not process groups or users. Also, the values are different (and limited) when compared to its UNIX counterpart.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:166317</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/166317.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=166317"/>
    <title>Does it hurt to beg?</title>
    <published>2009-06-07T03:26:40Z</published>
    <updated>2009-06-07T03:26:40Z</updated>
    <content type="html">Help me avoid a soul sucking cubicle job:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.pledgie.com/campaigns/4706"&gt;&lt;img alt="Click here to lend your support to: Awesome Ruby Development and make a donation at www.pledgie.com !" src="http://www.pledgie.com/campaigns/4706.png?skin_name=chrome" border="0" /&gt;&lt;/a&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:165965</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/165965.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=165965"/>
    <title>Published!</title>
    <published>2009-06-03T00:46:10Z</published>
    <updated>2009-06-03T00:46:10Z</updated>
    <content type="html">I. Am. &lt;a href="http://www.worthingtongames.com/CaesarsGallicWar.html"&gt;Published&lt;/a&gt;! Nope, not a book, but a game.&lt;br /&gt;&lt;br /&gt;Should be out in early August. Oh, and &lt;a href="http://www.boardgamegeek.com/boardgame/43245"&gt;here&lt;/a&gt; is the BGG link.&lt;br /&gt;&lt;br /&gt;Yes, I know about the typos and have already pointed them out. ;)</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:165801</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/165801.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=165801"/>
    <title>Maybe -t isn't the answer</title>
    <published>2009-06-01T22:28:23Z</published>
    <updated>2009-06-01T22:28:23Z</updated>
    <content type="html">I recently submitted a feature request for Rubygems to run with -t (run tests) by default. Because, hey, we're test obsessed right? Maybe it's not such a wise idea, though.&lt;br /&gt;&lt;br /&gt;Dave Rolsky &lt;a href="http://blog.urth.org/2009/05/the-real-problem-with-dependencies.html"&gt;points out&lt;/a&gt; a problem with running tests by default when installing modules via the CPAN shell in the world of Perl:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Perl has a great culture of testing. We expect all modules uploaded to CPAN to come with a test suite, and we expect modules to run their tests on install and to pass. I love that we have such high standards, but these standards are not without problems. When a module fails its tests, the person doing the install isn't in a good position to handle it. In many cases, they could probably force the install and use the module, but how could they know that?&lt;/blockquote&gt;&lt;br /&gt;In the comments Perrin Harkin points out:&lt;br /&gt;&lt;blockquote&gt;Running the tests in the CPAN shell before every module install was never very realistic and gets less so every day. I remember back in the early days of working with mod_perl, when the Perl testing culture was not that strong. I would find modules didn't install with the CPAN shell because the tests were written in a way that would never run on any computer except the author's. When I told authors about this, they would say "Oh, I've never used the CPAN shell. I just install modules in the normal way."&lt;br /&gt;&lt;br /&gt;No one does that anymore, because the dependency chains are now too long and annoying to do manually. We have to use the CPAN shell. (Or make alternative packaging of some kind, but that's a different story.) So, CPAN.pm should stop running the tests. Either they should be off by default, or it should be obvious how to turn them off globally. If someone is having trouble with a module, they can go run the tests then.&lt;br /&gt;&lt;br /&gt;Simply turning off the tests in the CPAN shell would make installing Moose a reasonable thing and do away with nearly all griping about dependencies.&lt;/blockquote&gt;&lt;br /&gt;Something to think about.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:165438</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/165438.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=165438"/>
    <title>Moosy</title>
    <published>2009-05-30T03:09:34Z</published>
    <updated>2009-05-30T03:09:34Z</updated>
    <content type="html">The whole "OMG, MOOSE!" epidemic that's swept the Perl community up recently has the rest of us (from Smalltalk, Ruby, Python, etc) somewhat baffled.&lt;br /&gt;&lt;br /&gt;From &lt;a href="http://use.perl.org/comments.pl?sid=43077&amp;amp;cid=68825"&gt;chromatic&lt;/a&gt;:&lt;br /&gt;&lt;blockquote&gt;If Perl 5 had a better class declaration and management system in the core, there'd be no need for Mouse, Moose, Squirrel, and dozens of other modules in the Class:: namespace.&lt;/blockquote&gt;&lt;br /&gt;Hey, you said it, not me.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:165300</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/165300.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=165300"/>
    <title>Intimacy from a distance</title>
    <published>2009-05-28T16:23:39Z</published>
    <updated>2009-05-28T16:23:39Z</updated>
    <content type="html">Kinda cool, yet kinda strange:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.distancelab.org/projects/mutsugoto/"&gt;http://www.distancelab.org/projects/mutsugoto/&lt;/a&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:djberg96:164930</id>
    <link rel="alternate" type="text/html" href="http://djberg96.livejournal.com/164930.html"/>
    <link rel="self" type="text/xml" href="http://djberg96.livejournal.com/data/atom/?itemid=164930"/>
    <title>Done with Facebook</title>
    <published>2009-05-12T02:54:28Z</published>
    <updated>2009-05-12T02:54:28Z</updated>
    <content type="html">My great Facebook experiment is over. It was fun while it lasted I suppose, but I decided to disable the account today. Why?&lt;br /&gt;&lt;br /&gt;First, and foremost, it's useless. It does nothing but shove ads in your face at every opportunity. It was mildly annoying at first, but began to grate on me more and more over time. It might not have been so bad if half the ads weren't a bunch of get rich quick schemes. If the ads don't seem above board, what does that say about Facebook?&lt;br /&gt;&lt;br /&gt;Second, it's not social. Not really. Meeting people for drinks or at the coffee shop is social. Firing off a random reply to someone else's random thought they've posted is not social.&lt;br /&gt;&lt;br /&gt;Third, as my friend says, there's a reason I haven't kept in touch with some people for 15 years.&lt;br /&gt;&lt;br /&gt;Last but not least there are the &lt;a href="http://www.guardian.co.uk/technology/2008/jan/14/facebook"&gt;privacy issues&lt;/a&gt;, among other things mentioned in that article.&lt;br /&gt;&lt;br /&gt;So, if I have something to say, I'll either say it here or in my blogger.com account.&lt;br /&gt;&lt;br /&gt;Otherwise, I'm going to go outside and actually talk to people and stuff.</content>
  </entry>
</feed>
