问:
Prop keeps returning undefined
I'm currently trying to create a table where each row has a checkbox that can be enabled or disabled.
I have created 3 files:

ChangeUserGroup.jsx - This is where the data is read from a json file

UserGroupForm.jsx - Starts the form and passes the this.prop.permissions on to the next file, which contains the table and the checkboxes.

TableShowPermissions.jsx - Contains the table and the problematic function + checkbox

I would like for the data in the ChangeUserGroup.jsx state(called groupDetails.permissions) to control if the checkbox for the given permission is initialized with "defaultChecked". But i am getting the following error:

The files contain the following:

ChangeUserGroup.jsx

```<code>import React, { Component } from 'react';
import { Helmet } from 'react-helmet';

import { Container, Row, Col, Card, CardHeader, CardBody, Table, Button } from 'reactstrap';

import jsonData from '_testdata/userGroups';
import LoadingIcon from '_components/LoadingIcon';
import UserGroupForm from '_components/UserGroupForm';

class ChangeUserGroup extends Component {

    constructor(props) {
        super(props);

        this.state = {
            isLoading: false,
            userGroupId: 0,
            groupDetails: []
        }

    }

    componentDidMount() {
        this.setState({ isLoading: true });

        const { userGroupId } = this.props.match.params

        this.setState({
            userGroupId: userGroupId
        });

        jsonData.userGroups.filter((a) => a.id.toString() === userGroupId).map((b) => this.setState({
            groupDetails: b,
            isLoading: false
        }));
    }

    render() {

        const { groupDetails, isLoading } = this.state;

        if (isLoading) {
            return <LoadingIcon />;
        }

        return (
            <>
                <Helmet>
                    <title>{global.siteName + " - Brugergrupper"}</title>
                </Helmet>

                <main>
                    <section className="section section-shaped section-lg">

                        <Container>
                            <Row className="justify-content-center">
                                <Col lg="12">
                                    <Card className="bg-secondary shadow border-0">
                                        <CardHeader className="bg-white">
                                            <h1 className="text-center">{groupDetails.name}</h1>

                                        </CardHeader>
                                        <CardBody className="px-lg-5 py-lg-5">

                                            <UserGroupForm
                                                id={groupDetails.id}
                                                groupName={groupDetails.name}
                                                position={groupDetails.position}
                                                permissions={groupDetails.permissions} />

                                        </CardBody>

                                    </Card>
                                </Col>
                            </Row>
                        </Container>
                    </section>
                </main>
            </>
        );
    }
}

export { ChangeUserGroup };
</code>```

UserGroupForm.jsx

```<code>import React, { Component } from 'react';

import { Form } from "reactstrap";

import CustomFormInput from '_components/FormStuff/CustomFormInput';
import TableShowPermissions from '_components/UserGroups/TableShowPermissions';

class UserGroupForm extends Component {

    render() {

        const { id, groupName, position, permissions } = this.props;

        return (
            <Form>
                <CustomFormInput pLabel="Gruppe navn" pIcon="fa-user" pType="text" pShowLabel="on" pValue={groupName} />
                <CustomFormInput pLabel="Gruppe position" pIcon="fa-user" pType="text" pShowLabel="on" pValue={position} />
                <hr />
                <TableShowPermissions
                    thePermissions={permissions} />
            </Form>

        );
    }
}

export default UserGroupForm;
</code>```

TableShowPermissions.jsx

```<code>import React, { Component } from 'react';

import jsonData from 'UserPermissions';

import { Table, Button } from "reactstrap";

class TableShowPermissions extends Component {

    constructor(props) {
        super(props);

        this.checkIfPermissionAdded = this.checkIfPermissionAdded.bind(this);
    }

    checkIfPermissionAdded(checkPerm) {
        const { thePermissions } = this.props;

        thePermissions.split('|').map(permC => {
            //console.log(checkPerm + " -- " + permC)
            if (checkPerm === permC) {
                return true;
            }
        });
        return false;
    }

    render() {

        return (

            <Table className="align-items-center table-bordered" responsive>
                <thead className="thead-light">
                    <tr>
                        <th scope="col">Permission navn</th>
                        <th scope="col">Beskrivelse</th>
                        <th scope="col" />
                    </tr>
                </thead>
                <tbody>

                    {jsonData.permissions.map(perm => (
                        <tr key={perm.id}>
                            <th scope="row">
                                {perm.permission}
                            </th>

                            <td>
                                {perm.description}
                            </td>

                            <td className="text-right">
                                <label className="custom-toggle">
                                    <input type="checkbox" defaultChecked={this.checkIfPermissionAdded(perm.permission)} />
                                    <span className="custom-toggle-slider rounded-circle" />
                                </label>
                            </td>
                        </tr>
                    ))}

                </tbody>
            </Table>

        );
    }
}

export default TableShowPermissions;
</code>```

JSON DATA

```<code>{
    "userGroups": [
        {
            "id": 1,
            "name": "Administrator",
            "position": "Admin",
            "permissions": "ADMIN_ROOT|"
        },
        {
            "id": 2,
            "name": "Moderator",
            "position": "Mod",
            "permissions": "ADMIN_SETTINGS_GENERAL|ADMIN_CASES_SEEALL|ADMIN_SETTINGS_CATEGORIES"
        },
        {
            "id": 3,
            "name": "Supporters",
            "position": "Supporter",
            "permissions": "ADMIN_CASES_SEEALL|"
        }
    ]
}
</code>```

Any help would be appreciated! :)

答:
Initialize your Loading initial state as true. Set your state in the constructor like this:

```<code>constructor(props) {
    super(props);

    this.state = {
        isLoading: true,
        userGroupId: props.match.params,
        groupDetails: []
    }
}
</code>```

Remove the first two setState from your componentDidMount. Each time a setState is called the render fucntion is called.

Title: Prop keeps returning undefined

Body:
I'm currently trying to create a table where each row has a checkbox that can be enabled or disabled.
I have created 3 files:

ChangeUserGroup.jsx - This is where the data is read from a json file

UserGroupForm.jsx - Starts the form and passes the this.prop.permissions on to the next file, which contains the table and the checkboxes.

TableShowPermissions.jsx - Contains the table and the problematic function + checkbox

I would like for the data in the ChangeUserGroup.jsx state(called groupDetails.permissions) to control if the checkbox for the given permission is initialized with "defaultChecked". But i am getting the following error:

The files contain the following:

ChangeUserGroup.jsx

import React, { Component } from 'react';
import { Helmet } from 'react-helmet';

import { Container, Row, Col, Card, CardHeader, CardBody, Table, Button } from 'reactstrap';

import jsonData from '_testdata/userGroups';
import LoadingIcon from '_components/LoadingIcon';
import UserGroupForm from '_components/UserGroupForm';

class ChangeUserGroup extends Component {

    constructor(props) {
        super(props);

        this.state = {
            isLoading: false,
            userGroupId: 0,
            groupDetails: []
        }

    }

    componentDidMount() {
        this.setState({ isLoading: true });

        const { userGroupId } = this.props.match.params

        this.setState({
            userGroupId: userGroupId
        });

        jsonData.userGroups.filter((a) => a.id.toString() === userGroupId).map((b) => this.setState({
            groupDetails: b,
            isLoading: false
        }));
    }

    render() {

        const { groupDetails, isLoading } = this.state;

        if (isLoading) {
            return <LoadingIcon />;
        }

        return (
            <>
                <Helmet>
                    <title>{global.siteName + " - Brugergrupper"}</title>
                </Helmet>

                        <Container>
                            <Row className="justify-content-center">
                                <Col lg="12">
                                    <Card className="bg-secondary shadow border-0">
                                        <CardHeader className="bg-white">

{groupDetails.name}

                                        </CardHeader>
                                        <CardBody className="px-lg-5 py-lg-5">

                                            <UserGroupForm
                                                id={groupDetails.id}
                                                groupName={groupDetails.name}
                                                position={groupDetails.position}
                                                permissions={groupDetails.permissions} />

                                        </CardBody>

                                    </Card>
                                </Col>
                            </Row>
                        </Container>

            </>
        );
    }
}

export { ChangeUserGroup };

UserGroupForm.jsx

import React, { Component } from 'react';

import { Form } from "reactstrap";

import CustomFormInput from '_components/FormStuff/CustomFormInput';
import TableShowPermissions from '_components/UserGroups/TableShowPermissions';

class UserGroupForm extends Component {

    render() {

        const { id, groupName, position, permissions } = this.props;

        return (
            <Form>
                <CustomFormInput pLabel="Gruppe navn" pIcon="fa-user" pType="text" pShowLabel="on" pValue={groupName} />
                <CustomFormInput pLabel="Gruppe position" pIcon="fa-user" pType="text" pShowLabel="on" pValue={position} />

                <TableShowPermissions
                    thePermissions={permissions} />
            </Form>

        );
    }
}

export default UserGroupForm;

TableShowPermissions.jsx

import React, { Component } from 'react';

import jsonData from 'UserPermissions';

import { Table, Button } from "reactstrap";

class TableShowPermissions extends Component {

    constructor(props) {
        super(props);

        this.checkIfPermissionAdded = this.checkIfPermissionAdded.bind(this);
    }

    checkIfPermissionAdded(checkPerm) {
        const { thePermissions } = this.props;

        thePermissions.split('|').map(permC => {
            //console.log(checkPerm + " -- " + permC)
            if (checkPerm === permC) {
                return true;
            }
        });
        return false;
    }

