For a long time I couldn't figure out how to make decent thumbnails
with
ImageMagick. Specifically, I wanted to create uniform sized
thumbnails from arbitrary images. Over the weekend I came across the
ImageMagick Examples page, which shows exactly how to do
this. Here's the command for a 150x150 thumbnail,
convert orig.jpg -thumbnail 150x150^ -gravity center \
-extent 150x150 thumb.jpg
It cuts out the largest square possible from the center of the image
and resizes that to 150x150. This capability has actually only been
available for 2 years now! It wasn't there last time I needed it.
I can think of one way to improve it: instead of selecting the center,
it selects the area with the highest information density. This could
be measured by edge detection, corner detection, or some other
statistical method. It would be selected by changing the gravity
option to, say, "entropy".
I'm listing this here mostly for my own future reference. :-)
Since I recently got back into Java recently, I threw together this
little Game of Life implementation in Java. It looks a lot like my maze generator/solver on the inside,
reflecting the way I think about these things. Gavin wrote a
competing version of the game in Processing which we were partially
discussing the other night, so I made my own.
The individual cells are actually objects themselves, so you could
inherit the abstract Cell class and drop in your own rules. I bet you
could even write a Cell that does the
iterated prisoner's dilemma cellular automata. The Cell objects
are wired together into a sort of mesh network. Instead of growing it
wraps around on the sides.
It takes up to four arguments right now, with three types of cells,
basic, implementing the basic Conway's Game of Life,
growth, which is a cell that matures over time, and
random which mixes both types together (seen in the
screenshot). The arguments work as follows,
Developing C in Emacs is a real joy, and it's mostly thanks to the
compile command. Once you have your Makefile -- or SConstruct or
whatever build system you like -- setup and you want to compile your
latest changes, just run M-x compile, which will run your
build system in a buffer. You can then step through the errors and
warnings with C-x `, and Emacs will take you to
them. It's a very nice way to write code.
I use the compile command so much that I bound it to C-x
C-k (C-k tends to be part of compile key
bindings),
(global-set-key "\C-x\C-k" 'compile)
Until recently, I didn't have as nice of a setup for Java. Since they
generally force offensive IDEs onto me at work this wasn't something I
needed yet anyway, but I get to choose my environment on a new
project this time. If you're using Makefiles for some reason when
building your Java project, it still works out fairly well because
they're usually called recursively. It gets more complicated with Ant, where there is only one
top-level build file. Emacs' compile command only runs the build
command in the buffer's current directory.
I know three solutions to this problem. One is to provide the build
file's absolute path when compile asks for the command
with the -buildfile (-f) option. You only
need to type it once per Emacs session, so that's not too bad.
ant -emacs -buildfile /path/to/build.xml
It's not well documented, but there is a -find option
that can be given to Ant that will cause it to search for the build
file itself. This is even nicer than the previous solution. Just
remember to place it last, unless you give it the build filename
too. For example, if you wanted to run the clean target,
ant -emacs clean -find
To keep the actual call as simple as possible, I wrote a wrapper for
compile, and put a hook in java-mode to
change the local binding. The wrapper, ant-compile,
searches for the build file the same way -find would do.
(defunant-compile ()
"Traveling up the path, find build.xml file and run compile."
(interactive)
(with-temp-buffer
(while (and (not (file-exists-p "build.xml"))
(not (equal "/" default-directory)))
(cd ".."))
(call-interactively 'compile)))
So I can transparently keep using my muscle memory compile binding, I
set up the key binding in a hook,
Yesterday was a slightly chilly day, in the mid 50s (Fahrenheit), so
when my officemate said we were getting snow I thought she was
kidding. Well, today we woke up to this winter wonderland,
My wife leapt for her camera and filmed that as soon as she realized
what was going on. We had much more than that by late afternoon.
According to the
Baltimore Sun it has snowed on December 5th for six of the last
eight years, and we don't get much snow around here. My only wish
would be for this to have happened on a weekday. I work for a
university, and educational organizations tend to fold and give snow
days really easily. This would probably have given me a nice paid day
off!
Don't stop here! This isn't everything. Check out the archives
(on the left) for more posts. Or just have a look at
the index.