问:
Maintaining python flask sessions from an ajax call
I am using flask sessions in my program to maintain all dynamic information .I have hosted my service on local host.

```<code>from flask import Flask,make_response,render_template, request, jsonify,json,jsonify,send_from_directory,session
from flask.ext.cors import CORS, cross_origin
import requests

app = Flask(__name__)
app.secret_key='test'
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'

@app.route('/getAnswer')
@cross_origin()
def getAnswer():
    userQuery = request.args.get("query")

    session['username']="testuser"
    session['userid']="Utkj3YC"
    reply=askquestion(userQuery,session)
    print "giving response : ",str(reply)
    answer=str(reply)

    return jsonify(response=answer,id="1",status="suc",dialog="initial")

if __name__ == '__main__':
    app.run(host='0.0.0.0',processes=True,debug=True,port=8000)
</code>```

This is my flask service and this works fine when i am testing the same from postman restclient. The postman requests are maintaining the same session variables.

The problem is when i integrated this service with my UI. the ajax request every time resets the flask session variable because of which i am unable to maintain the session.
My ajax call is as follows

```<code>$.ajax({
        url: "http://127.0.0.1:8000/getAnswer",
        method: 'GET',

        data: { query: query,dialog:dialog },
        success: function(data) {

         var $chatBox = $('#botReplyDiv').clone().prop('id',"botdiv"+data.id);
         var $loading = $('.loader');
         $chatBox.css("display", "block");
         var ul  = document.createElement('ul');
         console.log(data.response);
         var resp=data.response;
         var li=document.createElement('li');
         li.appendChild(document.createTextNode(data.response));

         ul.appendChild(li);

         }
         });
</code>```

I also tried adding this in the ajax request.

```<code>xhrFields: {
  withCredentials: true
  }
</code>```

But the problem still persists. every time a new session is created in flask. But the same code when i do with POSTMAN ,it is persisting the same session. What is the change that i have to do to make the ajax call retain the same session in every request ?

答: The problem was i was using http://locahost:8000/getAnswer in my client side code. I changed it ti http://127.0.0.1:8000/getAnswer and it is working fine now.</p>

Body:
I am using flask sessions in my program to maintain all dynamic information .I have hosted my service on local host.

from flask import Flask,make_response,render_template, request, jsonify,json,jsonify,send_from_directory,session
from flask.ext.cors import CORS, cross_origin
import requests

app = Flask(__name__)
app.secret_key='test'
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'

@app.route('/getAnswer')
@cross_origin()
def getAnswer():
    userQuery = request.args.get("query")

    session['username']="testuser"
    session['userid']="Utkj3YC"
    reply=askquestion(userQuery,session)
    print "giving response : ",str(reply)
    answer=str(reply)

    return jsonify(response=answer,id="1",status="suc",dialog="initial")

if __name__ == '__main__':
    app.run(host='0.0.0.0',processes=True,debug=True,port=8000)

This is my flask service and this works fine when i am testing the same from postman restclient. The postman requests are maintaining the same session variables.

The problem is when i integrated this service with my UI. the ajax request every time resets the flask session variable because of which i am unable to maintain the session.
My ajax call is as follows

$.ajax({
        url: "http://127.0.0.1:8000/getAnswer",
        method: 'GET',

        data: { query: query,dialog:dialog },
        success: function(data) {

         var $chatBox = $('#botReplyDiv').clone().prop('id',"botdiv"+data.id);
         var $loading = $('.loader');
         $chatBox.css("display", "block");
         var ul  = document.createElement('ul');
         console.log(data.response);
         var resp=data.response;
         var li=document.createElement('li');
         li.appendChild(document.createTextNode(data.response));

         ul.appendChild(li);

         }
         });

I also tried adding this in the ajax request.

xhrFields: {
  withCredentials: true
  }

But the problem still persists. every time a new session is created in flask. But the same code when i do with POSTMAN ,it is persisting the same session. What is the change that i have to do to make the ajax call retain the same session in every request ?


来源: stackexchange

问:
MVC 5 Razor view not rendering HTML within if condition
This is the MVC 5 razor view code:  ForestView.cshtml

```<code>@model Forest.Tree
@{
   var resultHtml = string.Empty;
 }
<div id="divTreeSearch>
@(Html.Kendo().PanelBar().
                         Name("panelbar")
                         .Items(panelbar =>
                                        {panelbar.Add()
                               .Content(@<text>@Html.Partial("_TreeSearch", Model, ViewData)</text>);}))
</div>
<div id="divTreeSearchResult">
@if(Model.TreeResultObj != null)
{
  resultHtml = Html.ContentFromPartial("_TreeReport", Model.TreeResultObj);

  @Html.Raw(resultHtml);    -- Not working
  @Html.Raw(HttpUtility.HtmlDecode(resultHtml)); -- Not Working
  Html.Raw(resultHtml);    -- Not working
  Html.Raw(HttpUtility.HtmlDecode(resultHtml)); -- Not Working

  Model.resultStringSaved  = resultHtml;
  @Html.DisplayText("resultStringSaved"); -- Not Working

   @Html.Raw("<text>Test</text>") -- Even this is not working

}

 @Html.Raw(Model.resultStringSaved) -- Not Working
 @Html.Raw(HttpUtility.HtmlDecode(Model.resultStringSaved)) -- Not Working
 @Html.DisplayText("resultStringSaved") -- Not Working

  @Html.Raw("<text>Test</text>") -- This is Working
</div>
</code>```

ForestView.cshtml - @model Forest.Tree
_TreeSearch.cshtml - @model Forest.Tree
_TreeReport.cshtml - @model Forest.SearchData.Results

The projerty TreeResultObj in the model Forest.Tree is of type Forest.SearchData.Results

The ForestView.cshtml is the main view which loads initially and displays the search inputs from the _TreeSearch partial
When search criteria entered and a 'search' button is clicked (all this is from the _TreeSearch) - a ajax call is make and the TreeSearch(id tree) action is called

The action again returns the main 'ForestView' - however now the model property 'TreeResultObj' is populated. so the code within the 'if conditon' in the 'ForestView' executed and calls another partial to get the content back as HTML string, which is saved in the 'resultHtml' variable

At this point I can see the Html Sting like "<Text>blah blah blah</text>"
However trying to display the HTML string below the search panel in the main 'ForestView' is not working - I have tried almost every possible way.

Any text within the if condition is not rendered - it is an ajax call so there is no page refresh - I can see the HTML string value and also save it as a Model property but cannot get to display it in the main view.
Any help would be much appreciated. Thanks in advance.

答:
I was also facing the same issue but I could make it to working. I wanted to open a div start and conditionally end it within a for loop.

Put any dummy HTML element before the @Html.Raw

```<code><div id="divTreeSearchResult">
@if(Model.TreeResultObj != null)
 {
  resultHtml = Html.ContentFromPartial("_TreeReport", Model.TreeResultObj);
  <span>dummySpan</span>
  @Html.Raw(resultHtml);
  @Html.Raw(HttpUtility.HtmlDecode(resultHtml));
  @Html.Raw(resultHtml);
  @Html.Raw(HttpUtility.HtmlDecode(resultHtml));

 Model.resultStringSaved  = resultHtml;
 @Html.DisplayText("resultStringSaved");

 @Html.Raw("<text>Test</text>")

}

@Html.Raw(Model.resultStringSaved)
@Html.Raw(HttpUtility.HtmlDecode(Model.resultStringSaved))
@Html.DisplayText("resultStringSaved")

@Html.Raw("<text>Test</text>")
</div>
</code>```

After you place a dummy html element there all the below @Html.Raw will work

Happy Coding

Tarak

ContentLicense: CC BY-SA 3.0

Body:
This is the MVC 5 razor view code:  ForestView.cshtml

@model Forest.Tree
@{
   var resultHtml = string.Empty;
 }

@(Html.Kendo().PanelBar().
                         Name("panelbar")
                         .Items(panelbar =>
                                        {panelbar.Add()
                               .Content(@<text>@Html.Partial("_TreeSearch", Model, ViewData)</text>);}))

@if(Model.TreeResultObj != null)
{
  resultHtml = Html.ContentFromPartial("_TreeReport", Model.TreeResultObj);

  @Html.Raw(resultHtml);    -- Not working
  @Html.Raw(HttpUtility.HtmlDecode(resultHtml)); -- Not Working
  Html.Raw(resultHtml);    -- Not working
  Html.Raw(HttpUtility.HtmlDecode(resultHtml)); -- Not Working

  Model.resultStringSaved  = resultHtml;
  @Html.DisplayText("resultStringSaved"); -- Not Working

   @Html.Raw("<text>Test</text>") -- Even this is not working

}

 @Html.Raw(Model.resultStringSaved) -- Not Working
 @Html.Raw(HttpUtility.HtmlDecode(Model.resultStringSaved)) -- Not Working
 @Html.DisplayText("resultStringSaved") -- Not Working

  @Html.Raw("<text>Test</text>") -- This is Working

ForestView.cshtml - @model Forest.Tree
_TreeSearch.cshtml - @model Forest.Tree
_TreeReport.cshtml - @model Forest.SearchData.Results

The projerty TreeResultObj in the model Forest.Tree is of type Forest.SearchData.Results

The ForestView.cshtml is the main view which loads initially and displays the search inputs from the _TreeSearch partial
When search criteria entered and a 'search' button is clicked (all this is from the _TreeSearch) - a ajax call is make and the TreeSearch(id tree) action is called

The action again returns the main 'ForestView' - however now the model property 'TreeResultObj' is populated. so the code within the 'if conditon' in the 'ForestView' executed and calls another partial to get the content back as HTML string, which is saved in the 'resultHtml' variable

At this point I can see the Html Sting like "<Text>blah blah blah</text>"
However trying to display the HTML string below the search panel in the main 'ForestView' is not working - I have tried almost every possible way.

Any text within the if condition is not rendered - it is an ajax call so there is no page refresh - I can see the HTML string value and also save it as a Model property but cannot get to display it in the main view.
Any help would be much appreciated. Thanks in advance.

Body:
I was also facing the same issue but I could make it to working. I wanted to open a div start and conditionally end it within a for loop.

Put any dummy HTML element before the @Html.Raw

