问:
Magento displays error after adding a product in the backend
I am running a Linux Server with Ubuntu 16.04 and PHP 7.0.15 with Magento 2.1.5.

When I go into the backend Products -> Add Product and add a product without any special settings the Website breaks in the frontend and displays the following error:

```<code>We're sorry, an error occured while generating this email.
</code>```

After checking the log files of magento I found these errors:

system.log

```<code>[2017-03-29 12:05:38] main.INFO: Cache file with merged layout: LAYOUT_adminhtml_STORE1_36f1b068ec7ccf4878f9284dd1137afd1 and handles catalog_product_prices: Please correct the XML data and try again.
</code>```

debug.log

```<code>[2017-03-29 12:37:02] main.DEBUG: cache_invalidate: {"method":"GET","url":"http://MYSHOPURL/","invalidateInfo":{"tags":["interception","CONFIG"],"mode":"matchingTag"},"is_exception":false} []
</code>```

Any ideas what might cause this issue? Adding a product to a webshop software shouldn't break it ^^

If you need further information or any other logs please let me know! I will provide them as soon as possible.

Thank you !

答:
After adding product from admin, run following command from CLI.</p>

```<code>php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento indexer:reindex
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
</code>```

Body:
I am running a Linux Server with Ubuntu 16.04 and PHP 7.0.15 with Magento 2.1.5.

When I go into the backend Products -> Add Product and add a product without any special settings the Website breaks in the frontend and displays the following error:

We're sorry, an error occured while generating this email.

After checking the log files of magento I found these errors:

system.log

[2017-03-29 12:05:38] main.INFO: Cache file with merged layout: LAYOUT_adminhtml_STORE1_36f1b068ec7ccf4878f9284dd1137afd1 and handles catalog_product_prices: Please correct the XML data and try again.

debug.log

[2017-03-29 12:37:02] main.DEBUG: cache_invalidate: {"method":"GET","url":"http://MYSHOPURL/","invalidateInfo":{"tags":["interception","CONFIG"],"mode":"matchingTag"},"is_exception":false} []

Any ideas what might cause this issue? Adding a product to a webshop software shouldn't break it ^^

If you need further information or any other logs please let me know! I will provide them as soon as possible.

Thank you !

Body:
After adding product from admin, run following command from CLI.

php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento indexer:reindex
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy


来源: stackexchange

问:
Converting pandas strings column to datetime with ocassionally missing hour part
I have duration string noted as '48m 37s' and sometimes as '1h 38m 29s' and a collection of string that holds this data in pandas dataframe's column

I'm trying to convert datatype of duration column to datetime as follows

```<code>pd.to_datetime(usg['duration'], format='%Hh %Mm %Ss')
</code>```

but failing with the following error

```<code>ValueError: time data '1h 38m 29s' does not match format '%Mm %Ss' (match)
</code>```

I understand that sometimes the hour part is missing in the list entries of duration column and wondering if there is a way to specify multiple formats if in case one fails to match other succeeds.

Doing so shall yield the output as below preserving the order of entries in the column

```<code>     00:39:40
     01:38:29
     07:39:40
</code>```

答:
You need:

```<code>usg = pd.DataFrame({'duration':['7h 39m 40s','15h 39m 40s','39m 40s']})
print (usg)

usg['duration'] = np.where(usg.duration.str.contains('h'),
                pd.to_datetime(usg['duration'], format='%Hh %Mm %Ss', errors='coerce'),
                pd.to_datetime(usg['duration'], format='%Mm %Ss',errors='coerce'))
print (usg)
             duration
0 1900-01-01 07:39:40
1 1900-01-01 15:39:40
2 1900-01-01 00:39:40
</code>```

Another solution:

```<code>usg['duration'] = pd.to_datetime(usg['duration'].where(usg.duration.str.contains('h'),
                                 '0h '+ usg['duration']),format='%Hh %Mm %Ss')
print (usg)
             duration
0 1900-01-01 07:39:40
1 1900-01-01 15:39:40
2 1900-01-01 00:39:40
</code>```

```<code>usg.loc[~usg.duration.str.contains('h'), 'duration'] = '0h '+ usg['duration']
usg['duration'] = pd.to_datetime(usg['duration'], format='%Hh %Mm %Ss')
print (usg)
             duration
0 1900-01-01 07:39:40
1 1900-01-01 15:39:40
2 1900-01-01 00:39:40
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have duration string noted as '48m 37s' and sometimes as '1h 38m 29s' and a collection of string that holds this data in pandas dataframe's column

I'm trying to convert datatype of duration column to datetime as follows

pd.to_datetime(usg['duration'], format='%Hh %Mm %Ss')

but failing with the following error

ValueError: time data '1h 38m 29s' does not match format '%Mm %Ss' (match)

I understand that sometimes the hour part is missing in the list entries of duration column and wondering if there is a way to specify multiple formats if in case one fails to match other succeeds.

Doing so shall yield the output as below preserving the order of entries in the column

     00:39:40
     01:38:29
     07:39:40

Body:
You need:

usg = pd.DataFrame({'duration':['7h 39m 40s','15h 39m 40s','39m 40s']})
print (usg)

usg['duration'] = np.where(usg.duration.str.contains('h'),
                pd.to_datetime(usg['duration'], format='%Hh %Mm %Ss', errors='coerce'),
                pd.to_datetime(usg['duration'], format='%Mm %Ss',errors='coerce'))
print (usg)
             duration
0 1900-01-01 07:39:40
1 1900-01-01 15:39:40
2 1900-01-01 00:39:40

Another solution:

usg['duration'] = pd.to_datetime(usg['duration'].where(usg.duration.str.contains('h'),
                                 '0h '+ usg['duration']),format='%Hh %Mm %Ss')
print (usg)
             duration
0 1900-01-01 07:39:40
1 1900-01-01 15:39:40
2 1900-01-01 00:39:40

usg.loc[~usg.duration.str.contains('h'), 'duration'] = '0h '+ usg['duration']
usg['duration'] = pd.to_datetime(usg['duration'], format='%Hh %Mm %Ss')
print (usg)
             duration
0 1900-01-01 07:39:40
1 1900-01-01 15:39:40
2 1900-01-01 00:39:40


问:
How to hide save button on popup form?
How to hide save button on popup form?*

The form view opened by action in python code.
I already tried some recommended solution, but their doesn't work.

Some portal/forum said this flags will be solve it. But it don't, what even more, it has not any effect to behavior. (anyway, where can I read from flags? I can't find any useful description about it.)

```<code>@api.multi
def button(self):
    viewId = self.env.ref('Model.model').id
    return {
        'name': _('Button action'),
        'view_type': 'form',
        'view_mode': 'form',
        'view_id': viewId,
        'res_model': 'model',
        'type': 'ir.actions.act_window',
        'res_id': self.id,
        'target': 'new',
        'flags': {'form': {'action_buttons': False}}
    }
</code>```

The most place said this is the right way, but it does not work...

```<code><record id="model" model="ir.ui.view">
        <field name="name">model</field>
        <field name="model">model</field>
        <field name="arch" type="xml">
            <form string="Button form" edit="false" create="false" delete="false">
                <group>
                    <field name="test" />
                    <button name="myButtonFunc" string="Demo button" icon="fa-plus" type="object"/>
                </group>
            </form>
        </field>
    </record>
</code>```

Any idea? Or experience with it?

答:
To hide default button of wizard you need to replace footer of wizard. see following example of view.xml

```<code><record id="test_models_wizard" model="ir.ui.view">
        <field name="name">test.models.form</field>
        <field name="model">test.models</field>
        <field name="arch" type="xml">
            <form string="Test Wizard">
                <group>
                    <group>
                        <field name="test_field_1"/>
                        <field name="test_field_2"/>
                    </group>
                </group>
                <footer>
                    <button name="your_test_method" string="My Button" type="object" class="btn-primary"/>
                    <button string="Cancel" class="btn-default" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>
</code>```

add your desired button in between footer tag!

Title: How to hide save button on popup form?

Body:
How to hide save button on popup form?*

The form view opened by action in python code.
I already tried some recommended solution, but their doesn't work.

Some portal/forum said this flags will be solve it. But it don't, what even more, it has not any effect to behavior. (anyway, where can I read from flags? I can't find any useful description about it.)

@api.multi
def button(self):
    viewId = self.env.ref('Model.model').id
    return {
        'name': _('Button action'),
        'view_type': 'form',
        'view_mode': 'form',
        'view_id': viewId,
        'res_model': 'model',
        'type': 'ir.actions.act_window',
        'res_id': self.id,
        'target': 'new',
        'flags': {'form': {'action_buttons': False}}
    }

The most place said this is the right way, but it does not work...

<record id="model" model="ir.ui.view">
        <field name="name">model</field>
        <field name="model">model</field>
        <field name="arch" type="xml">
            <form string="Button form" edit="false" create="false" delete="false">
                <group>
                    <field name="test" />
                    <button name="myButtonFunc" string="Demo button" icon="fa-plus" type="object"/>
                </group>
            </form>
        </field>
    </record>

Any idea? Or experience with it?

Body:
To hide default button of wizard you need to replace footer of wizard. see following example of view.xml

<record id="test_models_wizard" model="ir.ui.view">
        <field name="name">test.models.form</field>
        <field name="model">test.models</field>
        <field name="arch" type="xml">
            <form string="Test Wizard">
                <group>
                    <group>
                        <field name="test_field_1"/>
                        <field name="test_field_2"/>
                    </group>
                </group>
                <footer>
                    <button name="your_test_method" string="My Button" type="object" class="btn-primary"/>
                    <button string="Cancel" class="btn-default" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>

add your desired button in between footer tag!


问:
C# List<T> with standard values
I have a problem with List<T> and really need some help...

Example of code:

```<code>List<T> myFirstList = new List<T>();
myFirstList.Add(new T());
myFirstList.Add(new T());

List<T> mySecondList = new List<T>();
mySecondList.Add(new T());
mySecondList.Add(new T());

