问:
The best suggestion for a structure to store multiple keys and values - dictionaries?
The intention is to create the beginnings of a facebook type program (For teaching purposes) that stores a list of names of individuals along with their bio details.

I have two questions, one follows on from the next:

Question 1: How to get at the list values that are part of a value in a key value pair in a dictionary. For instance, to find out what friends John and Mary have in common, in this case friend1 and friend3

Question 2: The best method to create a structure that stores names,gender,hobbies,and friends? Would this be a dictionary and if so, how could this be defined? If not, what do people suggest?

```<code>#create a dictionary that stores names, and a list of friends
facebook_profile={"John":["friend1","friend2","friend3","friend4"],"Mary":["friend1","friend7","friend3","friend9"]}
print(facebook_profile)
</code>```

Required to store and subsequently print the following sample data:

```<code>Name:John
Gender: Male
Hobbies: Chess
Friends: friend1,friend2,friend3,friend4

Name: Mary
Gender: Female
Hobbies: Chequers
Friends: friend1,friend2,friend3,friend4
</code>```

I am aware the best solution would be a database and to use some sort of file handling to achieve it however, for teaching purposes we are trying to use only lists or dictionaries. These dictionaries/lists could then be written to a file, but the solution(s)/answers I am looking for must ideally be utilising only the list and dictionary structures.

答:
EDIT You edited your answer to state you want lists and dicts only, So maybe this is not for you, however, classes are the best way to achieve complicated storage of information about similar repetitive objects with many features, so i'll just leave this here

As this gets more and more complicated, nested dictionaries can be a real headache, I would suggest you define a class, something like this:

```<code>class Person()
    def __init__(self, name, gender):
        self.name = name
        self.gender = gender
</code>```

For that class you can define all sorts of methods, like finding friends in common:

```<code>class Person()
    def __init__(self, name, gender):
        self.name = name
        self.gender = gender
        self.friends = []
        self.hobbies = []
    def add_friends(self, list_of_friends):
        self.friends += list_of_friends
    def add_hobbies(self, list_of_hobbies):
        self.hobbies += list_of_hobbies
    def mutual_friends(self, another_person):
        return list(set(another_person.friends).intersection(self.friends))
</code>```

Then all you have to do is initialize each friend and start running all sorts of methods

```<code>john = Person('John', 'Male')
john.add_friends(['friend1', 'friend2', ...]
mary = Person('Mary', 'Female')
mary.add_friends(['friend3', 'friend7', ...]
common_friends = john.mutual_friends(mary)
print(common_friends) # Will print a list of mutual friends
</code>```

And like others said, for long lists of friends a more efficient way is to use set with intersection

Body:
The intention is to create the beginnings of a facebook type program (For teaching purposes) that stores a list of names of individuals along with their bio details.

I have two questions, one follows on from the next:

Question 1: How to get at the list values that are part of a value in a key value pair in a dictionary. For instance, to find out what friends John and Mary have in common, in this case friend1 and friend3

Question 2: The best method to create a structure that stores names,gender,hobbies,and friends? Would this be a dictionary and if so, how could this be defined? If not, what do people suggest?

#create a dictionary that stores names, and a list of friends
facebook_profile={"John":["friend1","friend2","friend3","friend4"],"Mary":["friend1","friend7","friend3","friend9"]}
print(facebook_profile)

Required to store and subsequently print the following sample data:

Name:John
Gender: Male
Hobbies: Chess
Friends: friend1,friend2,friend3,friend4

Name: Mary
Gender: Female
Hobbies: Chequers
Friends: friend1,friend2,friend3,friend4

I am aware the best solution would be a database and to use some sort of file handling to achieve it however, for teaching purposes we are trying to use only lists or dictionaries. These dictionaries/lists could then be written to a file, but the solution(s)/answers I am looking for must ideally be utilising only the list and dictionary structures.

Body:
EDIT You edited your answer to state you want lists and dicts only, So maybe this is not for you, however, classes are the best way to achieve complicated storage of information about similar repetitive objects with many features, so i'll just leave this here

As this gets more and more complicated, nested dictionaries can be a real headache, I would suggest you define a class, something like this:

class Person()
    def __init__(self, name, gender):
        self.name = name
        self.gender = gender

For that class you can define all sorts of methods, like finding friends in common:

class Person()
    def __init__(self, name, gender):
        self.name = name
        self.gender = gender
        self.friends = []
        self.hobbies = []
    def add_friends(self, list_of_friends):
        self.friends += list_of_friends
    def add_hobbies(self, list_of_hobbies):
        self.hobbies += list_of_hobbies
    def mutual_friends(self, another_person):
        return list(set(another_person.friends).intersection(self.friends))

Then all you have to do is initialize each friend and start running all sorts of methods

