Bathroom Reading Material

Problems With Clojure + Homebrew?

| Comments

There is a fix-all solution to any problems you’re having with Clojure + Homebrew.

1
$ brew uninstall clojure

Followed by

1
$ brew install cake

Or

1
$ brew install leiningen

In all seriousness, if you’ve installed Clojure via any package manager and you’re having problems, that’s because it doesn’t make any sense whatsoever to install Clojure through a package manager. The JVM ecosystem just doesn’t work that way. Clojure is essentially a library — it’s stored in a jar.

Instead, you want to install a build tool. Cake or Leiningen are Clojure build tools. They are your ‘interface’ to Clojure. They handle all the project management, classpath management, REPL management, compilation, and everything else that you shouldn’t need to or try to do on your own.

Do not try to ‘install’ Clojure. Install a build tool instead. It’ll prevent 98% of all beginner issues related to classpaths and make it easier for people in the Clojure mailing list and IRC channel to help you with real problems. Furthermore, they make it really easy to manage everything from small scripts to large projects, and can even give you properly classpathed repls as easy as cake repl and lein repl.

Meet Clojure Update

| Comments

This just in: progress, son.

Today was a great day for this budding author. I finished my next chapter, chapter 7 (tentative), and sent it to my editor. I’m not having any trouble at all keeping up with my deadlines.

Even better is that, about 20 minutes ago, I decided who I wanted my technical reviewer to be: Chris Granger, an insanely smart fellow and active member of the Clojure community. He is very interested in doing it, but nothing is official yet (I swear to God, all happened 20 minutes ago). I’ll be sure to tweet about it when it is official.

LibreOffice is much easier to face when you don’t have to do shit with it other than actually write the book and send each chapter individually. Of course, I’d still rather write my book in a plain text format, but beggars can’t be choosers and it works.

I’ve mostly been renovating mostly-complete chapters so far before sending them in. The real test will be writing new chapters from scratch, something that I’m going to have to face soon. I’m pretty sure I’ll make it though. I’m highly motivated because I have a fantastic technical reviewer, more communication with my publisher, and amazing friends encouraging me to get this sucker done.

Everything I’ve said before about the book still applies. There will be a free copy released when the book is finished that I am hoping will become an important entry-point for new Clojurians. I hope to do something similar to Learn You A Haskell and have a pretty HTML version of the book.

In summary, 2 chapters have been submitted to my publisher for review. Still targeting every 3 weeks for new chapters. Technical reviewer acquired but not entirely official yet. Morale is high.

Stay tuned.

Meet Clojure Update

| Comments

I haven’t written a status update for Meet Clojure in quite a while, so here it is.

Keith, my editor, emailed me a few weeks ago wanting to work out a new schedule for the book. Several months had passed with little communication between us and I didn’t get very much work done on the book, so this was a welcome surprise. We worked out a schedule: first chapter in 2 weeks and then a new chapter every 3. I finished the first chapter nearly a week before my September 22nd deadline.

This is good news. Chapter 4 is done and is currently undergoing review. It is one of the largest and most important chapters of the book, so it’s actually a pretty large chunk of progress.

We are very excited to have a real solid schedule for the book and I am anxious to get more of the book finished. Schedules are fantastic motivation. That said, our new schedule will certainly not allow for a 2011 release. There is isn’t even speculation as to when it’ll all be ready to ship at this point, so I can’t really provide any information on that. The important thing is that I am actively working on this and that I have real deadlines that it would not be good for me to miss.

As far as my relationship with Libre/OpenOffice goes, it’s still a little strained. I’ve found that most of my hatred for it came while I was converting the existing book from my Pandoc markdown workflow to the No Starch OpenOffice workflow. It was extreme tedium and required a lot of things that OpenOffice isn’t designed for.

It is much, much easier to actually write new content with OpenOffice. No Starch’s template switches styles intuatively and when appropriate all by itself, so I rarely have to do a whole lot of mouse stuff. I do miss Emacs and markup, and I definitely wish OpenOffice didn’t suck at keybindings on OS X, but I’ll survive.

In summary: Work being done. Progress being made. Unicorns being milked for their magic.

Stay tuned.

Moved to Octopress

| Comments