<div id="divTreeSearchResult">
@if(Model.TreeResultObj != null)
 {
  resultHtml = Html.ContentFromPartial("_TreeReport", Model.TreeResultObj);
  <span>dummySpan</span>
  @Html.Raw(resultHtml);
  @Html.Raw(HttpUtility.HtmlDecode(resultHtml));
  @Html.Raw(resultHtml);
  @Html.Raw(HttpUtility.HtmlDecode(resultHtml));

 Model.resultStringSaved  = resultHtml;
 @Html.DisplayText("resultStringSaved");

 @Html.Raw("<text>Test</text>")

}

@Html.Raw(Model.resultStringSaved)
@Html.Raw(HttpUtility.HtmlDecode(Model.resultStringSaved))
@Html.DisplayText("resultStringSaved")

@Html.Raw("<text>Test</text>")
</div>

After you place a dummy html element there all the below @Html.Raw will work

Happy Coding

Tarak


问:
how to display button when menu button is pressed in android
hi friends i want to pop up a button from the bottom of my screen when the default menu button is pressed on the android key pad. i want to navigate from that pop button to other screens.  </p>

答:
You first have to declare your desired menu in /menu/menu.xml
then you need a inflater for your menu:

```<code>// menuinflater
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    return true;
}
</code>```

And to handle your menu:

```<code>    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        // only one menu option here for preferences
        // for more just add new case with your ids
        case R.id.firstmenuitem:
            // Launch preferences activity
            Intent i = new Intent(youractivity.this, preferences.class);
            startActivity(i);
            break;

        }
        return true;
    }
</code>```

regards

ContentLicense: CC BY-SA 2.5

Body:
You first have to declare your desired menu in /menu/menu.xml
then you need a inflater for your menu:

// menuinflater
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    return true;
}

And to handle your menu:

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        // only one menu option here for preferences
        // for more just add new case with your ids
        case R.id.firstmenuitem:
            // Launch preferences activity
            Intent i = new Intent(youractivity.this, preferences.class);
            startActivity(i);
            break;

        }
        return true;
    }

regards


问:
Wordpress Internal server 500
I have a wordpress site in my local environment, then I transferred it on clients server then I encountered internal server error, when I changed language using q-translate plugin but in my local environment it is working.

I have tried:

wp-config - add memory

php.ini - put in root directory with
memoey_limit 2048M

答:
Try This,

WPLANG defines the name of the language translation (.mo) file. WP_LANG_DIR defines what directory the WPLANG .mo file resides. If WP_LANG_DIR is not defined WordPress looks first to wp-content/languages and then wp-includes/languages for the .mo defined by WPLANG file.

define( 'WPLANG', 'de_DE' );
define( 'WP_LANG_DIR', dirname(FILE) . '/wordpress/languages' );

Title: Wordpress Internal server 500


问:
Adding enum on model shows error on initializing different class object
I have added enum on RvDate model as:

```<code>class RvDate < ApplicationRecord
 enum status: { Available: 0, Not_Available: 1 }

 # Associations
 belongs_to :rv

 # Validations
 validates_presence_of :start_date
end
</code>```

But when I run Rv.create on rails console, it shows me the following error:

I have not used enum on Rv model and I do not need one. Is there anything I have missed here?

Rv model looks like this:

```<code>class Rv < ApplicationRecord
 has_many :rv_dates, dependent: :destroy
end
</code>```

Schema for rv_dates

```<code>create_table "rv_dates", force: :cascade do |t|
 t.integer  "rv_id"
 t.date     "start_date"
 t.date     "end_date"
 t.boolean  "availability"
 t.float    "price"
 t.text     "notes"
 t.datetime "created_at",   null: false
 t.datetime "updated_at",   null: false
 t.integer  "status"
 t.index ["rv_id"], name: "index_rv_dates_on_rv_id", using: :btree
end
</code>```

答: Thanks everyone for help. The actual issue was with the migration file. Rvs table had a field called status which was set to integer instead of string. Thus, this had caused the error unable to find the statuses for Rv class object. Really appreciate everyone's help.

Body:
I have added enum on RvDate model as:

class RvDate < ApplicationRecord
 enum status: { Available: 0, Not_Available: 1 }

 # Associations
 belongs_to :rv

 # Validations
 validates_presence_of :start_date
end

But when I run Rv.create on rails console, it shows me the following error:

I have not used enum on Rv model and I do not need one. Is there anything I have missed here?

Rv model looks like this:

class Rv < ApplicationRecord
 has_many :rv_dates, dependent: :destroy
end

Schema for rv_dates

create_table "rv_dates", force: :cascade do |t|
 t.integer  "rv_id"
 t.date     "start_date"
 t.date     "end_date"
 t.boolean  "availability"
 t.float    "price"
 t.text     "notes"
 t.datetime "created_at",   null: false
 t.datetime "updated_at",   null: false
 t.integer  "status"
 t.index ["rv_id"], name: "index_rv_dates_on_rv_id", using: :btree
end


问:
Excel is changing the digits after 15th to "0". Please suggest what to do in the same case
In the application, we are Exporting the data to Excel and saving it. Post opening the file, there is a column "Reference Number" which of 16 digits and it is displayed in exponential form.

After converting it into Number from Format Cells, it is changing it in Number Format but 16th digit is converted to "0". I tried to change it in text Format also but it is again converting it into exponential Form.

I tried to convert in number, text , customized form, etc. But Nothing is working. Please Suggest as I want the 16 digit Reference Number.

答: Numbers in Excel are stored a double precision (64-bit) floating point numbers.  These have between 15 and 16 digits of precision.  If you need numbers of that length or longer to be stored exactly, you must store them as text.</p>


问:
spark-submit pipeline model
I have an Apache Spark cluster (1 master + 1 worker) running on docker, I'm able to submit a job using spark-submit that fits a pipeline and then it is saved (PipelineModel.save(path)). The file is saved on my local machine exactly in the point where I executed the spark-submit command.

The problem arises when I try to deploy a production code when I want to load the PipelineModel and use it for prediction. I'm not able to pass the folder containing the files which have been saved.

This is the code I use to submit the job:

```<code>spark-submit --class ch.supsi.isteps.Main --master spark://172.17.0.1:7077 --packages org.apache.spark:spark-sql-kafka-0-10_2.11:2.2.0 --files=test/aFolder ./STR-0.1-alpha.jar --mode=production --file=test/aFolder
</code>```

where --mode=production --file=test/aFolder are parameters to my program

I already tried to use --files, but it doesn't accept folders. I would like to avoid copying the model in all the worker nodes.

EDIT

The problem is related to HDFS and Docker. As a backup solution we avoided working with spark-cluster inside Docker and switched to local mode inside Docker. This allowed to save and retrieve the file without problems. If you map the folders (docker-compose -> volumes) you don't even need to pass the files as they are already mapped to your containers

答:
I already tried to use --files, but it doesn't accept folders

Option 1:

SparkContext has below method to add files you can loop and  list of files in your folder and add them.

```<code>/**
* Add a file to be downloaded with this Spark job on every node.
*
* If a file is added during execution, it will not be available until the next TaskSet starts.
*
* @param path can be either a local file, a file in HDFS (or other Hadoop-supported
* filesystems), or an HTTP, HTTPS or FTP URI. To access the file in Spark jobs,
* use `SparkFiles.get(fileName)` to find its download location.
*/
def addFile(path: String): Unit = {
addFile(path, false)
}
</code>```

as mentioned above... SparkFiles.get(fileName) you can get the file name

or else SparkFiles has getRootDirectory to get the folder where you have added files and them you can access them.

```<code>/**
  * Get the root directory that contains files added through `SparkContext.addFile()`.
 */
 def getRootDirectory(): String =
 SparkEnv.get.driverTmpDir.getOrElse(".")

 }
</code>```

or else

using sparkcontext.listFiles you can get the list of files as sequence.

Option 2 :  If you want to go ahead with --files option then you can follow my answer submitting multiple jars from a folder using same approach you can add multiple files from a folder separated by delimiter as well.

Hope this helps!

Title: spark-submit pipeline model

Body:
I have an Apache Spark cluster (1 master + 1 worker) running on docker, I'm able to submit a job using spark-submit that fits a pipeline and then it is saved (PipelineModel.save(path)). The file is saved on my local machine exactly in the point where I executed the spark-submit command.

The problem arises when I try to deploy a production code when I want to load the PipelineModel and use it for prediction. I'm not able to pass the folder containing the files which have been saved.

This is the code I use to submit the job:

spark-submit --class ch.supsi.isteps.Main --master spark://172.17.0.1:7077 --packages org.apache.spark:spark-sql-kafka-0-10_2.11:2.2.0 --files=test/aFolder ./STR-0.1-alpha.jar --mode=production --file=test/aFolder

where --mode=production --file=test/aFolder are parameters to my program

I already tried to use --files, but it doesn't accept folders. I would like to avoid copying the model in all the worker nodes.

EDIT

The problem is related to HDFS and Docker. As a backup solution we avoided working with spark-cluster inside Docker and switched to local mode inside Docker. This allowed to save and retrieve the file without problems. If you map the folders (docker-compose -> volumes) you don't even need to pass the files as they are already mapped to your containers

Body:
I already tried to use --files, but it doesn't accept folders

Option 1:

SparkContext has below method to add files you can loop and  list of files in your folder and add them.

/**
* Add a file to be downloaded with this Spark job on every node.
*
* If a file is added during execution, it will not be available until the next TaskSet starts.
*
* @param path can be either a local file, a file in HDFS (or other Hadoop-supported
* filesystems), or an HTTP, HTTPS or FTP URI. To access the file in Spark jobs,
* use `SparkFiles.get(fileName)` to find its download location.
*/
def addFile(path: String): Unit = {
addFile(path, false)
}

as mentioned above... SparkFiles.get(fileName) you can get the file name

or else SparkFiles has getRootDirectory to get the folder where you have added files and them you can access them.

/**
  * Get the root directory that contains files added through `SparkContext.addFile()`.
 */
 def getRootDirectory(): String =
 SparkEnv.get.driverTmpDir.getOrElse(".")

 }

or else

using sparkcontext.listFiles you can get the list of files as sequence.

Option 2 :  If you want to go ahead with --files option then you can follow my answer submitting multiple jars from a folder using same approach you can add multiple files from a folder separated by delimiter as well.

Hope this helps!


