Search This Blog

How to convert IP address to country name


Public Function Dotted2LongIP(DottedIP As String) As Variant
    ' errors will result in a zero value
    On Error Resume Next

    Dim i As Byte, pos As Integer
    Dim PrevPos As Integer, num As Integer

    ' string cruncher
    For i = 1 To 4
        ' Parse the position of the dot
        pos = InStr(PrevPos + 1, DottedIP, ".", 1)

        ' If its past the 4th dot then set pos to the last
        'position + 1

        If i = 4 Then pos = Len(DottedIP) + 1

       ' Parse the number from between the dots

        num = Int(Mid(DottedIP, PrevPos + 1, pos - PrevPos - 1))

        ' Set the previous dot position
        PrevPos = pos

        ' No dot value should ever be larger than 255
        ' Technically it is allowed to be over 255 -it just
        ' rolls over e.g.
         '256 => 0 -note the (4 - i) that's the
         'proper exponent for this calculation


      Dotted2LongIP = ((num Mod 256) * (256 ^ (4 - i))) + _
         Dotted2LongIP

    Next

End Function

' convert long IP to dotted notation

Public Function LongIP2Dotted(ByVal LongIP As Variant) As String

    On Error GoTo ExitFun

    If LongIP = "" Or LongIP < 0 Then Err.Raise vbObjectError + 1

    Dim i As Integer, num As Currency

    ' big number cruncher
    For i = 1 To 4
        ' break off individual dot values - math out the wazoo
        num = Int(LongIP / 256 ^ (4 - i))

        ' sets up the value for the next calculation
        LongIP = LongIP - (num * 256 ^ (4 - i))

        ' a generic error to flag the exception handler -
        'no dot value should ever be larger than 255
        ' technically it is allowed to be over 255
        ' but it's not possible from this calculation so
        'raise an error
        If num > 255 Then Err.Raise vbObjectError + 1

        ' string builder
        If i = 1 Then
            ' 1st dot value has no leading dot
            LongIP2Dotted = num
        Else
            ' other dot values have a leading dot
            LongIP2Dotted = LongIP2Dotted & "." & num
        End If
    Next

Exit Function
ExitFun:
     LongIP2Dotted = "0.0.0.0" '"Invalid Input" ' whatever
End Function
These are simple functions that will take a string of text as input and trim it to the ammount of characters desired. Instead of cutting the text at that length it will cut the text after the word has finished. This means that the function will show X ammount of character plus the ammount of character it takes to finish the word that is being cut. This is a function that can be useful for blogs, news sites or calendars where you want to show a list of items with a short description. You can use this function to create this short description based on the complete text of the item.

Triming text is very straightforward in ASP, you can use the ASP Left function like Left(strSomeText,20) which would cut the strSomeText variable to a length of 20 characters. These functions go beyond that by not cutting at 20 characters which could be in the middle of a word, but instead these functions will look for the end of the word and than cut off the text.

CODE:


<%
Function fncTrimText(strText,intCharacters,blnMore)
' The function uses the following variables
 ' strText is used to pass the text to be trimmed
 ' intCharacters is used to indicate at what ammount of characters the text should be trimmed
 ' blnMore 0 for no and 1 for yes is used to add 3 dots after the trimmed text if the original text is longer

' Declare the variables required
 Dim blnDone : blnDone = 0
 Dim strTextTrimmed

' First trim the text to the desired ammount of characters
 strTextTrimmed = Left(strText,intCharacters)

' Then add the remaining characters of the word if a word was cut with the trimming
 If cInt(Len(strText)) > cInt(intCharacters) Then
  intCharacters = intCharacters + 1
  Do While (blnDone < 1)
   If Mid(strText,intCharacters,1) = " " Then
    blnDone = 1
   Else
    strTextTrimmed = strTextTrimmed & Mid(strText,intCharacters,1)
   End If
   If cInt(Len(strText)) <= cInt(intCharacters) Then
    blnDone = 1
   End If
   intCharacters = intCharacters + 1
  Loop