I spontaneously decided today that, while sick, I would spend the day setting up Octopress and trying it out. I did. I liked. I replaced wordpress with it. Unfortunately, this comes with a few consequences.

  • I used exitwp to import my Wordpress posts into Octopress. While it did its job importing the posts, it managed to clobber paragraph breaks and all of my code along the way. I’m going to try to fix this as best I can in my most important posts, but I’m not going to do it for all of them.
  • All of the old links are broken. I never used readable links with Wordpress and Octopress (rightfully) uses them by default. Luckily, my blog isn’t very popular so the link breakage will be less significant. I do apologize to anyone linking to my blog though and hope that this doesn’t inconvenience them too much.
  • All of the comments are gone. Comments didn’t move with the Wordpress post, and since the links have changed and I’m using Disqus now, there isn’t a simple way to retrieve them.

I firmly believe that the benefits of switching to Octopress will outweigh the issues, even if the benefits only apply to me. I’m very excited to write my posts in Emacs and markdown and to be getting rid of a useless MySQL instance and several instances of php-cgi.

All Media Centers Suck

| Comments

Recently, I’ve had a little down time thanks to appendicitis and a good round of surgery, so I’ve been working on getting a media center set up on my laptop. Unfortunately, none of them do everything that I require. The big choices right now are XBMC, Plex, and Boxee. They’re all excellent in some areas and pathetic in others.

My Requirements

I’m pretty picky about what I need from a media center. My needs are not the same as everyone else. First of all, I have a poor internet connection. It’s fast enough to stream from Netflix, but it’s a verizon mifi card, and they don’t like it when you rape their bandwidth. Therefore, I have to keep my streaming to a minimum. Because of that, I have these things called DVDs. They’re these neat little discs that hold movies. I get them from Netflix and Redbox and I put them into my little disc drive and movies play on my screen. It works pretty well. I need for my media center to handle, at a minimum, Pandora radio, Netflix streaming, DVD playback, music playback, and the ability to control it all from my android phone with a wifi remote. Sounds easy, doesn’t it? Guess what. None of them do it.

Boxee

Boxee is great. It’s a little do-it-all media center that can run on your computer or a dedicated “Boxee Box” that you can buy. Ever since the Boxee box came out, development has been focused on it. Recently, everybody started whining so they promised to pick development back up and have a release out by… this fall. In any case, Boxee in its current incarnation is very nice. It can play Pandora better than Plex, and it can stream Netflix just fine. It can do a whole lot of other stuff as well. Unfortunately, the latest version for the mac, 0.9.23.15885, cannot play DRM’d DVDS. They’ve disabled DVD support and an issue in their issue tracking about it was closed as ‘won’t fix’ with no explanation. Goodbye Boxee. I hope that, in that next release, it’ll be enabled. If the DVD support worked, Boxee would be absolutely perfect.

XBMC

XBMC is the biggest one of them all. It’s the media center that the other media centers we’re talking about were based on. It’s a fantastic media center within itself. However, it doesn’t even come close to doing what I need. Out of all the things I require, the only thing it does is handle DVD playback and music playback. They haven’t even taken a shot at adding Netflix and such. No clue why, seeing as how the media centers like Boxee and Plex that are based on it do implement them. There are third party add-ons for Netflix and Pandora though. Haven’t tried the Pandora add-on, but the Netflix plugin, XBMC flicks, at this point in time, doesn’t work. It hasn’t worked for the better part of this year. Whether or not it’ll actually be fixed is up in the air. XBMC isn’t really much of an option for me.

Plex

Plex is awesome. It is like Boxee in that it gets all of the streaming and local media stuff right. Its Pandora support is a little wonky but appears to work. The Netflix support is perfectly fine. The problem is that it doesn’t support DVD playback in a meaningful way. It has *some* support for it. You can turn it on and hit ‘dvd’ in the menu. It goes straight to the DVD menu. I couldn’t find any settings for anything, and turning on subtitles is tedious and unintuitive. You can’t even eject the disc when you’re done. Plex is great, but the DVD support is basically worthless. The biggest thing that irks me is how little the developers seem to care about DVD support. I’m beginning to wonder if I’m the only person who sees the importance of it. For the past 2 years or so, they’ve been saying things like “It’s on our radar.” and “We need to improve that.” but haven’t done anything. Maybe in the next 10 years or so when DVDs are obsolete they’ll finish up the DVD support. ;) Now, there is a workaround. You can set up applications to launch from within Plex. For example, you can make the mac’s default DVD player launch, and when it’s closed, Plex will reopen. Nice! The problem is that, while I *can* control Plex using the Plex remote from my Android phone, I cannot control DVD player. Alas, the dream is dead. Until Plex has decent DVD playback, I’m out of options. I’m extremely disappointed with my findings. At this point in time, all media centers suck (in certain ways).

