{"QuestionId": 32018049, "AnswerCount": 1, "Tags": "", "CreationDate": "2015-08-14T20:20:21.057", "AcceptedAnswerId": null, "Title": "Plotting realtime data with flask and bokeh", "Body": "

I am using a MongoDB to store sensordata(1 Measurement / sec.) and I would like to use flask and bokeh to plot the data in realtime in a web browser. Unfortunately my knowledge regarding web-frameworks is not that good. \nSo far I managed to create a static plot which reads the data from the database (see example below) \nWhat would be the best way to update the plot in realtime?

\n\n
from flask import Flask\n\nimport datetime\nfrom pymongo import MongoClient\nfrom bokeh.templates import RESOURCES\n\nfrom bokeh.plotting import figure\nfrom bokeh.resources import CDN\nfrom bokeh.embed import file_html\n\napp = Flask(__name__)\n\n@app.route('/')\ndef index():\n    client = MongoClient()\n\n    db = client.test\n    sdata = db.sensordata\n\n    output = list(sdata.find())\n\n    temp = [x['temperature'] for x in output]\n\n    get_time = lambda x: datetime.datetime.strptime(x['time'], '%Y-%m-%d %H:%M:%S')\n    time = [get_time(x) for x in output]\n\n    humidity = [x['humidity'] for x in output]\n    plot = figure(x_axis_type = \"datetime\")\n    plot.line(time, temp)\n    plot.line(time, humidity)\n\n    html = file_html(plot, CDN, \"my plot\")\n\n    return html\n\nif __name__=='__main__':\n    app.run(host='localhost', debug=True)\n
\n\n

EDIT:

\n\n

I think a solution with flask-socketio would be nice, but im not yet sure how to do it. To embedd the plot I need to create a script and div with script, div = components(plot) see (http://docs.bokeh.org/en/latest/docs/user_guide/embed.html)\nSo the script is put into the html header while the div is put into the body. I don't see how to update the data since it is stored inside script file in the header and not in the div.\nMy Idea was to change the html in the div with :

\n\n
 <script type=\"text/javascript\" charset=\"utf-8\">\n    $(document).ready(function(){\n        //connect to the socket server.\n        var socket = io.connect('http://' + document.domain + ':' + location.port + '/');\n\n        socket.on('plotupdate', function(msg) {\n            $('#plot').html(msg.plot);\n        });\n\n    });\n</script>\n
\n\n

But this doesn't work in this case.

\n", "Lable": "No"} {"QuestionId": 32129643, "AnswerCount": 2, "Tags": "", "CreationDate": "2015-08-20T22:43:46.797", "AcceptedAnswerId": "32129867", "Title": "Dynamically resize div for background image", "Body": "

I have a background image in a header that automatically resizes to the width of the window. However, the height does not adjust properly -- an inherited CSS property sets the div to a fixed height of 50px.

\n\n

Currently, I'm using:

\n\n
background-size: cover;\n
\n\n

I can specify a fixed height for the div that will be observed, but then the background is only correct at a specific window size. If I set the size to auto or 100%, it goes to 50px; How can I make it ignore the height it thinks it should be and just autoresize the header div to a background image that adjusts to window size?

\n", "Lable": "No"} {"QuestionId": 32191597, "AnswerCount": 0, "Tags": "", "CreationDate": "2015-08-24T20:56:04.783", "AcceptedAnswerId": null, "Title": "main, RECV TLSv1 ALERT: fatal, handshake_failure", "Body": "

I have a JAXWS client where I have configured the two properties for mutual authentication:

\n\n
System.setProperty(\"javax.net.ssl.keyStore\",\"sample.jks\");\nSystem.setProperty(\"javax.net.ssl.keyStorePassword\",\"xxxx\");        \nSystem.setProperty(\"javax.net.debug\", \"all\");\n
\n\n

From the logs, I see the following error at the end:

\n\n
main, READ: TLSv1 Alert, length = 2\nmain, RECV TLSv1 ALERT:  fatal, handshake_failure\n%% Invalidated:  [Session-1, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA]\nmain, called closeSocket()\nmain, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure\n
\n\n

I am not able to figure out the reason for this error.

\n\n

Any help would be greatly appreciated.

\n", "Lable": "No"} {"QuestionId": 32211283, "AnswerCount": 0, "Tags": "", "CreationDate": "2015-08-25T18:19:15.980", "AcceptedAnswerId": null, "Title": "Having an issue with Jquery and animate.css", "Body": "

I am having an issue with my code, I would like to make it so that when a link is clicked, the corresponding text bounces in and up and what ever is already on the page bounces out. I am able to achieve this, but it only works once per page load. I have a feeling its because of I am adding the classes and its not removing them until the page reloads. What can I do to not only tidy up my code but to also achieve the effect I am going for. Thank you in advance.

\n\n
        $('#home').on('click', function(e){\n            $('#aboutme-text').addClass(\"bounceOutUp\");\n            $('#portfolio-text').addClass(\"bounceOutUp\");\n            $('#projects-text').addClass(\"bounceOutUp\");\n            $('#contact-text').addClass(\"bounceOutUp\");\n\n            $('#my-name').removeClass(\"bounceOutUp\");\n\n            setTimeout(\"$('#my-name').show();\", 500);\n
\n\n

https://jsfiddle.net/26mdLrm1/

\n", "Lable": "No"} {"QuestionId": 32245108, "AnswerCount": 1, "Tags": "", "CreationDate": "2015-08-27T09:07:35.937", "AcceptedAnswerId": null, "Title": "What happens to transaction if SessionScoped and Stateless method calls are mixed", "Body": "

What happens in following scenario if error occurred in DStateless.method4() or BSession.method2()? I want that CStateless.method3() and DStateless.method4() share the same transaction.

\n\n

Is it permitted to make such calls in EJB and CDI ?

\n\n
ASession.method1() (calls)-> CStateless.method3() -> BSession.method2() -> DStateless.method4();\n
\n\n
\n\n
@SessionScoped\nclass ASession {\n   method1();\n}\n\n@SessionScoped\nclass BSession {\n   method2();\n}\n\n@Stateless\nclass CStateless {\n   method3();\n}\n\n@Stateless\nclass DStateless {\n   method4();\n}\n
\n", "Lable": "No"} {"QuestionId": 32253987, "AnswerCount": 2, "Tags": "", "CreationDate": "2015-08-27T15:45:35.620", "AcceptedAnswerId": "32256907", "Title": "JS console error shows Extjs trying to make a GET request for a class as if it was a file", "Body": "

Sorry if the title isn't the best.

\n\n

I'm roughing out a test project in Extjs 6. I have a viewmodel class that uses a store called customers:

\n\n
Ext.define('ChildSessionBinding.view.main.ChildSessionModel',{\n    extend: 'Ext.app.ViewModel',\n    alias: 'viewmodel.binding.childsession',\n\n    requires:[\n        'Ext.data.Store',\n        'ChildSessionBinding.model.Customer'\n    ],\n\n    stores:{\n        customers:{\n            model: 'ChildSessionBinding.model.Customer',\n            autoLoad: true,\n            session: true\n        }\n    }\n});\n
\n\n

The model it requires has hard coded test data in it:

\n\n
Ext.define('ChildSessionBinding.model.Customer', {\n    extend: 'Ext.data.Model',\n\n    fields: [\n        { name: 'name', type: 'auto' },\n        { name: 'phone', type: 'auto' }\n    ],\n\n    data:[\n        {name: 'test', phone: '12345'}\n    ]\n});\n
\n\n

And the view that uses the ViewModel is just a panel that shows a simple grid:

\n\n
Ext.define('ChildSessionBinding.view.main.ChildSession', {\n    extend: 'Ext.panel.Panel',\n\n    xtype: 'binding-child-session',\n\n    title: 'Binding Child Session Demo',\n    layout: {\n        type: 'vbox',\n        align: 'stretch'\n    },\n\n    viewModel: {\n        type: 'binding.childsession'\n    },\n\n    controller: 'binding.childsession',\n\n    session: true,\n\n    items:[\n        {\n            flex: 1,\n            xtype: 'grid',\n            bind: '{customers}',\n            columns:[\n                {\n                    dataIndex: 'name',\n                    flex: 1,\n                    text: 'Name'\n                },\n                {\n                    dataIndex: 'phone',\n                    flex: 1,\n                    text: 'Phone'\n                },\n                {\n                    xtype: 'widgetcolumn',\n                    width: 90,\n                    widget: {\n                        xtype: 'button',\n                        text: 'Edit',\n                        handler: 'onEditCustomerClick'\n                    }\n                }\n            ]\n        }\n    ]\n});\n
\n\n

When I load this in the browser, the grid does not load. I popped open the javascript console and saw that it was trying to make a get request to the server using the model's fully qualified name:

\n\n

\"wtf\"

\n\n

I've compared it to the kitchen sink example I'm trying to duplicate as well as other viewmodel stores that I've created in other projects and I don't see anything that would cause this.

\n\n

Also, to rule out any project file structure questions, here's the folder/file structure:

\n\n

\"folder

\n\n

EDIT

\n\n

Here's the stack trace from the javascript console:

\n\n

\"the

\n\n

Anyone see the problem?

\n", "Lable": "No"} {"QuestionId": 32266802, "AnswerCount": 1, "Tags": "", "CreationDate": "2015-08-28T08:39:15.797", "AcceptedAnswerId": "32267867", "Title": "How to use Promise.timeout in play framework filter", "Body": "

We want to use Play framework to simulata another application. The requirement is to delay the response for example 5 seconds.

\n\n

I want to do it in a filter, as it will apply to all actions. I want to use play.api.libs.concurrent.Promise.timeout to delay a response after the action returns. I am a newbie in Scala, I really don't know how to code with Scala, I always get a Future[Future[Result]] object.

\n\n

Could someone tell me which method I should use and how?

\n\n

Edited

\n\n

My incorrect code with compile error

\n\n
nextFilter(requestHeader).map {result=>\n  play.api.libs.concurrent.Promise.timeout(result, 5.seconds)\n}\n
\n", "Lable": "No"} {"QuestionId": 32361841, "AnswerCount": 1, "Tags": "", "CreationDate": "2015-09-02T19:46:30.230", "AcceptedAnswerId": null, "Title": "PowerBuilder PowerScript Selecting More than one option from a dropdown", "Body": "

I am having a great amount of difficulty wrapping my head around this concept: We currently present our reps with a drop down menu on the order screen that will present them with multiple add-on options depending on the product added to the order in the line before. The issue lies where they can only choose one of the options, and the line item gets written to the order and the reps are then unable to select the second add-on to add to the order (in the case that the customer wanted both add-ons instead of just one). The code posted below is the work of the programmer that came before me, so I am not sure if it is well written as Powerscript is new to me.

\n\n

Caveats -- this must remain a dropdown, and I cannot simply add the second add-on in the background. In order for the orders system to work properly, the selected addons must come right after the main product, one after another. I also cannot add a \"bundled\" product, as that would mess with sales reporting.

\n\n
String contact_type, contact_name \nLong contact_no, ll_child_row\nlong product_no, addon_product_no\nstring addon\nstring null_string\nstring promo_key\nstring addon_edition_code\nint qty\nreal price\nDataWindowChild contact_child \nAcceptText()\n\nIf GetColumnName() = 'attn_freeform' Then \n    AcceptText()\n    GetChild('attn_freeform', contact_child)\n    ll_child_row = contact_child.GetRow()\n    If ll_child_row > 0 Then\n        contact_name = contact_child.GetItemString(ll_child_row, 'contact_name')\n        If data = contact_name Then \n            contact_type = contact_child.GetItemString(ll_child_row, 'tar_contact_type')\n            contact_no = contact_child.GetItemNumber(ll_child_row, 'tar_contact_no')\n            SetItem(row, \"ship2_tar_contact_type\", contact_type)\n            SetItem(row, \"ship2_tar_contact_no\", contact_no)\n        Else\n            SetItem(row, \"ship2_tar_contact_type\", '')\n            SetItem(row, \"ship2_tar_contact_no\", -1)\n        End If\n    Else\n        SetItem(row, \"ship2_tar_contact_type\", '')\n        SetItem(row, \"ship2_tar_contact_no\", -1)\n    End If      \nEnd If \n\nif GetColumnName() = 'quantity' and not isnull(dw_order_detail.GetItemString(row,\"name_1\")) then\n    SetItem(row + 1,\"quantity\",integer(data))\n    AcceptText()\nend if \nif GetColumnName() = 'package_no' and not isnull(dw_order_detail.GetItemString(row,\"name_1\")) then\n    SetItem(row + 1,\"package_no\",dw_order_detail.getitemnumber(row,\"package_no\"))\n    AcceptText()\nend if \nif GetColumnName() = 'attn_freeform' and not isnull(dw_order_detail.GetItemString(row,\"name_1\")) then\n    SetItem(row + 1,\"attn_freeform\",data)\n    AcceptText()\nend if \nif GetColumnName() = 'promo_key' and not isnull(dw_order_detail.GetItemString(row,\"name_1\")) then\n    SetItem(row + 1,\"promo_key\",data)\n    AcceptText()\nend if \nif GetColumnName() = 'order_type' and not isnull(dw_order_detail.GetItemString(row,\"name_1\")) then\n    SetItem(row + 1,\"order_type\",dw_order_detail.getitemstring(row,\"order_type\"))\nend if \n\nif GetColumnName() = 'product_no' and not isnull(dw_order_detail.GetItemString(row,\"name_1\")) then\n    SetNull(null_string)\n    dw_order_detail.deleterow(row + 1)\n    dw_order_detail.SetItem(row,\"name_1\",null_string)\nend if  \n\nproduct_no = 0\nif GetColumnName() = 'product_no' and isnull(dw_order_detail.GetItemString(row,\"name_1\")) then \nproduct_no = dw_order_detail.GetItemNumber(row,'product_no')\nint checkAddon\nSelect isnull(count(*),0) into :checkAddon From  product p JOIN mag_addons t ON p.edition_code = t.primary_edition and p.product_no = :product_no;\n    if checkAddon > 0 then\n        dw_order_detail.SetItem(row, \"teach_12\",0)\n    end if\nend if \n\npromo_key = dw_order_detail.getitemstring(row,\"promo_key\")  \nqty = dw_order_detail.getitemnumber(row,\"quantity\")\nAcceptText()\n\nif GetColumnName() = 'name_1'  then //the dropdown for addon selection appears here\n    long ll_row, ll_inserted_row\n    SetNull(null_string)\n    product_no = 0\n    product_no = dw_order_detail.GetItemNumber(row,'product_no')\n    addon = dw_order_detail.GetItemString(row,\"name_1\") //this sets the name of the addon\nif isnull(addon) or addon = \"Select Add On...\"  then \n    return\nend if \nSelect p.product_no, t.add_on_edition into :addon_product_no, :addon_edition_code from product p JOIN mag_addons t ON p.edition_code = t.add_on_edition and p.description = :addon JOIN product d ON t.primary_edition = d.edition_code;\nif row + 1  <  dw_order_detail.RowCount() then \n     if dw_order_detail.GetItemString(row + 1,'addondesc') = addon then\n        return\n    end if \nend if \nif product_no >= 1 then \n    SELECT price INTO :price FROM dbo.get_price(:promo_key,:addon_edition_code,:qty, :vg_project_id);\n    if price = 0 then \n        price = .99 \n    end if\n    ll_row = dw_order_detail.GetRow()\n    ll_inserted_row = dw_order_detail.InsertRow(row + 1)\n    SetItem(row + 1,\"order_no\",dw_order_detail.getitemnumber(row,\"order_no\"))\n    SetItem(row + 1,\"line_item_no\",dw_order_detail.getitemnumber(row,\"line_item_no\") + 1)\n    SetItem(row + 1,\"status_code\",dw_order_detail.getitemstring(row,\"status_code\"))\n    SetItem(row + 1,\"ship2_tar_contact_type\",dw_order_detail.getitemstring(row,\"ship2_tar_contact_type\"))\n    SetItem(row + 1,\"ship2_tar_contact_no\",dw_order_detail.getitemnumber(row,\"ship2_tar_contact_no\"))\n    SetItem(row + 1,\"attn_freeform\",dw_order_detail.getitemstring(row,\"attn_freeform\"))\n    SetItem(row + 1,\"promo_key\",promo_key)\n    SetItem(row + 1,\"product_no\",addon_product_no)\n    SetItem(row + 1,\"quantity\",dw_order_detail.getitemnumber(row,\"quantity\"))\n    SetItem(row + 1,\"price\",price)\n    SetItem(row + 1,\"price_1\",price)\n    SetItem(row + 1,\"package_no\",dw_order_detail.getitemnumber(row,\"package_no\"))\n    SetItem(row + 1,\"order_type\",dw_order_detail.getitemstring(row,\"order_type\"))\n    SetItem(row + 1,\"shipping_rate\",dw_order_detail.getitemnumber(row,\"shipping_rate\"))\n    SetItem(row + 1,\"sales_tax_rate\",dw_order_detail.getitemnumber(row,\"sales_tax_rate\"))\n    SetItem(row + 1,\"ship2_tar_acct_type\",dw_order_detail.getitemstring(row,\"ship2_tar_acct_type\"))\n    SetItem(row + 1,\"ship2_tar_acct_no\",dw_order_detail.getitemnumber(row,\"ship2_tar_acct_no\"))\n    SetItem(row + 1,\"jt_id\",dw_order_detail.getitemnumber(row,\"jt_id\"))\n    SetItem(row + 1,\"year_began_teach\",dw_order_detail.getitemnumber(row,\"year_began_teach\"))\n    SetItem(row + 1,\"preferred_email\",dw_order_detail.getitemstring(row,\"preferred_email\"))\n    SetItem(row + 1,\"email\",dw_order_detail.getitemstring(row,\"email\"))\n    SetItem(row + 1,\"addondesc\",dw_order_detail.getitemstring(row,\"name_1\"))\n    SetItem(row,\"teach_12\",1)\n    SetItem(row + 1,\"teach_12\",2)\n\n    dw_order_detail.AcceptText()\nend if\ndw_order_detail.ScrollToRow(ll_inserted_row)\ndw_order_detail.SetFocus()\nend if\ndw_order_detail.AcceptText()\n
\n", "Lable": "No"} {"QuestionId": 32459219, "AnswerCount": 1, "Tags": "", "CreationDate": "2015-09-08T13:32:22.467", "AcceptedAnswerId": "32660544", "Title": "docker out of disk space", "Body": "

I'm hainvg trouble with docker and volume size. I'm running docker-machine with\nthree containers. The one giving me trouble is the MySQL container which has a\ndata-only container for persistance. When I try to import a mysql file, mysql\ncomplains that the table is\nfull,\nwhich really means that the disk is out of space. Looking at the system, I see\nthe problem, but don't know how to correct it:

\n\n
 _                 _   ____     _            _\n | |__   ___   ___ | |_|___ \\ __| | ___   ___| | _____ _ __\n | '_ \\ / _ \\ / _ \\| __| __) / _` |/ _ \\ / __| |/ / _ \\ '__|\n | |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |\n |_.__/ \\___/ \\___/ \\__|_____\\__,_|\\___/ \\___|_|\\_\\___|_|\n Boot2Docker version 1.8.1, build master : 7f12e95 - Thu Aug 13 03:24:56 UTC\n 2015\n Docker version 1.8.1, build d12ea79\n docker@default:~$ sudo -i\n Boot2Docker version 1.8.1, build master : 7f12e95 - Thu Aug 13 03:24:56 UTC\n 2015\n Docker version 1.8.1, build d12ea79\n root@default:~# df -h\n Filesystem                Size      Used Available Use% Mounted on\n tmpfs                   896.6M    112.4M    784.2M  13% /\n tmpfs                   498.1M    136.0K    498.0M   0% /dev/shm\n /dev/sda1                 2.8G      2.7G         0 100% /mnt/sda1\n cgroup                  498.1M         0    498.1M   0% /sys/fs/cgroup\n none                    462.2G     32.8G    429.5G   7% /Users\n /dev/sda1                 2.8G      2.7G         0 100%\n /mnt/sda1/var/lib/docker/aufs\n none                      2.8G      2.7G         0 100%\n /mnt/sda1/var/lib/docker/aufs/mnt/0a90321d2e941e31385a4c4096e\n none                      2.8G      2.7G         0 100%\n /mnt/sda1/var/lib/docker/aufs/mnt/bca6fc0c017233ed634e7e19284\n none                      2.8G      2.7G         0 100%\n /mnt/sda1/var/lib/docker/aufs/mnt/7e432f020ee8fc9c6a211c810e5\n
\n\n

I created the docker-machine like this, which I thought would give me the space I need, but it has not.

\n\n
docker-machine create --virtualbox-disk-size 4000 -d virtualbox default\n
\n\n

I'm creating the mysql image like this

\n\n
#!/bin/bash\n\necho \"- checking that the image exists\"\nIMAGE=$(docker images | grep cp_mysql)\nif [ -z \"$IMAGE\" ]; then\n  echo '- image does not exist, building'\n  docker build -t cp_mysql -f Dockerfile-app .\nfi\n\n\necho \"- checking if the mysql data volume exists\"\nDATA_VOL=$(docker ps -a | grep cp_mysql_data)\n\n# if empty\nif [ -z \"$DATA_VOL\" ]; then\n  echo '- data volume is empty - building'\n  DATA_VOL=$(docker build -t data -f Dockerfile-data_vol . | tail -n 1 | awk '{print $3}')\n  docker run --name cp_mysql_data $DATA_VOL\n  echo \"- build data volume: $DATA_VOL\"\nelse\n  DATA_VOL=$(echo $DATA_VOL | awk '{print $1}')\n  echo \"- data volume is not empty - using existing volume: $DATA_VOL\"\nfi\n\necho '- check if existing cp_mysql_app exists'\n\nAPP=$(docker ps -a | grep cp_mysql_app)\n\nif [ -z \"$APP\" ]; then\n  echo '- the app does not exist, let us create it'\n  docker run \\\n    --restart=always \\\n    --name cp_mysql_app \\\n    --restart=always \\\n    --volumes-from=cp_mysql_data \\\n    -e MYSQL_USER=cp \\\n    -e MYSQL_PASSWORD=cp \\\n    -e MYSQL_DATABASE=cp \\\n    -e MYSQL_ROOT_PASSWORD=root \\\n    -d \\\n    -p 3306:3306 cp_mysql\nelse\n  echo '- the does exist, let us just run it'\n  docker start cp_mysql_app\nfi\n
\n\n

Here's my docker info for that machine

\n\n
docker@default:~$ docker info\nContainers: 0\nImages: 0\nStorage Driver: aufs\n Root Dir: /mnt/sda1/var/lib/docker/aufs\n Backing Filesystem: tmpfs\n Dirs: 0\n Dirperm1 Supported: true\nExecution Driver: native-0.2\nLogging Driver: json-file\nKernel Version: 4.0.9-boot2docker\nOperating System: Boot2Docker 1.8.1 (TCL 6.3); master : 7f12e95 - Thu Aug 13 03:24:56 UTC 2015\nCPUs: 1\nTotal Memory: 996.2 MiB\nName: default\nID: XLSE:62WR:VWCR:T2Z6:FSE3:NTLV:EQRT:WLW5:NLPF:HPQH:JQGR:K4LZ\nDebug mode (server): true\nFile Descriptors: 9\nGoroutines: 16\nSystem Time: 2015-09-08T16:31:38.029737031Z\nEventsListeners: 0\nInit SHA1:\nInit Path: /usr/local/bin/docker\nDocker Root Dir: /mnt/sda1/var/lib/docker\nLabels:\n provider=virtualbox\n
\n\n

What I basically need is unbounded space for /dev/sda1, or to be able to specify a large disk size. I know this stems from my misunderstanding how docker mounts work, but I thought this thread would jump-start my research.

\n\n

Thanks in advance.

\n", "Lable": "No"} {"QuestionId": 32491867, "AnswerCount": 2, "Tags": "", "CreationDate": "2015-09-10T01:58:44.623", "AcceptedAnswerId": "32491913", "Title": "iOS 3D Touch programmatically", "Body": "

3D Touch is introduced in iPhone 6s/iPhone 6s plus,and I am wondering if we could have access to 3D Touch related API and do it programmatically in our app.Does anyone has some ideas?

\n", "Lable": "No"} {"QuestionId": 32500107, "AnswerCount": 1, "Tags": "", "CreationDate": "2015-09-10T11:02:50.737", "AcceptedAnswerId": "32502745", "Title": "iOS playback RTMP with AVFoundation", "Body": "

I need to implement an iOS app that playback RTMP with AV. Exists any library for this propose? I have bean searched on Internet but I didn't found nothing or any example.

\n\n

I think that I must capture frames and decodec because iOS don't playback rtmp.

\n\n

I haven't got idea to where start

\n", "Lable": "No"} {"QuestionId": 32510494, "AnswerCount": 1, "Tags": "", "CreationDate": "2015-09-10T19:51:37.430", "AcceptedAnswerId": "32510860", "Title": "Writable Attributes in python", "Body": "
1. class Mine:\n2.    def fun1(self,x):\n3.        self.x=x\n4.        print \"Inside fun1\",self.x\n\n5.    def fun2(self):\n6.        print \"Inside fun2 :\",self.x\n7.\n8.  obj1 = Mine()\n9.  obj1.fun1(1)\n10. obj1.fun2()\n\n11. obj2 = Mine()\n12. obj2.fun1(10000)\n13. obj2.fun2()\n\n14. del obj1.x\n15. #obj1.fun2()\n16. obj2.fun2()\n\n17. Mine.a=111\n18. obj3=Mine()\n19. print \"Mine.a: \",Mine.a\n20. print \"obj1.a: \",obj1.a\n21. print \"obj2.a: \",obj2.a\n22. print \"obj2.a: \",obj3.a\n\n23. obj2.c=222\n24. #print \"\\nMine.c: \",Mine.c\n25. #print \"obj1.c: \",obj1.c\n26. print \"obj2.c: \",obj2.c\n27. #print \"obj2.c: \",obj3.c\n
\n\n

Can someone please help me to understand what is happening at line number 17 and 23, and why the code on line number 19,20,21,22 is working fine and code on line number 24, 25, 27 is giving error ?

\n\n

Thanks in Advance.

\n", "Lable": "No"} {"QuestionId": 32569129, "AnswerCount": 1, "Tags": "", "CreationDate": "2015-09-14T16:03:33.953", "AcceptedAnswerId": null, "Title": "Why does SharedPreferences not support lists of Strings?", "Body": "

Why does SharedPreferences.Editor have a method putStringSet() but not a method putStringList()? This doesn't make any sense to me. My understanding (which could be wrong) is that SharedPreferences objects are stored internally using xml, and xml supports arrays.

\n\n

I understand that a SharedPreference object is intended to be a simple object for small amounts of data, so you wouldn't want to have too many put methods, but I would have thought if you were going to have one of putStringSet() or putStringList(), putStringList() would be both more generally useful (a set can be saved as a list, but not vice-versa) and easier to implement. Can anyone explain this?

\n", "Lable": "No"} {"QuestionId": 32600597, "AnswerCount": 1, "Tags": "", "CreationDate": "2015-09-16T05:42:29.237", "AcceptedAnswerId": null, "Title": "PHP cURL - how to check the return data type from fpassthru?", "Body": "

First, how do I call this type of data that returned successfully from fpassthru?

\n\n
\n

\ufffd\ufffdm\ufffdU\ufffdVmo\ufffd6\ufffdO\ufffd\ufffd\\%\ufffd\ufffdW\ufffd&0X\u06e4m\u056e\ufffdaZ&\ufffd'\ufffd^C\ufffd\ufffd\ufffd\ufffd1$m\ufffd\ufffd\uabaa\ufffd\ufffd\ufffdO>\ufffd\ufffd>\ufffdc;;U\ufffdkm\ufffd\ufffdG\ufffd\ufffd\ufffdA0>C\ufffd\ufffd\ufffdLhH\ufffd&\ufffd\ufffd\ufffd\ufffdw\ufffd\ufffd#\ufffdW\ufffdlv\ufffdZUl\ufffd\ufffd~_\ufffd\ufffd\u015dg\ufffd^{Ww\ufffd0\ufffd+\ufffd\ufffd%J\ufffd/A\ufffd!\ufffd\ufffdAD\ufffd\ufffd8\"\ufffdP\ufffd\ufffd3\ufffdK\ufffdD\ufffd$ \ufffdK\ufffdV;\ufffd\ufffd\ufffd\ufffd\ufffd,Uf{\u04e8n\ufffd\ufffd6EW\ufffd}\ufffd\u0527\u03ed\ufffd@g\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdX?aI\ufffd$\u00b6\ufffd\ufffd1\ufffd\ufffds&3\ufffd8%\ufffd\ufffd\ufffd#\ufffdS\ufffd/:\ufffdz\n \ufffd80\ufffd\ufffd\ufffd\ufffd\ufffd\ufffds\ufffd\ufffdJe\ufffd\ufffd\u649fO\ufffd*\ufffdO.@\n \ufffd5^.{,v\ufffd\ufffd.\ufffd[\ufffd\ufffd\ufffd\ufffd\ufffdiZ\ufffd\ufffd\ufffd4e1.u\ufffdPm\ufffd\\\ufffd\ufffdMU\u02c5\ufffdBf\ufffd\ufffdY.\ufffdf\ufffd\ufffd\ufffdk>\ufffd\ufffd\ufffdC\ufffd\ufffd\ufffdz\ufffd\u0418]i\ufffd\u062a)}i\ufffd^\ufffd\ufffdJYz\u05aa2z\ufffd=\ufffd\ufffd\ufffd\ufffdl\ufffd\ufffd^w\ufffd\ufffd|\ufffd\ufffd\ufffd\ufffd^'\ufffd}\u4ea9V\ufffd;6y``\ufffd\ufffd]A\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\u07d7\ufffd6_w\ufffd\ufffd\ufffdMg\ufffd#\ufffd\ufffd\n \ufffd\ufffd\ufffd\ufffd\ufffd\u06df0W\ufffd\ufffdw\ufffd\ufffd\ufffdv\ufffdL\ufffd\ufffd\ufffd\ufffd4\ufffdDS)b\ufffd\"\"\ufffd3F9\ufffd\ufffdh\ufffd\ufffd\n \u01b6&t%\ufffd\ufffd\ufffdi\ufffd,\ufffd\ufffd?\ufffd\ufffda\ufffdi,m\ufffd\ufffde\ufffd\ufffd\u0317\ufffd\ufffd\ufffd\u44a2D\u0284eh*\ufffd\u01d2=W\ufffd\ufffdQ\ufffdd<)i{\ufffd\ufffd%\ufffdX\ufffdQEO\ufffd:\u019bm\ufffd\ufffdo\ufffdJ\ufffd\ufffdP\ufffd'noKS\ufffdT\ufffd\ufffd\ufffdU&?q\ufffdu\ufffd+\ufffd\ufffdV\ufffd\ufffdFM;m\ufffd\ufffdj-\ufffd\ufffdih\ufffd1\ufffdl;\ufffd\ufffdN\ufffdo\ufffd\u050e\ufffdt=\ufffd\ufffdl\ufffd\ufffd>G\ufffd[C\u076c\ufffd\ufffd'd\ufffd\ufffd\ufffd\ufffd\ufffd0\ufffd!3\ufffd\ufffds\ufffdP\ufffddI\ufffdS\ufffdRI1\ufffd\ufffd\ufffd\ufffd\ufffdO\ufffd7V,\ufffd|\ufffd%$~Lx6\ufffdg\"LJRNq\"\ufffd i\n \ufffd\ufffd18\ufffdmL(G0\ufffd\ufffd\ufffd\ufffd\ufffd8\ufffd%a\ufffd\ufffdc\u020c\ufffd\ufffd\ufffdkB/\ufffd}\ufffd\ufffd\ufffd\ufffd,G\ufffd\ufffd\ufffdC 'q\ufffdx!X\\\ufffd\"A!C\ufffd\ufffdH_H)p\ufffd+\ufffdg\ufffd\ufffd\u0677\ufffd\ufffd\ufffd\ufffd\ufffd*\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u07abA\ufffd6\ufffdG\ufffd\n 6p\ufffd\ufffd\ufffdd\ufffd$*m\ufffd;\ufffd7\ufffdU,l\ufffd\ufffdT\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd~\ufffdv|P~Q\ufffd\ufffdE\ufffd\ufffdT'\ufffd\ufffd\ufffd\ufffd\ufffd\n \ufffd\ufffdqb$##\ufffd\ufffd\ufffd\ufffd/)\ufffdh%\n ?\ufffd\ufffd1\ufffdQ\ufffd\u04d8>\ufffdkB?#h\"\ufffdQ< 9\ufffdp\ufffd$\ufffd\ufffd\ufffdO|8\ufffd\"FI,\ufffdL\ufffd\ufffd?\ufffd\ufffd\ufffd&\ufffd\ufffd\ufffd\ufffd\ufffd[\ufffd\ufffdk\ufffd5gB\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd&}\ufffd^-\ufffd\ufffd~\ufffd\ufffd^\ufffdMs;\ufffd\ufffdp\ufffd\ufffd\ufffd\ufffd\ufffdr\ufffdf\ufffd__\ufffd\ufffd?\ufffd\ufffd\ufffd\ufffd:#\ufffd\ufffd3\ufffd\ufffdZ=\ufffd!s{X\ufffd\ufffd\ufffd[\ufffd\ufffd.pA\ufffdh\ufffdT\u018c\ufffd\ufffd\u02fa\ufffdv\ufffd\ufffd'}\ufffd7\ufffd\ufffd\ufffd\u05ab\ufffdqd)\u04dd\ufffd\ufffdt\ufffd\ufffd\ufffd\ufffd7\ufffd\ufffd\ufffd\ufffd\ufffd(

\n
\n\n

They are the output from this file - download.php,

\n\n
$file = \"G:/../xxx.tgz\";\n\n// Open the file in a binary mode\n$fp = fopen($file, 'rb');\n\n// Dump the tar and stop the script\n$success = fpassthru($fp);\n\nfclose($fp);\n\nif(!$success) {\n    throw new Exception('Unable to downlonad');\n}\n
\n\n

Then how do I check at cURL whether I get this type of data or others?

\n\n

For instance, curl.php,

\n\n
$curl = curl_init();\ncurl_setopt ($curl, CURLOPT_URL, \"http://127.0.0.1/.../download.php\");\ncurl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);\n\n$result = curl_exec ($curl);\ncurl_close ($curl);\n\nvar_dump(gettype($result)); // string 'string' (length=6) \n
\n\n

But if I echo 'hello world' in download.php, my data type result is string 'string' too. I need to differentiate them. Is it possible?

\n", "Lable": "No"} {"QuestionId": 32617100, "AnswerCount": 0, "Tags": "", "CreationDate": "2015-09-16T19:29:41.153", "AcceptedAnswerId": null, "Title": "Getting image dimensions using jquery from a file in onUploadComplete from uploadify", "Body": "

I'm trying to get the image width and height of an image file, right after it has uploaded to the server, but I can't seem to get the creation of this image from a file done correctly.\nI'm wondering if it's possible to do without a file reader or too much trouble in general, but then if there was a simple method I would've probably already tried it . . .

\n\n

This is the code:

\n\n
'onUploadComplete' : function(fileObj) {\n            var theImage = new Image();\n            theImage.src = fileObj.attr(fileObj);\n            // Get accurate measurements from that.\n            var imageWidth = theImage.width();\n            var imageHeight = theImage.height();\n            alert('The image file ' + fileObj.name + ' has the following resolution: ' + imageWidth + 'px X ' + imageHeight + 'px.');\n        },\n
\n\n

Right now nothing happens, but if I remove the imageWidth and imageHeight from the alert it fires, so I'm thinking it's not creating the image right and I tried a few things, but so far to no avail . . .

\n", "Lable": "No"} {"QuestionId": 32643604, "AnswerCount": 1, "Tags": "", "CreationDate": "2015-09-18T03:55:55.143", "AcceptedAnswerId": null, "Title": "Why does Save() of Hibernate session return Serializable?", "Body": "

The identifier returned after save method in hibernate session should implement serializable. Why is it so? Is Serilizable the only common interface of all the wrapper classes? Isnt there any other elegant approach to deal with this polymorphism? IMO, it should be Number Class, thats returned.

\n", "Lable": "No"} {"QuestionId": 32688273, "AnswerCount": 0, "Tags": "", "CreationDate": "2015-09-21T05:58:22.923", "AcceptedAnswerId": null, "Title": "'Log is not defined' error in fb share", "Body": "

Iam trying to share a page of my website in facebook , for that iam using this function share:

\n\n
var publish = {\n                  method: 'feed',\n                  message: 'getting educated about Facebook Connect',\n                  name: 'Connect',\n                  caption: 'The Facebook Connect JavaScript SDK',\n                  description: (\n                      'A small JavaScript library that allows you to harness ' +\n                      'the power of Facebook, bringing the user\\'s identity, ' +\n                      'social graph and distribution power to your site.'\n                  ),\n                  link: 'http://fbrell.com/',\n                  picture: 'http://fbrell.com/f8.jpg',\n                  actions: [\n                    { name: 'fbrell', link: 'http://fbrell.com/' }\n                  ],\n                  user_message_prompt: 'Share your thoughts about RELL'\n                };\n\nFB.ui(publish, Log.info.bind('feed callback'));//This line shows the error\n
\n\n

But while running the code i get the error as Log is not defined. What is wrong with this code????

\n", "Lable": "No"}