All new code snippets I find/write can now be found here:
http://snipplr.com/users/blackf0rk/
-
The "Ten Commandments", if you will, of .NET development. Definitely not limited to ten, nor groundbreaking by any means, this blog emphasizes simple code that any .NET developer should know; without the fluff and bloated code examples. "Just show me how to..."
Function GetGeoCoords(ByVal inString as String) As String
Dim xmlString As String = GetHTML("http://maps.google.com/maps/geo?output=xml&key=abcdefg&q=" & inString, 1)
Chunks = Regex.Split(xmlString, "coordinates>", RegexOptions.Multiline)
outString = Replace(Chunks(1), ",0</", "")
End Function
Public Function GetHTML(ByVal sURL As String, ByVal e As Integer) As String
Dim oHttpWebRequest As System.Net.HttpWebRequest
Dim sChunk As String
oHttpWebRequest = (System.Net.HttpWebRequest.Create(sURL))
Dim oHttpWebResponse As System.Net.WebResponse = oHttpWebRequest.GetResponse()
oStream = oHttpWebResponse.GetResponseStream
sChunk = New System.IO.StreamReader(oStream).ReadToEnd()
oStream.Close()
oHttpWebResponse.Close()
If e = 0 Then
Return Server.HtmlEncode(sChunk)
Else
Return Server.HtmlDecode(sChunk)
End If
End Function
Public Function GetGeoCoords(ByVal inString As String) As String
Dim Chunks As String()
Dim outString As String = ""
Chunks = Regex.Split(inString, "&")
For Each s As String In Chunks
If InStr(s, "ll") > 0 Then outString = s
Next
Return Replace(Replace(outString, "sll=", ""), "ll=", "")
End Function
Public Function GetHTML(ByVal sURL As String, ByVal e As Integer) As String
Dim oHttpWebRequest As System.Net.HttpWebRequest
Dim oStream As System.IO.Stream
Dim sChunk As String
oHttpWebRequest = (System.Net.HttpWebRequest.Create(sURL))
Dim oHttpWebResponse As System.Net.WebResponse = oHttpWebRequest.GetResponse()
oStream = oHttpWebResponse.GetResponseStream
sChunk = New System.IO.StreamReader(oStream).ReadToEnd()
oStream.Close()
oHttpWebResponse.Close()
If e = 0 Then
Return Server.HtmlEncode(sChunk)
Else
Return Server.HtmlDecode(sChunk)
End If
End Function
$file = file_get_contents('http://www.yoururl.com');
Public Function EncryptString(ByVal InSeed As Integer, ByVal InString As String) As String
Dim c1 As Integer
Dim NewEncryptString As String
Dim EncryptSeed As Integer
Dim EncryptChar As String
NewEncryptString = ""
EncryptSeed = InSeed
For c1 = 1 To Len(InString)
EncryptChar = Mid(InString, c1, 1)
EncryptChar = Chr(Asc(EncryptChar) Xor EncryptSeed)
EncryptSeed = EncryptSeed Xor c1
NewEncryptString = NewEncryptString & EncryptChar
Next
EncryptString = NewEncryptString
End Function