Works
SELECT 409.95 = (1 + 408.95)
Doesn't
SELECT 409.95 = (a + b)
Works
SELECT 409.95 = CAST((a + b) AS decimal)
Works
SELECT 409.95 = (1 + 408.95)
Doesn't
SELECT 409.95 = (a + b)
Works
SELECT 409.95 = CAST((a + b) AS decimal)
I don't know how (yet) and I can't recreate it, but I swear that Eclipse ate two of my files while in the CFEclipse perspective. Neither of which I had placed under version-control yet. (DOH!) I was able to recover one of them from a nightly back-up.
When trying to figure out exactly what the heck happened, I took a peek at the local history for my back-up file and Eclipse still had the record of my changes up to the moment I lost the file!
Sooooo I re-created my lost file, right-clicked "Compare With" and "Local History" and I was able to re-cover the latest version of my file!
Phew!
I've spent some time searching and I've finally found a good tool for auto-formatting SQL! Simply paste in your fugly code, make any configuration tweaks, post and *bam*. Beautiful SQL.
Great for those ColdFusion dumps.
There's also a desktop version, but I didn't check it out.
Half-Life is the game of choice at work, and sadly I'm terrible at it. I thought I'd try to write a little game using gosu to try and help me improve my accuracy. I just reached a good stopping point and I thought I'd share.
It's really simple, the idea is to shoot little 20 x 20 "targets" (I'm artistically challenged) before they expire. Missing or letting 10 targets expire will end the game. Next version will include sound, improved visuals and maybe even a couple other fun features if your lucky.
The code is a bit over-engineered but I plan on incorporating parts into some "core extensions" that I'm working on that will hopefully make it a lot easier for me to bang stuff like this out. Finally, as I doubt anyone will ever download this, I didn't bother to pack it up so you'll have to have Ruby and gosu installed in order to enjoy it.
PS: I've been a Photoshop user for many years, but I used GIMP to make these images and I didn't even hate it!
I've made a small date to my interpretation of Conway's Game of Life yet again. Now instead of generating a random graph you can actually click on tiles to turn them "on" or "off".
Here's the code and here's how it do.
You can find the older versions of the files here: http://joezack.com/index.php/tag/game-of-life/
I wrote up a basic model for a 52 card deck of playing cards in JavaScript (using beloved Prototype. I plan on using it to make some very simple card games in the near future. I thought it'd be interesting to post this before I actually used it anywhere so I could take a look at how much it changed after I actually implemented it.
There's not much to see at the moment. You can just shuffle and get a card dump:
<html> <head> <title>JavaScript Deck of Cards</title> <script src="/common/prototype.js" type="text/javascript"></script> <script src="deck_of_cards_v1.js" type="text/javascript"></script> </head> <body> <script> d = new Deck(); alert(d); d.shuffle(); alert(d); </script> </body> </html>
As anyone subscribing to MXNA has heard en masse today, the big news 'round the CF Circuit is the announcement of a ColdFusion "development tool" affectionately titled Bolt. (Although Adobe does has a habit of changing titles on us)
Here's what I'm on about.
1. Will it run on Linux?
This is a requirement for me. Since it's an "Eclipse based development tool" I assume it will, but I'd like to see it asserted. I don't mind paying a reasonable sum, but not if I have to wine or vm it.
2. Is it a plug-in or an IDE?
I hope by "development tool", they mean plug-in. At the time of this writing there are 1101 plug-ins listed on eclipseplugincentral.com and I'd like to be able to use any and all of them if I so choose. If I want to run Spket instead of JSEclipse, I don't want any grief about it. Also, I like having an agnostic editor. I want one IDE to rule them all. Chances are that if I have to keep eclipse around for my other languages then I'll probably going to just stick with it.
3. Bloat-i-ness?
I'm a little worried about Bolt being tacked onto eclipse along with a laundry list of exciting! new! features! that I won't use past the first week, but making for great upper-management selling points. I'm drowning in features as it is. This wouldn't be such a big deal except that I've noticed eclipse can be a memory hog. I know it's not an accurate measurement but it irritates me when I pop open the task manager on my windows box and see eclipse running well into the hundreds of megs, especially when e does most of what I want with a fraction of the memory and cpu usage.
All I really need out of an IDE is multi language and OS support, code-highlighting, snippets, RDS, auto-tabbing and intellisense. I signed up for the beta; if you can do this better than Eclipse, Adobe, I'm all yours.
I was working on implementing a ColdFusion payment processor for Chase Paymentech, but I kept running into the same error (which I've formatted so nicely using my ruby clipboard format utility!)
<?xml version='1.0' encoding='UTF-8'?> <Response> <QuickResp> <ProcStatus>05</ProcStatus> <StatusMsg>PTI43,TEXT/XML; CHARSET=UTF-8 is not supported</StatusMsg> </QuickResp> </Response>
I knew that PTI43 was part of the MIME Header Content-Type I was passing, so I did a little bit of poking around in the docs and came upon this. Apparently setting a cfhttpparam type of "xml" "identifies the request as having a content-type of text/xml.".
In order to send a valid message to chase you have to specify a particular MIME header setting "Content-Type", which ColdFusion was garbling. Thankfully all I had to do to fix it was switch the cfhttpparam type attribute to "body" in order to fix it.
<cffunction name="Authorize" output="no"> <cfargument name="vars" required="yes"/> <cfset var cfhttp = ""/> <cfset var i = ""/> <cfheader name="POST /AUTHORIZE HTTP/1.1"> <cfhttp url="#GetURL()#" port="#GetPort()#" method="POST"> <cfloop collection="#arguments.vars#" item="i"> <!--- header variables ---> <cfif i NEQ "XML"> <cfhttpparam type="header" name="#i#" value="#arguments.vars[i]#" /> </cfif> </cfloop> <!--- set the type to "body" NOT "xml"!!! ---> <cfhttpparam type="body" value="#arguments.vars["XML"]#" /> </cfhttp> <cfreturn cfhttp/> </cffunction>
I hadn't run into this problem before, so I thought I'd share!
There's a legacy app I work on that currently requires adding 4 columns and a couple rows (in different tables) every time you add a row to another table. It doesn't happen often and it would be a nightmare to refactor so I wrote little script that would search the database for any columns named 'x' as well as any fields with a value of 'x' and return an array of the offending tables.
I cleaned it up a little bit and cfc-ized it in case I ever have to do anything similar. I haven't tested it at all aside from the one time I ran it today so use it at your own risk. It's really simple to use, you just need to pass in the ColdFusion datasource name and the search term.
Example Usage:
<cfset db_util = CreateObject("component","db_util").init(dsn = "datasource_name")/> <cfoutput>Looking for column <strong>#search_term#</strong></cfoutput> <cfdump var="#db_util.FindColumn(search_term)#"> <cfoutput>Looking for value <strong>#search_term#</strong></cfoutput> <cfdump var="#db_util.FindValue(url.looking_for)#">
Download ColdFusion MySQL Search Utility!
PS: it won't search numeric columns if you aren't searching for a number.

During a brief period in elementary school drawing these things was quite the cool thing to do. I've been messing around with the GD2 module a bit lately and I thought it'd be fun and easy to write a little script to generate one.
It was.
The drawing algorithm
@nodes.times do |i| adjustment = i * @node_size pen.move_to adjustment, 0 pen.line_to 0, @size - adjustment end
Example Usage:
#takes in the output image size and the number of nodes c = Curve.new 180, 30 c.draw c.export "test.gif"
*Note: If your output size doesn't divide evenly by the number of nodes then the image will actually reduce the size of the output image.