问:
Why am I getting this javascript error when I'm doing my Django?
I have valid json according to jsonlint.com

In my javascript, I do this:

```<code>var params = JSON.parse('{{ all_params_in_json }}');
</code>```

And I get this error:

```<code>Uncaught SyntaxError: Unexpected token ILLEGAL
(anonymous function)
</code>```

Why? My json is valid.  I'm using the standard json2 library.

My json is this:

```{
    "browser_location": "Sausalito",
    "browser_distance": 5,
    "users_who_voted": [

    ],
    "author": {
        "username": "swnn",
        "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
        "first_name": "feli",
        "last_name": "twan",
        "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
        "is_active": true,
        "is_superuser": false,
        "is_staff": false,
        "last_login": 1295410796.0,
        "location": "San Francisco",
        "fullname": "twan Chan",
        "id": 1,
        "date_joined": 1293678904.0
    },
    "total_views": 227,
    "comments": [
        {
            "body": "sdfasdf",
            "created_at": 1295317816.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "sdfasdfasd",
            "created_at": 1295317900.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "sdasdasD",
            "created_at": 1295323153.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "The picture in this submission is not accurate",
            "created_at": 1295325473.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "This submission is not useful to me.",
            "created_at": 1295325491.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "lcokc",
            "created_at": 1295344958.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "gagaga",
            "created_at": 1295345040.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "wwwww",
            "created_at": 1295345084.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "sadfasdfasdf",
            "created_at": 1295345136.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "asdasdf",
            "created_at": 1295345253.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "sdfasdfasd",
            "created_at": 1295345279.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "asdfasdf",
            "created_at": 1295345358.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "foxed",
            "created_at": 1295345790.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "Is this really the right thing? I mean...after thinking about it. ist's just not very cool",
            "created_at": 1295345827.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "s this really the right thing? I mean...after thinking about it. ist's just not very cool",
            "created_at": 1295345871.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "his song really suck.s",
            "created_at": 1295346108.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "asdfasdf",
            "created_at": 1295383689.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "asdfasdf",
            "created_at": 1295410874.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "Is this all right?",
            "created_at": 1295411376.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        }
    ],
    "initial_vote": 0,
    "browser_lat": 37.848800659179688,
    "post": {
        "ip": "174.129.251.48",
        "thumb_500x500": {
            "url": "http://s3.amazonaws.com/fabletest/bv2814ghmd",
            "width": 500,
            "height": 351
        },
        "date": 1295154531.334044,
        "thumb_original": {
            "url": "http://farm6.static.flickr.com/5249/5336976806_481943d486_b.jpg",
            "width": 779,
            "height": 548
        },
        "total_views": 227,
        "thumb_230x480": {
            "url": "http://s3.amazonaws.com/fabletest/4e7h95rt3f",
            "width": 230,
            "height": 480
        },
        "test_set": "g2",
        "title": "Maybe. . .we were supposed to meet the wrong people before meeting the right one so that, when we finally meet the right person, we will know how to be grateful for that gift ...",
        "stamp": "bf305695ca51b5390dc0c2f34c074215",
        "pop_score": 241.59687499999995,
        "thumb_640x640": {
            "url": "http://s3.amazonaws.com/fabletest/4q15bsgmt2",
            "width": 640,
            "height": 450
        },
        "image_direction": "landscape",
        "author_username": "swnn",
        "thumb_230x230": {
            "url": "http://s3.amazonaws.com/fabletest/x0dq7gzb4f",
            "width": 230,
            "height": 230
        },
        "description": "sooc with Shana Rae overlay ....",
        "top_score": 0.90000000000000002,
        "active": true,
        "original_file": "http://farm6.static.flickr.com/5249/5336976806_481943d486_b.jpg",
        "loc_utm": [
            500000.0,
            6317527.4506855672
        ],
        "_id": {
            "$oid": "4d327d658aad6919be0000d5"
        },
        "sizes": [
            {
                "url": "http://farm6.static.flickr.com/5249/5336976806_481943d486_b.jpg",
                "width": 779,
                "height": 548
            },
            {
                "url": "http://s3.amazonaws.com/fabletest/4q15bsgmt2",
                "width": 640,
                "height": 450
            },
            {
                "url": "http://s3.amazonaws.com/fabletest/bv2814ghmd",
                "width": 500,
                "height": 351
            },
            {
                "url": "http://s3.amazonaws.com/fabletest/x0dq7gzb4f",
                "width": 230,
                "height": 230
            },
            {
                "url": "http://s3.amazonaws.com/fabletest/4e7h95rt3f",
                "width": 230,
                "height": 480
            },
            {
                "url": "http://s3.amazonaws.com/fabletest/g1pmqk7r6y",
                "width": 480,
                "height": 230
            }
        ],
        "loc_latlong": [
            57.0,
            -99.0
        ],
        "thumb_480x230": {
            "url": "http://s3.amazonaws.com/fabletest/g1pmqk7r6y",
            "width": 480,
            "height": 230
        },
        "processed": true,
        "author_id": 1,
        "content_id": 13259,
        "thumb_500x500_low": {
            "url": "http://s3.amazonaws.com/fabletest/oznumyqve7",
            "width": 500,
            "quality": 4,
            "height": 351
        }
    },
    "browser_long": -122.53489685058594,
    "pos_votes_count": 0
}
```

答: Sounds like you use invalid characters for label's inside the JSON. Check this, it may be browser-dependent what's legal or not.</p>

Body:
I have valid json according to jsonlint.com

In my javascript, I do this:

var params = JSON.parse('{{ all_params_in_json }}');

And I get this error:

Uncaught SyntaxError: Unexpected token ILLEGAL
(anonymous function)

Why? My json is valid.  I'm using the standard json2 library.

My json is this:

{
    "browser_location": "Sausalito",
    "browser_distance": 5,
    "users_who_voted": [

    ],
    "author": {
        "username": "swnn",
        "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
        "first_name": "feli",
        "last_name": "twan",
        "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
        "is_active": true,
        "is_superuser": false,
        "is_staff": false,
        "last_login": 1295410796.0,
        "location": "San Francisco",
        "fullname": "twan Chan",
        "id": 1,
        "date_joined": 1293678904.0
    },
    "total_views": 227,
    "comments": [
        {
            "body": "sdfasdf",
            "created_at": 1295317816.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "sdfasdfasd",
            "created_at": 1295317900.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "sdasdasD",
            "created_at": 1295323153.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "The picture in this submission is not accurate",
            "created_at": 1295325473.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "This submission is not useful to me.",
            "created_at": 1295325491.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "lcokc",
            "created_at": 1295344958.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "gagaga",
            "created_at": 1295345040.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "wwwww",
            "created_at": 1295345084.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "sadfasdfasdf",
            "created_at": 1295345136.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "asdasdf",
            "created_at": 1295345253.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "sdfasdfasd",
            "created_at": 1295345279.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "asdfasdf",
            "created_at": 1295345358.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "foxed",
            "created_at": 1295345790.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "Is this really the right thing? I mean...after thinking about it. ist's just not very cool",
            "created_at": 1295345827.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "s this really the right thing? I mean...after thinking about it. ist's just not very cool",
            "created_at": 1295345871.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "his song really suck.s",
            "created_at": 1295346108.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "asdfasdf",
            "created_at": 1295383689.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "asdfasdf",
            "created_at": 1295410874.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        },
        {
            "body": "Is this all right?",
            "created_at": 1295411376.0,
            "user": {
                "username": "swnn",
                "bio": "I'm the CEO at Twitter.  Prior to Twitter, I cofounded FeedBurner (acquired by Google). I'm an investor and Advisor in a few start-ups including about.me.\r\n \r\nI used to perform with Chicago\u2019s Annoyance Theater and at various comedy festivals in Edinburgh, Montreal and other distant lands. I recently left the cold winters of Chicago for Marin County's sunshine.",
                "first_name": "feli",
                "last_name": "twan",
                "avatar_url": "http://s3.amazonaws.com/fabletest/937ypvlchrd2e5z1a0sq",
                "is_active": true,
                "is_superuser": false,
                "is_staff": false,
                "last_login": 1295410796.0,
                "location": "San Francisco",
                "fullname": "twan Chan",
                "id": 1,
                "date_joined": 1293678904.0
            }
        }
    ],
    "initial_vote": 0,
    "browser_lat": 37.848800659179688,
    "post": {
        "ip": "174.129.251.48",
        "thumb_500x500": {
            "url": "http://s3.amazonaws.com/fabletest/bv2814ghmd",
            "width": 500,
            "height": 351
        },
        "date": 1295154531.334044,
        "thumb_original": {
            "url": "http://farm6.static.flickr.com/5249/5336976806_481943d486_b.jpg",
            "width": 779,
            "height": 548
        },
        "total_views": 227,
        "thumb_230x480": {
            "url": "http://s3.amazonaws.com/fabletest/4e7h95rt3f",
            "width": 230,
            "height": 480
        },
        "test_set": "g2",
        "title": "Maybe. . .we were supposed to meet the wrong people before meeting the right one so that, when we finally meet the right person, we will know how to be grateful for that gift ...",
        "stamp": "bf305695ca51b5390dc0c2f34c074215",
        "pop_score": 241.59687499999995,
        "thumb_640x640": {
            "url": "http://s3.amazonaws.com/fabletest/4q15bsgmt2",
            "width": 640,
            "height": 450
        },
        "image_direction": "landscape",
        "author_username": "swnn",
        "thumb_230x230": {
            "url": "http://s3.amazonaws.com/fabletest/x0dq7gzb4f",
            "width": 230,
            "height": 230
        },
        "description": "sooc with Shana Rae overlay ....",
        "top_score": 0.90000000000000002,
        "active": true,
        "original_file": "http://farm6.static.flickr.com/5249/5336976806_481943d486_b.jpg",
        "loc_utm": [
            500000.0,
            6317527.4506855672
        ],
        "_id": {
            "$oid": "4d327d658aad6919be0000d5"
        },
        "sizes": [
            {
                "url": "http://farm6.static.flickr.com/5249/5336976806_481943d486_b.jpg",
                "width": 779,
                "height": 548
            },
            {
                "url": "http://s3.amazonaws.com/fabletest/4q15bsgmt2",
                "width": 640,
                "height": 450
            },
            {
                "url": "http://s3.amazonaws.com/fabletest/bv2814ghmd",
                "width": 500,
                "height": 351
            },
            {
                "url": "http://s3.amazonaws.com/fabletest/x0dq7gzb4f",
                "width": 230,
                "height": 230
            },
            {
                "url": "http://s3.amazonaws.com/fabletest/4e7h95rt3f",
                "width": 230,
                "height": 480
            },
            {
                "url": "http://s3.amazonaws.com/fabletest/g1pmqk7r6y",
                "width": 480,
                "height": 230
            }
        ],
        "loc_latlong": [
            57.0,
            -99.0
        ],
        "thumb_480x230": {
            "url": "http://s3.amazonaws.com/fabletest/g1pmqk7r6y",
            "width": 480,
            "height": 230
        },
        "processed": true,
        "author_id": 1,
        "content_id": 13259,
        "thumb_500x500_low": {
            "url": "http://s3.amazonaws.com/fabletest/oznumyqve7",
            "width": 500,
            "quality": 4,
            "height": 351
        }
    },
    "browser_long": -122.53489685058594,
    "pos_votes_count": 0
}


来源: stackexchange

问:
About operator overload
I have a program in c++ that overload this operator >>. This operator is in charge of asking for a text entry cin >> My question is what do I have to do in case I have to use this same operator but for a ifstream entry.

EDITED with code

```<code>istream & operator >> (istream & Read, Person & ObjPers) {
     cout << "\ n \ n Enter name of Person:";
     Lee >> ObjPers.NomPers;
     cout << "\ n \ n Enter year of birth:";
     Read >> ObjPers.AnioNac;
     cout << "\ n \ nEnter place of birth:";
     Read >> ObjPers.LugNac;
     cout << "\ n \ nIs it alive ?:";
     Read >> ObjPers.Vive;
     return Read;
}
</code>```

If I need use the same operator but with a different use as ifstream >> variable What I need do ?

EDIT2:

When I overload ostream << this happens:

```<code>   ostream & operator << (ostream & Write, Persona & ObjPers) {
    Write << "\ n \ nData of the Person \ n";
    Type << "\ nName:" << ObjPers.NomPers;
    Write << "\ nPlace of birth:" << ObjPers.LugNac;
    Write << "\ nYear of birth:" << ObjPers.AnioNac;
    if (ObjPers.live == 1)
    Write << "\ nIt is alive. \ N";
    else
    Write << "\ nNot alive. \ N";
         return Write;

    }
</code>```

I when i try to use ofstream with << operator I can't the overloaded operator runs first

```<code>void BinaryTree <T> :: Save (NodeTree <T> * p, ofstream & out)
{
     if (p) {

        Save (p-> Sonleft, out);
         exit << p-> Info;

        Save (p-> SonRigth, out);

     }
     cout << endl;

}
</code>```

答:
When you implement the operator>> function,

Don't use  std::cin or std::cout in its implementation.

Assume that the user knows what to enter for such an object.

Use fully qualified names for istream, i.e. use std::istream& Read insted of istream& Read.

My suggestion for your function:

```<code>std::istream& operator>>(std::istream& in, Person & ObjPers) {
   in >> ObjPers.NomPers;
   in >> ObjPers.AnioNac;
   in >> ObjPers.LugNac;
   in >> ObjPers.Vive;
   return in;
}
</code>```

or combine the statements to one:

```<code>std::istream& operator>>(std::istream& in, Person & ObjPers) {
   return (in >> ObjPers.NomPers
              >> ObjPers.AnioNac
              >> ObjPers.LugNac
              >> ObjPers.Vive);
}
</code>```

ContentLicense: CC BY-SA 3.0

Title: About operator overload

Body:
I have a program in c++ that overload this operator >>. This operator is in charge of asking for a text entry cin >> My question is what do I have to do in case I have to use this same operator but for a ifstream entry.

EDITED with code

