Posted on Leave a comment

SQL Query Conundrum

Here’s a interesting SQL challenge:

Say you have a query returning a result set that in some cases one row cancels out another. For example, let’s say there are 5 columns: A B C D E. One result possibility is: row 1- A B C 4 E with row 2- Z Y X 9 E Naturally those are completely separate data elements. But when row 1 is A B C 4 E and row 2 is A B C -4 E row two is a data correction to row 1 (think double entry accounting) and row 1 and row 2 need to be excluded from the result set. So, right now if the result set returned 20 rows and had the situation above, we really only want to be returning 18 rows. What’s a good approach to this?

Here’s a better representation of the problem:

Row Name Account Rank Value Status

  1. G H I 5 J
  2. A B C 4 E
  3. A B C -4 E
  4. Z Y C 4 E
  5. A B C 7 E
  6. Z Y C 22 E

We really want to return rows 1, 4, 5, and 6.

Posted on Leave a comment

Query of queries reports runtime error

So are you pulling your hair out because your query of queries is returning an error "Query Of Queries runtime error."? The solution is rather simple. In your query that is feeding your QoQ, you probably have a column that is of datatype nchar. Cast that to a varchar and life will be good. Do the cast in the source query not the QoQ. eg. "CAST(foo AS varchar) AS bar" You’re welcome.

p.s. Yes, you can cast it to the same column name eg. "CAST(foo as varchar) AS bar" Case doesn’t matter.

Posted on Leave a comment

Programmer/Artist

As a programmer, I often feel like an artist reusing the same canvas over and over and no one ever looks at the painting. As I make modifications and improvements to a program, my previous creation vanishes often without having been appreciated by another programmer. I write tomes of code and a vast percentage of that writing ends up in the fire.

Posted on 11 Comments

WordPress 3.4 limited to 90 menu items

I’m working on a WordPress site. The site is to have roughly 106 pages all accessible via the WordPress menu system so that the enduser can add and remove pages from the menu as they like. Unfortunately, WordPress currently only allows 90 nodes (ie. 90 menu items) per menu. I have not figured out if this is a memory limitation, a hard coded limitation, or a setting yet. This must be overcome!

Reference:

Possible solutions:

  • Use add descendants as submenu items plugin
  • Check error logs and make sure max post vars was not exceeded. If so, increase in either .htaccess or php.ini
  • See if suhosin.post.max_vars and suhosin.request.max_vars are used with Dreamhost
Posted on Leave a comment

Changing the behavior of WordPress’ Publish button

A long unrealized goal of mine has been to change the behavior of WordPress’ publish button when adding a new post. Today, I’ll spend a little time examining the underlying code.

obert- and pixolin in Freenode’s #wordpress gave me good pointers to the WordPress forum and the WordPress hook directory.

I narrowed it down to two functions: wp_insert_post() and wp_publish_post(). Turns out that the correct function is wp_insert_post(). The only thing that wp_publish_post() does is to transition the status. Looks like I should be able to alter wp_insert_post() in my functions.php file and achieve my goal.

Got it!

Relevant references:

Posted on Leave a comment

Cross-domain communication

If I have an aspx site on one server, let’s call it foo.com and I have a php site on another server, let’s call it bar.com, and I want to use an iframe to include data from foo.com within the bar.com site, security for iframes prevents this correct?

So, if I instead create a subdomain of foo.com, let’s call it bar.foo.com and use bar.foo.com for the aspx site, does that overcome the cross-domain security issue since both sites are now part of the foo.com domain or does the nature of bar.foo.com being a tertiary domain still create the security issue since bar.foo.com is technically different than foo.com?

Posted on Leave a comment

WordPress Hooks, Actions and Filters – Modifying the Publish function

I’m writing a child theme to twentyeleven and want to modify the administrative post "Publish" function to do some additional processing during the saving of a new post. Does anyone know if there is a hook, action or filter that will allow me to extend the Publish function?

Posted on Leave a comment

Subversion Error Message On Branch/Tag

Today’s tech problem:

I am trying to create a new baseline for my code. I have checked my code out of my repository, updated individual files to the proper version for the baseline, and then when I try to tag or branch the working copy, I get an error.

Error Commit Failed (details follow):
Error File
Error ‘/svn/foo/bar/branches/blah/snafu/path/to/file/file.cfm’
Error already exists

Because of the failure, the branch attempt, or tag attempt, fail leaving the branch/tag empty.

How can the file already exist if the branch/tag starts out completely empty?

Posted on Leave a comment

Call to action: WordPress Developers Please Comment

Hello WordPress developers! (me included). When you make a theme, I implore you, please use a simple html comment at the top of each page to identify the template. For example: <!- – TEMPLATE: single.php – -> would allow someone unfamiliar with your theme to look in the generated source and see which template(s) are influencing the output. Yes, experienced WordPress developers should already know which files are being used but we don’t write themes only for experienced developers. And even experienced developers get stuck, tired, or would like things to be sped along and a simple comment, <!- – TEMPLATE: page.php – ->, would help tremendously. Thank you!

Posted on Leave a comment

Don’t use underscores in css ids

Today’s reminder from your friendly neighborhood codeslinger is "don’t use underscores in css ids!" You know, those lines _ that programmers like to use instead of spaces in variable names (because you can’t really have spaces in a variable name in most languages). This was an illegal character in the original CSS1 and CSS2 specifications (updated in 2001 to be valid) so setting an id to foo_bar (e.g. <div id="foo_bar">) would be translated by the browser as foo\_bar (e.g. <div id="foo\_bar">), well, some browsers, not all browsers because you know browsers are so consistent in their interpretation and implementation of these so called web standards.

The solution? Instead of underscores, opt for dashes (e.g. <div id="foo-bar">) or camel case (e.g. <div id="FooBar">) but remember that id’s and class names are case-sensitive.

See also.

Posted on 10 Comments

jquery challenge of the day

And now for something completely different…

Let’s say you have a table that could have infinite rows. The table has an id but none of the other elements (ie. we won’t be traversing by id). The column to the furthest right of the row has an anchor tag in the for of an <a href> There are no other anchors on that row. What I want to do is when the anchor tag is clicked, have the <a href> text in the row above the clicked on turn bold and only that <a href>. Sample table:

<table id="tbl">
   <thead>
      <tr>
         <th>col 1 label</th>
         <th>col 2 label</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>one</td>
         <td>sometext <a class="tt" href="#">link</a></td>
      </tr>
      <tr>
         <td>two</td>
         <td>moretext <a class="tt" href="#">link</a></td>
      </tr>
      <tr>
         <td>three</td>
         <td>differenttext <a class="tt" href="#">link</a></td>
      </tr>
      <tr>
         <td>four</td>
         <td>othertext <a class="tt" href="#">link</a></td>
      </tr>
   </tbody>
</table>

So, if I click the link in row three, I want the text "link" in row two to become bold. This is using jquery and traversing this is kicking me hard.