Updates: July 19, 2011

Eventually I decided on Plex. I ripped my entire DVD collection so the poor DVD support is less of an issue for me now. Furthermore, the Pandora plugin crappiness is not their fault. It turns out, Pandora is run by assholes who favor Boxee. I still think Boxee is nice. Plex is nicer. The media server and manager is fantastic and I can think of tons of uses for it in the future. Boxee plans to release a new version this fall (after the majority of their userbase had given up on them, assuming they had abandoned the downloadable version for the Boxee Box version), so it remains to be seen if it can win my heart. I doubt it. All it has that Plex doesn’t have that I want is a decent Pandora app, and it isn’t even Plex’s fault that it doesn’t have a good one. Boxee could be the best all around if it just had a few more developers to spare towards the downloadable version. But, it’s forgivable. They aren’t a huge company and they have to prioritize. I just wish the Boxee Box wasn’t the priority. They had a dream and they’re living that dream. Good for them!

An Update on Meet Clojure

| Comments

Introduction Recently, I announced that my book, Meet Clojure, was officially being published. This is true. Contract is signed, sealed, and delivered. It even has its very own website. The contract states that our initial soft deadline is November. I have no clue when it will actually be finished or when it will be in print, but I hope to have something that I can bring to the Conj with me. Early release copies or something, but it almost certainly won’t be in print by then. I’ll do something! I’m very excited that people are excited about the book, and I haven’t updated on my progress in a while, so that’s the purpose of this post. First of all, there hasn’t been much progress up to this point. I recently started a job writing Clojure at Geni, so I took a little time off from the book to focus on that. This is my very first job in the world, and it is very important to me that I am able to give them my best and still be able to do this book. I know I can. I’ve got a rhythm now, and I’m starting, slowly but surely, to continue work on the book. I want my progress to be an open thing. Writing a book is hard work, and a lot of people are confused about how the process works. I know I was. I’m going to talk about what is going on, how I’m approaching things, what exactly needs done, and what I’m working on now. More importantly, I’m going to talk about the problems I’m facing. Problems A very important part of writing a book is facing the problems that come with it. As with programming, there are always issues and ‘bugs’ that you have to deal with. I’ve went through 3 different editors and 3-5 different formats while writing this book. You know you’ve went through hell when you can’t remember what all you’ve written it in. I started out in Lyx, because it was the most approachable. Understand that I never intended on this book getting published. I figured that it would just be a totally free thing that I might self-publish dead tree copies of. Therefore, I had to use the things that I could most easily produce a nice looking PDF file from. Lyx was okay, but its editor is really terrible to write in IMO, so I eventually migrated the entire book to pandoc markdown. That was great. It was perfect. Unfortunately, my publisher, No Starch, requires that I write the book in OpenOffice or Word in order to take advantage of their stylesheet. I ended up spending a sickening amount of time migrating the book to OpenOffice. Each time I migrated the book to a new format, I had to do it by hand. The book would probably be done by now if not for that. OpenOffice is where I’m stuck, against my will. I’m dying for an asciidoc or markdown workflow from No Starch at some point in time, but if it comes, it will almost certainly be after my book is done with and finished. I could write something to take a plaintext format such as markdown or asciidoc and produce the ODT necessary, but with the stylesheet and such, I’d probably spend more time with that than actually writing the book. So, my biggest problem thus far has been facing OpenOffice (or LibreOffice, which is actually what I’m using). I simply cannot stand writing in this monstrosity. I spend more time clicking buttons and making sure my styles are correct than writing my book. Even the keybindings are awkward, since there is some bug in Open/LibreOffice that makes the ctrl key useless on OS X. I feel I have enough experience right here and now to declare that OpenOffice is simply not a good thing to have to write a book in. Especially for a programmer who is used to Emacs. But bitching about OpenOffice for three hours in a blog post isn’t going to get this book written. I do not blame No Starch for this. They have their workflow and it has worked fine for them before. They’ve just got a whiny Emacs user on their hands. There really aren’t many more clear ‘problems’. OpenOffice is one gigantic problem that I wish somebody would fix. If somebody feels like writing a plaintext format –> ODT converter that somehow magically supports OpenOffice stylesheets, I’ll name my first born after you. I shit you not. Moving on. What needs to be done, and what is being done Lots. Right now, I’m going through a phase of “well, I wrote all of this 6 months ago. I want to do x and y differently, so I need to change z and b and do n”. I find myself frequently not satisfied with what I’ve done, and thus rewriting an insanely large part of what is already done. This might sound like a great thing for the eventual reader, and it is, but imagine what kind of torment I have to face because of it. Right now, I’m reading the book from cover to cover (at least, what is already written) and I’m restructuring parts, rewriting parts, fixing parts, etc. There is a *lot* of work left to do here, because a lot of the book is already written. However, this is an important thing and would need to be done regardless of whether it is now or later. It needs to be now because then I can focus on how to structure the rest of the book. Next, there are several chapters that aren’t finished or haven’t even been started yet. Those need to be finished. Finally, I need to get up-to-date with Clojure 1.3 so that I can be sure that this book is entirely Clojure 1.3 compatible. There is no sense in another book for an outdated Clojure. Finally, on what needs to be done, I need to become accustomed to OpenOffice so that I can get work done. I’m not sure it is possible to be productive in this thing, but surely I can be useful. If I can keep from hanging myself first. Now, about this book Some people seem to have misunderstood me saying “This book is for complete beginners.” as meaning that the book is for complete programming beginners. It absolutely, positively, 100% is not. If you don’t have any programming experience, you almost certainly won’t get through the first chapter. This book is for complete beginners to Clojure, not programming in general. I’m not going to explain what control flow means, or the difference between an integer and a float. You need to have experience in approximately one programming language, and the fundamentals of programming should be clear to you. That said, this book is aimed at a very wide audience. Anybody who programs should be able to use this book. I’m working very hard to make this so, but it is a very difficult goal to achieve and if it doesn’t pan out, I apologize in advance. One thing you can feel safe knowing is that No Starch is very hardcore about technical and developmental review. They’re going to kick my fat ass all over Alabama until this book is worthy of reading, and I’m going to very willingly take that punishment. Conclusion Writing a book is hard. Writing a book in an environment you are unfamiliar with and hate is even harder. But I’m being whiny. I can do this thing, I just need to stop being lazy and focus. When I finish publishing this post and tweeting about it and such, I am going to spend an hour or two on my book. This whole thing is a lesson in discipline that I am grateful for.

