Skip to content

Author: xavier

Cisco SPA303 – Dial Plan

I’m new to the SPA303 phone. I had trouble figuring out how to set it up so I don’t have to dial the area code for a phone number within the same area code. Below is an example I found.

 Original string:

(*xx|[3469]11|0|00|[2-9]xxxxxx|1xxx[2-9]xxxxxxS0|xxxxxxxxxxxx.)

 Modified string: (lets assume my area code is 999)

(*xx|[3469]11|0|00|<:1999>[2-9]xxxxxx|1xxx[2-9]xxxxxxS0|xxxxxxxxxxxx.)

 

Leave a Comment

Access Modifiers (C# Programming Guide)

All types and type members have an accessibility level, which controls whether they can be used from other code in your assembly or other assemblies. You can use the following access modifiers to specify the accessibility of a type or member when you declare it:

public

The type or member can be accessed by any other code in the same assembly or another assembly that references it.

private

The type or member can be accessed only by code in the same class or struct.

protected

The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.

internal

The type or member can be accessed by any code in the same assembly, but not from another assembly.

protected internal

The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type.

http://msdn.microsoft.com/en-us/library/ms173121.aspx

Leave a Comment

SQL Changing Schema Name

Changing it one by one use the following.

ALTER SCHEMA dbo TRANSFER someschema.someobject;

Changing all stored procedures.

select 'ALTER SCHEMA dbo TRANSFER ' + SPECIFIC_SCHEMA + '.' + ROUTINE_NAME from INFORMATION_SCHEMA.ROUTINES  
where ROUTINE_TYPE='procedure'

 

Leave a Comment

Change HTMLEncode In An Autogenerated Gridview

The only way I found to change the HtmlEncode property on a bound column when auto-generating the grid-view.

protected void grFeedHistoryView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            BoundField field = (BoundField)((DataControlFieldCell)e.Row.Cells[2]).ContainingField;
            field.HtmlEncode = false;
        }

 

Leave a Comment

Simple Linq to SQL Insert and Update

private void InsertAndUpdate()
{
  NorthwindDataContext db = new NorthwindDataContext();

  //Insert a record

  Customer newCus = new Customer();
  newCus.CustomerID = "YYYZZ";
  newCus.CompanyName = "Company_Z";

  db.Customers.InsertOnSubmit(newCus);
  db.SubmitChanges();      

  //Update a record
  Customer record = (from p in db.Customers
         where p.CustomerID == "12345" 
         select p).SingleOrDefault();

  Console.WriteLine(default(Customer));
  if (record != default(Customer))
  {
    record.CompanyName = "Company_A";
  }

  db.SubmitChanges();
}

 

Leave a Comment

WordPress – Time To First Byte Slow – IIS

I had a problem with a WordPress website that I recently moved to a new server running PHP 5.4 and IIS. I found that the fix to my problem was in the wp-config.php file. I had to change the hostname of the MySQL db from localhost to 127.0.0.1. Maybe this is an issue with IPv6 being enabled on the server. I’ll try and look at that later.

From…

/** MySQL hostname */
define('DB_HOST', 'localhost');

To…

/** MySQL hostname */
define('DB_HOST', '127.0.0.1');

 

Leave a Comment

CentOS 6 – Change System Language

I recently bought a server whose language was set to something other than English. Here is the way to change the language.

Run the following commands

 nano /etc/sysconfig/i18n

and replace with the following

LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"

Log out and log back in. You should see the change.

Leave a Comment

C# List to DataTable

Don’t recall where I found this but converts List to DataTable.

public static System.Data.DataTable ToDataTable<T>(this IList<T> data)
        {
            System.ComponentModel.PropertyDescriptorCollection props = System.ComponentModel.TypeDescriptor.GetProperties(typeof(T));
            System.Data.DataTable table = new System.Data.DataTable();
            for (int i = 0; i < props.Count; i++)
            {
                System.ComponentModel.PropertyDescriptor prop = props[i];
                table.Columns.Add(prop.Name);
                //table.Columns.Add(prop.Name, prop.PropertyType);
            }
            object[] values = new object[props.Count];
            foreach (T item in data)
            {
                for (int i = 0; i < values.Length; i++)
                {
                    values[i] = props[i].GetValue(item);
                }
                table.Rows.Add(values);
            }
            return table;
        }

 

Leave a Comment

Using C# to check if string contains a string in string array

Pieced this together from stackoverflow… http://stackoverflow.com/questions/2912476/using-c-sharp-to-check-if-string-contains-a-string-in-string-array/2912541#2912541

string stringToCheck = "text1";
string[] stringArray = { "text1", "testtest", "test1test2", "test2text1" };

This checks if stringToCheck contains any one of substrings from stringArray.

if(stringArray.Any(stringToCheck.Contains))

If you want to ensure that it contains all the substrings, change Any to All:

if(stringArray.All(s => stringToCheck.Contains(s)))

 

Leave a Comment

Regex for U.S. and Canadian Zip Codes

Below is the regex code for U.S. and Canadian zip codes. I’m don’t remember where I found these but hopefully someone finds them useful.

string _usZipRegEx = @"^\d{5}(?:[-\s]\d{4})?$";
string _caZipRegEx = @"^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ])\ {0,1}(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$";
Leave a Comment

Hostigation – Good for backups!

Just wanted to share information on this hosting provider. I’ve been using Hostigation for a while now for backups, cheap and for the most part pretty stable. Lately they’ve been problems with a spammer, which is not allowed, but they’ve fixed the problem.

The plans just give you 64MB of RAM but that’s because you don’t need RAM if your just doing backups and these plans are just for backups.

You can get up to 300GB for a quarterly payment of $40. That’s less than $15 bucks a month.

http://hostigation.com

Leave a Comment