Monthly Archives: May 2013

How to use one connection to the Internet for VPN and another for accessing other websites?

You also asked about split tunneling, so let’s take a moment to explain that concept before walking through the process of creating a VPN connection. By default, when you create a VPN connection, Windows funnels all of the communications from your computer through the VPN. So, if you’re logged into a corporate VPN from home to check your email, all of the other Web surfing you’re doing on your computer is also being run through your corporate network. This is the default behavior because, from the company’s point of view, it’s the safest way and ensures all traffic is protected regardless of the destination.

You might not want this behavior, however, for a couple of reasons. First, it allows your company to inspect all of your personal Web traffic while connected to the VPN. Second, it will likely slow down your access to the Web, as everything must first be sent through the VPN.

Split tunneling, on the other hand, configures the VPN connection so that only traffic headed to computers on the corporate network is sent through the VPN connection. Other traffic leaving your computer goes out through your normal network connection.

Follow these steps to set up a VPN connection in Windows Vista that uses split tunneling:

  1. From the Control Panel, choose “Network & Internet.”
  2. Click “View Network Status and Tasks.”
  3. Click “Manage Network Connections.”
  4. Right-click on your VPN connection and select “Properties.”
  5. Select the “Networking” tab.
  6. Highlight “Internet Protocol Version 4 (TCP/IP v4).”
  7. Click “Properties.”
  8. Click “Advanced.”
  9. Uncheck the “Use default gateway on remote network” box.
  10. Click “OK” three times to close the windows you opened.

From that point forward, only traffic destined for your corporate network will be sent through the VPN. All other traffic will use the local network.

source: SuperUser

SQL Server Stopwords and Stoplists for Full-Text Search

By default FTS index uses system stoplist. If you want to have custom one, you need to create new first. To create a full-text stoplist in Management Studio refer to Configure and Manage Stopwords and Stoplists for Full-Text Search
In my case I used either “Create from the system stoplist” (and did modifications) or “Create an empty stoplist”.

REMEMBER after creating new stoplist:
– you have to make sure your full-text index uses this stop list and rebuild your catalog.
– Right click on your table, select full-text index then properties, and in the general tab click on the full-text stop list drop down and pick your stop list.
http://social.msdn.microsoft.com/Forums/en-US/sqlsearch/thread/91774a49-7362-41ad-ac91-7bd453cc94c6/

SQL Server 2008 provides three catalog views that are useful for retrieving the contents of system and custom stoplists:

SELECT * FROM sys.fulltext_system_stopwords;
SELECT * FROM sys.fulltext_stoplists;
SELECT * FROM sys.fulltext_stopwords;

For example get all available language names

SELECT DISTINCT slg.name
FROM sys.fulltext_system_stopwords ssw
JOIN sys.fulltext_languages slg
ON slg.lcid = ssw.language_id;

To do modifications on custom stoplist you can either use Management Studio (right click on the list then Properties) or SQL queries.

Digits or single characters problem

For example you want to search in your table ‘7 seats’ in your cars description table. It will find all having just ‘seats’ keyword because by default single digits and characters are stopwords.
To make sure you can use variations of queries below

SELECT stopword, lcid, name
FROM sys.fulltext_system_stopwords ssw
JOIN sys.fulltext_languages slg
ON slg.lcid = ssw.language_id

stoplist_01

SELECT stopword, lcid, name
FROM sys.fulltext_system_stopwords ssw
JOIN sys.fulltext_languages slg
ON slg.lcid = ssw.language_id
WHERE slg.lcid = 1033

stoplist_02

SELECT stopword, lcid, name
FROM sys.fulltext_system_stopwords ssw
JOIN sys.fulltext_languages slg
ON slg.lcid = ssw.language_id
WHERE stopword = '7'

stoplist_03

Stoplist modifications

To fix ‘7 seats’ all I had to do is remove ‘7’ single digit from the list using query

ALTER FULLTEXT STOPLIST MyList DROP '7' LANGUAGE 'English';

(Notice ‘;’ at the end)

When I wanted to do bulk update I used query below to generate bunch of other ones.

SELECT 'ALTER FULLTEXT STOPLIST MyList DROP ''' + stopword + ''' LANGUAGE ''' + name COLLATE DATABASE_DEFAULT + ''';'
FROM sys.fulltext_system_stopwords ssw
JOIN sys.fulltext_languages slg
ON slg.lcid = ssw.language_id
WHERE stopword = '7'
  • pay attention to COLLATE DATABASE_DEFAULT added to query – name field is conflicting in this query
  • remember about ‘;’ at the end
  • if you did ok, all of it will run with no problem

Sometimes you get an error like this

The stoplist 'StopList' does not contain fulltext stopword '7' with locale ID 1093. Specify a valid stopword and locale identifier (LCID) in the Transact-SQL statement.

When you have ALTER statements in separate lines, double click on error and SSMS will show you exact line. Then remove it.
Remember, if ALTER was successful in a first run, it will error out if ALTER again.

Remember

Once you are done, you will need to repopulate the affected indexes so that they will include the formerly excluded words in the index(right click on your table, full text index, ‘start full population’)
Sometimes it does not work. You query the table and results as they were before.
What helped me is setting action Repopulate index in Full Text properties or reassigning Full Text Index to System, Actions to Repopulate and assigning back (again, Actions Repopulate Index was set)

stoplist_04

stoplist_05

01

C# Delete files older than a date

static class Helpers
{
    public static void DeleteOldFiles(string folderPath, uint maximumAgeInDays, params string[] filesToExclude)
    {
        DateTime minimumDate = DateTime.Now.AddDays(-maximumAgeInDays);
        foreach (var path in Directory.EnumerateFiles(folderPath))
        {
            if (IsExcluded(path, filesToExclude))
                continue;

            DeleteFileIfOlderThan(path, minimumDate);
        }
    }

    private const int RetriesOnError = 3;
    private const int DelayOnRetry = 1000;

    private static bool IsExcluded(string item, string[] exclusions)
    {
        foreach (string exclusion in exclusions)
        {
            if (item.Equals(exclusion, StringComparison.CurrentCultureIgnoreCase))
                return true;
        }

        return false;
    }

    private static bool DeleteFileIfOlderThan(string path, DateTime date)
    {
        for (int i = 0; i < RetriesOnError; ++i)
        {
            try
            {
                FileInfo file = new FileInfo(path);
                if (file.CreationTime < date)
                    file.Delete();

                return true;
            }
            catch (IOException)
            {
                System.Threading.Thread.Sleep(DelayOnRetry);
            }
            catch (UnauthorizedAccessException)
            {
                System.Threading.Thread.Sleep(DelayOnRetry);
            }
        }

        return false;
    }
}

source: Stack Overflow