foreach (T myT in mySecondList)
{
   List<T> myThirdList = myFirstList;
   myThirdList.Add(new T());
}
</code>```

In the second loop from foreach (T myT in mySecondList) my variable myFirstList contains the value which was added in the first loop.

The actual question is:

How can I use myFirstList in every loop with just the two added Items?

I want to add values to myThirdList depending on the items in List two.
But every List hast standard values which should be contained every time.

Thanks for your help guys!

答: I think you just need to replace mycontrol.myList = myFirstList; this piece of code with that mycontrol.myList = new List<T>(myFirstList);

Title: C# List<T> with standard values

Body:
I have a problem with List<T> and really need some help...

Example of code:

List<T> myFirstList = new List<T>();
myFirstList.Add(new T());
myFirstList.Add(new T());

List<T> mySecondList = new List<T>();
mySecondList.Add(new T());
mySecondList.Add(new T());

foreach (T myT in mySecondList)
{
   List<T> myThirdList = myFirstList;
   myThirdList.Add(new T());
}

In the second loop from foreach (T myT in mySecondList) my variable myFirstList contains the value which was added in the first loop.

The actual question is:

How can I use myFirstList in every loop with just the two added Items?

I want to add values to myThirdList depending on the items in List two.
But every List hast standard values which should be contained every time.

Thanks for your help guys!


问:
Unable to deploy javalite on heroku
I have my procfile:

```<code>web: java -cp target/classes:target/dependency/* com.888.888.Application
</code>```

Connection details:

```<code>Base.open("com.mysql.jdbc.Driver", "jdbc:mysql://o3iyl77734btg.cbetxkdyhwsb.us-east-1.rds.amazonaws.com/lt9vgms3ueidoa", "nt2qniqiuhl67", "k2dijxt3xcf9o");
</code>```

POM:

```<code>    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <configuration>
            <mainClass>com.soul.seeker.Application</mainClass>
            <arguments>
            </arguments>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.0</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <encoding>UTF-8</encoding>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.4</version>
        <executions>
            <execution>
                <id>copy-dependencies</id>
                <phase>package</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

    <plugin>
        <groupId>org.javalite</groupId>
        <artifactId>activejdbc-instrumentation</artifactId>
        <version>${activejdbc.version}</version>
        <executions>
            <execution>
                <phase>process-classes</phase>
                <goals>
                    <goal>instrument</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</plugins>
</code>```

Heroku logs --tail:

```<code>2017-03-31T08:53:35.035665+00:00 app[api]: Starting process with command `java console` by user .k999@gmail.com
2017-03-31T08:59:37.504808+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-31T08:59:40.018376+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=8577 -jar target/*.jar`
2017-03-31T08:59:42.220679+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-03-31T08:59:42.224224+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2017-03-31T08:59:42.338167+00:00 app[web.1]: no main manifest attribute, in target/seeker_Java_Spark-1.0-SNAPSHOT.jar
2017-03-31T08:59:42.441817+00:00 heroku[web.1]: Process exited with status 1
2017-03-31T08:59:42.456928+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-31T09:14:41.000000+00:00 app[api]: Build started by user .k999@gmail.com
2017-03-31T09:14:59.771140+00:00 app[api]: Release v13 created by user .k999@gmail.com
2017-03-31T09:14:59.771140+00:00 app[api]: Deploy db9bb50 by user .k999@gmail.com
2017-03-31T09:14:41.000000+00:00 app[api]: Build succeeded
2017-03-31T09:15:00.343156+00:00 app[api]: Release v13 created by user .k999@gmail.com
2017-03-31T09:15:00.464317+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-31T09:15:03.852306+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=30122 -jar target/*.jar`
2017-03-31T09:15:06.100736+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-03-31T09:15:06.106289+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2017-03-31T09:15:06.253188+00:00 app[web.1]: no main manifest attribute, in target/seeker_Java_Spark-1.0-SNAPSHOT.jar
2017-03-31T09:15:06.338012+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-31T09:15:06.339425+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-31T09:15:06.329112+00:00 heroku[web.1]: Process exited with status 1
2017-03-31T09:15:09.463349+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=49453 -jar target/*.jar`
2017-03-31T09:15:12.032819+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-03-31T09:15:12.037084+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2017-03-31T09:15:12.129561+00:00 app[web.1]: no main manifest attribute, in target/seeker_Java_Spark-1.0-SNAPSHOT.jar
2017-03-31T09:15:12.210338+00:00 heroku[web.1]: Process exited with status 1
2017-03-31T09:15:12.220183+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-31T09:15:55.312322+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="//getRecent" host=seeker-java-spark.herokuapp.com request_id=7df2a77a-8a78-43a3-874b-8ecbf394653d fwd="54.224.180.207" dyno= connect= service= status=503 bytes= protocol=https
2017-03-31T09:16:01.138972+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="//data_on_page_load?limit=4&offset=0" host=seeker-java-spark.herokuapp.com request_id=b8ff2299-bd1d-435b-bf84-e358ca9d44f6 fwd="54.224.180.207" dyno= connect= service= status=503 bytes= protoc
l=https
2017-03-31T09:17:06.000000+00:00 app[api]: Build started by user .k999@gmail.com
2017-03-31T09:17:23.683130+00:00 app[api]: Deploy 4968a29 by user .k999@gmail.com
2017-03-31T09:17:23.683130+00:00 app[api]: Release v14 created by user .k999@gmail.com
2017-03-31T09:17:24.061692+00:00 app[api]: Release v14 created by user .k999@gmail.com
2017-03-31T09:17:06.000000+00:00 app[api]: Build succeeded
2017-03-31T09:17:24.717686+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-31T09:17:27.559351+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=38303 -jar target/*.jar`
2017-03-31T09:17:29.517107+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-03-31T09:17:29.520526+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2017-03-31T09:17:29.605348+00:00 app[web.1]: no main manifest attribute, in target/seeker_Java_Spark-1.0-SNAPSHOT.jar
2017-03-31T09:17:29.727476+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-31T09:17:29.720959+00:00 heroku[web.1]: Process exited with status 1
^CTerminate batch job (Y/N)? y
</code>```

heroku java console command: Running this command shows main class not found but I have declared the procfile properly, I don't know why it is not working.

```<code>E:\WORKSPACE\NETBEANS_WORKSPACE\seeker_Java_Spark>heroku run java console
Running java console on seeker-java-spark... up, run.4407 (Free)
Error: Could not find or load main class console
</code>```

答:
Heroku is trying to run your app with the command java $JAVA_OPTS -Dserver.port=30122 -jar target/*.jar.

Check that your Procfile is checked into Git by running git ls-files.

I don't know what heroku run java console is supposed to be. That's not a command I've ever seen.

Title: Unable to deploy javalite on heroku

Body:
I have my procfile:

web: java -cp target/classes:target/dependency/* com.888.888.Application

Connection details:

Base.open("com.mysql.jdbc.Driver", "jdbc:mysql://o3iyl77734btg.cbetxkdyhwsb.us-east-1.rds.amazonaws.com/lt9vgms3ueidoa", "nt2qniqiuhl67", "k2dijxt3xcf9o");

POM:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <configuration>
            <mainClass>com.soul.seeker.Application</mainClass>
            <arguments>
            </arguments>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.0</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <encoding>UTF-8</encoding>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.4</version>
        <executions>
            <execution>
                <id>copy-dependencies</id>
                <phase>package</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

    <plugin>
        <groupId>org.javalite</groupId>
        <artifactId>activejdbc-instrumentation</artifactId>
        <version>${activejdbc.version}</version>
        <executions>
            <execution>
                <phase>process-classes</phase>
                <goals>
                    <goal>instrument</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</plugins>

Heroku logs --tail:

2017-03-31T08:53:35.035665+00:00 app[api]: Starting process with command `java console` by user .k999@gmail.com
2017-03-31T08:59:37.504808+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-31T08:59:40.018376+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=8577 -jar target/*.jar`
2017-03-31T08:59:42.220679+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-03-31T08:59:42.224224+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2017-03-31T08:59:42.338167+00:00 app[web.1]: no main manifest attribute, in target/seeker_Java_Spark-1.0-SNAPSHOT.jar
2017-03-31T08:59:42.441817+00:00 heroku[web.1]: Process exited with status 1
2017-03-31T08:59:42.456928+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-31T09:14:41.000000+00:00 app[api]: Build started by user .k999@gmail.com
2017-03-31T09:14:59.771140+00:00 app[api]: Release v13 created by user .k999@gmail.com
2017-03-31T09:14:59.771140+00:00 app[api]: Deploy db9bb50 by user .k999@gmail.com
2017-03-31T09:14:41.000000+00:00 app[api]: Build succeeded
2017-03-31T09:15:00.343156+00:00 app[api]: Release v13 created by user .k999@gmail.com
2017-03-31T09:15:00.464317+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-31T09:15:03.852306+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=30122 -jar target/*.jar`
2017-03-31T09:15:06.100736+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-03-31T09:15:06.106289+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2017-03-31T09:15:06.253188+00:00 app[web.1]: no main manifest attribute, in target/seeker_Java_Spark-1.0-SNAPSHOT.jar
2017-03-31T09:15:06.338012+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-31T09:15:06.339425+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-31T09:15:06.329112+00:00 heroku[web.1]: Process exited with status 1
2017-03-31T09:15:09.463349+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=49453 -jar target/*.jar`
2017-03-31T09:15:12.032819+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-03-31T09:15:12.037084+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2017-03-31T09:15:12.129561+00:00 app[web.1]: no main manifest attribute, in target/seeker_Java_Spark-1.0-SNAPSHOT.jar
2017-03-31T09:15:12.210338+00:00 heroku[web.1]: Process exited with status 1
2017-03-31T09:15:12.220183+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-31T09:15:55.312322+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="//getRecent" host=seeker-java-spark.herokuapp.com request_id=7df2a77a-8a78-43a3-874b-8ecbf394653d fwd="54.224.180.207" dyno= connect= service= status=503 bytes= protocol=https
2017-03-31T09:16:01.138972+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="//data_on_page_load?limit=4&offset=0" host=seeker-java-spark.herokuapp.com request_id=b8ff2299-bd1d-435b-bf84-e358ca9d44f6 fwd="54.224.180.207" dyno= connect= service= status=503 bytes= protoc
l=https
2017-03-31T09:17:06.000000+00:00 app[api]: Build started by user .k999@gmail.com
2017-03-31T09:17:23.683130+00:00 app[api]: Deploy 4968a29 by user .k999@gmail.com
2017-03-31T09:17:23.683130+00:00 app[api]: Release v14 created by user .k999@gmail.com
2017-03-31T09:17:24.061692+00:00 app[api]: Release v14 created by user .k999@gmail.com
2017-03-31T09:17:06.000000+00:00 app[api]: Build succeeded
2017-03-31T09:17:24.717686+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-31T09:17:27.559351+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -Dserver.port=38303 -jar target/*.jar`
2017-03-31T09:17:29.517107+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-03-31T09:17:29.520526+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2017-03-31T09:17:29.605348+00:00 app[web.1]: no main manifest attribute, in target/seeker_Java_Spark-1.0-SNAPSHOT.jar
2017-03-31T09:17:29.727476+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-31T09:17:29.720959+00:00 heroku[web.1]: Process exited with status 1
^CTerminate batch job (Y/N)? y

heroku java console command: Running this command shows main class not found but I have declared the procfile properly, I don't know why it is not working.

E:\WORKSPACE\NETBEANS_WORKSPACE\seeker_Java_Spark>heroku run java console
Running java console on seeker-java-spark... up, run.4407 (Free)
Error: Could not find or load main class console


问:
How to deal with Error: 0 (non-NA) cases plm package?
I know this has been asked, and I've looked at at least 10 threads on this topic, but I still can't understand it. I'm using the plm package to estimate a random effects model on some panel data. I have a model that I have specified, but when I insert an additional variable that does not contain any NA's, I get the following error message.

```<code>Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
  0 (non-NA) cases
</code>```

I have pared it down as much as possible to the following:

```<code>plm(dependent ~ varA + varB + varC + varD, data=mydata,
    model="random", index=c("Name", "Month"), na.action=na.exclude)
</code>```

Without varA the model works fine. In place of VarA, I can insert other variables that I have at my disposal, and some will work while others will not.

My data can be obtained here.

I have tried using na.omit(mydata), which works sometimes but not reliably.

Any insight would be appreciated.

答:
This happens due to the specifics of your data and the model and this is, thus, rather a statistical question:

The between regression used in the default random effects method of Swamy-Arora (random.method = "swar") is not estimable for this model (4 individuals (Name in your data) while at the same time trying to estimate 4 covariates and intercept), thus the model is not estimable with the default RE estimator. You can try a different random effects method, e.g., set random.method to  "amemiya" or "walhus".

```<code>plm(dependent ~ varA + varB + varC + varD, data=mydata,
    model="random", index=c("Name", "Month"), random.method = "amemiya")
</code>```

(Yes, the error message of plm could be improved here.)

ContentLicense: CC BY-SA 4.0

Body:
I know this has been asked, and I've looked at at least 10 threads on this topic, but I still can't understand it. I'm using the plm package to estimate a random effects model on some panel data. I have a model that I have specified, but when I insert an additional variable that does not contain any NA's, I get the following error message.

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
  0 (non-NA) cases

I have pared it down as much as possible to the following:

plm(dependent ~ varA + varB + varC + varD, data=mydata,
    model="random", index=c("Name", "Month"), na.action=na.exclude)

Without varA the model works fine. In place of VarA, I can insert other variables that I have at my disposal, and some will work while others will not.

My data can be obtained here.

I have tried using na.omit(mydata), which works sometimes but not reliably.

Any insight would be appreciated.

Body:
This happens due to the specifics of your data and the model and this is, thus, rather a statistical question:

The between regression used in the default random effects method of Swamy-Arora (random.method = "swar") is not estimable for this model (4 individuals (Name in your data) while at the same time trying to estimate 4 covariates and intercept), thus the model is not estimable with the default RE estimator. You can try a different random effects method, e.g., set random.method to  "amemiya" or "walhus".

plm(dependent ~ varA + varB + varC + varD, data=mydata,
    model="random", index=c("Name", "Month"), random.method = "amemiya")

(Yes, the error message of plm could be improved here.)


问:
Storing column value types to an array
I want to refactor my code. I create a fix column so I always write "table.columns.Add(name, dataType) ...."´.

I want to keep it with a loop and store all these column informations into an two dimensional array.

The first value of this array is the column name, the second is the type of the column.

How can I store this type?

My current code:

```<code> object[,] tableColumns = { // Contains all column names + column dataType
            {"Predecessors", List<Process>},
            {"Successors", List<Process>},
            {"ProcessId", int},
            {"ProcessName", string},
            {"ProcessDuration", int},
            {"FAZ", int},
            {"SAZ", int},
            {"FEZ", int},
            {"SEZ", int},
            {"EntireBuffer", int},
            {"FreeBuffer", int},
            {"IsCritical", bool},
            {"IsStartProcess", bool},
            {"IsEndProcess", bool}
        };

        for (int i = 0; i < tableColumns.Length; i++) // create all these columns
        {
            ProcessTable.Columns.Add(tableColumns[i, 1].ToString(), tableColumns[i, 2] as Type);
        }
</code>```

So as you can see, the only thing missing here is the storing of the datatype in its correct way.

答:
For storing the actual type of an object, C# uses the Type class. You can get the respective Type object for any class, struct, etc. via the typeof(*classname*) operator.

If you want to get the Type object from an actual object, you can use the object's GetType() method.

Title: Storing column value types to an array

Body:
I want to refactor my code. I create a fix column so I always write "table.columns.Add(name, dataType) ...."´.

I want to keep it with a loop and store all these column informations into an two dimensional array.

The first value of this array is the column name, the second is the type of the column.

How can I store this type?

My current code:

 object[,] tableColumns = { // Contains all column names + column dataType
            {"Predecessors", List<Process>},
            {"Successors", List<Process>},
            {"ProcessId", int},
            {"ProcessName", string},
            {"ProcessDuration", int},
            {"FAZ", int},
            {"SAZ", int},
            {"FEZ", int},
            {"SEZ", int},
            {"EntireBuffer", int},
            {"FreeBuffer", int},
            {"IsCritical", bool},
            {"IsStartProcess", bool},
            {"IsEndProcess", bool}
        };

        for (int i = 0; i < tableColumns.Length; i++) // create all these columns
        {
            ProcessTable.Columns.Add(tableColumns[i, 1].ToString(), tableColumns[i, 2] as Type);
        }

So as you can see, the only thing missing here is the storing of the datatype in its correct way.


问:
Ansible win_msi installation fails
I'm trying to make this work for a while now, running out of ideas.

I got an .msi file which I want to install on a Win7 client using Ansible.
The playbook runs through but in the end the program won't be installed.

I also cannot make it work with the "raw" command which works with .exe files but doesn't seem to work with my .msi file.

Specs:

```<code>ansible --version
ansible 2.2.0.0
</code>```

OS i'm trying to install on is Win7 Proffesional.

Powershell version is:

```<code>$psversiontable

Name         Value
----         -----
PSVersion    5.0.10589.117
</code>```

Playbook looks like this:

```<code> - name: Install zarafaclient version 7.2
     win_msi:
       path: 'C:\\temp_files\\z7.2.msi'
       state: present
</code>```

I also tried different syntaxes, so the playbook shouldn't be the issue.

Here is what I get from ansible if I run it with -vvvv

```<code>TASK [Install zarafaclient version 7.2] ****************************************
task path: /home/pfl/ansible/Provisioning-Windows-with-Ansible/playbook.yml:10
Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/windows/win_msi.ps1
<192.168.37.144> ESTABLISH WINRM CONNECTION FOR USER: fdsadm on PORT 5986 TO 192.168.37.144
<192.168.37.144> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1481285937.55-262476455300775").FullName | Write-Host -Separator '';
<192.168.37.144> PUT "/tmp/tmp0l4Ayh" TO "C:\Users\fdsadm\AppData\Local\Temp\ansible-tmp-1481285937.55-262476455300775\win_msi.ps1"
<192.168.37.144> EXEC Set-StrictMode -Version Latest
Try
{
& 'C:\Users\fdsadm\AppData\Local\Temp\ansible-tmp-1481285937.55-262476455300775\win_msi.ps1'
}
Catch
{
$_obj = @{ failed = $true }
If ($_.Exception.GetType)
{
$_obj.Add('msg', $_.Exception.Message)
}
Else
{
$_obj.Add('msg', $_.ToString())
}
If ($_.InvocationInfo.PositionMessage)
{
$_obj.Add('exception', $_.InvocationInfo.PositionMessage)
}
ElseIf ($_.ScriptStackTrace)
{
$_obj.Add('exception', $_.ScriptStackTrace)
}
Try
{
$_obj.Add('error_record', ($_ | ConvertTo-Json | ConvertFrom-Json))
}
Catch
{
}
Echo $_obj | ConvertTo-Json -Compress -Depth 99
Exit 1
}
Finally { Remove-Item "C:\Users\fdsadm\AppData\Local\Temp\ansible-tmp-1481285937.55-262476455300775" -Force -Recurse -ErrorAction SilentlyContinue }
changed: [192.168.37.144] => {
    "changed": true,
    "invocation": {
        "module_name": "win_msi"
    },
    "log": ""
}

PLAY RECAP *********************************************************************
192.168.37.144             : ok=2    changed=1    unreachable=0    failed=0
</code>```

答:
it looks like an issue with the spacing

I think it you should look like

```<code>- name: Install zarafaclient version 7.2
  win_msi:
    path: 'C:\\temp_files\\z7.2.msi'
    state: present
</code>```

Title: Ansible win_msi installation fails

Body:
I'm trying to make this work for a while now, running out of ideas.

I got an .msi file which I want to install on a Win7 client using Ansible.
The playbook runs through but in the end the program won't be installed.

I also cannot make it work with the "raw" command which works with .exe files but doesn't seem to work with my .msi file.

Specs:

ansible --version
ansible 2.2.0.0

OS i'm trying to install on is Win7 Proffesional.

Powershell version is:

$psversiontable

Name         Value
----         -----
PSVersion    5.0.10589.117

Playbook looks like this:

 - name: Install zarafaclient version 7.2
     win_msi:
       path: 'C:\\temp_files\\z7.2.msi'
       state: present

I also tried different syntaxes, so the playbook shouldn't be the issue.

Here is what I get from ansible if I run it with -vvvv

TASK [Install zarafaclient version 7.2] ****************************************
task path: /home/pfl/ansible/Provisioning-Windows-with-Ansible/playbook.yml:10
Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/windows/win_msi.ps1
<192.168.37.144> ESTABLISH WINRM CONNECTION FOR USER: fdsadm on PORT 5986 TO 192.168.37.144
<192.168.37.144> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1481285937.55-262476455300775").FullName | Write-Host -Separator '';
<192.168.37.144> PUT "/tmp/tmp0l4Ayh" TO "C:\Users\fdsadm\AppData\Local\Temp\ansible-tmp-1481285937.55-262476455300775\win_msi.ps1"
<192.168.37.144> EXEC Set-StrictMode -Version Latest
Try
{
& 'C:\Users\fdsadm\AppData\Local\Temp\ansible-tmp-1481285937.55-262476455300775\win_msi.ps1'
}
Catch
{
$_obj = @{ failed = $true }
If ($_.Exception.GetType)
{
$_obj.Add('msg', $_.Exception.Message)
}
Else
{
$_obj.Add('msg', $_.ToString())
}
If ($_.InvocationInfo.PositionMessage)
{
$_obj.Add('exception', $_.InvocationInfo.PositionMessage)
}
ElseIf ($_.ScriptStackTrace)
{
$_obj.Add('exception', $_.ScriptStackTrace)
}
Try
{
$_obj.Add('error_record', ($_ | ConvertTo-Json | ConvertFrom-Json))
}
Catch
{
}
Echo $_obj | ConvertTo-Json -Compress -Depth 99
Exit 1
}
Finally { Remove-Item "C:\Users\fdsadm\AppData\Local\Temp\ansible-tmp-1481285937.55-262476455300775" -Force -Recurse -ErrorAction SilentlyContinue }
changed: [192.168.37.144] => {
    "changed": true,
    "invocation": {
        "module_name": "win_msi"
    },
    "log": ""
}

PLAY RECAP *********************************************************************
192.168.37.144             : ok=2    changed=1    unreachable=0    failed=0

Body:
it looks like an issue with the spacing

I think it you should look like

- name: Install zarafaclient version 7.2
  win_msi:
    path: 'C:\\temp_files\\z7.2.msi'
    state: present


问:
How to exclude a jar from gradle
I try to exclude a jar from gradle build but how to do that for my project part I am not clear.Below are the dependencies I have to exclude only geronimo-javamail_1.4_spec/1.7.1 jar because which gives error when I try to send mail.Please give your guidance to solve this.

```<code>    dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-batch")
    //compile("org.springframework.boot:spring-boot-devtools")
    compile('org.apache.commons':'commons-lang3':'3.5'){
                exclude module: 'geronimo'
    }
    compile group: 'org.apache.cxf', name: 'cxf-spring-boot-starter-jaxws', version: '3.1.10'
    compile group: 'org.apache.cxf', name: 'cxf-rt-ws-security', version: '3.1.10'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}
</code>```

update:exclusion is not working

答:
First of all, there is an issue with this statement:

```<code>compile('org.apache.commons':'commons-lang3':'3.5')
</code>```

If you want to use the colon notation for a dependency, it has to be all in one String, like so:

```<code>compile('org.apache.commons:commons-lang3:3.5')
</code>```

Also, you should probably use the full module name: module: 'geronimo-javamail_1.4_spec'.

Finally, geronimo-javamail_1.4_spec is a transitive dependency of more than one dependency in this setup, so you should exclude it everywhere where necessary one by one, or exclude it altogether like so:

```<code>configurations {
    all*.exclude module: 'geronimo-javamail_1.4_spec'
}
</code>```

This should be added in your build.gradle file at the same level as the dependencies{} section, not within it, so the final code would look like this:

```<code>configurations {
    all*.exclude module: 'geronimo-javamail_1.4_spec'
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-batch")
    //compile("org.springframework.boot:spring-boot-devtools")
    compile('org.apache.commons:commons-lang3:3.5')
    compile group: 'org.apache.cxf', name: 'cxf-spring-boot-starter-jaxws', version: '3.1.10'
    compile group: 'org.apache.cxf', name: 'cxf-rt-ws-security', version: '3.1.10'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}
</code>```

Title: How to exclude a jar from gradle

Body:
I try to exclude a jar from gradle build but how to do that for my project part I am not clear.Below are the dependencies I have to exclude only geronimo-javamail_1.4_spec/1.7.1 jar because which gives error when I try to send mail.Please give your guidance to solve this.

    dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-batch")
    //compile("org.springframework.boot:spring-boot-devtools")
    compile('org.apache.commons':'commons-lang3':'3.5'){
                exclude module: 'geronimo'
    }
    compile group: 'org.apache.cxf', name: 'cxf-spring-boot-starter-jaxws', version: '3.1.10'
    compile group: 'org.apache.cxf', name: 'cxf-rt-ws-security', version: '3.1.10'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

update:exclusion is not working

Body:
First of all, there is an issue with this statement:

compile('org.apache.commons':'commons-lang3':'3.5')

If you want to use the colon notation for a dependency, it has to be all in one String, like so:

compile('org.apache.commons:commons-lang3:3.5')

Also, you should probably use the full module name: module: 'geronimo-javamail_1.4_spec'.

Finally, geronimo-javamail_1.4_spec is a transitive dependency of more than one dependency in this setup, so you should exclude it everywhere where necessary one by one, or exclude it altogether like so:

configurations {
    all*.exclude module: 'geronimo-javamail_1.4_spec'
}

This should be added in your build.gradle file at the same level as the dependencies{} section, not within it, so the final code would look like this:

configurations {
    all*.exclude module: 'geronimo-javamail_1.4_spec'
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-batch")
    //compile("org.springframework.boot:spring-boot-devtools")
    compile('org.apache.commons:commons-lang3:3.5')
    compile group: 'org.apache.cxf', name: 'cxf-spring-boot-starter-jaxws', version: '3.1.10'
    compile group: 'org.apache.cxf', name: 'cxf-rt-ws-security', version: '3.1.10'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}


问:
SSRS Lock rectangle in Top of report when scrolling
I know there is a solution to keep a tablix header in top of report when scrolling, but do you how how to do this with a rectangle which is outside of tablix?</p>

答: You can't. You can either use the tablix header (which you're aware of) or the page header.</p>


问:
Elegant way to organize and user ngResource
My app need interact with various tables and views. I'm new in angular and I can't think a elegant way to organizer the services in my app of ngResource. Any sugestions?
I think that my controller declaration is very full of services.

/app/app.resource.js

```<code>angular.module('totalizacao').factory('ldap', ['$resource', function($resource) {
    return $resource('api.php/ldap/:usuario/:senha', {usuario: '@usuario', senha:''}, {
        login: {
            isArray: false,
            method: 'POST'
        }
    });
}]);

angular.module('totalizacao').factory('tb_agendamentos_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_agendamentos_llpp/:ID', {'ID' :''});
}]);

angular.module('totalizacao').factory('tb_atendimentos_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_atendimentos_llpp/:ID', {'ID' :''});
}]);

angular.module('totalizacao').factory('tb_grupo_oferta_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_grupo_oferta_llpp/', {});
}]);

angular.module('totalizacao').factory('tb_mvmt_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_mvmt_llpp/', {});
}]);

ngular.module('totalizacao').factory('tb_ofertas_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_ofertas_llpp/', {});
}]);

angular.module('totalizacao').factory('tb_score_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_score_llpp');
}]);

angular.module('totalizacao').factory('tb_vendas_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_vendas_llpp/:ID_LNHA', {ID_LNHA: ''});
}]);

angular.module('totalizacao').factory('tb_vendas_servicos_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_vendas_servicos_llpp/:ID', {'ID' :''});
}]);

angular.module('totalizacao').factory('vw_agendamentos_llpp', ['$resource', function($resource) {
    return $resource('api.php/vw_agendamentos_llpp/');
}]);

angular.module('totalizacao').factory('vw_arvore_ofertas_llpp', ['$resource', function($resource) {
    return $resource('api.php/vw_arvore_ofertas_llpp/', {});
}]);

.
.
.
</code>```

My controller

```<code>angular.module('totalizacao').controller('arvoreOferta',
            ['$routeParams','$rootScope','$scope','vw_vendas_llpp','vw_arvore_ofertas_llpp'
            ,'tb_grupo_oferta_llpp', 'tb_ofertas_llpp', 'tb_agendamentos_llpp','tb_atendimentos_llpp'
            ,'tb_vendas_servicos_llpp', 'vw_vendas_servicos_llpp'
             ,'vw_agendamentos_llpp','tb_score_llpp','vw_ofertas_totais','dateFilter'
        , function($routeParams, $rootScope, $scope, vw_vendas_llpp, vw_arvore_ofertas_llpp
                  ,tb_grupo_oferta_llpp, tb_ofertas_llpp, tb_agendamentos_llpp
                  , tb_atendimentos_llpp, tb_vendas_servicos_llpp, vw_vendas_servicos_llpp
                  , vw_agendamentos_llpp, tb_score_llpp, vw_ofertas_totais, dateFilter){

        var self = this;
.
.
.
</code>```

答:
I always prefer using $http since i can have more control on making it generic, infact $resource internally uses $http. But since you have used $resource i am making an effort to do it $resource way.

Please forgive my syntaxes and compilation errors, as i am directly typing it here.
    what you can do is create a common service or factory say apiService or apiFactory and then pass the required parameters, http method and action etc..
    I wont go into coding details, as its upto you how generalise and what you pass, but something like this:

```<code>//First create a constant object:

angular.module('totalizacao').constant('apiConstants', {
    totalizacao: 'api.php/tb_mvmt_llpp/',
    totalizacao1: 'api.php/tb_mvmt_llpp1/'
});

// Generalise your factory as you want this is to give you an idea.
angular.module('totalizacao').factory('apiFactory', ['$resource','apiConstants', function($resource) {
    var apiFactory = {};
   /* Http Method  = GET, PUT, POST;
       MethodName = { 'get':    {method:'GET'},
    'save':   {method:'POST'},
    'query':  {method:'GET', isArray:true},
    'remove': {method:'DELETE'},
    'delete': {method:'DELETE'} };*/
    apiFactory.executeApi = function(url, methodName, httpMethod, params){
        var paramNames = Object.keys(params);// getKeys
        //construct url
        // you can put a for loop here to make it more generic for multiple params
        //params[paramNames[i]] will get you the value, here i just have one
        var completeUrl = url + ':' + paramNames[0]; // api.php/tb_mvmt_llpp/:paramName1

        var resources = $resource(completeUrl, null, {
                          apiMethod: {
                              method: httpMethod
                          }
                    });
       //you can return the promise or return the value
      resources[methodName](params) ///resources['get'](params)
            .$promise.then(function(user) {
          // do something

        });
        return // resources[methodName](params).$promise or some variable after

    };

    return apiFactory;
});
</code>```

in your controller, inject apiFactory, apiConstants and do the following

```<code>    var params = {
       paramName1 : 'paramValue1'
    };
    apiFactory.executeApi(apiConstants.totalizacao, 'get', params).then(success,error);

    function success(){};
    function error(){};
