Code And Cocktails

The Delete Refactoring

| Comments

The Code is unnecessary.

Delete it.

void printLog (String msg) {                   
    int logLevel = 2;                   
    LOG.printLine(msg);          
}        

=>

void printLog (String msg) {                   
    LOG.printLine(msg);          
}    

Motivation

Sometimes code doesn’t do anything. Maybe a variable is no longer used, or a whole function or class is no longer referenced by the rest of the code. If that happens, delete it.

Mechanics

  • select unused code
  • press the delete key
  • compile and test

Example

I start with the following code:

// This method is no longer used          
// int getErrorLevel() {          
//     return -1;          
// }    

Select the text and hit delete. I now have the resulting code:

 

Code'n'Cocktails - Crazy Idea?

| Comments

I jokingly I mentioned the idea of Code’n’Cocktails on Twitter…

https://twitter.com/#!/verdammelt/status/158292007981289472

This was shortly after a short conversation while partaking of aprés Boston Software Craftsmanship beers in which I was asked about cocktails and someone suggested getting cocktails after the meeting next time. It was also immediately after I was asked when we were going to get cocktails by @zdsbs (prompted by my tweeting I had just purchased a book of Absinthe Cocktail recipes).

I did but jest (poison in jest; no offense i’the world [Hamlet III.ii.234-235])…

But now I am thinking it through.

I have heard of ‘Code & Coffee’ and thought it a good idea. A place to meet people who like code and coffee. While I really like coffee, I also like cocktails and I seem to be surrounded by people who get up later than I do - so why not meet after work for cocktails and code? Brilliant!

So what would a Code’n’Cocktail look like? I see a few possibilities:

  1. A cocktail party where code/coding is the topic of conversation
  2. A coding dojo/coderetreat/code kata session with booze
  3. A salon for coding

I think the first and last are very similar and given my inclinations I like the connotations of referring to it as a salon. I think that would be my preference. I would not want to limit it entirely to discussion; so some coding would be good.

What do I hope attendees would get out of such an event? I think attendees should have fun and at least one of: learn something, teach something, make contacts.

This sort of event would have to happen at a bar or someone’s home. I don’t see how it could happen at someone’s workplace or a place like NERD as it obviously needs a well stocked bar. The problem is location. The Location would need to be able to accommodate an prior-to-event unknown number of people (making a reservation would be difficult); and accommodate the possibility of coding (standing at a bar may not work). I think an off night at a bar might work - the place would love to get business on a slow night…

The gears in my mind are turning. If you have interest or thoughts please comment or contact me.

Gnus Configuration (2.75 of N) - Spam Splitting

| Comments

I think I have no solved the problem of Bogofilter not running after group exit. I had my spam-process group parameter written wrong.

(spam-process ((spam spam-use-bogofilter)
        (ham spam-use-bogofilter)))

Note that this is a sexpr of two elements, the second one being a list. I had it being a sexpr of three elements.

Oh the joy of silent failure.

I have also found mention of the BBDB problem on the mailing list – so there is a possible fix there if I get a new copy of spam.el from the repository or something like that.

Gnus Configuration (2.5 of N) - Spam Splitting

| Comments

An addendum to follow up on how to fix an item that was giving me a problem before.

In order to get ham & spam moved and processed as such when you mark it you need to set up additional group parameters:

'(("nnfolder.*"
 (spam-contents gnus-group-spam-classification-ham)
 (spam-process (ham spam-use-bogofilter)
           (spam spam-use-bogofilter))
 (spam-process-destination "nnfolder:spam.spam"))
("spam.spam"
 (spam-contents gnus-group-spam-classification-spam)
 (spam-process (spam spam-use-bogofilter)
           (ham spam-use-bogofilter))
 (ham-process-destination "nnfolder:mail.misc"))

Specifically the spam-process-destination and ham-process-destination pair. These cause the mail to be moved from the ham to spam groups and /visa versa/.

