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.

 

Mortgage Bailout: Who pays for it?

So the government has signed into law a new bill to give “mortgage relief” to people who got into trouble with their loan. That sounds nice doesn’t it?

While people who hit hard times when the real estate market took a down turn and their houses were worth less than they paid for them, all I can say is “life’s a bitch”. There has never been a guarantee that your house will increase in value. Everyone should realize that when their interest rate is variable, that means it can change and you might pay much more. It’s a risk. You are rewarded for taking the risk by getting a lower initial rate. You might come out on top, you might lose. It’s a gamble. Except when the government shows up to bail you out when things go wrong. Some will say, “Well it doesn’t hurt you to help these people out.” Bull! It hurts me in two ways:

  1. First and foremost, it doesn’t fix the long term problem of stupid people buying something they can’t afford. Bitten once, shame on you, bitten twice shame on me. These people are still “bite free”. They won’t learn from this and are likely to do it again. Why not, there’s no risk if the government will bail you out.
  2. All of us as tax payers pay for it. The money comes from somewhere. As the article states, this bill costs $800 billion and pushes the deficit to 10.6 trillion. That means we just increased our debt by 8%. To bail out stupid people.

I chose not to take the risk. I paid a higher interest rate to get a 30 year fixed loan. I felt a little foolish when others got lower rates. But I now have an interest rate locked in for the next 25 years. Why did I do this? In part, because I had earlier gotten a 5/1 ARM mortgage that went up on me and I learned my lesson.

Don’t let the government make the American people stupider than they already are. Let your congressperson know that you don’t like this bill and would like to see less “nanny-state” policies and more “tough love”

 

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')

 

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');

Search and Replace across all tables

Search and replace all occurances of a string in all tables in a database.
From http://vyaskn.tripod.com/

--To replace all occurences of 'America' with 'USA':
EXEC SearchAndReplace 'America', 'USA'
GO


REATE PROC SearchAndReplace
(
@SearchStr nvarchar(100),
@ReplaceStr nvarchar(100)
)
AS
BEGIN

-- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved.
-- Purpose: To search all columns of all tables for a given search string and replace it with another string
-- Written by: Narayana Vyas Kondreddi
-- Site: http://vyaskn.tripod.com
-- Tested on: SQL Server 7.0 and SQL Server 2000
-- Date modified: 2nd November 2002 13:50 GMT

SET NOCOUNT ON

DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110), @SQL nvarchar(4000), @RCTR int
SET @TableName = ''
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')
SET @RCTR = 0

WHILE @TableName IS NOT NULL
BEGIN
SET @ColumnName = ''
SET @TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
AND OBJECTPROPERTY(
OBJECT_ID(
QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
), 'IsMSShipped'
) = 0
)

WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
BEGIN
SET @ColumnName =
(
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)
AND TABLE_NAME = PARSENAME(@TableName, 1)
AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND QUOTENAME(COLUMN_NAME) > @ColumnName
)

IF @ColumnName IS NOT NULL
BEGIN
SET @SQL= 'UPDATE ' + @TableName +
' SET ' + @ColumnName
+ ' = REPLACE(' + @ColumnName + ', '
+ QUOTENAME(@SearchStr, '''') + ', ' + QUOTENAME(@ReplaceStr, '''') +
') WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
EXEC (@SQL)
SET @RCTR = @RCTR + @@ROWCOUNT
END
END
END

 

SELECT 'Replaced ' + CAST(@RCTR AS varchar) + ' occurence(s)' AS 'Outcome'
END