Archive

Archive for November, 2010

Another 183 sites rescued from the demise of geocities

November 27, 2010 Leave a comment
     Friday, October 12, 2012  2:27 PM        <dir> _
     Sunday, October 14, 2012  8:16 AM        <dir> a
     Monday, October 15, 2012  2:59 PM        <dir> b
    Tuesday, October 16, 2012  6:04 AM        <dir> c
   Saturday, October 13, 2012  6:09 AM        <dir> f
     Friday, October 12, 2012 11:13 PM        <dir> g
     Friday, October 12, 2012 10:47 PM        <dir> h
     Friday, October 12, 2012 10:22 PM        <dir> i
     Friday, October 12, 2012 10:07 PM        <dir> j
     Friday, October 12, 2012  9:51 PM        <dir> k
     Friday, October 12, 2012  9:39 PM        <dir> l
     Friday, October 12, 2012  9:24 PM        <dir> m
     Friday, October 12, 2012  9:12 PM        <dir> n
     Friday, October 12, 2012  8:42 PM        <dir> o
     Friday, October 12, 2012  8:21 PM        <dir> p
     Friday, October 12, 2012  7:56 PM        <dir> q
     Friday, October 12, 2012  7:20 PM        <dir> r
     Friday, October 12, 2012  7:01 PM        <dir> s
     Friday, October 12, 2012  6:54 PM        <dir> t
     Friday, October 12, 2012  6:24 PM        <dir> u
     Friday, October 12, 2012  5:41 PM        <dir> v
     Friday, October 12, 2012  4:55 PM        <dir> w
     Friday, October 12, 2012  4:19 PM        <dir> x
     Friday, October 12, 2012  3:32 PM        <dir> y
     Friday, October 12, 2012  2:46 PM        <dir> z
Advertisements
Categories: Uncategorized

NVARCHAR(4000) & NTEXT vs NVARCHAR(MAX)

November 25, 2010 Leave a comment

What is the difference between NVARCHAR(4000), NTEXT and NVARCHAR(MAX)?

First consider this SQL script:

 

declare @BigData ntext
set @BigData = N’0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-1K-
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-2K-
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-3K-
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-4K-‘

select @BigData

If @BigData is declared as NVARCHAR(4000), then the select statement will truncate at 4K bytes. You can’t declare as NVARCHAR(8000) as it will give the error:

Msg 2717, Level 16, State 2, Line 1
The size (8000) given to the parameter ‘@BigData’ exceeds the maximum allowed (4000).

@BigData cannot be declared as NTEXT, since it gives the error:

Msg 2739, Level 16, State 1, Line 1
The text, ntext, and image data types are invalid for local variables.

but, as NVARCHAR(MAX) then the data is not truncated!

 

Categories: Uncategorized

How to loop for a specified time in C#

November 24, 2010 Leave a comment

Say that you wanted to do something for one minute, as often as possible; then this bit of code is quite a nice way of doing it;

It would be called like:

foreach(var i in TimeLoop(TimeSpan.FromSeconds(30))

{ // Do something }

 

/// <summary>
/// A Loop that continues for a given time
/// </summary>
/// <param name=”duration”></param>
/// <returns></returns>
private static IEnumerable TimeLoop(TimeSpan duration)
{
var dtStart = DateTime.Now;
for (; ; )
{
yield return null;
System.Threading.Thread.Sleep(100);
var tsElapsed = DateTime.Now – dtStart;
if (tsElapsed > duration)
{
yield break;
}
}
}

Categories: Uncategorized

Saving Geocities

November 17, 2010 3 comments

I downloaded the Geocities torrent, but it only gets to 23.7% complete, so, stopping it there, I unzipped whatever zips I could, finding only “geocities.archiveteam.torrent\ARCHIVES\geocities-unmangled\www.geocities.com” to be the only directory with a few sites that could be salvaged.

After that, I processed all the html files, removing absolute links, then uploaded them to my server. It’s only 104 websites, or 340 Mb out of the 1 Tb download, so it’s less than a 3,000th of the size of geocities, but whenever a 100% seed for that torrent comes online, then I can finish the download.

 

 Saturday, October 13, 2012 12:17 PM        <dir> 0
   Saturday, October 13, 2012 12:25 PM        <dir> 1
   Saturday, October 13, 2012 12:25 PM        <dir> 2
   Saturday, October 13, 2012 12:25 PM        <dir> 3
   Saturday, October 13, 2012 12:26 PM        <dir> 4
   Saturday, October 13, 2012 12:28 PM        <dir> 5
   Saturday, October 13, 2012 12:28 PM        <dir> 7
   Saturday, October 13, 2012 12:28 PM        <dir> 8
   Saturday, October 13, 2012 12:28 PM        <dir> 9
     Sunday, October 14, 2012  8:29 AM        <dir> _
     Sunday, October 14, 2012  8:40 AM        <dir> a
     Sunday, October 14, 2012  8:52 AM        <dir> c
     Sunday, October 14, 2012  9:18 AM        <dir> d
   Saturday, October 13, 2012  2:55 PM        <dir> e
     Sunday, October 14, 2012  9:37 AM        <dir> f
     Sunday, October 14, 2012  9:40 AM        <dir> g
     Sunday, October 14, 2012  9:56 AM        <dir> h
     Sunday, October 14, 2012 10:22 AM        <dir> i
   Saturday, October 13, 2012  5:26 PM        <dir> j
   Saturday, October 13, 2012  6:02 PM        <dir> k
   Saturday, October 13, 2012  6:03 PM        <dir> L
   Saturday, October 13, 2012  8:16 PM        <dir> m
     Sunday, October 14, 2012  1:11 AM        <dir> n
     Sunday, October 14, 2012  1:18 AM        <dir> o
     Sunday, October 14, 2012  1:47 AM        <dir> p
     Sunday, October 14, 2012  2:12 AM        <dir> q
     Sunday, October 14, 2012  4:06 AM        <dir> r
     Sunday, October 14, 2012  5:22 AM        <dir> s
     Sunday, October 14, 2012  5:51 AM        <dir> t
     Sunday, October 14, 2012  6:37 AM        <dir> u
     Sunday, October 14, 2012  7:05 AM        <dir> v
     Sunday, October 14, 2012  7:05 AM        <dir> W
     Sunday, October 14, 2012  7:14 AM        <dir> x
     Sunday, October 14, 2012  7:37 AM        <dir> y
     Sunday, October 14, 2012  8:16 AM        <dir> z
Categories: Uncategorized

Unable to telnet to port 25 remotely (Windows SMTP)

November 16, 2010 Leave a comment

Setting up the SMTP & POP3 service on Windows 2003, I noticed that I could telnet localhost 25 on remote desktop, but not telnet port 25 remotely.

This turned out to be a setting in the Windows SMTP service. Just Open IIS, Right click properties on Default SMTP virtual server, then Access, connection and

select “All except list below”. Then I can telnet in, and the email started working 🙂

Categories: Uncategorized

Start an IIS website synchronously with ADSI

November 15, 2010 Leave a comment

Using ADSI, once you have a DirectoryEntry object for a given website using

var root = new DirectoryEntry(“IIS://localhost/W3SVC”);
foreach (DirectoryEntry e in root.Children)
{
if (e.SchemaClassName != “IIsWebServer”) continue;

// e now represents a website in IIS

}

You can start and stop it using

Entry.Invoke(“start”);

Entry.Invoke(“stop”);

However, these commands run asynchronously, and you need to poll on the value

Entry.Invoke(“Get”, “ServerState”)

Where 4 is stopped and 2 is started. However, those using IISAdmin.net will find that this value never changes, meaning that it is impossible to tell when the website has actually changed state. Therefore, my fix was calling:

Entry.RefreshCache();

Prior to calling Invoke/Get

Categories: Uncategorized

Hello World on Windows Phone 7

November 12, 2010 Leave a comment

Just having a look at the Windows Phone SDK, and my first app, as always is “Hello World”

Here’s the Xaml below;

<phone:PhoneApplicationPage
x:Class=”WindowsPhoneApplication.MainPage”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
xmlns:phone=”clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone”
xmlns:shell=”clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone”
xmlns:d=”http://schemas.microsoft.com/expression/blend/2008&#8243;
xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006&#8243;
mc:Ignorable=”d” d:DesignWidth=”480″ d:DesignHeight=”696″
FontFamily=”{StaticResource PhoneFontFamilyNormal}”
FontSize=”{StaticResource PhoneFontSizeNormal}”
Foreground=”{StaticResource PhoneForegroundBrush}”
SupportedOrientations=”Portrait” Orientation=”Portrait”
shell:SystemTray.IsVisible=”True”>

<!–LayoutRoot is the root grid where all page content is placed–>
<Grid x:Name=”LayoutRoot” Background=”Transparent”>
<Grid.RowDefinitions>
<RowDefinition Height=”Auto”/>
<RowDefinition Height=”*”/>
</Grid.RowDefinitions>

<!–TitlePanel contains the name of the application and page title–>
<StackPanel x:Name=”TitlePanel” Grid.Row=”0″ Margin=”12,17,0,28″>
<TextBlock x:Name=”ApplicationTitle” Text=”Hello World” Style=”{StaticResource PhoneTextNormalStyle}”/>
<TextBlock x:Name=”PageTitle” Text=”Hi!” Margin=”9,-7,0,0″ Style=”{StaticResource PhoneTextTitle1Style}”/>
</StackPanel>

<!–ContentPanel – place additional content here–>
<Grid x:Name=”ContentPanel” Grid.Row=”1″ Margin=”12,0,12,0″></Grid>
</Grid>

<!–Sample code showing usage of ApplicationBar–>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible=”True” IsMenuEnabled=”True”>
<shell:ApplicationBarIconButton IconUri=”/Images/appbar_button1.png” Text=”Button 1″/>
<shell:ApplicationBarIconButton IconUri=”/Images/appbar_button2.png” Text=”Button 2″/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text=”MenuItem 1″/>
<shell:ApplicationBarMenuItem Text=”MenuItem 2″/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>

Categories: Uncategorized