Configuring VyprVPN on Android 2.1
We all know that NOTHING is private on an Open Wi-Fi network (like at starbucks, book stores, airports … and yes even hotel rooms) (see this article for more information: What is a Wi-Fi Hotspot and How Do I Use It? and this one How to Stay Safe on Public Wi-Fi)
So how do you protect your information? on your shiny new Android phone? … Use a service like VyprVPN
I did the following steps on my new Nexus One (Android version 2.1)
How to configure VyprVPN on Android 2.1
- go into settings
- Wireless & networks
- VPN settings
- Add VPN
- Add PPTP VPN
- set the VPN name: VyprVPN (or whatever you want doesn’t make a difference)
-
set the VPN server to one of the following:
- us1.vpn.giganews.com for Los Angeles, CA
- us2.vpn.giganews.com for Washington, DC
- eu1.vpn.giganews.com for Amsterdam
- YES! Enable encryption (otherwise whats the point)
- do not need any DNS search domains (this is for corporate VPNs)
thats IT … Menu … Save
to use it remember to:
Type your Giganews Username and Password in their respective fields
How To Convert from a .NET Int32 to EBCDIC Signed Integer
Many of us have had to write data exports from our PC based management systems that are in some strange formats. Signed Integers (which smells of COBOL and EBCDIC on a main frame) are no exception.
Now I know all you Computer and Mini Computer (mid range) guys out there are like ‘strange format’? YOUR STRANGE TONY!!! . well maybe
Anyway here is my C# method for converting from System.Int32 to a signed integer string.
public static string GetSignedInt(int i)
{
if (i == 0)
return "0";
char[] c = i.ToString().ToCharArray();
Encoder enc = System.Text.Encoding.GetEncoding(37).GetEncoder();
byte[] b = new byte[1];
int usedChars;
int usedBytes;
bool completed;
enc.Convert(c, c.Length – 1, 1, b, 0, 1, true, out usedChars, out usedBytes, out completed);
if (i > 0)
b[0] = (byte)(b[0] – 48);
else
b[0] = (byte)(b[0] – 32);
c[c.Length - 1] = (char)b[0];
Decoder dec = System.Text.Encoding.GetEncoding(37).GetDecoder();
dec.Convert(b, 0, 1, c, c.Length – 1, 1, true, out usedBytes, out usedChars, out completed);
return new string(c);
}
Basically I’m converting to EBCDIC first, then do the simple math that offsets us into either a positive number or negative number, then convert back to ASCII. It might be expensive to do it this way, but I’d rather it cost more if there is one less logic tree to debug
Resolution to QUOTED_IDENTIFIER Error when using SqlCacheDependancy’s
At work we are building a medium sized ASP.NET web application.
We are using ASP.NET forms authentication for the membership. I then decided to implement a custom role provider (implementing ProviderBase) based on our [Employee] application table. Implementing this was really easy! Along the way I realized that out database was going to get hammered unless I implemented some kind of caching. Fortunate for me ASP.NET has a great application cache framework.
Enter SqlCacheDependancy : Were running this on SQL 2005, so I set ENABLE_BROKER (which enables the Service Broker) on my database.
About once or twice a day we started seeing the following error in our Health Monitoring logs:
Process information:
Process ID: 3804
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: System.Data.SqlClient.SqlException
Exception message: UPDATE failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or query notifications and/or xml data type methods.
Since many of the tables are created by aspnet_regsql.exe . I didn’t want to monkey around with the MS tables.
You need to set the QUOTED_IDENTIFIER option at the database level BEFORE you install the aspnet tables.
ALTER DATABASE [db] SET QUOTED_IDENTIFIER ON WITH NO_WAIT
note on the NO_WAIT option: (from msdn)
NO_WAIT
NO_WAIT checks for connections before attempting to change the database state and causes the ALTER DATABASE statement to fail if certain connections exist. When the transition is to SINGLE_USER mode, the ALTER DATABASE statement fails if any other connections exist. When the transition is to RESTRICTED_USER mode, the ALTER DATABASE statement fails if any unqualified connections exist.
So here is the order in which I build the database:
- create database
- alter database, set enable_broker
- alter database, set QUOTED_IDENTIFIER
- install aspnet_regsql.exe tables
- install application tables, view, sprocs, etc . . .
That is it, I hope this helps you out in your adventures!
Linux Killall Equivalent in Windows Vista
While working on a midsized ASP.NET project today, I finally got fed up having to kill ‘by hand’ (or by clicking) the ASP.NET Development Servers (4 run for my project).
I found this Linux Killall equivalent in Windows Vista today:
TASKKILL
TASKKILL [/S system [/U username [/P [password]]]]
{ [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]
Description:
This tool is used to terminate tasks by process id (PID) or image name.
Parameter List:
/S system Specifies the remote system to connect to.
/U [domain\]user Specifies the user context under which the
command should execute.
/P [password] Specifies the password for the given user
context. Prompts for input if omitted.
/FI filter Applies a filter to select a set of tasks.
Allows "*" to be used. ex. imagename eq acme*
/PID processid Specifies the PID of the process to be terminated.
Use TaskList to get the PID.
/IM imagename Specifies the image name of the process
to be terminated. Wildcard '*' can be used
to specify all tasks or image names.
/T Terminates the specified process and any
child processes which were started by it.
/F Specifies to forcefully terminate the process(es).
/? Displays this help message.
Filters:
Filter Name Valid Operators Valid Value(s)
----------- --------------- -------------------------
STATUS eq, ne RUNNING |
NOT RESPONDING | UNKNOWN
IMAGENAME eq, ne Image name
PID eq, ne, gt, lt, ge, le PID value
SESSION eq, ne, gt, lt, ge, le Session number.
CPUTIME eq, ne, gt, lt, ge, le CPU time in the format
of hh:mm:ss.
hh - hours,
mm - minutes, ss - seconds
MEMUSAGE eq, ne, gt, lt, ge, le Memory usage in KB
USERNAME eq, ne User name in [domain\]user
format
MODULES eq, ne DLL name
SERVICES eq, ne Service name
WINDOWTITLE eq, ne Window title
NOTE
----
1) Wildcard '*' for /IM switch is accepted only when a filter is applied.
2) Termination of remote processes will always be done forcefully (/F).
3) "WINDOWTITLE" and "STATUS" filters are not considered when a remote
machine is specified.
Examples:
TASKKILL /IM notepad.exe
TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
TASKKILL /F /IM cmd.exe /T
TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"
Creating a ASP.NET Rounded Panel
These days using a Rounded Panel on your web site is almost a given. Here is an example to creating a Rounded Panel that inherits from System.Web.Ui.Panel, in a WebControls class library.
First thing I did was fire up Jasc Paintshop Pro and created some rounded rectangles (with a 4px radius) … then I cut the corners off, and pasted all of them into a new image (16×4) [its a PNG with a transparent background]
The Image I used for the corners (4corners-c.png) [the image go in your web project]
The C# code [this goes in your class library]
using System.Web.UI; using System.Web.UI.WebControls; namespace MyWebControls { [ToolboxData( "<{0}:RoundedPanel runat=\"server\"></{0}:RoundedPanel>")] public class RoundedPanel : Panel { public override void RenderBeginTag(HtmlTextWriter writer) { writer.WriteBeginTag("table"); writer.WriteAttribute("class", "RoundedPanel"); writer.WriteAttribute("cellpadding", "0"); writer.WriteAttribute("cellspacing", "0"); writer.Write(Html32TextWriter.TagRightChar); writer.WriteBeginTag("tr"); writer.Write(Html32TextWriter.TagRightChar); writer.WriteBeginTag("td"); writer.WriteAttribute("class", "tl"); writer.Write(Html32TextWriter.TagRightChar); writer.Write("<div style='width:1px;height:1px;overflow:hidden;'></div>"); writer.WriteEndTag("td"); writer.WriteBeginTag("td"); writer.WriteAttribute("class", "top"); writer.Write(Html32TextWriter.TagRightChar); writer.Write("<div style='width:1px;height:1px;overflow:hidden;'></div>"); writer.WriteEndTag("td"); writer.WriteBeginTag("td"); writer.WriteAttribute("class", "tr"); writer.Write(Html32TextWriter.TagRightChar); writer.Write("<div style='width:1px;height:1px;overflow:hidden;'></div>"); writer.WriteEndTag("td"); writer.WriteEndTag("tr"); } public override void RenderEndTag(HtmlTextWriter writer) { writer.WriteBeginTag("tr"); writer.Write(Html32TextWriter.TagRightChar); writer.WriteBeginTag("td"); writer.WriteAttribute("class", "bl"); writer.Write(Html32TextWriter.TagRightChar); writer.Write("<div style='width:1px;height:1px;overflow:hidden;'></div>"); writer.WriteEndTag("td"); writer.WriteBeginTag("td"); writer.WriteAttribute("class", "bottom"); writer.Write(Html32TextWriter.TagRightChar); writer.Write("<div style='width:1px;height:1px;overflow:hidden;'></div>"); writer.WriteEndTag("td"); writer.WriteBeginTag("td"); writer.WriteAttribute("class", "br"); writer.Write(Html32TextWriter.TagRightChar); writer.Write("<div style='width:1px;height:1px;overflow:hidden;'></div>"); writer.WriteEndTag("td"); writer.WriteEndTag("tr"); writer.WriteEndTag("table"); } protected override void RenderContents(HtmlTextWriter writer) { writer.WriteBeginTag("tr"); writer.Write(Html32TextWriter.TagRightChar); writer.WriteBeginTag("td"); writer.WriteAttribute("class", "left"); writer.Write(Html32TextWriter.TagRightChar); writer.Write("<div style='width:1px;height:1px;overflow:hidden;'></div>"); writer.WriteEndTag("td"); writer.WriteBeginTag("td"); writer.WriteAttribute("class", "content"); writer.Write(Html32TextWriter.TagRightChar); base.RenderContents(writer); writer.WriteEndTag("td"); writer.WriteBeginTag("td"); writer.WriteAttribute("class", "right"); writer.Write(Html32TextWriter.TagRightChar); writer.Write("<div style='width:1px;height:1px;overflow:hidden;'></div>"); writer.WriteEndTag("td"); writer.WriteEndTag("tr"); } } }
I chose to inherit from Panel, that way I didn’t have to deal with the complexities of creating a Container Control (a control than can contain other controls), also you can treat my panel as a regular Panel, so your code behind pretty much can stay the same.
You can see that I am using some CSS classes for the styling, you could extend those string literals as public properties if you didn’t want the class names to be hard coded.
The CSS [this goes in your web project]
.RoundedPanel { } .RoundedPanel .tl { background-image: url("images/4corners-c.png"); background-repeat: no-repeat; width:4px; height:4px; } .RoundedPanel .top { border-top: 1px solid #c0c0c0; height:3px; } .RoundedPanel .tr { background-position: -3px 0px; background-image: url("images/4corners-c.png"); background-repeat: no-repeat; width:4px; height:4px; } .RoundedPanel .left { border-left: 1px solid #c0c0c0; width:4px; } .RoundedPanel .content { } .RoundedPanel .right { border-right: 1px solid #c0c0c0; width:4px; } .RoundedPanel .bl { background-position: -8px 0px; background-image: url("images/4corners-c.png"); background-repeat: no-repeat; width:4px; height:4px; } .RoundedPanel .bottom { border-bottom: 1px solid #c0c0c0; height:3px; } .RoundedPanel .br { background-position: -11px 0px; background-image: url("images/4corners-c.png"); background-repeat: no-repeat; width:4px; height:4px; }
Also … if you wanted to you could embed your images and CSS in your WebControl library … but I will leave that to another post. (hint search for Page.ClientScript.GetWebResourceUrl())
ADO.NET Entity Framework
|
I just started reading Programming Entity Framework The subjects include: Data Binding with WPF, LINQ to Entities Queries, Utilizing the ASP.NET EntityDataSource Control, Using Entity Objects with Web and WCF Services, Using the Entity Framework with n-Tier Windows Forms or WPF Applications, a bit on Data Transfer Objects (DTO), Customizing Entities, Using the Entity Framework with n-Tier ASP.NET Applications, Using Stored Procedures with the EDM, Handling Entity Framework Exceptions, Performance, Security, Multithreaded Applications, Data Binding with Windows Forms . there are many other topics discussed So far I love the layout of the book. I also looked at Professional ADO.NET 3.5 with LINQ and the Entity Framework (Wrox Programmer to Programmer) (Paperback) … but I decided to go with this newer Programming Entity Framework book … |
How To Burn ISO Images on Windows Server 2008
You can use the CDBurn.exe tool from Microsoft. It is included in the Windows Server 2003 Resource Tools.
You can even use this tool to erase CDRW discs.
Command Line Syntax:
Usage:
cdburn <drive> image [options]
Options:
-erase Erases the disk before burning (valid for R/W only)
-sao Writes the image out in "session at once", or cue
sheet, mode (default is "track at once")
-speed Speed of burn, or ‘max’ for maximum speed
-imagehaspostgap Use if your image already contains a 150 sector postgap
The [image] must be provided unless the -erase flag is set.
If both an image and -erase are provided, the media will be
erased prior to burning the image to the disc.
LINQ, SqlMetal, Nesting The Generated Code File
LINQ is really cool, SqlMetal has been my code generator of choice (for a book on LINQ, SqlMetal and all of the cool new features)… I like to keep my class file names the same as the class contained in the file. Since SqlMetal generates partial classes, and we don’t want to modify the generated file directly, well now we are stuck creating a new file name that doesn’t match our naming convention. (note: you could stick the generated code in a generated directory or something, which is what I had done in the past… UNTIL NOW
)
Enter the DependentUpon element tag in your project file. Real quick open a Windows Forms, or Web project. Notice how the webforms or windows forms classes have a *.designer.cs code file nested underneath the actual form. Not only does it help us keep the files grouped together, but it allows us to keep naming conventions and keeps the project solution clean… Now that you have your project open, unload it, then Edit the project file directly (so you can see the XML)… Scroll down to the Compile items collection… Ah Ha! do you see that? Its the DependentUpon element nested underneath the *.designer.cs files.
You can use this for your Linq DataProvider class library projects. Here’s the system that I use.
A Regenerate batch file (DbGen.cmd)
Modify your csproj file to use the DependentUpon directive on your generated code file.
<Compile Include=”website.cs” />
<Compile Include=”website.sqlmetal.cs”>
<DependentUpon>website.cs</DependentUpon>
</Compile>
All of your custom code goes into the base named code file (website.cs in my example)
How To Install Windows Live Writer on Windows Server 2008
So this is my first post using Windows Live Writer from a Windows Server 2008 workstation.
I was not able to install Windows Live Writer 2008 on my server workstation, it would give the error:
Sorry, Windows Live programs cannot be installed on Windows Server, Windows XP Professional x64 Edition, or Windows operating systems earlier than Windows XP Service Pack 2.
BUT you CAN install the Technical Preview version on Windows Server 2008 !!!
Need a good book on Windows Server 2008, see Windows Server 2008 Unleashed
How To Copy / Clone a Hyper-V Virtual Machine
You can create a copy or clone of an existing virtual machine (VM) quite easily in Hyper-V … The process is a little different than you might think though. The basic procedure is to export and import a virtual machine. I use my VM’s primarily for separate development sandboxes and test machines, so here’s the steps I used:
- Sysprep the guest VM (for windows machines)
- Shut down the guest
- Rename the VM to “Dev Ws – Base” (in Hyper-V Manager)
- Hyper-V Export Virtual Machine
- Rename the original VM back to the original name
- Make a copy of the exported directory in windows explorer (optional if you want more than one copy) (i used robocopy from an administrator command prompt [robocopy /s "Dev Ws - Base" "Dev Ws - SplendidCRM"])
- Import the one of the directories
- Rename the new VM to your new VM name, in my case it was “Dev Ws – DotNetNuke”
Now you should have multiple copies of your original VM. Check out Microsoft Windows Server 2008: Implementation and Administration for more information on Hyper-V!
Oh and if you want to move the exported folder for any reason before you re-import it, you might need to stop the Hyper-V service, other wise you may get a “destination folder access denied” error box.
If you want a scripted solution to this (like to make lets say 10 machines) check out this post.