istream & operator >> (istream & Read, Person & ObjPers) {
     cout << "\ n \ n Enter name of Person:";
     Lee >> ObjPers.NomPers;
     cout << "\ n \ n Enter year of birth:";
     Read >> ObjPers.AnioNac;
     cout << "\ n \ nEnter place of birth:";
     Read >> ObjPers.LugNac;
     cout << "\ n \ nIs it alive ?:";
     Read >> ObjPers.Vive;
     return Read;
}

If I need use the same operator but with a different use as ifstream >> variable What I need do ?

EDIT2:

When I overload ostream << this happens:

   ostream & operator << (ostream & Write, Persona & ObjPers) {
    Write << "\ n \ nData of the Person \ n";
    Type << "\ nName:" << ObjPers.NomPers;
    Write << "\ nPlace of birth:" << ObjPers.LugNac;
    Write << "\ nYear of birth:" << ObjPers.AnioNac;
    if (ObjPers.live == 1)
    Write << "\ nIt is alive. \ N";
    else
    Write << "\ nNot alive. \ N";
         return Write;

    }

I when i try to use ofstream with << operator I can't the overloaded operator runs first

void BinaryTree <T> :: Save (NodeTree <T> * p, ofstream & out)
{
     if (p) {

        Save (p-> Sonleft, out);
         exit <
 Info;

        Save (p-> SonRigth, out);

     }
     cout << endl;

}

Body:
When you implement the operator>> function,

Don't use  std::cin or std::cout in its implementation.

Assume that the user knows what to enter for such an object.

Use fully qualified names for istream, i.e. use std::istream& Read insted of istream& Read.

My suggestion for your function:

std::istream& operator>>(std::istream& in, Person & ObjPers) {
   in >> ObjPers.NomPers;
   in >> ObjPers.AnioNac;
   in >> ObjPers.LugNac;
   in >> ObjPers.Vive;
   return in;
}

or combine the statements to one:

std::istream& operator>>(std::istream& in, Person & ObjPers) {
   return (in >> ObjPers.NomPers
              >> ObjPers.AnioNac
              >> ObjPers.LugNac
              >> ObjPers.Vive);
}


问:
How can I transfer ArrayLists between classes?
I am a rather large-scale noob. I have come across the answer a multitude of times, but, it was just not in a format I could understand. Right now, I am attempting to send a List full of values, to a separate class. I tried each of the resources but to no avail. Apologies if this is an inappropriate question here, a simple ask-with-no-code.</p>

答:
You need a method or a constructor on the class the receives the ArrayList that accepts ArrayLists.

Pseudocode:

```<code>public class Class1 {

    //Constructor
    public Class1(){}

    //Methods
    public ArrayList createArray(){
        //Your code here
    }

}

public class Class2 {

    //Constructor
    public Class2(ArrayList myArray){
        //Your code here
    }

}

public class Test{
    Class1 c1 = new Class1;
    ArrayList array = c1.createArray();
    Class2 c2 = new Class2(array);
}
</code>```

Body:
You need a method or a constructor on the class the receives the ArrayList that accepts ArrayLists.

Pseudocode:

public class Class1 {

    //Constructor
    public Class1(){}

    //Methods
    public ArrayList createArray(){
        //Your code here
    }

}

public class Class2 {

    //Constructor
    public Class2(ArrayList myArray){
        //Your code here
    }

}

public class Test{
    Class1 c1 = new Class1;
    ArrayList array = c1.createArray();
    Class2 c2 = new Class2(array);
}


问:
PDOException “could not find driver” in php
I have installed Lampp on my linux system, and I am learning symfony2, while trying to create the schema with symfony2 command

```<code>php app/console doctrine:schema:create
</code>```

I am getting the following error message:-

```<code>PDOException “could not find driver”
</code>```

I also uncomment this line extension=php_pdo_mysql.dll in php.ini file

I tried to look and google my issue but couldn't resolve my problem. when i run php -m command i am getting the following result:-

```<code>PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mhash
openssl
pcntl
pcre
PDO
----
----
</code>```

Is there a way i can remove this issue ?

答:
There are two PHP versions installed in my server PHP 5.6 and PHP 7

When I run the command php app/console doctrine:schema:update I have the error : [PDOException] could not find driver

I resolve this error by specifying the PHP version:

```<code>php5.6 app/console doctrine:schema:update
</code>```

Body:
I have installed Lampp on my linux system, and I am learning symfony2, while trying to create the schema with symfony2 command

php app/console doctrine:schema:create

I am getting the following error message:-

PDOException “could not find driver”

I also uncomment this line extension=php_pdo_mysql.dll in php.ini file

I tried to look and google my issue but couldn't resolve my problem. when i run php -m command i am getting the following result:-

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mhash
openssl
pcntl
pcre
PDO
----
----

Is there a way i can remove this issue ?

Body:
There are two PHP versions installed in my server PHP 5.6 and PHP 7

When I run the command php app/console doctrine:schema:update I have the error : [PDOException] could not find driver

I resolve this error by specifying the PHP version:

php5.6 app/console doctrine:schema:update


问:
Importing sklearn error
So I have been trying to install numpy, scipy and sklearn for a course I am taking. After many issues and numerous attempts, I installed pycharm and used their built in package manager to get numpy and scipy. I also installed sklearn but when I import it in my code i get the following error:

```<code>Traceback (most recent call last):
  Python Shell, prompt 1, line 3
  File "C:\Users\Berges\AppData\Local\Programs\Python\Python35\Lib\site-packages\sklearn\__init__.py", line 57, in <module>
    from .base import clone
  File "C:\Users\Berges\AppData\Local\Programs\Python\Python35\Lib\site-packages\sklearn\base.py", line 12, in <module>
    from .utils.fixes import signature
  File "C:\Users\Berges\AppData\Local\Programs\Python\Python35\Lib\site-packages\sklearn\utils\__init__.py", line 11, in <module>
    from .validation import (as_float_array,
  File "C:\Users\Berges\AppData\Local\Programs\Python\Python35\Lib\site-packages\sklearn\utils\validation.py", line 18, in <module>
    from ..utils.fixes import signature
  File "C:\Users\Berges\AppData\Local\Programs\Python\Python35\Lib\site-packages\sklearn\utils\fixes.py", line 406, in <module>
    if np_version < (1, 12, 0):
builtins.TypeError: unorderable types: str() < int()
</code>```

(I am using python 3.5.2 and when u run python3 on bash I can import sklearn just fine but it seems to be using python 3.4.3 for that)

UPDATE:

I installed Anaconda and attempted to run the following code from Wing IDE and Atom:

```<code>import numpy as np
X = np.array([[-1,-1],[-2,-1],[-3.-2],[1,1],[2,1],[3,2]])
Y = np.array([1,1,1,2,2,2])
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X,Y)
print(clf.predict([[-0.8,-1]]))
</code>```

I then get the following error:

```<code>Traceback (most recent call last):
  File "C:\Users\Berges\Downloads\test.py", line 6, in <module>
    clf.fit(X,Y)
  File "C:\Users\Berges\Anaconda3\lib\site-packages\sklearn\naive_bayes.py", line 173, in fit
    X, y = check_X_y(X, y)
  File "C:\Users\Berges\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 510, in check_X_y
    ensure_min_features, warn_on_dtype, estimator)
  File "C:\Users\Berges\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 373, in check_array
    array = np.array(array, dtype=dtype, order=order, copy=copy)
ValueError: setting an array element with a sequence.
</code>```

