case somevar
when 17
do_something_here()
end
Because, you know, if statements are for people who know how to
program, or something.
To summarize, I left DebConf on Saturday morning, arrived NYC on the afternoon where Raquel was waiting for me. By Sunday, we had the very nice chance to meet with abrotman, rcox and stew. We stayed at stew and rcox’s place until Tuesday, when we got back. We also had the chance to meet with people that we have been working for remotely.
We were walking around in NYC, and suddenly, the 5th avenue became multicolor. It was the gay pride parade. You can take a look at the pics on the gallery, lots of gay people. Our visit to NYC was pretty gayish actually, since we spent our first night in Chelsea, presenced an electronic music festival or similar for lesbians, and the next day, first row on the parade
And that’s it, since we came back until like yesterday, life was a mess; lots of work pending to deliver and many other issues. Finally, we are right now settled up again, enjoying a cold rainy nice weather in Mexico City with very cheap beer (compared with UK pints!) and loved people
Thanks to all who made such a wonderful DebConf, even that, in my case, I arrived late and left early, it was just great (thanks also to MJ Ray, specially; and also to all people who was worried about my arrival, you know who you are, thanks). Thanks also to Mike and Rachel who hosted us, they are a very nice couple. And also, thanks to Alex who joined us in NYC, coming from Philadelphia, spent a nice day with us, took us to Chinatown and Little Italy and gave me a Phillies baseball cap (just as exchange of the worldwide famous umbrella hat).
git-hash-object that helps you creating a hash for a particular object (though it’s also trivial to do with sha1sum). For regular files, git-hash-object -t blob $filename is enough. For symbolic links, you have to read the link destination, and give it without a trailing character (be it the NULL character or a carriage return) to git-hash-object -t blob --stdin. For directories, you have to generate a tree “structure” by yourself and pass it to git-hash-object -t tree --stdin. I haven’t bothered looking at other file types.
The tree structure can be guessed by either looking at mktree.c or at the output of git-cat-file tree $sha1 where $sha1 is the SHA-1 hash for a tree object. It contains 3 informations for each node in the tree : the file mode, with the same format as what stat() returns, except for some reason, permissions are 000 for directories and symbolic links ; the file name ; and the SHA-1 hash. These informations are written with the following format : file mode in octal ascii and no padding zero (”%o”) followed by a space character, then the filename followed by a NULL character, and the binary form of the SHA-1 hash.
Nodes are sorted in a not-so-quite lexical order (take a look at base_name_compare in read-cache.c) and are not separated by any special character: the mode of a file just follows the SHA-1 hash of its predecessor.
With all this new knowledge, you should be able to write some code that would return the SHA-1 from an arbitrary directory. Okay, since you must be at least as lazy as I am, you can take the script I wrote.
Now, let’s take a look at a real life case : what commit is the latest nightly snapshot for the linux kernel from ? First, download the latest snapshot patch and its baseline, and extract the whole. Then, run my git-hash-tree.pl script with the directory containing the extracted kernel as an argument. It will return, after a while, the SHA-1 hash for the whole tree. During this long process, you also have plenty of time to git clone linus’s tree.
Once you’re all done, you can search for the commit corresponding to the tree hash (let’s call it $hash) with the following command :
git-rev-list --all while read h; do git-cat-file commit $h grep -q "^tree $hash" && echo $h && break; done
If you just followed these steps, you should just have spent a great moment having no result at all. There are actually 2 things that prevent this method to properly work with the linux kernel nightlies :
-gitn from the EXTRAVERSION variable in the Makefile.git diff only includes diff headers for removal of empty files, so if you apply the snapshot patch with the patch utility (and you can’t apply it with git-apply since you don’t have a .git directory), empty files that were marked as deleted will still be on your tree. It happens with the current snapshot patch (2.6.22-rc7-git6): it doesn’t remove include/asm-blackfin/macros.h.
case some_variable
when 'X'
process-based-on-X
if save
post-processing
else
throw_an_error
end
when 'Y'
process-based-on-Y
if save
some-other-post-processing
else
throw_an_error
end
when 'Z'
process-based-on-Z
if !save
throw_an_error
end
end
In each case, the pre-save processing was unique, and -- more
importantly -- the action to take after a successful save was
different, so I couldn't just save-and-handle after the case
statement. However, the throw_an_error code was the same in each
case, so I just changed the code to do this:
begin
case some_variable
when 'X'
process-based-on-X
save!
post-processing
when 'Y'
process-based-on-Y
save!
some-other-post-processing
when 'Z'
process-based-on-Z
save!
end
rescue ActiveRecord::InvalidRecord
throw_an_error
end
My mind was blown. Soooo much clearer now. I have an "everything's OK"
code path, and a "bugger me, something broke" path, cleanly separated.
But something didn't feel quite right...
And now I know what it is. I'm bothered by the fact that I'm sailing very
close to using exceptions as an ordinary, every day flow control mechanism.
I think I've convinced myself that, in this case, it's OK, but I'm a little
concerned that I might go power-hungry and start using it in places that it
really isn't warranted. I guess I'll just have to keep an eye on myself.
Just remember, everyone: save! isn't a dirty word!
<IfModule mod_fastcgi.c>
<Directory /var/www/vir/syn.theti.ca/typo>
FastCgiIpcDir /tmp/fcgi_ipc/
FastCgiServer /var/www/vir/syn.theti.ca/typo/public/dispatch.fcgi -initial-env RAILS_ENV=production -processes 15 -idle-timeo
ut 60
</Directory>
</IfModule>
It’s strange that the section is called mod_fastcgi.c, not mod_fcgid.c. Either that was done to make it a “drop in” replacement for fastcgi, and later changed in the next release, or else this config was not actually used, but somehow my blog started in production mode before the upgrade anyway. In any case, the blog is back in production node with the new fcgid with the following module section (based on this one from the mod_fcgid home page).
<IfModule mod_fcgid.c>
DefaultInitEnv RAILS_ENV production
<Directory /var/www/vir/syn.theti.ca/typo>
FCGIWrapper "/var/www/vir/syn.theti.ca/typo/public/dispatch.fcgi" .fcgi
</Directory>
</IfModule>
Hope this is helpful to others making the upgrade.
The store served a general, non-technical audience. DRM-FREE, it turns
out, is a good way to sell music. Not just to geeks but to any consumer
who has been stymied unfairly by DRM or knows someone who has. That, it
turns out, is a whole lot people. Consumers know what DRM is and they
know don't like it.
As consumers learn more about DRM, they want to avoid it. Seeing this,
the companies that produce DRM are looking for ways to escape. The
Apple/EMI deal seems to be an attempt to protect market share that
the use of DRM is threatening. Others, like HBO's Bob Zitter, are
disingenuously attempting to escape the stigma of DRM by simply
rebranding the technology.
Of course, DRM suffers from a much more fundemental problem than bad
branding. The problem with DRM is that consumers don't like what it does
and are only sometimes willing to suffer through it when not given the
choice. Increasingly often, as with in the example of the flier I
found, consumers have a choice. Things don't look good for DRM. For DRM
opponents, the self-defeating nature of the technology is our greatest
ally.
Oatmeal Pancakes 2 eggs 4 T. veg. oil 1 3/4 cup buttermilk 1 cup all-purpose flour 1 cup rolled oats 3 Tbl. brown sugar 1/2 tsp. cinnamon 2 tsp. baking powder 1/2 tsp. baking soda 1/2 tsp. salt Beat eggs in medium-sized bowl. Beat in vegetable oil until well mixed, then stir in buttermilk. Add remaining ingredients and stir to blend.
ecdf
and plot.stepfun (rather than
redoing it ad-hoc as I had done), and also add explicitly quantiles. The two
charts use the exact same instructions; however the second chart transforms
the x-axis to a logarithmic scale.
While it is close to impossible to find the 25 or 50 percentile on the first
chart, it becomes a lot easier on the second chart because the x-axis is
'stretched' using the log transform. About one quarters of the distribution appears
to be rebuild within 1.5 months old, and about half is younger than four
months (as a quick call to summary(pkgAge) confirms). Reading
these proprtions off the original chart, or the non-log chart, is much more difficult.
Next.