Sometimes in MSSQL, you need to mimic the Oracle ROWNUM functionality. Here are some tips on ways to compress it into a single line of SQL. Continue reading “Oracle-like ROWNUM in MySQL”
Category: Technology
I work in technology everyday, and occasionally I like to share what I’ve found.
Search Triggers, Stored Procs, and Functions
Code that will search Triggers, Stored Procs, and Functions in MS SQL Server Continue reading “Search Triggers, Stored Procs, and Functions”
God and AI
Don’t count on playing God – He’s a lot sneakier than we suspected just a couple years ago.
— Artificial Intelligence Researcher
Finding comand line arguments in PHP script
A good way to look for particular arguments passed on the command line to a PHP script.
The code below will grab the -f argument and stick it in the $filename variable.
<code>
$filename = ”;
for ( $c=0; $c<$argc; $c++) {
if ( $argv[$c] == ‘-f’ ) {
$filename = $argv[$c + 1];
break;
}
}
</code>
Preventing Windows Update reboots
How to keep from getting those annoying restart messages from windows update.
Type gpedit.msc at the run prompt you see at the bottom of your list when you click the start button. This will bring up a new tool.
Navigate to “Computer Configuration -> Administrative Templates ->Windows Components -> Windows Update”
To change the interval between reminder windows change:
“Re-prompt for restart with scheduled installations”
To keep the computer from rebooting while you’re away, change:
“No auto-restart with logged on users for scheduled automatic updates”
Thanks to Tekzilla for the tip.
Convert Moodle Timestamp fields to Date
I get really frustrated with Moodle for using int fields to store dates. They store it in the Unix (Epoch) format. Here’s how to make it more readable.
To convert it to a readable date, use
FROM_UNIXTIME(int)
You can also get more formatting control with something like:
FROM_UNIXTIME(int, '%Y %D %M %h:%i:%s %x')
Search through text of Stored Procedure
Code to search across the text of all stored procedures for a particular string.
SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE ‘%foobar%’
AND ROUTINE_TYPE=’PROCEDURE’
Call parent class constructor in PHP5
This may be obvious to some, but I had a hard time figuring it out at first. I needed to call the constructor of a parent class in the child. This is handy when you have things that happen in the constructor of all children, but one place where there is some extra stuff that needs to happen. Rather than duplicate the common things, just call the parent constructor before doing your extra stuff.
parent::Node($rTypes);
In this case it will call the parent class name Node and will pass the row record variable that was passed to the child constructor.
Long character fields from database weird in PHP
When you are returning longer text from a query in PHP, like from a varchar(MAX) or such you can get weird characters at the end. The problem is that the ODBC connection, which I used to query the MS SQL database, has a default field bytes limit of 4096 chracters. This is controlled by the odbc.defaultlrl setting in the php.ini file. The solution that I found was to override this setting in the page where you need the long text with a line like this.
ini_set(‘odbc.defaultlrl’,65536);
Supposedly you can use the functionodbc_longreadlen setting, but I was not able to get it to work. You can find more info here and here. The default value for this is 4096, so 65536 may be overkill, but you can find what fits. When I tried 0, which is supposed to set it to passthrough all the text it didn’t work at all.
For the curious lrl = long read length
Handling checkboxes in JQuery
Some quick notes on handling checkboxes (and probably radio buttons, but I haven’t tested that) in JQuery.
To find a count of all checked items with the class Testbox.
$(".Testbox:checked").size();
To get a count of all of the unchecked items use this code:
$(".Testbox:not(:checked)").size();
To test an individual item with the ID Testbox1 use this:
$('#Testbox1').is(':checked');