问:
Xcode 9 Crashing while setting a Texture in SKScene in Spritekit
I am building a game in Spritekit with Xcode currently. After updating to Xcode 9 I've found that every time I set a texture through the .sks file, Xcode crashes instantly. I've restarted my computer, updated the app, reloaded the textures and nothing changed. I have the 2017 Macbook Prof 13" w/ touch bar. Here are the diagnostics:</p>

```<code>Process:               Xcode [577]
Path:                  /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier:            com.apple.dt.Xcode
Version:               9.0.1 (13249)
Build Info:            IDEFrameworks-13249000000000000~2
App Item ID:           497799835
App External ID:       823984564
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Xcode [577]
User ID:               501

Date/Time:             2017-10-22 17:30:06.029 -0400
OS Version:            Mac OS X 10.12.6 (16G29)
Report Version:        12
Anonymous UUID:        0537A8C3-9FB2-836A-088B-E5D2B7FEB3EB

Time Awake Since Boot: 100 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: SKCRenderer_resource_queue

Exception Type:        EXC_BAD_ACCESS (SIGBUS)
Exception Codes:       KERN_PROTECTION_FAILURE at 0x000000012ceef7b8
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Bus error: 10
Termination Reason:    Namespace SIGNAL, Code 0xa
Terminating Process:   exc handler [0]

VM Regions Near 0x12ceef7b8:
    MALLOC_LARGE           000000012ceaf000-000000012ceef000 [  256K] rw-/rwx SM=PRV
--> mapped file            000000012ceef000-000000012cf22000 [  204K] r--/rw- SM=COW
    MALLOC_LARGE           000000012cf31000-000000012cf71000 [  256K] rw-/rwx SM=PRV

Application Specific Information:
Sending userDidChangeValue: to <SKInspectorTextureProperty: 0x7fadb2219440> from <NSComboBox: 0x7fadb221ad80>
ProductBuildVersion: 9A1004
Performing @selector(userDidChangeValue:) from sender NSComboBox 0x7fadb221ad80
</code>```

答:
OHM,I found the reason
It will occurs if your image not equal ratio with current size of skspritenode on storyboard
Good Luck!</p>

ContentLicense: CC BY-SA 4.0

Body:
I am building a game in Spritekit with Xcode currently. After updating to Xcode 9 I've found that every time I set a texture through the .sks file, Xcode crashes instantly. I've restarted my computer, updated the app, reloaded the textures and nothing changed. I have the 2017 Macbook Prof 13" w/ touch bar. Here are the diagnostics:

Process:               Xcode [577]
Path:                  /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier:            com.apple.dt.Xcode
Version:               9.0.1 (13249)
Build Info:            IDEFrameworks-13249000000000000~2
App Item ID:           497799835
App External ID:       823984564
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Xcode [577]
User ID:               501

Date/Time:             2017-10-22 17:30:06.029 -0400
OS Version:            Mac OS X 10.12.6 (16G29)
Report Version:        12
Anonymous UUID:        0537A8C3-9FB2-836A-088B-E5D2B7FEB3EB

Time Awake Since Boot: 100 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: SKCRenderer_resource_queue

Exception Type:        EXC_BAD_ACCESS (SIGBUS)
Exception Codes:       KERN_PROTECTION_FAILURE at 0x000000012ceef7b8
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Bus error: 10
Termination Reason:    Namespace SIGNAL, Code 0xa
Terminating Process:   exc handler [0]

VM Regions Near 0x12ceef7b8:
    MALLOC_LARGE           000000012ceaf000-000000012ceef000 [  256K] rw-/rwx SM=PRV
--> mapped file            000000012ceef000-000000012cf22000 [  204K] r--/rw- SM=COW
    MALLOC_LARGE           000000012cf31000-000000012cf71000 [  256K] rw-/rwx SM=PRV

Application Specific Information:
Sending userDidChangeValue: to <SKInspectorTextureProperty: 0x7fadb2219440> from <NSComboBox: 0x7fadb221ad80>
ProductBuildVersion: 9A1004
Performing @selector(userDidChangeValue:) from sender NSComboBox 0x7fadb221ad80


问:
Big blank space HTML
In some area I have this big space between some sentence:

Is there a way to correct this with CSS?

HTML for a second example:

```<code><span style="color: rgb(197, 0, 0); text-align: justify; font-size: 14px;">
    <span id="MainContent_rptTest_lblTitle_2">Support to Efficient, Effictive and Transparent</span><br>
        <div style="color: rgb(197, 0, 0); text-align: justify; font-size: 12px;">
            <strong>
                <span id="MainContent_rptTest_lblDescription_2">September 2009 – January 2010</span></strong></div>
    </span>
</code>```

答: Take out the text-align: justify. That's what it does to get the right margin of the text to line up. You can't have both.</p>

Title: Big blank space HTML

Body:
In some area I have this big space between some sentence:

Is there a way to correct this with CSS?

HTML for a second example:

    Support to Efficient, Effictive and Transparent

                September 2009 – January 2010


问:
How to open files with sublime text 3 from terminal?
Is there a way to do it? I looked for a similar question but only found one on MAC OSX. However, I'm using Ubuntu 14.04.</p>

答:
Yes ,There's a way. Just Use the command subl to open sublime text from terminal.
if you want to open a specific file use subl path/to/the/file.

But sublime text must be installed using ppa.
  For particular installation of sublime text 3 using ppa refer This Link on .


问:
Why one of the two object instances pointing to the same object behaves differently upon assigning NULL to any of them?
Consider below code snippet :

```<code><?php
  class SimpleClass {
    // property declaration
    public $var = 'a default value';

    // method declaration
    public function displayVar() {
      echo $this->var;
    }
  }

  $instance = new SimpleClass();

  $assigned   =  $instance;

  $instance->var = '$assigned will have this value';
  var_dump($instance);
  echo "<br>";
  var_dump($assigned);
?>
</code>```

The output of above code is as below :

```<code>object(SimpleClass)#1 (1) { ["var"]=> string(30) "$assigned will have this value" }
object(SimpleClass)#1 (1) { ["var"]=> string(30) "$assigned will have this value" }
</code>```

I understood the above program well. I understood the fact that any changes to either $instance or $assigned will be reflected in the other, because they are pointing to the same object instance.

But this principle is failing in below code upon assigning NULL to any of the two object instances. It is expected that both of the object instances should become NULL but one of the two contains NULL and other doesn't contain NULL. Why so?

```<code><?php
  class SimpleClass {
    // property declaration
    public $var = 'a default value';

    // method declaration
    public function displayVar() {
      echo $this->var;
    }
  }

  $instance = new SimpleClass();

  $assigned   =  $instance;

  $instance = NULL;
  var_dump($instance);
  echo "<br>";
  var_dump($assigned);
?>
</code>```

Output of above code is as below :

```<code>NULL
object(SimpleClass)#1 (1) { ["var"]=> string(15) "a default value" }
</code>```

Also, in the above code no where the class method displayVar() is being called which echoes the text 'a default value' nor there is any constructor method present then how the var property of an object instance $assigned is getting set instead of having NULL in it?

As both of the object instances are pointing to the same object why they behave in one way when NULLis assigned to one of them and other(the expected) way when string or some meaningful value is assigned to one of them?

答:
When you create an object, PHP creates a zval under the hood. It's some space in memory holding the object structure and data. Ok, it's somewhat more complex, but that's all you need to know for this case.

Assigning the object to $instance means you are assigning a pointer sort of thing to this zval. When you then do $assigned = $instance, PHP just makes $assigned point to this zval, too:

```<code>$instance -> your object <- $assigned
    ^                           ^
    |____________ = ____________|
</code>```

So you effectively have two separate pointers (indicated by -> and <- above) to the same underlying data structure.

When you assign NULL to one of the variables, you are only clearing out the pointer of this particular variable to the zval. But the other variable still points to it:

```<code>$instance = NULL;

// causes

$instance -> NULL
     ^       your object <- $assigned
     |                          ^
     |___________ != ___________|
</code>```

Let's try this in an interactive session (type php -a in your shell):

```<code>php > $a = new StdClass;
php > $a->foo = 42;
php > $b = $a;
php > var_dump($b);
object(stdClass)#1 (1) {
  ["foo"]=>
  int(42)
}
php > $a = null;
php > var_dump($b);
object(stdClass)#1 (1) {
  ["foo"]=>
  int(42)
}
</code>```

This is different from using an actual reference, where $assigned actually points to the pointer of $instance:

```<code>your object <- $instance <- $assigned
                   ^            ^
                   |_____= _____|
</code>```

When you set $instance to NULL here, you are deleting the connection between your object and the $instance, so $assigned also loses it's (indirect) connection to your object.

```<code>php > $a = new StdClass;
php > $a->foo = 42;
php > $b = &$a;
php > var_dump($b);
object(stdClass)#2 (1) {
  ["foo"]=>
  int(42)
}
php > $a = null;
php > var_dump($b);
NULL
</code>```

By doing $b = &$a; $b doesn't point to the zval directly, but to $a actually, hence when you assign NULL to $a, $b will be whatever you assigned $a to and vice versa, e.g. if you do $b = 42 afterwards, $a would be 42 as well:

```<code>$instance = null;
// causes
null <- $instance <- $assigned
            ^            ^
            |_____= _____|
</code>```

So even when you set $instance = null you are still maintaining the reference from $assigned to $instance. To completely delete/unlink the association between $a and $b, you'd need to use unset.

Body:
Consider below code snippet :

<?php
  class SimpleClass {
    // property declaration
    public $var = 'a default value';

    // method declaration
    public function displayVar() {
      echo $this->var;
    }
  }

  $instance = new SimpleClass();

  $assigned   =  $instance;

  $instance->var = '$assigned will have this value';
  var_dump($instance);
  echo "
";
  var_dump($assigned);
?>

The output of above code is as below :

object(SimpleClass)#1 (1) { ["var"]=> string(30) "$assigned will have this value" }
object(SimpleClass)#1 (1) { ["var"]=> string(30) "$assigned will have this value" }

I understood the above program well. I understood the fact that any changes to either $instance or $assigned will be reflected in the other, because they are pointing to the same object instance.

But this principle is failing in below code upon assigning NULL to any of the two object instances. It is expected that both of the object instances should become NULL but one of the two contains NULL and other doesn't contain NULL. Why so?

<?php
  class SimpleClass {
    // property declaration
    public $var = 'a default value';

    // method declaration
    public function displayVar() {
      echo $this->var;
    }
  }

  $instance = new SimpleClass();

  $assigned   =  $instance;

  $instance = NULL;
  var_dump($instance);
  echo "