答:
You missed a small detail that causes this error.

In the X array you type [-3. -2] instead of [-3, -2].

So you missed a comma.

The following works fine:

```<code>import numpy as np

X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
Y = np.array([1, 1, 1, 2, 2, 2])

from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X, Y)

print(clf.predict([[-0.8, -1]]))
</code>```

Results:

```<code>[1]
</code>```

Title: Importing sklearn error

Body:
So I have been trying to install numpy, scipy and sklearn for a course I am taking. After many issues and numerous attempts, I installed pycharm and used their built in package manager to get numpy and scipy. I also installed sklearn but when I import it in my code i get the following error:

Traceback (most recent call last):
  Python Shell, prompt 1, line 3
  File "C:\Users\Berges\AppData\Local\Programs\Python\Python35\Lib\site-packages\sklearn\__init__.py", line 57, in <module>
    from .base import clone
  File "C:\Users\Berges\AppData\Local\Programs\Python\Python35\Lib\site-packages\sklearn\base.py", line 12, in <module>
    from .utils.fixes import signature
  File "C:\Users\Berges\AppData\Local\Programs\Python\Python35\Lib\site-packages\sklearn\utils\__init__.py", line 11, in <module>
    from .validation import (as_float_array,
  File "C:\Users\Berges\AppData\Local\Programs\Python\Python35\Lib\site-packages\sklearn\utils\validation.py", line 18, in <module>
    from ..utils.fixes import signature
  File "C:\Users\Berges\AppData\Local\Programs\Python\Python35\Lib\site-packages\sklearn\utils\fixes.py", line 406, in <module>
    if np_version < (1, 12, 0):
builtins.TypeError: unorderable types: str() < int()

(I am using python 3.5.2 and when u run python3 on bash I can import sklearn just fine but it seems to be using python 3.4.3 for that)

UPDATE:

I installed Anaconda and attempted to run the following code from Wing IDE and Atom:

import numpy as np
X = np.array([[-1,-1],[-2,-1],[-3.-2],[1,1],[2,1],[3,2]])
Y = np.array([1,1,1,2,2,2])
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X,Y)
print(clf.predict([[-0.8,-1]]))

I then get the following error:

Traceback (most recent call last):
  File "C:\Users\Berges\Downloads\test.py", line 6, in <module>
    clf.fit(X,Y)
  File "C:\Users\Berges\Anaconda3\lib\site-packages\sklearn\naive_bayes.py", line 173, in fit
    X, y = check_X_y(X, y)
  File "C:\Users\Berges\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 510, in check_X_y
    ensure_min_features, warn_on_dtype, estimator)
  File "C:\Users\Berges\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 373, in check_array
    array = np.array(array, dtype=dtype, order=order, copy=copy)
ValueError: setting an array element with a sequence.

Body:
You missed a small detail that causes this error.

In the X array you type [-3. -2] instead of [-3, -2].

So you missed a comma.

The following works fine:

import numpy as np

X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
Y = np.array([1, 1, 1, 2, 2, 2])

from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X, Y)

print(clf.predict([[-0.8, -1]]))

Results:

[1]