    render() {

        return (

                        Permission navn
                        Beskrivelse

                    {jsonData.permissions.map(perm => (

                                {perm.permission}

                                {perm.description}

                                    <input type="checkbox" defaultChecked={this.checkIfPermissionAdded(perm.permission)} />

                    ))}

        );
    }
}

export default TableShowPermissions;

JSON DATA

{
    "userGroups": [
        {
            "id": 1,
            "name": "Administrator",
            "position": "Admin",
            "permissions": "ADMIN_ROOT|"
        },
        {
            "id": 2,
            "name": "Moderator",
            "position": "Mod",
            "permissions": "ADMIN_SETTINGS_GENERAL|ADMIN_CASES_SEEALL|ADMIN_SETTINGS_CATEGORIES"
        },
        {
            "id": 3,
            "name": "Supporters",
            "position": "Supporter",
            "permissions": "ADMIN_CASES_SEEALL|"
        }
    ]
}

Any help would be appreciated! :)

Body:
Initialize your Loading initial state as true. Set your state in the constructor like this:

constructor(props) {
    super(props);

    this.state = {
        isLoading: true,
        userGroupId: props.match.params,
        groupDetails: []
    }
}

Remove the first two setState from your componentDidMount. Each time a setState is called the render fucntion is called.


来源: stackexchange

问:
Why does python not recognise this as my dataset even though the file clearly exists on my computer?
I am a beginner at python and i'm trying to improve my skills by trying to follow this python tutorial:
https://towardsdatascience.com/exploratory-analysis-python-kaggle-data-b0afb6ec1788

The line i typed in was:

df = pd.read_csv('C:\Stuff\Python\Medical Appointment Data\792_3538_bundle_archive.zip\KaggleV2-May-2016.csv')
```

<p>I think the line is meant to enable python to read the data so we can later construct a few graphs.
But when i type it in it gives me quite a long error here:</p>

<p>https://gyazo.com/28f7c49e70d3e968cdeb6fd653b4ea04 (sorry i didn't want to take up too much space including it all here)</p>

<p>I have tried a couple things including moving the file i'm trying to get it to use and also some formatting things like changing what quotes i use and the brackets.</p>

<p>I found this page which i think references this issue but haven't found any working solution from there.</p>

<p>"CSV file does not exist" for a filename with embedded quotes</p>

<p>This is my full code so far:</p>

```import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from IPython import get_ipython
ipy = get_ipython()
if ipy is not None:
    ipy.run_line_magic('matplotlib', 'inline')
import plotly.plotly as pyimport plotly.offline as pyo
import plotly.graph_objs as go
pyo.offline.init_notebook_mode()
df = pd.read_csv('C:\Stuff\Python\Medical Appointment Data\792_3538_bundle_archive.zip\KaggleV2-May-2016.csv')
```

Thank you in advance for any and all help recieved.
Let me know if you need any extra information.
Also i'm sorry if this is layout is bad or improper. This is my first question and i tried my best. (I can also try fix it if necessary)

答:
You can either use a raw string:

df = pd.read_csv(r'C:\Stuff\Python\Medical Appointment Data\792_3538_bundle_archive.zip\KaggleV2-May-2016.csv')

```

<p>Or escape all the slashes there:</p>

<pre class="lang-py prettyprint-override"><code>df = pd.read_csv('C:\\Stuff\\Python\\Medical Appointment Data\\792_3538_bundle_archive.zip\\KaggleV2-May-2016.csv')

</code>```

I highly recommend to use raw strings and put all your data files to the dedicated directory in your project, then your path will be shorter and more readable.

ContentLicense: CC BY-SA 4.0

Body:
I am a beginner at python and i'm trying to improve my skills by trying to follow this python tutorial:
https://towardsdatascience.com/exploratory-analysis-python-kaggle-data-b0afb6ec1788

The line i typed in was:

df = pd.read_csv('C:\Stuff\Python\Medical Appointment Data\792_3538_bundle_archive.zip\KaggleV2-May-2016.csv')

I think the line is meant to enable python to read the data so we can later construct a few graphs.
But when i type it in it gives me quite a long error here:

https://gyazo.com/28f7c49e70d3e968cdeb6fd653b4ea04 (sorry i didn't want to take up too much space including it all here)

I have tried a couple things including moving the file i'm trying to get it to use and also some formatting things like changing what quotes i use and the brackets.

I found this page which i think references this issue but haven't found any working solution from there.

"CSV file does not exist" for a filename with embedded quotes

This is my full code so far:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from IPython import get_ipython
ipy = get_ipython()
if ipy is not None:
    ipy.run_line_magic('matplotlib', 'inline')
import plotly.plotly as pyimport plotly.offline as pyo
import plotly.graph_objs as go
pyo.offline.init_notebook_mode()
df = pd.read_csv('C:\Stuff\Python\Medical Appointment Data\792_3538_bundle_archive.zip\KaggleV2-May-2016.csv')

Thank you in advance for any and all help recieved.
Let me know if you need any extra information.
Also i'm sorry if this is layout is bad or improper. This is my first question and i tried my best. (I can also try fix it if necessary)

Body:
You can either use a raw string:

df = pd.read_csv(r'C:\Stuff\Python\Medical Appointment Data\792_3538_bundle_archive.zip\KaggleV2-May-2016.csv')

Or escape all the slashes there:

df = pd.read_csv('C:\\Stuff\\Python\\Medical Appointment Data\\792_3538_bundle_archive.zip\\KaggleV2-May-2016.csv')

I highly recommend to use raw strings and put all your data files to the dedicated directory in your project, then your path will be shorter and more readable.


问:
Heroku: Precompiling assets failed. Push rejected, failed to compile Ruby app
I am trying on pushing and making my app live on heroku but when I tried execute git push heroku master I got the ff error:

```<code>giboapp git:master ❯ git push heroku master                                ⏎