";
  var_dump($assigned);
?>

Output of above code is as below :

NULL
object(SimpleClass)#1 (1) { ["var"]=> string(15) "a default value" }

Also, in the above code no where the class method displayVar() is being called which echoes the text 'a default value' nor there is any constructor method present then how the var property of an object instance $assigned is getting set instead of having NULL in it?

As both of the object instances are pointing to the same object why they behave in one way when NULLis assigned to one of them and other(the expected) way when string or some meaningful value is assigned to one of them?

Body:
When you create an object, PHP creates a zval under the hood. It's some space in memory holding the object structure and data. Ok, it's somewhat more complex, but that's all you need to know for this case.

Assigning the object to $instance means you are assigning a pointer sort of thing to this zval. When you then do $assigned = $instance, PHP just makes $assigned point to this zval, too:

$instance -> your object <- $assigned
    ^                           ^
    |____________ = ____________|

So you effectively have two separate pointers (indicated by -> and <- above) to the same underlying data structure.

When you assign NULL to one of the variables, you are only clearing out the pointer of this particular variable to the zval. But the other variable still points to it:

$instance = NULL;

// causes

$instance -> NULL
     ^       your object <- $assigned
     |                          ^
     |___________ != ___________|

Let's try this in an interactive session (type php -a in your shell):

php > $a = new StdClass;
php > $a->foo = 42;
php > $b = $a;
php > var_dump($b);
object(stdClass)#1 (1) {
  ["foo"]=>
  int(42)
}
php > $a = null;
php > var_dump($b);
object(stdClass)#1 (1) {
  ["foo"]=>
  int(42)
}

This is different from using an actual reference, where $assigned actually points to the pointer of $instance:

your object <- $instance <- $assigned
                   ^            ^
                   |_____= _____|

When you set $instance to NULL here, you are deleting the connection between your object and the $instance, so $assigned also loses it's (indirect) connection to your object.

php > $a = new StdClass;
php > $a->foo = 42;
php > $b = &$a;
php > var_dump($b);
object(stdClass)#2 (1) {
  ["foo"]=>
  int(42)
}
php > $a = null;
php > var_dump($b);
NULL

By doing $b = &$a; $b doesn't point to the zval directly, but to $a actually, hence when you assign NULL to $a, $b will be whatever you assigned $a to and vice versa, e.g. if you do $b = 42 afterwards, $a would be 42 as well:

$instance = null;
// causes
null <- $instance <- $assigned
            ^            ^
            |_____= _____|

So even when you set $instance = null you are still maintaining the reference from $assigned to $instance. To completely delete/unlink the association between $a and $b, you'd need to use unset.


问:
Store object into array and group all array with the same value in PHP
I'm working on array right now and I need to arrange this based on value.

```<code>{
        "data": {
            "id": 2,
            "title": "second evaluation form",
            "emp_position": "System Architecture",
            "rating": 5,
            "segments": [
                {
                    "segment_name": "Job Role ",
                    "question": "How old are you?"
                },
                {
                    "segment_name": "360 Segments",
                    "question": "What is your food?"
                },
                {
                    "segment_name": "360 Segments",
                    "question": "sample question"
                },
            ]
        }
    }
</code>```

What I need to do is to store this object into array and group all question based on segment_name like this:

```<code>{
    "data":[
         {
            "id": 2,
            "title": "second evaluation form",
            "emp_position": "System Architecture",
            "rating": 5,
            "segments": [
                {
                    "segment_name": "Job Role "
                    "question_collection": [
                        {
                            "id": 4,
                            "question": "How old are you?"
                        }
                    ]

                },
                {
                    "segment_name": "360 Segments",
                    "question_collection":[
                        {
                           "id": 1,
                           "question": "What is your food?"
                        },
                        {
                             "id": 2,
                            "question": "sample question"
                         }
                    ]
                },

            ]
        }
    ]
}
</code>```

And this is what I've tried to do:

```<code> $array_value =[];
        foreach ($query AS $key => &$data) {
            $array_value['id'] = $data['id'];
            $array_value['title'] = $data['title'];
            $array_value['emp_position'] = $data['position'];
            $array_value['rating'] = $data['rating_count'];

            if ( is_array($data) ) {
               $array_value['segments'][$key]['segment_name'] = $data['segment'];
               $array_value['segments'][$key]['question'] = $data['question'];
            }

        }
</code>```

答:
Collection function might help you find your solution.

```<code>$json = '{"data":{"id":2,"title":"second evaluation form","emp_position":"System Architecture","rating":5,"segments":[{"segment_name":"Job Role ","question":"How old are you?"},{"segment_name":"360 Segments","question":"What is your food?"},{"segment_name":"360 Segments","question":"sample question"}]}}';

    $array = json_decode($json, true);
    $coll = collect($array['data']['segments']);
    $coll = $coll->groupBy('segment_name');
    dump($coll);
</code>```

Hope this helps you.Let me know if any problem

Body:
I'm working on array right now and I need to arrange this based on value.

{
        "data": {
            "id": 2,
            "title": "second evaluation form",
            "emp_position": "System Architecture",
            "rating": 5,
            "segments": [
                {
                    "segment_name": "Job Role ",
                    "question": "How old are you?"
                },
                {
                    "segment_name": "360 Segments",
                    "question": "What is your food?"
                },
                {
                    "segment_name": "360 Segments",
                    "question": "sample question"
                },
            ]
        }
    }

What I need to do is to store this object into array and group all question based on segment_name like this:

{
    "data":[
         {
            "id": 2,
            "title": "second evaluation form",
            "emp_position": "System Architecture",
            "rating": 5,
            "segments": [
                {
                    "segment_name": "Job Role "
                    "question_collection": [
                        {
                            "id": 4,
                            "question": "How old are you?"
                        }
                    ]

                },
                {
                    "segment_name": "360 Segments",
                    "question_collection":[
                        {
                           "id": 1,
                           "question": "What is your food?"
                        },
                        {
                             "id": 2,
                            "question": "sample question"
                         }
                    ]
                },

            ]
        }
    ]
}

And this is what I've tried to do:

 $array_value =[];
        foreach ($query AS $key => &$data) {
            $array_value['id'] = $data['id'];
            $array_value['title'] = $data['title'];
            $array_value['emp_position'] = $data['position'];
            $array_value['rating'] = $data['rating_count'];

            if ( is_array($data) ) {
               $array_value['segments'][$key]['segment_name'] = $data['segment'];
               $array_value['segments'][$key]['question'] = $data['question'];
            }

        }

Body:
Collection function might help you find your solution.

$json = '{"data":{"id":2,"title":"second evaluation form","emp_position":"System Architecture","rating":5,"segments":[{"segment_name":"Job Role ","question":"How old are you?"},{"segment_name":"360 Segments","question":"What is your food?"},{"segment_name":"360 Segments","question":"sample question"}]}}';

    $array = json_decode($json, true);
    $coll = collect($array['data']['segments']);
    $coll = $coll->groupBy('segment_name');
    dump($coll);

Hope this helps you.Let me know if any problem


问:
unable to open div box as layer using z-index
I am trying to open action div box as layer in but unable to do that.

when i click on action button div box will open within that  only. it should be open as layer.

Code:

ul {
  z-index: 2
}

