How do I transform a List into a DataSet?

You can do it through reflection and generics, inspecting the properties of the underlying type. Consider this extension method that I use: public static DataTable ToDataTable<T>(this IEnumerable<T> collection) { DataTable dt = new DataTable(“DataTable”); Type t = typeof(T); PropertyInfo[] pia = t.GetProperties(); //Inspect the properties and create the columns in the DataTable foreach (PropertyInfo pi … Read more

How to add config transformations for a custom config file in Visual Studio?

Visual Studio transforms only web.config files by default. If you need custom config file with transformation for DEV, UAT, PROD, etc environments, then try to Use custom extensions for Visual Studio like SlowCheetah – XML Transforms for Config transformation preview functionality. Add for the project from Nuget SlowCheetah to provide build in transformation. A little … Read more

Perspective transform of SVG paths (four corner distort)

This is my drag distort proposal (share you knowledge, Q&A-style). Live example is in http://jsfiddle.net/xjHUk/278/ and the main code is this: (only output window: http://jsfiddle.net/xjHUk/279/embedded/result/) function transferPoint (xI, yI, source, destination) { var ADDING = 0.001; // to avoid dividing by zero var xA = source[0].x; var yA = source[0].y; var xC = source[2].x; var … Read more

How does transforming points with a transformMatrix work in fabricJS?

Not really a geometric problem. The geometric part was solve by you. If you would look at internal polygon class from fabricjs you would notice that polygon as a calcDimension function where every point gets an offset: http://fabricjs.com/docs/fabric.Polygon.html To calculate canvas position you have to add that offset back before transforming. var canvas = new … Read more

Android image view matrix scale + translate

There’s a convenient method called Matrix.setRectToRect(RectF, RectF, ScaleToFit) to help you here. Matrix m = imageView.getImageMatrix(); RectF drawableRect = new RectF(0, 0, imageWidth, imageHeight); RectF viewRect = new RectF(0, 0, imageView.getWidth(), imageView.getHeight()); m.setRectToRect(drawableRect, viewRect, Matrix.ScaleToFit.CENTER); imageView.setImageMatrix(m); That should set the matrix m to have combo of scaling and translate values that is needed to show … Read more

Understanding `scale` in R

log simply takes the logarithm (base e, by default) of each element of the vector. scale, with default settings, will calculate the mean and standard deviation of the entire vector, then “scale” each element by those values by subtracting the mean and dividing by the sd. (If you use scale(x, scale=FALSE), it will only subtract … Read more

How to do this image transformation?

I felt like coding it up in C++ for you rather than using the command line like for my other answer, so I have put it as a different answer. On top, it also actually implements the Douglas-Peucker algorithm and, for fun and good measure, animates it. //////////////////////////////////////////////////////////////////////////////// // main.cpp // Mark Setchell // To … Read more