size

How to find the size of a class in C#

China☆狼群 提交于 2019-11-29 09:17:48
public class A { int x; float y; } How to find the size of the class in C#. Is there any operator like Sizeof(), which used to be in C++ Short answer: You dont. Long answer: You can only do that if you type has a fixed layout and has no managed members. Structs are fixed by default. Classes can attributed to have a fixed layout. (I am not showing how, as you really do not need it. It is only important when doing interop.) Ritesh The following would give you the size of the C# class: Marshal.SizeOf(typeof(Myclass)); using System.Runtime.InteropServices; [StructLayout(LayoutKind.Sequential)]

Get the size of an Android file resource?

孤人 提交于 2019-11-29 09:12:56
I have a video file in the raw folder in my resources. I want to find the size of the file. I have this piece of code: Uri filePath = Uri.parse("android.resource://com.android.FileTransfer/" + R.raw.video); File videoFile = new File(filePath.getPath()); Log.v("LOG", "FILE SIZE "+videoFile.length()); But it always gives me that the size is 0. What am I doing wrong? You can't use File for resources. Use Resources or AssetManager to get an InputStream to the resource, then call the available() method on it. Like this: InputStream is = context.getResources().openRawResource(R.raw.nameOfFile); int

Size of char pointer array from function

一个人想着一个人 提交于 2019-11-29 09:01:59
Using this code: #include <stdio.h> void printSize(char *messages[]) { printf("%d", sizeof(messages) / sizeof(char *)); } int main(void) { printf("Size when through passing direct to function: "); printSize((char *[]){"Zero", "One", "Two", "Three"}); printf("\n"); printf("Size when calculating in main: %d\n", sizeof((char *[]){"Zero", "One", "Two", "Three"}) / sizeof(char *)); return 1; } I get output: Size when through passing direct to function: 1 Size when calculating in main: 4 I understand there is no way to get the correct amount of elements in a char* array, but I am curious as to why

Problem reading files greater than 1GB with XMLReader

落花浮王杯 提交于 2019-11-29 07:47:03
Is there a maximum file size the XMLReader can handle? I'm trying to process an XML feed about 3GB large. There are certainly no PHP errors as the script runs fine and successfully loads to the database after it's been run. The script also runs fine with smaller test feeds - 1GB and below. However, when processing larger feeds the script stops reading the XML File after about 1GB and continues running the rest of the script. Has anybody experienced a similar problem? and if so how did you work around it? Thanks in advance. gazda I had same kind of problem recently and I thought to share my

how can i put a JButton on an image?

拟墨画扇 提交于 2019-11-29 07:43:32
I am trying to fix a JFrame where there will be a background image and on the image JButtons which will do some commands. I try to do it without layout because i want to put small buttons in some specific locations on the JFrame but every time i do it, the background image comes to the front or the JFrame has size equal to the JFrame size. With the following code, the JButton has the same size to JFrame. I have tried to change the size and location of the JButton but nothing. Can you help me please? here is the code public final class Test extends JComponent { private Image background; private

How to set Send Buffer Size for sockets in python

拟墨画扇 提交于 2019-11-29 07:37:10
I have a client socket at my server end and what I want is to set Send buffer size for the socket just like I set Receive buffer size .Any idea on how I can set it? Because while sending huge data, the socket disconnects. James Mills Use socket.setsockopt() and SO_SNDBUF : socket.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, <value>) Where <value> is the buffer size you want to set as a Python int . Example: socket.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 8192) # Buffer size 8192 See: setsockopt arun.rajput You can use socket.setsockopt() : s = socket.socket(socket.AF_INET, socket

Android: Measure/detect covered area by a finger touch on screen (NOT only touch coordinates)

£可爱£侵袭症+ 提交于 2019-11-29 06:15:00
I would like to get access to the area covered by a finger for each touch event on an Android. Every touch event will result in a coordinate pair X and Y independent of how big the finger and consequently the touch area is that triggered the event. I was wondering if there is a way to get the area data which triggered the touch event e.g. size or coordinates NOT Any help is much appreciated. Thanks in advance for you answer or redirects, Christian The method motionEvent.getSize() should give you what you want (but the level of accuracy may vary depending on the device's screen). You need to

Customize list item bullets using CSS

霸气de小男生 提交于 2019-11-29 05:26:06
Is it possible to change the size of an <li> element's bullet ? Take a look at the code below: li { list-style: square; // I want to change the size of this squared bullet. } I can't seem to find any way to achieve that. You mean altering the size of the bullet, I assume? I believe this is tied to the font-size of the li tag. Thus, you can blow up the font-size for the LI, then reduce it for an element contained inside. Kind of sucks to add the extra markup - but something like: li {font-size:omgHuge;} li span {font-size:mehNormal;} Alternately, you can specify an image file for your list

size of NumPy array

有些话、适合烂在心里 提交于 2019-11-29 04:58:04
问题 Is there an equivalent to the MATLAB size() command in Numpy? In MATLAB, >>> a = zeros(2,5) 0 0 0 0 0 0 0 0 0 0 >>> size(a) 2 5 In Python, >>> a = zeros((2,5)) >>> array([[ 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0.]]) >>> ????? 回答1: This is called the "shape" in NumPy, and can be requested via the .shape attribute: >>> a = zeros((2, 5)) >>> a.shape (2, 5) If you prefer a function, you could also use numpy.shape(a) . 回答2: Yes numpy has a size function, and shape and size are not quite the same

【R】调整ggplot图例大小

风格不统一 提交于 2019-11-29 04:45:35
图例太多时,会挤压正图,显得正图展示区域很小,这时有必要缩小图例。 ################# # 减小ggplot图例 ################# library(ggplot2) p <- ggplot(mtcars, aes(drat, mpg, color = factor(gear), shape = factor(vs))) + geom_point(size = 2) + theme_classic() + theme(legend.position = c(0.1, 0.7)) p # Overwrite given size (2) to 0.5 (super small) p <- p + guides(shape = guide_legend(override.aes = list(size = 0.5))) p p <- p + guides(color = guide_legend(override.aes = list(size = 0.5))) p p <- p + theme(legend.title = element_text(size = 3), legend.text = element_text(size = 3)) p addSmallLegend <- function(myPlot, pointSize = 0.5,