john = Person('John', 'Male')
john.add_friends(['friend1', 'friend2', ...]
mary = Person('Mary', 'Female')
mary.add_friends(['friend3', 'friend7', ...]
common_friends = john.mutual_friends(mary)
print(common_friends) # Will print a list of mutual friends

And like others said, for long lists of friends a more efficient way is to use set with intersection


来源: stackexchange

问:
Mpdf bulk data loading issue
I am using mpdf for pdf export. Its working fine for me. But while trying to load bulk data with mpdf it showing memory exhausted error. I have tried to print all data before writing to mpdf. It showing all data correctly. but while trying to load these data in mpdf it showing above error. Anybody can support me to solve this issue?</p>

答:
```<code>ini_set('memory_limit', '1024M');
</code>```

Add this line
OR
Increase memory limit in php.ini file

```<code> memory_limit = 256M
</code>```

ContentLicense: CC BY-SA 3.0

Title: Mpdf bulk data loading issue

Body:
ini_set('memory_limit', '1024M');

Add this line
OR
Increase memory limit in php.ini file

 memory_limit = 256M


问:
aframe camera switch between exit vr and enter vr
how is it possible to switch between the camera on desktop and VR?
i wanna use  the mouse-cursor on desktop and when i enter VR  it should switch to another camera with cursor-fusing.

here is my code:

```<code><a-entity id="cam-desktop" camera="userHeight: 1.6; zoom:1 " look-controls mouse-cursor>
</a-entity>

<a-entity id="cam-vr" camera="userHeight: 1.6; zoom:1 " look-controls>
    <a-animation begin="cursor-fusing" delay=" 3000" attribute="camera.zoom" from="1" to="4" dur="1000"></a-animation>
  <a-animation begin="click" delay="500" attribute="camera.zoom" from="4" to="1" dur="1000"></a-animation>
    <a-entity cursor="fuse: true; fuseTimeout:4000" geometry="primitive: ring; radiusInner: 0.02; radiusOuter: 0.03; thetaLength: 360; thetaStart: 0" rotation="0 0 90" position="0 0 -1" material="color: black; side: double; shader: flat">
    <a-animation begin="cursor-fusing" attribute="geometry.thetaLength" from="360" to="0" easing="linear" dur="3000"></a-animation>
    <a-animation begin="mouseleave" attribute="geometry.thetaLength" from="360" to="360" dur="0"></a-animation>
    </entity>
</a-entity>
</code>```

thank you very much!

答:
You can create a component, which listenes to the 'enter-vr' and 'exit-vr' events, and set the active camera accordingly:

```<code>AFRAME.registerComponent('scenelistener',{
   init:function(){
      let vrcam = document.querySelector("#cam-vr");
      let dcam = document.querySelector("#cam-desktop");
      let  vrmode = false;
      this.el.sceneEl.addEventListener('enter-vr',function(){
           if(!vrmode){
               dcam.setAttribute('active',false);
               vrcam.setAttribute('active',true);
               vrmode!=vrmode;
           }
      }
      this.el.sceneEl.addEventListener('exit-vr',function(){
           if(vrmode){
               dcam.setAttribute('active',true);
               vrcam.setAttribute('active',false);
               vrmode!=vrmode;
           }
      }
  }
});
</code>```

Actually, You can just paste the listeners anywhere, moreover You could just listen to any event and do stuff accordingly to the received event, I just wanted to show You the concept.
Im not sure what happens if 2+ camera's are active, so i made them false on change.

UPDATE

I did not see that the cameras are entities, not primitives, so You have to set the attribute like this: setAttribute('camera','active',true)

I have some issues with the cursor, so i make it visible and invisible, depending on the vr state.

Working fiddle ( at least the camera switch ) here.

Body:
how is it possible to switch between the camera on desktop and VR?
i wanna use  the mouse-cursor on desktop and when i enter VR  it should switch to another camera with cursor-fusing.

here is my code:

    </entity>

thank you very much!

Body:
You can create a component, which listenes to the 'enter-vr' and 'exit-vr' events, and set the active camera accordingly:

AFRAME.registerComponent('scenelistener',{
   init:function(){
      let vrcam = document.querySelector("#cam-vr");
      let dcam = document.querySelector("#cam-desktop");
      let  vrmode = false;
      this.el.sceneEl.addEventListener('enter-vr',function(){
           if(!vrmode){
               dcam.setAttribute('active',false);
               vrcam.setAttribute('active',true);
               vrmode!=vrmode;
           }
      }
      this.el.sceneEl.addEventListener('exit-vr',function(){
           if(vrmode){
               dcam.setAttribute('active',true);
               vrcam.setAttribute('active',false);
               vrmode!=vrmode;
           }
      }
  }
});

Actually, You can just paste the listeners anywhere, moreover You could just listen to any event and do stuff accordingly to the received event, I just wanted to show You the concept.
Im not sure what happens if 2+ camera's are active, so i made them false on change.

UPDATE

I did not see that the cameras are entities, not primitives, so You have to set the attribute like this: setAttribute('camera','active',true)

I have some issues with the cursor, so i make it visible and invisible, depending on the vr state.

Working fiddle ( at least the camera switch ) here.


问:
Gradle task for local tomcat deployment
I have written a task for deploying war file in my local tomcat instance. I have few issues in it and need help in it.

Following is gradle task-

```<code>task deploy (dependsOn: build){
    delete 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT', 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT.war'
    copy {
        from "build/libs"
        into "D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps"
        include "ROOT.war"
    }
}
</code>```

Issue I am facing every time I run deploy task, its updating ROOT.war file but the contents of ROOT directory is not updated

I have checked the timestamps of file to determine which files are updated.

Thanks in advance for help!

答:
I had figured in out, I need to wrap the tasks in doLast{} block. So final tasks looks like- </p>

```<code>task deploy (dependsOn: build){
  doLast{
    delete 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT', 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT.war'
    copy {
        from "build/libs"
        into "D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps"
        include "ROOT.war"
    }
  }
}
</code>```

Title: Gradle task for local tomcat deployment

Body:
I have written a task for deploying war file in my local tomcat instance. I have few issues in it and need help in it.

Following is gradle task-

task deploy (dependsOn: build){
    delete 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT', 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT.war'
    copy {
        from "build/libs"
        into "D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps"
        include "ROOT.war"
    }
}

Issue I am facing every time I run deploy task, its updating ROOT.war file but the contents of ROOT directory is not updated

I have checked the timestamps of file to determine which files are updated.

Thanks in advance for help!

Body:
I had figured in out, I need to wrap the tasks in doLast{} block. So final tasks looks like-

task deploy (dependsOn: build){
  doLast{
    delete 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT', 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT.war'
    copy {
        from "build/libs"
        into "D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps"
        include "ROOT.war"
    }
  }
}


问:
JavaScript JQuery Ajax Issue: POST Works fine in Firefox, IE, Safari but not Chrome
I'm new to JavaScript, and working on a hobby project with a few developers. We have a simple page that is used to submit requests to a database.

I decided to try learning JQuery, and started implementing some AJAX functionality into this request page. It works fine in FireFox, IE and Safari, but for some odd reason, I can't get it to work in Chrome.

I've been debugging it for a couple of hours now, and I have no idea why it's not working. Here's the relevant part of the HTML form (post action removed due to JavaScript):

```<code>        <form method="POST">
            <input type="text" name="amount" value="0" size="7" />
            <input type="submit" value="Fulfill!" /><br />
            <input type="hidden" name="index" value="69" />
            <input type="hidden" name="item" value="Iron Ore" />
        </form>
</code>```

And here's the PHP form that it posts to:

```<code><?php
require_once("../classes/Database.php");
$database = new Database();

$amount = $database->sanitizeString($_POST['amount']);
$index = $database->sanitizeString($_POST['index']);
$username = $database->sanitizeString($_POST['username']);
$item =  $database->sanitizeString($_POST['item']);
$database->connect();
$database->setRequest($amount, $index, $username, $item);
$database->setKarma($username, $amount, $item);
?>
</code>```

And most importantly, here's my newbie JavaScript code that's simply in the HTML file:

```<code><script language="JavaScript">
    var amount = 0;
    var index = 0;
    var item = 0;
    var username = "";
    var data = "";
    $(document).ready(function(){
        $("form input[type=submit]").click(function(){
            amount = $(this).siblings("input[name=amount]").val();
            index = $(this).siblings("input[name=index]").val();
            item = $(this).siblings("input[name=item]").val();
            username = "<?=$_SESSION['username']; ?>";
            //var stuff = $.post("pages/ajaxfulfill.php", {amount:amount,index:index,item:item, username:username}, function(data){alert(data)}, "html");
            var stuff = $.ajax(
                                    {
                                        url: "pages/ajaxfulfill.php",
                                        type: "POST", data:"amount=" + amount + "&index=" + index + "&item=" + item + "&username=" + username,
                                        success: function(data)
                                        {
                                            alert("Success")
                                        },
                                        error: function (XMLHttpRequest, textStatus, errorThrown)
                                        {
                                            alert("error" + XMLHttpRequest.status);
                                            alert("error" + XMLHttpRequest.responseText);
                                        }
                                    }
                               )
            $(this).parents("td").text("Submitted");

        });

    });

</script>
</code>```

At first, I was using the commented out $.post function, which works with the above mentioned browsers. I attempted to switch to the $.ajax function during my debug process, and found out that FF, IE, and Safari always return a "Success" alert, whereas Chrome is returning an Error with status 0 and a blank response.

Being a JavaScript newbie, I'm completely lost at why this would fail. If anyone could point me in the right direction, you'll have my profound respect and well wishes. Thanks.

答:
I realise this is an old post, but I have just had similar symptoms in my project and ended up here trying to find a solution.

I followed some of the advice here about debugging and realised that Chrome does not update the same as other browsers. Changes I had made in the js code, and css were instantly updated in Safari and Firefox with a normal refresh, but Chrome needs a Hard Reload and Cache clear before it updated those same items.

I'm not saying this is the cure for all the issues mentioned above, but it solved my problem.

ContentLicense: CC BY-SA 2.5

Body:
I'm new to JavaScript, and working on a hobby project with a few developers. We have a simple page that is used to submit requests to a database.

I decided to try learning JQuery, and started implementing some AJAX functionality into this request page. It works fine in FireFox, IE and Safari, but for some odd reason, I can't get it to work in Chrome.

I've been debugging it for a couple of hours now, and I have no idea why it's not working. Here's the relevant part of the HTML form (post action removed due to JavaScript):

        <form method="POST">
            <input type="text" name="amount" value="0" size="7" />
            <input type="submit" value="Fulfill!" />

            <input type="hidden" name="index" value="69" />
            <input type="hidden" name="item" value="Iron Ore" />
        </form>

And here's the PHP form that it posts to:

<?php
require_once("../classes/Database.php");
$database = new Database();

$amount = $database->sanitizeString($_POST['amount']);
$index = $database->sanitizeString($_POST['index']);
$username = $database->sanitizeString($_POST['username']);
$item =  $database->sanitizeString($_POST['item']);
$database->connect();
$database->setRequest($amount, $index, $username, $item);
$database->setKarma($username, $amount, $item);
?>

And most importantly, here's my newbie JavaScript code that's simply in the HTML file:

At first, I was using the commented out $.post function, which works with the above mentioned browsers. I attempted to switch to the $.ajax function during my debug process, and found out that FF, IE, and Safari always return a "Success" alert, whereas Chrome is returning an Error with status 0 and a blank response.

Being a JavaScript newbie, I'm completely lost at why this would fail. If anyone could point me in the right direction, you'll have my profound respect and well wishes. Thanks.


问:
get value DIV in PHP
I want to get DIV contents in PHP to submit a form.

```<code><div id="hello"></div>
</code>```

In my search, I was advised to use <input type="hidden" but I do not know how to do.

答:
If you don't want to use an input field to show a value (perhaps because you don't want the user to modify it or for styling reasons). You can display it in a div, and pass the value with the form submission by duplicating the value in a hidden input positioned inside your form.  The div may be inside or outside your form.</p>

```<code><div id="user">Jaber</div>
<form>
    ... any other form fields
    <input type="hidden" name="user" value="Jaber">
    ... submit button
</form>
</code>```

Title: get value DIV in PHP

Body:
I want to get DIV contents in PHP to submit a form.

In my search, I was advised to use <input type="hidden" but I do not know how to do.

Body:
If you don't want to use an input field to show a value (perhaps because you don't want the user to modify it or for styling reasons). You can display it in a div, and pass the value with the form submission by duplicating the value in a hidden input positioned inside your form.  The div may be inside or outside your form.

<div id="user">Jaber</div>
<form>
    ... any other form fields
    <input type="hidden" name="user" value="Jaber">
    ... submit button
</form>


问:
Don't change URL on Place change in GWT
i have a question about GWT. In GWT when i navigate to a new Place it changes URL address in browser bar. So is  there any solution to not change the URL when going to new Place. Code example with goTo method is below.</p>

```<code>@Override
public void onFailure(Throwable caught) {
      super.onFailure(caught);
      ForbiddenPlace forbiddenPlace = new ForbiddenPlace();
      goTo(forbiddenPlace);
}
</code>```

答: If you use the PlaceController.goTo method, it will fire a PlaceChangeEvent in the eventBus, this will be used by both PlaceHistoryHandler and ActivityManager. It is the PlaceHistoryHandler the one that is updating the URL (Historian), so... if you just want to show the place without updating the URL (Historian) you can manually supply the place to your ActivityManager using ActivityManager.onPlaceChange(new PlaceChangeEvent(new ForbiddenPlace())).

Title: Don't change URL on Place change in GWT

Body:
i have a question about GWT. In GWT when i navigate to a new Place it changes URL address in browser bar. So is  there any solution to not change the URL when going to new Place. Code example with goTo method is below.

@Override
public void onFailure(Throwable caught) {
      super.onFailure(caught);
      ForbiddenPlace forbiddenPlace = new ForbiddenPlace();
      goTo(forbiddenPlace);
}


问:
Enable event handler?
Fellow sufferers

I wish to use event handling when someone selects a cell. I made an eventhandler function which starts like:

```<code>Private Sub Worksheet_SelectionChange(ByVal Target As Range)
</code>```

The eventhandler does not get called when i change cell. Do I need to enable event handling or what am I doing wrong?

BW Peter Bunde Hansen

答:
To add an event handler for selection change on Sheet 1, ensure you are in the module for the correct sheet and use the below code:

```<code>Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub
</code>```

To add an event handler for the entire workbook to get a selection change in any sheet, ensure you are in the ThisWorkbook module and use the below:

```<code>Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

End Sub
</code>```

Title: Enable event handler?

Body:
Fellow sufferers

I wish to use event handling when someone selects a cell. I made an eventhandler function which starts like:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

The eventhandler does not get called when i change cell. Do I need to enable event handling or what am I doing wrong?

BW Peter Bunde Hansen

Body:
To add an event handler for selection change on Sheet 1, ensure you are in the module for the correct sheet and use the below code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

To add an event handler for the entire workbook to get a selection change in any sheet, ensure you are in the ThisWorkbook module and use the below:

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

End Sub


问:
Hive QL Collection items terminated by '$'
I am creating an external table customer with customer id, name and spouse name.

```<code> CREATE TABLE customer(cust id, name struct<fname:string,lname:string>,spouse_name struct<fname:string,lname:string>
    )row format delimited
    fields terminated by ','
    collection items terminated by '$';
</code>```

I am wondering what if incoming data comes something like this

```<code>1,FNAME1$LNAME1,SPOUSE_FNAME1#SPOUSE_LNAME1
2,FNAME2$LNAME2,SPOUSE_FNAME2#SPOUSE_LNAME2
</code>```

I cannot have two delimiters in 'collection items' statement. '$' delimiter would only separate FNAME* and LNAME*. It won't do anything with SPOUSE_FNAME* and SPOUSE_LNAME*. Do we need to write a custom serde for this? I am not sure how data would look like in real world but it is very possible that at some point of time we can get data like this.

Body:
I am creating an external table customer with customer id, name and spouse name.

 CREATE TABLE customer(cust id, name struct<fname:string,lname:string>,spouse_name struct<fname:string,lname:string>
    )row format delimited
    fields terminated by ','
    collection items terminated by '$';

I am wondering what if incoming data comes something like this

1,FNAME1$LNAME1,SPOUSE_FNAME1#SPOUSE_LNAME1
2,FNAME2$LNAME2,SPOUSE_FNAME2#SPOUSE_LNAME2

I cannot have two delimiters in 'collection items' statement. '$' delimiter would only separate FNAME* and LNAME*. It won't do anything with SPOUSE_FNAME* and SPOUSE_LNAME*. Do we need to write a custom serde for this? I am not sure how data would look like in real world but it is very possible that at some point of time we can get data like this.

Body:
One possible approach is loading the structs as simple strings and doing the data manipulation within a view.

create external table customer
(
    cust_id     int
   ,name        string
   ,spouse_name string
)
    row format delimited
    fields terminated by ','
;

select * from customer
;

+---------+---------------+-----------------------------+
| cust_id |     name      |         spouse_name         |
+---------+---------------+-----------------------------+
|       1 | FNAME1$LNAME1 | SPOUSE_FNAME1#SPOUSE_LNAME1 |
|       2 | FNAME2$LNAME2 | SPOUSE_FNAME2#SPOUSE_LNAME2 |
+---------+---------------+-----------------------------+

create view customer_v
as
select  cust_id
       ,named_struct('fname',name[0]       ,'lname',name[1])        as name
       ,named_struct('fname',spouse_name[0],'lname',spouse_name[1]) as spouse_name

from   (select  cust_id
               ,split(name,'\\$')       as name
               ,split(spouse_name,'#')  as spouse_name

        from    customer
        ) c
;

select * from customer_v
;

+---------+-------------------------------------+---------------------------------------------------+
| cust_id |                name                 |                    spouse_name                    |
+---------+-------------------------------------+---------------------------------------------------+
|       1 | {"fname":"FNAME1","lname":"LNAME1"} | {"fname":"SPOUSE_FNAME1","lname":"SPOUSE_LNAME1"} |
|       2 | {"fname":"FNAME2","lname":"LNAME2"} | {"fname":"SPOUSE_FNAME2","lname":"SPOUSE_LNAME2"} |
+---------+-------------------------------------+---------------------------------------------------+


问:
Practical problems of artificial intelligence on client side
Can anybody provide me with examples of front-end problems that could be solved by means of artificial intelligence models (neural networks, fuzzy logic, genetic algorithms)?

The only thing I've found is "Optimization of web newspaper layout in real time" (http://hera.ugr.es/doi/15001684.pdf)

I would be very pleased if you provide me with more practically relevant problems.

答:
Well, any problem that has a wide range of possible solutions which can be discovered and optimized faster by an AI algorithm than a human...

I'll just throw some random ideas out there:

Classifying users based on user behaviours (time spent on pages, links clicked, mouse positions, all sorts of other measurable facets of user behaviour). You might want to classify them in all sorts of dimensions, the possibilities are basically endless.

Interactive simulations with agents driven using neural networks and genetic algorithms.

Classification of user drawn images.

Sentiment analysis.

You can do whatever AI stuff you want on client side. The question you should ask is when to do it client side and when to do it server side. Obviously if you want to keep  your algorithms safe then don't write them in Javascript that can be viewed client side. If you need to have reliable performance, don't do it client side.


问:
Gtk2Hs : Missing functions when migrating from Gtk2 to Gtk3
I wrote a Haskell program with Gtk2Hs dealing with Gtk2. But when I tried to build my program with Gtk3, GHC complains about missing functions which doesn't exist anymore :

```<code>• Variable not in scope:
    widgetGetSize :: GtkGL.GLDrawingArea -> IO (Integer, Integer)

• Variable not in scope:
    renderWithDrawable :: t1 -> Render () -> IO ()
</code>```

Do you know if there are functions in Gtk3 which could replace these functions ?

Is there another way in Gtk3 to get the size of a widget ?

Note : I still can build my program with Gtk2 but I woulk like to anticipate a full migration to Gtk3

答:
GtkGLArea — A widget for custom drawing with OpenGL

API: ( C ) ( Vala )

GtkGLArea is a widget that allows drawing with OpenGL.

GtkGLArea sets up its own GdkGLContext for the window it creates, and
  creates a custom GL framebuffer that the widget will do GL rendering
  onto. It also ensures that this framebuffer is the default GL
  rendering target when rendering.

In order to draw, you have to connect to the “render” signal, or
  subclass GtkGLArea and override the GtkGLAreaClass.render() virtual
  function.

The GtkGLArea widget ensures that the GdkGLContext is associated with
  the widget's drawing area, and it is kept updated when the size and
  position of the drawing area changes.

GtkWidget Size

To get the widget size, use the GtkAllocation getters. Notice that GtkWidget has request size methods but the allocated size may differ.

Width: ( C ) ( Vala )

Height: ( C ) ( Vala )

GtkAllocation: ( C ) ( Vala )

Body:
I wrote a Haskell program with Gtk2Hs dealing with Gtk2. But when I tried to build my program with Gtk3, GHC complains about missing functions which doesn't exist anymore :

• Variable not in scope:
    widgetGetSize :: GtkGL.GLDrawingArea -> IO (Integer, Integer)

• Variable not in scope:
    renderWithDrawable :: t1 -> Render () -> IO ()

Do you know if there are functions in Gtk3 which could replace these functions ?

Is there another way in Gtk3 to get the size of a widget ?

Note : I still can build my program with Gtk2 but I woulk like to anticipate a full migration to Gtk3


问:
Linq Query C# ( Multiple Occurrences in String array)
Guys I know this might be a naive Question but i got to ask.
I have array of string
List<string> lstPets = new List<string> { "dog", "cat","horse","parrot" };

And a string

string paragraph = "This is a test script to test whether a dog exists or not";

Now I have to write a linq query to find whether any occurrence of "lstPets" in "paragrah".

Thanks in advance. :)

答:
```<code>var sentenceQuery = from item in paragraph
                        let w = item .Split(new char[] { '.', '?', '!', ' ', ';', ':', ',' },                                          StringSplitOptions.RemoveEmptyEntries)
                        where w.Distinct().Intersect(IsPets).Count() == IsPets.Count()
                        select item ;
    foreach (string str in sentenceQuery)
    {
        Console.WriteLine(str);
    }
</code>```


问:
Android Textview Scrolling Issue
Firstly, I am new to android so if I have missed something basic I do apologise.

I have created a GridView to store some information. The GridView consists of a 3x6 grid. In each cell, there is an image and text directly under the image. As the GridView is so large I have implemented a scrollbar.

This is how the page should look normally and is when first loaded/selected :

Everything looks wonderful, however, when I scroll down to the bottom and then back up, the text seems to wrap up and then push the image out of place. I am not sure why this is?

This is how the page looks after I have scrolled down and they scroll back up :

For the GridView, I have an XML file with the GridView itself along with a TextView at the very top called content_rewards.xml. I have also create an XML file for each picture/text in the grid itself called relics_gridlayout.xml. I believe I am probably missing a property of the TextViews in either one of these files, however, I am not sure which one or which property. I don't think it has anything to do with the grid or adapter itself hence I will not include that code.

content_rewards.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fitsSystemWindows="true"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="25dp">

<GridView
    android:id="@+id/customgrid"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_below="@+id/os_texts"
    android:columnWidth="100dp"
    android:numColumns="auto_fit"
    android:stretchMode="spacingWidthUniform"
    android:verticalSpacing="35dp"
    android:scrollbars="horizontal"
    tools:layout_constraintTop_creator="1"
    android:layout_marginTop="116dp"
    tools:layout_constraintLeft_creator="1"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent"/>

<TextView
    android:id="@+id/textView4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="B = 0   S = 0   G = 0"
    android:textSize="24sp"
    tools:layout_constraintRight_creator="1"
    tools:layout_constraintBottom_creator="1"
    app:layout_constraintBottom_toTopOf="@+id/customgrid"
    app:layout_constraintRight_toRightOf="parent"
    tools:layout_constraintLeft_creator="1"
    android:layout_marginBottom="8dp"
    app:layout_constraintLeft_toLeftOf="parent"/>
</android.support.constraint.ConstraintLayout>
</code>```

relics_gridlayout.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="3dp">

<ImageView
    android:id="@+id/os_images"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:src="@mipmap/ic_launcher" />

<TextView
    android:layout_below="@+id/os_images"
    android:id="@+id/os_texts"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="This is Just Dummy Text"
    android:textAlignment="center"
    android:textSize="18dp"
    android:textStyle="bold"/>

</RelativeLayout>
</code>```

Any help would be great. Thanks.

答:
```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ECEFF1"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".MainActivity"
    tools:showIn="@layout/app_bar_main">

    <GridView
        android:id="@+id/grd1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:gravity="center"
        android:horizontalSpacing="6dp"
        android:numColumns="auto_fit"
        android:stretchMode="columnWidth"
        android:verticalSpacing="6dp">

    </GridView>

</RelativeLayout>
</code>```

This should solve your problem.

The scrolling view behavior will handle the scrolling irrespective of the size

Now add the Text view out of the Relative layout to view it always.

Or have a parent as Nested scrolling View and allow the nested scrolling enabled as false

```<code>setNestedScrollingEnabled(false)
</code>```

A sample from my code that I already have used successfully to resolve such issue

Use your Grid view instead of Recycler View.

If you want the Item Text View to be always of 2 lines then set munLines="2" in the item Layout

```<code><android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_container_reports"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.AppCompatTextView
                    android:id="@+id/tab_header"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="8dp"
                    android:text="@string/user_reports"
                    android:textAllCaps="true"
                    android:textColor="@color/colorPrimaryDark"
                    android:textSize="@dimen/tab_label"
                    app:textAllCaps="true" />

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/reports_recycler"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fadeScrollbars="false"
                        android:nestedScrollingEnabled="false"
                        android:padding="4dp" />
                </RelativeLayout>
            </LinearLayout>
        </android.support.v4.widget.NestedScrollView>
    </android.support.v4.widget.SwipeRefreshLayout>
</code>```

Title: Android Textview Scrolling Issue

Body:
Firstly, I am new to android so if I have missed something basic I do apologise.

I have created a GridView to store some information. The GridView consists of a 3x6 grid. In each cell, there is an image and text directly under the image. As the GridView is so large I have implemented a scrollbar.

This is how the page should look normally and is when first loaded/selected :

Everything looks wonderful, however, when I scroll down to the bottom and then back up, the text seems to wrap up and then push the image out of place. I am not sure why this is?

This is how the page looks after I have scrolled down and they scroll back up :

For the GridView, I have an XML file with the GridView itself along with a TextView at the very top called content_rewards.xml. I have also create an XML file for each picture/text in the grid itself called relics_gridlayout.xml. I believe I am probably missing a property of the TextViews in either one of these files, however, I am not sure which one or which property. I don't think it has anything to do with the grid or adapter itself hence I will not include that code.

content_rewards.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fitsSystemWindows="true"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="25dp">

<GridView
    android:id="@+id/customgrid"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_below="@+id/os_texts"
    android:columnWidth="100dp"
    android:numColumns="auto_fit"
    android:stretchMode="spacingWidthUniform"
    android:verticalSpacing="35dp"
    android:scrollbars="horizontal"
    tools:layout_constraintTop_creator="1"
    android:layout_marginTop="116dp"
    tools:layout_constraintLeft_creator="1"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent"/>

<TextView
    android:id="@+id/textView4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="B = 0   S = 0   G = 0"
    android:textSize="24sp"
    tools:layout_constraintRight_creator="1"
    tools:layout_constraintBottom_creator="1"
    app:layout_constraintBottom_toTopOf="@+id/customgrid"
    app:layout_constraintRight_toRightOf="parent"
    tools:layout_constraintLeft_creator="1"
    android:layout_marginBottom="8dp"
    app:layout_constraintLeft_toLeftOf="parent"/>
</android.support.constraint.ConstraintLayout>

relics_gridlayout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="3dp">

<ImageView
    android:id="@+id/os_images"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:src="@mipmap/ic_launcher" />

<TextView
    android:layout_below="@+id/os_images"
    android:id="@+id/os_texts"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="This is Just Dummy Text"
    android:textAlignment="center"
    android:textSize="18dp"
    android:textStyle="bold"/>

</RelativeLayout>

Any help would be great. Thanks.

Body:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ECEFF1"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".MainActivity"
    tools:showIn="@layout/app_bar_main">

    <GridView
        android:id="@+id/grd1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:gravity="center"
        android:horizontalSpacing="6dp"
        android:numColumns="auto_fit"
        android:stretchMode="columnWidth"
        android:verticalSpacing="6dp">

    </GridView>

</RelativeLayout>

This should solve your problem.

The scrolling view behavior will handle the scrolling irrespective of the size

Now add the Text view out of the Relative layout to view it always.

Or have a parent as Nested scrolling View and allow the nested scrolling enabled as false

setNestedScrollingEnabled(false)

A sample from my code that I already have used successfully to resolve such issue

Use your Grid view instead of Recycler View.

If you want the Item Text View to be always of 2 lines then set munLines="2" in the item Layout

<android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_container_reports"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.AppCompatTextView
                    android:id="@+id/tab_header"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="8dp"
                    android:text="@string/user_reports"
                    android:textAllCaps="true"
                    android:textColor="@color/colorPrimaryDark"
                    android:textSize="@dimen/tab_label"
                    app:textAllCaps="true" />

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/reports_recycler"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fadeScrollbars="false"
                        android:nestedScrollingEnabled="false"
                        android:padding="4dp" />
                </RelativeLayout>
            </LinearLayout>
        </android.support.v4.widget.NestedScrollView>
    </android.support.v4.widget.SwipeRefreshLayout>


问:
Why doesn't `Box::new` return an `Option` or `Result`?
I don't understand why Box::new doesn't return an Option or Result.

The allocation can fail because memory is not unlimited, or something else could happen; what is the behavior in such cases? I can't find any information about it.

答:
A more general form is What to do on Out Of Memory (OOM)?

There are many difficulties in handling OOM:

detecting it,

recovering from it (gracefully),

integrating it in the language (gracefully).

The first issue is detecting it. Many OSes today will, by default, use swap space. In this case, your process is actually in trouble way before you get to the OOM situation because starting to use swap space will significantly slow down the process. Other OSes will kill low-priority processes when a higher process requires more memory (OOM killer), or promise more memory than they currently have in the hope it will not be used or will be available by the time it is necessary (overcommit), etc...

The second issue is recovering. At the process level, the only way to recover is to free memory... without allocating any in the mean time. This is not as easy as it sounds, for example there is no guarantee that panicking and unwinding will not require allocating memory (for example, the act of storing a panic message could allocate if done carelessly). This is why the current rustc runtime aborts by default on OOM.

The third issue is language integration: memory allocations are everywhere. Any use of Box, Vec, String, etc... So, if you shun the panic route and use the Result route instead, you need to tweak nearly any mutating method signature to account for this kind of failure, and this will bubble in all interfaces.

Finally, it's notable that in domains where memory allocation failure need be handled... often times memory allocation is not allowed to start with. In critical embedded software, for example, all memory is allocated up-front and there is a proof that no more than what is allocated will be required.

This is important, because it means that there are very few situations where (1) dynamic memory allocation is allowed and (2) its failure must be handled gracefully by the process itself.

And at this point, one can only wonder how much complexity budget should be spent on this, and how much complexity this will push unto the 99% of programs which do not care.


问:
How to find overlapping patterns in a regex?
Suppose I have a string like this 123456789. Is there any way to find the every possible existing pattern from the given string like this

1234, 2345, 3456,4567, 5678, 6789 using regex

I did this but couldn't figure out the solution:

```<code>import re
regex = r"[1-9]{4}"
test_string = "123456789"
print(re.findall(regex, test_str))
</code>```

this outputs:

```<code>['1234', '5678']
</code>```

Any help will mean a lot to me, Thanks

答:
You can try this regex:

```<code>\d(?=(\d{3}))
</code>```

Regex Demo

Sample Source (Run here )

```<code>import re
regex = r"\d(?=(\d{3}))"
test_str = "123456789"
matches = re.finditer(regex, test_str)

for match in matches:
 print(match.group()+match.group(1));
</code>```

Body:
Suppose I have a string like this 123456789. Is there any way to find the every possible existing pattern from the given string like this

1234, 2345, 3456,4567, 5678, 6789 using regex

I did this but couldn't figure out the solution:

import re
regex = r"[1-9]{4}"
test_string = "123456789"
print(re.findall(regex, test_str))

this outputs:

['1234', '5678']

Any help will mean a lot to me, Thanks

Body:
You can try this regex:

\d(?=(\d{3}))

Regex Demo

Sample Source (Run here )

import re
regex = r"\d(?=(\d{3}))"
test_str = "123456789"
matches = re.finditer(regex, test_str)

for match in matches:
 print(match.group()+match.group(1));


问:
Having issues installing nodejs/npm
I've completely uninstalled nodejs/npm both.

However they seem to be throwing same error consistently whilst installing.
I've also tried sudo-apt get update
sudo apt cache verify and apt cache search, when I search nodejs is not found or npm.

```<code>The program 'nodejs' is currently not installed. You can install it by typing:
sudo apt-get install nodejs
</code>```

And when I do sudo apt-get intall nodejs

```<code>Reading package lists... Done
Building dependency tree
Reading state information... Done
Package nodejs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'nodejs' has no installation candidate
</code>```

I've made sure nodejs/npm is removed from /usr/bin etc. Still doesn't seem to be working at all.

答: Try apt-get updateto update the list.

Title: Having issues installing nodejs/npm

Body:
I've completely uninstalled nodejs/npm both.

However they seem to be throwing same error consistently whilst installing.
I've also tried sudo-apt get update
sudo apt cache verify and apt cache search, when I search nodejs is not found or npm.

The program 'nodejs' is currently not installed. You can install it by typing:
sudo apt-get install nodejs

And when I do sudo apt-get intall nodejs

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package nodejs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'nodejs' has no installation candidate

I've made sure nodejs/npm is removed from /usr/bin etc. Still doesn't seem to be working at all.

Body: Try apt-get updateto update the list.


问:
Custom serialization for fields in Rails
Is there a way to have a custom serialization for fields in rails, a method that runs when a field is saved and loaded to convert from/to a string which is what ultimately is saved on the database.

Specifically what I want to do is have a field of type symbol like gender, with possible values :male and :female storing "male" and "female" on the database. There are some workarounds, like:

```<code>def gender
  read_attribute(:gender).try(:to_sym)
end
</code>```

but that leaves obj.attributes unchanged, so it's a leaky abstraction.

答:
well for just male/female you could just do a Boolean column like male and if it was false assume that meant female, add wrapper methods for it</p>

```<code>def female?
  return !self.male?
end
</code>```

Body:
Is there a way to have a custom serialization for fields in rails, a method that runs when a field is saved and loaded to convert from/to a string which is what ultimately is saved on the database.

Specifically what I want to do is have a field of type symbol like gender, with possible values :male and :female storing "male" and "female" on the database. There are some workarounds, like:

def gender
  read_attribute(:gender).try(:to_sym)
end

but that leaves obj.attributes unchanged, so it's a leaky abstraction.

Body:
well for just male/female you could just do a Boolean column like male and if it was false assume that meant female, add wrapper methods for it

def female?
  return !self.male?
end


问:
Displaying MySQL Data with Images in Table
I have set up a table that displays data from my SQL database using

```<code> $sql = "SELECT company_id, stk_buy, stk_sell FROM price";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
       echo "<table><tr><th>ID</th><th>Company</th><th>Buying Price</th><th>Selling Price</th></tr>";
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "<tr><td>".$row["company_id"]."</td><td>".$row["stk_buy"]."</td><td>".$row["stk_sell"]."</td></tr>";
    }
    echo "</table>";
   } else {
       echo "0 results";
   }
</code>```

I want to have images display in the Company column, different ones in each row.
Similar to:
Is there a possible way of displaying images with my current html table setup or do I have to fetch each row to display images?

答:
In these query you have not gave the image coloum name.You have to assign image coloum name like this</p>

```<code>$sql = "SELECT company_id,image(column name for image) stk_buy, stk_sell FROM price";
</code>```

Body:
I have set up a table that displays data from my SQL database using

 $sql = "SELECT company_id, stk_buy, stk_sell FROM price";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
       echo "

ID	Company	Buying Price	Selling Price
";
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "
".$row["company_id"]."	".$row["stk_buy"]."	".$row["stk_sell"]."
";
    }
    echo "