Songbird in 2011

| Comments

So, I’m a secret long-time Songbird fan. I know, I know. Once they dropped Linux support everybody (including myself) ran like hell and never looked back. As it turns out, they may have been right about their Linux user base — it wasn’t that significant. Mostly, they just haven’t had quite as much publicity since then, because people got understandably butthurt. However, Songbird has continued to evolve, so one can only assume that they’re OS X and Windows user base is still going strong. Of course, Songbird still works on Linux and they put out ‘unofficial’ builds all the time, though they’re always labeled as ‘unofficial’ and ‘untested’ (whatever that is supposed to mean). I actually tried it on Linux and, save for some issues with conflicting gstreamers (Songbird ships it’s own version of gstreamer), it worked fine. I don’t quite understand what they mean by “we no longer support Linux” when, three years later, they’re still putting out Linux builds and they still work. I find it bizarre that they have volunteers that can handle this, but they can’t handle at least some resemblence of official ‘support’ for Linux? Songbird is open source, so I highly doubt it’ll ever be broken as long as Linux users that happen to be programmers are using it. Nonetheless, I stopped using it when I moved to Linux a few years ago. I’ve used everything else, but not Songbird. But now I’m on a mac, and I don’t even want to think about touching iTunes. My good ol’ Clementine is fantastic, but Songbird supports all sorts of stuff that it doesn’t, with CD ripping being a good example. Of course, Clementine will get all the features that I like at some point because it has an awesome developer, and the things it doesn’t support are things I don’t really need, but hey, I’m on a platform that Songbird officially supports, so why not? Alas, I’m using Songbird once again. Oh, the nostalgia. Songbird is good. Still sucks up a fat portion of memory, but shit, most media players do at this point, and Songbird does more than most and does it prettier than most. I’m the last person on earth to give a shit how much memory things use as long as I have enough to fit what I’m working with in, and I have plenty. I’m an Emacs user. I like the kitchen sink and all that. Songbird is beautiful: image The theme (feather) system is lovely, and Songbird can have virtually any look you can think of. That isn’t really what I was looking for though. Media views are important to me. I am extremely picky about how I am allowed to look at my music. In the screenshot above, notice there are several different panes. Those are ‘filter panes’. An alternative to the iTunesy list view, they allow me to look through my music and narrow things down based on genre, album, and artist. I’m actually surprised at how few media players have something like this. It seemed like a massive miss to me in that new fangled Miro thingy and is my top major reason for not using it. And, if filter view isn’t enough for you, the media view stuff in Songbird is extensible! You can actually add new media views via extensions, so you have an infinite number of ways to look at your media library and if you’re a programmer, you can create them yourself. This brings us to extensions, another neat feature of Songbird. Songbird is very Mozillia-y, being a descendent of Firefox, and has a very thorough extension system. When you think of Songbird extensions, think of Firefox extensions. They’re quite similar in capability. Chatzilla actually runs in Songbird, if you need an idea. Songbird is very modular and a lot of even relatively basic functionality is implemented as extensions, including the lyrics pane in my screenshot and even stuff like syncing. And this brings us to syncing! Songbird is great at syncing. Syncing is implemented as various extensions for MTP and MSC devices.I use my HTC Evo as my little music box, so I enjoy easy ways to throw music at it. Android is great because you can just drag and drop music into the file system just like you would on your own computer. However, there is something to be said for being able to sync from your desktop media player just by dragging and dropping it. This *almost* worked out of the box. Songbird detected my Evo as soon as I plugged it in. Syncing works out of the box for some devices because these devices are known and configured beforehand. Songbird has to know what types of media a device can take and thus it has to know about that device beforehand for it to work perfectly. If it doesn’t know about the device, it has to assume it is just a random standard media device and only assumes that it can play MP3 files. Apparently, for some reason, it couldn’t figure out my poor Evo, and my music collection mostly consists of OGG files. Jesus wept. So, Songbird keeps a file in the root of a device’s file system called .SBSettings.xml. This file can tell Songbird its capabilities (what it can play and what it can do). Therefore, it must be changed. I’m not a huge fan of editing XML files by hand just to sync music to a phone, so I found Devise, a fantastic little extension for Songbird for editing .SBSettings.xml. It provides a simple UI for defining your phone’s capabilities. I got all that done in about 30 seconds and was syncing music. If you find yourself in this position and Songbird can’t figure out your device, grab that extension. 9 times out of 10, you’ll spend hours trying to figure out how to write the XML properly yourself, especially if you aren’t a programmer. .SBSettings.xml isn’t meant to be edited by hand by users. Beyond this, Songbird does the typical things you’d expect from a media player. It actually even has some support for videos, but I’m not quite sure how much. If you haven’t heard much about it in a while, rest assured that Songbird is still heavily developed and well supported. If you’re on OS X or Windows, go ahead and give it a go. If you’re on Linux, hell, even you could give it a go. The whole “we’ve dropped Linux support” thing seems like a case of blowing ones wad a bit too early. That said, they could break it tomorrow and nobody would have even the slightest right to bitch about it because they would be able to play the “Hey, we called it…” card, rightfully. Songbird works on Linux right now, but it may not work forever. A lot of people just jump shipped and abandoned Songbird when they dropped Linux support when they could have saved the whole project if they had just stepped up and helped out. If you like Songbird, consider helping out with the Linux support. Nightingale is a step in the right direction, but they’re still having trouble getting off the ground. They’re keeping people updated but progress is obviously slow, and that is a direct result of not enough organization and manpower. Help them out. Nightingale is an important project. P.S. This whole post was meant to be about syncing Songbird with Android devices, but I’ll be damned if I didn’t turn it into a whole post about Songbird. Hope you enjoyed it and learned something anyway. :)

