Asp.Net RSS 2.0
 Sunday, December 28, 2008

My servers are leased so if anything goes wrong and a reboot is needed I have to wait for my provider to preform it.

In this post we will create a vb Script that pings an IP address and reboots if it can't see it. We will simply run it on a timer using the command scheduler.

Here is the script:

Option Explicit

dim strHost

'The ip address you want to monitor
strHost="111.222.333.444"

if Ping(strHost) = True then

'You can do stuff here if you want.

Else

    'The next three lines reboot
 
 dim objShell
 Set objShell = CreateObject("WScript.Shell")
 objShell.Run "shutdown /r /t 000"

end if

'the following is a subroutine called above

Function Ping(strHost)

    dim objPing, objRetStatus

    set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" & strHost & "'")

    for each objRetStatus in objPing
        if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode<>0 then

          Ping = False
        
      else
            Ping = True
      end if
    next
End Function

Just save this to a vbs file and add

cscript c:\ping.vbs

to "Scheduled tasks" every 15 minutes.

'Till next time...

Sunday, December 28, 2008 7:17:16 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Dedicated Server | Windows Server 2003
 Tuesday, November 25, 2008

The msdn documentation was a little hazy on this subject. Here it is as I understand it....

Lets start from the beginning; and adrotator will take a list of images and rotate through them every time the page loads. Some ads may need to appear more often than others. That is where the Impressions property comes in. It allows to give some ads more weight than others. Perhaps one person is paying more for the ad.

OK, so how do we use it? if every image should be weighted equally just set it to 1. Other wise you need to figure out the ratio. To figure it out you add up all the impression values in the file. Each ads ratio is it's impression value divided by the total.

So if there were three ads in the file and they looked like this:

ad 1 imressions = 1
ad 2 impressions=2
ad 2 impressions =2

The total is 5. Ad 1 will be show 1 out of 5 times. Ad 2 will be shown 2 out of 5 times and so on.

I like to work in percentages. To do this just divy up the ads until we get to 100%.

Ad 1 impressions = 20%
Ad 2 impressions= 40%
ad 3 impressions= 40%

Just make sure they all ad up to 100 and your done.  The percentage is the number of impressions.  1, 2,2 is actually the same as 20, 40, 40 so why not base it on 100 so it's easier to figure out?

Good Luck.

 

P.S. I saw a blog somewhere that wrapped an adrotator in a UpdatePanel that pdated on a timer. Interesting. Quicker than flash and more flexible than an animated gif. I'll be filing that in the back of my mind.

Tuesday, November 25, 2008 4:28:33 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
ASP.Net | XML | adrotator
 Thursday, October 30, 2008

I recently worked on a project requiring C#. It was a positive experience and as a result I have decided to switch from vb to c# for all projects where I have a choice.

There are several reasons I guess. I feel that thinking in c# syntax will help in other technologies. For example Java script and Actionscript. They are all very similar.

About a year ago I was looking for a programming job on sites like monster and dice and it seemed like c# was more in demand.

Programmer friends of mine alwasys seemed to look down on VB as if it were a noob language. 

Having used both I'm starting to like c# better.  I find that they booth can do the same things. If c# makes me more marketable then great! I'm sure it's in my mind but some how I feel more professional using it.

Anyways, my code samples will be c# from now on.

 

Thursday, October 30, 2008 1:26:02 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
ASP.Net | Web Development

I had this error pop up on me recently.

Operator '==' incompatible with operand types 'Int32' and 'Object'

I had an good grasp on why but the stack track would not tell me where!

The issue is that a null object was being used in a where clause somewhere. Linq translated the null as "" and could not be compared the the ID field which is an int.

My solution was to simply check each key and cancel the action if there is a null value.

Since I couldn't tell which Linq Data source was crashing I wired up on selecting events for them ALL and put the following code in:

foreach (KeyValuePair<string, object> kvp in e.WhereParameters)
{

   if (kvp.Value == null){

      e.Cancel = true;

      return;

   }

}

 

Problem solved.

Thursday, October 30, 2008 1:13:40 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
ASP.Net | Errors | Linq | SQL | Web Development
 Wednesday, October 15, 2008

Previously I wrote about using an elastic div to wrap around floated columns. The element I used to force a stretch was <br style="clear:both">. I've noticed that this element renders empty space in certain browsers. This is undesirable when trying to snug a footer up to streched middle section. In it's place I have started using <div style="width:0px; height:0px; clear:both"></div> This seems to work more consistantly across the browsers I support.

 

Wednesday, October 15, 2008 12:04:56 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
CSS | HTML
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2009
nPath Ltd.

Statistics
Total Posts: 24
This Year: 0
This Month: 0
This Week: 0
Comments: 1
All Content © 2009, nPath Ltd.
Sign In