table {
  z-index: 1
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
  <thead>
    <tr>
      <th>Sr.No</th>
      <th>LeadCreated DateTime</th>
      <th>RetailerName</th>
      <th>ShopName</th>
      <th>Mobile</th>
      <th>Address</th>
      <th>City</th>
      <th>Pincode</th>
      <th>Status</th>
      <th>Action</th>
    </tr>
  </thead>
  <tbody>

    <tr class="odd gradeX">
      <td>1</td>
      <td>10-10-2017</td>
      <td>Test</td>
      <td>Test</td>
      <td>9904773479</td>
      <td>Surat</td>
      <td>Surat</td>
      <td>304230</td>
      <td style="background: <?php if ($row->Status == 'InProcess') echo 'green';if ($row->Status == 'Closed') echo 'orange';if ($row->Status == 'Dead') echo 'black'; ?>;color: #FFFFFF">
        <?= $row->Status ?>
      </td>
      <td class="pbutton">
        <div class="btn-group">
          <!-- Button trigger modal -->
          <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
                                                                Action <span class="caret"></span>
                                                            </button>
          <ul class="dropdown-menu pull-right " role="menu" style="position: relative;width: 160px;z-index: 99">
            <li>LeadId ?>" data-toggle="modal" data-target="#viewleadmodal"><span class="glyphicon glyphicon-fullscreen"></span> View</li>
            <li><span class="fa fa-edit"></span> Add Lead Update</li>
            <li><span class="fa fa-edit"></span> Edit</li>
            <li><span class="glyphicon glyphicon-trash"></span> Delete</li>
          </ul>
        </div>
      </td>
    </tr>

  </tbody>
</table></code>```

答:
Override the ul.dropdown-menu styles to make it absolute, either use !important or override the inline styles.

```<code>ul.dropdown-menu{
  position: absolute !important;
  width: 200px;
  top: 15%;
  left: 20%;
}
</code>```

ul.dropdown-menu {
  z-index: 2
}

table {
  z-index: 1
  position: relative;
}
ul.dropdown-menu{
  position: absolute !important;
  width: 200px;
  top: 15%;
  left: 20%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
  <thead>
    <tr>
      <th>Sr.No</th>
      <th>LeadCreated DateTime</th>
      <th>RetailerName</th>
      <th>ShopName</th>
      <th>Mobile</th>
      <th>Address</th>
      <th>City</th>
      <th>Pincode</th>
      <th>Status</th>
      <th>Action</th>
    </tr>
  </thead>
  <tbody>

    <tr class="odd gradeX">
      <td>1</td>
      <td>10-10-2017</td>
      <td>Test</td>
      <td>Test</td>
      <td>9904773479</td>
      <td>Surat</td>
      <td>Surat</td>
      <td>304230</td>
      <td style="background: <?php if ($row->Status == 'InProcess') echo 'green';if ($row->Status == 'Closed') echo 'orange';if ($row->Status == 'Dead') echo 'black'; ?>;color: #FFFFFF">
        <?= $row->Status ?>
      </td>
      <td class="pbutton">
        <div class="btn-group">
          <!-- Button trigger modal -->
          <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
                                                                Action <span class="caret"></span>
                                                            </button>
          <ul class="dropdown-menu pull-right " role="menu" style="position: relative;width: 160px;z-index: 99">
            <li>LeadId ?>" data-toggle="modal" data-target="#viewleadmodal"><span class="glyphicon glyphicon-fullscreen"></span> View</li>
            <li><span class="fa fa-edit"></span> Add Lead Update</li>
            <li><span class="fa fa-edit"></span> Edit</li>
            <li><span class="glyphicon glyphicon-trash"></span> Delete</li>
          </ul>
        </div>
      </td>
    </tr>

  </tbody>
</table></code>```

Body:
I am trying to open action div box as layer in but unable to do that.

when i click on action button div box will open within that  only. it should be open as layer.

Code:

ul {
  z-index: 2
}

table {
  z-index: 1
}

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

      Sr.No
      LeadCreated DateTime
      RetailerName
      ShopName
      Mobile
      Address
      City
      Pincode
      Status
      Action

      1
      10-10-2017
      Test
      Test
      9904773479
      Surat
      Surat
      304230
      <td style="background: <?php if ($row->Status == 'InProcess') echo 'green';if ($row->Status == 'Closed') echo 'orange';if ($row->Status == 'Dead') echo 'black'; ?>;color: #FFFFFF">
        <?= $row->Status ?>

          <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
                                                                Action
                                                            </button>

<a href="#viewleadmodal" data-id="<?= $row->LeadId ?>" data-toggle="modal" data-target="#viewleadmodal"> View

 Add Lead Update

 Edit

 Delete

Body:
Override the ul.dropdown-menu styles to make it absolute, either use !important or override the inline styles.

ul.dropdown-menu{
  position: absolute !important;
  width: 200px;
  top: 15%;
  left: 20%;
}

ul.dropdown-menu {
  z-index: 2
}

table {
  z-index: 1
  position: relative;
}
ul.dropdown-menu{
  position: absolute !important;
  width: 200px;
  top: 15%;
  left: 20%;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
  <thead>
    <tr>
      <th>Sr.No</th>
      <th>LeadCreated DateTime</th>
      <th>RetailerName</th>
      <th>ShopName</th>
      <th>Mobile</th>
      <th>Address</th>
      <th>City</th>
      <th>Pincode</th>
      <th>Status</th>
      <th>Action</th>
    </tr>
  </thead>
  <tbody>

    <tr class="odd gradeX">
      <td>1</td>
      <td>10-10-2017</td>
      <td>Test</td>
      <td>Test</td>
      <td>9904773479</td>
      <td>Surat</td>
      <td>Surat</td>
      <td>304230</td>
      <td style="background: <?php if ($row->Status == 'InProcess') echo 'green';if ($row->Status == 'Closed') echo 'orange';if ($row->Status == 'Dead') echo 'black'; ?>;color: #FFFFFF">
        <?= $row->Status ?>
      </td>
      <td class="pbutton">
        <div class="btn-group">
          <!-- Button trigger modal -->
          <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
                                                                Action <span class="caret"></span>
                                                            </button>
          <ul class="dropdown-menu pull-right " role="menu" style="position: relative;width: 160px;z-index: 99">
            <li><a href="#viewleadmodal" data-id="<?= $row->LeadId ?>" data-toggle="modal" data-target="#viewleadmodal"><span class="glyphicon glyphicon-fullscreen"></span>&nbsp;View</a></li>
            <li><a href="followup.php?LeadId=1"><span class="fa fa-edit"></span>&nbsp;Add Lead Update</a></li>
            <li><a href="leadedit.php"><span class="fa fa-edit"></span>&nbsp;Edit</a></li>
            <li><a href="javascript:void(0)" onclick="check_perform_sdelete('14');"><span class="glyphicon glyphicon-trash"></span>&nbsp;Delete</a></li>
          </ul>
        </div>
      </td>
    </tr>

  </tbody>
</table>


问:
DYNAMIC-EXTENT ignored in CLISP?
I read here that "it is permissible for an implementation to ignore" the dynamic-extent declaration in Common Lisp, and I was wondering if it is in fact ignored in the CLISP implementation.

I have tried testing with the following code:

```<code>(let ((b (cons 1 2)))
 (declare (dynamic-extent b))
 (list b))
</code>```

Which returns:

```<code>((1 . 2))
</code>```

My guess is that it is ignored, but I wanted to be sure.

Also, if it is ignored, is there a way for me to explicitly allocate memory to the stack rather than the heap?

答:
This is actually a great question! (have ingratiate myself because my karma is so low!)

As others have mentioned CLISP ignores declare dynamic-extent. However other implementations do obey it, and for good reason. Quoting SBCL:

SBCL has fairly extensive support for performing allocation on the
  stack when a variable is declared dynamic-extent. The
  dynamic-extent declarations are not verified, but are simply
  trusted as long as sb-ext:*stack-allocate-dynamic-extent* is
  true.

Also, keep in mind that CL declarations are promises made by the programmer to the lisp system. Declarations, in general, have no defined observable behavior either when the programmer keeps his promise or when they are broken.

The alway helpful and cheery SBCL documentation goes on to say:

If dynamic extent constraints specified in the Common Lisp standard
  are violated, the best that can happen is for the program to have
  garbage in variables and return values; more commonly, the system will
  crash.

In particular, it is important to realize that dynamic extend is
  contagious:

```<code>(let* ((a (list 1 2 3))
       (b (cons a a)))
   (declare (dynamic-extent b))
   ;; Unless A is accessed elsewhere as well, SBCL will consider
   ;; it to be otherwise inaccessible -- it can only be accessed
   ;; through B, after all -- and stack allocate it as well.
   ;;
   ;; Hence returning (CAR B) here is unsafe.
   ...)
</code>```

The takeaway being: generally in lisp declarations don't result in the change of a conforming program's 'meaning'. All bets are off if your program runs counter to your declared intent.  What the 'effect' of a declaration is, i.e. how the compiler optimizes the resulting code (and whether it optimizes it at all) vary from implementation to implementation and even from version to version.

Title: DYNAMIC-EXTENT ignored in CLISP?

Body:
I read here that "it is permissible for an implementation to ignore" the dynamic-extent declaration in Common Lisp, and I was wondering if it is in fact ignored in the CLISP implementation.

I have tried testing with the following code:

(let ((b (cons 1 2)))
 (declare (dynamic-extent b))
 (list b))

Which returns:

((1 . 2))

My guess is that it is ignored, but I wanted to be sure.

Also, if it is ignored, is there a way for me to explicitly allocate memory to the stack rather than the heap?

Body:
This is actually a great question! (have ingratiate myself because my karma is so low!)

As others have mentioned CLISP ignores declare dynamic-extent. However other implementations do obey it, and for good reason. Quoting SBCL:

SBCL has fairly extensive support for performing allocation on the
  stack when a variable is declared dynamic-extent. The
  dynamic-extent declarations are not verified, but are simply
  trusted as long as sb-ext:*stack-allocate-dynamic-extent* is
  true.

Also, keep in mind that CL declarations are promises made by the programmer to the lisp system. Declarations, in general, have no defined observable behavior either when the programmer keeps his promise or when they are broken.

The alway helpful and cheery SBCL documentation goes on to say:

If dynamic extent constraints specified in the Common Lisp standard
  are violated, the best that can happen is for the program to have
  garbage in variables and return values; more commonly, the system will
  crash.

In particular, it is important to realize that dynamic extend is
  contagious:

(let* ((a (list 1 2 3))
       (b (cons a a)))
   (declare (dynamic-extent b))
   ;; Unless A is accessed elsewhere as well, SBCL will consider
   ;; it to be otherwise inaccessible -- it can only be accessed
   ;; through B, after all -- and stack allocate it as well.
   ;;
   ;; Hence returning (CAR B) here is unsafe.
   ...)

The takeaway being: generally in lisp declarations don't result in the change of a conforming program's 'meaning'. All bets are off if your program runs counter to your declared intent.  What the 'effect' of a declaration is, i.e. how the compiler optimizes the resulting code (and whether it optimizes it at all) vary from implementation to implementation and even from version to version.


问:
I want to create a json structure like this with the gson library with the proper object creation
```<code>{
   "restaurantId":"0a60fa5e-642c-4e4f-ae37-a7c8093e1659",
   "restaurantName":"Food Market",
   "paymentRefKey":"cpmqmvpv",
   "paymentStatus":"success",
   "paymentMode":"paypal_account",
   "transactionStatus":"settling",
   "payerId":"PAYER_ID-2f3c6088eb828dab",
   "paypalPaymentId":"PAY-e43a2913d8ad92ccda1cf872",
   "orderNetAmount":"21.825",
   "salesTax":0,
   "serviceFee":1.575,
   "discount":0,
   "subTotal":22.5,
   "orderQuantity":1,
   "userId":"68503c6e-9475-4081-8bdf-199bc194745f",
   "firstName":"test",
   "lastName":"customer",
   "email":"test.customer@yopmail.com",
   "contactNumber":"9516238470",
   "couponcode":{
      "type":"percent",
      "midval":2.25,
      "code":"QDH596"
   },
   "orderLines":[
      {
         "quantity":1,
         "offerId":"2bb21254-fe7d-4695-ae99-d420fdae3aca",
         "startValidity":"2017-09-26T06:55:00.000Z",
         "endValidity":"2017-11-02T01:00:00.000Z",
         "categoryId":"dbae9249-705a-4d7a-86ce-6f5c5c180855",
         "itemName":"Dosa.",
         "menuId":"02bfcaec-0bb1-42b9-87a5-c60e04fcf9fc",
         "actualPrice":25,
         "dealPrice":22.5,
         "netAmount":22.5,
         "discountPercent":10,
         "type":"offer",
         "itemImagePath":"offers/offer_1506408444171.jpeg",
         "unlimitedQuantity":true
      }
   ]
}
</code>```

this is the json formate i want to make by using gson in android i have make pojo class but i could not generate the  same formate
i generate the formate using gson as below

```<code>[
   {
      "contactNumber":"8149425758",
      "couponcode":{
         "midval":0,
         "type":"percent"
      },
      "discount":0,
      "email":"udasibharat1@gmail.com",
      "firstName":"Bharat",
      "lastName":"Udasi",
      "orderLines":[
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509619452389.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"6d16df4a-ab9c-4930-8337-2b3f65969fb8",
            "quantity":3,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":false
         },
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509609642206.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"d4152ba9-a5bc-4f5b-ad03-a5180a0e0199",
            "quantity":11,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":80,
            "dealPrice":80,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Burger_1507295095917.jpeg",
            "itemName":"Burger",
            "menuId":"5ea97c74-74fe-4e96-beb6-ba7772a160e3",
            "netAmount":80,
            "quantity":11,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":50,
            "dealPrice":50,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Panir-Tikka_1507295128370.jpeg",
            "itemName":"Panir Tikka",
            "menuId":"70b4d4d3-2679-4e16-a90c-b081401c268f",
            "netAmount":50,
            "quantity":9,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         }
      ],
      "orderNetAmount":"24.0",
      "orderQuantity":34,
      "payerId":"60g59yxg",
      "paymentMode":"paypal_account",
      "paymentRefKey":"60g59yxg",
      "paymentStatus":"1000",
      "paypalPaymentId":"60g59yxg",
      "restaurantId":"9b104614-b02f-45aa-ab6e-a2afd569835a",
      "restaurantName":"Michel Plaza",
      "salesTax":0,
      "serviceFee":156.8,
      "subTotal":1960,
      "transactionStatus":"settling",
      "userId":"538eb196-3f6a-415e-bd13-ffc4191c37b1"
   },
   {
      "contactNumber":"8149425758",
      "couponcode":{
         "midval":0,
         "type":"percent"
      },
      "discount":0,
      "email":"udasibharat1@gmail.com",
      "firstName":"Bharat",
      "lastName":"Udasi",
      "orderLines":[
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509619452389.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"6d16df4a-ab9c-4930-8337-2b3f65969fb8",
            "quantity":3,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":false
         },
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509609642206.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"d4152ba9-a5bc-4f5b-ad03-a5180a0e0199",
            "quantity":11,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":80,
            "dealPrice":80,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Burger_1507295095917.jpeg",
            "itemName":"Burger",
            "menuId":"5ea97c74-74fe-4e96-beb6-ba7772a160e3",
            "netAmount":80,
            "quantity":11,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":50,
            "dealPrice":50,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Panir-Tikka_1507295128370.jpeg",
            "itemName":"Panir Tikka",
            "menuId":"70b4d4d3-2679-4e16-a90c-b081401c268f",
            "netAmount":50,
            "quantity":9,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         }
      ],
      "orderNetAmount":"24.0",
      "orderQuantity":34,
      "payerId":"60g59yxg",
      "paymentMode":"paypal_account",
      "paymentRefKey":"60g59yxg",
      "paymentStatus":"1000",
      "paypalPaymentId":"60g59yxg",
      "restaurantId":"9b104614-b02f-45aa-ab6e-a2afd569835a",
      "restaurantName":"Michel Plaza",
      "salesTax":0,
      "serviceFee":156.8,
      "subTotal":1960,
      "transactionStatus":"settling",
      "userId":"538eb196-3f6a-415e-bd13-ffc4191c37b1"
   },
   {
      "contactNumber":"8149425758",
      "couponcode":{
         "midval":0,
         "type":"percent"
      },
      "discount":0,
      "email":"udasibharat1@gmail.com",
      "firstName":"Bharat",
      "lastName":"Udasi",
      "orderLines":[
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509619452389.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"6d16df4a-ab9c-4930-8337-2b3f65969fb8",
            "quantity":3,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":false
         },
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509609642206.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"d4152ba9-a5bc-4f5b-ad03-a5180a0e0199",
            "quantity":11,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":80,
            "dealPrice":80,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Burger_1507295095917.jpeg",
            "itemName":"Burger",
            "menuId":"5ea97c74-74fe-4e96-beb6-ba7772a160e3",
            "netAmount":80,
            "quantity":11,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":50,
            "dealPrice":50,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Panir-Tikka_1507295128370.jpeg",
            "itemName":"Panir Tikka",
            "menuId":"70b4d4d3-2679-4e16-a90c-b081401c268f",
            "netAmount":50,
            "quantity":9,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         }
      ],
      "orderNetAmount":"24.0",
      "orderQuantity":34,
      "payerId":"60g59yxg",
      "paymentMode":"paypal_account",
      "paymentRefKey":"60g59yxg",
      "paymentStatus":"1000",
      "paypalPaymentId":"60g59yxg",
      "restaurantId":"9b104614-b02f-45aa-ab6e-a2afd569835a",
      "restaurantName":"Michel Plaza",
      "salesTax":0,
      "serviceFee":156.8,
      "subTotal":1960,
      "transactionStatus":"settling",
      "userId":"538eb196-3f6a-415e-bd13-ffc4191c37b1"
   },
   {
      "contactNumber":"8149425758",
      "couponcode":{
         "midval":0,
         "type":"percent"
      },
      "discount":0,
      "email":"udasibharat1@gmail.com",
      "firstName":"Bharat",
      "lastName":"Udasi",
      "orderLines":[
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509619452389.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"6d16df4a-ab9c-4930-8337-2b3f65969fb8",
            "quantity":3,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":false
         },
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509609642206.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"d4152ba9-a5bc-4f5b-ad03-a5180a0e0199",
            "quantity":11,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":80,
            "dealPrice":80,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Burger_1507295095917.jpeg",
            "itemName":"Burger",
            "menuId":"5ea97c74-74fe-4e96-beb6-ba7772a160e3",
            "netAmount":80,
            "quantity":11,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":50,
            "`enter code here`dealPrice":50,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Panir-Tikka_1507295128370.jpeg",
            "itemName":"Panir Tikka",
            "menuId":"70b4d4d3-2679-4e16-a90c-b081401c268f",
            "netAmount":50,
            "quantity":9,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         }
      ],
      "orderNetAmount":"24.0",
      "orderQuantity":34,
      "payerId":"60g59yxg",
      "paymentMode":"paypal_account",
      "paymentRefKey":"60g59yxg",
      "paymentStatus":"1000",
      "paypalPaymentId":"60g59yxg",
      "restaurantId":"9b104614-b02f-45aa-ab6e-a2afd569835a",
      "restaurantName":"Michel Plaza",
      "salesTax":0,
      "serviceFee":156.8,
      "subTotal":1960,
      "transactionStatus":"settling",
      "userId":"538eb196-3f6a-415e-bd13-ffc4191c37b1"
   }
]
</code>```

答:
You already done all the parts. last thing you need to do, convert gson string to JSONArray. use this code for that

```<code>JSONArray jsonarray = new JSONArray("gson string");
</code>```

if you need like this

```<code>{
   "restaurantId":"0a60fa5e-642c-4e4f-ae37-a7c8093e1659",
      '
      '
      '
      '
      '
   "contactNumber":"9516238470",
   "couponcode":{
      '
      '
      '
      '
   },
   "orderLines":[
      '
      '
      '
      '
   ]
}
</code>```

not like this

```<code>{
   "contactNumber":"8149425758",
      '
      '
      '
      '
      '
   "couponcode":{
      '
      '
      '
      '
   },
   "lastName":"Udasi",
   "orderLines":[
      '
      '
      '
      '
   ],
   "orderNetAmount":"24.0",
      '
      '
      '
}
</code>```

this happen because data sorted by element key. look at element key then u can see

Body:
{
   "restaurantId":"0a60fa5e-642c-4e4f-ae37-a7c8093e1659",
   "restaurantName":"Food Market",
   "paymentRefKey":"cpmqmvpv",
   "paymentStatus":"success",
   "paymentMode":"paypal_account",
   "transactionStatus":"settling",
   "payerId":"PAYER_ID-2f3c6088eb828dab",
   "paypalPaymentId":"PAY-e43a2913d8ad92ccda1cf872",
   "orderNetAmount":"21.825",
   "salesTax":0,
   "serviceFee":1.575,
   "discount":0,
   "subTotal":22.5,
   "orderQuantity":1,
   "userId":"68503c6e-9475-4081-8bdf-199bc194745f",
   "firstName":"test",
   "lastName":"customer",
   "email":"test.customer@yopmail.com",
   "contactNumber":"9516238470",
   "couponcode":{
      "type":"percent",
      "midval":2.25,
      "code":"QDH596"
   },
   "orderLines":[
      {
         "quantity":1,
         "offerId":"2bb21254-fe7d-4695-ae99-d420fdae3aca",
         "startValidity":"2017-09-26T06:55:00.000Z",
         "endValidity":"2017-11-02T01:00:00.000Z",
         "categoryId":"dbae9249-705a-4d7a-86ce-6f5c5c180855",
         "itemName":"Dosa.",
         "menuId":"02bfcaec-0bb1-42b9-87a5-c60e04fcf9fc",
         "actualPrice":25,
         "dealPrice":22.5,
         "netAmount":22.5,
         "discountPercent":10,
         "type":"offer",
         "itemImagePath":"offers/offer_1506408444171.jpeg",
         "unlimitedQuantity":true
      }
   ]
}

this is the json formate i want to make by using gson in android i have make pojo class but i could not generate the  same formate
i generate the formate using gson as below

[
   {
      "contactNumber":"8149425758",
      "couponcode":{
         "midval":0,
         "type":"percent"
      },
      "discount":0,
      "email":"udasibharat1@gmail.com",
      "firstName":"Bharat",
      "lastName":"Udasi",
      "orderLines":[
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509619452389.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"6d16df4a-ab9c-4930-8337-2b3f65969fb8",
            "quantity":3,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":false
         },
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509609642206.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"d4152ba9-a5bc-4f5b-ad03-a5180a0e0199",
            "quantity":11,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":80,
            "dealPrice":80,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Burger_1507295095917.jpeg",
            "itemName":"Burger",
            "menuId":"5ea97c74-74fe-4e96-beb6-ba7772a160e3",
            "netAmount":80,
            "quantity":11,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":50,
            "dealPrice":50,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Panir-Tikka_1507295128370.jpeg",
            "itemName":"Panir Tikka",
            "menuId":"70b4d4d3-2679-4e16-a90c-b081401c268f",
            "netAmount":50,
            "quantity":9,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         }
      ],
      "orderNetAmount":"24.0",
      "orderQuantity":34,
      "payerId":"60g59yxg",
      "paymentMode":"paypal_account",
      "paymentRefKey":"60g59yxg",
      "paymentStatus":"1000",
      "paypalPaymentId":"60g59yxg",
      "restaurantId":"9b104614-b02f-45aa-ab6e-a2afd569835a",
      "restaurantName":"Michel Plaza",
      "salesTax":0,
      "serviceFee":156.8,
      "subTotal":1960,
      "transactionStatus":"settling",
      "userId":"538eb196-3f6a-415e-bd13-ffc4191c37b1"
   },
   {
      "contactNumber":"8149425758",
      "couponcode":{
         "midval":0,
         "type":"percent"
      },
      "discount":0,
      "email":"udasibharat1@gmail.com",
      "firstName":"Bharat",
      "lastName":"Udasi",
      "orderLines":[
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509619452389.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"6d16df4a-ab9c-4930-8337-2b3f65969fb8",
            "quantity":3,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":false
         },
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509609642206.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"d4152ba9-a5bc-4f5b-ad03-a5180a0e0199",
            "quantity":11,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":80,
            "dealPrice":80,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Burger_1507295095917.jpeg",
            "itemName":"Burger",
            "menuId":"5ea97c74-74fe-4e96-beb6-ba7772a160e3",
            "netAmount":80,
            "quantity":11,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":50,
            "dealPrice":50,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Panir-Tikka_1507295128370.jpeg",
            "itemName":"Panir Tikka",
            "menuId":"70b4d4d3-2679-4e16-a90c-b081401c268f",
            "netAmount":50,
            "quantity":9,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         }
      ],
      "orderNetAmount":"24.0",
      "orderQuantity":34,
      "payerId":"60g59yxg",
      "paymentMode":"paypal_account",
      "paymentRefKey":"60g59yxg",
      "paymentStatus":"1000",
      "paypalPaymentId":"60g59yxg",
      "restaurantId":"9b104614-b02f-45aa-ab6e-a2afd569835a",
      "restaurantName":"Michel Plaza",
      "salesTax":0,
      "serviceFee":156.8,
      "subTotal":1960,
      "transactionStatus":"settling",
      "userId":"538eb196-3f6a-415e-bd13-ffc4191c37b1"
   },
   {
      "contactNumber":"8149425758",
      "couponcode":{
         "midval":0,
         "type":"percent"
      },
      "discount":0,
      "email":"udasibharat1@gmail.com",
      "firstName":"Bharat",
      "lastName":"Udasi",
      "orderLines":[
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509619452389.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"6d16df4a-ab9c-4930-8337-2b3f65969fb8",
            "quantity":3,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":false
         },
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509609642206.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"d4152ba9-a5bc-4f5b-ad03-a5180a0e0199",
            "quantity":11,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":80,
            "dealPrice":80,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Burger_1507295095917.jpeg",
            "itemName":"Burger",
            "menuId":"5ea97c74-74fe-4e96-beb6-ba7772a160e3",
            "netAmount":80,
            "quantity":11,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":50,
            "dealPrice":50,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Panir-Tikka_1507295128370.jpeg",
            "itemName":"Panir Tikka",
            "menuId":"70b4d4d3-2679-4e16-a90c-b081401c268f",
            "netAmount":50,
            "quantity":9,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         }
      ],
      "orderNetAmount":"24.0",
      "orderQuantity":34,
      "payerId":"60g59yxg",
      "paymentMode":"paypal_account",
      "paymentRefKey":"60g59yxg",
      "paymentStatus":"1000",
      "paypalPaymentId":"60g59yxg",
      "restaurantId":"9b104614-b02f-45aa-ab6e-a2afd569835a",
      "restaurantName":"Michel Plaza",
      "salesTax":0,
      "serviceFee":156.8,
      "subTotal":1960,
      "transactionStatus":"settling",
      "userId":"538eb196-3f6a-415e-bd13-ffc4191c37b1"
   },
   {
      "contactNumber":"8149425758",
      "couponcode":{
         "midval":0,
         "type":"percent"
      },
      "discount":0,
      "email":"udasibharat1@gmail.com",
      "firstName":"Bharat",
      "lastName":"Udasi",
      "orderLines":[
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509619452389.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"6d16df4a-ab9c-4930-8337-2b3f65969fb8",
            "quantity":3,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":false
         },
         {
            "actualPrice":50,
            "dealPrice":45,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"https://s3.amazonaws.com/bigzpoon-develop/offers/offer_1509609642206.png",
            "itemName":"Panir Tikka",
            "netAmount":45,
            "offerId":"d4152ba9-a5bc-4f5b-ad03-a5180a0e0199",
            "quantity":11,
            "startValidity":"1970-01-01T01:30:00.000Z",
            "type":"offer",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":80,
            "dealPrice":80,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Burger_1507295095917.jpeg",
            "itemName":"Burger",
            "menuId":"5ea97c74-74fe-4e96-beb6-ba7772a160e3",
            "netAmount":80,
            "quantity":11,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         },
         {
            "actualPrice":50,
            "`enter code here`dealPrice":50,
            "discountPercent":0,
            "endValidity":"1970-01-01T17:30:00.000Z",
            "itemImagePath":"menu/Panir-Tikka_1507295128370.jpeg",
            "itemName":"Panir Tikka",
            "menuId":"70b4d4d3-2679-4e16-a90c-b081401c268f",
            "netAmount":50,
            "quantity":9,
            "startValidity":"1970-01-01T17:30:00.000Z",
            "type":"menu",
            "unlimitedQuantity":true
         }
      ],
      "orderNetAmount":"24.0",
      "orderQuantity":34,
      "payerId":"60g59yxg",
      "paymentMode":"paypal_account",
      "paymentRefKey":"60g59yxg",
      "paymentStatus":"1000",
      "paypalPaymentId":"60g59yxg",
      "restaurantId":"9b104614-b02f-45aa-ab6e-a2afd569835a",
      "restaurantName":"Michel Plaza",
      "salesTax":0,
      "serviceFee":156.8,
      "subTotal":1960,
      "transactionStatus":"settling",
      "userId":"538eb196-3f6a-415e-bd13-ffc4191c37b1"
   }
]

