问:
Optionally descend a nested struct
Assuming a class template Optional exists:

```<code>template <class T>
class Optional
{
public:
  ...
  bool isPresent(void) const {...}
  const T& value(void) {...} // throws if !isPresent()
  ...
};
</code>```

Also, some structs with nested Optional fields are defined:

```<code>struct A;
struct B;
struct C;
struct D;

struct A
{
   Optional<B> b1_;
   int i_;
};

struct B
{
   Optional<C> c1_;
   int j_;
};

struct C
{
   Optional<D> d1_;
   int k_;
};

struct D
{
   int l_;
   int m_;
   int n_;
};
</code>```

I'm looking for a programming idiom that provides the following behavior without the ugliness.

```<code>int get_l_OrDefault(const A& a, int def)
{
  if (!a.b_.isPresent()) return def;
  else if (!a.b_.value().c_.isPresent()) return def;
  else if (!a.b_.value().c_.value().d_.isPresent()) return def;
  else return a.b_.value().c_.value().d_.value().l_;
}
</code>```

Given an A a;, can I define something that takes some representation of the path to the non-optional leaf field and a default value?

```<code>getValueOrDefault(a.b.j_, 0);
getValueOrDefault(a.b.c.k_, 0);
... etc
</code>```

答:
you need something recursive to do it. As an example, if you can have the same base class for your A, B, C, structs, you can have something like this:

```<code>struct Presentable <T> {
  Optional<T> opt;
  virtual int getIntValue(int def) {
    if (opt.isPresent())
     return opt.getValue().getIntValue(def);
    else
     return def;
    }
};

struct A : public Presentable<B>) {
  int i_;
};
...
struct D : Presentable <F> {
   int getIntValue(int) {return l_;}
}
</code>```

Now you can get your value from the end of the chain or 'def'.

This is just one of possible variants, but in any case you would either need some base class, or you can use a pointer to create parent-child relation between structs (Optional class can help in doing so), or you can probably use dynamic cast for doing it.

Title: Optionally descend a nested struct

Body:
Assuming a class template Optional exists:

template <class T>
class Optional
{
public:
  ...
  bool isPresent(void) const {...}
  const T& value(void) {...} // throws if !isPresent()
  ...
};

Also, some structs with nested Optional fields are defined:

struct A;
struct B;
struct C;
struct D;

struct A
{
   Optional b1_;
   int i_;
};

struct B
{
   Optional<C> c1_;
   int j_;
};

struct C
{
   Optional<D> d1_;
   int k_;
};

struct D
{
   int l_;
   int m_;
   int n_;
};

I'm looking for a programming idiom that provides the following behavior without the ugliness.

int get_l_OrDefault(const A& a, int def)
{
  if (!a.b_.isPresent()) return def;
  else if (!a.b_.value().c_.isPresent()) return def;
  else if (!a.b_.value().c_.value().d_.isPresent()) return def;
  else return a.b_.value().c_.value().d_.value().l_;
}

Given an A a;, can I define something that takes some representation of the path to the non-optional leaf field and a default value?

getValueOrDefault(a.b.j_, 0);
getValueOrDefault(a.b.c.k_, 0);
... etc

Body:
you need something recursive to do it. As an example, if you can have the same base class for your A, B, C, structs, you can have something like this:

struct Presentable <T> {
  Optional<T> opt;
  virtual int getIntValue(int def) {
    if (opt.isPresent())
     return opt.getValue().getIntValue(def);
    else
     return def;
    }
};

struct A : public Presentable<B>) {
  int i_;
};
...
struct D : Presentable <F> {
   int getIntValue(int) {return l_;}
}

Now you can get your value from the end of the chain or 'def'.

This is just one of possible variants, but in any case you would either need some base class, or you can use a pointer to create parent-child relation between structs (Optional class can help in doing so), or you can probably use dynamic cast for doing it.


来源: stackexchange

问:
Restrict users to their own entities
How can we restrict users to their own entities within the Framework? I know that we can check the session Id or include the currentSession in the LINQ query but I kind of wonder if the framework provides a better and efficient way to overcome this?</p>

答:
If multi-tenant support

Salesforce.com uses the concept of OrganizationId. The downside is that a given email address can't be used in more than 1 organization to log on.

So whenever a user would add a Project or whatever, the record would include their OrganizaionId. Then other users would be limited to only projects that had their OrganizationId.

If just user created records

Include a column in your primary tables called "Owner" and populate that with their username.

ContentLicense: CC BY-SA 3.0

Title: Restrict users to their own entities


问:
No Download Prompt Issue on Browser
I have a simple web page where I make a database query through html button triggering ajax within javascript which is calling a php script to make the query into database. Then, fill all the result returned from the query into a csv file and download it.

The problem is when I check the wireshark capture, I can see the packet containing all the information I need within HTTP 200 OK packet. However, there is no download prompt for me to download the file.

Here are the headers in the packet:

```<code>HTTP/1.1 200 OK
Date: Thu, 06 Jul 2017 00:52:35 GMT
Server: Apache/2.4.6 (Red Hat Enterprise Linux) PHP/5.4.16
X-Powered-By: PHP/5.4.16
Content-Description: File Transfer
Content-Disposition: attachment; filename=data.csv
Content-Length: 2968
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: application/csv; charset=utf-8

Media type: application/csv; charset=utf-8 (2968 bytes)
</code>```

Let me know if any further information is needed.

EDIT #1 - added AJAX Code:

```<code>        $.ajax({
            url:"export_csv.php", //the page containing php script
            data: { userID : "L2Export", 'avc' : avc, 'connType' : connType },
            type: "POST", //request type
            success:function(result){
                console.log("ajax success");
            }
</code>```

EDIT #2 - added PHP code:

```<code>$queryStatement = "SELECT * FROM ".$db_record." ".$where;
header("Content-Description: File Transfer");
header('Content-Type: application/csv; charset=utf-8');
header("Content-Disposition: attachment; filename=data.csv");
$output = fopen("php://output", "w");
fputcsv($output, array(<HEADERS ARE HERE>));
$result = mysqli_query($conn, $queryStatement);
//error_log("Here is the statement $queryStatement", 0);
while($row = mysqli_fetch_assoc($result))  {
    fputcsv($output, $row);
}
fclose($output);
mysqli_close($conn);
</code>```

答:
Creating an AJAX request does indeed fetch a resource from the server, but that response will not trigger a browser download prompt. To prompt a download on a POST request, you must submit a <form> and set the Content-Disposition header properly (which you have correctly done in PHP):

HTML:

```<code><form method="POST" action="export_csv.php">
  <input type="hidden" name="userID" value="L2Export"/>
  <!-- other POST data... -->
  <button type="submit">Download CSV File</button>
</form>
</code>```

You can even use JavaScript to dynamically add other hidden <input> fields if necessary in an event listener:

JavaScript:

```<code>var form = document.querySelector('form[action="export_csv.php"]');

form.addEventListener('submit', function (event) {
  var avcEl = form.querySelector('[name="avc"]') || document.createElement('input');
  var connTypeEl = form.querySelector('[name="connType"]') || document.createElement('input');

  avcEl.type = 'hidden';
  avcEl.name = 'avc';
  avcEl.value = avc; // get this how you did for the $.ajax()

  connTypeEl.type = 'hidden';
  connTypeEl.name = 'connType';
  connTypeEl.value = connType; // get this how you did for the $.ajax()

  // don't worry, these won't error if they're already children of <form>
  form.appendChild(avcEl);
  form.appendChild(connTypeEl);
});
</code>```

Title: No Download Prompt Issue on Browser

Body:
I have a simple web page where I make a database query through html button triggering ajax within javascript which is calling a php script to make the query into database. Then, fill all the result returned from the query into a csv file and download it.

The problem is when I check the wireshark capture, I can see the packet containing all the information I need within HTTP 200 OK packet. However, there is no download prompt for me to download the file.

Here are the headers in the packet:

HTTP/1.1 200 OK
Date: Thu, 06 Jul 2017 00:52:35 GMT
Server: Apache/2.4.6 (Red Hat Enterprise Linux) PHP/5.4.16
X-Powered-By: PHP/5.4.16
Content-Description: File Transfer
Content-Disposition: attachment; filename=data.csv
Content-Length: 2968
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: application/csv; charset=utf-8

Media type: application/csv; charset=utf-8 (2968 bytes)

Let me know if any further information is needed.

