Summary: My Secret Life as a Spaghetti Coder
Posts about Ruby, Java, Coldfusion, OOAD, TDD, DSLs, and more (some not TLAs!)...
My take at this concept was too long for twitter, and I was too
lazy to pare it down: In ...
Date Published: Feb 08, 2012 - 5:51 am
You know when you see code like this: class CompulsionsController
< ApplicationController # ... standard actions
above here def update if params
[ :obsessions ] . include ? ( ObsessionsTypes [
:murdering_small_animals ] )
handle_sociopathic_obsessions
redirect_to socio_path and return elsif params
[ :obsessions ]
handle_normal_obsessions redirect_to
standard_obsessions_path and return end
...
Date Published: Feb 01, 2012 - 4:44 am
Most online developer API services that I've used are set up as if
the customer is also the software developer. That should change. As
the software developer, I don't want to be the owner of my
customer's accounts, and I don't want to worry about trying to
figure out how to transfer ownership (if your service allows it,
that is). Because of that, theres a lot of waste that goes on:
wastes of my time, which wastes my customer's or my company's
money. I'm saying "customer" here, but you might substitute that
with "the person who really needs / ...
Date Published: Jan 27, 2012 - 5:01 am
Type Casing is the act of using case statements in a program to
determine what to do with an object based on what type of object it
is. It's an OO fail, often hoping to implement Multiple Dispatch .
(See also Case Statements Considered Harmful ) Here are three
passive-aggressive ways to feel like you're getting back at
typecasers. The first tactic turns your object into an everything ,
so it's whatever the typecaser was looking for. I've called it
OmniObject . module OmniObject def is_a? ( * ...
Date Published: Dec 21, 2011 - 7:49 am
Suppose you have some awesome analytics tool that provides great
value to a bank's customer, but they need to interact with it
through the bank's website, and you need to host the tool. You
already have the data you need for the analytics to work, and the
only missing piece you're left to consider is "how do I know to
whom to show which data?" The data is private, so you need to
ensure you're not showing it to someone who's not authorized to see
it. Photo by pbkwee Some more constraints: ...
Date Published: Dec 09, 2011 - 5:13 am
With a name like each_cons , I thought you were going to iterate
through all the permutations of how I could construct a list you
operated upon. For example, I thought [ 1 , 2 , 3 , 4 ] . each_cons
do | x | # I did not notice the required argument puts x.
inspect end would output: [[1,2,3,4], []] [[1,2,3], [4]]
[[1,2], [3,4]] [[1], [2,3,4]] [[], [1,2,3,4]] So when I needed to
find the ...
Date Published: Oct 24, 2011 - 8:45 am
It's a small step, but emcee-3PO can now identify the staves in an
image of sheet music for my single test case of "My Darling
Clementine." I need to include hundreds more test cases, and I plan
to when I implement code to make the tests mark the sheet music
with what emcee3po detected so I can visually inspect the accuracy.
Ichiro Fujinaga's "Optical Music Recognition using Projections"
(PDF) explains the process in detail, but it turns out to be
relatively simple. To locate the staves: Do a y-projection on the
image. ...
Date Published: Oct 17, 2011 - 3:20 pm
plupload-rails3 is ...
Date Published: Oct 12, 2011 - 1:58 pm
If you follow me on twitter , you already know I ran into some
trouble compiling Ruby and OpenSSL the other day. Calling it "Some
Trouble" might be a bit of an understatement. The next morning, I
likened it to this title bout: Not only was Ruby and OpenSSL giving
me trouble, in my quest to get it working, I totally messed up
everything that depended on OpenSSL . Email with TLS? Gone. SSH?
Yep, gone as well. Tech support's first recommendation was to
requisition a new server. Of course I wasn't going ...
Date Published: Sep 09, 2011 - 1:43 pm
Frequent changes and deprecations to technology you rely upon cause
dependencies to break if you want to upgrade. In many cases, you'll
find yourself hacking through someone else's code to try to fix it,
because a new version has yet to be release (and probably never
will). That can be a chore. I get embarrassed when something I've
recommended falls prey to this cycle. Backwards compatibility is
one way to deal with the issue, but in the Rails world, few seem
worried about it. It doesn't bother me that code and interface
quality is a high priority, but it does cause ...
Date Published: Sep 02, 2011 - 2:18 pm
emcee-3PO takes a text file of music, runs it through a Markov
Model, and generates new music to be played with Archaeopteryx .
It's an idea I've had for a while, which _why day gave me a good
excuse to start. There's not much there yet -- the first sentence
above tells you exactly what it does -- but I hope to add some
features to it as time allows: Read from sheet music Use different
instruments instead of simply playing the notes as written / make
it symphonic Choose probabilities in some smart way to ...
Date Published: Aug 19, 2011 - 4:46 pm
Update: Ruby 1.9.3 adds the ability to use ranges as arguments to
rand , which produces more obvious code. So if you're using it,
instead of using "magic offsets" like I did in the original post
(as Joni Orponen mentions in the comments below), it would be
better to use rand(1..6) to simulate a die roll. So to summarize:
if you need a percentage between 0 and 1, just call rand . If you
need an integer between 0 and x (not including x), you can still
call rand(x) . Finally, if you need a number in a specific range,
...
Date Published: Feb 15, 2012 - 4:58 am