问:
How to make a database migration where the target remains fully operational during it
At our company we are trying to migrate data from an old Local SQL Server database to a RDS MySql database using SSIS. The original database is roughly 4GB in size and we are required to do the migration without taking down the production servers. The dev team reports that the migration runs fine with data being transferred, but after several hours (roughly 8 hours, but it's not exact. Sometimes it's less sometimes it's more) the connection abruptly closes. We have tried everything we can possibly think of on our side but we don't know what else could be going wrong. Based on their tests and ours, we think it could be the instance is closing the connection after being open for too long. Does anyone know what could be causing this?.

We need another alternative tool to make the migration and the target databases remains fully operational during the process?

答:
I recommend you try the MySQL workbench 6.3 that oracle has out which has a piece precisely designed for your purpose.  It is under GNU license so they have a community version which is free.  There is also Data Loader which has a free trial version. The standard version is only $99.  You can use logical export and convert it, so there will be no down time.  GoldenGate would be perfect, but it is crazy expensive.  I know people who have used Kettle to do what you are doing.  Kettle is open source but you will have to write transforms so it will be a bit more tedious.  With SqlServer you can clone the database, and then use the cloned version to do whatever you need to do to get it converted to MySql, bring it down, whatever, while the original stays up.

Cheers

Why cannot a 4GB database be brought down for a bit?  And why would a 4GB database take 8 hours using SSIS ?   I commonly move terabytes around in less time than that.  That is in an Oracle shop, but still...


问:
Powershell scripts going to sleep
I have a powershell script which loops over each file in a folder and does a lot of "high-computation" tasks on each of these files. I have multiple instances of this script running on my system.

I do use a write-host before starting each of these tasks to see when these tasks start and end.

I started these instances of the script last night and when I came today morning I noticed that some of my powershell terminal were stuck at a write-host command and when I pressed ENTER they wrote that content to terminal and continued the preocessing.

It looks like some of these terminals go to sleep. Why am i seeing this and how can i prevent this?

答:
Disable the "QuickEdit" option in the "Windows PowerShell" Properties window.

Right click the PowerShell window to get the to the Properties window.

Title: Powershell scripts going to sleep


问:
Is Android POSIX-compatible?
Is Android POSIX-compatible? I know it uses the Linux kernel, but I'm not sure if that means it's POSIX compatible, as the POSIX standard deals more with userland functions. So, is it compatible?

For example, if I use only ANSI and POSIX functions in my C program, would it compile and run on Android without needing any code-changes?

答:
Official Bionic in tree documentation quote

https://android.googlesource.com/platform/bionic/+/37ad9597839c70a7ec79578e5072df9c189fc830/docs/status.md

Run ./libc/tools/check-symbols-glibc.py in bionic/ for the current list of POSIX functions implemented by glibc but not by bionic. Currently (2017-10):

```<code>aio_cancel
aio_error
aio_fsync
aio_read
aio_return
aio_suspend
aio_write
lio_listio
pthread_cancel
pthread_mutex_consistent
pthread_mutex_getprioceiling
pthread_mutex_setprioceiling
pthread_mutexattr_getprioceiling
pthread_mutexattr_getprotocol
pthread_mutexattr_getrobust
pthread_mutexattr_setprioceiling
pthread_mutexattr_setprotocol
pthread_mutexattr_setrobust
pthread_setcancelstate
pthread_setcanceltype
pthread_testcancel
wordexp
wordfree
libm
</code>```

Current libm symbols: https://android.googlesource.com/platform/bionic/+/master/libm/libm.map.txt

0 remaining missing POSIX libm functions.

Bionic Wikipedia page

https://en.wikipedia.org/wiki/Bionic_(software)#Differences_from_POSIX

Also has some interesting info:

Although bionic aims to implement all of C11 and POSIX, there are still (as of Oreo) about 70 POSIX functions missing[8] from libc. There are also POSIX functions such as the endpwent/getpwent/setpwent family that are inapplicable to Android because it lacks a passwd database. As of Oreo, libm is complete.

Some functions deliberately do not conform to the POSIX or C standards for security reasons, such as printf which does not support the %n format string.[9]

Title: Is Android POSIX-compatible?

Body:
Official Bionic in tree documentation quote

https://android.googlesource.com/platform/bionic/+/37ad9597839c70a7ec79578e5072df9c189fc830/docs/status.md

Run ./libc/tools/check-symbols-glibc.py in bionic/ for the current list of POSIX functions implemented by glibc but not by bionic. Currently (2017-10):

aio_cancel
aio_error
aio_fsync
aio_read
aio_return
aio_suspend
aio_write
lio_listio
pthread_cancel
pthread_mutex_consistent
pthread_mutex_getprioceiling
pthread_mutex_setprioceiling
pthread_mutexattr_getprioceiling
pthread_mutexattr_getprotocol
pthread_mutexattr_getrobust
pthread_mutexattr_setprioceiling
pthread_mutexattr_setprotocol
pthread_mutexattr_setrobust
pthread_setcancelstate
pthread_setcanceltype
pthread_testcancel
wordexp
wordfree
libm

Current libm symbols: https://android.googlesource.com/platform/bionic/+/master/libm/libm.map.txt

0 remaining missing POSIX libm functions.

Bionic Wikipedia page

https://en.wikipedia.org/wiki/Bionic_(software)#Differences_from_POSIX

Also has some interesting info:

Although bionic aims to implement all of C11 and POSIX, there are still (as of Oreo) about 70 POSIX functions missing[8] from libc. There are also POSIX functions such as the endpwent/getpwent/setpwent family that are inapplicable to Android because it lacks a passwd database. As of Oreo, libm is complete.

Some functions deliberately do not conform to the POSIX or C standards for security reasons, such as printf which does not support the %n format string.[9]


问:
The IE Fieldset Background Color Bleed Bug
Setup:

I have an HTML page with a fieldset
  element. The background color of the
  fieldset element is different from the
  background of the page. The border of
  the fieldset has a slightly darker
  color that the background.

Problem:

In Firefox only the area inside the
  border has the specified background
  color. In IE7 the background color
  flows over the area delimited by the
  border (only at the top).

Question:

What can I do to make the background
  of the fieldset element stay within
  the area delimited by the border on
  IE7?

答:
<s>Have you reset your margins and padding?</s>

EDIT:

Actually, Matt Heerema apparently had a similar problem. Which he successfully fixed.

"Getting Fieldset Backgrounds and Legends to Behave in IE".

OwnerDisplayName: Diego Deberdt

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: Diego Deberdt

OwnerDisplayName: Jonathan Sampson

LastEditorDisplayName: Jonathan Sampson


问:
jQuery jFlow plugin. How can I have more than one on a single page?
I'm using a very lovely and simple plugin called jFlow that gives me a basic content slider etc. However, I can see no documentation or help on how to get two (or more) on one page at the same time working seperately from one another.

At the moment, if I set two up, they almost combine as one, despite having a different configuration from one another.

Any help would be great, thanks.
Michael.

答:
I have just battled with this and as Tim said, they key is to use classes, separate IDs and define everything in each instance of jFlow, like this:

```<code>$(function() {
        $("#controller1").jFlow({
            controller: ".jFlowControl1",
            slides: "#slides1",
            slideWrapper : "#jFlowSlide1",
            width: "300px",
            height: "280px",
            prev: ".jFlowPrev1",
            next: ".jFlowNext1"
        });
        $("#controller2").jFlow({
            controller: ".jFlowControl2",
            slides: "#slides2",
            slideWrapper : "#jFlowSlide2",
            width: "300px",
            height: "280px",
            prev: ".jFlowPrev2",
            next: ".jFlowNext2"
        });
        $("#controller3").jFlow({
            controller: ".jFlowControl3",
            slides: "#slides3",
            slideWrapper : "#jFlowSlide3",
            width: "300px",
            height: "280px",
            prev: ".jFlowPrev3",
            next: ".jFlowNext3"
        });
    });
</code>```

And the sliders look something like this:

```<code><div id="controller1" class="hidden">
    <span class="jFlowControl1">No 1</span>
    <span class="jFlowControl1">No 2</span>
    <span class="jFlowControl1">No 3</span>
</div>
<div id="slides1">
        <img src="images/1.jpg" />
        <img src="images/2.jpg" />
        <img src="images/3.jpg" />
</div>

<!-- second controller and slides -->
<div id="controller2" class="hidden">
    <span class="jFlowControl2">No 1</span>
    <span class="jFlowControl2">No 2</span>
    <span class="jFlowControl2">No 3</span>
</div>
<div id="slides2">
    <img src="images/1.jpg" />
    <img src="images/2.jpg" />
    <img src="images/3.jpg" />
</div>

<!-- third controller and slides -->
<div id="controller3" class="hidden">
    <span class="jFlowControl3">No 1</span>
    <span class="jFlowControl3">No 2</span>
    <span class="jFlowControl3">No 3</span>
</div>
<div id="slides3">
    <img src="images/1.jpg" />
    <img src="images/2.jpg" />
    <img src="images/3.jpg" />
</div>
</code>```

So pretty much everything has a 1, 2 or 3 after it, or however many jFlow sliders you want.

If you want the previous and next to work these would be defined in the same way, like so:

```<code><!-- first slider -->
<span class="jFlowPrev1"><</span>
<span class="jFlowNext1">></span>

<!-- second slider -->
<span class="jFlowPrev2"><</span>
<span class="jFlowNext2">></span>

<!-- third slider -->
<span class="jFlowPrev3"><</span>
<span class="jFlowNext3">></span>
</code>```

Body:
I have just battled with this and as Tim said, they key is to use classes, separate IDs and define everything in each instance of jFlow, like this:

$(function() {
        $("#controller1").jFlow({
            controller: ".jFlowControl1",
            slides: "#slides1",
            slideWrapper : "#jFlowSlide1",
            width: "300px",
            height: "280px",
            prev: ".jFlowPrev1",
            next: ".jFlowNext1"
        });
        $("#controller2").jFlow({
            controller: ".jFlowControl2",
            slides: "#slides2",
            slideWrapper : "#jFlowSlide2",
            width: "300px",
            height: "280px",
            prev: ".jFlowPrev2",
            next: ".jFlowNext2"
        });
        $("#controller3").jFlow({
            controller: ".jFlowControl3",
            slides: "#slides3",
            slideWrapper : "#jFlowSlide3",
            width: "300px",
            height: "280px",
            prev: ".jFlowPrev3",
            next: ".jFlowNext3"
        });
    });

And the sliders look something like this:

<div id="controller1" class="hidden">
    <span class="jFlowControl1">No 1</span>
    <span class="jFlowControl1">No 2</span>
    <span class="jFlowControl1">No 3</span>
</div>
<div id="slides1">
        <img src="images/1.jpg" />
        <img src="images/2.jpg" />
        <img src="images/3.jpg" />
</div>

<!-- second controller and slides -->
<div id="controller2" class="hidden">
    <span class="jFlowControl2">No 1</span>
    <span class="jFlowControl2">No 2</span>
    <span class="jFlowControl2">No 3</span>
</div>
<div id="slides2">
    <img src="images/1.jpg" />
    <img src="images/2.jpg" />
    <img src="images/3.jpg" />
</div>

<!-- third controller and slides -->
<div id="controller3" class="hidden">
    <span class="jFlowControl3">No 1</span>
    <span class="jFlowControl3">No 2</span>
    <span class="jFlowControl3">No 3</span>
</div>
<div id="slides3">
    <img src="images/1.jpg" />
    <img src="images/2.jpg" />
    <img src="images/3.jpg" />
</div>

So pretty much everything has a 1, 2 or 3 after it, or however many jFlow sliders you want.

If you want the previous and next to work these would be defined in the same way, like so:

<!-- first slider -->
<span class="jFlowPrev1">&lt;</span>
<span class="jFlowNext1">&gt;</span>

<!-- second slider -->
<span class="jFlowPrev2">&lt;</span>
<span class="jFlowNext2">&gt;</span>

<!-- third slider -->
<span class="jFlowPrev3">&lt;</span>
<span class="jFlowNext3">&gt;</span>


问:
How to Disable UWP App Suspension?
I am using C# to develop a UWP app for Windows 10 running only on desktop computers, targeting platform version 10.0.14393.0. Due to business requirements, the app lifecycle must behave like a traditional Win32 application.

Therefore, I followed the recommendation from this article to request an ExtendedExecutionSession  with ExtendedExecutionReason.Unspecified. I also configured Windows to never sleep and never hibernate.

Still, on rare occasions, Windows will revoke the extended execution session with reason SystemPolicy and then proceed to suspend the UWP app.

Two questions:

How can I get more information (system logs? event logs?) regarding what led to Windows revoking the extended execution session?

How can I get rid of these rare cases of suspensions so that the UWP app lifecycle behaves exactly like Win32 applications (that is, stay running until user explicitly stops it from running)?

Thanks!

答:
I remembered that previous SO post - His question was : When I use the App service to communicate with Win32 apps, it prevents the app entering suspend state.
I've succeeded to recreate the issue with the sample app that referred at the post.

I don't now that is an intended behavior or not, but it may help to resolve your situation.

UWP application not going to suspend state

Title: How to Disable UWP App Suspension?


问:
Android Kotlin - Volley Unexpected response code 500
I made REST API with Django Rest Framework. Currently, I'm working on a mobile app for my site. When I do POST request (it's my second POST request in my app) I'm getting this error:

E/Volley: [385] BasicNetwork.performRequest: Unexpected response code 500 for http://laude.ct8.pl/api/user/data/aktualizacja/

Here is my code:

```<code>private val UPDATE_URL = "http://laude.ct8.pl/api/user/data/aktualizacja/"
private var volleyRequest: RequestQueue? = null
private val jsonObj = JSONObject()

volleyRequest = Volley.newRequestQueue(this)

private fun aktualizacja() {

        jsonObj.put("librus_user", usernameEdit.text)
        jsonObj.put("librus_pswd", passwordEdit.text)

        val req = JsonObjectRequest(Request.Method.POST, UPDATE_URL, jsonObj,
                Response.Listener { response ->
                    Toast.makeText(this, response.toString(), Toast.LENGTH_LONG).show()
                    val user = Intent(this, UserActivity::class.java)
                    startActivity(user)
                },
                Response.ErrorListener { error ->
                    Toast.makeText(this, error.toString(), Toast.LENGTH_LONG).show()
                })
        req.retryPolicy = DefaultRetryPolicy(60000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)

        volleyRequest!!.add(req)
    }
</code>```

When I use same data on my website I'm not getting any errors, I got it only on a mobile app.
Thanks for help !

答:
The server error is caused by you making JsonObjectRequest and passing an JsonObject as a body of parameter while your server requires them as Strings(I observed the link!). The quick fix is to use StringRequest and pass your parameters as a String as ! Check the code below to get the idea!

```<code>private val UPDATE_URL = "http://laude.ct8.pl/api/user/data/aktualizacja/"
private var volleyRequest: RequestQueue? = null

volleyRequest = Volley.newRequestQueue(this)

private fun aktualizacja() {

        val req = object : StringRequest(Request.Method.POST,
                UPDATE_URL,
                Response.Listener { response ->
                Toast.makeText(this, response, Toast.LENGTH_LONG).show()
                val user = Intent(this, UserActivity::class.java)
                startActivity(user)

                }, Response.ErrorListener { e ->

               Toast.makeText(this, error.toString(), Toast.LENGTH_LONG).show()
        }) {
            public override fun getParams(): Map<String, String> {
                val params = HashMap<String, String>()
                params.put("username", usernameEdit.text)
                params.put("password", passwordEdit.text)
                return params
            }
        }
        req.retryPolicy = DefaultRetryPolicy(60000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)

    volleyRequest!!.add(req)

}
</code>```

You should also NOTE that the response is also a String so if you need it as a JSONOject convert it.

Sorry if you may get any errors in the code! I wrote the code in Java and convert to Kotlin using Android Studio!! I hope you will get the general idea!

Body:
I made REST API with Django Rest Framework. Currently, I'm working on a mobile app for my site. When I do POST request (it's my second POST request in my app) I'm getting this error:

E/Volley: [385] BasicNetwork.performRequest: Unexpected response code 500 for http://laude.ct8.pl/api/user/data/aktualizacja/

Here is my code:

private val UPDATE_URL = "http://laude.ct8.pl/api/user/data/aktualizacja/"
private var volleyRequest: RequestQueue? = null
private val jsonObj = JSONObject()

volleyRequest = Volley.newRequestQueue(this)

private fun aktualizacja() {

        jsonObj.put("librus_user", usernameEdit.text)
        jsonObj.put("librus_pswd", passwordEdit.text)

        val req = JsonObjectRequest(Request.Method.POST, UPDATE_URL, jsonObj,
                Response.Listener { response ->
                    Toast.makeText(this, response.toString(), Toast.LENGTH_LONG).show()
                    val user = Intent(this, UserActivity::class.java)
                    startActivity(user)
                },
                Response.ErrorListener { error ->
                    Toast.makeText(this, error.toString(), Toast.LENGTH_LONG).show()
                })
        req.retryPolicy = DefaultRetryPolicy(60000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)

        volleyRequest!!.add(req)
    }

When I use same data on my website I'm not getting any errors, I got it only on a mobile app.
Thanks for help !

Body:
The server error is caused by you making JsonObjectRequest and passing an JsonObject as a body of parameter while your server requires them as Strings(I observed the link!). The quick fix is to use StringRequest and pass your parameters as a String as ! Check the code below to get the idea!

private val UPDATE_URL = "http://laude.ct8.pl/api/user/data/aktualizacja/"
private var volleyRequest: RequestQueue? = null

volleyRequest = Volley.newRequestQueue(this)