Seesaw and Tallyho, a Match Made in Heaven

| Comments

I do not like swing. Swing is the bane of my existence. As a matter of fact, none of the various Java GUI frameworks really make me happy. When I have to use GUI, I always use Swing regardless of my hatred for it, simply because it is the most accessible of the GUI frameworks. I haven’t written many GUI applications in Clojure because avoiding Swing became a goal. After a week or so of work on a desktop wordpress editor, I had decided that I would, at some point, write a wrapper around Swing to make it less insane and painful to use. I’m very happy to say that somebody took it upon themselves to do this, and it wasn’t me. Enter Seesaw There is a God of a man out there named Dave Ray who is working on a fantastic Swing wrapper in Clojure called Seesaw. Seesaw has a concept of ‘widgets’, where each Swing component is a widget and a widget is a much more clojury interface to the underlying component. The README is fantastic at explaining all of this, and I know that I won’t do it justice, so just read that. Enter Tallyho My family and I play a lot of card games. Games like UNO and Quiddler where scoring is essential and tedious. How much paper have you wasted during your lifetime just by scoring board games and such alone? Quite a lot, I’d bet. I know we have. Recently, we’ve been using an Android application for scoring. It works really well and made things a lot faster and easier. Our pens and papers rejoiced as the war against UNO ended and they were free. Now I have a laptop. A macbook pro, to be precise. When we play games, I tend to carry the laptop in with me and play music and such with it. It only makes sense that I would not crowd the table with my phone as well just for scoring when I have a laptop in front of me, but alas, I could find no decent score keepers like the one I used on Android. I was sad. I sat and pondered my life and the universe, cried a few tears, blew my nose, and decided that I would just write one myself. Tallyho Now we’ve already laid down the cold, hard facts, of which there are two: Swing sucks, Seesaw is awesome. Therefore, it was logicial that I write Tallyho using Seesaw, and so I did. The result is currently 111 lines of Clojure (and the majority really is Clojure and looks like Clojure and not Java!), and is actually pretty nice looking, if simple. There is a menubar and corresponding right-click menu that all have the same items: add player, delete player, reset scores, reset all scores. Everything you need for scoring. The whole main pane is just a giant JTable, a table with names on the left and scores on the right. To modify a player’s score, you double click on a row (a player) and a box pops up as seen above. You can enter -number to decrement a score or +number/just the number itself to increment a score. The most shocking thing about this is how quickly and easily I was able to write this. I got the basic thing written in 3 hours, and most of that was learning Seesaw and looking up JTable documentation. It has a good number of features, looks good, scales good, is cross-platform, stable, and all in about an hour a day for 3 days. I would have trouble with just finishing the thing if I had written it in straight Swing. There is nothing that can make me run screaming away from an application faster than Swing, but Seesaw made things better. The Code Since the entire application is weighing in at just 111 lines, I’ll go ahead and paste the whole thing, as it is right now, here: [clj] (ns tallyho.core (:use seesaw.core [clojure.string :only [join]]) (:import [javax.swing JOptionPane JTable] javax.swing.table.DefaultTableModel java.awt.event.MouseEvent) (:gen-class)) (def table-model (proxy [DefaultTableModel] [(to-array-2d []) (object-array [“name” “score”])] (isCellEditable [row column] false))) (defn calculate-score [[calc & digits :as all] old] (let [old (Integer/parseInt (str old)) digits (when digits (Integer/parseInt (join digits)))] (cond (= \+ calc) (+ old digits) (= \– calc) (– old digits) :else (+ old (Integer/parseInt (join all)))))) (defn validate [s] (when-not (empty? s) s)) (defn calc-new-score [old] (when-let [new-score (validate (JOptionPane/showInputDialog “Enter -number to decrease score.\nEnter either +number or number to increase score.”))] (or (try (calculate-score new-score old) (catch NumberFormatException e)) (do (alert “Enter a real number, dude.”) (recur old))))) (defn on-table-click [e] (when (and (= (.getButton e) MouseEvent/BUTTON1) (= 2 (.getClickCount e))) (let [s-table (to-widget e) row (.rowAtPoint s-table (.getPoint e))] (when (>= row 0) (when-let [new-score (calc-new-score (.getValueAt s-table row 1))] (.setValueAt table-model new-score row 1)))))) (declare score-table) (defn add-user [e] (when-let [user (validate (JOptionPane/showInputDialog “Enter the player’s name.”))] (.addRow table-model (object-array [user “0”])))) (defn delete-user [e] (when-let [row (selection score-table)] (.removeRow table-model row))) (defn confirm [] (= JOptionPane/YES_OPTION (JOptionPane/showConfirmDialog score-table “Are you sure?” “Seriously?” JOptionPane/YES_NO_OPTION))) (defn reset-scores [e] (when (confirm) (doseq [row (range 0 (.getRowCount score-table))] (.setValueAt table-model 0 row 1)))) (defn reset-game [e] (when (confirm) (.setRowCount table-model 0))) (def add-user-action (action :handler add-user :name “Add Player”)) (def delete-user-action (action :handler delete-user :name “Delete Player”)) (def reset-scores-action (action :handler reset-scores :name “Reset Scores”)) (def reset-game-action (action :handler reset-game :name “Remove All Players”)) (def score-table (doto (table :model table-model :listen [:mouse-clicked on-table-click] :popup (fn [e] [add-user-action delete-user-action reset-scores-action reset-game-action]) :font “ARIAL-PLAIN-14”) (.setFillsViewportHeight true) (.setRowHeight 20))) (def scroll-pane (scrollable score-table)) (def menus (menubar :items [(menu :text “Tallyho” :items [add-user-action delete-user-action reset-scores-action reset-game-action])])) (def main-panel (mig-panel :constraints [“fill, ins 0”] :items [[scroll-pane “grow”]])) (defn -main [& args] (invoke-now (frame :title “TallyHOOOOOOO” :content main-panel :on-close :exit :menubar menus))) [/clj] The project is also on Github. The most amazing part of this, IMO, is the menus. Look at them! Holy shit! Have you seen Clojure code that works with JMenus and JMenuBars directly? You *have* to abstract over it in every application just to be able to look at it and then look at yourself in the mirror in the morning with pride. With Seesaw, we have these reusable ‘actions’. We use these actions in the menubar and the popup menu so almost no code is duplicated or unnecessary. Then look at the frame. The frame is 5 lines of code and could fit on 2 or 3. With mig-panel, I can create a mig-layout’d panel so quickly and easily that it shouldn’t even be legal, and that applies to other layout managers as well. Seesaw is making Swing possible to read and is getting rid of tedium. At some point, it will be a fairly comprehensive wrapper. Right now, it is still experimental. It is experimental because we don’t really know what we want out of a Clojure Swing wrapper, and we’re experimenting to find out. The author is very open to feedback and he absolutely needs it in order for the project to continue and survive, so please use Seesaw and share your experiences with him. He is very responsive. The Seesaw project is more important than I can properly express here. GUI programming is very hard if you aren’t familiar with Java and Swing when you come into Clojure, and even harder to tolerate once you are. Seesaw has the potential to mitigate this problem effectively, but the community needs to play a part. Participate! Interested in Tallyho? I imagine that the people who read this won’t all be programmers. I also expect some people to end up here as a result of googling for score keeping apps, and that’s great. I hope Tallyho can serve your purpose. If you want to try it out, go to the project’s Github page, click the big ‘downloads’ button and then download the latest version of tallyho.jar. This is a standalone jar that you can use. On Windows, you can typically just double click such a jar for it to run. Otherwise, you can run it from the command-line by executing the command `java -jar tallyho.jar`. Usage of the application should be fairly self explanatory. If you run into any bugs or have any feature requests or anything like that, create an issue on the github page. Feedback would be enjoyed.