' Now add the ... after the trimmed text
  If blnMore = 1 Then
   strTextTrimmed = strTextTrimmed & " ... "
  End If
 End If

 fncTrimText = strTextTrimmed

End Function
%>
 

CODE 2:


<%
Function fncTrimText(strText,intCharacters)
' The function uses the following variables
 ' strText is used to pass the text to be trimmed
 ' intCharacters is used to indicate at what ammount of characters the text should be trimmed

 If Len(strText) > intCharacters Then
  If inStr(100,strText," ") > intCharacters Then
   strText = Left(strText,inStr(intCharacters,strText," ")) & "..."
  ElseIf inStr(intCharacters,strText," ") = intCharacters Then
   strText = Left(strText,intCharacters) & "..."
  End If
 End If

 fncTrimText = strText
End Function
%> 

Source: http://flyinglowlander.com/ASP/trim_text_function/
Simple ASP RSS XML Data Feed Importer and Reader

This is an easy and simple ASP script that will import, read and display RSS data feeds. It uses Microsoft.XMLDOM to import and process the code. The way this code works, there is no need to use an external XSL style sheet since all the formatting is done right within the script.
You can plug this script into any of your .asp pages for it to work.

Source: http://www.sorenwinslow.com/RSSAspCode.asp

Here is the code for the easy RSS/XML feed reader:

TheFeed = "http://www.amadirectlink.com/amadirectlink.xml"
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.Async = False
objXML.SetProperty "ServerHTTPRequest", True
objXML.ResolveExternals = True
objXML.ValidateOnParse = True
objXML.Load(TheFeed)
CellCount = 0
If (objXML.parseError.errorCode = 0) Then
  Set objRoot = objXML.documentElement
  If IsObject(objRoot) = False Then
     Response.Write "There was an error retrieving the news feed"
  Else
     Set objItems = objRoot.getElementsByTagName("item")
        If IsObject(objItems) = True Then
           For Each objItem in objItems
              On Error Resume Next
              TheTitle =  objItem.selectSingleNode("title").Text
              TheLink =  objItem.selectSingleNode("link").Text
              TheDesc =  objItem.selectSingleNode("description").Text
              TheDate =  objItem.selectSingleNode("pubDate").Text
              Response.Write "" & _
                             "" & TheTitle & "" & _
                             "" & _
                             "
"
              Response.Write TheDesc & _
                             "
"
              Response.Write TheDate & _
                             "
" Next End If Set objItems = Nothing End If Else Response.Write "There was an error retrieving the news feed" End If Set objXML = Nothing 

The Fast Enough Computer


Why you shouldn't always buy the fastest, most expensive parts; even if you can afford them.

While I have not yet (and may never) recover from my addiction to having the Biggest Fastest Most Expensive computer parts I can afford, the experience I've gained writing for this website over the past year or so has hammered home the lesson that most of the time, I'm just wasting my money. And you probably are, too.

What do you need a fast computer for?

Unless you're a professional who needs the power of a high-end workstation, the meanest, cheapest no-name box you can buy is likely more than sufficient for everything you do...except gaming. That's the metric I'm going to use here: frame rates in games, at a decent resolution with good visual effects. Looking at the Steam hardware survey, we can see that the most common gaming resolution is 1680x1050 pixels, so that's what I'll use. The goal is to build a system that will play most modern games at 30fps or better at 1680x1050 with good visual quality (i.e. without having to turn off anti-aliasing or other visual effects) and decent expansion capability for the least amount of money.

Benchmarks don't matter

Most of us will look to benchmark results to determine a computer's performance. It's like taking your car to the local drag strip and seeing how fast it'll do the 1/4 mile run. But much of the time, a benchmark score has about as much relevance to your computer as your car's 1/4 miles time has to its day-to-day driving experience. This is especially true for synthetic benchmarks: while tuning your system to deliver the bestest fastest results in AIDA64 or PassMark can be fun, all that really matters at the end of the day is how many FPS you can spit out in Crysis, Metro 2033, Bad Company, or whatever your favorite game is.

