Blog syndication should be working again
For some reason my cached atom feed wasn’t getting regenerated properly when I posted new articles. It’ll take a bit more digging to figure out why, but now at least all of my writing from the past few months should be showing up. Many thanks to Daniel Zepeda for letting me know.
Posted in Personal | no comments |
The weirdest code I've seen recently
I was kicking around in ActiveResource::Base recently and it took me a good solid ten minutes to figure out why the prefix method didn’t recur infinitely.
def prefix(options={})
default = site.path
default << '/' unless default[-1..-1] == '/'
# generate the actual method based on the current site path
self.prefix = default
prefix(options)
end
def prefix_source
prefix # generate #prefix and #prefix_source methods first
prefix_source
end
def prefix=(value = '/')
# Replace :placeholders with '#{embedded options[:lookups]}'
prefix_call = value.gsub(/:\w+/) { |key| "\#{options[#{key}]}" }
# Redefine the new methods.
code = <<-end_code
def prefix_source() "#{value}" end
def prefix(options={}) "#{prefix_call}" end
end_code
silence_warnings { instance_eval code, FILE, LINE }
rescue
logger.error "Couldn't set prefix: #{$!}\n #{code}"
raise
end
Do you see it? When prefix is called, it calls prefix=, which redefines prefix and returns. prefix in turn returns by calling not itself but the newly-created method of the same name.
I am not known for my low tolerance of metalanguage hackery (exhibit). But I do have my limits, and this exceeds them; calling it needlessly obfuscatory would be kind. Or am I wrong? Is there no better way to provide a method with the same semantics?
You can take the software company out of the jungle
But etc. In my job search this past semester I declined to apply there, even though I have contacts, and now I remember why.
Posted in Personal | 2 comments |
They what said it best
Thanks, The Economist:
When it comes to most dangerous products—be they drugs, cigarettes or fast cars—this newspaper advocates a more [classically] liberal approach than the American government does. But when it comes to handguns, automatic weapons and other things specifically designed to kill people, we believe control is necessary, not least because the failure to deal with such violent devices often means that other freedoms must be curtailed. Instead of a debate about guns, America is now having a debate about campus security.
I recommend that you all subscribe; it’s excellent. Much of their content is also available online for free. I promise I’ll return to technical stuff soon. link
Posted in Personal | no comments |
This is not a free speech issue
I am not a constitutional scholar, but it’s my understanding that the Bill of Rights is silent on the issue of an inalienable right to one’s own talk show. Don Imus isn’t in jail. This is all about community speech and the government isn’t involved. This is precisely how it’s supposed to work.
Posted in Personal | 2 comments |
Your host is