Enumerating objects: 930, done.
Counting objects: 100% (930/930), done.
Delta compression using up to 2 threads
Compressing objects: 100% (645/645), done.
Writing objects: 100% (930/930), 263.37 KiB | 2.29 MiB/s, done.
Total 930 (delta 516), reused 470 (delta 255), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:             Detected buildpacks: Ruby,Node.js
remote:             See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.0.2
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.6.5
remote: -----> Installing dependencies using bundler 2.0.2
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
remote:        Fetching gem metadata from https://rubygems.org/............
remote:        Fetching rake 13.0.1
remote:        Installing rake 13.0.1
remote:        Fetching concurrent-ruby 1.1.6
remote:        Fetching thread_safe 0.3.6
remote:        Fetching minitest 5.14.1
remote:        Installing minitest 5.14.1
remote:        Installing thread_safe 0.3.6
remote:        Installing concurrent-ruby 1.1.6
remote:        Fetching builder 3.2.4
remote:        Installing builder 3.2.4
remote:        Fetching erubi 1.9.0
remote:        Installing erubi 1.9.0
remote:        Fetching mini_portile2 2.4.0
remote:        Fetching crass 1.0.6
remote:        Installing mini_portile2 2.4.0
remote:        Installing crass 1.0.6
remote:        Fetching rack 2.2.2
remote:        Fetching nio4r 2.5.2
remote:        Installing rack 2.2.2
remote:        Installing nio4r 2.5.2 with native extensions
remote:        Fetching websocket-extensions 0.1.4
remote:        Installing websocket-extensions 0.1.4
remote:        Fetching mini_mime 1.0.2
remote:        Installing mini_mime 1.0.2
remote:        Fetching arel 9.0.0
remote:        Installing arel 9.0.0
remote:        Fetching mimemagic 0.3.5
remote:        Installing mimemagic 0.3.5
remote:        Fetching execjs 2.7.0
remote:        Installing execjs 2.7.0
remote:        Fetching bcrypt 3.1.13
remote:        Installing bcrypt 3.1.13 with native extensions
remote:        Fetching msgpack 1.3.3
remote:        Installing msgpack 1.3.3 with native extensions
remote:        Fetching popper_js 1.16.0
remote:        Installing popper_js 1.16.0
remote:        Fetching method_source 1.0.0
remote:        Installing method_source 1.0.0
remote:        Fetching thor 1.0.1
remote:        Installing thor 1.0.1
remote:        Fetching ffi 1.13.0
remote:        Installing ffi 1.13.0 with native extensions
remote:        Fetching tilt 2.0.10
remote:        Installing tilt 2.0.10
remote:        Using bundler 2.0.2
remote:        Fetching coffee-script-source 1.12.2
remote:        Installing coffee-script-source 1.12.2
remote:        Fetching orm_adapter 0.5.0
remote:        Installing orm_adapter 0.5.0
remote:        Fetching kaminari-core 1.2.0
remote:        Installing kaminari-core 1.2.0
remote:        Fetching pg 1.2.3
remote:        Installing pg 1.2.3 with native extensions
remote:        Fetching puma 3.12.4
remote:        Installing puma 3.12.4 with native extensions
remote:        Fetching rb-fsevent 0.10.4
remote:        Installing rb-fsevent 0.10.4
remote:        Fetching turbolinks-source 5.2.0
remote:        Installing turbolinks-source 5.2.0
remote:        Fetching tzinfo 1.2.7
remote:        Installing tzinfo 1.2.7
remote:        Fetching nokogiri 1.10.9
remote:        Installing nokogiri 1.10.9 with native extensions
remote:        Fetching i18n 1.8.2
remote:        Installing i18n 1.8.2
remote:        Fetching websocket-driver 0.7.2
remote:        Installing websocket-driver 0.7.2 with native extensions
remote:        Fetching rack-test 1.1.0
remote:        Installing rack-test 1.1.0
remote:        Fetching sprockets 3.7.2
remote:        Installing sprockets 3.7.2
remote:        Fetching warden 1.2.8
remote:        Installing warden 1.2.8
remote:        Fetching mail 2.7.1
remote:        Installing mail 2.7.1
remote:        Fetching marcel 0.3.3
remote:        Installing marcel 0.3.3
remote:        Fetching autoprefixer-rails 9.7.4
remote:        Installing autoprefixer-rails 9.7.4
remote:        Fetching uglifier 4.2.0
remote:        Installing uglifier 4.2.0
remote:        Fetching coffee-script 2.4.1
remote:        Installing coffee-script 2.4.1
remote:        Fetching bootsnap 1.4.6
remote:        Installing bootsnap 1.4.6 with native extensions
remote:        Fetching sassc 2.3.0
remote:        Installing sassc 2.3.0 with native extensions
remote:        Fetching rb-inotify 0.10.1
remote:        Installing rb-inotify 0.10.1
remote:        Fetching turbolinks 5.2.1
remote:        Installing turbolinks 5.2.1
remote:        Fetching activesupport 5.2.4.2
remote:        Installing activesupport 5.2.4.2
remote:        Fetching faker 1.9.6
remote:        Installing faker 1.9.6
remote:        Fetching loofah 2.5.0
remote:        Installing loofah 2.5.0
remote:        Fetching sass-listen 4.0.0
remote:        Installing sass-listen 4.0.0
remote:        Fetching rails-dom-testing 2.0.3
remote:        Installing rails-dom-testing 2.0.3
remote:        Fetching globalid 0.4.2
remote:        Installing globalid 0.4.2
remote:        Fetching activemodel 5.2.4.2
remote:        Installing activemodel 5.2.4.2
remote:        Fetching jbuilder 2.10.0
remote:        Installing jbuilder 2.10.0
remote:        Fetching pundit 1.1.0
remote:        Installing pundit 1.1.0
remote:        Fetching rails-html-sanitizer 1.3.0
remote:        Installing rails-html-sanitizer 1.3.0
remote:        Fetching sass 3.7.4
remote:        Installing sass 3.7.4
remote:        Fetching activejob 5.2.4.2
remote:        Installing activejob 5.2.4.2
remote:        Fetching activerecord 5.2.4.2
remote:        Installing activerecord 5.2.4.2
remote:        Fetching actionview 5.2.4.2
remote:        Installing actionview 5.2.4.2
remote:        Fetching actionpack 5.2.4.2
remote:        Installing actionpack 5.2.4.2
remote:        Fetching kaminari-actionview 1.2.0
remote:        Installing kaminari-actionview 1.2.0
remote:        Fetching kaminari-activerecord 1.2.0
remote:        Installing kaminari-activerecord 1.2.0
remote:        Fetching kaminari 1.2.0
remote:        Installing kaminari 1.2.0
remote:        Fetching actionmailer 5.2.4.2
remote:        Fetching actioncable 5.2.4.2
remote:        Installing actionmailer 5.2.4.2
remote:        Installing actioncable 5.2.4.2
remote:        Fetching activestorage 5.2.4.2
remote:        Installing activestorage 5.2.4.2
remote:        Fetching railties 5.2.4.2
remote:        Installing railties 5.2.4.2
remote:        Fetching sprockets-rails 3.2.1
remote:        Installing sprockets-rails 3.2.1
remote:        Fetching coffee-rails 4.2.2
remote:        Fetching responders 3.0.0
remote:        Installing coffee-rails 4.2.2
remote:        Installing responders 3.0.0
remote:        Fetching font-awesome-rails 4.7.0.5
remote:        Fetching jquery-rails 4.3.5
remote:        Installing font-awesome-rails 4.7.0.5
remote:        Installing jquery-rails 4.3.5
remote:        Fetching jquery-ui-rails 6.0.1
remote:        Installing jquery-ui-rails 6.0.1
remote:        Fetching rails 5.2.4.2
remote:        Installing rails 5.2.4.2
remote:        Fetching rails-ujs 0.1.0
remote:        Installing rails-ujs 0.1.0
remote:        Fetching sass-rails 5.1.0
remote:        Installing sass-rails 5.1.0
remote:        Fetching toastr-rails 1.0.3
remote:        Installing toastr-rails 1.0.3
remote:        Fetching devise 4.7.1
remote:        Installing devise 4.7.1
remote:        Fetching sassc-rails 2.1.2
remote:        Installing sassc-rails 2.1.2
remote:        Fetching bootstrap 4.4.1
remote:        Installing bootstrap 4.4.1
remote:        Bundle complete! 29 Gemfile dependencies, 81 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into `./vendor/bundle`
remote:        Post-install message from i18n:
remote:
remote:        HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
remote:        But that may break your application.
remote:
remote:        If you are upgrading your Rails application from an older version of Rails:
remote:
remote:        Please check your Rails app for 'config.i18n.fallbacks = true'.
remote:        If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
remote:        'config.i18n.fallbacks = [I18n.default_locale]'.
remote:        If not, fallbacks will be broken in your app by I18n 1.1.x.
remote:
remote:        If you are starting a NEW Rails application, you can ignore this notice.
remote:
remote:        For more info see:
remote:        https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
remote:
remote:        Post-install message from sass:
remote:
remote:        Ruby Sass has reached end-of-life and should no longer be used.
remote:
remote:        * If you use Sass as a command-line tool, we recommend using Dart Sass, the new
remote:          primary implementation: https://sass-lang.com/install
remote:
remote:        * If you use Sass as a plug-in for a Ruby web framework, we recommend using the
remote:          sassc gem: https://github.com/sass/sassc-ruby#readme
remote:
remote:        * For more details, please refer to the Sass blog:
remote:          https://sass-lang.com/blog/posts/7828841
remote:
remote:        Bundle completed (205.46s)
remote:        Cleaning up the bundler cache.
remote: -----> Installing node-v10.15.3-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Yarn executable was not detected in the system.
remote:        Download Yarn at https://yarnpkg.com/en/docs/install
remote:        I, [2020-06-02T04:42:57.811792 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/custom-0f9c6eb8f419d40212aae1b1abd8dd92617ab9a6b297929f414ad07d06d8499c.css
remote:        I, [2020-06-02T04:42:57.812515 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/custom-0f9c6eb8f419d40212aae1b1abd8dd92617ab9a6b297929f414ad07d06d8499c.css.gz
remote:        I, [2020-06-02T04:42:57.815816 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/100x100-bb24ed89d670dafbdedc9b92250df33b1d7e1ed19a752316576b49ddc59692cd.png
remote:        I, [2020-06-02T04:42:57.817712 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/intro-bg-a44085e80be1f8213987eb40045db6f039e02308c0405b5f84874743f1fb2c63.png
remote:        I, [2020-06-02T04:42:57.820262 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/intro-img-46db85e95b37abe91c9d7356ab6d975b967b2f6da4fab28edad0106658c51b24.svg
remote:        I, [2020-06-02T04:42:57.821419 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/intro-img-46db85e95b37abe91c9d7356ab6d975b967b2f6da4fab28edad0106658c51b24.svg.gz
remote:        I, [2020-06-02T04:42:57.824955 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/list-img-e69b310f8037732ce25e835bdeff8185af501e530047c454248935496f3ed5a5.svg
remote:        I, [2020-06-02T04:42:57.825201 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/list-img-e69b310f8037732ce25e835bdeff8185af501e530047c454248935496f3ed5a5.svg.gz
remote:        I, [2020-06-02T04:42:57.828445 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/logo-e09c3450e5b47daf835806cad4de85b81c66eba28411acfc26072238016c4ab3.png
remote:        I, [2020-06-02T04:42:57.831251 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/testimonial-029a9f73596373572da3aa2b3bf601804ae209e0fbc6bb74e81ffcf3a4f374b9.jpg
remote:        rake aborted!
remote:        Uglifier::Error: Unexpected token: name (newOption). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
remote:        --
remote:         38072     $.ajax({
remote:         38073       url: '/categories',
remote:         38074       method: 'post',
remote:         38075       data: {
remote:         38076         category: { name: capitalizeFirstLetter($('#new-category').val()) }
remote:         38077       },
remote:         38078       success: function (category) {
remote:         38079         if (category.id != null) {
remote:            =>           let newOption = $('<option/>')
remote:         38081             .attr('value', category.id)
remote:         38082             .attr('selected', true)
remote:         38083             .text(category.name)
remote:         38084
remote:         38085           $('#category_select').append(newOption);
remote:         38086           $('#new-category').val('');
remote:         38087         }
remote:         38088       },
remote:        ==
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/uglifier-4.2.0/lib/uglifier.rb:291:in `parse_result'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/uglifier-4.2.0/lib/uglifier.rb:221:in `run_uglifyjs'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/uglifier-4.2.0/lib/uglifier.rb:166:in `compile'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:53:in `call'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:28:in `call'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:142:in `block in find'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:228:in `block in stat_tree
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `each'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `stat_directory'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:227:in `stat_tree'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `each'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `block in logical_paths
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `each'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `logical_paths'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:140:in `find'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
remote:        Tasks: TOP => assets:precompile
remote:        (See full trace by running task with --trace)
remote:
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !   Push rejected to giboapp.
remote:
To https://git.heroku.com/giboapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/giboapp.git'
giboapp git:master ❯                                                       ⏎
</code>```

For the record I am using postgresql for my app.

I tried to on adding this code on my config/application.rb file:

```<code>config.assets.initialize_on_precompile = false
</code>```

But still did not work after pushing again.

I also tried compiling my assets via rails precompile:assets but still no effect.

Can anyone help me on this please? I am beginner with heroku.

答:
Your Heroku Log states this:

```<code>#...
remote:        Uglifier::Error: Unexpected token: name (newOption). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
#...
</code>```

Joel_Blum mentions it already in the comments, try replacing

config.assets.js_compressor = :uglifier
```

<p>with</p>

<pre class="lang-rb prettyprint-override"><code>config.assets.js_compressor = Uglifier.new(harmony: true)
</code>```

in config/environments/production.rb

See https://github.com/lautis/uglifier/issues/127#issuecomment-352224986

Body:
I am trying on pushing and making my app live on heroku but when I tried execute git push heroku master I got the ff error:

giboapp git:master ❯ git push heroku master                                ⏎

Enumerating objects: 930, done.
Counting objects: 100% (930/930), done.
Delta compression using up to 2 threads
Compressing objects: 100% (645/645), done.
Writing objects: 100% (930/930), 263.37 KiB | 2.29 MiB/s, done.
Total 930 (delta 516), reused 470 (delta 255), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:             Detected buildpacks: Ruby,Node.js
remote:             See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.0.2
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.6.5
remote: -----> Installing dependencies using bundler 2.0.2
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
remote:        Fetching gem metadata from https://rubygems.org/............
remote:        Fetching rake 13.0.1
remote:        Installing rake 13.0.1
remote:        Fetching concurrent-ruby 1.1.6
remote:        Fetching thread_safe 0.3.6
remote:        Fetching minitest 5.14.1
remote:        Installing minitest 5.14.1
remote:        Installing thread_safe 0.3.6
remote:        Installing concurrent-ruby 1.1.6
remote:        Fetching builder 3.2.4
remote:        Installing builder 3.2.4
remote:        Fetching erubi 1.9.0
remote:        Installing erubi 1.9.0
remote:        Fetching mini_portile2 2.4.0
remote:        Fetching crass 1.0.6
remote:        Installing mini_portile2 2.4.0
remote:        Installing crass 1.0.6
remote:        Fetching rack 2.2.2
remote:        Fetching nio4r 2.5.2
remote:        Installing rack 2.2.2
remote:        Installing nio4r 2.5.2 with native extensions
remote:        Fetching websocket-extensions 0.1.4
remote:        Installing websocket-extensions 0.1.4
remote:        Fetching mini_mime 1.0.2
remote:        Installing mini_mime 1.0.2
remote:        Fetching arel 9.0.0
remote:        Installing arel 9.0.0
remote:        Fetching mimemagic 0.3.5
remote:        Installing mimemagic 0.3.5
remote:        Fetching execjs 2.7.0
remote:        Installing execjs 2.7.0
remote:        Fetching bcrypt 3.1.13
remote:        Installing bcrypt 3.1.13 with native extensions
remote:        Fetching msgpack 1.3.3
remote:        Installing msgpack 1.3.3 with native extensions
remote:        Fetching popper_js 1.16.0
remote:        Installing popper_js 1.16.0
remote:        Fetching method_source 1.0.0
remote:        Installing method_source 1.0.0
remote:        Fetching thor 1.0.1
remote:        Installing thor 1.0.1
remote:        Fetching ffi 1.13.0
remote:        Installing ffi 1.13.0 with native extensions
remote:        Fetching tilt 2.0.10
remote:        Installing tilt 2.0.10
remote:        Using bundler 2.0.2
remote:        Fetching coffee-script-source 1.12.2
remote:        Installing coffee-script-source 1.12.2
remote:        Fetching orm_adapter 0.5.0
remote:        Installing orm_adapter 0.5.0
remote:        Fetching kaminari-core 1.2.0
remote:        Installing kaminari-core 1.2.0
remote:        Fetching pg 1.2.3
remote:        Installing pg 1.2.3 with native extensions
remote:        Fetching puma 3.12.4
remote:        Installing puma 3.12.4 with native extensions
remote:        Fetching rb-fsevent 0.10.4
remote:        Installing rb-fsevent 0.10.4
remote:        Fetching turbolinks-source 5.2.0
remote:        Installing turbolinks-source 5.2.0
remote:        Fetching tzinfo 1.2.7
remote:        Installing tzinfo 1.2.7
remote:        Fetching nokogiri 1.10.9
remote:        Installing nokogiri 1.10.9 with native extensions
remote:        Fetching i18n 1.8.2
remote:        Installing i18n 1.8.2
remote:        Fetching websocket-driver 0.7.2
remote:        Installing websocket-driver 0.7.2 with native extensions
remote:        Fetching rack-test 1.1.0
remote:        Installing rack-test 1.1.0
remote:        Fetching sprockets 3.7.2
remote:        Installing sprockets 3.7.2
remote:        Fetching warden 1.2.8
remote:        Installing warden 1.2.8
remote:        Fetching mail 2.7.1
remote:        Installing mail 2.7.1
remote:        Fetching marcel 0.3.3
remote:        Installing marcel 0.3.3
remote:        Fetching autoprefixer-rails 9.7.4
remote:        Installing autoprefixer-rails 9.7.4
remote:        Fetching uglifier 4.2.0
remote:        Installing uglifier 4.2.0
remote:        Fetching coffee-script 2.4.1
remote:        Installing coffee-script 2.4.1
remote:        Fetching bootsnap 1.4.6
remote:        Installing bootsnap 1.4.6 with native extensions
remote:        Fetching sassc 2.3.0
remote:        Installing sassc 2.3.0 with native extensions
remote:        Fetching rb-inotify 0.10.1
remote:        Installing rb-inotify 0.10.1
remote:        Fetching turbolinks 5.2.1
remote:        Installing turbolinks 5.2.1
remote:        Fetching activesupport 5.2.4.2
remote:        Installing activesupport 5.2.4.2
remote:        Fetching faker 1.9.6
remote:        Installing faker 1.9.6
remote:        Fetching loofah 2.5.0
remote:        Installing loofah 2.5.0
remote:        Fetching sass-listen 4.0.0
remote:        Installing sass-listen 4.0.0
remote:        Fetching rails-dom-testing 2.0.3
remote:        Installing rails-dom-testing 2.0.3
remote:        Fetching globalid 0.4.2
remote:        Installing globalid 0.4.2
remote:        Fetching activemodel 5.2.4.2
remote:        Installing activemodel 5.2.4.2
remote:        Fetching jbuilder 2.10.0
remote:        Installing jbuilder 2.10.0
remote:        Fetching pundit 1.1.0
remote:        Installing pundit 1.1.0
remote:        Fetching rails-html-sanitizer 1.3.0
remote:        Installing rails-html-sanitizer 1.3.0
remote:        Fetching sass 3.7.4
remote:        Installing sass 3.7.4
remote:        Fetching activejob 5.2.4.2
remote:        Installing activejob 5.2.4.2
remote:        Fetching activerecord 5.2.4.2
remote:        Installing activerecord 5.2.4.2
remote:        Fetching actionview 5.2.4.2
remote:        Installing actionview 5.2.4.2
remote:        Fetching actionpack 5.2.4.2
remote:        Installing actionpack 5.2.4.2
remote:        Fetching kaminari-actionview 1.2.0
remote:        Installing kaminari-actionview 1.2.0
remote:        Fetching kaminari-activerecord 1.2.0
remote:        Installing kaminari-activerecord 1.2.0
remote:        Fetching kaminari 1.2.0
remote:        Installing kaminari 1.2.0
remote:        Fetching actionmailer 5.2.4.2
remote:        Fetching actioncable 5.2.4.2
remote:        Installing actionmailer 5.2.4.2
remote:        Installing actioncable 5.2.4.2
remote:        Fetching activestorage 5.2.4.2
remote:        Installing activestorage 5.2.4.2
remote:        Fetching railties 5.2.4.2
remote:        Installing railties 5.2.4.2
remote:        Fetching sprockets-rails 3.2.1
remote:        Installing sprockets-rails 3.2.1
remote:        Fetching coffee-rails 4.2.2
remote:        Fetching responders 3.0.0
remote:        Installing coffee-rails 4.2.2
remote:        Installing responders 3.0.0
remote:        Fetching font-awesome-rails 4.7.0.5
remote:        Fetching jquery-rails 4.3.5
remote:        Installing font-awesome-rails 4.7.0.5
remote:        Installing jquery-rails 4.3.5
remote:        Fetching jquery-ui-rails 6.0.1
remote:        Installing jquery-ui-rails 6.0.1
remote:        Fetching rails 5.2.4.2
remote:        Installing rails 5.2.4.2
remote:        Fetching rails-ujs 0.1.0
remote:        Installing rails-ujs 0.1.0
remote:        Fetching sass-rails 5.1.0
remote:        Installing sass-rails 5.1.0
remote:        Fetching toastr-rails 1.0.3
remote:        Installing toastr-rails 1.0.3
remote:        Fetching devise 4.7.1
remote:        Installing devise 4.7.1
remote:        Fetching sassc-rails 2.1.2
remote:        Installing sassc-rails 2.1.2
remote:        Fetching bootstrap 4.4.1
remote:        Installing bootstrap 4.4.1
remote:        Bundle complete! 29 Gemfile dependencies, 81 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into `./vendor/bundle`
remote:        Post-install message from i18n:
remote:
remote:        HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
remote:        But that may break your application.
remote:
remote:        If you are upgrading your Rails application from an older version of Rails:
remote:
remote:        Please check your Rails app for 'config.i18n.fallbacks = true'.
remote:        If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
remote:        'config.i18n.fallbacks = [I18n.default_locale]'.
remote:        If not, fallbacks will be broken in your app by I18n 1.1.x.
remote:
remote:        If you are starting a NEW Rails application, you can ignore this notice.
remote:
remote:        For more info see:
remote:        https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
remote:
remote:        Post-install message from sass:
remote:
remote:        Ruby Sass has reached end-of-life and should no longer be used.
remote:
remote:        * If you use Sass as a command-line tool, we recommend using Dart Sass, the new
remote:          primary implementation: https://sass-lang.com/install
remote:
remote:        * If you use Sass as a plug-in for a Ruby web framework, we recommend using the
remote:          sassc gem: https://github.com/sass/sassc-ruby#readme
remote:
remote:        * For more details, please refer to the Sass blog:
remote:          https://sass-lang.com/blog/posts/7828841
remote:
remote:        Bundle completed (205.46s)
remote:        Cleaning up the bundler cache.
remote: -----> Installing node-v10.15.3-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Yarn executable was not detected in the system.
remote:        Download Yarn at https://yarnpkg.com/en/docs/install
remote:        I, [2020-06-02T04:42:57.811792 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/custom-0f9c6eb8f419d40212aae1b1abd8dd92617ab9a6b297929f414ad07d06d8499c.css
remote:        I, [2020-06-02T04:42:57.812515 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/custom-0f9c6eb8f419d40212aae1b1abd8dd92617ab9a6b297929f414ad07d06d8499c.css.gz
remote:        I, [2020-06-02T04:42:57.815816 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/100x100-bb24ed89d670dafbdedc9b92250df33b1d7e1ed19a752316576b49ddc59692cd.png
remote:        I, [2020-06-02T04:42:57.817712 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/intro-bg-a44085e80be1f8213987eb40045db6f039e02308c0405b5f84874743f1fb2c63.png
remote:        I, [2020-06-02T04:42:57.820262 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/intro-img-46db85e95b37abe91c9d7356ab6d975b967b2f6da4fab28edad0106658c51b24.svg
remote:        I, [2020-06-02T04:42:57.821419 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/intro-img-46db85e95b37abe91c9d7356ab6d975b967b2f6da4fab28edad0106658c51b24.svg.gz
remote:        I, [2020-06-02T04:42:57.824955 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/list-img-e69b310f8037732ce25e835bdeff8185af501e530047c454248935496f3ed5a5.svg
remote:        I, [2020-06-02T04:42:57.825201 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/list-img-e69b310f8037732ce25e835bdeff8185af501e530047c454248935496f3ed5a5.svg.gz
remote:        I, [2020-06-02T04:42:57.828445 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/logo-e09c3450e5b47daf835806cad4de85b81c66eba28411acfc26072238016c4ab3.png
remote:        I, [2020-06-02T04:42:57.831251 #1618]  INFO -- : Writing /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/public/assets/testimonial-029a9f73596373572da3aa2b3bf601804ae209e0fbc6bb74e81ffcf3a4f374b9.jpg
remote:        rake aborted!
remote:        Uglifier::Error: Unexpected token: name (newOption). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
remote:        --
remote:         38072     $.ajax({
remote:         38073       url: '/categories',
remote:         38074       method: 'post',
remote:         38075       data: {
remote:         38076         category: { name: capitalizeFirstLetter($('#new-category').val()) }
remote:         38077       },
remote:         38078       success: function (category) {
remote:         38079         if (category.id != null) {
remote:            =>           let newOption = $('<option/>')
remote:         38081             .attr('value', category.id)
remote:         38082             .attr('selected', true)
remote:         38083             .text(category.name)
remote:         38084
remote:         38085           $('#category_select').append(newOption);
remote:         38086           $('#new-category').val('');
remote:         38087         }
remote:         38088       },
remote:        ==
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/uglifier-4.2.0/lib/uglifier.rb:291:in `parse_result'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/uglifier-4.2.0/lib/uglifier.rb:221:in `run_uglifyjs'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/uglifier-4.2.0/lib/uglifier.rb:166:in `compile'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:53:in `call'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:28:in `call'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:142:in `block in find'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:228:in `block in stat_tree
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `each'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `stat_directory'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:227:in `stat_tree'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `each'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `block in logical_paths
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `each'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `logical_paths'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:140:in `find'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
remote:        /tmp/build_9bbd97d889fb02756ba5cbdef84e8320/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
remote:        Tasks: TOP => assets:precompile
remote:        (See full trace by running task with --trace)
remote:
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !   Push rejected to giboapp.
remote:
To https://git.heroku.com/giboapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/giboapp.git'
giboapp git:master ❯                                                       ⏎

For the record I am using postgresql for my app.

I tried to on adding this code on my config/application.rb file:

config.assets.initialize_on_precompile = false

But still did not work after pushing again.

I also tried compiling my assets via rails precompile:assets but still no effect.

Can anyone help me on this please? I am beginner with heroku.

Body:
Your Heroku Log states this:

#...
remote:        Uglifier::Error: Unexpected token: name (newOption). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
#...

Joel_Blum mentions it already in the comments, try replacing

config.assets.js_compressor = :uglifier

with

config.assets.js_compressor = Uglifier.new(harmony: true)

in config/environments/production.rb

See https://github.com/lautis/uglifier/issues/127#issuecomment-352224986


问:
I used Joins same table (self join) with having count. But the results are not as expected. I am using Oracle database
I tried to run the below query. I want all the data in column rp_num to be in the column rp_num_group. And also i want all the data of the column rp_num which is having count more than one (more than one count in std_id, rp_fam,  rn, rp_id) to be in the column std_id_group. But with my query i get the data which is having count more than 1 in both the columns rp_num_group and std_id_group. Kindly suggest the right way to use the joins to get the correct result.

for example, if my table is like below:

std_id      rn      rp_id       rp_fam      rp_num

1234        1234    1           abc         a12
1234        1235    1           abc         a34
1234        1236    1           xyz         a56
1244        1246    2           xyz         234
1244        1245    2           hgf         z65
1254        1456    2           hgf         z78
```

<p>I would expect my result to be:</p>

<pre class="lang-none prettyprint-override"><code>std_id      rp_num_group        std_id_group
1234        a12 a34 a56          a12:abc  a34:abc
1244        234 265 z78          z65:hgf  z78:hgf
</code>```

But my result is like below:

std_id      rp_num_group        std_id_group
1234        a12 a34            a12:abc  a34:abc
1244        z65 z78            z65:hgf  z78:hgf
```

```     SELECT DISTINCT rrpn.std_id,
                          Stringagg(rrpn.rp_num)
                          over (
                            PARTITION BY tmta.rp_id,tmta.rn,tmta.std_id
                            ORDER BY Nlssort(tmta.mta, 'NLS_SORT=BINARY_CI') ROWS
                          BETWEEN unbounded
                          preceding AND unbounded following ) AS rp_num_group,
                            Stringagg_distinct(rrpn3.rp_num||':'||rrpn3.rp_fam )
                          over (
                            PARTITION BY rrpn3.std_id, rrpn3.rn, rrpn3.rp_id
                            ORDER BY Nlssort(rrpn3.rp_num, 'NLS_SORT=BINARY_CI') ROWS
                          BETWEEN unbounded
                          preceding AND unbounded following ) AS std_id_group
        FROM   data_rrpn rrpn
                join data_rrpn rrpn3
                  ON rrpn3.std_id = rrpn.std_id
                AND rrpn3.rp_fam = rrpn.rp_fam
                AND rrpn3.rn = rrpn.rn
                AND rrpn3.rp_id = rrpn.rp_id
               join (SELECT std_id,
                            rp_fam,
                            rn,
                            rp_id,
                            Count(*)
                     FROM   data_rrpn
                     GROUP  BY std_id,
                               rp_fam,
                               rn,
                               rp_id
                     HAVING Count(*) > 1) rrpn2
                 ON rrpn3.std_id = rrpn2.std_id
                    AND rrpn3.rp_fam = rrpn2.rp_fam
                    AND rrpn3.rn = rrpn2.rn
                    AND rrpn3.rp_id = rrpn2.rp_id
        ORDER  BY rrpn.std_id;
```

答:
It seems like you want simple string aggregation,  with filtering on groups having more than one record:</p>

```<code>select
    std_id,
    listagg(rp_num, ' ') within group(order by rp_num) rp_num_group,
    listagg(rp_num || ':' || rp_fam, ' ') within group(order by rp_num) std_id_group
from data_rrpn
group by std_id
having count(*) > 1
</code>```

Body:
I tried to run the below query. I want all the data in column rp_num to be in the column rp_num_group. And also i want all the data of the column rp_num which is having count more than one (more than one count in std_id, rp_fam,  rn, rp_id) to be in the column std_id_group. But with my query i get the data which is having count more than 1 in both the columns rp_num_group and std_id_group. Kindly suggest the right way to use the joins to get the correct result.

for example, if my table is like below:

std_id      rn      rp_id       rp_fam      rp_num

1234        1234    1           abc         a12
1234        1235    1           abc         a34
1234        1236    1           xyz         a56
1244        1246    2           xyz         234
1244        1245    2           hgf         z65
1254        1456    2           hgf         z78

I would expect my result to be:

std_id      rp_num_group        std_id_group
1234        a12 a34 a56          a12:abc  a34:abc
1244        234 265 z78          z65:hgf  z78:hgf

But my result is like below:

std_id      rp_num_group        std_id_group
1234        a12 a34            a12:abc  a34:abc
1244        z65 z78            z65:hgf  z78:hgf

     SELECT DISTINCT rrpn.std_id,
                          Stringagg(rrpn.rp_num)
                          over (
                            PARTITION BY tmta.rp_id,tmta.rn,tmta.std_id
                            ORDER BY Nlssort(tmta.mta, 'NLS_SORT=BINARY_CI') ROWS
                          BETWEEN unbounded
                          preceding AND unbounded following ) AS rp_num_group,
                            Stringagg_distinct(rrpn3.rp_num||':'||rrpn3.rp_fam )
                          over (
                            PARTITION BY rrpn3.std_id, rrpn3.rn, rrpn3.rp_id
                            ORDER BY Nlssort(rrpn3.rp_num, 'NLS_SORT=BINARY_CI') ROWS
                          BETWEEN unbounded
                          preceding AND unbounded following ) AS std_id_group
        FROM   data_rrpn rrpn
                join data_rrpn rrpn3
                  ON rrpn3.std_id = rrpn.std_id
                AND rrpn3.rp_fam = rrpn.rp_fam
                AND rrpn3.rn = rrpn.rn
                AND rrpn3.rp_id = rrpn.rp_id
               join (SELECT std_id,
                            rp_fam,
                            rn,
                            rp_id,
                            Count(*)
                     FROM   data_rrpn
                     GROUP  BY std_id,
                               rp_fam,
                               rn,
                               rp_id
                     HAVING Count(*) > 1) rrpn2
                 ON rrpn3.std_id = rrpn2.std_id
                    AND rrpn3.rp_fam = rrpn2.rp_fam
                    AND rrpn3.rn = rrpn2.rn
                    AND rrpn3.rp_id = rrpn2.rp_id
        ORDER  BY rrpn.std_id;

Body:
It seems like you want simple string aggregation,  with filtering on groups having more than one record:

select
    std_id,
    listagg(rp_num, ' ') within group(order by rp_num) rp_num_group,
    listagg(rp_num || ':' || rp_fam, ' ') within group(order by rp_num) std_id_group
from data_rrpn
group by std_id
having count(*) > 1


问:
How to Initialize Variable based on placeholder in Tensorflow
I have a loop running through some data (which I cannot change/access) and I need to "initialize" a variable based on the placeholder data the first time the loop is running. Here's some equivalent dummy code:

```<code>    #This is the code I can modify
x =  K.placeholder()
v = K.variable( 0 )
y = v + x**2 #Want different behaviours for y after the first iteration

    #The code bellow can only run the session, I cannot change the structure from a for loop.
sess = tf.Session()
sess.run(tf.initialize_all_variables())
for value in [4,7,2,2,5,7,8,3,1]:
    print(sess.run( K.update(v,y) , feed_dict={x: value }) )
</code>```

The problem is that I want y to change behaviour after the first update in the for loop, so I want v to "initialize" based on the first datapoint (in this case 0 + 4^2), and then do something different with the other datapoints. The reason for doing this is to speed up a process, basically I will be using the first datapoint to make a heavy calculation to get an initial value forv and then update the value using the following datapoints which is less expensive. Using tf.cond() is useless since it evaluates both return values and thus I might as well only run the heavy calculation for each datapoint.

I have tried to initialize the v variable based on the placeholder, but that does not appear to work. If anyone is familiar with Keras this is a part of an optimizer and it's get_updates() function, thus why I am not able to change the for loop running the updates.

This feels like a rather standard problem, how is it usually done with tensorflow?

答: To anyone experience similar problems, tf.cond does work to solve this I just accidentally used tensors I had defined outside of my fn_true and fn_false. Also it appears that for loops inside fn_true or fn_false breaks them and forces tensorflow to evaluate all branches.</p>

Body:
I have a loop running through some data (which I cannot change/access) and I need to "initialize" a variable based on the placeholder data the first time the loop is running. Here's some equivalent dummy code:

    #This is the code I can modify
x =  K.placeholder()
v = K.variable( 0 )
y = v + x**2 #Want different behaviours for y after the first iteration

    #The code bellow can only run the session, I cannot change the structure from a for loop.
sess = tf.Session()
sess.run(tf.initialize_all_variables())
for value in [4,7,2,2,5,7,8,3,1]:
    print(sess.run( K.update(v,y) , feed_dict={x: value }) )

The problem is that I want y to change behaviour after the first update in the for loop, so I want v to "initialize" based on the first datapoint (in this case 0 + 4^2), and then do something different with the other datapoints. The reason for doing this is to speed up a process, basically I will be using the first datapoint to make a heavy calculation to get an initial value forv and then update the value using the following datapoints which is less expensive. Using tf.cond() is useless since it evaluates both return values and thus I might as well only run the heavy calculation for each datapoint.

I have tried to initialize the v variable based on the placeholder, but that does not appear to work. If anyone is familiar with Keras this is a part of an optimizer and it's get_updates() function, thus why I am not able to change the for loop running the updates.

This feels like a rather standard problem, how is it usually done with tensorflow?


问:
Buttons in iOS app don't respond to touches around the edge of the screen
I'm relatively new to iOS development, but I'm having a go at working on some open source code for an old game that used to be pretty popular (Eden World Builder)

I've made quite a lot of progress in cleaning up the codebase, making small changes. But there's an issue I can't seem to fix. Every button in the game will not respond to taps around the edges of the screen. If a button is in the corner of the screen, you will have to tap towards the bottom of the button.

I've tried to move the buttons away from the edges, and they work, but that isn't practical for use. So there's something preventing the edges of the screen from registering button taps for some reason, and it doesn't seem to be anything to do with the button target areas themselves.

One thing I've noticed: This game is currently on the App Store, even though it hasn't been updated since 2015. In the App Store version (Which is built from the same code that I have) the issue doesn't occur. It must be something to do with building  it in a newer version of Xcode, right?

Any assistance would be very helpful, this has been frustrating me for weeks now. Thanks

答:
Try adding this to viewDidAppear</p>

```<code>override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    if let window = view.window,
        let recognizers = window.gestureRecognizers {
        recognizers.forEach { r in
            r.delaysTouchesBegan = false
            r.cancelsTouchesInView = false
            r.isEnabled = false
        }
    }
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Try adding this to viewDidAppear

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    if let window = view.window,
        let recognizers = window.gestureRecognizers {
        recognizers.forEach { r in
            r.delaysTouchesBegan = false
            r.cancelsTouchesInView = false
            r.isEnabled = false
        }
    }
}


问:
Find longest sequence of common words from list of words in python
I searched a lot for a solution and I indeed have found similar questions. This answer gives back the longest sequence of CHARACTERS that might NOT belong in all of the strings in the input list. This answer gives back the longest common sequences of WORDS that MUST belong to all of the strings in the input list.

I am looking for a combination of the above solutions. That is, I want the longest sequence of common WORDS that might NOT appear in all of the words/phrases of the input list.

Here are some examples of what is expected:

['exterior lighting', 'interior lighting'] --> 'lighting'

['ambient lighting', 'ambient light'] --> 'ambient'

['led turn signal lamp', 'turn signal lamp', 'signal and ambient lamp', 'turn signal light'] --> 'turn signal lamp'

['ambient lighting', 'infrared light'] --> ''

Thank you

答:
A rather crude solution but I think it works:</p>

```<code>from nltk.util import everygrams
import pandas as pd

def get_word_sequence(phrases):

    ngrams = []

    for phrase in phrases:
        phrase_split = [ token for token in phrase.split()]
        ngrams.append(list(everygrams(phrase_split)))

    ngrams = [i for j in ngrams for i in j]  # unpack it

    counts_per_ngram_series = pd.Series(ngrams).value_counts()

    counts_per_ngram_df = pd.DataFrame({'ngram':counts_per_ngram_series.index, 'count':counts_per_ngram_series.values})

    # discard the pandas Series
    del(counts_per_ngram_series)

    # filter out the ngrams that appear only once
    counts_per_ngram_df = counts_per_ngram_df[counts_per_ngram_df['count'] > 1]

    if not counts_per_ngram_df.empty:
        # populate the ngramsize column
        counts_per_ngram_df['ngramsize'] = counts_per_ngram_df['ngram'].str.len()

        # sort by ngramsize, ngram_char_length and then by count
        counts_per_ngram_df.sort_values(['ngramsize', 'count'], inplace = True, ascending = [False, False])

        # get the top ngram
        top_ngram = " ".join(*counts_per_ngram_df.head(1).ngram.values)

        return top_ngram

    return ''
</code>```

Body:
A rather crude solution but I think it works:

from nltk.util import everygrams
import pandas as pd

def get_word_sequence(phrases):

    ngrams = []

    for phrase in phrases:
        phrase_split = [ token for token in phrase.split()]
        ngrams.append(list(everygrams(phrase_split)))

    ngrams = [i for j in ngrams for i in j]  # unpack it

    counts_per_ngram_series = pd.Series(ngrams).value_counts()

    counts_per_ngram_df = pd.DataFrame({'ngram':counts_per_ngram_series.index, 'count':counts_per_ngram_series.values})

    # discard the pandas Series
    del(counts_per_ngram_series)

    # filter out the ngrams that appear only once
    counts_per_ngram_df = counts_per_ngram_df[counts_per_ngram_df['count'] > 1]

    if not counts_per_ngram_df.empty:
        # populate the ngramsize column
        counts_per_ngram_df['ngramsize'] = counts_per_ngram_df['ngram'].str.len()

        # sort by ngramsize, ngram_char_length and then by count
        counts_per_ngram_df.sort_values(['ngramsize', 'count'], inplace = True, ascending = [False, False])

        # get the top ngram
        top_ngram = " ".join(*counts_per_ngram_df.head(1).ngram.values)

        return top_ngram

    return ''


问:
EF Codefirst How to Load Object Hierarchy with Dynamic Proxy turned Off
I need to serialize an object to pass it as a parameter in a webservice. I followed the recommendations the the article:
 DataContractSerializer Error using Entity Framework 4.0 with WCF 4.0

This Object is quit complex because it resembles a hierarchical data structure.

Now I have a problem, because the related objects (one to many objects) are not loading and their value is null.

This is not a problem if I use Dynamic proxies, however dynamic proxy objects do not serialize for use in a webservice.

I have tried to turn on / off lazy loading in the dbContext but it made no difference.

Any one knows how I can work around this problem, perhaps even loading a proxy object and copying it to a 'Real' Object?

Thanks

答:
If it's a relationship that you really must have, your best bet is to load the data using the normal dynamic proxy object and use something like AutoMapper (or a manual conversion) to convert it into whatever you want to send across the service. You can then ensure that what you want to send gets loaded and populated.

Trying to tell EF and WCF to know how to automatically get it right for a complex hierarchical object just isn't worth the effort compared to doing the loading/conversion manually.


问:
Deleting Empty Cells from Google SpreadSheet Programatically to avoid 5000000 cell limit error
I have written small batch job in Scala language where I first pull the data from database and dump it in google spreadsheet.

Initially the job worked very well but suddenly it started failing with following error :

```<code> ERR com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
 ERR   "code" : 400,
 ERR   "errors" : [ {
 ERR     "domain" : "global",
 ERR     "reason" : "badRequest"
 ERR {
 ERR   } ],
 ERR   "message" : "This action would increase the number of cells in the workbook above the limit of 5000000 cells.",
 ERR    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
 ERR    at
</code>```

Surprisingly, I am inserting a list of 1800 records each having 20 columns. So total number of cells in my case of 36000 but it is far away from the limit 50,00,000 cells mentioned in the error.

I could not find any concrete solution yet but I removed few empty columns from the spreadsheet and the batch job started working properly. So, it might be possible that those empty rows and columns are responsible behind the limit overflow.

I am already doing clean up of entire spreadsheet before inserting the data. But I think, I need to delete the cells which are empty rather than cleaning it up.

Please find following code snippet to check my current implementation. Note that, here, I have used range value "A2:Z" as the first row is header and I don't want it to be deleted.

```<code>def  clearAndInsertRowsToSpreadSheet(itemsToAppend : util.List[util.List[AnyRef]],
                              range : String,
                              spreadSheetId : String){

    clearSpreadSheet(range,spreadSheetId)

    insertRowsToSpreadSheet(itemsToAppend,range,spreadSheetId)

  }

  private def insertRowsToSpreadSheet(itemsToAppend : util.List[util.List[AnyRef]], range : String,
                                      spreadSheetId : String) ={

    val data : ValueRange = new ValueRange()
    data.setValues(itemsToAppend)

    val appendRequest = googleSpreadSheetService.getSheets().spreadsheets()
      .values().append(spreadSheetId, range,data)

    appendRequest.setValueInputOption("USER_ENTERED")
    appendRequest.setInsertDataOption("INSERT_ROWS")

    val appendValuesResponse = appendRequest.execute()

    appendValuesResponse.getUpdates

  }
  private def clearSpreadSheet(range : String, spreadSheetId : String) : String = {

    val clearDataRequest = googleSpreadSheetService.
        getSheets().spreadsheets().
        values().clear(spreadSheetId,range, new ClearValuesRequest())

    val clearResponse = clearDataRequest.execute()

    clearResponse.getClearedRange
  }
</code>```

But, How I can write a code to delete all rows and columns which are empty before dumping my data. I tried with BatchClearValuesByDataFilterRequest but it did not work. I am searching for a some mechanism where I can provide a condition to check ROWs and Columns having empty cells.

Any suggestion appreciated !

答:
Root Cause Of the Problem

After few more round of testing and observation, I found that the problem was with the way I have used "append" function. In my code, I was first performing clean up of spreadsheet and then appending the new data using Append method.

Here, two points needs to be noted.

Clear function only clears the cells value but does not delete the cells or release the memory. So those cleared cells remains already occupied.

Google API append function actually prepends new data with existing rows(cells) rather than using existing empty cells.

To make it more clear, assume that we have 100 rows with 12 columns. So total 1200 cells are occupied. While executing the code mentioned in problem statement, the clean up function will clean up those 1200 cells but does not delete it. So, Google API considers those cells are as still occupied. Now, while calling append function with a list of 50 objects, the append method will prepend 50 new rows by moving existing 100 rows to downside. So now, after executing my code, total occupied cells will be 1800.

```<code>Total Number of Old cells = 100 ROWs * 12 Columns  = 1200
Total Number of New cells = 50 ROWs * 12 Columns   = 600
---------------------------------------------------------
Total Number of cell after job execution = 1800
</code>```

So, considering above example, frequent execution of above code will lead our spreadsheet to reach its max allowed cell limit 50,00,000 error.

Solutions :

We can solve above problem by two ways.

Remove the unused cells rather than clearing them using BatchUpdate and DeleteDimensionRequest.

Use Update method instead of Append which will use existing cells to insert the data. But note that you need to clear the spreadsheet before using Update method.

I would suggest to go with solution#2 update method as UpdateResponse provides better in depth statics. It provides total numbers of rows, columns and cells updated which can be used to tracking purpose.

Below is the code snippet for above two solutions :

Solution#1. Remove rows using BatchUpdate method and
DeleteDimentionRequest :

Here, we need to note one point. We can not delete all rows of spreadsheet. So we need to keep on static header in the spreadsheet. And while using DeleteDimentionRequest, the stat index starts with zero.

```<code>val dimensionRange : DimensionRange = new DimensionRange()
 dimensionRange.setDimension("ROWS")
 dimensionRange.setStartIndex(1)
 //dimensionRange.setEndIndex(1001)

 val deleteDimensionRequest : DeleteDimensionRequest = new DeleteDimensionRequest()
 deleteDimensionRequest.setRange(dimensionRange)

 val request : Request = new Request()
 request.setDeleteDimension(deleteDimensionRequest)

 val requests : util.List[Request] = new util.ArrayList[Request]()
 requests.add(request)

 val batchUpdateRequest : BatchUpdateSpreadsheetRequest =new  BatchUpdateSpreadsheetRequest()
 batchUpdateRequest.setRequests(requests)

 val batchUpdate: Sheets#Spreadsheets#BatchUpdate =  googleSpreadSheetService.getSheets()
    .spreadsheets()
    .batchUpdate(spreadSheetId, batchUpdateRequest)

 val batchUpdateResponse = batchUpdate.execute()
</code>```

Solution#2. Clean up the cells and call update method to insert the
data :

//Code

```<code>private def clearAndInsertRowsToSpreadSheet(itemsToAppend : util.List[util.List[AnyRef]], range : String, spreadSheetId : String) :  UpdateValuesResponse = {

        clearSpreadSheet(range, spreadSheetId)
        updateSpreadSheetData(itemsToAppend,range, spreadSheetId)

      }

      private def updateSpreadSheetData(itemsToAppend : util.List[util.List[AnyRef]], range : String, spreadSheetId : String) ={

        val data : ValueRange = new ValueRange()
        data.setValues(itemsToAppend)

        val updateRequest: Sheets#Spreadsheets#Values#Update = googleSpreadSheetService.getSheets()
          .spreadsheets()
          .values()
          .update(spreadSheetId, range, data)

        updateRequest.setValueInputOption("USER_ENTERED")
        val updateValuesResponse: UpdateValuesResponse = updateRequest.execute()
        updateValuesResponse
      }
      private def clearSpreadSheet(range : String, spreadSheetId : String) : String = {

        val clearDataRequest = googleSpreadSheetService.
          getSheets().spreadsheets().
          values().clear(spreadSheetId,range, new ClearValuesRequest())

        val clearResponse = clearDataRequest.execute()

        clearResponse.getClearedRange
      }
</code>```

Hope, above answer is sufficient enough to understand the nature of the problem and its possible solutions.

Body:
I have written small batch job in Scala language where I first pull the data from database and dump it in google spreadsheet.

Initially the job worked very well but suddenly it started failing with following error :

 ERR com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
 ERR   "code" : 400,
 ERR   "errors" : [ {
 ERR     "domain" : "global",
 ERR     "reason" : "badRequest"
 ERR {
 ERR   } ],
 ERR   "message" : "This action would increase the number of cells in the workbook above the limit of 5000000 cells.",
 ERR    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
 ERR    at

Surprisingly, I am inserting a list of 1800 records each having 20 columns. So total number of cells in my case of 36000 but it is far away from the limit 50,00,000 cells mentioned in the error.

I could not find any concrete solution yet but I removed few empty columns from the spreadsheet and the batch job started working properly. So, it might be possible that those empty rows and columns are responsible behind the limit overflow.

I am already doing clean up of entire spreadsheet before inserting the data. But I think, I need to delete the cells which are empty rather than cleaning it up.

Please find following code snippet to check my current implementation. Note that, here, I have used range value "A2:Z" as the first row is header and I don't want it to be deleted.

def  clearAndInsertRowsToSpreadSheet(itemsToAppend : util.List[util.List[AnyRef]],
                              range : String,
                              spreadSheetId : String){

    clearSpreadSheet(range,spreadSheetId)

    insertRowsToSpreadSheet(itemsToAppend,range,spreadSheetId)

  }

  private def insertRowsToSpreadSheet(itemsToAppend : util.List[util.List[AnyRef]], range : String,
                                      spreadSheetId : String) ={

    val data : ValueRange = new ValueRange()
    data.setValues(itemsToAppend)

    val appendRequest = googleSpreadSheetService.getSheets().spreadsheets()
      .values().append(spreadSheetId, range,data)

    appendRequest.setValueInputOption("USER_ENTERED")
    appendRequest.setInsertDataOption("INSERT_ROWS")

    val appendValuesResponse = appendRequest.execute()

    appendValuesResponse.getUpdates

  }
  private def clearSpreadSheet(range : String, spreadSheetId : String) : String = {

    val clearDataRequest = googleSpreadSheetService.
        getSheets().spreadsheets().
        values().clear(spreadSheetId,range, new ClearValuesRequest())

    val clearResponse = clearDataRequest.execute()

    clearResponse.getClearedRange
  }

But, How I can write a code to delete all rows and columns which are empty before dumping my data. I tried with BatchClearValuesByDataFilterRequest but it did not work. I am searching for a some mechanism where I can provide a condition to check ROWs and Columns having empty cells.

Any suggestion appreciated !

Body:
Root Cause Of the Problem

After few more round of testing and observation, I found that the problem was with the way I have used "append" function. In my code, I was first performing clean up of spreadsheet and then appending the new data using Append method.

Here, two points needs to be noted.

Clear function only clears the cells value but does not delete the cells or release the memory. So those cleared cells remains already occupied.

Google API append function actually prepends new data with existing rows(cells) rather than using existing empty cells.

To make it more clear, assume that we have 100 rows with 12 columns. So total 1200 cells are occupied. While executing the code mentioned in problem statement, the clean up function will clean up those 1200 cells but does not delete it. So, Google API considers those cells are as still occupied. Now, while calling append function with a list of 50 objects, the append method will prepend 50 new rows by moving existing 100 rows to downside. So now, after executing my code, total occupied cells will be 1800.

Total Number of Old cells = 100 ROWs * 12 Columns  = 1200
Total Number of New cells = 50 ROWs * 12 Columns   = 600
---------------------------------------------------------
Total Number of cell after job execution = 1800

So, considering above example, frequent execution of above code will lead our spreadsheet to reach its max allowed cell limit 50,00,000 error.

Solutions :

We can solve above problem by two ways.

Remove the unused cells rather than clearing them using BatchUpdate and DeleteDimensionRequest.

Use Update method instead of Append which will use existing cells to insert the data. But note that you need to clear the spreadsheet before using Update method.

I would suggest to go with solution#2 update method as UpdateResponse provides better in depth statics. It provides total numbers of rows, columns and cells updated which can be used to tracking purpose.

Below is the code snippet for above two solutions :

Solution#1. Remove rows using BatchUpdate method and
DeleteDimentionRequest :

Here, we need to note one point. We can not delete all rows of spreadsheet. So we need to keep on static header in the spreadsheet. And while using DeleteDimentionRequest, the stat index starts with zero.

val dimensionRange : DimensionRange = new DimensionRange()
 dimensionRange.setDimension("ROWS")
 dimensionRange.setStartIndex(1)
 //dimensionRange.setEndIndex(1001)

 val deleteDimensionRequest : DeleteDimensionRequest = new DeleteDimensionRequest()
 deleteDimensionRequest.setRange(dimensionRange)

 val request : Request = new Request()
 request.setDeleteDimension(deleteDimensionRequest)

 val requests : util.List[Request] = new util.ArrayList[Request]()
 requests.add(request)

 val batchUpdateRequest : BatchUpdateSpreadsheetRequest =new  BatchUpdateSpreadsheetRequest()
 batchUpdateRequest.setRequests(requests)

 val batchUpdate: Sheets#Spreadsheets#BatchUpdate =  googleSpreadSheetService.getSheets()
    .spreadsheets()
    .batchUpdate(spreadSheetId, batchUpdateRequest)

 val batchUpdateResponse = batchUpdate.execute()

Solution#2. Clean up the cells and call update method to insert the
data :

//Code

private def clearAndInsertRowsToSpreadSheet(itemsToAppend : util.List[util.List[AnyRef]], range : String, spreadSheetId : String) :  UpdateValuesResponse = {

        clearSpreadSheet(range, spreadSheetId)
        updateSpreadSheetData(itemsToAppend,range, spreadSheetId)

      }

      private def updateSpreadSheetData(itemsToAppend : util.List[util.List[AnyRef]], range : String, spreadSheetId : String) ={

        val data : ValueRange = new ValueRange()
        data.setValues(itemsToAppend)

        val updateRequest: Sheets#Spreadsheets#Values#Update = googleSpreadSheetService.getSheets()
          .spreadsheets()
          .values()
          .update(spreadSheetId, range, data)

        updateRequest.setValueInputOption("USER_ENTERED")
        val updateValuesResponse: UpdateValuesResponse = updateRequest.execute()
        updateValuesResponse
      }
      private def clearSpreadSheet(range : String, spreadSheetId : String) : String = {

        val clearDataRequest = googleSpreadSheetService.
          getSheets().spreadsheets().
          values().clear(spreadSheetId,range, new ClearValuesRequest())

        val clearResponse = clearDataRequest.execute()

        clearResponse.getClearedRange
      }

Hope, above answer is sufficient enough to understand the nature of the problem and its possible solutions.


问:
How can I stop Python from recognizing string literals such as "\n" or "\b"?
I am using an API to convert LaTeX to PNG format. The latex strings that I am converting are written in latex, .tex, and so they use phrases such as '\n'.

On example of a string that I have is

```<code>query = "$\displaystyle \binom n r = \dfrac{n!}{r!(n-r)!}$"
</code>```

However, Python recognizes the \b in \binom and thus the string is recognized as having a line break, even though all I want it to do is just recognize the individual characters.

If at all possible, I would like to not have to modify the string itself, as the string too is taken from an API. So is there any way to ignore these string literals such as '\b' or '\n'?

答:
Use r"$\displaystyle \binom n r = \dfrac{n!}{r!(n-r)!}$". This is called a raw string. You can read more about it here

Generally, you can use raw strings in the following format:

Normal string:

```<code>'Hi\nHow are you?'
</code>```

output:

```<code>   Hi
   How are you?
</code>```

Raw string:

```<code>r'Hi\nHow are you?'
</code>```

output:

```<code>   Hi\nHow are you?
</code>```

Body:
I am using an API to convert LaTeX to PNG format. The latex strings that I am converting are written in latex, .tex, and so they use phrases such as '\n'.

On example of a string that I have is

query = "$\displaystyle \binom n r = \dfrac{n!}{r!(n-r)!}$"

However, Python recognizes the \b in \binom and thus the string is recognized as having a line break, even though all I want it to do is just recognize the individual characters.

If at all possible, I would like to not have to modify the string itself, as the string too is taken from an API. So is there any way to ignore these string literals such as '\b' or '\n'?

Body:
Use r"$\displaystyle \binom n r = \dfrac{n!}{r!(n-r)!}$". This is called a raw string. You can read more about it here

Generally, you can use raw strings in the following format:

Normal string:

'Hi\nHow are you?'

output:

   Hi
   How are you?

Raw string:

r'Hi\nHow are you?'

output:

   Hi\nHow are you?


问:
Cannot get docker image of gcr.io/automl-vision-ondevice/gcloud-container-1.14.0:latest
I got an error when I was trying to download the docker image from

gcr.io/automl-vision-ondevice/gcloud-container-1.14.0:latest

But I got an error of Access Denied. How can I solve this issue? Thanks a lot.

$ export CPU_DOCKER_GCR_PATH=gcr.io/automl-vision-ondevice/gcloud-container-1.14.0:latest
$ docker pull ${CPU_DOCKER_GCR_PATH}
Error response from daemon: Get https://gcr.io/v2/automl-vision-ondevice/gcloud-container-1.14.0/manifests/latest: denied: Permission denied: Consumer 'project:automl-vision-ondevice' has been suspended.```

答:
I had the same problem. Luckily i changed the language of the documentation to english and found another URL under which the Docker image is located. The Google team has probably moved the image.

Change

```<code>$ export CPU_DOCKER_GCR_PATH=gcr.io/automl-vision-ondevice/gcloud-container-1.14.0:latest
</code>```

to

```<code>$ export CPU_DOCKER_GCR_PATH=gcr.io/cloud-devrel-public-resources/gcloud-container-1.14.0:latest
</code>```

Body:
I had the same problem. Luckily i changed the language of the documentation to english and found another URL under which the Docker image is located. The Google team has probably moved the image.

Change

$ export CPU_DOCKER_GCR_PATH=gcr.io/automl-vision-ondevice/gcloud-container-1.14.0:latest

to

$ export CPU_DOCKER_GCR_PATH=gcr.io/cloud-devrel-public-resources/gcloud-container-1.14.0:latest