Tuesday, August 21, 2012

Remove outline of current line in VS2012

Visual Studio 2012 has a feature that will outline the current line in it's text editor. I hate this and wanted it to die. You can remove it here: Options -> Text Editor -> uncheck "Highlight Current line"

Monday, April 23, 2012

If you want to get a list of all the tables in a DB that have a particular column name:
SELECT table_name FROM information_schema.columns WHERE column_name = 'satellite_group_id';

Monday, April 2, 2012

Transform non lat/long coordinate to lat/long using proj.net

This took me some time. I eventually found something online close and created this method. The inputs are authority and the native point to be transformed. The authority is the string that you would use in a program like cs2cs.exe to make a transform.

private static double[] TransformCoordToLatLong(string authority, double[] fromPoint)
    {
        // The authority type needs to be proj4, and we will be turning the coordinate into lat/long (WGS84)
        string authType = "proj4";
        string WGS84WKT = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\"," +
            "6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326" +
            "\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\"," +
            "0.01745329251994328, AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]";

        SpatialReferenceTransformation srt = new SpatialReferenceTransformation();
        SR.AuthorityTransformationResult[] transformations;
        transformations = srt.TransformToKnownAuthorities(authType, authority, null);
        transformations = srt.AddLocalTransformation(transformations);
        
        ICoordinateSystem pcs_New = CoordinateSystemWktReader.Parse(transformations[0].AuthorityText) as ICoordinateSystem;
        ICoordinateSystem pcs_wgs84 = CoordinateSystemWktReader.Parse(WGS84WKT) as ICoordinateSystem;

        CoordinateSystemFactory csFactory = new ProjNet.CoordinateSystems.CoordinateSystemFactory();
        CoordinateTransformationFactory ctFactory = new CoordinateTransformationFactory();
        ICoordinateSystem sourceCS = csFactory.CreateFromWkt(transformations[0].AuthorityText);
        ICoordinateSystem targetCS = csFactory.CreateFromWkt(WGS84WKT);
        ICoordinateTransformation transformer = ctFactory.CreateFromCoordinateSystems(pcs_New, pcs_wgs84);

        double[] toPoint = transformer.MathTransform.Transform(fromPoint);
        return toPoint;
    }

Proj.net

Thursday, March 15, 2012

Superfish menu opens on click rather than on hover

I couldn't find anything online that worked for changing the Superfish menu to open on click rather than on hover. Here it is:

Changing this line (line 21, over function):

$$.showSuperfishUl().siblings().hideSuperfishUl();
To this:

$$.click(function(){$(this).showSuperfishUl().siblings().hideSuperfishUl();});

Full superfish code for clicking the menu:

Tuesday, February 14, 2012

Create a SQL insert statement(s) from a SQL select statement

I'm not sure why, but porting a SQL Server 2008 DB to PostGres has been a pain in the ass. I would think MS would have a simple SQL export command that would generate a script that could be used by another DB to create a new DB with the same data, but no.

A coworker showed me this trick to create INSERT statements from SELECT statements to help me out, though

select 'insert into mugg.subscription(subscription_id, name, system) values (''' || subscription_id || ',' || name || ',' || system ||''')' from mugg.subscription

After running this, Here is one of the rows:
"insert into mugg.subscription(subscription_id, name, system) values ('6CBF39EE-0E53-4CED-841E-02EC0A8E8C00,i-cubed testing subscription,MUGG')"

The pipes (||) are SQL's way of concatenating strings and you use a single quote to escape a single quote.