Sure, having a monster system that delivers triple-digit frame rates on a 30" monitor with the latest DX11 games with all the eye candy turned on confers certain bragging rights...and if bragging rights is what you're after, well, go get those three NVIDIA GTX580 cards and start overclocking them. But don't expect it to make any difference in your gaming experience unless you're running a PhysX-heavy game in 3D Vision on a triple monitor system. What, that's not what you're running? Well, then...

Consider this: first, if your system can maintain 30 frames per second or more on a given game, that's Fast Enough. Very few people can discern the visual difference between 30fps and anything faster. I certainly can't. But even if you can, the absolute limit is 60fps, because that's the refresh frequency of your monitor. It physically can't display more than that, and when you do, you get horizontal "tearing" artifacts, which is why most games these days have an option to sync the frame redraws to the monitor's vertical refresh, effectively capping your frame rate at 60fps. Given this, who cares if your system can generate more frames per second? You're not going to see them.

Second, game developers want to produce games that run well on mid-range systems, because people with Intel 980X systems running dual NVIDIA GTX580 cards don't really make up a large part of the market. Sure, Crysis brought even high-end systems to their knees when it was introduced, but do you want to spend hundreds of dollars to run a single game?

So, what do you need to play current modern games at 1680x1050 with good frame rates and decent visual quality? As it turns out, all you need is a computer that's Fast Enough. Here's what I'd suggest...

More here

Source: Benchmarkreviews.com

I don't usually cry, but once I did I feel much stronger. I don't need to cry to be strong. There are lots of things that I don't understand in this journey ... I'll be extra careful

http://en.wikipedia.org/wiki/Potter%27s_syndrome
http://en.wikipedia.org/wiki/Oligohydramnios
http://www.ithinkdiff.com/how-to-enable-ahci-in-windows-7-rc-after-installation/
nForce 700 series for Snow Leopard using iATKOS S3 Version 2 (10.6.3)
http://www.insanelymac.com/forum/index.php?showtopic=184224&st=1640
http://www.insanelymac.com/forum/index.php?automodule=blog&blogid=284&
http://www.tonymacx86.com/viewtopic.php?f=7&t=2074&hilit=nforce+790i

10.6.5 update: After updating to 10.6.5 I can boot with all 4 cores in 32bit mode

nForce 790i SLI Ultra for Leopard
http://www.insanelymac.com/forum/index.php?showtopic=127212&st=0&p=899331&#entry899331
http://www.insanelymac.com/forum/index.php?showtopic=180127
http://www.insanelymac.com/forum/index.php?showtopic=187846

nForce 700 series Snow Leopard guide:
http://www.insanelymac.com/forum/index.php?showtopic=184224&st=0#entry1252071
http://www.insanelymac.com/forum/index.php?automodule=blog&blogid=284&

nForce ATA Drivers
http://www.insanelymac.com/forum/index.php?showtopic=211866&pid=1420852&st=0&#entry1420852

Multiple video card in Snow Leopard
http://www.insanelymac.com/forum/index.php?showtopic=183349&st=20
http://aquamac.proboards.com/index.cgi?board=hack1&action=display&thread=569
http://www.insanelymac.com/forum/index.php?showtopic=110366

EFI Nvidia the easy way
http://forum.netkas.org/index.php?topic=222.0

Spotlight problem:

As for Spotlight indexing generated KPs, often it is a result of the attempted Spotlight indexing of a mounted NTFS volume..........

In which case, look out for

BSD process name corresponding to current thread: mds

as mds is the metadata server. It serves all clients of the metadata APIs, including Spotlight.......also look for


com.apple.filesystems.ntfs(3.3)@0x14de000->0x153dfff

indicating a NTFS filesystem support issue........

You can drag your NTFS volume into the Privacy window by going to System Preferences >>>> Spotlight >>>> Privacy............this will prevent Spotlight from trying to index it..........

Antivirus software may also trigger mds when searching for viruses.....

frezzing without a KP is may be a Spotlight indexing problem. When i have spotlight enabled my system is pretty unstable and frezzes like every 10 min. When it's disabled i have no problems.

http://www.insanelymac.com/forum/index.php?showtopic=184224&st=1620