</code>```

Body:
My app need interact with various tables and views. I'm new in angular and I can't think a elegant way to organizer the services in my app of ngResource. Any sugestions?
I think that my controller declaration is very full of services.

/app/app.resource.js

angular.module('totalizacao').factory('ldap', ['$resource', function($resource) {
    return $resource('api.php/ldap/:usuario/:senha', {usuario: '@usuario', senha:''}, {
        login: {
            isArray: false,
            method: 'POST'
        }
    });
}]);

angular.module('totalizacao').factory('tb_agendamentos_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_agendamentos_llpp/:ID', {'ID' :''});
}]);

angular.module('totalizacao').factory('tb_atendimentos_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_atendimentos_llpp/:ID', {'ID' :''});
}]);

angular.module('totalizacao').factory('tb_grupo_oferta_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_grupo_oferta_llpp/', {});
}]);

angular.module('totalizacao').factory('tb_mvmt_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_mvmt_llpp/', {});
}]);

ngular.module('totalizacao').factory('tb_ofertas_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_ofertas_llpp/', {});
}]);

angular.module('totalizacao').factory('tb_score_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_score_llpp');
}]);

angular.module('totalizacao').factory('tb_vendas_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_vendas_llpp/:ID_LNHA', {ID_LNHA: ''});
}]);

angular.module('totalizacao').factory('tb_vendas_servicos_llpp', ['$resource', function($resource) {
    return $resource('api.php/tb_vendas_servicos_llpp/:ID', {'ID' :''});
}]);

angular.module('totalizacao').factory('vw_agendamentos_llpp', ['$resource', function($resource) {
    return $resource('api.php/vw_agendamentos_llpp/');
}]);

angular.module('totalizacao').factory('vw_arvore_ofertas_llpp', ['$resource', function($resource) {
    return $resource('api.php/vw_arvore_ofertas_llpp/', {});
}]);

.
.
.

My controller

angular.module('totalizacao').controller('arvoreOferta',
            ['$routeParams','$rootScope','$scope','vw_vendas_llpp','vw_arvore_ofertas_llpp'
            ,'tb_grupo_oferta_llpp', 'tb_ofertas_llpp', 'tb_agendamentos_llpp','tb_atendimentos_llpp'
            ,'tb_vendas_servicos_llpp', 'vw_vendas_servicos_llpp'
             ,'vw_agendamentos_llpp','tb_score_llpp','vw_ofertas_totais','dateFilter'
        , function($routeParams, $rootScope, $scope, vw_vendas_llpp, vw_arvore_ofertas_llpp
                  ,tb_grupo_oferta_llpp, tb_ofertas_llpp, tb_agendamentos_llpp
                  , tb_atendimentos_llpp, tb_vendas_servicos_llpp, vw_vendas_servicos_llpp
                  , vw_agendamentos_llpp, tb_score_llpp, vw_ofertas_totais, dateFilter){

        var self = this;
.
.
.

Body:
I always prefer using $http since i can have more control on making it generic, infact $resource internally uses $http. But since you have used $resource i am making an effort to do it $resource way.

Please forgive my syntaxes and compilation errors, as i am directly typing it here.
    what you can do is create a common service or factory say apiService or apiFactory and then pass the required parameters, http method and action etc..
    I wont go into coding details, as its upto you how generalise and what you pass, but something like this:

//First create a constant object:

angular.module('totalizacao').constant('apiConstants', {
    totalizacao: 'api.php/tb_mvmt_llpp/',
    totalizacao1: 'api.php/tb_mvmt_llpp1/'
});

// Generalise your factory as you want this is to give you an idea.
angular.module('totalizacao').factory('apiFactory', ['$resource','apiConstants', function($resource) {
    var apiFactory = {};
   /* Http Method  = GET, PUT, POST;
       MethodName = { 'get':    {method:'GET'},
    'save':   {method:'POST'},
    'query':  {method:'GET', isArray:true},
    'remove': {method:'DELETE'},
    'delete': {method:'DELETE'} };*/
    apiFactory.executeApi = function(url, methodName, httpMethod, params){
        var paramNames = Object.keys(params);// getKeys
        //construct url
        // you can put a for loop here to make it more generic for multiple params
        //params[paramNames[i]] will get you the value, here i just have one
        var completeUrl = url + ':' + paramNames[0]; // api.php/tb_mvmt_llpp/:paramName1

        var resources = $resource(completeUrl, null, {
                          apiMethod: {
                              method: httpMethod
                          }
                    });
       //you can return the promise or return the value
      resources[methodName](params) ///resources['get'](params)
            .$promise.then(function(user) {
          // do something

        });
        return // resources[methodName](params).$promise or some variable after

    };

    return apiFactory;
});

in your controller, inject apiFactory, apiConstants and do the following

    var params = {
       paramName1 : 'paramValue1'
    };
    apiFactory.executeApi(apiConstants.totalizacao, 'get', params).then(success,error);

    function success(){};
    function error(){};


问:
How do I drop a file from a branch and go back to the trunk version?
I have an SVN branch that has files with committed modifications on it.
We've now decided that some of these modifications are not required.

How do I effectively discard all the changes I've made to these files on the branch and get the branch to go back to using the trunk revision of these particular files?

Edit: I should have added that some of the files were new on the branch, but have subsequently been added to trunk by a completely different branch and now I want to use those. I sorted these ones by SVN Deleting them from the branch then using SVN Copy to copy the versions from the trunk - which seems to have worked.

答:
Right click a file you want to roll
back, TortoiseSVN "Show Log"

Identify the revision you want to
roll back to.

Right click the revision and "Revert
to this revision"

Check that the file is now in the
state you want

Commit

Between step 4 and 5, you can also roll back other files in case you want to commit all rollbacks together.

Instead of reverting entirely to a specific revision, you can also just undo the changes of certain revisions with "Revert changes from this revision". This is useful if some unwanted changes are followed in the history by changes that you want to keep.

This is all covered in the excellent TortoiseSVN documentation, which you can access through the TortoiseSVN "help" item in your windows explorer context menu.

ContentLicense: CC BY-SA 2.5


问:
Visual Studio error D8016: '/ZI' and '/Gy' command-line options are incompatible
I am having an issue with a project that I am working on. Despite the fact that the code is right, I can't build it because I got the following error

Error  D8016   '/ZI' and '/Gy-' command-line options are incompatible  LoadReport  C:\LoadReport\LoadReport\cl

My version of the visual studio is 2015. Any idea would be appreciated.

答:
You are choosing "Edit and Continue" (/ZI) to be able to fix code during debugging, but also "Disable Function-Level Linking" (/Gy-).

Those two will not work together, as you cannot just change one function in the middle of the code. So just choose one of them, like changing /Gy- to /Gy.


问:
node.js http.connections
I am looking over node.js code and can't understand some of it.  Please help me with it.

```<code>var http = require("http"),
server = http.createServer(function(req,res) {});
......
if(MaxUserCheck <1 ){
server.watcher.stop();
logmsg(level1, server.connections);
}
</code>```

For the above code,
what is "watcher" and how to use it?
"server.connections"   - what is this? and how to use it?

I have seen using server module as

```<code>server.on('request', function (req,res){};
...
server.listen(52273, function(){};
</code>```

and I can understand as above, but using as "server.connections" can't understand and haven't seen it use like that.

I looked up on node.js manual but doesn't explain it.(http://nodejs.org/api/)
It seems that "server.connections" returns how many clients connected to our server..(Server uses Fugue for multi clients)
where can I find the usage of "server.connections" and "server.watcher"

Thank you.

答: These two syntaxes might have been used/required in other directories.  If I export this module to a different file and say require('watcher') there , it will work.however I'm not sure what watcher is used but it could be webwatcher module.</p>

Title: node.js http.connections

Body:
I am looking over node.js code and can't understand some of it.  Please help me with it.

var http = require("http"),
server = http.createServer(function(req,res) {});
......
if(MaxUserCheck <1 ){
server.watcher.stop();
logmsg(level1, server.connections);
}

For the above code,
what is "watcher" and how to use it?
"server.connections"   - what is this? and how to use it?

I have seen using server module as

server.on('request', function (req,res){};
...
server.listen(52273, function(){};

and I can understand as above, but using as "server.connections" can't understand and haven't seen it use like that.

I looked up on node.js manual but doesn't explain it.(http://nodejs.org/api/)
It seems that "server.connections" returns how many clients connected to our server..(Server uses Fugue for multi clients)
where can I find the usage of "server.connections" and "server.watcher"

Thank you.


问:
How to read table field's default value?
I want to read a table field's default value. I'm currently using the following syntax:

```<code>DEF VAR iDefaultValue AS INT NO-UNDO.

iDefaultValue = BUFFER MyTable:BUFFER-FIELD("MyField"):DEFAULT-VALUE.
</code>```

However, when this field gets renamed or there is a typo, it will go thru the compiling process successfully and the possible error is thrown later at the runtime.

Is there any other way to read this value without writting and passing it as string? I'd like to catch any typos or errors with simple syntax check.

答:
You could just define the variable like the field and use its value.

```<code>DEF VAR iDefaultValue like myTable.MyField NO-UNDO.
/* Don't change the variable! */
</code>```

Of course if the initial value of the database field is changed you need to recompile, otherwise you will get the old initial value.
If you want to make sure to always get the current value and catch errors at compile time you can write

```<code>DEF VAR iDefaultValue like myTable.MyField NO-UNDO.
iDefaultValue = BUFFER MyTable:BUFFER-FIELD("MyField"):DEFAULT-VALUE.
</code>```

In this case when the fields gets renamed but the code isn't recompiled you will still get a runtime error.
With the following code you should get an error when starting the program in the latter case.

```<code>DEF VAR iDefaultValue like myTable.MyField NO-UNDO.
define frame f_dummy
  myTable.MyField view-as fill-in skip
with side-labels width 255 stream-io.
iDefaultValue = BUFFER MyTable:BUFFER-FIELD("MyField"):DEFAULT-VALUE.
</code>```

I suppose you will have to decide which behaviour is preferable for you.
All examples assume that the table and field names are known at compile time.

Body:
I want to read a table field's default value. I'm currently using the following syntax:

DEF VAR iDefaultValue AS INT NO-UNDO.

iDefaultValue = BUFFER MyTable:BUFFER-FIELD("MyField"):DEFAULT-VALUE.

However, when this field gets renamed or there is a typo, it will go thru the compiling process successfully and the possible error is thrown later at the runtime.

Is there any other way to read this value without writting and passing it as string? I'd like to catch any typos or errors with simple syntax check.

Body:
You could just define the variable like the field and use its value.

DEF VAR iDefaultValue like myTable.MyField NO-UNDO.
/* Don't change the variable! */

Of course if the initial value of the database field is changed you need to recompile, otherwise you will get the old initial value.
If you want to make sure to always get the current value and catch errors at compile time you can write

DEF VAR iDefaultValue like myTable.MyField NO-UNDO.
iDefaultValue = BUFFER MyTable:BUFFER-FIELD("MyField"):DEFAULT-VALUE.

In this case when the fields gets renamed but the code isn't recompiled you will still get a runtime error.
With the following code you should get an error when starting the program in the latter case.

DEF VAR iDefaultValue like myTable.MyField NO-UNDO.
define frame f_dummy
  myTable.MyField view-as fill-in skip
with side-labels width 255 stream-io.
iDefaultValue = BUFFER MyTable:BUFFER-FIELD("MyField"):DEFAULT-VALUE.

I suppose you will have to decide which behaviour is preferable for you.
All examples assume that the table and field names are known at compile time.


问:
Bind data frames recursively
I have to data frames, same number of columns but different number of rows. I want to bind the columns of one data frame to the columns of the other data frame, but one to all the others, i.e., the first row of one data frame to all the other rows of the second data frame, and so on.

I tried with a for loop, but of course, for a large number of rows, it takes a long time. As an example:

```<code>df1 <- data.frame(replicate(5,sample(0:1,5,rep=TRUE)))
df2 <- data.frame(replicate(5,sample(0:1,5,rep=TRUE)))

b1 <- data.frame()
for (i in 1:nrow(df1)) {
    for (k in 1:nrow(df2)) {
        b1 <- rbind(b1, cbind(df1[i,], df2[k,]))
    }
}
</code>```

In this case, b1 is a data frame of 25 rows and 10 columns.

I tried with do.call, but I get a one-to-one mapping, i.e., a data frame of 5 rows in this case (first column to first column, second column to second column, and so on).

Any ideas on how to improve this?

Thanks!

答:
If i understand you correctly this is the same as:</p>

```<code>ind_1 <- rep(seq_len(nrow(df1)), each = nrow(df2))
ind_2 <- rep(seq_len(nrow(df2)), nrow(df1))

cbind(df1[ind_1, ], df2[ind_2, ])
</code>```

Title: Bind data frames recursively

Body:
I have to data frames, same number of columns but different number of rows. I want to bind the columns of one data frame to the columns of the other data frame, but one to all the others, i.e., the first row of one data frame to all the other rows of the second data frame, and so on.

I tried with a for loop, but of course, for a large number of rows, it takes a long time. As an example:

df1 <- data.frame(replicate(5,sample(0:1,5,rep=TRUE)))
df2 <- data.frame(replicate(5,sample(0:1,5,rep=TRUE)))

b1 <- data.frame()
for (i in 1:nrow(df1)) {
    for (k in 1:nrow(df2)) {
        b1 <- rbind(b1, cbind(df1[i,], df2[k,]))
    }
}

In this case, b1 is a data frame of 25 rows and 10 columns.

I tried with do.call, but I get a one-to-one mapping, i.e., a data frame of 5 rows in this case (first column to first column, second column to second column, and so on).

Any ideas on how to improve this?

Thanks!

Body:
If i understand you correctly this is the same as:

ind_1 <- rep(seq_len(nrow(df1)), each = nrow(df2))
ind_2 <- rep(seq_len(nrow(df2)), nrow(df1))

cbind(df1[ind_1, ], df2[ind_2, ])


问:
App Engine, How to check if all values in a list are in a string list in the datastore
If you have a string list in the datastore that has the values:

a,b,c

How can you compare it against a list so that it only returns true if every value in the string list is present in the list?

['a', 'b'] would return false

['a', 'b', 'c'] would return true

['a', 'b', 'c', 'd', 'e'] would return true

Is this possible with GQL alone or would I need to pull put out the string list and loop over it?

答:
From the documentation:

A query cannot compare two list values. There is no way to test two lists for equality without testing each element for membership separately.

So I would guess that your comparison is also not possible directly.

It may be more efficient to use sets to compare, rather than looping over a list.


问:
Referencing PowerPoint Object in Excel VBA
Long story short - I am trying to pass a string to PowerPoint from PowerShell to update a textbox on a master slide. I can do this from within PowerPoint vba, but it is completely static. As soon as I try to pass data through PowerShell to PowerPoint, I get an error that I have been unable to solve. (see here)

So instead I am attempting to do it through an Excel proxy! I already use Excel VBA to update content on PowerPoint slides, so thought this would be suitable. I currently have shapes set up in Excel, data is updated, and then this is pasted in to a PowerPoint deck, saved and closed.

I need to now extend this Excel macro with functionality that updates the textbox on the master slide. I need to translate "PowerPoint VBA" to "Excel VBA for PowerPoint", what a horrible sentence... I digress:

PowerPoint VBA

```<code>Function UpdateMasterF(message As Variant)
    Dim sourceLabel As Shape
    Dim curSLD As Long
    curSLD = ActiveWindow.View.Slide.SlideIndex

    'switch to SlideMaster
    Application.Windows(1).ViewType = ppViewSlideMaster

    Set sourceLabel = ActivePresentation.SlideMaster.CustomLayouts(1).Shapes("sourcelabel")
    sourceLabel.TextFrame.TextRange.Text = message

    'return to default
    Application.Windows(1).ViewType = ppViewNormal

    'set slide
    ActiveWindow.Presentation.Slides(curSLD).Select
</code>```

Excel VBA

```<code>Function TestPowerPoint(message As Variant, presPath As Variant)
    Dim oPPTApp As Object
    Dim oPPTFile As Object

    Set oPPTApp = CreateObject("PowerPoint.Application")
    oPPTApp.Visible = msoTrue
    Set oPPTFile = oPPTApp.Presentations.Open(presPath)

    ' translate e.g. ApplicationWindow, ActivePresentation etc

    oPPTFile.Save
    oPPTFile.Close
    Set oPPTFile = Nothing
    oPPTApp.Quit
    Set oPPTApp = Nothing
</code>```

I need to be able to complete the same steps as in the PowerPoint VBA but in the Excel macro. I'm having issues finding the right names for it though. So where it says

```<code>Application.Windows(1).ViewType = ppViewSlideMaster
</code>```

Can this be replaced with oPPTApp or oPPTFile? I've read through MSDN Docs and it seems to match but doesn't work.

Hopefully that's conveyed my ask! I expect most people to read and shudder at such a situation...

答:
So extending Steve's answer, I decided to just replace the existing box with a new one, to save the pain of trying to edit the existing shape.

I'm fortunate that the automation I am doing is for the creation of new PowerPoint decks, so I'm able to just place these new shapes on them as I create multiple decks from one blank canvas.

The code I ended up with to get the same formatting is:

```<code>Function TestPowerPoint(message1 As String, message2 As String, presPath As Variant)

set up variables to be used
Dim oPPTApp As PowerPoint.Application
Dim oPPTFile As Object
Dim oPPTPres As PowerPoint.Presentation

Set oPPTApp = CreateObject("PowerPoint.Application")
oPPTApp.Visible = msoTrue
Set oPPTFile = oPPTApp.Presentations.Open(presPath)
Set oPPTPres = oPPTApp.ActivePresentation

With oPPTPres.Designs(1).SlideMaster.CustomLayouts(1)
    With .Shapes.AddTextbox(msoTextOrientationHorizontal, 28, 60, 500, 25)
        .ZOrder msoBringToFront
        With .TextFrame.TextRange
            .Text = message1
            With .Font
                .Size = 10
                .Name = "Calibri"
                .Color = RGB(255, 0, 0)
                .Bold = msoTrue
            End With
        End With
    End With
End With

With oPPTPres.Designs(1).SlideMaster.CustomLayouts(2)
    With .Shapes.AddTextbox(msoTextOrientationHorizontal, 28, 200, 736, 50)
        .ZOrder msoBringToFront
        With .TextFrame.TextRange
            .Text = message2
            .ParagraphFormat.Alignment = ppAlignCenter
            With .Font
                .Size = 32
                .Name = "Calibri"
                .Color = RGB(255, 255, 255)
                .Bold = msoFalse
            End With
        End With
    End With
End With

oPPTFile.Save
oPPTFile.Close
Set oPPTFile = Nothing
oPPTApp.Quit
Set oPPTApp = Nothing

End Function
</code>```

Fantastic! Thank you to everyone who contributed.

Body:
Long story short - I am trying to pass a string to PowerPoint from PowerShell to update a textbox on a master slide. I can do this from within PowerPoint vba, but it is completely static. As soon as I try to pass data through PowerShell to PowerPoint, I get an error that I have been unable to solve. (see here)

So instead I am attempting to do it through an Excel proxy! I already use Excel VBA to update content on PowerPoint slides, so thought this would be suitable. I currently have shapes set up in Excel, data is updated, and then this is pasted in to a PowerPoint deck, saved and closed.

I need to now extend this Excel macro with functionality that updates the textbox on the master slide. I need to translate "PowerPoint VBA" to "Excel VBA for PowerPoint", what a horrible sentence... I digress:

PowerPoint VBA

Function UpdateMasterF(message As Variant)
    Dim sourceLabel As Shape
    Dim curSLD As Long
    curSLD = ActiveWindow.View.Slide.SlideIndex

    'switch to SlideMaster
    Application.Windows(1).ViewType = ppViewSlideMaster

    Set sourceLabel = ActivePresentation.SlideMaster.CustomLayouts(1).Shapes("sourcelabel")
    sourceLabel.TextFrame.TextRange.Text = message

    'return to default
    Application.Windows(1).ViewType = ppViewNormal

    'set slide
    ActiveWindow.Presentation.Slides(curSLD).Select

Excel VBA

Function TestPowerPoint(message As Variant, presPath As Variant)
    Dim oPPTApp As Object
    Dim oPPTFile As Object

    Set oPPTApp = CreateObject("PowerPoint.Application")
    oPPTApp.Visible = msoTrue
    Set oPPTFile = oPPTApp.Presentations.Open(presPath)

    ' translate e.g. ApplicationWindow, ActivePresentation etc

    oPPTFile.Save
    oPPTFile.Close
    Set oPPTFile = Nothing
    oPPTApp.Quit
    Set oPPTApp = Nothing

I need to be able to complete the same steps as in the PowerPoint VBA but in the Excel macro. I'm having issues finding the right names for it though. So where it says

Application.Windows(1).ViewType = ppViewSlideMaster

Can this be replaced with oPPTApp or oPPTFile? I've read through MSDN Docs and it seems to match but doesn't work.

Hopefully that's conveyed my ask! I expect most people to read and shudder at such a situation...

Body:
So extending Steve's answer, I decided to just replace the existing box with a new one, to save the pain of trying to edit the existing shape.

I'm fortunate that the automation I am doing is for the creation of new PowerPoint decks, so I'm able to just place these new shapes on them as I create multiple decks from one blank canvas.

The code I ended up with to get the same formatting is:

Function TestPowerPoint(message1 As String, message2 As String, presPath As Variant)

set up variables to be used
Dim oPPTApp As PowerPoint.Application
Dim oPPTFile As Object
Dim oPPTPres As PowerPoint.Presentation

Set oPPTApp = CreateObject("PowerPoint.Application")
oPPTApp.Visible = msoTrue
Set oPPTFile = oPPTApp.Presentations.Open(presPath)
Set oPPTPres = oPPTApp.ActivePresentation

With oPPTPres.Designs(1).SlideMaster.CustomLayouts(1)
    With .Shapes.AddTextbox(msoTextOrientationHorizontal, 28, 60, 500, 25)
        .ZOrder msoBringToFront
        With .TextFrame.TextRange
            .Text = message1
            With .Font
                .Size = 10
                .Name = "Calibri"
                .Color = RGB(255, 0, 0)
                .Bold = msoTrue
            End With
        End With
    End With
End With

With oPPTPres.Designs(1).SlideMaster.CustomLayouts(2)
    With .Shapes.AddTextbox(msoTextOrientationHorizontal, 28, 200, 736, 50)
        .ZOrder msoBringToFront
        With .TextFrame.TextRange
            .Text = message2
            .ParagraphFormat.Alignment = ppAlignCenter
            With .Font
                .Size = 32
                .Name = "Calibri"
                .Color = RGB(255, 255, 255)
                .Bold = msoFalse
            End With
        End With
    End With
End With

oPPTFile.Save
oPPTFile.Close
Set oPPTFile = Nothing
oPPTApp.Quit
Set oPPTApp = Nothing

End Function

Fantastic! Thank you to everyone who contributed.


问:
Numpy: find index of the elements within range
I have a numpy array of numbers, for example,

```<code>a = np.array([1, 3, 5, 6, 9, 10, 14, 15, 56])
</code>```

I would like to find all the indexes of the elements within a specific range. For instance, if the range is (6, 10), the answer should be (3, 4, 5). Is there a built-in function to do this?

Body:
I have a numpy array of numbers, for example,

a = np.array([1, 3, 5, 6, 9, 10, 14, 15, 56])

I would like to find all the indexes of the elements within a specific range. For instance, if the range is (6, 10), the answer should be (3, 4, 5). Is there a built-in function to do this?

Body:
a = np.array([1,2,3,4,5,6,7,8,9])
b = a[(a>2) & (a<8)]


问:
Get kubernetes service running on specific port
How to set k8s service on port 80:

trying:

```<code>λ kubectl run hello-nginx --image=nginx --port=80
deployment "hello-nginx" created

λ kubectl expose deployment hello-nginx --type=LoadBalancer
service "hello-nginx" exposed

λ kubectl get services
NAME          CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
hello-nginx   10.0.0.142   <pending>     80:30674/TCP   12m
kubernetes    10.0.0.1     <none>        443/TCP        1h

λ minikube service hello-nginx --url
http://192.168.178.105:30674
</code>```

Is it possible to expose this service at http://192.168.178.105:80 ?

Environment: Windowns 10, Docker with Hyper-V

答:
You are using the LoadBalancer strategy, that is recommended when you are using a cloud environment.

You should check this doc to expose ports in your nodes directly this way:

```<code>kubectl expose deployment hello-nginx --type=NodePort
</code>```

After that you can check the port assigned to expose your service and you should be able to access to it.

The range of ports that kubernetes use with this strategy can be configured as you can see here with the "--service-node-port-range portRange" atribute. By default it will use a random port in a range 30000-32767
You can choose the port assigned from the range configured, but I'm not sure right now if you can configure that range to use privileged ports.

If you can't and need to expose your app with the port 80, the easiest solution is to use an nginx to proxypass from port 80 to your-service-nodeport

Body:
How to set k8s service on port 80:

trying:

λ kubectl run hello-nginx --image=nginx --port=80
deployment "hello-nginx" created

λ kubectl expose deployment hello-nginx --type=LoadBalancer
service "hello-nginx" exposed

λ kubectl get services
NAME          CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
hello-nginx   10.0.0.142   <pending>     80:30674/TCP   12m
kubernetes    10.0.0.1     <none>        443/TCP        1h

λ minikube service hello-nginx --url
http://192.168.178.105:30674

Is it possible to expose this service at http://192.168.178.105:80 ?

Environment: Windowns 10, Docker with Hyper-V

Body:
You are using the LoadBalancer strategy, that is recommended when you are using a cloud environment.

You should check this doc to expose ports in your nodes directly this way:

kubectl expose deployment hello-nginx --type=NodePort

After that you can check the port assigned to expose your service and you should be able to access to it.

The range of ports that kubernetes use with this strategy can be configured as you can see here with the "--service-node-port-range portRange" atribute. By default it will use a random port in a range 30000-32767
You can choose the port assigned from the range configured, but I'm not sure right now if you can configure that range to use privileged ports.

If you can't and need to expose your app with the port 80, the easiest solution is to use an nginx to proxypass from port 80 to your-service-nodeport


问:
Get the last non-empty cell in a column in Google Sheets
I use the following function

```<code>=DAYS360(A2, A35)
</code>```

to calculate the difference between two dates in my column. However, the column is ever expanding and I currently have to manually change 'A35' as I update my spreadsheet.

Is there a way (in Google Sheets) to find the last non-empty cell in this column and then dynamically set that parameter in the above function?

答:
My favorite is:

```<code>=INDEX(A2:A,COUNTA(A2:A),1)
</code>```

So, for the OP's need:

```<code>=DAYS360(A2,INDEX(A2:A,COUNTA(A2:A),1))
</code>```

Body:
I use the following function

=DAYS360(A2, A35)

to calculate the difference between two dates in my column. However, the column is ever expanding and I currently have to manually change 'A35' as I update my spreadsheet.

Is there a way (in Google Sheets) to find the last non-empty cell in this column and then dynamically set that parameter in the above function?

Body:
My favorite is:

=INDEX(A2:A,COUNTA(A2:A),1)

So, for the OP's need:

=DAYS360(A2,INDEX(A2:A,COUNTA(A2:A),1))


问:
Xamarin Forms List View Show Different Pages?
New to Xamarin here. How can I make each item on a listview go to a different page in Xamarin Forms?

For example, something like Facebook app:

答: Facebook is using a master detail page for this. Your should take a look at this Xamarin link about Master Detail Page. Let me know if this is not what you're looking for and I'll give you a solution for a listview. I personally would go with the master detail page. </p>


问:
Brightness Screen Filter
Does anyone have an idea how to implement an Brightness Screen Filter like the one here:

http://www.appbrain.com/app/screen-filter/com.haxor

I need a starting point and I can't figure out how to do it.

答:
You ca try this also:</p>

```<code>protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.max_bright);

        WindowManager.LayoutParams lp = getWindow().getAttributes();

        lp.screenBrightness = 100 / 100.0f;

        getWindow().setAttributes(lp);

    }