One problem still remains – the bogofilter still doesn’t seem to be doing anything. I don’t see any evidence that it is being called in the `Messages buffer either.

So the score is:

  1. Bogofilter not being called when groups exited
  2. Wish I could get BBDB to work.

Gnus Configuration (2 of N) - Spam Splitting

| Comments

Setting up Splitting

The next thing I felt I needed to set up was spam splitting. I didn’t want obvious spam being dumped into my inbox anymore.

To set up spam splitting you need to be using Fancy Splitting. Then you add (: spam-split) to you fancy split rules. At this point you have something like:

(setq nnmail-split-methods 'nnmail-split-fancy
         nnmail-split-fancy '(| (: spam-split)
                                "mail.misc"))

You also have to call spam-initialize to make it start working.

/However/ one has to do a little more. You have to specify which spam back ends you want to use. Since my ISP runs SpamAssassin I chose to use spam-use-spamassassin-headers. Setting this to t makes the spam package check for the X-Spam-Status: YES header. (There are plenty of choices so check out the doc)

What didn’t work quite right

I also wanted to use Bogofilter so that my local machine could learn to identify stuff that my upstream Spamassassin did not. However I’m not sure if that is working correctly. My Bogofilter database file is still zero size.

To get a spam back end to process spam and ham when you are done reading a group you need to add some group parameters. So I set:

(setq gnus-parameters
       '(("nnfolder.*"
          (spam-contents gnus-group-spam-classification-ham)
          (spam-process (ham spam-use-bogofilter)))
         ("spam.spam"
          (spam-contents gnus-group-spam-classification-spam)
          (spam-process (spam spam-use-bogofilter)))
        ...

But like I said that doesn’t appear to be working. I’m probably just missing something small that is mentioned in the documentation.

What seems to be broken

Before my nuke and pave (and upgrade to emacs v24) I was using BBDB as a whitelist. So if you were not in my BBDB then you went to spam. However with v24 when I try to use BBDB I get an error saying that bbdb-search is undefined. It /is/ defined in bbdb-com.el however so I am not sure what is wrong. I’m going to investigate a bit more and post a question on gmane.emacs.gnus.general and gmane.emacs.gnus.user (maybe also gmane.emacs.bbdb.user).

Coderetreat - the Need for Preparedness

| Comments

Abstract

This observer has noted a repeated waste of time by attendees of the Coderetreats he has attended. Herein is described a simple way to be better prepared when you attend your next Coderetreat

Observational Data

This past weekend was the Global Day of Coderetreat and I attended the one in Cambridge, Mass. This was my third and I again saw an annoyance I want to get out of my head.

First, let me recapitulate the idea of the code retreat. The participants work on the Conway’s Game of Life programming problem in 45 minute intervals in pairs, throwing away the code after every iteration. Some iterations have interesting constraints added; such as ‘no primitives’, ‘no ifs’, or ‘silent paring’.

I have noticed that at each coderetreat I’ve attended some people spend time (usually only in the first session luckily) fighting with their environments to get the point where they can start coding. To me any time spent setting up the environment is wasted time when you have 45 minutes. I’m not saying that this was a /huge/ issue – but a very little bit of preparation can save plenty of time during the event.

An Initial Attempt for a Personal Solution

Given that I saw (and felt, when pairing with someone who was unprepared) this problem at the Chicago coderetreat (held the day after SCNA), I made sure I had a ruby and Java project all set up so that I had a failing test (true == false). That way I knew that everything was all set: all needed libraries, any special configuration (autotest & rspec always gives me a little bit of hassle), any other annoying little thing was done. I even went so far as to push them up to GitHub so others could use them to. (git makes deleting the code after an iteration very easy: git reset --hard HEAD && git clean -fqx).

It turns out that I didn’t need to do this. There was already a GitHub repository that did what I needed and much more: coreyhaines/coderetreat.

Conclusion

Given that the above repository is set up for 10 programming languages currently, it is likely that the ones you want to use are already there. Simply cloning the repository and doing a quick smoke test will ensure that your environment is ready for the session.

If you don’t find your favorite language – or the skeleton provided doesn’t work as well as it could – send a pull request (I tweaked the ruby starting point to let autotest work with rspec right away).

There Comes a Time in Every Emacs-user's Life When...

| Comments

…you just need to nuke-and-pave your configuration.

That time has come for me – especially with respect to my GNUS configuration. I’ve been using GNUS to read news since probably 1990 or earlier, before then I remember using rn.

As for email I’ve used RMAIL and VM. I don’t remember exactly when I switched GNUS but it has been probably at least 5 years.

Over that time my gnus init file has grown pretty hairy. It is time for a shave.

Over the last week I’ve switched to a pretest release of Emacs v24 and during that time I cleaned out a lot of configuration – but feared to clean out much of my gnus configuration. However in trying to get the spam checking working better I realized that a nuke-and-pave is probably the best thing to do now.

So I am about to remove nearly ALL of my gnus configuration. Pray for me.

p.s. I’ll try to blog about my luck or lack-there-of. And also any interesting bits I discover along the way.

GNUS Configuration Note 1 (of N)

| Comments

So far I have flailed around moving my email to a different structure. I have been using nnmail-use-long-file-names set to t up until now. But I decided to try it out with the default value of nil.

I had several problems this evening

  • Sent mail was going to nnfolder+nnfolder instead of nnfolder+archive as advertised. I think that this may have been caused by old settings in my .newsrc.eld. After mucking about in there I started getting my sent mail in the right place.

  • Not sure how it happened but the system acted as if nnfolder-directory was set to ~/News/nnfolder but then suddenly switched to ~/Mail/. I got that all sorted out (now set to ~/News/mail) but it took some time and my brain didn’t figure out how it was working for while. The important part here is if you move a mail file you must also move/edit the active file to list that mail group.

Some of the problems may have been caused by a rather cavalier attitude to the task. If I had sat down to do it more carefully and slowly it could have gone more smoothly.

No mail was lost so I am happy. But the system as it is currently configured is definitely not the way I want to keep it. Things to do next:

  • spam handling
  • expiry for archving (which I conflate that with sent mail processing)
  • splitting (but less splitting than I was doing previously)

But now… time for sleep.

\LaTeX Blog Posting - a Test Post.

| Comments

I have had some annoying problems recently making posterous blog posts via email using markdown.

These problems have made me feel foolish - like I can’t get something /simple/ right. Or even more importantly, like I am incapable of simple copy editing.

Thus I am writing this test blog post.

However, not wanting to write a post saying:

> testing testing - please ignore

Instead I will mumble something about LaTeX and muse on how it would be sort of cool if I could write each post as a LaTeX document and then they’d look pretty gorgeous. Not that I need lots of equations - but really LaTeX would do it so perfectly. isn't it
lovely

Perhaps my biggest problem is that I can’t easily get a nice preview. I am editing this in Emacs using Gnus. Really given that it is Emacs there may already be a solution to my problems - or I could do it myself.

But getting back to LaTeX blogging. What might that look like? Perhaps each post would be a PDF? Or maybe the LaTeX document would be rendered as HTML? Perhaps this deserves a little more thinking.

Time to send this off and see how screwed up it looks in my posterous.