EDIT #1 - added AJAX Code:

        $.ajax({
            url:"export_csv.php", //the page containing php script
            data: { userID : "L2Export", 'avc' : avc, 'connType' : connType },
            type: "POST", //request type
            success:function(result){
                console.log("ajax success");
            }

EDIT #2 - added PHP code:

$queryStatement = "SELECT * FROM ".$db_record." ".$where;
header("Content-Description: File Transfer");
header('Content-Type: application/csv; charset=utf-8');
header("Content-Disposition: attachment; filename=data.csv");
$output = fopen("php://output", "w");
fputcsv($output, array(<HEADERS ARE HERE>));
$result = mysqli_query($conn, $queryStatement);
//error_log("Here is the statement $queryStatement", 0);
while($row = mysqli_fetch_assoc($result))  {
    fputcsv($output, $row);
}
fclose($output);
mysqli_close($conn);

Body:
Creating an AJAX request does indeed fetch a resource from the server, but that response will not trigger a browser download prompt. To prompt a download on a POST request, you must submit a <form> and set the Content-Disposition header properly (which you have correctly done in PHP):

HTML:

<form method="POST" action="export_csv.php">
  <input type="hidden" name="userID" value="L2Export"/>
  <!-- other POST data... -->
  <button type="submit">Download CSV File</button>
</form>

You can even use JavaScript to dynamically add other hidden <input> fields if necessary in an event listener:

JavaScript:

var form = document.querySelector('form[action="export_csv.php"]');

form.addEventListener('submit', function (event) {
  var avcEl = form.querySelector('[name="avc"]') || document.createElement('input');
  var connTypeEl = form.querySelector('[name="connType"]') || document.createElement('input');

  avcEl.type = 'hidden';
  avcEl.name = 'avc';
  avcEl.value = avc; // get this how you did for the $.ajax()

  connTypeEl.type = 'hidden';
  connTypeEl.name = 'connType';
  connTypeEl.value = connType; // get this how you did for the $.ajax()

  // don't worry, these won't error if they're already children of <form>
  form.appendChild(avcEl);
  form.appendChild(connTypeEl);
});


问:
c# sorting list by substring
i have a list of strings:

```<code>\\\\Tecan1\\tecan #1 output\\15939-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15942-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15945-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15948-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15951-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15954-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15957-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15960-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15963-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15940-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15943-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15946-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15949-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15952-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15955-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15958-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15961-E.ESY\r\n
\\\\Tecan-5\\Output\\15941-E.ESY\r\n
\\\\Tecan-5\\Output\\15944-E.ESY\r\n
\\\\Tecan-5\\Output\\15947-E.ESY\r\n
\\\\Tecan-5\\Output\\15950-E.ESY\r\n
\\\\Tecan-5\\Output\\15953-E.ESY\r\n
\\\\Tecan-5\\Output\\15956-E.ESY\r\n
\\\\Tecan-5\\Output\\15959-E.ESY\r\n
\\\\Tecan-5\\Output\\15962-E.ESY\r\n
</code>```

each \r\n should be a new line. sorry for the bad formatting

i need to sort the list of by the file name 15939-E.ESY, etc... i need the entire list in alphanumerical order by the filename. how would i sort it this way?

答:
I'd use Path.GetFileName like this

```<code>list = list.OrderBy(s=>Path.GetFileName(s)).ToList();
</code>```

Where list is a collection of those lines.

ContentLicense: CC BY-SA 2.5

Title: c# sorting list by substring

Body:
i have a list of strings:

\\\\Tecan1\\tecan #1 output\\15939-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15942-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15945-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15948-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15951-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15954-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15957-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15960-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15963-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15940-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15943-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15946-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15949-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15952-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15955-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15958-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15961-E.ESY\r\n
\\\\Tecan-5\\Output\\15941-E.ESY\r\n
\\\\Tecan-5\\Output\\15944-E.ESY\r\n
\\\\Tecan-5\\Output\\15947-E.ESY\r\n
\\\\Tecan-5\\Output\\15950-E.ESY\r\n
\\\\Tecan-5\\Output\\15953-E.ESY\r\n
\\\\Tecan-5\\Output\\15956-E.ESY\r\n
\\\\Tecan-5\\Output\\15959-E.ESY\r\n
\\\\Tecan-5\\Output\\15962-E.ESY\r\n

each \r\n should be a new line. sorry for the bad formatting

i need to sort the list of by the file name 15939-E.ESY, etc... i need the entire list in alphanumerical order by the filename. how would i sort it this way?

Body:
I'd use Path.GetFileName like this

list = list.OrderBy(s=>Path.GetFileName(s)).ToList();

Where list is a collection of those lines.


问:
How I could create a font that show the space " " as simbol like this "_"?
I dont know How I could do this  I need to get an idea for create a font in format ttf

PLease help me with this

答: Fontforge can read and write ttf files. Just edit an existing font and change the space character.</p>


问:
Unable to map docker volume with colon
Is there a way to mount a host directory as a data volume while the host directory path contains a colon?
Example

```<code>-v /colon:path/test:data
</code>```

In that case it's treating data as additional option. The /colon:path/test is a correct Unix path.

答:
Yes.  With the --mount option you can specify the source and destination.  This option was added to Docker 17.05.0.

```<code>--mount type=bind,source=/colon:path/test,destination=/data
</code>```

Note: You must use absolute pathnames.  I'm assuming the destination is /data.

From the docker run manpage:

See also --mount, which is the successor of --tmpfs and --volume.
  Even though there is no plan to deprecate --volume, usage of --mount
  is recommended.

Example:

```<code>touch foo:bar
docker run --rm --mount type=bind,source=$PWD/foo:bar,destination=/tmp/foo:bar busybox ls /tmp
</code>```

Title: Unable to map docker volume with colon

Body:
Is there a way to mount a host directory as a data volume while the host directory path contains a colon?
Example

-v /colon:path/test:data

In that case it's treating data as additional option. The /colon:path/test is a correct Unix path.

Body:
Yes.  With the --mount option you can specify the source and destination.  This option was added to Docker 17.05.0.

--mount type=bind,source=/colon:path/test,destination=/data

Note: You must use absolute pathnames.  I'm assuming the destination is /data.

From the docker run manpage:

See also --mount, which is the successor of --tmpfs and --volume.
  Even though there is no plan to deprecate --volume, usage of --mount
  is recommended.

Example:

touch foo:bar
docker run --rm --mount type=bind,source=$PWD/foo:bar,destination=/tmp/foo:bar busybox ls /tmp


问:
Service Fabric, which certificate do I use where?
I'm settings up a Service Fabric cluster in Azure and want to run a web API (using .NET Core) over https. I want to use my CA-signed wildcard (*.mydomain.com) certificate to access this API. But I'm a bit confused as to where I use it when I create the cluster, is it the cluster or client certificate? I'm thinking the client certificate, but the documentation states that this is for admin tools (i.e. the Explorer), so I'm unsure on how to proceed.

And yes I've read a ton of posts and resources, but I still find this confusing.

答:
There are three certificate types.  Here is a summary overview of them.

The Cluster certificate is used for the Explorer endpoint and is deployed to the primary nodes.  So if you add your *.mydomain.com wildcard cert there, and CNAME something (e.g. manage.mydomain.com) to [yourcluster].[region].cloudapp.azure.com, then when you hit your management endpoint that cert will be what will be presented to the web browser.

The Reverse Proxy SSL certificate is deployed to each of the nodes and is used when using the built-in reverse proxy feature of Service Fabric.  In this case this is what is being used when you hit https://api.mydomain.com/YourAppName/YourService/Resource (where api.mydomain.com is another CNAME to yourcluster.region.cloudapp.azure.com).  This is used as an alternative to running your own reverse proxy or other offloading layer (Application Gateway, IIS, nginx, API Management, etc).

The Client certificates are used in place of Azure Active Directory authentication to the management endpoint.  So instead of managing users in AAD (with the _Cluster AAD application and the Admin / Read-Only roles), you manage access by handing out management certificates (Admin or Read-Only) to your trusted users.

You can also have secondaries these certificates to use in certificate rollover situations.


问:
How to set values to 2d array and access the values using arr[i][j] or arr[i,j] in javascript
I need to copy few cells from one excel to another excel using node js.
Suppose i need to copy 3 cell values from 2 rows and assign to an array as below

First row

```<code>array[0,0] = A1 value

array[0,1] = B1 value

array[0,2] = C1 value
</code>```

Second Row

```<code>array[1,0] = A2 value

array[1,1] = B2 value

array[1,2] = C2 value
</code>```

After that i need to use the filled array and paste those values in another excel file in same location.That time i need to access  below array structure to paste into exact location.

Excel 2

```<code>A1 = array[0,0].value

B1 = array[1,0].value

etc...
</code>```

It does not behave the same way as we do in c#. Please let me know the code required in javascript.

答:
As you may know, 2D array is nothing but array of array. That's exactly what you need to do in javascript to create one. For example :

// you can use an Array construct as well.
let my_2d_array = [];

my_2d_array[0] = [];

my_2d_array[0][0] = 'some value';

console.log(my_2d_array[0][0]);```

Similarly you can create an array of objects as well, based on your requirement.

Hope this helps !

Body:
I need to copy few cells from one excel to another excel using node js.
Suppose i need to copy 3 cell values from 2 rows and assign to an array as below

First row

array[0,0] = A1 value

array[0,1] = B1 value

array[0,2] = C1 value

Second Row

array[1,0] = A2 value

array[1,1] = B2 value

array[1,2] = C2 value

After that i need to use the filled array and paste those values in another excel file in same location.That time i need to access  below array structure to paste into exact location.

Excel 2

A1 = array[0,0].value

B1 = array[1,0].value

etc...

It does not behave the same way as we do in c#. Please let me know the code required in javascript.

Body:
As you may know, 2D array is nothing but array of array. That's exactly what you need to do in javascript to create one. For example :

// you can use an Array construct as well.
let my_2d_array = [];

my_2d_array[0] = [];

my_2d_array[0][0] = 'some value';

console.log(my_2d_array[0][0]);

Similarly you can create an array of objects as well, based on your requirement.

Hope this helps !


问:
Package Installer Application crashing when launched from Gmail app
I got the following error when i tried to Install an APK on my device. It is working in device Galaxy POP, Galaxy ACE s 5830. The only problem in galaxy s3

My app's manifest file is below.

```<code>     <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.fixcity_app"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:resizeable="true"
        android:smallScreens="true"
        android:xlargeScreens="true" />

    <application
        android:icon="@drawable/icon_app_"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".SignupActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".LoginActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".FIX_Activity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".TakePictureActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".HomeActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".DisplayPhotoPblm"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".PostCommentActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".SelCategoryActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>

        <uses-library android:name="com.google.android.maps" />

        <activity
            android:name=".ProblemScreenActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".ViewMapActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".ChangeCategoryActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".FixedDisplayPhotoPblm"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".FixedProblemScreenActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".NoProofActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".ListProblemActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name="com.example.twitter_cls.PrepareRequestTokenActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".ReportsActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".SettingActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>

        <uses-library
            android:name="com.google.android.maps"
            android:required="true" />
    </application>

</manifest>
</code>```

Please Help me, thanks in Advance.

EDITED.

this is happened only when i install apk from gmail. if i run app directly from eclipse then its worked.

why this happens i want to k'no. please help me....

EDIT 11/10/2012 :

```<code>    10-11 06:06:33.626: I/ActivityManager(98): START {dat=file:///mnt/sdcard/Download/FixMyCity.apk cmp=com.android.packageinstaller/.InstallAppProgress (has extras)} from pid 1192
10-11 06:06:33.626: W/WindowManager(98): Failure taking screenshot for (240x394) to layer 21015
10-11 06:06:33.776: W/InstallAppProgress(1192): Replacing package:com.example.fixmycity
10-11 06:06:33.856: D/dalvikvm(1192): GC_FOR_ALLOC freed 11791K, 27% free 33725K/45575K, paused 74ms
10-11 06:06:33.876: I/dalvikvm-heap(1192): Grow heap (frag case) to 44.460MB for 12027004-byte allocation
10-11 06:06:34.086: D/dalvikvm(1192): GC_CONCURRENT freed 7K, 1% free 45462K/45575K, paused 6ms+7ms
10-11 06:06:34.156: I/Process(98): Sending signal. PID: 1192 SIG: 3
10-11 06:06:34.156: I/dalvikvm(1192): threadid=3: reacting to signal 3
10-11 06:06:34.166: I/dalvikvm(1192): Wrote stack traces to '/data/anr/traces.txt'
10-11 06:06:34.656: I/Process(98): Sending signal. PID: 1192 SIG: 3
10-11 06:06:34.656: I/dalvikvm(1192): threadid=3: reacting to signal 3
10-11 06:06:34.676: I/dalvikvm(1192): Wrote stack traces to '/data/anr/traces.txt'
10-11 06:06:34.856: D/dalvikvm(1192): GC_FOR_ALLOC freed <1K, 1% free 45462K/45575K, paused 66ms
10-11 06:06:34.856: I/dalvikvm-heap(1192): Forcing collection of SoftReferences for 21381328-byte allocation
10-11 06:06:34.946: D/dalvikvm(1192): GC_BEFORE_OOM freed 9K, 1% free 45453K/45575K, paused 93ms
10-11 06:06:34.946: E/dalvikvm-heap(1192): Out of memory on a 21381328-byte allocation.
10-11 06:06:34.957: I/dalvikvm(1192): "main" prio=5 tid=1 RUNNABLE
10-11 06:06:34.957: I/dalvikvm(1192):   | group="main" sCount=0 dsCount=0 obj=0x409c1460 self=0x12810
10-11 06:06:34.957: I/dalvikvm(1192):   | sysTid=1192 nice=0 sched=0/0 cgrp=default handle=1074082952
10-11 06:06:34.957: I/dalvikvm(1192):   | schedstat=( 3530101707 2280882759 989 ) utm=303 stm=50 core=0
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.Bitmap.nativeCreate(Native Method)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.content.res.Resources.loadDrawable(Resources.java:1935)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.content.res.Resources.getDrawable(Resources.java:664)
10-11 06:06:34.966: I/dalvikvm(1192):   at com.android.packageinstaller.PackageUtil.getAppSnippet(PackageUtil.java:177)
10-11 06:06:34.966: I/dalvikvm(1192):   at com.android.packageinstaller.InstallAppProgress.initView(InstallAppProgress.java:223)
10-11 06:06:34.966: I/dalvikvm(1192):   at com.android.packageinstaller.InstallAppProgress.onCreate(InstallAppProgress.java:164)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.Activity.performCreate(Activity.java:4465)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.ActivityThread.access$600(ActivityThread.java:123)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.os.Handler.dispatchMessage(Handler.java:99)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.os.Looper.loop(Looper.java:137)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.ActivityThread.main(ActivityThread.java:4424)
10-11 06:06:34.966: I/dalvikvm(1192):   at java.lang.reflect.Method.invokeNative(Native Method)
10-11 06:06:34.976: I/dalvikvm(1192):   at java.lang.reflect.Method.invoke(Method.java:511)
10-11 06:06:34.976: I/dalvikvm(1192):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-11 06:06:34.976: I/dalvikvm(1192):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-11 06:06:34.976: I/dalvikvm(1192):   at dalvik.system.NativeStart.main(Native Method)
10-11 06:06:34.976: D/AndroidRuntime(1192): Shutting down VM
10-11 06:06:34.976: W/dalvikvm(1192): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-11 06:06:35.006: E/AndroidRuntime(1192): FATAL EXCEPTION: main
10-11 06:06:35.006: E/AndroidRuntime(1192): java.lang.OutOfMemoryError
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.Bitmap.nativeCreate(Native Method)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.content.res.Resources.loadDrawable(Resources.java:1935)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.content.res.Resources.getDrawable(Resources.java:664)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at com.android.packageinstaller.PackageUtil.getAppSnippet(PackageUtil.java:177)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at com.android.packageinstaller.InstallAppProgress.initView(InstallAppProgress.java:223)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at com.android.packageinstaller.InstallAppProgress.onCreate(InstallAppProgress.java:164)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.Activity.performCreate(Activity.java:4465)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.os.Looper.loop(Looper.java:137)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.ActivityThread.main(ActivityThread.java:4424)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at java.lang.reflect.Method.invokeNative(Native Method)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at java.lang.reflect.Method.invoke(Method.java:511)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at dalvik.system.NativeStart.main(Native Method)
10-11 06:06:35.046: W/ActivityManager(98):   Force finishing activity com.android.packageinstaller/.InstallAppProgress
10-11 06:06:35.186: I/Process(98): Sending signal. PID: 1192 SIG: 3
10-11 06:06:35.186: I/dalvikvm(1192): threadid=3: reacting to signal 3
10-11 06:06:35.186: I/dalvikvm(1192): Wrote stack traces to '/data/anr/traces.txt'
10-11 06:06:35.566: W/ActivityManager(98): Activity pause timeout for ActivityRecord{41a415b8 com.android.packageinstaller/.InstallAppProgress}
10-11 06:06:35.576: I/Process(98): Sending signal. PID: 1192 SIG: 3
10-11 06:06:35.576: I/dalvikvm(1192): threadid=3: reacting to signal 3
10-11 06:06:35.586: I/dalvikvm(1192): Wrote stack traces to '/data/anr/traces.txt'
10-11 06:06:35.836: D/dalvikvm(98): GC_CONCURRENT freed 479K, 11% free 15792K/17671K, paused 6ms+74ms
10-11 06:06:35.926: W/NetworkManagementSocketTagger(98): setKernelCountSet(10014, 1) failed with errno -2
10-11 06:06:36.816: W/NetworkManagementSocketTagger(98): setKernelCountSet(10029, 0) failed with errno -2
10-11 06:06:46.369: W/ActivityManager(98): Activity destroy timeout for ActivityRecord{41a415b8 com.android.packageinstaller/.InstallAppProgress}
10-11 06:06:46.526: W/ActivityManager(98): Activity destroy timeout for ActivityRecord{419f82a0 com.android.packageinstaller/.PackageInstallerActivity}
10-11 06:08:40.916: I/GTalkService/c(226): [AndroidEndpoint@1097419944] connect: acct=1000000, state=CONNECTING
10-11 06:08:40.976: E/GTalkService(226): connectionClosed: no XMPPConnection - That's strange!
10-11 06:08:43.986: D/ConnectivityService(98): handleInetConditionHoldEnd: net=0, condition=0, published condition=0
10-11 06:11:02.866: D/dalvikvm(426): GC_CONCURRENT freed 505K, 17% free 14262K/17159K, paused 6ms+9ms
</code>```

答:
I had this problem too,
I changed my application icon size to 512*512 (it was very big before) and then it resolved!</p>

Body:
I got the following error when i tried to Install an APK on my device. It is working in device Galaxy POP, Galaxy ACE s 5830. The only problem in galaxy s3

My app's manifest file is below.

     <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.fixcity_app"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:resizeable="true"
        android:smallScreens="true"
        android:xlargeScreens="true" />

    <application
        android:icon="@drawable/icon_app_"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".SignupActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".LoginActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".FIX_Activity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".TakePictureActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".HomeActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".DisplayPhotoPblm"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".PostCommentActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".SelCategoryActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>

        <uses-library android:name="com.google.android.maps" />

        <activity
            android:name=".ProblemScreenActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".ViewMapActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".ChangeCategoryActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".FixedDisplayPhotoPblm"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".FixedProblemScreenActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".NoProofActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".ListProblemActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name="com.example.twitter_cls.PrepareRequestTokenActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".ReportsActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name=".SettingActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>

        <uses-library
            android:name="com.google.android.maps"
            android:required="true" />
    </application>

</manifest>

Please Help me, thanks in Advance.

EDITED.

this is happened only when i install apk from gmail. if i run app directly from eclipse then its worked.

why this happens i want to k'no. please help me....

EDIT 11/10/2012 :

    10-11 06:06:33.626: I/ActivityManager(98): START {dat=file:///mnt/sdcard/Download/FixMyCity.apk cmp=com.android.packageinstaller/.InstallAppProgress (has extras)} from pid 1192
10-11 06:06:33.626: W/WindowManager(98): Failure taking screenshot for (240x394) to layer 21015
10-11 06:06:33.776: W/InstallAppProgress(1192): Replacing package:com.example.fixmycity
10-11 06:06:33.856: D/dalvikvm(1192): GC_FOR_ALLOC freed 11791K, 27% free 33725K/45575K, paused 74ms
10-11 06:06:33.876: I/dalvikvm-heap(1192): Grow heap (frag case) to 44.460MB for 12027004-byte allocation
10-11 06:06:34.086: D/dalvikvm(1192): GC_CONCURRENT freed 7K, 1% free 45462K/45575K, paused 6ms+7ms
10-11 06:06:34.156: I/Process(98): Sending signal. PID: 1192 SIG: 3
10-11 06:06:34.156: I/dalvikvm(1192): threadid=3: reacting to signal 3
10-11 06:06:34.166: I/dalvikvm(1192): Wrote stack traces to '/data/anr/traces.txt'
10-11 06:06:34.656: I/Process(98): Sending signal. PID: 1192 SIG: 3
10-11 06:06:34.656: I/dalvikvm(1192): threadid=3: reacting to signal 3
10-11 06:06:34.676: I/dalvikvm(1192): Wrote stack traces to '/data/anr/traces.txt'
10-11 06:06:34.856: D/dalvikvm(1192): GC_FOR_ALLOC freed <1K, 1% free 45462K/45575K, paused 66ms
10-11 06:06:34.856: I/dalvikvm-heap(1192): Forcing collection of SoftReferences for 21381328-byte allocation
10-11 06:06:34.946: D/dalvikvm(1192): GC_BEFORE_OOM freed 9K, 1% free 45453K/45575K, paused 93ms
10-11 06:06:34.946: E/dalvikvm-heap(1192): Out of memory on a 21381328-byte allocation.
10-11 06:06:34.957: I/dalvikvm(1192): "main" prio=5 tid=1 RUNNABLE
10-11 06:06:34.957: I/dalvikvm(1192):   | group="main" sCount=0 dsCount=0 obj=0x409c1460 self=0x12810
10-11 06:06:34.957: I/dalvikvm(1192):   | sysTid=1192 nice=0 sched=0/0 cgrp=default handle=1074082952
10-11 06:06:34.957: I/dalvikvm(1192):   | schedstat=( 3530101707 2280882759 989 ) utm=303 stm=50 core=0
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.Bitmap.nativeCreate(Native Method)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
10-11 06:06:34.957: I/dalvikvm(1192):   at android.content.res.Resources.loadDrawable(Resources.java:1935)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.content.res.Resources.getDrawable(Resources.java:664)
10-11 06:06:34.966: I/dalvikvm(1192):   at com.android.packageinstaller.PackageUtil.getAppSnippet(PackageUtil.java:177)
10-11 06:06:34.966: I/dalvikvm(1192):   at com.android.packageinstaller.InstallAppProgress.initView(InstallAppProgress.java:223)
10-11 06:06:34.966: I/dalvikvm(1192):   at com.android.packageinstaller.InstallAppProgress.onCreate(InstallAppProgress.java:164)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.Activity.performCreate(Activity.java:4465)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.ActivityThread.access$600(ActivityThread.java:123)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.os.Handler.dispatchMessage(Handler.java:99)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.os.Looper.loop(Looper.java:137)
10-11 06:06:34.966: I/dalvikvm(1192):   at android.app.ActivityThread.main(ActivityThread.java:4424)
10-11 06:06:34.966: I/dalvikvm(1192):   at java.lang.reflect.Method.invokeNative(Native Method)
10-11 06:06:34.976: I/dalvikvm(1192):   at java.lang.reflect.Method.invoke(Method.java:511)
10-11 06:06:34.976: I/dalvikvm(1192):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-11 06:06:34.976: I/dalvikvm(1192):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-11 06:06:34.976: I/dalvikvm(1192):   at dalvik.system.NativeStart.main(Native Method)
10-11 06:06:34.976: D/AndroidRuntime(1192): Shutting down VM
10-11 06:06:34.976: W/dalvikvm(1192): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-11 06:06:35.006: E/AndroidRuntime(1192): FATAL EXCEPTION: main
10-11 06:06:35.006: E/AndroidRuntime(1192): java.lang.OutOfMemoryError
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.Bitmap.nativeCreate(Native Method)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.content.res.Resources.loadDrawable(Resources.java:1935)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.content.res.Resources.getDrawable(Resources.java:664)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at com.android.packageinstaller.PackageUtil.getAppSnippet(PackageUtil.java:177)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at com.android.packageinstaller.InstallAppProgress.initView(InstallAppProgress.java:223)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at com.android.packageinstaller.InstallAppProgress.onCreate(InstallAppProgress.java:164)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.Activity.performCreate(Activity.java:4465)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.os.Looper.loop(Looper.java:137)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at android.app.ActivityThread.main(ActivityThread.java:4424)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at java.lang.reflect.Method.invokeNative(Native Method)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at java.lang.reflect.Method.invoke(Method.java:511)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-11 06:06:35.006: E/AndroidRuntime(1192):     at dalvik.system.NativeStart.main(Native Method)
10-11 06:06:35.046: W/ActivityManager(98):   Force finishing activity com.android.packageinstaller/.InstallAppProgress
10-11 06:06:35.186: I/Process(98): Sending signal. PID: 1192 SIG: 3
10-11 06:06:35.186: I/dalvikvm(1192): threadid=3: reacting to signal 3
10-11 06:06:35.186: I/dalvikvm(1192): Wrote stack traces to '/data/anr/traces.txt'
10-11 06:06:35.566: W/ActivityManager(98): Activity pause timeout for ActivityRecord{41a415b8 com.android.packageinstaller/.InstallAppProgress}
10-11 06:06:35.576: I/Process(98): Sending signal. PID: 1192 SIG: 3
10-11 06:06:35.576: I/dalvikvm(1192): threadid=3: reacting to signal 3
10-11 06:06:35.586: I/dalvikvm(1192): Wrote stack traces to '/data/anr/traces.txt'
10-11 06:06:35.836: D/dalvikvm(98): GC_CONCURRENT freed 479K, 11% free 15792K/17671K, paused 6ms+74ms
10-11 06:06:35.926: W/NetworkManagementSocketTagger(98): setKernelCountSet(10014, 1) failed with errno -2
10-11 06:06:36.816: W/NetworkManagementSocketTagger(98): setKernelCountSet(10029, 0) failed with errno -2
10-11 06:06:46.369: W/ActivityManager(98): Activity destroy timeout for ActivityRecord{41a415b8 com.android.packageinstaller/.InstallAppProgress}
10-11 06:06:46.526: W/ActivityManager(98): Activity destroy timeout for ActivityRecord{419f82a0 com.android.packageinstaller/.PackageInstallerActivity}
10-11 06:08:40.916: I/GTalkService/c(226): [AndroidEndpoint@1097419944] connect: acct=1000000, state=CONNECTING
10-11 06:08:40.976: E/GTalkService(226): connectionClosed: no XMPPConnection - That's strange!
10-11 06:08:43.986: D/ConnectivityService(98): handleInetConditionHoldEnd: net=0, condition=0, published condition=0
10-11 06:11:02.866: D/dalvikvm(426): GC_CONCURRENT freed 505K, 17% free 14262K/17159K, paused 6ms+9ms


问:
how to connect AudioClip at local file
I downloaded the .mp3 file from the server and stored it in my android persistentDataPath. But I do not know how to connect .mp3 files to AudioClip.
Please let me know if there is a workaround for this.</p>

答:
Update

As pointed out in the comments WWW now supports .mp3 files making it the way to go.

```<code>using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public string url;
    public AudioSource source;
    void Start() {
        WWW www = new WWW(url);
        source = GetComponent<AudioSource>();
        source.clip = www.audioClip;
    }
    void Update() {
        if (!source.isPlaying && source.clip.isReadyToPlay)
            source.Play();

    }
}
</code>```

Original answer:

Audio clip doesn't accept a file. It accepts an array of floats.

You can use NAudio to convert the compressed MP3 to a WAV file.

```<code>using NAudio;
using NAudio.Wave;
// ....

using (Mp3FileReader reader = new Mp3FileReader(mp3File))
{
    WaveFileWriter.CreateWaveFile(outputFile, reader);
}
</code>```

You will then need to read the wave file which will basically have a header followed by the chunk data. The chunk data can be converted to a float and sent to your audio clip.

Title: how to connect AudioClip at local file

Body:
Update

As pointed out in the comments WWW now supports .mp3 files making it the way to go.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public string url;
    public AudioSource source;
    void Start() {
        WWW www = new WWW(url);
        source = GetComponent<AudioSource>();
        source.clip = www.audioClip;
    }
    void Update() {
        if (!source.isPlaying && source.clip.isReadyToPlay)
            source.Play();

    }
}

Original answer:

Audio clip doesn't accept a file. It accepts an array of floats.

You can use NAudio to convert the compressed MP3 to a WAV file.

using NAudio;
using NAudio.Wave;
// ....

using (Mp3FileReader reader = new Mp3FileReader(mp3File))
{
    WaveFileWriter.CreateWaveFile(outputFile, reader);
}

You will then need to read the wave file which will basically have a header followed by the chunk data. The chunk data can be converted to a float and sent to your audio clip.


问:
When should I use setDT() instead of data.table() to create a data.table?
I am having difficulty grasping the essence of the setDT() function. As I read code on SO, I frequently come across the use of setDT() to create a data.table. Of course the use of data.table() is ubiquitous. I feel like I solidly comprehend the nature of data.table() yet the relevance of setDT() eludes me. ?setDT tells me this:

setDT converts lists (both named and unnamed) and data.frames to data.tables by reference.

as well as:

In data.table parlance, all set* functions change their input by reference. That is, no copy is made at all, other than temporary working memory, which is as large as one column.

So this makes me think I should only use setDT() to make a data.table, right? Is setDT() simply a list to data.table converter?

```<code>library(data.table)

a <- letters[c(19,20,1,3,11,15,22,5,18,6,12,15,23)]
b <- seq(1,41,pi)
ab <- data.frame(a,b)
d <- data.table(ab)
e <- setDT(ab)

str(d)
#Classes ‘data.table’ and 'data.frame': 13 obs. of  2 variables:
# $ a: Factor w/ 12 levels "a","c","e","f",..: 9 10 1 2 5 7 11 3 8 4 ...
# $ b: num  1 4.14 7.28 10.42 13.57 ...
# - attr(*, ".internal.selfref")=<externalptr>

str(e)
#Classes ‘data.table’ and 'data.frame': 13 obs. of  2 variables:
# $ a: Factor w/ 12 levels "a","c","e","f",..: 9 10 1 2 5 7 11 3 8 4 ...
# $ b: num  1 4.14 7.28 10.42 13.57 ...
# - attr(*, ".internal.selfref")=<externalptr>
</code>```

Seemingly no difference in this instance. In another instance the difference is evident:

```<code>ba <- list(a,b)
f <- data.table(ba)
g <- setDT(ba)

str(f)
#Classes ‘data.table’ and 'data.frame': 2 obs. of  1 variable:
# $ ba:List of 2
#  ..$ : chr  "s" "t" "a" "c" ...
#  ..$ : num  1 4.14 7.28 10.42 13.57 ...
# - attr(*, ".internal.selfref")=<externalptr>

str(g)
#Classes ‘data.table’ and 'data.frame': 13 obs. of  2 variables:
# $ V1: chr  "s" "t" "a" "c" ...
# $ V2: num  1 4.14 7.28 10.42 13.57 ...
# - attr(*, ".internal.selfref")=<externalptr>
</code>```

When should I use setDT()? What makes setDT() relevant? Why not just make the original data.table() function capable of doing what setDT() is able to do?

答:
Update:

@Roland makes some good points in the comments section, and the post is better for them. While I originally focused on memory overflow issues, he pointed out that even if this doesn't happen, memory management of various copies takes substantial time, which is a more common everyday concern. Examples of both issues have now been added as well.

I like this question on stackoverflow because I think it is really about avoiding stack overflow in R when dealing with larger data sets.   Those who are unfamiliar with data.table family of set operations may benefit from this discussion!

One should use setDT() when working with larger data sets that take up a considerable amount of RAM because the operation will modify each object in place, conserving memory. For data that is a very small percentage of RAM, using data.table’s copy-and-modify is fine.

The creation of the setDT function was actually inspired by the following thread on stack overflow, which is about working with a large data set (several GB's). You will see Matt Dowle chime in an suggest the 'setDT' name.

Convert a data frame to a data.table without copy

A bit more depth:

With R, data is stored in memory. This speeds things up considerably because RAM is much faster to access than storage devices. However, a problem can arise when one’s data set is a large portion of RAM. Why? Because base R has a tendency to make copies of each data.frame when some operations are applied to them. This has improved after version 3.1, but addressing that is beyond the scope of this post. If one is pulling multiple data.frames or lists into one data.frame or data.table, your memory usage will expand rather quickly because at some point during the operation, multiple copies of your data exist in RAM. If the data set is big enough, you may run out of memory when all the copies are produced, and your stack will overflow. See example of this below. We get an error, and original memory address and class of object does not change.

```<code>> N <- 1e8
> P <- 1e2
> data <- as.data.frame(rep(data.frame(rnorm(N)), P))
>
> pryr::object_size(data)
800 MB
>
> tracemem(data)
[1] "<0000000006D2DF18>"
>
> data <- data.table(data)
Error: cannot allocate vector of size 762.9 Mb
>
> tracemem(data)
[1] "<0000000006D2DF18>"
> class(data)
[1] "data.frame"
>
</code>```

The ability to just modify the object in place without copying is a big deal. That is what setDT does when it takes a list or data.frame and returns a data.table. The same example as above using setDT, now works fine and without error. Both class and memory address change, and no copies take place.

```<code>> tracemem(data)
[1] "<0000000006D2DF18>"
> class(data)
[1] "data.frame"
>
> setDT(data)
>
> tracemem(data)
[1] "<0000000006A8C758>"
> class(data)
[1] "data.table" "data.frame"
</code>```

@Roland points out that for most people, the bigger concern is speed, which suffers as a side effect of such intensive use of memory management. Here is an example with smaller data that does not crash the cpu, and illustrates how much faster setDT is for this job. Notice the results of 'tracemem' in the wake of data <- data.table(data), making copies of data. Contrast that with setDT(data) which doesn't print a single copy. We have to then call tracemem(data) to see the new memory address.

```<code>> N <- 1e5
> P <- 1e2
> data <- as.data.frame(rep(data.frame(rnorm(N)), P))
> pryr::object_size(data)
808 kB

> # data.table method
> tracemem(data)
[1] "<0000000019098438>"
> data <- data.table(data)
tracemem[0x0000000019098438 -> 0x0000000007aad7d8]: data.table
tracemem[0x0000000007aad7d8 -> 0x0000000007c518b8]: copy as.data.table.data.frame as.data.table data.table
tracemem[0x0000000007aad7d8 -> 0x0000000018e454c8]: as.list.data.frame as.list vapply copy as.data.table.data.frame as.data.table data.table
> class(data)
[1] "data.table" "data.frame"
>
> # setDT method
> # back to data.frame
> data <- as.data.frame(data)
> class(data)
[1] "data.frame"
> tracemem(data)
[1] "<00000000125BE1A0>"
> setDT(data)
> tracemem(data)
[1] "<00000000125C2840>"
> class(data)
[1] "data.table" "data.frame"
>
</code>```

How does this impact timing? As we can see, setDT is much faster for it.

```<code>> # timing example
> data <- as.data.frame(rep(data.frame(rnorm(N)), P))
> microbenchmark(setDT(data), data <- data.table(data))
Unit: microseconds
                     expr       min         lq        mean    median            max neval        uq
              setDT(data)    49.948    55.7635    69.66017    73.553        100.238   100    79.198
 data <- data.table(data) 54594.289 61238.8830 81545.64432 64179.131     611632.427   100 68647.917
</code>```

Set functions can be used in many areas, not just when converting objects to a data.tables. You can find more information on the reference semantics and how to apply them elsewhere by calling the vignette on the subject.

```<code>library(data.table)
vignette("datatable-reference-semantics")
</code>```

This is a great question and those thinking of using R with larger data sets or who just want to speed up data manipulation actives, can benefit from being familiar with the significant performance improvements of data.table reference semantics.

ContentLicense: CC BY-SA 4.0

Body:
I am having difficulty grasping the essence of the setDT() function. As I read code on SO, I frequently come across the use of setDT() to create a data.table. Of course the use of data.table() is ubiquitous. I feel like I solidly comprehend the nature of data.table() yet the relevance of setDT() eludes me. ?setDT tells me this:

setDT converts lists (both named and unnamed) and data.frames to data.tables by reference.

as well as:

In data.table parlance, all set* functions change their input by reference. That is, no copy is made at all, other than temporary working memory, which is as large as one column.

So this makes me think I should only use setDT() to make a data.table, right? Is setDT() simply a list to data.table converter?

library(data.table)

a <- letters[c(19,20,1,3,11,15,22,5,18,6,12,15,23)]
b <- seq(1,41,pi)
ab <- data.frame(a,b)
d <- data.table(ab)
e <- setDT(ab)

str(d)
#Classes ‘data.table’ and 'data.frame': 13 obs. of  2 variables:
# $ a: Factor w/ 12 levels "a","c","e","f",..: 9 10 1 2 5 7 11 3 8 4 ...
# $ b: num  1 4.14 7.28 10.42 13.57 ...
# - attr(*, ".internal.selfref")=<externalptr>

str(e)
#Classes ‘data.table’ and 'data.frame': 13 obs. of  2 variables:
# $ a: Factor w/ 12 levels "a","c","e","f",..: 9 10 1 2 5 7 11 3 8 4 ...
# $ b: num  1 4.14 7.28 10.42 13.57 ...
# - attr(*, ".internal.selfref")=<externalptr>

Seemingly no difference in this instance. In another instance the difference is evident:

ba <- list(a,b)
f <- data.table(ba)
g <- setDT(ba)

str(f)
#Classes ‘data.table’ and 'data.frame': 2 obs. of  1 variable:
# $ ba:List of 2
#  ..$ : chr  "s" "t" "a" "c" ...
#  ..$ : num  1 4.14 7.28 10.42 13.57 ...
# - attr(*, ".internal.selfref")=<externalptr>

str(g)
#Classes ‘data.table’ and 'data.frame': 13 obs. of  2 variables:
# $ V1: chr  "s" "t" "a" "c" ...
# $ V2: num  1 4.14 7.28 10.42 13.57 ...
# - attr(*, ".internal.selfref")=<externalptr>

When should I use setDT()? What makes setDT() relevant? Why not just make the original data.table() function capable of doing what setDT() is able to do?

Body:
Update:

@Roland makes some good points in the comments section, and the post is better for them. While I originally focused on memory overflow issues, he pointed out that even if this doesn't happen, memory management of various copies takes substantial time, which is a more common everyday concern. Examples of both issues have now been added as well.

I like this question on stackoverflow because I think it is really about avoiding stack overflow in R when dealing with larger data sets.   Those who are unfamiliar with data.table family of set operations may benefit from this discussion!

One should use setDT() when working with larger data sets that take up a considerable amount of RAM because the operation will modify each object in place, conserving memory. For data that is a very small percentage of RAM, using data.table’s copy-and-modify is fine.

The creation of the setDT function was actually inspired by the following thread on stack overflow, which is about working with a large data set (several GB's). You will see Matt Dowle chime in an suggest the 'setDT' name.

Convert a data frame to a data.table without copy

A bit more depth:

With R, data is stored in memory. This speeds things up considerably because RAM is much faster to access than storage devices. However, a problem can arise when one’s data set is a large portion of RAM. Why? Because base R has a tendency to make copies of each data.frame when some operations are applied to them. This has improved after version 3.1, but addressing that is beyond the scope of this post. If one is pulling multiple data.frames or lists into one data.frame or data.table, your memory usage will expand rather quickly because at some point during the operation, multiple copies of your data exist in RAM. If the data set is big enough, you may run out of memory when all the copies are produced, and your stack will overflow. See example of this below. We get an error, and original memory address and class of object does not change.

> N <- 1e8
> P <- 1e2
> data <- as.data.frame(rep(data.frame(rnorm(N)), P))
>
> pryr::object_size(data)
800 MB
>
> tracemem(data)
[1] "<0000000006D2DF18>"
>
> data <- data.table(data)
Error: cannot allocate vector of size 762.9 Mb
>
> tracemem(data)
[1] "<0000000006D2DF18>"
> class(data)
[1] "data.frame"
>

The ability to just modify the object in place without copying is a big deal. That is what setDT does when it takes a list or data.frame and returns a data.table. The same example as above using setDT, now works fine and without error. Both class and memory address change, and no copies take place.

> tracemem(data)
[1] "<0000000006D2DF18>"
> class(data)
[1] "data.frame"
>
> setDT(data)
>
> tracemem(data)
[1] "<0000000006A8C758>"
> class(data)
[1] "data.table" "data.frame"

@Roland points out that for most people, the bigger concern is speed, which suffers as a side effect of such intensive use of memory management. Here is an example with smaller data that does not crash the cpu, and illustrates how much faster setDT is for this job. Notice the results of 'tracemem' in the wake of data <- data.table(data), making copies of data. Contrast that with setDT(data) which doesn't print a single copy. We have to then call tracemem(data) to see the new memory address.

> N <- 1e5
> P <- 1e2
> data <- as.data.frame(rep(data.frame(rnorm(N)), P))
> pryr::object_size(data)
808 kB

> # data.table method
> tracemem(data)
[1] "<0000000019098438>"
> data <- data.table(data)
tracemem[0x0000000019098438 -> 0x0000000007aad7d8]: data.table
tracemem[0x0000000007aad7d8 -> 0x0000000007c518b8]: copy as.data.table.data.frame as.data.table data.table
tracemem[0x0000000007aad7d8 -> 0x0000000018e454c8]: as.list.data.frame as.list vapply copy as.data.table.data.frame as.data.table data.table
> class(data)
[1] "data.table" "data.frame"
>
> # setDT method
> # back to data.frame
> data <- as.data.frame(data)
> class(data)
[1] "data.frame"
> tracemem(data)
[1] "<00000000125BE1A0>"
> setDT(data)
> tracemem(data)
[1] "<00000000125C2840>"
> class(data)
[1] "data.table" "data.frame"
>

How does this impact timing? As we can see, setDT is much faster for it.

> # timing example
> data <- as.data.frame(rep(data.frame(rnorm(N)), P))
> microbenchmark(setDT(data), data <- data.table(data))
Unit: microseconds
                     expr       min         lq        mean    median            max neval        uq
              setDT(data)    49.948    55.7635    69.66017    73.553        100.238   100    79.198
 data <- data.table(data) 54594.289 61238.8830 81545.64432 64179.131     611632.427   100 68647.917

Set functions can be used in many areas, not just when converting objects to a data.tables. You can find more information on the reference semantics and how to apply them elsewhere by calling the vignette on the subject.

library(data.table)
vignette("datatable-reference-semantics")

This is a great question and those thinking of using R with larger data sets or who just want to speed up data manipulation actives, can benefit from being familiar with the significant performance improvements of data.table reference semantics.


问:
How do I get Filter Criteria in Excel 2016 using VBA?
I am working on an Excel 2016 VBA Macro that applies a filter to the headings column. Afterwards, the user applies the filter criteria. I would like to be able to in VBA retrieve the filter criteria that the user applied and save it to a string array. Is there a way to access the filter criteria?</p>

答:
the code would to be like this. The code of field is  cells(1, f).</p>

```<code>Dim sht As Worksheet
Set sht = ActiveSheet
With sht.AutoFilter
    With .Filters
        ReDim filtarr(1 To .Count, 1 To 4) ' change array
        For f = 1 To .Count
            With .Item(f)
                If .On Then
                    filtarr(f, 1) = .Criteria1
                    filtarr(f, 4) = Cells(1, f) 'field
                    Debug.Print .Criteria1, Cells(1, f)
                    If .Operator Then
                        filtarr(f, 2) = .Operator
                        filtarr(f, 3) = .Criteria2

                        Debug.Print .Operator & ", " & .Criteria2
                    End If
                End If
            End With
        Next f
    End With
End With
</code>```

Body:
the code would to be like this. The code of field is  cells(1, f).

Dim sht As Worksheet
Set sht = ActiveSheet
With sht.AutoFilter
    With .Filters
        ReDim filtarr(1 To .Count, 1 To 4) ' change array
        For f = 1 To .Count
            With .Item(f)
                If .On Then
                    filtarr(f, 1) = .Criteria1
                    filtarr(f, 4) = Cells(1, f) 'field
                    Debug.Print .Criteria1, Cells(1, f)
                    If .Operator Then
                        filtarr(f, 2) = .Operator
                        filtarr(f, 3) = .Criteria2

                        Debug.Print .Operator & ", " & .Criteria2
                    End If
                End If
            End With
        Next f
    End With
End With


问:
Why are the lookup procedures for getting an attribute from a class and from an instance different?
Python in a Nutshell describes the lookup procedures when getting an attribute. The book distinguishes two cases

the lookup procedure when getting an attribute from a class, e.g. cls.name

Getting an attribute from a class

When  you  use  the  syntax  C.name   to  refer  to  an  attribute
  on  a  class  object  C,  the lookup proceeds in two steps:

When  name   is  a  key  in  C.__dict__,  C.name   fetches  the  value  v   from C.__dict__['name'] .  Then,  when  v   is
  a  descriptor  (i.e.,  type(v)   supplies  a method  named
  __get__ ),  the  value  of  C.name   is  the  result  of  calling
  type(v).__get__(v,  None,  C) .  When  v   is  not  a  descriptor,
  the  value  of C.name  is  v .

When  name  is not a key in  C.__dict__ ,  C.name  delegates the lookup to  C ’s base classes, meaning it loops on  C ’s
  ancestor classes and tries the  name  lookup on each (in method
  resolution order, as covered in “Method resolution order” on page
  113).

the lookup procedure when getting an attribute from an instance, e.g. obj.name

Since in Python 3, every class object is actually an instance of its metaclass (e.g. type class), according to the book, why are the lookup procedure for getting an attribute from a class and the lookup procedure for getting an attribute from an instance different?

答:
They're not very different, and the description from the book covers the two ways in which they differ:

Descriptors found on a class instance (after not being found on the class) don't get invoked (a.x = somedescriptor() where a is a class instance, not a class, followed by a.x will just return the instance of somedescriptor() you just made), while descriptors found on a metaclass instance i.e. a class (after not being found on the metaclass) get invoked with None as the instance it was called on (A.x = somedescriptor() where A is a metaclass instance, not a metaclass, will invoke .__get__(None, A) on the somedescriptor() you just made). This allows stuff like @classmethod to work by binding the method to the class itself whether it's looked up on an instance of the class or the class itself.

Class instances don't have a concept of "parent instances" (the namespace of the class instance itself is a flat dict, even if the attributes associated with that class instance were defined by methods from multiple levels of inheritance), so the idea of MRO-based lookup is unique to metaclass instances.

Everything else is pretty much the same, it's just that the book is glossing over the concept of metaclasses here, since most classes are instances of the base type, which has no special behaviors. If you have a metaclass other than type, the full instance lookup rules apply when looking up attributes on a class (it's just the class of the class is the metaclass).

They were probably trying to avoid the complexity of metaclasses early on, but in the process made it seem like the rules for instance lookup didn't apply to classes; they do, it's just that classes add a couple extra rules to the basic lookup procedure.


问:
ffmpeg is reading SDP from RTSP stream but unable to save a screenshot. is it network or utility issue?
My task is to get a screenshot from IP camera rtsp stream via ffmpeg.
I got following error when I'm trying to do that on DigitalOcean droplet:

```<code>root@docker-512mb-fra1-01:~# ffmpeg -hide_banner -loglevel debug -i rtsp://10.132.193.9//ch0.h264 -f image2 latest.jpg
Splitting the commandline.
Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-i' ... matched as input url with argument 'rtsp://10.132.193.9//ch0.h264'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'image2'.
Reading option 'latest.jpg' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option hide_banner (do not show program banner) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url rtsp://10.132.193.9//ch0.h264.
Successfully parsed a group of options.
Opening an input file: rtsp://10.132.193.9//ch0.h264.
[rtsp @ 0x1298440] SDP:
v=0
o=- 1499314217993040 1 IN IP4 192.168.1.128
s=H.264 Program Stream, streamed by the LIVE555 Media Server
i=ch0.h264
t=0 0
a=DevVer:pusher2
a=GroupName:IPCAM
a=NickName:CIF
a=CfgSection:PROG_CHN0
a=tool:LIVE555 Streaming Media v2011.08.13
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:H.264 Program Stream, streamed by the LIVE555 Media Server
a=x-qt-text-inf:ch0.h264
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:4000
a=rtpmap:96 H264/90000
a=control:trackID=1
a=fmtp:96 packetization-mode=1;profile-level-id=64001F;sprop-parameter-sets=Z2QAH6wrUCgC3IA=,aO48MA==
a=framesize:96 1280-720
a=cliprect:0,0,1280,720
m=audio 0 RTP/AVP 97
a=rtpmap:97 mpeg4-generic/8000/2
a=fmtp:97 streamtype=5;profile-level-id=1;cpresent=0;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1590
a=control:trackID=2

Failed to parse interval end specification ''
[rtsp @ 0x1298440] video codec set to: h264
[rtsp @ 0x1298440] RTP Packetization Mode: 1
[rtsp @ 0x1298440] RTP Profile IDC: 64 Profile IOP: 0 Level: 1f
[rtsp @ 0x1298440] Extradata set to 0x1298a20 (size: 23)
[rtsp @ 0x1298440] audio codec set to: aac
[rtsp @ 0x1298440] audio samplerate set to: 8000
[rtsp @ 0x1298440] audio channels set to: 2
[udp @ 0x129e7e0] end receive buffer size reported is 131072
[udp @ 0x129e680] end receive buffer size reported is 131072
[udp @ 0x12bf380] end receive buffer size reported is 131072
[udp @ 0x12bf1c0] end receive buffer size reported is 131072
[rtsp @ 0x1298440] hello state=0
[rtsp @ 0x1298440] UDP timeout, retrying with TCP
[rtsp @ 0x1298440] hello state=0
[rtsp @ 0x1298440] Could not find codec parameters for stream 0 (Video: h264, 1 reference frame, none(left), 1280x720, 1/180000): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, rtsp, from 'rtsp://10.132.193.9//ch0.h264':
  Metadata:
    title           : H.264 Program Stream, streamed by the LIVE555 Media Server
    comment         : ch0.h264
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0, 0, 1/90000: Video: h264, 1 reference frame, none(left), 1280x720, 1/180000, 90k tbr, 90k tbn, 180k tbc
    Stream #0:1, 0, 1/8000: Audio: aac, 8000 Hz, stereo, fltp
Successfully opened the file.
Parsing a group of options: output url latest.jpg.
Applying option f (force format) with argument image2.
Successfully parsed a group of options.
Opening an output file: latest.jpg.
Successfully opened the file.
detected 1 logical cores
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'video_size' to value '1280x720'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'pix_fmt' to value '-1'
[buffer @ 0x12f9680] Unable to parse option value "-1" as pixel format
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'time_base' to value '1/90000'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'frame_rate' to value '180000/2'
[buffer @ 0x12f9680] Unable to parse option value "-1" as pixel format
[buffer @ 0x12f9680] Error setting option pix_fmt to value -1.
[graph 0 input from stream 0:0 @ 0x1298280] Error applying options to the filter.
Error opening filters!
Exiting normally, received signal 2.
</code>```

As you see, ffmpeg is able to read SDP metadata, but for some reason is unable to save a screenshot

Also same command works fine on my laptop with same VPN configuration!

Just in case, IP camera doesn't have a public IP address and accessible via VPN.

What could be wrong and how to debug?

I tried to increase -analyzeduration and -probesize options from default 5s to 30s, but it doesn't work.

答:
If you see.. the output contains below issue:

```<code>Failed to parse interval end specification ''
</code>```

So, ffmpeg is unable to find the range for start and end time for seeking rtp stream. It did not find all the required parameters (maybe corrupted). So, I hope it would be helpful to add some of below flags to your ffmpeg command from this and this discussion.

```<code>-pix_fmt yuv420p or -analyzeduration 2147483647 (some huge value)
</code>```

Body:
My task is to get a screenshot from IP camera rtsp stream via ffmpeg.
I got following error when I'm trying to do that on DigitalOcean droplet:

root@docker-512mb-fra1-01:~# ffmpeg -hide_banner -loglevel debug -i rtsp://10.132.193.9//ch0.h264 -f image2 latest.jpg
Splitting the commandline.
Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-i' ... matched as input url with argument 'rtsp://10.132.193.9//ch0.h264'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'image2'.
Reading option 'latest.jpg' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option hide_banner (do not show program banner) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url rtsp://10.132.193.9//ch0.h264.
Successfully parsed a group of options.
Opening an input file: rtsp://10.132.193.9//ch0.h264.
[rtsp @ 0x1298440] SDP:
v=0
o=- 1499314217993040 1 IN IP4 192.168.1.128
s=H.264 Program Stream, streamed by the LIVE555 Media Server
i=ch0.h264
t=0 0
a=DevVer:pusher2
a=GroupName:IPCAM
a=NickName:CIF
a=CfgSection:PROG_CHN0
a=tool:LIVE555 Streaming Media v2011.08.13
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:H.264 Program Stream, streamed by the LIVE555 Media Server
a=x-qt-text-inf:ch0.h264
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:4000
a=rtpmap:96 H264/90000
a=control:trackID=1
a=fmtp:96 packetization-mode=1;profile-level-id=64001F;sprop-parameter-sets=Z2QAH6wrUCgC3IA=,aO48MA==
a=framesize:96 1280-720
a=cliprect:0,0,1280,720
m=audio 0 RTP/AVP 97
a=rtpmap:97 mpeg4-generic/8000/2
a=fmtp:97 streamtype=5;profile-level-id=1;cpresent=0;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1590
a=control:trackID=2

Failed to parse interval end specification ''
[rtsp @ 0x1298440] video codec set to: h264
[rtsp @ 0x1298440] RTP Packetization Mode: 1
[rtsp @ 0x1298440] RTP Profile IDC: 64 Profile IOP: 0 Level: 1f
[rtsp @ 0x1298440] Extradata set to 0x1298a20 (size: 23)
[rtsp @ 0x1298440] audio codec set to: aac
[rtsp @ 0x1298440] audio samplerate set to: 8000
[rtsp @ 0x1298440] audio channels set to: 2
[udp @ 0x129e7e0] end receive buffer size reported is 131072
[udp @ 0x129e680] end receive buffer size reported is 131072
[udp @ 0x12bf380] end receive buffer size reported is 131072
[udp @ 0x12bf1c0] end receive buffer size reported is 131072
[rtsp @ 0x1298440] hello state=0
[rtsp @ 0x1298440] UDP timeout, retrying with TCP
[rtsp @ 0x1298440] hello state=0
[rtsp @ 0x1298440] Could not find codec parameters for stream 0 (Video: h264, 1 reference frame, none(left), 1280x720, 1/180000): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, rtsp, from 'rtsp://10.132.193.9//ch0.h264':
  Metadata:
    title           : H.264 Program Stream, streamed by the LIVE555 Media Server
    comment         : ch0.h264
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0, 0, 1/90000: Video: h264, 1 reference frame, none(left), 1280x720, 1/180000, 90k tbr, 90k tbn, 180k tbc
    Stream #0:1, 0, 1/8000: Audio: aac, 8000 Hz, stereo, fltp
Successfully opened the file.
Parsing a group of options: output url latest.jpg.
Applying option f (force format) with argument image2.
Successfully parsed a group of options.
Opening an output file: latest.jpg.
Successfully opened the file.
detected 1 logical cores
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'video_size' to value '1280x720'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'pix_fmt' to value '-1'
[buffer @ 0x12f9680] Unable to parse option value "-1" as pixel format
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'time_base' to value '1/90000'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x1298280] Setting 'frame_rate' to value '180000/2'
[buffer @ 0x12f9680] Unable to parse option value "-1" as pixel format
[buffer @ 0x12f9680] Error setting option pix_fmt to value -1.
[graph 0 input from stream 0:0 @ 0x1298280] Error applying options to the filter.
Error opening filters!
Exiting normally, received signal 2.

As you see, ffmpeg is able to read SDP metadata, but for some reason is unable to save a screenshot

Also same command works fine on my laptop with same VPN configuration!

Just in case, IP camera doesn't have a public IP address and accessible via VPN.

What could be wrong and how to debug?

I tried to increase -analyzeduration and -probesize options from default 5s to 30s, but it doesn't work.

Body:
If you see.. the output contains below issue:

Failed to parse interval end specification ''

So, ffmpeg is unable to find the range for start and end time for seeking rtp stream. It did not find all the required parameters (maybe corrupted). So, I hope it would be helpful to add some of below flags to your ffmpeg command from this and this discussion.

-pix_fmt yuv420p or -analyzeduration 2147483647 (some huge value)


问:
Yesterday's date in SSIS package setting in variable through expression
I am setting a variable in SSIS package and I'm using this expression:

```<code>DATEPART("yyyy", GETDATE())*10000
        + DATEPART("month", GETDATE())*100
        + DATEPART("day",GETDATE())
</code>```

The expression will give me a variable value like 'yyyymmdd'. My problem is that I want yesterday's date.

For example on 11/1/2014 it should be 20141031

答:
```<code>(DT_WSTR, 4) YEAR(GETDATE()) +RIGHT("0" + (DT_WSTR, 2) MONTH(GETDATE()),2) +RIGHT("0" + (DT_WSTR, 2) DATEPART("DD", DATEADD("day", -1, GETDATE())),2)
</code>```

Above will also give you date one day before. Main issue issue doing plus or minus gives truncation error in expression.

```<code>RIGHT("0" + (DT_WSTR, 2) DATEPART("DD", DATEADD("day", -1, GETDATE())),2)
</code>```

will not break the expression.

Body:
I am setting a variable in SSIS package and I'm using this expression:

DATEPART("yyyy", GETDATE())*10000
        + DATEPART("month", GETDATE())*100
        + DATEPART("day",GETDATE())

The expression will give me a variable value like 'yyyymmdd'. My problem is that I want yesterday's date.

For example on 11/1/2014 it should be 20141031

Body:
(DT_WSTR, 4) YEAR(GETDATE()) +RIGHT("0" + (DT_WSTR, 2) MONTH(GETDATE()),2) +RIGHT("0" + (DT_WSTR, 2) DATEPART("DD", DATEADD("day", -1, GETDATE())),2)

Above will also give you date one day before. Main issue issue doing plus or minus gives truncation error in expression.

RIGHT("0" + (DT_WSTR, 2) DATEPART("DD", DATEADD("day", -1, GETDATE())),2)

will not break the expression.


问:
Has wampserver installed properly?
I have downloaded wampserver, however I cannot open the application. When I do it comes back to the installation process. I see no icons thats changes colour. Have I installed the program incorrectly. Whats the best and easiest way?

I am trying to set phpmyadmin, however I am unable to do so, the information on the web seems to direct me towards installing wamp.

Are there other ways to get phpMyadmin locally?

I have successfully managed to install mysql and use this via command line.

答:
This is the simple run-down

Download wampserver from here WAMP

Run the installer all the way through

Go to 'unistall a program' in control panel and very wampserver is in the list

Run the application 'wampmanager.exe' should be in c:/wamp64/wampmanager

A 'W' icon shoud be in the the taskbar, left-click>Restart all services, should be green now

Again left-click>localhost will take you to your homepage index.html

If you get error 404 not found, right-click>tools>test port 80 If it says its used by another application, go back to the same menu and click "use a port other than 80", a windows comes up and type 8080, restart all services and repeat step 6.

Again left-click>phpMyAdmin will take you there, default password may be blank(as in empty) or 'root'

Title: Has wampserver installed properly?


问:
multiple images in div
Could not find anything on this for the life of me. I simply want to display 1 little icon, multiple times on the same row,
But want to rotate each instance a bit more then the last one. So by the end of the row, the last icon is completely flipped compared to the first icon.

Here is my attempt: (thanks)

```<code><div class="container">
    <p class="one">I don't</p><p class="two">really want </p><p class="three">any</p><p class="four">words here</p>
</div>

<style>
p.one {
  float:left;
  image: url("http://www.itel.am/assets/ico/iconsForSocials/gl.png");
}
p.two {
  float:right;
  background-image: url("http://www.itel.am/assets/ico/iconsForSocials/gl.png");
  transform: rotate(60deg);
}
p.three {
  float:right;
  background-image: url("http://www.itel.am/assets/ico/iconsForSocials/gl.png");
  transform: rotate(120deg);
}
p.four {
  float:right;
  background-image: url("http://www.itel.am/assets/ico/iconsForSocials/gl.png");
  transform: rotate(180deg);
}
</style>
</code>```

答:
Positioning system in a row can be achieved with 2 ways. The first and easy way is bootstrap grid system , so your problem could be solved like this

```<code><div class="container-fluid">
    <div class="col-sm-3">img</div>
    <div class="col-sm-3">img</div>
    <div class="col-sm-3">img</div>
    <div class="col-sm-3">img</div>
</div>
</code>```

Replace the img keyword i wrote with your  images and transform them as you like inside css and you will be all set.

The second and more advanced way to place images in a row inside a div is position css attribute.

```<code>position:relative;
top:40px;
left:70px;
</code>```

This will place the element in a specific place relative to its parent , so then you could place them wherever you want.

There are definitely more ways to do this like flexbox and more , but i totally recommend using bootstrap grid system because its easy to use and most of all responsive!

Title: multiple images in div

Body:
Could not find anything on this for the life of me. I simply want to display 1 little icon, multiple times on the same row,
But want to rotate each instance a bit more then the last one. So by the end of the row, the last icon is completely flipped compared to the first icon.

Here is my attempt: (thanks)

I don't

really want

any

words here

Body:
Positioning system in a row can be achieved with 2 ways. The first and easy way is bootstrap grid system , so your problem could be solved like this

<div class="container-fluid">
    <div class="col-sm-3">img</div>
    <div class="col-sm-3">img</div>
    <div class="col-sm-3">img</div>
    <div class="col-sm-3">img</div>
</div>

Replace the img keyword i wrote with your  images and transform them as you like inside css and you will be all set.

The second and more advanced way to place images in a row inside a div is position css attribute.

position:relative;
top:40px;
left:70px;

This will place the element in a specific place relative to its parent , so then you could place them wherever you want.

There are definitely more ways to do this like flexbox and more , but i totally recommend using bootstrap grid system because its easy to use and most of all responsive!


问:
Outlook 2013 'Run a script' rule has disappeared
I have some rules for work in outlook 2013 - however following my laptop crashing the other day, I can no longer run any rules, they simply do not work (I don't even get a debug notification). Upon checking my macros, I found that when I tried to click on any scripts I have and I keep getting the message 'This action is not available in the current mode'.
The option to create a new script has disappeared from the rule list too.

So far I have tried:
-Using the outlook 2016 fix by running the registry fix DWORD 1 (There is nothing out there for 2013). I have restarted my Pc and it still has not changed a thing.
-System restore to a previous date. This has literally changed nothing.

I'm a little stuck. I have attached screenshots to further explain exactly what I am experiencing.

Thanks,

Rachael

Some information has been whited out due to confidentiality.

Trust Centre Settings:

答:
here is a quick and dirty test to check whether vba code runs at all when email arrives

put it into "ThisOutLookSession" which is under  "Microsoft Office Outlook Objects"

then send yourself an email ... if vba runs then you should see a popup

it will not solve your problem, but it will provide more info to help narrow down the cause

```<code>Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    MsgBox "you have mail"
End Sub
</code>```

Body:
here is a quick and dirty test to check whether vba code runs at all when email arrives

put it into "ThisOutLookSession" which is under  "Microsoft Office Outlook Objects"

then send yourself an email ... if vba runs then you should see a popup

it will not solve your problem, but it will provide more info to help narrow down the cause

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    MsgBox "you have mail"
End Sub