</code>```

Title: Brightness Screen Filter

Body:
You ca try this also:

protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.max_bright);

        WindowManager.LayoutParams lp = getWindow().getAttributes();

        lp.screenBrightness = 100 / 100.0f;

        getWindow().setAttributes(lp);

    }


问:
Small Basic if-statement
So for school I'm making a project with small basic, idea is very simple, just like my question. I'm making a sort of gambling simulator.

```<code>ready:
TextWindow.WriteLine("Do you want to bet? yes(1) or no(2).")
answer = TextWindow.ReadNumber()
If answer = 1 Then
  Goto start
Else
  Goto ready
  EndIf
  start:
TextWindow.WriteLine("Ok lets go.")
points = 100
var1 = Math.GetRandomNumber(10)
If 5 < var1 < 9 Then
  points = points + 100
ElseIf 9 < var1 < 10 then
  points = points + 200
Elseif 1 < var1 < 5 then
  points = points - 100
EndIf

TextWindow.WriteLine("You rolled " + var1 + ". You now have " + points + " points.")
</code>```

The problem im facing is that whatever happens to my var1 100 gets added to my points, even when var1 is e.g. 1 or 10.

I've asked my teacher, he couldnt explain to me what was wrong.
what am I to do?

thanks in advance

答:
You had three issues.

As suggested by +koceeng, Small Basic dose not support the "x < y < z" structure. Making it worse is Small Basic's tendency to fail safe, meaning that this will compile, but i won't give the expected result. The correct structure for this logic is "x < y and y < z". In other words, all logic is binary and comparisons should only happen two by two.

You have a logic bug as you go from if to if-else. "5 < var1 and var1 < 9" combined with "9 < var1 and var1 < 10" has a hole in it. Nine drops out of the logic and the if statement never matches on it. The same thing will happen to the 5. The correct combination uses an equals sign on one end of the logic or the other: "9 <= var1 and var1 < 10".

Your goto loop was making my head hurt. unless you are doing something simple like creating an infinite loop, jumping from the bottom of your program to the top, you should usually avoid the goto statement entirely. A while loop is a better choice for the type of input protection you are doing.

Here is a corrected version of your code:

```<code>answer = 2
While answer <> 1 'Input Protection
TextWindow.WriteLine("Do you want to bet? yes(1) or no(2).")
answer = TextWindow.ReadNumber()
EndWhile

