Beyond Web Logs

Discuss technology, web development, networks and more ...

Recent posts

Tags

First time here? At BeyondWebLogs we discuss technology, web development, personal development, networks and more. You can subscribe to the RSS feed so that you keep up to date with the latest content. Now, on with the regular content...

GRABBING THE HIDDEN

To easily select all
hidden files, use the
following:
  .[^.]*  ..?*
For example,
echo .[^.]* ..?*
will output a list of
all hidden files in your
current directory.
.[^.]*  selects all files
starting with a dot but NOT
having a dot as their
second character.
..?*    selects all files
starting with two dots and
having at least one additional
character
Together, they will retrieve
ANY file starting with '.'
except '.' and '..'  (even
tricky ones like '...hideme')
The ^ (caret) symbol can be
used as the first character
inside [ ] at any time to say
"not one of the following"
rather than the usual "any one
of the following."
[^0-9a-fA-F] will match any
character that is NOT a hex
digit.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: How To
Posted by naveed on Sunday, August 24, 2008 7:41 PM
Permalink | Comments (0) | Post RSSRSS comment feed

how to take care of: maximum connections reached remote desktop connection

When you've reached maximum number of connections using your remote desktop connection, for whatever reason, there is a simple solution to take care of this error. All you have to do is log in using a console command [to follow] and then open that computer's task manager, go to users, and then log off enough users that the remote desktop connection lets you log back on.

Here's the command:

mstsc -v:0.0.0.0 /f -console