private fun aktualizacja() {

        val req = object : StringRequest(Request.Method.POST,
                UPDATE_URL,
                Response.Listener { response ->
                Toast.makeText(this, response, Toast.LENGTH_LONG).show()
                val user = Intent(this, UserActivity::class.java)
                startActivity(user)

                }, Response.ErrorListener { e ->

               Toast.makeText(this, error.toString(), Toast.LENGTH_LONG).show()
        }) {
            public override fun getParams(): Map<String, String> {
                val params = HashMap<String, String>()
                params.put("username", usernameEdit.text)
                params.put("password", passwordEdit.text)
                return params
            }
        }
        req.retryPolicy = DefaultRetryPolicy(60000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)

    volleyRequest!!.add(req)

}

You should also NOTE that the response is also a String so if you need it as a JSONOject convert it.

Sorry if you may get any errors in the code! I wrote the code in Java and convert to Kotlin using Android Studio!! I hope you will get the general idea!


问:
How to make HTML text hidden until clicked on
I'm trying to learn how to make HTML text toggle with jQuery, which is pretty easy in itself, but I want the text to be hidden automatically until it is clicked on with a button. I've looked it up and I can't find how to do this. I figured it should be easy, and I have this part

```<code><h4 id="text1">This is some toggleable text</h4>

$(document).ready(function(){
    $("#button1").click(function(){
      $("#text1").toggle();
    });
});
</code>```

Which works fine as a regular toggle, but this leaves the text there until first clicked on.

Codepen: https://codepen.io/anon/pen/bYYeEB

答:
```<code><script>
  $(document).ready(function() {
  $("#text1").css("display", "none");//you just have to add this line
  $("#button1").click(function() {
  $("#text1").toggle();
 });
});
</script>
</code>```

Body:
I'm trying to learn how to make HTML text toggle with jQuery, which is pretty easy in itself, but I want the text to be hidden automatically until it is clicked on with a button. I've looked it up and I can't find how to do this. I figured it should be easy, and I have this part

This is some toggleable text

$(document).ready(function(){
    $("#button1").click(function(){
      $("#text1").toggle();
    });
});

Which works fine as a regular toggle, but this leaves the text there until first clicked on.

Codepen: https://codepen.io/anon/pen/bYYeEB


问:
Linked list program in C
I am coding for a simple linked list , but facing a little problem. The program is like it is accepting name, age and DOB through user, and memory for it is dynamically allocated. After taking data from the user, it is searching a name, asked by user, if the name exists, it should print all the details related to it.
Here is my code- </p>

```<code>//function declarations
struct node *initnode(char *, char *, char *);

void add(struct node *);

struct node *printnode(struct node *);

struct node *searchname(struct node *, char *);

struct node {
    char name[25];
    char age[10];
    char dob[10];
    struct node *next;
};

struct node *head = (struct node *) NULL;

struct node *initnode(char *name, char *age, char *dob1)
{
    struct node *ptr;
    ptr = (struct node *) malloc(sizeof(struct node));
    if (ptr == NULL)
        return (struct node *) NULL;
    else {
        strcpy(ptr->name, name);
        strcpy(ptr->age, age);
        strcpy(ptr->dob, dob1);
        ptr->next = NULL;
        return ptr;
    }

}

struct node *printnode(struct node *ptr)
{
    printf("Name -> %s\n", ptr->name);
    printf("age -> %s \n", ptr->age);
    printf("dob ->%s\n", ptr->dob);
    return ptr;
}

void add(struct node *newp)
{
    struct node *temp = (struct node *) malloc(sizeof(struct node));
    if (head == NULL)
        head = newp;
    else {
        for (temp = head; temp->next != NULL; temp = temp->next);
        temp->next = newp;
        temp = newp;
    }
    free(temp);
}

struct node *searchname(struct node *ptr, char *name1)
{

    if (strcmp(name1, ptr->name) == 0) {
        printf("\n name found \n");
        printf("\n details are -\n");
        printnode(ptr);
        return ptr;
    } else {
        printf("\n name not found in the database \n");
    }

}

int main()
{
    char name[25];
    char name1[25];
    char rep;
    char age[10];
    char dob[10];
    int i;
    int flag = 1;
    struct node *ptr;

    do {
        fflush(stdin);
        while (flag != 0) {
            printf("Enter name -- ");
            gets(name);

            for (i = 0; name[i] != '\0'; i++)
                if (isdigit(name[i])) {
                    printf("Error in user input, name should be in alphabets\n");
                    flag = 1;
                    break;
                }

                else
                    flag = 0;
        }

        flag = 1;

        while (flag != 0) {
            printf("Enter age -- ");
            scanf("%s", &age);
            fflush(stdin);

            for (i = 0; age[i] != '\0'; i++)
                if (isalpha(age[i])) {

                    printf("Error in user input, age should be in numbers\n");
                    flag = 1;
                    break;
                } else {
                    flag = 0;
                }
        }

        flag = 1;
        while (flag != 0) {
            printf("Enter dob in DD/MM/YY format-- ");
            scanf("%s", &dob);
            fflush(stdin);

            for (i = 0; dob[i] != '\0'; i++) {
                if (isalpha(dob[i])) {
                    printf("Error in user input, dob should be in numbers\n");
                    flag = 1;
                    break;
                } else
                    flag = 0;

            }

        }

        flag = 1;

        ptr = initnode(name, age, dob);
        add(ptr);

        printf("\n Do you want to continue?<Y/N>:\n ");
        scanf("%s", &rep);
        //rep = getchar();

    }
    while (rep == 'Y' || rep == 'y');

    printf("\n do u want to search for a name in the database? <Y/N>:\n");
    scanf("%s", &rep);

    if (rep == 'Y' || rep == 'y') {
        printf("Enter name you want to search-- ");
        scanf("%s", &name1);

        ptr = searchname(head, name1);
    } else {
        printf("\n goodbye \n");
    }

    do {
        printf("\n do u want to search again? <Y/N>:\n");
        scanf("%s", &rep);

        if (rep == 'Y' || rep == 'y') {

            printf("Enter name you want to search-- ");
            scanf("%s", &name1);

            ptr = searchname(head, name1);
        } else {
            printf("\n goodbye \n");
        }
    }
    while (rep == 'Y' || rep == 'y');
    return 0;

}
</code>```

<p>The issue is that it is searching for the first entry only and not others, can anyone help me to sort out this? I am compiling through "gcc".   </p>

答:
Check your add function, it is wrong. Step mentally through it, and see what happens
to your pointer, and to the memory it points to.

What are the malloc and free used for in the add function?

Title: Linked list program in C

Body:
I am coding for a simple linked list , but facing a little problem. The program is like it is accepting name, age and DOB through user, and memory for it is dynamically allocated. After taking data from the user, it is searching a name, asked by user, if the name exists, it should print all the details related to it.
Here is my code-

//function declarations
struct node *initnode(char *, char *, char *);

void add(struct node *);

struct node *printnode(struct node *);

struct node *searchname(struct node *, char *);

struct node {
    char name[25];
    char age[10];
    char dob[10];
    struct node *next;
};

struct node *head = (struct node *) NULL;

struct node *initnode(char *name, char *age, char *dob1)
{
    struct node *ptr;
    ptr = (struct node *) malloc(sizeof(struct node));
    if (ptr == NULL)
        return (struct node *) NULL;
    else {
        strcpy(ptr->name, name);
        strcpy(ptr->age, age);
        strcpy(ptr->dob, dob1);
        ptr->next = NULL;
        return ptr;
    }

}