TextWindow.WriteLine("Ok lets go.")
points = 100
var1 = Math.GetRandomNumber(10)
If 5 <= var1 And var1 < 9 Then
  points = points + 100
ElseIf 9 = var1 or var1 = 10 then
  points = points + 200
Elseif 1 <= var1 and var1 < 5 then
  points = points - 100
EndIf

TextWindow.WriteLine("You rolled " + var1 + ". You now have " + points + " points.")
</code>```

Title: Small Basic if-statement

Body:
So for school I'm making a project with small basic, idea is very simple, just like my question. I'm making a sort of gambling simulator.

ready:
TextWindow.WriteLine("Do you want to bet? yes(1) or no(2).")
answer = TextWindow.ReadNumber()
If answer = 1 Then
  Goto start
Else
  Goto ready
  EndIf
  start:
TextWindow.WriteLine("Ok lets go.")
points = 100
var1 = Math.GetRandomNumber(10)
If 5 < var1 < 9 Then
  points = points + 100
ElseIf 9 < var1 < 10 then
  points = points + 200
Elseif 1 < var1 < 5 then
  points = points - 100
EndIf

TextWindow.WriteLine("You rolled " + var1 + ". You now have " + points + " points.")

The problem im facing is that whatever happens to my var1 100 gets added to my points, even when var1 is e.g. 1 or 10.

I've asked my teacher, he couldnt explain to me what was wrong.
what am I to do?

thanks in advance

Body:
You had three issues.

As suggested by +koceeng, Small Basic dose not support the "x < y < z" structure. Making it worse is Small Basic's tendency to fail safe, meaning that this will compile, but i won't give the expected result. The correct structure for this logic is "x < y and y < z". In other words, all logic is binary and comparisons should only happen two by two.

You have a logic bug as you go from if to if-else. "5 < var1 and var1 < 9" combined with "9 < var1 and var1 < 10" has a hole in it. Nine drops out of the logic and the if statement never matches on it. The same thing will happen to the 5. The correct combination uses an equals sign on one end of the logic or the other: "9 <= var1 and var1 < 10".

Your goto loop was making my head hurt. unless you are doing something simple like creating an infinite loop, jumping from the bottom of your program to the top, you should usually avoid the goto statement entirely. A while loop is a better choice for the type of input protection you are doing.

Here is a corrected version of your code:

answer = 2
While answer <> 1 'Input Protection
TextWindow.WriteLine("Do you want to bet? yes(1) or no(2).")
answer = TextWindow.ReadNumber()
EndWhile

TextWindow.WriteLine("Ok lets go.")
points = 100
var1 = Math.GetRandomNumber(10)
If 5 <= var1 And var1 < 9 Then
  points = points + 100
ElseIf 9 = var1 or var1 = 10 then
  points = points + 200
Elseif 1 <= var1 and var1 < 5 then
  points = points - 100
EndIf

TextWindow.WriteLine("You rolled " + var1 + ". You now have " + points + " points.")


问:
How to put gap for toggle image and hint text in Edittext android?
I am new for android. i want space gap between toggle image and hint text same field of edit text

.

This is my edit text xml code

```<code>     <EditText
            android:id="@+id/nation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/email"
            android:layout_centerHorizontal="true"
            android:drawableLeft="@drawable/ic_flag"
            android:layout_marginTop="11dp"
            android:inputType="textCapWords"
            android:hint="Nationality"/>
