With a little side of applesauce...

Thursday, September 30, 2010

Debian Squeeze - install Amazon MP3 downloader

The current Amazon MP3 downloader relies on an older version of Boost than is currently shipping in Debian Squeeze, (and Ubuntu Lucid Lynx 10.4).

Amazon MP3 downloader needs:
ii  libboost-date-time1.34.1                                    1.34.1-14                            set of date-time libraries based on generic programming concepts
ii libboost-filesystem1.34.1 1.34.1-14 filesystem operations (portable paths, iteration over directories, etc) in C++
ii libboost-iostreams1.34.1 1.34.1-14 Boost.Iostreams Library
ii libboost-regex1.34.1 1.34.1-14 regular expression library for C++
ii libboost-signals1.34.1 1.34.1-14 managed signals and slots library for C++
ii libboost-thread1.34.1 1.34.1-14 portable C++ multi-threading


And, Debian Squeeze has:
ii  libboost-date-time1.42.0                                    1.42.0-4                             set of date-time libraries based on generic programming concepts
ii libboost-iostreams1.42.0 1.42.0-4 Boost.Iostreams Library
ii libboost-python1.42.0 1.42.0-4 Boost.Python Library
ii libboost-thread1.42.0 1.42.0-4 portable C++ multi-threading


The easy way to get around this is to add a repo line for Debian Lenny to your /etc/apt/sources.list:
### libboost for amazonmp3 downloader
deb http://ftp.us.debian.org/debian/ lenny main


Then run the following commands in your terminal of choice:
sudo apt-get update
sudo apt-get -f install libboost-iostreams1.34.1
sudo apt-get -f install


Which will install the older version of libboost alongside the newer:
ii  libboost-date-time1.34.1                                    1.34.1-14                            set of date-time libraries based on generic programming concepts
ii libboost-date-time1.42.0 1.42.0-4 set of date-time libraries based on generic programming concepts
ii libboost-filesystem1.34.1 1.34.1-14 filesystem operations (portable paths, iteration over directories, etc) in C++
ii libboost-iostreams1.34.1 1.34.1-14 Boost.Iostreams Library
ii libboost-iostreams1.42.0 1.42.0-4 Boost.Iostreams Library
ii libboost-python1.42.0 1.42.0-4 Boost.Python Library
ii libboost-regex1.34.1 1.34.1-14 regular expression library for C++
ii libboost-signals1.34.1 1.34.1-14 managed signals and slots library for C++
ii libboost-thread1.34.1 1.34.1-14 portable C++ multi-threading
ii libboost-thread1.42.0 1.42.0-4 portable C++ multi-threading


The run the amazonmp3 downloader:
$ amazonmp3 


and enjoy your music :)

NOTE: These instructions should work for Ubuntu, except your /etc/apt/sources.list should look like this:
deb http://archive.ubuntu.com/ubuntu/ jaunty universe   

Wednesday, September 29, 2010

GridFox - grid layout tool for Firefox

I just found GridFox, which displays a grid on a web page, to help you verify your layout. Simple, yet priceless!

Monday, September 27, 2010

CSS vertical-align a button in a table cell

Note to self: You can't vertical-align a button if it shares the cell with other items, including non-breaking space...

Coldfusion - cfajaxproxy and natural sorting

I couldn't seem to get natural sort working when I using a bind on my CFSELECT. To get around it, I just passed the query object back as JSON to Javascript, and used this nifty Javascript naturalSort.js by Jim Palmer.

CFC:
    <cffunction name="getMeasurementBySourceID"
returntype="query"
returnformat="json"
access="remote"
output="no"
hint="get a Source's associated Measurement by SourceID from the ION_EEMData view vwSMP_SourceMeasurementPairs
@return query ">
...


Javascript:
<cfajaxproxy cfc="#Application.cfcPath#.Enviromon" jsclassname="e">
...

function getMeasurementBySourceID( sourceid ){
var inst = new e();
var result = inst.getMeasurementBySourceID( sourceid );

return result;
}

function getNodeList( nodefield, sourceid, nodeid ) {
var orig_nodes = getMeasurementBySourceID( sourceid );
var options = '';
var nodes = orig_nodes.DATA.sort(naturalSort);
for (var i=0; i<nodes.length; i++) {
if (nodes[i][1] == nodeid) {
options += '<option value="' + nodes[i][1] + '" selected="selected">' + nodes[i][0] + '</option>';
} else {
options += '<option value="' + nodes[i][1] + '">' + nodes[i][0] + '</option>';
}
}
if (nodefield == 1) {
$("select#nodelist").html(options);
} else {
$("select#nodelist2").html(options);
}
}
...


'nodefield' allows me to reuse this code for multiple nodes.

Here is a link to Jim's blog:
http://www.overset.com/2008/09/01/javascript-natural-sort-algorithm-with-unicode-support/

Wednesday, September 15, 2010

Python - UPDATE query with psycopg2

I am using psycopg2 to work with my Postgresql database, and was not getting my UPDATE queries to modify rows in the database. Aha! You have to run a conn.commit() after executing the query to commit the changes to the db.
            cursor = conn.cursor()
