size

Unix find average file size

Deadly 提交于 2019-11-27 01:34:05
问题 I have a directory with a ton of files I want to find the average file size of these files so something like ls somethinghere whats the average file size of everything meets that? 回答1: I found something here: http://vivekjain10.blogspot.com/2008/02/average-file-size-within-directory.html To calculate the average file size within a directory on a Linux system, following command can be used: ls -l | gawk '{sum += $5; n++;} END {print sum/n;}' 回答2: A short, general and recursion-friendly

How many characters in varchar(max)

戏子无情 提交于 2019-11-27 01:27:12
问题 How many characters can a SQL Server 2008 database field contain when the data type is VARCHAR(MAX)? 回答1: From http://msdn.microsoft.com/en-us/library/ms176089.aspx varchar [ ( n | max ) ] Variable-length, non-Unicode character data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of data entered + 2 bytes. The data entered can be 0 characters in length. The ISO synonyms for varchar are char varying or

change array size

本小妞迷上赌 提交于 2019-11-27 01:23:18
Is it possible to change an array size after declaration? If not, is there any alternative to arrays? I do not want to create an array with a size of 1000, but I do not know the size of the array when I'm creating it. Corey Sunwold No, try using a strongly typed List instead. For example: Instead of using int[] myArray = new int[2]; myArray[0] = 1; myArray[1] = 2; You could do this: List<int> myList = new List<int>(); myList.Add(1); myList.Add(2); Lists use arrays to store the data so you get the speed benefit of arrays with the convenience of a LinkedList by being able to add and remove items

Getting terminal size in c for windows?

泪湿孤枕 提交于 2019-11-27 01:12:34
How to check ymax and xmax in a console window, under Windows, using plain c? There is this piece of code for linux: #include <stdio.h> #include <sys/ioctl.h> int main (void) { struct winsize max; ioctl(0, TIOCGWINSZ , &max); printf ("lines %d\n", max.ws_row); printf ("columns %d\n", max.ws_col); } Now I wonder how can I do the same for windows. I tried winioctl.h but it does not define struct winsize nor any other with a similar name. Any tips? Thanks. PS. In linux you also can find the console size using getenv("LINES"); . Is there a similar variable under windows? PPS. Also, there is always

How can I get the size of a folder on SD card in Android?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 00:52:36
Is it possible to easily get the size of a folder on the SD card? I use a folder for caching of images, and would like to present the total size of all cached images. Is there a way to this other than iterating over each file? They all reside inside the same folder? Moss Just go through all files and sum the length of them: /** * Return the size of a directory in bytes */ private static long dirSize(File dir) { if (dir.exists()) { long result = 0; File[] fileList = dir.listFiles(); for(int i = 0; i < fileList.length; i++) { // Recursive call if it's a directory if(fileList[i].isDirectory()) {

C++ vector的越界错误

◇◆丶佛笑我妖孽 提交于 2019-11-27 00:45:33
做题的时候,c++的vector下标引用成功地坑到了自己。 参考: https://blog.csdn.net/hexiaomin_1984/article/details/26168265 在写 for 循环时候,当条件为 i < = v.size()-1的时候, 很容易出现数组越界。 int j = a.size()-2; //cout << "a.size()-4:" << a.size()-4 << endl; for(; j >= a.size()-3; j--) cout << j << ","; cout << a[j] << ","; } 比如我在写上述代码时候,出现段错误,原因是数组下标越界,打印出来的a.size()-4为 18446744073709551615。说明始终无法满足循环终止条件。 使用unsigned int 的时候,-1变为4294967295 会导致数组越界,出现崩溃。 导致错误的发生。 来源: https://www.cnblogs.com/Shinered/p/11336991.html

Mongo order by length of array

徘徊边缘 提交于 2019-11-27 00:41:47
Lets say I have mongo documents like this: Question 1 { answers:[ {content: 'answer1'}, {content: '2nd answer'} ] } Question 2 { answers:[ {content: 'answer1'}, {content: '2nd answer'} {content: 'The third answer'} ] } Is there a way to order the collection by size of answers? After a little research I saw suggestions of adding another field, that would contain number of answers and use it as a reference but may be there is native way to do it? I thought you might be able to use $size , but that's only to find arrays of a certain size, not ordering. From the mongo documentation: http://www

Size of empty UDP and TCP packet?

落花浮王杯 提交于 2019-11-27 00:38:53
What is the size of an empty UDP datagram? And that of an empty TCP packet? I can only find info about the MTU, but I want to know what is the "base" size of these, in order to estimate bandwidth consumption for protocols on top of them. Himanshu TCP: Size of Ethernet frame - 24 Bytes Size of IPv4 Header (without any options) - 20 bytes Size of TCP Header (without any options) - 20 Bytes Total size of an Ethernet Frame carrying an IP Packet with an empty TCP Segment - 24 + 20 + 20 = 64 bytes UDP: Size of Ethernet frame - 24 Bytes Size of IPv4 Header (without any options) - 20 bytes Size of UDP

Reducing PDF file size using Ghostscript on Linux didn't work

最后都变了- 提交于 2019-11-27 00:24:16
问题 I have about 50-60 pdf files (images) that are 1.5MB large each. Now I don't want to have such large pdf files in my thesis as that would make downloading, reading and printing a pain in the rear. So I tried using ghostscript to do the following: gs \ -dNOPAUSE -dBATCH \ -sDEVICE=pdfwrite \ -dCompatibilityLevel=1.4 \ -dPDFSETTINGS="/screen" \ -sOutputFile=output.pdf \ L_2lambda_max_1wl_E0_1_zg.pdf However, now my 1.4MB pdf is 1.5MB large. What did I do wrong? Is there some way I can check the

UICollectionView cell subviews do not resize

戏子无情 提交于 2019-11-27 00:20:37
In a CollectionView , some cells should have an additional subview or layer. The CollectionView can be told to resize it's cells, thus all content needs to resize appropriately. Currently, the cell is initialized from a nib containing a cell with imageview; the cell nib is linked to a custom UICollectionViewCell subclass, that only does the init. Autoresize subviews is checked. The CollectionView is told to resize the cell by a value derived and returned in sizeForItemAtIndexPath: . I have subclassed a FlowLayout but it only specifies ScrollDirection and Insets . All of that is working fine.