[of course you'll replace the 0.0.0.0 with the ip address of your remote server]

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: How To | Tips n Tricks
Posted by muneeb on Tuesday, August 05, 2008 1:14 PM
Permalink | Comments (1) | Post RSSRSS comment feed

manual backup of your windows sharepoint services [wss] site

Ever wondered how to take a full manual backup of your windows sharepoint services 3.0 [wss] site? Of course you can use stsadm command to do a full backup but you'll have to run this command every time you need to take your site's backup.

Below is a .bat script that you can use to automate this manual process. It automatically creates a filename for you and takes your wss site's backup. You can schedule this .bat file using windows schedule and your wss site's backup will take care of itself.

... and here's the script:

@echo off
echo +++++++++++++++++
echo Initializing backup...
echo Starting backup...
echo +++++++++++++++++
for /f "delims=/ tokens=1-3" %%a in ("%DATE:~4%") do (
        for /f "delims=:. tokens=1-4" %%m in ("%TIME: =0%") do (
            set FILENAME=site_backup-%%c-%%b-%%a-%%m%%n%%o%%p
        )
    )

c:
cd \Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN
@echo off
stsadm.exe -o backup -url http://server -filename D:\%FILENAME%.dat -overwrite
echo Backup complete.

Simply copy, and then save the above script as a .bat file, and that's it.

Hope it helps, as it definitely helped me. As always, thank you to all those who helped me create this script.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: ASP.NET | General | How To | SharePoint
Posted by muneeb on Monday, August 04, 2008 7:30 PM
Permalink | Comments (0) | Post RSSRSS comment feed

How to submit or POST form data using Silverlight in ASP.NET

As you probably already know, Silverlight is a browser plugin for providing rich web content. It includes a subset of the capabilities of WPF, and it aims to rival Adobe Flash. However, submitting form data using POST in silverlight is not as trivial as you might imagine. You would need to create HttpWebRequest menthod to POST your silverlight based form data and that's not all. You will also need to go through many pitfalls like SynchronizationContext issues.

Here is the sample code to submit or POST form data in ASP.NET using Silverlight. I hope it would help you a lot in intergating your silverlight application in ASP.NET.

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        syncContext = SynchronizationContext.Current
        For Each uie As UIElement In MasterPage.Children
            GetChilds(uie)
        Next
        Dim url As New Uri(HtmlPage.Document.DocumentUri, "processfile.aspx")
        Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
        request.Method = "POST"
        request.ContentType = "application/x-www-form-urlencoded"
        request.BeginGetRequestStream(New AsyncCallback(AddressOf RequestProceed), request)
End Sub

Private Sub RequestProceed(ByVal asyncResult As IAsyncResult)
        Dim request As HttpWebRequest = DirectCast(asyncResult.AsyncState, HttpWebRequest)
        Dim postData As New StreamWriter(request.EndGetRequestStream(asyncResult))
        postData.Write(formData)
        postData.Close()
        request.BeginGetResponse(New AsyncCallback(AddressOf RProceed), request)
End Sub

Private Sub RProceed(ByVal asyncResult As IAsyncResult)
        Dim request As HttpWebRequest = DirectCast(asyncResult.AsyncState, HttpWebRequest)
        Dim response As HttpWebResponse = request.EndGetResponse(asyncResult)
        syncContext.Post(AddressOf ExtractResponse, response)
End Sub

Private Sub ExtractResponse(ByVal state As Object)
        Dim response As HttpWebResponse = TryCast(state, HttpWebResponse)
        Dim url As New Uri(HtmlPage.Document.DocumentUri, "YourPage.aspx")
        HtmlPage.Window.Eval("window.location.href='" & url.ToString & "';")
End Sub

Private Sub GetChilds(ByVal uie As UIElement)
       Dim obj As String
         obj = uie.ToString
        names = names & obj

        If obj = "System.Windows.Controls.StackPanel" Then
            Dim sp As StackPanel
            sp = DirectCast(uie, System.Windows.Controls.StackPanel)
            For Each spChild As UIElement In sp.Children
                GetChilds(spChild)
            Next
        End If

        If obj = "System.Windows.Controls.Grid" Then
            Dim gv As Grid
            gv = DirectCast(uie, System.Windows.Controls.Grid)
            For Each gvChild As UIElement In gv.Children
                GetChilds(gvChild)
            Next
        End If
        If obj = "System.Windows.Controls.TextBox" Then
            Dim tb As TextBox
            tb = DirectCast(uie, System.Windows.Controls.TextBox)
            formData = formData & tb.Name & "$#*"
            formData = formData & tb.Text & "$#*;"
        End If
        If obj.Contains("System.Windows.Controls.RadioButton") Then
            Dim rb As RadioButton
            rb = DirectCast(uie, System.Windows.Controls.RadioButton)
            formData = formData & rb.Name & "$#*"
            formData = formData & rb.IsChecked & "$#*;"
        End If
        If obj.Contains("System.Windows.Controls.CheckBox") Then
            Dim cb As CheckBox
            cb = DirectCast(uie, System.Windows.Controls.CheckBox)
            formData = formData & cb.Name & "$#*"
            formData = formData & cb.IsChecked & "$#*;"
       End If
    End Sub


Hope this helps!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: How To
Posted by Waqas on Saturday, June 14, 2008 7:36 PM
Permalink | Comments (0) | Post RSSRSS comment feed

How to use JSON ?

JSON is a textual data-interchange format. Its purpose is to offer a representation of structured data that is independent of the language or platform used. This makes it possible to interchange data between applications written in different languages and run the applications on different machines. Compared to XML, which is probably the best-known data-interchange format, JSON has a compact syntax. This means that often, less bandwidth is required to transmit JSON data through a network.

JSON is based on a subset of the JavaScript language. As a consequence, encoding and parsing are nearly immediate. JSON is built on two structures: a collection of name and value pairs, called an object; and an ordered list of values, called an array. In JSON, a value can be one of the following:

  • An object
  • An array
  • A number
  • A string
  • true
  • false
  • Null

An object is represented by a JavaScript object literal, and an array is represented by a JavaScript array literal. The remaining values are represented by the corresponding literals.

Because JSON is a subset of JavaScript literals, there are some restrictions on the syntax. In a JSON object, the name part of a name/value pair must be a string, and the value part must be one of the supported values. The following is the JSON representation of an object with two properties:

 

{ "firstName":"John", "lastName":"Doe" }

 

In JavaScript, both the objects have the same structure. However, the second object isn’t a valid JSON representation, because the names of the properties aren’t enclosed in double quotes. Restrictions also apply to JSON arrays, where elements must be supported values. For example, a Date object isn’t in the list of supported values and therefore can’t be an element of a JSON array or a property of a JSON object. A String has the same representation as a JavaScript string literal, except that strings must always be enclosed in double quotes. Numbers are similar to JavaScript number literals, but octal and hexadecimal formats aren’t supported. Here is an example of a JSON array:

 

[1, 2, 3, 5, 7]

 

The Boolean values true and false, as well as null, have the same representation as the corresponding JavaScript literals.

 

One of the advantages of JSON is that it’s easy to parse. Many JSON parsers, written for numerous languages, have been developed to automate the process of generating and parsing JSON. (A list is available at the official JSON site, http://json.org/.) In JavaScript, the parsing process is immediate: All you have to do is pass the JSON string to the JavaScript eval function. If you have a jsonString variable that contains the JSON data, the following code parses it and returns the corresponding JavaScript object:

 

var parsedJson = eval('(' + jsonString + ')');

 

Note that you should enclose the JSON data in parentheses before calling eval. By doing this, you force eval to consider the argument an expression, and an object literal {} won’t be interpreted as a code block. But the eval function can execute arbitrary code, which can lead to security issues if the data come from an untrusted source. For this reason, it’s always recommended that you validate the JSON data before calling the eval function.

 

Also note that the the official JSON site, http://json.org/, provides a regular expression for validating JSON data. You can find it in the JavaScript implementation downloadable from the website.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: How To
Posted by Waqas on Monday, June 09, 2008 12:49 PM
Permalink | Comments (0) | Post RSSRSS comment feed

How to open text file in ASP.NET

Here is a code snippet to address a common problem to use simple text files using System.IO in ASP.NET:

        'Open a file for reading
        Dim FILENAME As String = Server.MapPath("Data.txt")

        'Get a StreamReader class
        Dim objStreamReader As System.IO.StreamReader
        objStreamReader = System.IO.File.OpenText(FILENAME)

        'Read the entire file into a string
        Dim contents As String = objStreamReader.ReadToEnd()

        'Optionally you may wish to replace carraige returns with <br>s
        TextBox1.Text = contents.Replace(vbCrLf, "<br>")

        objStreamReader.Close()

Hope it helps!

Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: How To
Posted by Waqas on Friday, June 06, 2008 5:13 PM
Permalink | Comments (0) | Post RSSRSS comment feed

How to set or synchronize your machine time with domain controller

Sometimes, you might get an error "The time on your machine does not match with the network time". The basic issue here is that the time on the machine is not automatically synced with the time on the domain controller.

To resolve this problem, simply login as a local account and sync the time with the domain controller using the Net time command.

To do this, goto the command prompt and run the following:

NET TIME /domain:mydomainname /SET /Y

This will synchronize the machine time to that of the domain controller.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: How To
Posted by Waqas on Thursday, April 17, 2008 12:24 PM
Permalink | Comments (0) | Post RSSRSS comment feed