";
   } else {
       echo "0 results";
   }

I want to have images display in the Company column, different ones in each row.
Similar to:
Is there a possible way of displaying images with my current html table setup or do I have to fetch each row to display images?

Body:
In these query you have not gave the image coloum name.You have to assign image coloum name like this

$sql = "SELECT company_id,image(column name for image) stk_buy, stk_sell FROM price";


问:
How to solve SystemOutOfMemory Exception
I am getting below exception in my application at line:

```<code>Workbook workbook = new Workbook(fstream);
</code>```

Exception:

Exception of type 'System.OutOfMemoryException' was thrown.

C# Code:

```<code>string tempPath = @"C:\File\01_TDv01.xlsx";
foreach (string templateFile in Directory.GetFiles(tempPath))
{
    using (FileStream fstream = new FileStream(templateFile, FileMode.Open))
    {
         Workbook workbook = new Workbook(fstream);     //getting exception here
         Worksheet worksheet = workbook.Worksheets[0];
         ArrayList List = new ArrayList();

    //other code
    }
}
catch (Exception ex)
{

}
</code>```

I am processing the Excel file of size 38,436 KB; with 10K rows in it.

Web Config Settings:

```<code><add key="maxFileSizeLimit" value="2147483647" />

<httpRuntime targetFramework="4.5"  maxQueryStringLength="52768" enable="true" maxRequestLength="2147483647"/>

<requestLimits maxQueryString="52768" maxAllowedContentLength="4294967295" />
</code>```