Body:
You already done all the parts. last thing you need to do, convert gson string to JSONArray. use this code for that

JSONArray jsonarray = new JSONArray("gson string");

if you need like this

{
   "restaurantId":"0a60fa5e-642c-4e4f-ae37-a7c8093e1659",
      '
      '
      '
      '
      '
   "contactNumber":"9516238470",
   "couponcode":{
      '
      '
      '
      '
   },
   "orderLines":[
      '
      '
      '
      '
   ]
}

not like this

{
   "contactNumber":"8149425758",
      '
      '
      '
      '
      '
   "couponcode":{
      '
      '
      '
      '
   },
   "lastName":"Udasi",
   "orderLines":[
      '
      '
      '
      '
   ],
   "orderNetAmount":"24.0",
      '
      '
      '
}

this happen because data sorted by element key. look at element key then u can see


问:
Firebase cloud messaging stopped with upgrade to Oreo
I was just getting started with Android development and managed to get Firebase messaging working after running the wizard.  I was able to receive background notifications on my Nexus 5X running Nougat.  But then my 5X upgraded to Oreo and Firebase notifications haven't worked since.  I've heard about background execution limitations, but since I'm just getting started I don't know what I actually have to do to get it working again.  Are there any write ups on this?  I tried a new project from scratch hoping the wizard had been updated, but no change.  I was using application broadcast messages and topic subscription messages, no device token used.</p>