Seesaw’s Github page Tallyho’s Github page

TryClojure Update

| Comments

I’ve been seeing quite a few complaints about TryClojure’s stability/uptime lately. Understandably. The uptime of the site has been unbelievably pathetic. When I started TryClojure, Licenser, the author of its original sandbox, bought the try-clojure.org domain and hosted the site on his own server because I didn’t have anywhere to host it myself. His server used to run SunOS and now it runs OpenIndia. Both of which I am insanely unfamiliar with. This limited my ability to maintain the server and such. These complaints pointed out an obvious problem, and one that I am currently addressing and want to talk about here. My first step was to move TryClojure to Alan Malloy’s and my Linode VPS. As of right now, this server has been up for over 130 days since the very day we purchased it. Server uptime will not be a problem. Furthermore, I have the utmost control over the server and what happens to TryClojure. I can monitor errors and figure out problems that might make the site go down. A while back, I did a bit of a call to action for TryClojure. With the help of the people who participated, TryClojure was moved to Clojure 1.2, all dependencies updated, a new sandbox, and a fantastic new design. Unfortunately, some things didn’t get done, people lost interest, and once again TryClojure was left in the dust. I’ve been fairly busy lately. With the book and general everyday life, my whiny ass gets a little overwhelmed. Over the past week, I’ve been making time for TryClojure and I’ll keep doing that until TryClojure meets its expectations. My problem is that I’m just not that good at web development. TryClojure was my first and is my only serious webdev project. I can’t design a website for shit (thankfully, I know people who can) and I don’t know JavaScript. When I have to write JavaScript, I rely on JQuery and JS documentation to get me by. I’m learning slowly, but I don’t use it enough to know it at this point, which is unfortunate for TryClojure. However, I know people who do know JavaScript, and some of those people don’t mind helping out. This brings me to the actual point of this post. TryClojure is now live on my server with a huge update.

  • Everybody wanted a TryHaskellish interactive tutorial, well now you’ve got one! Thanks to mefesto from #clojure on IRC, we’ve been able to get an interactive tutorial up and running.
  • I’ve rewritten all the tutorial content and am working on adding more content to it over the next couple of weeks.
  • I’ve got rid of syntax highlighting in the tutorial and in the console, because it was never all that useful in the first place and required a jquery-console hack to work that meant I couldn’t update jqeury-console without doing that hack over again.
  • Because of this, I’ve been able to update jquery-console to the newest version which allows for copying and pasting! Copying and pasting was another of the big gripes (once again, understandably). You can do it now.
  • Clojail has been updated to the latest version (which is almost always the same version that sexpbot uses), and I’ll be updating the rest of the dependencies (ring and such) to the latest versions soon.

