If it's worth doing...By Kevin Marshall on May 9 2008If it's worth doing, it's worth refactoring.
Categories: General Comments: 0 It works! It works! Well, sort of.By Kevin Marshall on May 8 2008I actually got the background stuff for fubnub'ing feeds working today!
follow fubnub 4. Now all I have to do is Tweet away and when I'm ready to 'publish', I just send a direct tweet to fubnub that looks something like this: d fubnub #pt I'm publishing with fubnub! This command tells fubnub that it should grab my latest tweets (from my Twitter timeline), apply the template I choose to that data, and then send it via email to the address I specified. The subject of the email will be everything after the #pt in my tweet...so in this case "I'm publishing with fubnub!". Pretty cool eh? But there's already a little more you can do (and lots more in the works). 1. If I chose to publish to my blog instead, the stuff after the #pt would be used as my post title. (currently you can publish via xmlrpc to wordpress and other metaweblog supported xmlrpc clients) 2. If I want to wrap up a series of RSS feeds into one post, I can go through the set up process like I mentioned above and the only thing that needs to change (besides the template because we will be using different fields) is the #pt command to something like this: d fubnub #pr I'm publishing with fubnub! 3. fubnub also keeps track of the latest Tweet and/or RSS link that was included when you published, so that the next time you say to publish, it will not repeat items. (there are a few gotchas in the system right now because of limitations on what you can get out of Twitter timelines and RSS feeds, but the basic idea is true that it will not repeat data that it has already published.) Of course all of this will hopefully be broken down with images and examples on the actual fubnub.com site (just as soon as I get time to do that). I'll probably also build in support so that you can publish via tools at the fubnub site or by sending a publish command via email directly to fubnub (for those that don't want to mess with Twitter). I'm also going to be working on adding in support for other feed related sources like Tumblr and audioscribbler (last.fm stuff). For now though, the back end is up and running. So I'll be moving on to the front end (the fubnub.com web site)...once I get enough of that together, I can actually try and get a few other people out there trying/using it...and then we'll see where it takes us! Categories: General Comments: 0 The Perl DBI and MS SQL text fieldsBy Kevin Marshall on May 7 2008So I'm putting in a crunch effort to get this latest fubnub idea together and, as is the case with most of these crunches, I'm hitting little problems at every corner.
Error: DBD::ODBC::st fetchrow_array failed: [Microsoft][ODBC SQL Server Driver]String data, right truncation (SQL-01004)(DBD: st_fetch/SQLFetch (long truncated DBI attribute LongTruncOk not set and/or LongReadLen too
Searching around online, I found a number of people suggesting that you set a few options so that your code looks something like this: my $dbh = DBI->connect("dbi:ODBC:$dsn", $username, $password);
The LongTruncOk tells the driver that it's OK to truncate text fields if it needs to. The LongReadLen sets the number of bytes a single select statement should grab from a text field. For the most part, this was the extent of the solutions I found, so I guess it worked well enough for most people. However, I still had a couple of small problems -- OK big problems. It really wasn't OK to truncate my data and I don't know how many bytes of data my text fields might end up holding (which is one of the reasons I'm using a text field in the first place). So what to do? Well as it turns out, the ODBC driver for PHP that I use tends to have this same issue. As luck would have it the solution to the problem in PHP turns out to also work for this Perl DBD::ODBC situation. You simply have to get the length in bytes of the data you are going to grab (using the datalength function in T-SQL) and then make multiple calls to the database grabbing a substring of your text field in byte chunks. You just do this until you've loaded all your data into a variable. A code example shows this concept in action: my $dbh = DBI->connect("dbi:ODBC:$dsn", $username, $password);
So a couple of interesting things to note about the code above... First, I do actually use the two settings (LongTruncOK and LongReadLen) mentioned above. I picked the value of 255 bytes for my default text field size because it should grab most cases just fine for me...and the larger you make that block, the fewer times you have to do the additional query to get all your data. The downside of course is that you are using more memory the larger you set this value to. Second in my initial query I don't just get the datalength, I actually also grab the text field as well. This way, if my text field is smaller than the initial 255 byte chunk I told the driver to grab, I can just use the field directly like a normal select statement and avoid any extra database calls (remember database calls are ALWAYS expensive things you want to try and limit as much as possible). If the data in my text field is bigger than 255 bytes, I start doing my additional queries grabbing the next 255 bytes of the text field each time until I've got all the data for the text field loaded. Then I can finally move on without losing access to any of my data (I mean why would I put data into my database that I'm not actually going to need to get out and use in some way at some point?). Again, the downside to all of this is the number of database calls that you might end up making just to load your data into memory (so you can do whatever it is that you really want to do with that data). So just be mindful of how often you do this kind of thing, and try to design around having to do this as much as you can...especially in production and heavy load environments. Categories: Code, Database, General, Perl Comments: 0 Thought dump...By Kevin Marshall on May 6 2008XML without a DTD or Schema is basically just a CSV file with slightly harder processing rules. Sure you can get a little more out of the relationship of the data, but honestly not that much more than a well designed CSV.
Categories: General Comments: 2 Ka'ching.By Kevin Marshall on May 5 2008I put in some good time on the front end stuff of fubnub.com tonight...still nothing really worth chatting about or showing off, but it's one step closer to getting there Categories: General Comments: 0
|
Search All Posts »Blog Details »This blog now includes 120 wonderfully exciting posts from 1 unique and very special writer! Archives by Category »(20) Code »(4) ColdFusion » (9) Database » (8) Factor » (120) General » (9) JavaScript » (7) Perl » (12) PHP » (14) Ruby » Archives by Month »December 2007 »January 2008 » February 2008 » March 2008 » April 2008 » May 2008 » Sites you gotta visit »BotFu.comDraftwizard.com Reviews.com StoryRank.com Kevin Marshall - Who's that?I'm just your basic programmer. I can't spell to save my life, I'm not the greatest story teller, and I often ramble on about nothing. This blog showcases all of that! Believe it or not I wrote a book (Pro Active Record) for APress and a PDF (Web Services with Rails) for O'Reilly. If you're bored drop me an email at info at botfu.com or view my outdated resume. |
