Friday, September 30, 2005

Updated C# Text Clips (PN2)

Updated Text Clips for Programmers Notepad 2 (C#). ASP.NET Snippets and Miscellaneous Snippets (properties) added.


Tags: ,

Wednesday, September 21, 2005

Programmers Notepad 2 User Tools

Programmers Notepad 2 has a very useful tools feature. The configuration is kept in the %APPDATA%\Echo Software\PN2 folder as UserTools.xml

The format is fairly simple. Here is my UserTools.xml file:

<schemetools>
    <global>
        <tool command="C:\Program Files\Scintilla Text Editor\SciTE.exe" flags="40" folder="" index="0" name="SciTE" params="&quot;%d%f&quot;" parsepattern="" shortcut="0"></tool>
        <tool command="C:\Program Files\FileZilla\FileZilla.exe" flags="40" folder="%d" index="1" name="FileZilla" params="" parsepattern="" shortcut="0"></tool>
        <tool command="explorer.exe" flags="40" folder="" index="2" name="Windows Explorer" params="%d" parsepattern="" shortcut="0"></tool>
        <tool command="cmd" flags="40" folder="" index="3" name="Command Prompt" params="/k cd %d" parsepattern="" shortcut="0"></tool>
        <tool command="mmc" flags="40" folder="" index="4" name="IIS" params="C:\WINNT\System32\Inetsrv\iis.msc" parsepattern="" shortcut="0"></tool>
        <tool command="svn" flags="33" folder="%d" index="5" name="svn add" params="add &quot;%f&quot;" parsepattern="" shortcut="0"></tool>
        <tool command="svn" flags="33" folder="%d" index="6" name="svn add (all in folder)" params="add *" parsepattern="" shortcut="0"></tool>
        <tool command="svn" flags="97" folder="%d" index="7" name="svn commit" params="commit &quot;%f&quot; --message &quot;%?&quot;" parsepattern="" shortcut="0"></tool>
        <tool command="svn" flags="33" folder="%d" index="8" name="svn commit (folder)" params="commit --message &quot;%?&quot;" parsepattern="" shortcut="0"></tool>
        <tool command="svn" flags="33" folder="%d" index="9" name="svn commit (folder, non-recursive)" params="commit --non-recursive --message &quot;%?&quot;" parsepattern="" shortcut="0"></tool>
        <tool command="svn" flags="33" folder="%d" index="10" name="svn diff" params="diff &quot;%f&quot;" parsepattern="" shortcut="0"></tool>
        <tool command="svn" flags="33" folder="%d" index="11" name="svn info" params="info &quot;%f&quot;" parsepattern="" shortcut="0"></tool>
        <tool command="svn" flags="33" folder="%d" index="12" name="svn status" params="status &quot;%f&quot;" parsepattern="" shortcut="0"></tool>
        <tool command="svn" flags="33" folder="%d" index="13" name="svn status (folder)" params="status" parsepattern="" shortcut="0"></tool>
        <tool command="svn" flags="33" folder="%d" index="14" name="svn status (folder, non-recursive)" params="status --non-recursive" parsepattern="" shortcut="0"></tool>
        <tool command="svn" flags="35" folder="%d" index="15" name="svn update" params="update &quot;%f&quot;" parsepattern="" shortcut="0"></tool>
    </global>
    <scheme name="csharp">
        <tool command="C:\Program Files\SharpDevelop\bin\SharpDevelop.exe" flags="41" folder="" index="0" name="SharpDevelop" params="&quot;%d%f&quot;" parsepattern="" shortcut="0"></tool>
    </scheme>
    <scheme name="web">
        <tool command="tidy" flags="1569" folder="" index="0" name="Tidy" params="-i -asxhtml -wrap 230 --indent-spaces 4 -q" parsepattern="" shortcut="0"></tool>
    </scheme>
    <scheme name="xml">
        <tool command="tidy" flags="1569" folder="" index="0" name="Tidy" params="-i -xml -wrap 230 --indent-spaces 4 -q" parsepattern="" shortcut="0"></tool>
    </scheme>
</schemetools>

As you can see, the root tag is '<schemetools>'. There is one '<global>' tag under this with tools common to all files. There are also several '<scheme>' tags with tools for each scheme.

Under '<global>' and '<scheme>' you can have '<tool>', with the following attributes:

  • command: path to the executable to run, include full path if not in any of the folders listed in the PATH environment variable.
  • flags: various preferences set using checkboxes and dropdowns in the tool properties (i.e. those that are not set with any other attributes for the '<tool>' tag)
  • folder: which folder the tool starts in
  • index: where it appears in the tool list
  • name: what you see when you use the Tools menu
  • params: parameters you pass on the the command
  • parsepattern: pattern for custom output parsing
  • shortcut: keyboard shortcut for the tool. 0 means no shortcut. Calculate by adding one or more modifiers to numbers, numpad, cursor, letter or function key values.
    • Modifiers: SHIFT = 256, CTRL = 512, ALT = 1024
    • Numbers: 0 = 48, 1 = 49, 2 = 50, 3 = 51, 4 = 52, 5 = 53, 6 = 54, 7 = 55, 8 = 56, 9 = 57
    • Numpad: 0 = 96, 1 = 97, 2 = 98, 3 = 99, 4 = 100, 5 = 101, 6 = 102, 7 = 103, 8 = 104, 9 = 105, * = 106, + = 107, - = 109, . = 110, / = 2159
    • Cursor: UP = 2086, DOWN = 2088, LEFT = 2085, RIGHT = 2087
    • Letters: A = 65, B = 66, C = 67, D = 68, E = 69, F = 70, G = 71, H = 72, I = 73, J = 74, K = 75, L = 76, M = 77, N = 78, O = 79, P = 80, Q = 81, R = 82, S = 83, T = 84, U = 85, V = 86, W = 87, X = 88, Y = 89, Z = 90
    • Function Keys: F1 = 112, F2 = 113, F3 = 114, F4 = 115, F5 = 116, F6 = 117, F7 = 118, F8 = 119, F9 = 120, F10 = 121, F11 = 122, F12 = 123

You cannot use a modifier on its own. You can combine modifiers with numbers, letters or function keys. You can have only one number, letter, or function key in a shortcut (so no F1 + A).

For example, CTRL + ALT + Numpad * = 512 + 1024 + 106 = 1642


Tags: , ,

Tuesday, September 20, 2005

Opera now free (no banner ads)

The Opera browser is now available without banner ads. Has fairly good standards support and is a very small download, also very fast at loading and displaying web pages. Now if only it had an extensions mechanism like Firefox. A three way battle between Firefox, IE and Opera (which was only really two way before as Opera had ads).


Tags: ,

Thursday, September 15, 2005

Text Clips for Programmers Notepad 2 (C#)

Edit (30 Sep 2005): ASP.NET Snippets and Miscellaneous Snippets (properties) added.

More Text Clips for Programmers Notepad 2. Useful for when working with C#.

Create a file in the clips sub directory of the Programmers Notepad directory, with the extension .clips (i.e. csclips.clips) and paste in the following code:

<?xml version="1.0"?>
<clips name="C# Clips">
<clip name="------ Exception handling ------"></clip>
<clip name="throw"><![CDATA[throw(new |Exception());]]></clip>
<clip name="try-catch"><![CDATA[try
{
|
}
catch(Exception e)
{

}]]></clip>
<clip name="try-finally"><![CDATA[try
{
|
}
finally
{

}]]></clip>
<clip name="try-catch-finally"><![CDATA[try
{
|
}
catch(Exception e)
{

}
finally
{

}]]></clip>
<clip name="------ Iteration ------"></clip>
<clip name="do"><![CDATA[do 
{

}
while(|);]]></clip>
<clip name="for"><![CDATA[for (int i = 0; i <= |; i++)
{

}]]></clip>
<clip name="foreach"><![CDATA[foreach (int i in |)
{

}]]></clip>
<clip name="while"><![CDATA[while(|) 
{

}]]></clip>
<clip name="------ Reference type declaration ------"></clip>
<clip name="class"><![CDATA[public class |
{

}]]></clip>
<clip name="delegate"><![CDATA[delegate void |();]]></clip>
<clip name="delegate (event handling)"><![CDATA[public delegate void |ChangedEventHandler();
public event ChangedEventHandler Changed;
protected virtual void OnChanged() 
{
 if (Changed != null)
 {
  Changed();
 }
}]]></clip>
<clip name="interface"><![CDATA[public interface I|
{

}]]></clip>
<clip name="------ Selection ------"></clip>
<clip name="?:"><![CDATA[| = (bar == baz) ? footrue : foofalse]]></clip>
<clip name="if"><![CDATA[if(|) 
{

}]]></clip>
<clip name="if-else"><![CDATA[if(|) 
{

}
else
{

}]]></clip>
<clip name="if-else if"><![CDATA[if(|) 
{

}
else if()
{

}]]></clip>
<clip name="switch case"><![CDATA[switch(|) 
{
 case 1:
  break;
 default:
  break;
}]]></clip>
<clip name="------ Documentation Comments ------"></clip>
<clip name="/// "><![CDATA[///|]]></clip>
<clip name="&lt;c&gt; (inline code)"><![CDATA[<c>|</c>]]></clip>
<clip name="&lt;code&gt; (multiline code)"><![CDATA[/// <code>
/// |
/// </code>]]></clip>
<clip name="&lt;example&gt; (method example)"><![CDATA[/// <example>
/// |
/// </example>]]></clip>
<clip name="&lt;example&gt; (method example, includes &lt;code&gt;)"><![CDATA[/// <example>
///  <code>
/// |
///  </code>
/// </example>]]></clip>
<clip name="&lt;exception&gt;"><![CDATA[/// <exception cref="System.Exception">Thrown when... |.</exception>]]></clip>
<clip name="&lt;include&gt;"><![CDATA[//// <include file='|.xml' path='MyDocs/MyMembers[@name="test"]/*' />]]></clip>
<clip name="&lt;list&gt; (bullet, with items)"><![CDATA[/// <list type="bullet">
///  <listheader>
///   <term>List Header</term>
///   <description>|.</description>
///  </listheader>
///  <item>
///   <term>Term 1</term>
///   <description>Item 1.</description>
///  </item>
///  <item>
///   <term>Term 2</term>
///   <description>Item 2.</description>
///  </item>
/// </list>]]></clip>
<clip name="&lt;list&gt; (number, with items)"><![CDATA[/// <list type="number">
///  <listheader>
///   <term>List Header</term>
///   <description>|.</description>
///  </listheader>
///  <item>
///   <term>Term 1</term>
///   <description>Item 1.</description>
///  </item>
///  <item>
///   <term>Term 2</term>
///   <description>Item 2.</description>
///  </item>
/// </list>]]></clip>
<clip name="&lt;list&gt; (table, with items)"><![CDATA[/// <list type="table">
///  <listheader>
///   <term>List Header</term>
///   <description>|.</description>
///  </listheader>
///  <item>
///   <term>Term 1</term>
///   <description>Item 1.</description>
///  </item>
///  <item>
///   <term>Term 2</term>
///   <description>Item 2.</description>
///  </item>
/// </list>]]></clip>
<clip name="&lt;list&gt; (bullet, without items)"><![CDATA[/// <list type="bullet">
/// |
/// </list>]]></clip>
<clip name="&lt;list&gt; (number, without items)"><![CDATA[/// <list type="number">
/// |
/// </list>]]></clip>
<clip name="&lt;list&gt; (table, without items)"><![CDATA[/// <list type="table">
/// |
/// </list>]]></clip>
<clip name="&lt;list&gt; - &lt;item&gt;"><![CDATA[///  <item>
///   <term>List Header</term>
///   <description>|.</description>
///  </item>]]></clip>
<clip name="&lt;list&gt; - &lt;listheader&gt;"><![CDATA[///  <listheader>
///   <term>List Header</term>
///   <description>|.</description>
///  </listheader>]]></clip>
<clip name="&lt;para&gt; (paragraph)"><![CDATA[/// <para>
///  |
/// </para>]]></clip>
<clip name="&lt;param&gt; (parameter)"><![CDATA[/// <param name='|'>Description.</param>]]></clip>
<clip name="&lt;paramref&gt; (parameter reference)"><![CDATA[<paramref name="|"/>]]></clip>
<clip name="&lt;permission&gt;"><![CDATA[/// <permission cref="System.Security.PermissionSet">|.</permission>]]></clip>
<clip name="&lt;remarks&gt;"><![CDATA[/// <remarks>
/// |
/// </remarks>]]></clip>
<clip name="&lt;returns&gt;"><![CDATA[/// <returns>
/// |
/// </returns>]]></clip>
<clip name="&lt;see&gt;"><![CDATA[<see cref="|"/>]]></clip>
<clip name="&lt;seealso&gt;"><![CDATA[<seealso cref="|"/>]]></clip>
<clip name="&lt;summary&gt;"><![CDATA[/// <summary>
/// |
/// </summary>]]></clip>
<clip name="&lt;value&gt;"><![CDATA[/// <value>|.</value>]]></clip>
<clip name="------ ASP.NET Snippets ------"></clip>
<clip name="Page CodeBehind"><![CDATA[using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace MyNamespace
{
 public class MyPage : Page
 {
  #region Web Form Designer generated code
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: This call is required by the ASP.NET Web Form Designer.
   //
   InitializeComponent();
  }
  /// <summary>
  ///  Required method for Designer support - do not modify
  ///  the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {
   this.Load += new System.EventHandler(this.LoadPage);
  }
  #endregion
  
  private void LoadPage(object sender, EventArgs e)
  {
   |
  }
 }
}]]></clip>
<clip name="UserControl CodeBehind"><![CDATA[using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace MyNamespace
{
 public class MyControl : UserControl
 {
  #region Web Form Designer generated code
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: This call is required by the ASP.NET Web Form Designer.
   //
   InitializeComponent();
  }
  /// <summary>
  ///  Required method for Designer support - do not modify
  ///  the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {
   this.Load += new System.EventHandler(this.LoadUserControl);
  }
  #endregion
  
  private void LoadUserControl(object sender, EventArgs e)
  {
   |
  }
 }
}]]></clip>
<clip name="WebHandler"><![CDATA[<%@ WebHandler Language="C#" Class="MyNamespace.MyHandler" %>
using System;
using System.IO;
using System.Web;
namespace MyNamespace
{
 public class MyHandler: IHttpHandler 
 {
  
  public bool IsReusable
  {
   get
   {
    return true;
   }
  }
  
  public void ProcessRequest(HttpContext ctx)
  {
   ctx.Response.ContentType = "text/plain";
   ctx.Response.Write("|");
   ctx.Response.End();
  }
 }
}]]></clip>
<clip name="------ Miscellaneous Snippets ------"></clip>
<clip name="Property (bool)"><![CDATA[private bool |myBool;
public bool MyBool
{
 get
 {
  return myBool;
 }
 set
 {
  myBool = value;
 }
}]]></clip>
<clip name="Property (DateTime)"><![CDATA[private DateTime |myDate;
public DateTime MyDate
{
 get
 {
  return myDate;
 }
 set
 {
  myDate = value;
 }
}]]></clip>
<clip name="Property (decimal)"><![CDATA[private decimal |myDecimal;
public decimal MyDecimal
{
 get
 {
  return myDecimal;
 }
 set
 {
  myDecimal = value;
 }
}]]></clip>
<clip name="Property (double)"><![CDATA[private double |myDouble;
public double MyDouble
{
 get
 {
  return myDouble;
 }
 set
 {
  myDouble = value;
 }
}]]></clip>
<clip name="Property (float)"><![CDATA[private float |myFloat;
public float MyFloat
{
 get
 {
  return myFloat;
 }
 set
 {
  myFloat = value;
 }
}]]></clip>
<clip name="Property (int)"><![CDATA[private int |myInt;
public int MyInt
{
 get
 {
  return myInt;
 }
 set
 {
  myInt = value;
 }
}]]></clip>
<clip name="Property (long)"><![CDATA[private long |myLong;
public long MyLong
{
 get
 {
  return myLong;
 }
 set
 {
  myLong = value;
 }
}]]></clip>
<clip name="Property (short)"><![CDATA[private short |myShort;
public short MyShort
{
 get
 {
  return myShort;
 }
 set
 {
  myShort = value;
 }
}]]></clip>
<clip name="Property (string)"><![CDATA[private string |myString;
public string MyString
{
 get
 {
  return myString;
 }
 set
 {
  myString = value;
 }
}]]></clip>
</clips>

Tags: , , ,

Wednesday, September 14, 2005

Google Blog Search

Search weblogs with Google Blog Search. If a site has an RSS feed and 'pings' a site (like Weblogs.com) when it is updated, it should become searchable through this. In some ways better than Google Search as it is likely to be more up to date and have less spam. You can have your results as an Atom or RSS feed. No ads (yet).


Tags: , ,

Thursday, September 08, 2005

Tamper proof URL's, Expiring Web Pages

Passing Tamper-Proof QueryString Parameters and Creating Expiring Web Pages cover how you can improve the security of your web application. While the example code is in VB.NET, the idea can be applied to any web programming language (PHP, Perl, VBScript etc). Basically you pass a hash (of the parameters plus a 'secret salt' (a custom string added to the start/finish)) only known to those that need to connect to the page (often just pages on the same website, but maybe used by other sites), along with the parameters and the current time and date.


Tags: ,

Web Standards Are Your Responsibility

7nights - Web Standards Are Your Responsibility. It may be a challenge to get an uncompliant site recoded to standards, but will save time in maintenance in the future (if you pages are semantically well done), plus the pages will work as expected (except perhaps a few CSS quirks) in any browser that is compliant with the standard. Standards can also be a selling point for an application - a bigger market can be targetted than if you coded just for the dominant browser (i.e. Internet Explorer). Plus there is no guarantee that your site will work in the future (if IE lost its dominant market share).


Tags: ,

Runasspc - run programs with admin rights

Runasspc allows limited account users to run programs with admin rights. Better than runas as it saves the credentials encrypted in a file and you decide which programs can be run as admin, no need to give out the password.


Tags: ,

Sunday, September 04, 2005

Standards-schmandards

Standards-schmandards is a site about developing accessible web pages. Despite its name, standards are important to its authors. It is the home of FANGS, a screen reader emulator for Firefox.


Tags: ,

CSS 2.1 parser in IE 7

Looks like many pages will not be broken when the CSS in IE7 is improved. So by implemented hacks that use child selectors and the * html hack to work round IE, the * html will be ignored while the child selector processed (like what other browsers do).

"We've already started talking about a few of the CSS changes that are going to be available in IE 7 when we release, but there are a few hanging points that we haven't talked about yet or haven't covered completely. There are 3 specific items I'd like to talk about:
  • Using the root node wild card selector for IE only rules (* HTML) [strict mode only fix]
  • Multi-class selectors as defined by CSS 2.1 (.floral.pastel) [strict mode only fix]
  • Pseudo-element parsing sometimes flags rules as invalid (P:first-letter{ color: red; }) [strict/quirks mode fix]"
Improving the CSS 2.1 strict parser for IE 7

Tags: , ,