Classic ASP on Windows 7, IIS 7 is SLOW!

So I have this show web app thingy that runs local. Put it on a new laptop and it ran like a dog. After sorting out the installation of classic ASP, tweaking the recycling, permissions, timeouts and everything else – I finally remembered: SQL initially uses named piped and shared memory. These sound neat and fast but they are BOFFO.

1: Edit your hosts file and add 127.0.0.1 localhost
2: Go to SQL Configuration Tool, Interfaces and get rid of named pipes and shared memory.
3: ADD TCP/IP

There you go – instant fast IIS on Windows 7 with SQL 2008.

New Book – MySQL and PHP – an introduction – Now with Real World Examples!

When I am learning something I get pretty discouraged by the books available. They are too long and too damned expensive. I will buy a 400 page book for 50 bucks and read the 30 pages I need. So, I wrote an e-book called MySQL and PHP an Introduction and published it on Amazon (Link here). It is 9.99, about 60 pages and comes with a complete web application. I just today added some real world examples. It demonstrates how to do things like sub queries, in clauses, not in clauses and when they are useful.

Click here to view the samples and working web application.

mysqlimport – can’t get stat of file

So on my server here I have a process that ftps some data from a SQL server and loads it to MySQL. All was well until I got:
Can’t get stat of ‘/home/username/www/data’ (Errcode: 13)

I tried chmod and chown and running the file as root and everything. No success. I then found a post that said – move the file to /tmp. So I tried it and it worked! Here are my scripts.

Please note – you will have to add a user to mysql that has import permissions!

sql

truncate table equipment_in;

LOAD DATA INFILE ‘/tmp/equipment.csv’
REPLACE
INTO TABLE equipment_in
FIELDS TERMINATED BY ‘,’
OPTIONALLY ENCLOSED BY ‘”‘
LINES TERMINATED BY ‘\r\n’;

getdata

cd /tmp
rm *.csv*
wget ftp://username:password@servername/*.csv
mysql –user=username –password=thepassword databasename < /folder/with/the/sql

MySQL
MySQL Documents

SEO and You

So you are thinking you need the services of an SEO (Search Engine Optimization) company. My experience with them so far is less than stellar. They seem to be good at using lots of words and “exciting phrases of the day”. Here are the basics that cover 95% of SEO:

1: Page Titles should be descriptive.
2: Description meta tag should be complete. When you do a google search and see a paragraph under the result, that comes from the description.
3: Keywords meta tag should be complete.
4: Important words in your content should be bold or strong.
5. Use H1, H2 and H3 tags to identify page sections.

Finally, If you are a member of a trade group or organization in your field, link to their pages. Ask if they will link back. If your site has lots of information about “Bees” that is great. If it also links to other pages about “Bees” that is better. If other sites dealing with “Bees” link back to you, that is best.

Todd

Lockboxdata.com – secure, online stuff

So a while ago – in fact years ago – I had this idea. I thought, “what happens if something happens to me or my house?” I mean, would my wife know the username and password to my business account? Where the life insurance is? What we need is an online lockbox to save this stuff. So – I wrote Lockboxdata.com. It does all that and more. You can share documents safely and keep all sorts of records. The data is all encrypted and each account has it’s own key.

Anyway – if you want to use it – use the code LBOXWELCOME for a free account.

Todd

Geeks and Message Boards

When I go to a message board and ask something like, “how do I limit port 3306 to one computer using iptables?” and you know the answer, please just answer the damned question. I know you have it in your iptables config file. It is probably simple. Don’t point us to a website on iptables (we already found that and said, “WTF?”. Copy the lines in question and post them.

Some of us like to go outside. We want to get the answer and use it. We do not want to understand every technology like you do. The ones we use all the time we’ll master. These other things – no chance.

Then there are the, “oh – a newbie question – what goes in the newbie section” responses. You know what? Bite me. Once again we are trying to solve a problem. Answers like that do not help. They piss us off.

There. I said it. I will probably loose my geek membership card but that’s okay with me.

by the way – here is the answer that worked for me:


/sbin/iptables -A INPUT -i eth0 -p tcp --dport mysql -j DROP
/sbin/iptables -A INPUT -i eth0 -p udp --dport mysql -j DROP
/sbin/iptables -I INPUT -i eth0 -p tcp -s 55.55.55.55 --dport mysql -j ACCEPT
/sbin/iptables -I INPUT -i eth0 -p udp -s 55.55.55.55 --dport mysql -j ACCEPT

just replace 55.55.55.55 with the ip you need to allow

Disconnected Recordsets in ASP

I am a huge fan of disconnected recordsets especially when we are displaying reports or any other database driven content on a web page. Once the data is returned to the recordset object, why maintain a connection to the database? Let it go do database things and let the web server play with the data. Here is my function. I call it getrs() because I am lazy. Most of it I copied from somewhere. I also assumes you have an open global database connection called db and a table called SQLError (for logging purposes).

Function GetRS(strSQL)

Const adOpenStatic = 3
Const adUseClient = 3
Const adLockBatchOptimistic = 4


Dim oRS
Set oRS = Server.CreateObject("ADODB.Recordset")
oRS.CursorLocation = adUseClient
on error resume next
err.Clear
oRS.Open strSQL, db, adOpenStatic, adLockBatchOptimistic
if err <> 0 then
dim rsx
set rsx=server.CreateObject("adodb.recordset")
rsx.open "select * from sqlerror where 1=2",db,3,2
rsx.addnew
rsx("page")=request("page")
rsx("sql")=strsql
rsx("username")=session("uname")
rsx.update
rsx.close
set rsx=nothing
response.write "Your request created a system error. The error has been logged. Please make sure any fields you entered are the correct data types. "
response.end
end if
Set oRS.ActiveConnection = Nothing
Set GetRS = oRS
End Function

And you use it like this:

set rs=getrs("select username from users")
while not rs.eof
response.write rs("username") & "<br>"
rs.movenext
end
%>

It is simple and makes reading your code pretty damned easy. An added benefit is that you can move to the end of the recordset with rs.movelast and then move to the first with rs.movefirst as often as you’d like.

Can’t find that file?

Too many times I have needed to find a piece of code that calls a view, proc or table. If you are using any of Microsoft’s developer products you can do “Find in solution” but it takes a month. You can also go to the server, browse to the folder and click search only to get no results. Well, I have a solution.

Unix and Linux people may remember grep. Well, there is a windows version called Wingrep ( http://www.wingrep.com/ ). Install it. Use it. Find the files you need.