What is wrong in my code and how can I resolve this exception?

I can't make lot of changes in code as it is already live.

答:
@user3196511

Could you provide us your template file "01_TDv01.xlsx". We need to evaluate your issue using your template file. Please also make sure you have sufficient memory (e.g 10 times or more memory of the size of the file) available for the big process as you are loading a large file We also recommend you to kindly try our latest version/fix: Aspose.Cells for .NET v17.6.x (if you are not already using it). Moreover, you should try to set MemoryPreference attribute on while loading your template file, see the following sample code for your reference:
e.g
Sample code:

```<code>        //Specify the LoadOptions
        LoadOptions opt = new LoadOptions();
        //Set the memory preferences
        opt.MemorySetting = MemorySetting.MemoryPreference;

        using (FileStream fstream = new FileStream(templateFile, FileMode.Open))
{
     Workbook workbook = new Workbook(fstream, opt);     //getting exception here
     Worksheet worksheet = workbook.Worksheets[0];

//other code
}
</code>```

I am working as Support developer/ Evangelist at Aspose.

ContentLicense: CC BY-SA 4.0

Body:
I am getting below exception in my application at line:

Workbook workbook = new Workbook(fstream);

Exception:

Exception of type 'System.OutOfMemoryException' was thrown.

C# Code:

string tempPath = @"C:\File\01_TDv01.xlsx";
foreach (string templateFile in Directory.GetFiles(tempPath))
{
    using (FileStream fstream = new FileStream(templateFile, FileMode.Open))
    {
         Workbook workbook = new Workbook(fstream);     //getting exception here
         Worksheet worksheet = workbook.Worksheets[0];
         ArrayList List = new ArrayList();

    //other code
    }
}
catch (Exception ex)
{

}

I am processing the Excel file of size 38,436 KB; with 10K rows in it.

Web Config Settings:

<add key="maxFileSizeLimit" value="2147483647" />

<httpRuntime targetFramework="4.5"  maxQueryStringLength="52768" enable="true" maxRequestLength="2147483647"/>

<requestLimits maxQueryString="52768" maxAllowedContentLength="4294967295" />

What is wrong in my code and how can I resolve this exception?

I can't make lot of changes in code as it is already live.

Body:
@user3196511

Could you provide us your template file "01_TDv01.xlsx". We need to evaluate your issue using your template file. Please also make sure you have sufficient memory (e.g 10 times or more memory of the size of the file) available for the big process as you are loading a large file We also recommend you to kindly try our latest version/fix: Aspose.Cells for .NET v17.6.x (if you are not already using it). Moreover, you should try to set MemoryPreference attribute on while loading your template file, see the following sample code for your reference:
e.g
Sample code:

        //Specify the LoadOptions
        LoadOptions opt = new LoadOptions();
        //Set the memory preferences
        opt.MemorySetting = MemorySetting.MemoryPreference;

        using (FileStream fstream = new FileStream(templateFile, FileMode.Open))
{
     Workbook workbook = new Workbook(fstream, opt);     //getting exception here
     Worksheet worksheet = workbook.Worksheets[0];

//other code
}

I am working as Support developer/ Evangelist at Aspose.


问:
Cordova / PhoneGap Plugin Permission Settings for NSCameraUsageDescription, NSPhotoLibraryUsageDescription and NSMicrophoneUsageDescription

App attempts to access privacy-sensitive data without a usage
  description. The app's Info.plist must contain an
  NSPhotoLibraryUsageDescription key with a string value explaining to
  the user how the app uses this data

答:
Cordova / PhoneGap Plugin Permission Settings for
  NSCameraUsageDescription, NSPhotoLibraryUsageDescription and
  NSMicrophoneUsageDescription in iOS  by adding a declaration to the
  Config.xml file

```<code><plugin name="cordova-plugin-media-capture" source="npm" spec="*">
  <variable name="CAMERA_USAGE_DESCRIPTION" value="App would like to access the camera." />
  <variable name="MICROPHONE_USAGE_DESCRIPTION" value="App would like to access the microphone." />
  <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="App would like to access the library." />
</plugin>
</code>```

Body:
Cordova / PhoneGap Plugin Permission Settings for
  NSCameraUsageDescription, NSPhotoLibraryUsageDescription and
  NSMicrophoneUsageDescription in iOS  by adding a declaration to the
  Config.xml file

<plugin name="cordova-plugin-media-capture" source="npm" spec="*">
  <variable name="CAMERA_USAGE_DESCRIPTION" value="App would like to access the camera." />
  <variable name="MICROPHONE_USAGE_DESCRIPTION" value="App would like to access the microphone." />
  <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="App would like to access the library." />
</plugin>