</code>```

答:
use :

```<code>android:drawablePadding="20dp"
</code>```

to change Hint text color use:

```<code>android:textColorHint="@android:color/darker_gray"

 <EditText
    android:id="@+id/nation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/email"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="11dp"
    android:drawableLeft="@drawable/ic_flag"
    android:drawablePadding="20dp"
    android:hint="Nationality"
    android:textColorHint="@android:color/darker_gray"
    android:inputType="textCapWords" />
</code>```

Body:
I am new for android. i want space gap between toggle image and hint text same field of edit text

.

This is my edit text xml code

     <EditText
            android:id="@+id/nation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/email"
            android:layout_centerHorizontal="true"
            android:drawableLeft="@drawable/ic_flag"
            android:layout_marginTop="11dp"
            android:inputType="textCapWords"
            android:hint="Nationality"/>

Body:
use :

android:drawablePadding="20dp"

to change Hint text color use:

android:textColorHint="@android:color/darker_gray"

 <EditText
    android:id="@+id/nation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/email"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="11dp"
    android:drawableLeft="@drawable/ic_flag"
    android:drawablePadding="20dp"
    android:hint="Nationality"
    android:textColorHint="@android:color/darker_gray"
    android:inputType="textCapWords" />


问:
SSRS SQL 2008 R2 - How to reference the value of other groups?
I have a matrix setup in the report designer in BIDS. Below is a screenshot:

All I want to do is use an expression to multiply the value of COL GROUP 1 by COL GROUP 2, for each ROW GROUP as illustrated in red. What would be the best way to achieve this?

EDIT: For clarity, each column group is filtered to only return a single value per adjacent column group

答:
On a per row basis, you can use..

```<code>=ReportItems!ColGroup1Value.Value * ReportItems!ColGroup2Value.Value
</code>```

This assumes that the textbox which contains the value for "ColGroup1Value" is named ColGroup1Value.

See https://learn.microsoft.com/en-us/sql/reporting-services/report-design/built-in-collections-reportitems-collection-references-report-builder for more information about ReportItems.

Body:
On a per row basis, you can use..

=ReportItems!ColGroup1Value.Value * ReportItems!ColGroup2Value.Value

This assumes that the textbox which contains the value for "ColGroup1Value" is named ColGroup1Value.

See https://learn.microsoft.com/en-us/sql/reporting-services/report-design/built-in-collections-reportitems-collection-references-report-builder for more information about ReportItems.


问:
Get user current lat lng after GPS enabled - Android
I have followed this tutorial http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/ for showing popup if GPS in not enabled and getting users current location.

And here is the broadcast receiver which listens to the GPS enabled disabled condition

```<code>private BroadcastReceiver mGpsSwitchStateReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {

        if (intent.getAction().matches("android.location.PROVIDERS_CHANGED")) {
            gps = new GPSTracker(getActivity());

            if(gps.canGetLocation()){
                Log.d("Your Location", "latitude:" + gps.getLatitude() + ", longitude: " + gps.getLongitude());

                Toast.makeText(getActivity(), "GPS Switch", Toast.LENGTH_SHORT).show();

                if(gps.getLatitude() != 0 && gps.getLongitude() != 0 ){
                    final CameraPosition cameraPosition = new CameraPosition.Builder()
                            .target(new LatLng(gps.getLatitude(),gps.getLongitude()))      // Sets the center of the map to selected place
                            .zoom(15)                   // Sets the zoom
                            .build();                   //
                    gMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
                    Toast.makeText(getActivity(), "GPS Switch Lat: "+gps.getLatitude()+" Long: "+gps.getLongitude(), Toast.LENGTH_SHORT).show();
                }
            } else {
                if(!gps.isSettingDialogShown())
                    gps.showSettingsAlert();
            }
        }
    }
};
</code>```

When I enable the GPS via settings dialog or from drop down menu. GPSTracker class gets the location service and checks for the user's current location in this code fragment

```<code>public Location getLocation() {
    try {
        locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);

        // getting GPS status
        isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

        // getting network status
        isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if (!isGPSEnabled && !isNetworkEnabled) {
            // no network provider is enabled
        } else {
            this.canGetLocation = true;
            if (isNetworkEnabled) {
                locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,MIN_TIME_BW_UPDATES,MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                Log.d("Network", "Network Enabled");
                if (locationManager != null) {
                    location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    if (location != null) {
                        latitude = location.getLatitude();
                        longitude = location.getLongitude();

                    }
                }
            }
            // if GPS Enabled get lat/long using GPS Services
            if (isGPSEnabled) {
                if (location == null) {
                    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                    Log.d("GPS", "GPS Enabled");
                    if (locationManager != null) {
                        location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                        if (location != null) {
                            latitude = location.getLatitude();
                            longitude = location.getLongitude();

                        }
                    }
                }
            }
        }

    } catch (SecurityException e) {
        e.printStackTrace();
    }

    return location;
}
</code>```

Problem:

Firstly I don't know why broadcast receiver, receives the action two times and secondly when in normal mode lat lng value in receiver remains zero but in debugging sometimes it returns the value of users current location.

Can you please help what I am doing wrong?

答: If you don't need to work with Gps and Network Locations separately. I recommend to use FusedLocationProvider. BroadcastReceiver is probably working twice because it works for both gps and network location services</p>

Body:
I have followed this tutorial http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/ for showing popup if GPS in not enabled and getting users current location.

And here is the broadcast receiver which listens to the GPS enabled disabled condition

private BroadcastReceiver mGpsSwitchStateReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {

        if (intent.getAction().matches("android.location.PROVIDERS_CHANGED")) {
            gps = new GPSTracker(getActivity());

            if(gps.canGetLocation()){
                Log.d("Your Location", "latitude:" + gps.getLatitude() + ", longitude: " + gps.getLongitude());

                Toast.makeText(getActivity(), "GPS Switch", Toast.LENGTH_SHORT).show();

                if(gps.getLatitude() != 0 && gps.getLongitude() != 0 ){
                    final CameraPosition cameraPosition = new CameraPosition.Builder()
                            .target(new LatLng(gps.getLatitude(),gps.getLongitude()))      // Sets the center of the map to selected place
                            .zoom(15)                   // Sets the zoom
                            .build();                   //
                    gMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
                    Toast.makeText(getActivity(), "GPS Switch Lat: "+gps.getLatitude()+" Long: "+gps.getLongitude(), Toast.LENGTH_SHORT).show();
                }
            } else {
                if(!gps.isSettingDialogShown())
                    gps.showSettingsAlert();
            }
        }
    }
};

When I enable the GPS via settings dialog or from drop down menu. GPSTracker class gets the location service and checks for the user's current location in this code fragment

public Location getLocation() {
    try {
        locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);

        // getting GPS status
        isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

        // getting network status
        isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if (!isGPSEnabled && !isNetworkEnabled) {
            // no network provider is enabled
        } else {
            this.canGetLocation = true;
            if (isNetworkEnabled) {
                locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,MIN_TIME_BW_UPDATES,MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                Log.d("Network", "Network Enabled");
                if (locationManager != null) {
                    location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    if (location != null) {
                        latitude = location.getLatitude();
                        longitude = location.getLongitude();

                    }
                }
            }
            // if GPS Enabled get lat/long using GPS Services
            if (isGPSEnabled) {
                if (location == null) {
                    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                    Log.d("GPS", "GPS Enabled");
                    if (locationManager != null) {
                        location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                        if (location != null) {
                            latitude = location.getLatitude();
                            longitude = location.getLongitude();

                        }
                    }
                }
            }
        }

    } catch (SecurityException e) {
        e.printStackTrace();
    }

    return location;
}

Problem:

Firstly I don't know why broadcast receiver, receives the action two times and secondly when in normal mode lat lng value in receiver remains zero but in debugging sometimes it returns the value of users current location.

Can you please help what I am doing wrong?