答:
When you target Android 8.0 (API level 26), you must implement one or more notification channels to display notifications to your users. If you don't target Android 8.0 (API level 26) but your app is used on devices running Android 8.0 (API level 26), your app behaves the same as it would on devices running Android 7.1 (API level 25) or lower.

If you change your target version into Android 8.0 (API level 26), you have to do the following change

```<code>      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
     NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
     String id = "id_product";//This will be enter when creating Builder
     // The user-visible name of the channel.
     CharSequence name = "Product";
     // The user-visible description of the channel.
     String description = "Notifications regarding our products";
     int importance = NotificationManager.IMPORTANCE_MAX;
     NotificationChannel mChannel = new NotificationChannel(id, name, importance);
     // Configure the notification channel.
     mChannel.setDescription(description);
     mChannel.enableLights(true);
     // Sets the notification light color for notifications posted to this
     // channel, if the device supports this feature.
     mChannel.setLightColor(Color.RED);
     notificationManager.createNotificationChannel(mChannel);
  }
</code>```

Change your Builder constructor

```<code>NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(applicationContext, **ID you have put in the Notification Channel**)
</code>```

Finally you can create the notification from the Builder

```<code>notificationManager.notify("0", notificationBuilder.build())
</code>```

Ref: https://developer.android.com/guide/topics/ui/notifiers/notifications.html#ManageChannels

Body:
When you target Android 8.0 (API level 26), you must implement one or more notification channels to display notifications to your users. If you don't target Android 8.0 (API level 26) but your app is used on devices running Android 8.0 (API level 26), your app behaves the same as it would on devices running Android 7.1 (API level 25) or lower.

If you change your target version into Android 8.0 (API level 26), you have to do the following change

      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
     NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
     String id = "id_product";//This will be enter when creating Builder
     // The user-visible name of the channel.
     CharSequence name = "Product";
     // The user-visible description of the channel.
     String description = "Notifications regarding our products";
     int importance = NotificationManager.IMPORTANCE_MAX;
     NotificationChannel mChannel = new NotificationChannel(id, name, importance);
     // Configure the notification channel.
     mChannel.setDescription(description);
     mChannel.enableLights(true);
     // Sets the notification light color for notifications posted to this
     // channel, if the device supports this feature.
     mChannel.setLightColor(Color.RED);
     notificationManager.createNotificationChannel(mChannel);
  }

Change your Builder constructor

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(applicationContext, **ID you have put in the Notification Channel**)

Finally you can create the notification from the Builder

notificationManager.notify("0", notificationBuilder.build())

Ref: https://developer.android.com/guide/topics/ui/notifiers/notifications.html#ManageChannels


问:
How to fill empty string with %20 from an array of strings ios
I have a String array which I found from JSON object. It's an Image array containing 4 images presently.I don't know how many images I will get in future.
My Question is the Image URL is not showing in my ImageView Because it contains some blank space with it.I have already checked if this space is replaced with %20 then I can happily use it in my ImageView.

Can Anyone Suggest me how can I replace all the blank space from all the image String URL which is there in this Image Array?

Please Found my Code for the same:-----

