What is the difference between getWidth/Height() and getMeasuredWidth/Height() in Android SDK?

As the name suggests the measuredWidth/height is used during measuring and layoutting phase. Let me give an example, A widget is asked to measure itself, The widget says that it wants to be 200px by 200px. This is measuredWidth/height. During the layout phase, i.e. in onLayout method. The method can use the measuredWidth/height of its … Read more

How to get the size of the current screen in WPF?

I created a little wrapper around the Screen from System.Windows.Forms, currently everything works… Not sure about the “device independent pixels”, though. public class WpfScreen { public static IEnumerable<WpfScreen> AllScreens() { foreach (Screen screen in System.Windows.Forms.Screen.AllScreens) { yield return new WpfScreen(screen); } } public static WpfScreen GetScreenFrom(Window window) { WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window); Screen screen … Read more

Array Size (Length) in C#

If it’s a one-dimensional array a, a.Length will give the number of elements of a. If b is a rectangular multi-dimensional array (for example, int[,] b = new int[3, 5];) b.Rank will give the number of dimensions (2) and b.GetLength(dimensionIndex) will get the length of any given dimension (0-based indexing for the dimensions – so … Read more

Array[n] vs Array[10] – Initializing array with variable vs numeric literal

In C++, variable length arrays are not legal. G++ allows this as an “extension” (because C allows it), so in G++ (without being -pedantic about following the C++ standard), you can do: int n = 10; double a[n]; // Legal in g++ (with extensions), illegal in proper C++ If you want a “variable length array” … Read more

What does the WPF star do (Width=”100*”)

In a WPF Grid, Width=”*” or Height=”*” means proportional sizing. For example: to give 30% to column 1 and 70% to column 2 – <ColumnDefinition Width=”3*” /> <ColumnDefinition Width=”7*” /> And likewise for rows – <RowDefinition Height=”3*” /> <RowDefinition Height=”7*” /> The numbers do not have to be integers. If the Width for RowDefinition (Height … Read more

PHPExcel auto size column width

If a column is set to AutoSize, PHPExcel attempts to calculate the column width based on the calculated value of the column (so on the result of any formulae), and any additional characters added by format masks such as thousand separators. By default, this is an estimated width: a more accurate calculation method is available, … Read more

How many bytes in a JavaScript string?

You can use the Blob to get the string size in bytes. Examples: console.info( new Blob([‘😂’]).size, // 4 new Blob([‘👍’]).size, // 4 new Blob([‘😂👍’]).size, // 8 new Blob([‘👍😂’]).size, // 8 new Blob([‘I\’m a string’]).size, // 12 // from Premasagar correction of Lauri’s answer for // strings containing lone characters in the surrogate pair range: // … Read more