Wednesday, September 3, 2014

MS SQL server query to Find Columns or Fields in Database



SELECT t.name AS table_name, 
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%Your_Field_Name%'
ORDER BY schema_name, table_name

Sunday, February 9, 2014

Inject onload javascript function for aspx pages with master page

1. Add the using reference to the top of your pages .cs file

     using System.Web.UI.HtmlControls;

2. In your Page_Load function of the .cs file add

      ((HtmlGenericControl) this.Page.Master.FindControl("PageBody")).Attributes.Add("onload", "load()");


3. Make sure your master page BODY has the  the matching id from above. in this case: ID="PageBody" runat="server"

4. In your aspx file, add you load function.  something like

<script type="text/javascript">
        function load() {
            alert('page loaded');
        }
 </script>

Friday, October 25, 2013

Free SIP account and Phone number, then Connect Google Voice Number to your SIP Soft Phone - Free

The way to connect Google voice to your SIP soft phone is fairly simple

1. Get a SIP account from sip2sip.info

Its free and just take a minute to create an account

2. Get an IPKall phone number from ipkall.com

create an account and use your sip3sip.info and they will give you a USA phone number.

3. Get a google voice number and forward it to your IPKall phone number

4. setup your softphone using your sip2sip.info account

This way you have a local google voice number that rings on your softphone!

enjoy!


Tuesday, September 24, 2013

document.getElementById and asp.net with Master Pages

Using JavaScript to locate controls in ASP.net pages that are linked to master pages can be tricky.  This is because the ASP.net reassigned control IDs dynamically.

A simple solution is to use asp.net inline Tags.

For Example:

Instead for saying:

document.getElementById("Label1")

say

document.getElementById("<%=Label1.ClientID%>")


Thats it... I hope this helps some of you.

Sunday, February 13, 2011

XNA Bezier Curve Editor Demo

Here is a quick look at the Bezier Curve editor I made in XNA that uses the function from my prior blog . Note there are circular Paths each withe 3 segments. Each segment is a 4 point Bezier calculation.


The basic tricks in getting this to be a smooth curve across the whole path is to:

  1. p3 of the each segment is in common to p0 of next each segment.
  2. To make the circular, p3 of last segment must be same as p0 of 1st segment.
  3. p2 and p3 of each segment must be on a strait line with p0 and p1 or the next segment. So this means
    • If a path point was moved by user, you must also move left and right control handler points by same deltas
    • If left handler moved,  must also move corresponding path point so it intersects line to other handler at mid point
    • If right handler moved, must also move corresponding path point so it intersects line to other handler at mid point


Simple function for a Bezier Curve in C#

The Bezier Curve formula below can be used to define  smooth curves between points in space.

P(t) = (1-t)^3P0 + 3(1-t)^2tP1 + 3(1-t)t^2P2 + t^3P3

The function below is a C# implementation of the formula return the X and Y coordinates for Time (t) given the 4 points that define the Bezier Curve.  You can extend this to 3D very easily.  Include this function in your c# projects to create smooth curves and multi-segment paths.  In a future post I will show how to implement multi-segment paths and circular paths using Bezier Curves.   I used this function and technique in my XNA game projects that required smooth paths for my objects.  I was also able to create a multi-segment curve editor which I will try to cover later on.

C# Code Sample:

        private Vector2 GetPoint(float t, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3)
        {
            float cx = 3 * (p1.X - p0.X);
            float cy = 3 * (p1.Y - p0.Y);

            float bx = 3 * (p2.X - p1.X) - cx;
            float by = 3 * (p2.Y - p1.Y) - cy;

            float ax = p3.X - p0.X - cx - bx;
            float ay = p3.Y - p0.Y - cy - by;

            float Cube = t * t * t;
            float Square = t * t;

            float resX = (ax * Cube) + (bx * Square) + (cx * t) + p0.X;
            float resY = (ay * Cube) + (by * Square) + (cy * t) + p0.Y;

            return new Vector2(resX, resY);
        }

To use the function, simply pass in the 4 point and a time (between 0 and 1).   At  t=0 you will be at p0, and at t=1 you will be at p3.      To draw the curve, try calling this function from a for loop that looks something like this:

// preset your p0,p1,p2,p3

Vector2 PlotPoint;
for (float t = 0;  t <= 1.0f; t += 0.01f)
{
  PlotPoint = GetPoint(t, p0, p1, p2, p3);

  // now call some function to plot the PlotPoint
  YourDrawFunction(PlotPoint);
}