"Murphy was an optimist!"
SQL Query Conundrum June 17, 2013 9:43 am
Posted by Doug McCaughan in : MS SQL, Programming, TechnologyHere’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:
add a commentRow Name Account Rank Value Status
- G H I 5 J
- A B C 4 E
- A B C -4 E
- Z Y C 4 E
- A B C 7 E
- Z Y C 22 E
We really want to return rows 1, 4, 5, and 6.
Query of queries reports runtime error February 22, 2013 12:21 pm
Posted by Doug McCaughan in : ColdFusion, Programming, TechnologySo 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.
add a commentjqGrid so powerful! February 22, 2013 9:51 am
Posted by Doug McCaughan in : JavaScript, jQuery, Programming, TechnologyI am loving working with jqGrid. My latest discovery is the ease at which elements on the grid can be changed. For instance, if you want to change the default "View 1 – 10 of 98" you can do it in either the language file or simply by adding a parameter to the grid:
add a commentrecordtext: "View {0} – {1} of {2} addwhateveryourwant",
Programmer/Artist February 15, 2013 11:41 am
Posted by Doug McCaughan in : Programming, TechnologyAs 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.
add a commentNOOOOOoooooooo! December 9, 2012 12:46 pm
Posted by Doug McCaughan in : HTML, Humor, Of Interest, Programming, TechnologyWordPress 3.4 limited to 90 menu items June 19, 2012 9:26 am
Posted by Doug McCaughan in : MySQL, PHP, Programming, Software, Technology, WordPressI’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
Changing the behavior of WordPress’ Publish button June 16, 2012 11:07 am
Posted by Doug McCaughan in : Programming, Software, Technology, WordPressA 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:
- codex wp_insert_post_data
- wp_insert_post hook for a wordpress plugin
- wp_insert_post with POST data
- Codex wp_insert_post
- codex developer documentation
- Codex pluggable functions
- How to add days weeks months to any date
Cross-domain communication January 11, 2012 9:16 pm
Posted by Doug McCaughan in : HTML, Programming, TechnologyIf 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?
add a commentWordPress Hooks, Actions and Filters – Modifying the Publish function January 4, 2012 10:38 am
Posted by Doug McCaughan in : Blog, Communications, PHP, Programming, Publishing, Software, Technology, WordPressI’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?
add a commentSubversion Error Message On Branch/Tag September 15, 2011 11:21 am
Posted by Doug McCaughan in : Programming, TechnologyToday’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?
add a commentFrom the mouths of programmers August 17, 2011 7:06 pm
Posted by Doug McCaughan in : Daily Life, From the mouths of babes, Programming, Technologyadd a commentNow that the day is over, I can finally begin my work.
Google’s Voice Search June 17, 2011 10:49 am
Posted by Doug McCaughan in : Programming, Software, TechnologyI think I’ve seen this and never paid any mind to it. How long Google had voice search on Chrome?
1 comment so farCall to action: WordPress Developers Please Comment February 17, 2011 9:33 am
Posted by Doug McCaughan in : PHP, Programming, Software, Technology, WordPressHello 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!
add a commentDon’t use underscores in css ids November 17, 2010 4:35 pm
Posted by Doug McCaughan in : CSS, HTML, Programming, TechnologyToday’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.
add a commentjquery challenge of the day September 7, 2010 6:19 pm
Posted by Doug McCaughan in : CSS, Daily Life, JavaScript, jQuery, Programming, TechnologyAnd 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.
10comments