```<code>    NSArray* latest = [json objectForKey:@"BANNER"];

    NSMutableArray *data=[NSMutableArray new];

      if (!latest) {

        NSLog(@"Error parsing JSON: %@",error);
    }
       else{

        for(int i=0; i<latest.count ; i++)
        {
            NSDictionary *dict = [latest objectAtIndex:i];

            [data addObject:[dict objectForKey:@"url"]];
        }
        NSLog(@"data :%@",data);
        }
</code>```

# Pragma Mark: I have Found image array in the below format

```<code>data :(
    "https://xyz.in/mobile/1508139616-Food Offer Banner App (1).jpg",
    "https://xyz.in/mobile/1508163055-Serving  Banner app.jpg",
    "https://xyz.in/mobile/1508746128-Food App Banner Deal10.jpg",
    "https://xyz.in/mobile/1508746172-Food Banner Features.jpg"
)
</code>```

Pragma Mark: I want to convert "data" like this

```<code>data :(
    "https://xyz.in/mobile/1508139616-Food%20Offer%20Banner%20App%20(1).jpg",
    "https://xyz.in/mobile/1508163055-Serving%20Banne%20app.jpg",
    "https://xyz.in/mobile/1508746128-Food%20App%20Banner%20Deal10.jpg",
    "https://xyz.in/mobile/1508746172-Food%20Banner%20Features.jpg"
)
</code>```

I know this Question is already there but for single string only.But My Question is I want to convert the complete Array of String Url.
Please Help me Already Spent 3-4 days.

答:
Let use stringByReplacingOccurrencesOfString. It can help you replace all space with %20.

```<code>yourImageUrlString = [yourImageUrlString stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
</code>```

For your code

```<code>NSArray* latest = [json objectForKey:@"BANNER"];

NSMutableArray *data=[NSMutableArray new];

if (!latest) {

  NSLog(@"Error parsing JSON: %@",error);
}
else{

  for(int i=0; i<latest.count ; i++)
  {
    NSDictionary *dict = [latest objectAtIndex:i];
    NSString *url = [dict objectForKey:@"url"];
    url = [url stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
    [data addObject:url];
  }
  NSLog(@"data :%@",data);
}
</code>```

Body:
I have a String array which I found from JSON object. It's an Image array containing 4 images presently.I don't know how many images I will get in future.
My Question is the Image URL is not showing in my ImageView Because it contains some blank space with it.I have already checked if this space is replaced with %20 then I can happily use it in my ImageView.

Can Anyone Suggest me how can I replace all the blank space from all the image String URL which is there in this Image Array?

Please Found my Code for the same:-----

    NSArray* latest = [json objectForKey:@"BANNER"];

    NSMutableArray *data=[NSMutableArray new];

      if (!latest) {

        NSLog(@"Error parsing JSON: %@",error);
    }
       else{

        for(int i=0; i<latest.count ; i++)
        {
            NSDictionary *dict = [latest objectAtIndex:i];

            [data addObject:[dict objectForKey:@"url"]];
        }
        NSLog(@"data :%@",data);
        }

# Pragma Mark: I have Found image array in the below format

data :(
    "https://xyz.in/mobile/1508139616-Food Offer Banner App (1).jpg",
    "https://xyz.in/mobile/1508163055-Serving  Banner app.jpg",
    "https://xyz.in/mobile/1508746128-Food App Banner Deal10.jpg",
    "https://xyz.in/mobile/1508746172-Food Banner Features.jpg"
)

Pragma Mark: I want to convert "data" like this

data :(
    "https://xyz.in/mobile/1508139616-Food%20Offer%20Banner%20App%20(1).jpg",
    "https://xyz.in/mobile/1508163055-Serving%20Banne%20app.jpg",
    "https://xyz.in/mobile/1508746128-Food%20App%20Banner%20Deal10.jpg",
    "https://xyz.in/mobile/1508746172-Food%20Banner%20Features.jpg"
)

I know this Question is already there but for single string only.But My Question is I want to convert the complete Array of String Url.
Please Help me Already Spent 3-4 days.

Body:
Let use stringByReplacingOccurrencesOfString. It can help you replace all space with %20.

yourImageUrlString = [yourImageUrlString stringByReplacingOccurrencesOfString:@" " withString:@"%20"];

For your code

NSArray* latest = [json objectForKey:@"BANNER"];

NSMutableArray *data=[NSMutableArray new];

if (!latest) {

  NSLog(@"Error parsing JSON: %@",error);
}
else{

  for(int i=0; i<latest.count ; i++)
  {
    NSDictionary *dict = [latest objectAtIndex:i];
    NSString *url = [dict objectForKey:@"url"];
    url = [url stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
    [data addObject:url];
  }
  NSLog(@"data :%@",data);
}


问:
R: duplicate data in a dataframe
Mars:

```<code>ticket  Name    Fare
  A3    Emily    50
  A4    Jack     50
  A5    Sam      25
  A6    Lara     25
  A4    Julie    50
  A3    Kevin    50
</code>```

When we go to the movies, sometimes we buy one ticket for two people's price. Now I need to count the repeated data. I know how to count it, but not sure how to put it back into the data frame since the length will be different.

My code:

```<code>a <- as.data.frame(table(Mars$ticket))
Mars$Count <- Mars$ticket[a$Var2]
</code>```

Output:

```<code>var1   Var2
A3      2
A4      2
A5      1
A6      1

Error
  replacement has 4 rows, data has 6
</code>```

Expected output:

Mars:

```<code>ticket  Name    Fare  Count
  A3    Emily    50     2
  A4    Jack     50     2
  A5    Sam      25     1
  A6    Lara     25     1
  A4    Julie    50     2
  A3    Kevin    50     2
</code>```

答:
You can use merge like this

```<code>df <- read.table(text = "ticket  Name    Fare
A3    Emily    50
A4    Jack     50
A5    Sam      25
A6    Lara     25
A4    Julie    50
A3    Kevin    50", header = T)

a <- as.data.frame(table(df$ticket))

merge(df, a, by.x = "ticket", by.y = "Var1", all.x = T)

  ticket  Name Fare Freq
1     A3 Emily   50    2
2     A3 Kevin   50    2
3     A4  Jack   50    2
4     A4 Julie   50    2
5     A5   Sam   25    1
6     A6  Lara   25    1
</code>```

Title: R: duplicate data in a dataframe

Body:
Mars:

ticket  Name    Fare
  A3    Emily    50
  A4    Jack     50
  A5    Sam      25
  A6    Lara     25
  A4    Julie    50
  A3    Kevin    50

When we go to the movies, sometimes we buy one ticket for two people's price. Now I need to count the repeated data. I know how to count it, but not sure how to put it back into the data frame since the length will be different.

My code:

a <- as.data.frame(table(Mars$ticket))
Mars$Count <- Mars$ticket[a$Var2]

Output:

var1   Var2
A3      2
A4      2
A5      1
A6      1

Error
  replacement has 4 rows, data has 6

Expected output:

Mars:

ticket  Name    Fare  Count
  A3    Emily    50     2
  A4    Jack     50     2
  A5    Sam      25     1
  A6    Lara     25     1
  A4    Julie    50     2
  A3    Kevin    50     2

Body:
You can use merge like this

df <- read.table(text = "ticket  Name    Fare
A3    Emily    50
A4    Jack     50
A5    Sam      25
A6    Lara     25
A4    Julie    50
A3    Kevin    50", header = T)

a <- as.data.frame(table(df$ticket))

merge(df, a, by.x = "ticket", by.y = "Var1", all.x = T)

  ticket  Name Fare Freq
1     A3 Emily   50    2
2     A3 Kevin   50    2
3     A4  Jack   50    2
4     A4 Julie   50    2
5     A5   Sam   25    1
6     A6  Lara   25    1


问:
How to make Parallel call to 2 different methods in c#
I Have 2 methods getReponseFromDb() & getResponsefromthirdParty() returning some data in datatable format. How can i make this request async and wait till both of them return result</p>

```<code>public static datatable GetResult() {
      var task1 = getResponseFromDb();
      var task2 = getResponseFromThirdParty();
      ProcessResult(task1, task2);
}

public static datatable getResponseFromDB() {
    using(con SqlConnection = new SqlConnection()) {
       //get data from sql
    }
     returns datatable
}

public static datatable getResponseFromthirdParty() {
    //networkrequest
    //process to datatable
    //return datatable
}
</code>```

答:
using System.Threading.Tasks;

/Keep a list of all task/

```<code>    List<Task<DataTable>> AllTasks = new List<Task<DataTable>>();
</code>```

/Call both functions in parallel/

```<code>    Task<DataTable> t1 = new Task<DataTable>(() => getReponseFromDb());

    Task<DataTable> t2 = new Task<DataTable>(() => getResponseFromthirdParty());
    AllTasks.Add(t1);
    AllTasks.Add(t2);
    t1.Start();
    t2.Start();
</code>```

/Wait for completion of all task/

```<code>    Task.WhenAll(AllTasks).ContinueWith(task => ProcessResult(AllTasks));
</code>```

NOTE: Use different SqlConnection object for both tasks if connecting to same database or you might get an error!:)

Body:
I Have 2 methods getReponseFromDb() & getResponsefromthirdParty() returning some data in datatable format. How can i make this request async and wait till both of them return result

public static datatable GetResult() {
      var task1 = getResponseFromDb();
      var task2 = getResponseFromThirdParty();
      ProcessResult(task1, task2);
}

public static datatable getResponseFromDB() {
    using(con SqlConnection = new SqlConnection()) {
       //get data from sql
    }
     returns datatable
}

public static datatable getResponseFromthirdParty() {
    //networkrequest
    //process to datatable
    //return datatable
}

Body:
using System.Threading.Tasks;

/Keep a list of all task/

    List<Task<DataTable>> AllTasks = new List<Task<DataTable>>();

/Call both functions in parallel/

    Task<DataTable> t1 = new Task<DataTable>(() => getReponseFromDb());

    Task<DataTable> t2 = new Task<DataTable>(() => getResponseFromthirdParty());
    AllTasks.Add(t1);
    AllTasks.Add(t2);
    t1.Start();
    t2.Start();

/Wait for completion of all task/

    Task.WhenAll(AllTasks).ContinueWith(task => ProcessResult(AllTasks));

NOTE: Use different SqlConnection object for both tasks if connecting to same database or you might get an error!:)