struct node *printnode(struct node *ptr)
{
    printf("Name -> %s\n", ptr->name);
    printf("age -> %s \n", ptr->age);
    printf("dob ->%s\n", ptr->dob);
    return ptr;
}

void add(struct node *newp)
{
    struct node *temp = (struct node *) malloc(sizeof(struct node));
    if (head == NULL)
        head = newp;
    else {
        for (temp = head; temp->next != NULL; temp = temp->next);
        temp->next = newp;
        temp = newp;
    }
    free(temp);
}

struct node *searchname(struct node *ptr, char *name1)
{

    if (strcmp(name1, ptr->name) == 0) {
        printf("\n name found \n");
        printf("\n details are -\n");
        printnode(ptr);
        return ptr;
    } else {
        printf("\n name not found in the database \n");
    }

}

int main()
{
    char name[25];
    char name1[25];
    char rep;
    char age[10];
    char dob[10];
    int i;
    int flag = 1;
    struct node *ptr;

    do {
        fflush(stdin);
        while (flag != 0) {
            printf("Enter name -- ");
            gets(name);

            for (i = 0; name[i] != '\0'; i++)
                if (isdigit(name[i])) {
                    printf("Error in user input, name should be in alphabets\n");
                    flag = 1;
                    break;
                }

                else
                    flag = 0;
        }

        flag = 1;

        while (flag != 0) {
            printf("Enter age -- ");
            scanf("%s", &age);
            fflush(stdin);

            for (i = 0; age[i] != '\0'; i++)
                if (isalpha(age[i])) {

                    printf("Error in user input, age should be in numbers\n");
                    flag = 1;
                    break;
                } else {
                    flag = 0;
                }
        }

        flag = 1;
        while (flag != 0) {
            printf("Enter dob in DD/MM/YY format-- ");
            scanf("%s", &dob);
            fflush(stdin);

            for (i = 0; dob[i] != '\0'; i++) {
                if (isalpha(dob[i])) {
                    printf("Error in user input, dob should be in numbers\n");
                    flag = 1;
                    break;
                } else
                    flag = 0;

            }

        }

        flag = 1;

        ptr = initnode(name, age, dob);
        add(ptr);

        printf("\n Do you want to continue?<Y/N>:\n ");
        scanf("%s", &rep);
        //rep = getchar();

    }
    while (rep == 'Y' || rep == 'y');

    printf("\n do u want to search for a name in the database? <Y/N>:\n");
    scanf("%s", &rep);

    if (rep == 'Y' || rep == 'y') {
        printf("Enter name you want to search-- ");
        scanf("%s", &name1);

        ptr = searchname(head, name1);
    } else {
        printf("\n goodbye \n");
    }

    do {
        printf("\n do u want to search again? <Y/N>:\n");
        scanf("%s", &rep);

        if (rep == 'Y' || rep == 'y') {

            printf("Enter name you want to search-- ");
            scanf("%s", &name1);

            ptr = searchname(head, name1);
        } else {
            printf("\n goodbye \n");
        }
    }
    while (rep == 'Y' || rep == 'y');
    return 0;

}

The issue is that it is searching for the first entry only and not others, can anyone help me to sort out this? I am compiling through "gcc".


问:
How to get inverse object relation when specified related_name
I have the following model similiar to the relationship in the django docs https://docs.djangoproject.com/en/1.11/ref/models/relations/:

```<code>class Employee(models.Model):
    user = models.OneToOneField(User, blank=True, null=True)
    company = models.ForeignKey('companies.Company', related_name='company', blank=True, null=True)
    brand = models.OneToOneField('companies.Brand', related_name='brand', blank=True, null=True)
</code>```

I try to get the employee from the Brand like this:

```<code>attendees = Brand.objects.filter(pk=2)

for a in attendees:
    print a.employee
</code>```

I get the error:

'Brand' object has no attribute 'employee'

I have also tried:

```<code>attendees = Brand.objects.filter(pk=2)

for a in attendees:
    print a.employee_set
</code>```

and get:

'Brand' object has no attribute 'employee_set'

How can I get the employee from the brand?

Thanks

答:
The problem was related name:

```<code>brand = models.OneToOneField('companies.Brand', related_name='brand')
</code>```

I changed it to:

```<code>brand = models.OneToOneField('companies.Brand', related_name='employee')
</code>```

Body:
I have the following model similiar to the relationship in the django docs https://docs.djangoproject.com/en/1.11/ref/models/relations/:

class Employee(models.Model):
    user = models.OneToOneField(User, blank=True, null=True)
    company = models.ForeignKey('companies.Company', related_name='company', blank=True, null=True)
    brand = models.OneToOneField('companies.Brand', related_name='brand', blank=True, null=True)

I try to get the employee from the Brand like this:

attendees = Brand.objects.filter(pk=2)

for a in attendees:
    print a.employee

I get the error:

'Brand' object has no attribute 'employee'

I have also tried:

attendees = Brand.objects.filter(pk=2)

for a in attendees:
    print a.employee_set

and get:

'Brand' object has no attribute 'employee_set'

How can I get the employee from the brand?

Thanks

Body:
The problem was related name:

brand = models.OneToOneField('companies.Brand', related_name='brand')

I changed it to:

brand = models.OneToOneField('companies.Brand', related_name='employee')


问:
Evaluating a function call constructed from a string
Say I have two functions whose names are contained within a vector. I would like to test if each function works.

My approach, which I readily admit could be wrong, was to loop through the vector then paste () to the function name. But then I realized I have no idea how to evaluate the function call which is current stored as a string. Here is a reprex:

```<code>func1 <- function(){
  message("func1 works")
}

func2 <- function(){
  message("func2 works")
}

fv <- c("func1","func2")

for(i in seq_along(fv)){
  fv_func <- paste0(fv[i],"()")
  print(fv_func)
}
[1] "func1()"
[1] "func2()"
</code>```

So in this context I am asking how to evaluate func1() and func2() though the ultimate goal is to evaluate function whose names are stored in a vector - meaning i'm open to better solution.

答:
If you have the names of the functions as strings you can get() them:

```<code>fv <- c("func1","func2")

for(i in seq_along(fv)){
    fv_func <- get(fv[i])
    # Can just call normally, no need to paste () on
    fv_func()
}
</code>```

Body:
Say I have two functions whose names are contained within a vector. I would like to test if each function works.

My approach, which I readily admit could be wrong, was to loop through the vector then paste () to the function name. But then I realized I have no idea how to evaluate the function call which is current stored as a string. Here is a reprex:

func1 <- function(){
  message("func1 works")
}

func2 <- function(){
  message("func2 works")
}

fv <- c("func1","func2")

for(i in seq_along(fv)){
  fv_func <- paste0(fv[i],"()")
  print(fv_func)
}
[1] "func1()"
[1] "func2()"

So in this context I am asking how to evaluate func1() and func2() though the ultimate goal is to evaluate function whose names are stored in a vector - meaning i'm open to better solution.

Body:
If you have the names of the functions as strings you can get() them:

fv <- c("func1","func2")

for(i in seq_along(fv)){
    fv_func <- get(fv[i])
    # Can just call normally, no need to paste () on
    fv_func()
}