All of these changes are brand new and not guaranteed to be bug free. I’m still in the process of putting finishing touches on everything. Finally, I need to make one last point. Do you know how many TryClojure bug reports I’ve received since it was conceived (early last year, I believe)? Less than 10. Hell, maybe around 5. I don’t really use it, so I rarely find these bugs myself. If they are left unreported, I may never notice them. Remember google groups thread I linked earlier? That’s where these issues were raised. When those posts were made, TryClojure was down. As a matter of fact, that’s why they were made in the first place. I did not know that it was down. As a matter of fact, I didn’t even see those group posts until Alan mentioned it to me! I was kind of shocked that they were arguing about stability issues and TryClojure’s uptime without even letting me know that it was down in the first place so that I could figure out the problem. It is really easy to contact me. I’m always on IRC on #clojure and #sexpbot, my Github page is linked from TryClojure’s about page, and my Github page even has my email address on it. You can send a telegram if you want, I don’t care, just please let me know if something is wrong or else I can’t do anything about it. I am open to ideas as to how to make TryClojure better. If you’ve got an idea, by all means, pull the shit out of the repository and start implementing stuff. The great thing about open source is that we can all make TryClojure better together. I can’t do it alone.

Return (or, Progress Report on Meet Clojure)

| Comments

To start off, I’ll point out the obvious: I’ve been all but entirely inactive for around 2 months. My Github page does not lie. Alas, I’ve not written any code. I also haven’t written any of my book in the same amount of time. Well, besides maybe two sections and some various fixes. No serious new content. The fact of the matter is, I’m a teenager. I’m weak. These last two months, I’ve done things with my life that didn’t involve computers, and I enjoyed it. It was a ‘break’ of sorts for me. I have to say I needed it. People who know me can vouch on the amount of time that I was spending on the computer for a good year or two. Well, it’s about time I come back. My buddy Alan has been maintaining my projects while I was inactive. Awesome little San Francisconian fellow. Furthermore, I have a decent shot at getting my book published, so I really need to get back to work on it. I’m coming up with a battle plan that I’ll detail here. First of all, everything I said about the book is still true. It’ll be a totally free introductory text on Clojure even if I do get it published. Getting it published would just be a huge cherry at the tip of the ice-cream cone, because it would mean print versions and a little cash for myself in the process. No Starch seems interested in my book, and we’re currently figuring things out. Second, a lot of the book is written. It is nowhere near done, but I wrote a hefty amount of tome in a very short amount of time. Of course, speed doesn’t come without disadvantages. The book feels rickety to me. I’m not satisfied with how everything is right now, so I definitely have a lot of work do to. The first thing I want to do is read Chris Houser and Mike Fogus’s masterpiece, The Joy of Clojure, from cover to cover. There are a lot of things that I do not understand and that I need to understand in order to complete my book. One gaping hole in my knowledge is about reasonably advanced Java interop and concurrency stuff. These are things that I’ll have to spend time with and let sink in. After I finish The Joy of Clojure, I’m going to read my entire book (what is written) from cover to cover and restructure things, add content where content should be but is missing, and rewrite existing content that isn’t quite right. This is hugely important. After that, I can start adding new content. Furthermore, there are a lot of people that are interested in reviewing my book. Since the book is going to be open source, I am not stingy and any Clojurer who would like to help me out is very welcome to do so. Just email me or send me a message at Github. If you’ve already done this before and got no response, try again. Bug the shit out of me. I don’t mind. I think I’ve missed a few people, so I’m going to start compiling a list of these people so that I can keep track of who I should give material to. In conclusion: I’m back. You’ll be able to find me in #clojure more often again. The book is absolutely still in progress. Slow progress, but progress nonetheless. I haven’t left the Clojure game, I’ve only taken a break. I love you guys, Clojure, and programming in general way to much to disappear forever. Sincerely, Anthony P.S. Before you mention it, no, I’m not so important that I necessarily need a return announcement. But damn it, my ego asked for one, and who am I to deny him what he asks for?