updateRecordStatus = "UPDATE queue SET status = " + str(status) + " WHERE qid = " + str(qid) + ";"
cursor.execute(updateRecordStatus)
conn.commit()
cursor.close ()


The tricky part of troubleshooting this was that cursor.rowcount and cursor.statusmessage were returning '1' and 'UPDATE 1' respectively, yet the row was not changing in the table.

Thanks to this example for helping me out:
http://www.daniweb.com/forums/post962021.html#post962021

Tuesday, September 14, 2010

jquery-tablesorter - not sorting by timestamp

I am finishing up my attendance application, but found that I couldn't sort my tables via a timestamp column with a 'yyyy-mm-dd hh:mm:ss.0' format. The answer? I needed to create a custom tablesorter parser:
        $.tablesorter.addParser({
id: "customDate",
is: function(s) {
return /\d{1,4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d+/.test(s);
},
format: function(s) {
s = s.replace(/\-/g," ");
s = s.replace(/:/g," ");
s = s.replace(/\./g," ");
s = s.split(" ");
return $.tablesorter.formatFloat(new Date(s[0], s[1]-1, s[2], s[3], s[4], s[5]).getTime()+parseInt(s[6]));
},
type: "numeric"
});
<cfif form.hat EQ 'eventattendance'>
$("#hor-minimalist-b").tablesorter({
sortList: [[1,1]],
headers: { 1: { sorter:'customDate' } }
});
<cfelse>
$("#hor-minimalist-b").tablesorter({
sortList: [[1,1]],
headers: { 2: { sorter:'customDate' } }
});
</cfif>



1. The addParser() definition needs to be above the tablesorter stanza.
2. I am just using Coldfusion to configure tablesorter for two different pages.

The parser was found in the links below:
http://www.weask.us/entry/date-sorting-problem-jquery-tablesorter
http://linkroller.com/fullpage/ad/13754/?http%3A//tablesorter.com/docs/example-parsers.html

Friday, September 10, 2010

Coldfusion autosuggest and leading zeros

I am adding this to my brain dump, as it is hidden in a comment in Raymond Camden's ColdfusionJedi article, "Using CF8 Ajax features to solve the 'pick one of thousands' issue":

In Coldfusion 8, autosuggest will strip leading zeros off of numbers. The fix is to add whitespace to the front and end of the number before returning it to the browser.

The answer is found here:
http://www.coldfusionjedi.com/index.cfm/2008/12/25/Using-CF8-Ajax-features-to-solve-the-pick-one-of-thousands-issue#c73DA7073-19B9-E658-9D097070DF8C2A6B

Wednesday, September 8, 2010

Coldfusion Query of Queries - Get first and last row of resultset

Since Query of Queries does not have a LIMIT keyword, I found this work-around to be sufficient for grabbing the first and last rows of a resultset:
<cfquery dbtype="query" name="durationUserRecords">
SELECT * FROM getEventAttendance
WHERE email = <cfqueryparam value="#getEventAttendance.email#" cfsqltype="cf_sql_varchar" maxlength="50">
ORDER BY attendancetime ASC
</cfquery>
<cfset oldestTime = durationUserRecords [ "attendancetime" ][ 1 ]>
<cfset newestTime = durationUserRecords [ "attendancetime" ][ durationUserRecords.RecordCount ]>

Thursday, September 2, 2010

Mac OSX / Adobe Bridge CS5 - error occurred in a Bridge extension, and insufficient disk storage

We have found an interesting problem with Adobe Bridge CS5, Mac OS X 10.6, and CIFS shares from our Netapp. When starting Adobe Bridge CS5, we received four errors:

'TypeError: undefined is not an object;
onResize()
buildUIStack(true, "Cabinet")
...'

'TypeError: undefined is not an object:
onResize()
buildUIStack( true, "Cabinet")
...
populate([Group:[object Group]],true)'

'An error occurred in a Bridge extension
Javascript error .../amgMain.jsxinc:1251: dropdown.onChange is not a function'

And, when trying to save a PDF or Web Gallery via the Output Module:

Our issue was caused by Windows/CIFS network shares mounted on the desktop. Once we unmounted the CIFS shares, all javascript, and disk storage errors went away. Interestingly enough, we also have a CIFS share, (also from the Netapp), which has UNIX-enabled security, and which does not cause Bridge to throw any errors when saving through the Output module...

So to sum-up:

1. Bridge CS5 is throwing the same error messages on startup, and when using the Output module to save to the local harddrive, as posted by JM at the start of this thread.
2. The errors are fixed by unmounting any Windows-security enabled CIFS shares, in our case, from a Netapp.
3. UNIX-security enabled CIFS shares from the same Netapp do not cause any errors.

Like JM we were not trying to access any of the network shares, and were trying to save to /Users/ouruser/Documents/, which are on the local harddrive.

We only encountered the issue, JM and the users on the thread get all of the credit for finding the work-around.
http://forums.adobe.com/message/3104027
http://forums.adobe.com/message/3102195#3102195