问:
Accessing serial data from Neurosky Mindset over bluetooth in linux
I am trying to access the serial data stream being transmitted from the Neurosky Mindset over bluetooth. It is a step in using ThinkGear Communications Protocol mentioned here:

http://developer.neurosky.com/docs/doku.php?id=which_api_is_right_for_me

There are a couple programs that should do this for me (Puzzlebox, Mindstream, etc.), I've either had apparently unsolvable dependency issues or they don't do exactly what I want.

I am able to pair the Mindset with my machine using blueman (specifically blueman-manager) I am able to connect the serial port to /dev/rfcomm0. What I am first wondering is: how do I read from this data stream. If I run sdptool records on the device, I get the following output:

Service Name: Dev B
Service RecHandle: 0x10005
Service Class ID List:
  "Serial Port" (0x1101)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 3
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100

(I get more than that, but that is the service I'm trying to access.)

I guess my main questions are: If cat /dev/rfcomm0 displays nothing does that mean that there is no data being transmitted? Is the problem that it isn't being displayed because it is raw? Is there a command that will guarantee to give me any serial data if it is being transmitted? Is there a bluetooth standard command that starts SPP transmission (I've searched for documentation for bluez, but that hasn't been too fruitful)?

I have run everything as both root and regular so that doesn't seem to fix it.

Any help would be greatly appreciated.

答:
I have the old NeuroSky Mindwave and BrainLink_Lite neurogadgets and here I used BrainLink. Neurosky and Brainlink work in the same way using the same protocol cause BrainLink used NeuroSky chip (TGAM). I solved that problem follow the next road:

first I get:

```<code>$ dmesg | tail -n 50
....
[243709.823581] Bluetooth: hci0: BCM: chip id 63
[243709.839507] Bluetooth: hci0: ShisiusStation
[243709.840576] Bluetooth: hci0: BCM20702A1 (001.002.014) build 0000
[243709.840606] bluetooth hci0: Direct firmware load for brcm/BCM20702A1-13d3-3404.hcd failed with error -2
[243709.840608] Bluetooth: hci0: BCM: Patch brcm/BCM20702A1-13d3-3404.hcd not found
...
</code>```

after connection via blueman-manager I get in dmesg output:

```<code>[254803.943803] Bluetooth: TIOCGSERIAL is not supported
[254804.299425] Bluetooth: bad checksum in packet
[254817.417375] Bluetooth: TIOCGSERIAL is not supported
[254817.417498] Bluetooth: TIOCGSERIAL is not supported
[254823.416967] Bluetooth: TIOCGSERIAL is not supported
[254865.049149] ERROR @wl_inform_single_bss : cfg80211_inform_bss_frame error
</code>```

Thats OK! By the way I can't connect to BrainLink for about 1-2 secs via

```<code>  bash$ sudo rfcomm connect /dev/rfcomm0 8C:DE:52:44:AB:23 1
</code>```

Also I patched my Bluetooth device error (Direct firmware load for brcm/BCM20702A1-13d3-3404.hcd failed with error -2) following that doc link (without descibed module recompiling)

```<code>wget https://www.dropbox.com/s/krg2ulkxdrqxham/bluetooth-hogfan.tar.gz
tar -zxvf bluetooth-hogfan.tar.gz
cd bluetooth
sudo cp fw-13d3_3404.hcd /lib/firmware/brcm
sudo cp fw-13d3_3404.hcd /lib/firmware/brcm/BCM20702A1-13d3-3404.hcd
sudo modprobe -r btusb
sudo modprobe btusb
</code>```

In the result I could connect BT using channel 6 (not 1,2,3,4,5, ...). I don't know why.

```<code># in real rfcomm0 became rfcomm59 by the end of experimintations.
sudo rfcomm connect rfcomm0 8C:DE:52:44:AB:23 6
Connected /dev/rfcomm0 to 8C:DE:52:44:AB:23 on channel 6
Press CTRL-C for hangup
</code>```

In another shell:

```<code>$: sudo cat /dev/rfcomm0 | hexdump -C
...
000f7f80  00 7b 02 aa aa 04 80 02  00 2c 51 aa aa 04 80 02  |.{.......,Q.....|
000f7f90  ff f9 85 aa aa 04 80 02  ff f9 85 aa aa 04 80 02  |................|
000f7fa0  00 44 39 aa aa 04 80 02  00 5b 22 aa aa 04 80 02  |.D9......[".....|
000f7fb0  00 31 4c aa aa 04 80 02  00 07 76 aa aa 04 80 02  |.1L.......v.....|
000f7fc0  ff ba c4 aa aa 04 80 02  ff 7e 00 aa aa 04 80 02  |.........~......|
000f7fd0  ff b3 cb aa aa 04 80 02  ff f9 85 aa aa 04 80 02  |................|
000f7fe0  00 1b 62 aa aa 04 80 02  00 45 38 aa aa 04 80 02  |..b......E8.....|
000f7ff0  00 36 47 aa aa 04 80 02  00 27 56 aa aa 04 80 02  |.6G......'V.....|
000f8000  00 66 17 aa aa 04 80 02  00 c5 b8 aa aa 04 80 02  |.f..............|
000f8010  00 e6 97 aa aa 04 80 02  00 91 ec aa aa 04 80 02  |................|
000f8020  ff f3 8b aa aa 04 80 02  ff d3 ab aa aa 04 80 02  |................|
000f8030  00 28 55 aa aa 04 80 02  00 36 47 aa aa 04 80 02  |.(U......6G.....|
...
</code>```

Details of data meaning are described here, here and here. Sometimes it works fine for the long time and sometimes neuro-serial-stream brings EOF so it's useful to read /dev/rfcomm0 since some time after disconnect. In case of connection to channel 3 I got:

```<code>sudo rfcomm connect rfcomm0 8C:DE:52:44:AB:23 3
Connected /dev/rfcomm43 to 8C:DE:52:44:AB:23 on channel 3
Press CTRL-C for hangup
# since 10 secs it is disconnect....
Disconnected
</code>```

Output is:

```<code>$ sudo cat /dev/rfcomm43 | hexdump -C
00000000  55 04 00 38 00 00 c4 55  04 00 38 00 00 c4 55 04  |U..8...U..8...U.|
00000010  00 38 00 00 c4 55 04 00  38 00 00 c4 55 04 00 38  |.8...U..8...U..8|
...
000000a0  c4 55 04 00 38 00 00 c4  55 04 00 38 00 00 c4     |.U..8...U..8...|
000000af
# (and disconnect)
</code>```

By the bye, I try to run NeuroPy example and got attention measure only one time:). Also I have to do next:

```<code>sudo chmod 777 /dev/rfcomm0
sudo python neuropyexample.py
</code>```

BrainLink was deleted from blueman paired devices during the all described experiments. Also I tested that during TuSion via-Art neuroapp development process. Here is Facebook community group. My last phrase:

```<code># Ubuntu 16.04
$ uname -a
Linux SlavikBoss 4.4.0-81-generic #104-Ubuntu SMP Wed Jun 14 08:17:06 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
</code>```

Body:
I have the old NeuroSky Mindwave and BrainLink_Lite neurogadgets and here I used BrainLink. Neurosky and Brainlink work in the same way using the same protocol cause BrainLink used NeuroSky chip (TGAM). I solved that problem follow the next road:

first I get:

$ dmesg | tail -n 50
....
[243709.823581] Bluetooth: hci0: BCM: chip id 63
[243709.839507] Bluetooth: hci0: ShisiusStation
[243709.840576] Bluetooth: hci0: BCM20702A1 (001.002.014) build 0000
[243709.840606] bluetooth hci0: Direct firmware load for brcm/BCM20702A1-13d3-3404.hcd failed with error -2
[243709.840608] Bluetooth: hci0: BCM: Patch brcm/BCM20702A1-13d3-3404.hcd not found
...

after connection via blueman-manager I get in dmesg output:

[254803.943803] Bluetooth: TIOCGSERIAL is not supported
[254804.299425] Bluetooth: bad checksum in packet
[254817.417375] Bluetooth: TIOCGSERIAL is not supported
[254817.417498] Bluetooth: TIOCGSERIAL is not supported
[254823.416967] Bluetooth: TIOCGSERIAL is not supported
[254865.049149] ERROR @wl_inform_single_bss : cfg80211_inform_bss_frame error

Thats OK! By the way I can't connect to BrainLink for about 1-2 secs via

  bash$ sudo rfcomm connect /dev/rfcomm0 8C:DE:52:44:AB:23 1

Also I patched my Bluetooth device error (Direct firmware load for brcm/BCM20702A1-13d3-3404.hcd failed with error -2) following that doc link (without descibed module recompiling)

wget https://www.dropbox.com/s/krg2ulkxdrqxham/bluetooth-hogfan.tar.gz
tar -zxvf bluetooth-hogfan.tar.gz
cd bluetooth
sudo cp fw-13d3_3404.hcd /lib/firmware/brcm
sudo cp fw-13d3_3404.hcd /lib/firmware/brcm/BCM20702A1-13d3-3404.hcd
sudo modprobe -r btusb
sudo modprobe btusb

In the result I could connect BT using channel 6 (not 1,2,3,4,5, ...). I don't know why.

# in real rfcomm0 became rfcomm59 by the end of experimintations.
sudo rfcomm connect rfcomm0 8C:DE:52:44:AB:23 6
Connected /dev/rfcomm0 to 8C:DE:52:44:AB:23 on channel 6
Press CTRL-C for hangup

In another shell:

$: sudo cat /dev/rfcomm0 | hexdump -C
...
000f7f80  00 7b 02 aa aa 04 80 02  00 2c 51 aa aa 04 80 02  |.{.......,Q.....|
000f7f90  ff f9 85 aa aa 04 80 02  ff f9 85 aa aa 04 80 02  |................|
000f7fa0  00 44 39 aa aa 04 80 02  00 5b 22 aa aa 04 80 02  |.D9......[".....|
000f7fb0  00 31 4c aa aa 04 80 02  00 07 76 aa aa 04 80 02  |.1L.......v.....|
000f7fc0  ff ba c4 aa aa 04 80 02  ff 7e 00 aa aa 04 80 02  |.........~......|
000f7fd0  ff b3 cb aa aa 04 80 02  ff f9 85 aa aa 04 80 02  |................|
000f7fe0  00 1b 62 aa aa 04 80 02  00 45 38 aa aa 04 80 02  |..b......E8.....|
000f7ff0  00 36 47 aa aa 04 80 02  00 27 56 aa aa 04 80 02  |.6G......'V.....|
000f8000  00 66 17 aa aa 04 80 02  00 c5 b8 aa aa 04 80 02  |.f..............|
000f8010  00 e6 97 aa aa 04 80 02  00 91 ec aa aa 04 80 02  |................|
000f8020  ff f3 8b aa aa 04 80 02  ff d3 ab aa aa 04 80 02  |................|
000f8030  00 28 55 aa aa 04 80 02  00 36 47 aa aa 04 80 02  |.(U......6G.....|
...

Details of data meaning are described here, here and here. Sometimes it works fine for the long time and sometimes neuro-serial-stream brings EOF so it's useful to read /dev/rfcomm0 since some time after disconnect. In case of connection to channel 3 I got:

sudo rfcomm connect rfcomm0 8C:DE:52:44:AB:23 3
Connected /dev/rfcomm43 to 8C:DE:52:44:AB:23 on channel 3
Press CTRL-C for hangup
# since 10 secs it is disconnect....
Disconnected

Output is:

$ sudo cat /dev/rfcomm43 | hexdump -C
00000000  55 04 00 38 00 00 c4 55  04 00 38 00 00 c4 55 04  |U..8...U..8...U.|
00000010  00 38 00 00 c4 55 04 00  38 00 00 c4 55 04 00 38  |.8...U..8...U..8|
...
000000a0  c4 55 04 00 38 00 00 c4  55 04 00 38 00 00 c4     |.U..8...U..8...|
000000af
# (and disconnect)

By the bye, I try to run NeuroPy example and got attention measure only one time:). Also I have to do next:

sudo chmod 777 /dev/rfcomm0
sudo python neuropyexample.py

BrainLink was deleted from blueman paired devices during the all described experiments. Also I tested that during TuSion via-Art neuroapp development process. Here is Facebook community group. My last phrase:

# Ubuntu 16.04
$ uname -a
Linux SlavikBoss 4.4.0-81-generic #104-Ubuntu SMP Wed Jun 14 08:17:06 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux


问:
Dynamically setting CSS values using ASP.NET
I'm working on a site where the images and other resources will be located on a separate domain from the main content of the site. We will use something like 'www.example.com' for the main site, and then 'images.example.com' for all extra resources for styles, etc.

When developing the site I will keep all of these resources on local dev. machines. The challenge here is keeping CSS references consistent between the production server and development environments.

What I was thinking of doing was creating a web.config key that would store the URL of the images server. Then, when switching from development to production I could just change the web.config value and everything would be done.

Is there any way to add a value to a CSS file, dynamically or otherwise, from some place in a config or C# class? Or am I going about this the wrong way?

Also, I'm limited to using .NET 2.0 if that makes a difference.

UPDATE

To expand on this a little more, I know I can use a web.config setting for server controls' URLs. Those are already generated dynamically. What I'm more interested in is what options I have for modifying (or doing "something") to static CSS files that will allow me to change URLs for things such as background image resources that would be referenced in CSS. Is there anything I can do besides find/replacing the values using my IDE? Perhaps something that can be done automatically with a deployment script?

答:
You duped your own question:

https://stackoverflow.com/questions/449236/dynamically-setting-css-values-using-asp-net

OwnerDisplayName: DanHerbert

LastEditorDisplayName: DanHerbert

OwnerDisplayName: Diodeus


问:
checking resources in xml and displaying icons for the resources in android
hai every one. i am new to android. in my project i had some problems reading xml files. In my xml i have included some audios and videos paths and i want to read the xml file  through the code  and i want to display some images n my view if there are some audio or video files. can any body tel how to read the xml file.
 thanking you in advance</p>

答:
Ok first you need to create a parser Below is the code to do this:

public static void readTemplateFile(Context context) {

```<code>    /**
     Include File Checking
     */

    try {
        XML_Handler_Template myExHan = new XML_Handler_Template();

        InputStreamReader isr =  new
        FileReader( new File(Environment.getExternalStorageDirectory().getPath() + "/Library Template.xml" ));

        XML_Handler_Template.context = context;

        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();

        XMLReader xr = sp.getXMLReader();

        xr.setContentHandler((ContentHandler) myExHan);

        xr.parse(new InputSource(isr));

    } catch (Exception e) {

        Toast.makeText(context, ">" + e.getMessage(), Toast.LENGTH_LONG).show();

    }

}
</code>```

You then need a Handler Class. In the above example my class is called XML_Handler_Template.

FileReader( new File(Environment.getExternalStorageDirectory().getPath() + "/FILEPATH/FILE.XML" ));

Here is the XML_Handler_Class at the moment it is blank:

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class XML_Handler_Template extends DefaultHandler{

```<code>    public static Context context = null;

@Override
public void startDocument() throws SAXException {
    //this is called when the document is first read
}

@Override
public void startElement(String namespaceURI, String localName,
        String qName, Attributes atts) throws SAXException {
                    //This is called when a new Tag is opened
                    //localName holds the Tag Name, the Value is got from the
                    //Characters function at the end of this class

                   //the attributes for each tag are stored in the atts array, you can either handle the attribute values here or pass the information to a separate function to handle them,
                   if (atts.getLength()>0){
            for (int i=0;i<atts.getLength();i++){

                addAttrib(atts.getLocalName(i) , atts.getValue(i))  ;

            }
        }
}

@Override
public void endElement(String namespaceURI, String localName, String qName)
throws SAXException {
    //This is called when a Tag is closed
}

@Override
public void endDocument() throws SAXException {
                //this is called when the document is closed
}

@Override
public void characters(char ch[], int start, int length) {
            //This is where the value of a Tag are read
    String value = new String( ch , start , length );
            // You may want to include a replaceAll("\r","") and replaceAll("\n","") to remove any hidden chars

}
</code>```

}

have a play with this and see how you get on for now =0) I passed a context to the class so whilst i was learning I could use toasts to show me the values that were being read.

Body:
Ok first you need to create a parser Below is the code to do this:

public static void readTemplateFile(Context context) {

    /**
     Include File Checking
     */

    try {
        XML_Handler_Template myExHan = new XML_Handler_Template();

        InputStreamReader isr =  new
        FileReader( new File(Environment.getExternalStorageDirectory().getPath() + "/Library Template.xml" ));

        XML_Handler_Template.context = context;

        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();

        XMLReader xr = sp.getXMLReader();

        xr.setContentHandler((ContentHandler) myExHan);

        xr.parse(new InputSource(isr));

    } catch (Exception e) {

        Toast.makeText(context, ">" + e.getMessage(), Toast.LENGTH_LONG).show();

    }

}

You then need a Handler Class. In the above example my class is called XML_Handler_Template.

FileReader( new File(Environment.getExternalStorageDirectory().getPath() + "/FILEPATH/FILE.XML" ));

Here is the XML_Handler_Class at the moment it is blank:

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class XML_Handler_Template extends DefaultHandler{

    public static Context context = null;

@Override
public void startDocument() throws SAXException {
    //this is called when the document is first read
}

@Override
public void startElement(String namespaceURI, String localName,
        String qName, Attributes atts) throws SAXException {
                    //This is called when a new Tag is opened
                    //localName holds the Tag Name, the Value is got from the
                    //Characters function at the end of this class

                   //the attributes for each tag are stored in the atts array, you can either handle the attribute values here or pass the information to a separate function to handle them,
                   if (atts.getLength()>0){
            for (int i=0;i<atts.getLength();i++){

                addAttrib(atts.getLocalName(i) , atts.getValue(i))  ;

            }
        }
}

@Override
public void endElement(String namespaceURI, String localName, String qName)
throws SAXException {
    //This is called when a Tag is closed
}

@Override
public void endDocument() throws SAXException {
                //this is called when the document is closed
}

@Override
public void characters(char ch[], int start, int length) {
            //This is where the value of a Tag are read
    String value = new String( ch , start , length );
            // You may want to include a replaceAll("\r","") and replaceAll("\n","") to remove any hidden chars

}

}

have a play with this and see how you get on for now =0) I passed a context to the class so whilst i was learning I could use toasts to show me the values that were being read.


问:
Passing bitwise operation as argument to function in C
What will be the argument value if we call function with the following argument

```<code>void func((0x1 | 0x3))
</code>```

Is it true that if the result of this operation is >0 it gives true, and for the opposite it gives false, or we get 0x3 as a return value of this operation?

答:
0x1 | 0x3 is a compile-time evaluable constant expression: it's an int type with the value 3.

If you were thinking of the || operator, then in C, the value of 0x1 || 0x3 is an int type with the value 1 as evaluation of || stops at the first non-zero argument. This short-circuiting property also applies to C++ but here the type would be bool with the value true and you have to take extra care if func is overloaded1:

```<code>void func(int)
{
    // pay me a bonus
}

#ifdef __cplusplus
void func(const bool&)
{
    // reformat my hard disk
}
#endif
</code>```

1C++ allows functions to be overloaded, C doesn't. Yet another important difference.

Body:
What will be the argument value if we call function with the following argument

void func((0x1 | 0x3))

Is it true that if the result of this operation is >0 it gives true, and for the opposite it gives false, or we get 0x3 as a return value of this operation?

Body:
0x1 | 0x3 is a compile-time evaluable constant expression: it's an int type with the value 3.

If you were thinking of the || operator, then in C, the value of 0x1 || 0x3 is an int type with the value 1 as evaluation of || stops at the first non-zero argument. This short-circuiting property also applies to C++ but here the type would be bool with the value true and you have to take extra care if func is overloaded1:

void func(int)
{
    // pay me a bonus
}

#ifdef __cplusplus
void func(const bool&)
{
    // reformat my hard disk
}
#endif

1C++ allows functions to be overloaded, C doesn't. Yet another important difference.


答:
First change your query to get image as well from table and then In your echo for table row, add one more td tag with img tag and src of the image to point the path where the image is stored. Something like

```<code>echo "<tr><td>".$row["company_id"]."</td><td><img src='./path-to-image/".$row["image-column-name"]."' width='100' height='100'/></td><td>".$row["stk_buy"]."</td><td>".$row["stk_sell"]."</td></tr>";
</code>```

You can change width and height attributes value to what you want.

Title: Displaying MySQL Data with Images in Table

Body:
First change your query to get image as well from table and then In your echo for table row, add one more td tag with img tag and src of the image to point the path where the image is stored. Something like

echo "<tr><td>".$row["company_id"]."</td><td><img src='./path-to-image/".$row["image-column-name"]."' width='100' height='100'/></td><td>".$row["stk_buy"]."</td><td>".$row["stk_sell"]."</td></tr>";

You can change width and height attributes value to what you want.


问:
count the number of points at the end of a string
I need to count the number of points at the END of string.
The number of points in the middle of the string are not relevant and should not be countet.

How can this be done?

```<code>string sample = "This.is.a.sample.string.....";
</code>```

for the example above the correct answer would be 5 because there are 5 points at the end of the string.

because of performace reasons I would prefer a fast solution. Don't know if Regular Expressions

```<code>\.*$
</code>```

should be used in such a case.

答:
It can be something like..</p>

```<code>string sample = "This.is.a.sample.string.....";
int count = 0;
if(sample.EndsWith("."))
   count = sample.Substring(sample.TrimEnd('.').Length).Length;
</code>```

Body:
I need to count the number of points at the END of string.
The number of points in the middle of the string are not relevant and should not be countet.

How can this be done?

string sample = "This.is.a.sample.string.....";

for the example above the correct answer would be 5 because there are 5 points at the end of the string.

because of performace reasons I would prefer a fast solution. Don't know if Regular Expressions

\.*$

should be used in such a case.

Body:
It can be something like..

string sample = "This.is.a.sample.string.....";
int count = 0;
if(sample.EndsWith("."))
   count = sample.Substring(sample.TrimEnd('.').Length).Length;


问:
'Realm/Realm.h' file not found in iOS when Archiving
When Archiving the project for Enterprise Distribution I'm getting an error "'Realm/Realm.h' file not found" .

Screenshot:

Realm works fine both on simulator and devices when I run it. But the problem is when Archive the project.

答: See if framework search path is set correctly for release build. </p>


问:
How do you use Django-filter's '__in' lookup?
I am using Django REST framework with the django-filter package, but my question is mostly about django-filter. I don't understand how to use filters with "__in" lookup.

For example I have the following model:

```<code>class Book(models.Model):
   name = models.CharField(max_length=100)

class BookView(viewsets.ReadOnlyModelViewSet):
   serializer_class = BookSerializer()
   model = Book
   filter_fields = ('id', 'name')
</code>```

And I can't use URLs like /v1/books/?id__in=1,2,3 to find books with id 1, 2 or 3.

How do you use Django-filter's '__in' lookup?

答: Instead /v1/books/?id__in=1,2,3 you can use /v1/books/?id=1&id=2&id=3

Body:
I am using Django REST framework with the django-filter package, but my question is mostly about django-filter. I don't understand how to use filters with "__in" lookup.

For example I have the following model:

class Book(models.Model):
   name = models.CharField(max_length=100)

class BookView(viewsets.ReadOnlyModelViewSet):
   serializer_class = BookSerializer()
   model = Book
   filter_fields = ('id', 'name')

And I can't use URLs like /v1/books/?id__in=1,2,3 to find books with id 1, 2 or 3.

How do you use Django-filter's '__in' lookup?


答:
Since you used only one pipe, the result is bitwise OR, not a logical OR:

```<code>0x01 | 0x03  ---> 0x03
</code>```

Logical OR uses two pipes:

```<code>0x01 || 0x03 ---> 1
</code>```

Title: Passing bitwise operation as argument to function in C

Body:
Since you used only one pipe, the result is bitwise OR, not a logical OR:

0x01 | 0x03  ---> 0x03

Logical OR uses two pipes:

0x01 || 0x03 ---> 1


问:
Making a deep copy of a struct with arrays in it?
After googling I've learned that it's not possible unless you do it manually. Take this code for example:

```<code>public struct SEverything
{
    public int[] arrayOfHouseNumbers;
    public string nameOfOwner;
}
</code>```

I only know of a very cumbersome way to copy it and that's to create a new struct and do it like this:

```<code>private void CopySEverything()
{
    sEverythingCopy = new SEverything();
    sEverythingCopy.nameOfOwner = sEverythingOriginal.nameOfOwner;
    sEverythingCopy.arrayOfHouseNumbers = new
    int[sEverythingOriginal.arrayOfHouseNumbers.Length];

    for (int i = 0; i < sEverythingCopy.Length; i++)
    {
        sEverythingCopy[i] = sEverythingOriginal[i];
    }
}
</code>```

I'm using a much more complicated struct and it would be really annoying to do the above for a big struct, not to mention that if the structure of the struct is changed, the code has to be rewritten. Any advice is very welcome.

e: is serializing and deserializing a good option?

答:
```<code>private void CopySEverything()
{
    sEverythingCopy = new SEverything();
    sEverythingCopy.nameOfOwner = sEverythingOriginal.nameOfOwner;
    sEverythingCopy.arrayOfHouseNumbers = new
    int[sEverythingOriginal.arrayOfHouseNumbers.Length];

    for (int i = 0; i < sEverythingCopy.Length; i++)
    {
        sEverythingCopy[i] = sEverythingOriginal[i];
    }
}
</code>```

could be simplified to:

```<code>private void CopySEverything()
{
    sEverythingCopy = new SEverything();
    sEverythingCopy.nameOfOwner = sEverythingOriginal.nameOfOwner;
    sEverythingCopy.arrayOfHouseNumbers = sEverythingOriginal.arrayOfHouseNumbers.ToArray();
}
</code>```

You should also consider https://github.com/Burtsev-Alexey/net-object-deep-copy/blob/master/ObjectExtensions.cs .

Body:
After googling I've learned that it's not possible unless you do it manually. Take this code for example:

public struct SEverything
{
    public int[] arrayOfHouseNumbers;
    public string nameOfOwner;
}

I only know of a very cumbersome way to copy it and that's to create a new struct and do it like this:

private void CopySEverything()
{
    sEverythingCopy = new SEverything();
    sEverythingCopy.nameOfOwner = sEverythingOriginal.nameOfOwner;
    sEverythingCopy.arrayOfHouseNumbers = new
    int[sEverythingOriginal.arrayOfHouseNumbers.Length];

    for (int i = 0; i < sEverythingCopy.Length; i++)
    {
        sEverythingCopy[i] = sEverythingOriginal[i];
    }
}

I'm using a much more complicated struct and it would be really annoying to do the above for a big struct, not to mention that if the structure of the struct is changed, the code has to be rewritten. Any advice is very welcome.

e: is serializing and deserializing a good option?

Body:
private void CopySEverything()
{
    sEverythingCopy = new SEverything();
    sEverythingCopy.nameOfOwner = sEverythingOriginal.nameOfOwner;
    sEverythingCopy.arrayOfHouseNumbers = new
    int[sEverythingOriginal.arrayOfHouseNumbers.Length];

    for (int i = 0; i < sEverythingCopy.Length; i++)
    {
        sEverythingCopy[i] = sEverythingOriginal[i];
    }
}

could be simplified to:

private void CopySEverything()
{
    sEverythingCopy = new SEverything();
    sEverythingCopy.nameOfOwner = sEverythingOriginal.nameOfOwner;
    sEverythingCopy.arrayOfHouseNumbers = sEverythingOriginal.arrayOfHouseNumbers.ToArray();
}

You should also consider https://github.com/Burtsev-Alexey/net-object-deep-copy/blob/master/ObjectExtensions.cs .


问:
WordPress duplicating but same login
I've duplicated my own site to another domain and I want to run both the websites. I am confused between the same login for both the sites. The one which I copied is www.artiana.io and the one which I copied to is www.teamnautilus.com, the WordPress login for both are same. I am scared to make any further changes as it may affect both the sites. Please, can anyone clear my doubt?

Best regards,
Sahaba

答:
you will create  anew databse and import your first one to new databse and then connect 2nd setup with newly created databse.
In this way you have two diffrent sites with diffrent databse</p>

Title: WordPress duplicating but same login