问:
How can I use a formula in a for loop in java
I am a beginner java programmer, studying off basic youtube videos and overflow forums, and i came across a question on an textbook sheet that asked me to use a for loop program and print this table out as well as fill in each blank

```<code>Number   Square   Cube   (n+1)/(2n-18)
______________________________________
1         #        #          #
2         #        #          #
3         #        #          #
4         #        #          #
5         #        #          #
</code>```

I thought I should try it out to test myself. I came up with the following program that works perfectly for the Number, Square and Cube part of the table, but I don't understand how to generate the numbers using the given formula. The formula I initialized as a variable (double) doesn't print the actual results, and I honestly don't have a clue as to what to do. I'd rather a simple explanation than a complex one and simple changes to the code rather than complex. As I said I am a beginner, and many different methods may go right over my head. Thank you so much in advance (also an extra task asks that I print out the sums of each column. I don't know how to do that at all, and would like an explanation if possible, but wouldn't mind if I don't receive one)

```<code>int number;
int maxValue;

Scanner keyboard = new Scanner(System.in);
System.out.println("how many numbers do you want the max value to be");
maxValue = keyboard.nextInt();

System.out.println("Number\tSquare\tCube (n+1)/(2n-18)");
System.out.println("--------------------------------");
for (number = 1; number <= maxValue; number++) {
    double formula = (number + 1) / (number * 2);
    System.out.println(
        number + "\t\t\t" + number * number + "\t\t\t" +
        number * number * number + "\t\t\t" + formula);
}
</code>```

答:
Your formula should be:

```<code>double formula = (double)(number + 1) / (number * 2 - 18);
</code>```

Two issues:

missing -18

the / is doing an integer division unless you cast at least one operand into a double

Oh! one more thing: when number==9, there is a division by zero. A double division gives you "Infinity" whereas an integer division throws an exception.

Body:
I am a beginner java programmer, studying off basic youtube videos and overflow forums, and i came across a question on an textbook sheet that asked me to use a for loop program and print this table out as well as fill in each blank

Number   Square   Cube   (n+1)/(2n-18)
______________________________________
1         #        #          #
2         #        #          #
3         #        #          #
4         #        #          #
5         #        #          #

I thought I should try it out to test myself. I came up with the following program that works perfectly for the Number, Square and Cube part of the table, but I don't understand how to generate the numbers using the given formula. The formula I initialized as a variable (double) doesn't print the actual results, and I honestly don't have a clue as to what to do. I'd rather a simple explanation than a complex one and simple changes to the code rather than complex. As I said I am a beginner, and many different methods may go right over my head. Thank you so much in advance (also an extra task asks that I print out the sums of each column. I don't know how to do that at all, and would like an explanation if possible, but wouldn't mind if I don't receive one)

int number;
int maxValue;

Scanner keyboard = new Scanner(System.in);
System.out.println("how many numbers do you want the max value to be");
maxValue = keyboard.nextInt();

System.out.println("Number\tSquare\tCube (n+1)/(2n-18)");
System.out.println("--------------------------------");
for (number = 1; number <= maxValue; number++) {
    double formula = (number + 1) / (number * 2);
    System.out.println(
        number + "\t\t\t" + number * number + "\t\t\t" +
        number * number * number + "\t\t\t" + formula);
}

Body:
Your formula should be:

double formula = (double)(number + 1) / (number * 2 - 18);

Two issues:

missing -18

the / is doing an integer division unless you cast at least one operand into a double

Oh! one more thing: when number==9, there is a division by zero. A double division gives you "Infinity" whereas an integer division throws an exception.


来源: stackexchange

问:
Lotus Java proxy in time read order
I made a lotus Java proxy, but the mailbox list was not arranged in chronological order, what should I do。

```<code>Database database = session.getDatabase(session.getServerName, string, false);
View view = database.getView("($Inbox)");
Document document = view.getFirstDocument();
.....
</code>```

My idea is to use the search function to get the time - arranged mailing list. How should the code write?

答: By the way, getting the time - arranged mailing list also needs to be the inbox or the hair box...</p>

ContentLicense: CC BY-SA 3.0

Title: Lotus Java proxy in time read order

Body:
I made a lotus Java proxy, but the mailbox list was not arranged in chronological order, what should I do。

Database database = session.getDatabase(session.getServerName, string, false);
View view = database.getView("($Inbox)");
Document document = view.getFirstDocument();
.....

My idea is to use the search function to get the time - arranged mailing list. How should the code write?


答:
Your formula does not match the textbook.  Try this:

```<code>System.out.println("Number\tSquare\tCube (n+1)/(2n-18)");
System.out.println("--------------------------------");

for (int number=1; number <= maxValue; number++) {
    double square = Math.pow(number, 2);
    double cube = Math.pow(number, 3);
    double formula = (number + 1) / (number * 2 - 18);
    System.out.println(number + "\t\t\t" + square + "\t\t\t" + cube + "\t\t\t" + formula);
}
</code>```

Note: As pointed out by @MauricePerry an input of 9 would cause a divide by zero.  Rather than try to catch this unchecked exception, I think you should control your input values so that this does not happen.

Title: How can I use a formula in a for loop in java

Body:
Your formula does not match the textbook.  Try this:

System.out.println("Number\tSquare\tCube (n+1)/(2n-18)");
System.out.println("--------------------------------");

for (int number=1; number <= maxValue; number++) {
    double square = Math.pow(number, 2);
    double cube = Math.pow(number, 3);
    double formula = (number + 1) / (number * 2 - 18);
    System.out.println(number + "\t\t\t" + square + "\t\t\t" + cube + "\t\t\t" + formula);
}

Note: As pointed out by @MauricePerry an input of 9 would cause a divide by zero.  Rather than try to catch this unchecked exception, I think you should control your input values so that this does not happen.


问:
Any tips for making Hive run faster on Hadoop?
I'm new to Hive and Hadoop. I have Hadoop configured for pseudo-distributed operation with one data node and one name node, all on localhost.

I have a trivial employee table containing 4 records. I can select the records in a reasonable amount of time, but anything beyond that takes really long. For example:

```<code>0: jdbc:hive2://localhost:10000> select * from emp;
+------------+------------+-------------+-------------+------------+
| emp.empno  | emp.ename  |   emp.job   | emp.deptno  | emp.etype  |
+------------+------------+-------------+-------------+------------+
| 7369       | SMITH      | CLERK       | 10          | PART_TIME  |
| 7400       | JONES      | ENGINEER    | 10          | FULL_TIME  |
| 7500       | BROWN      | NIGHTGUARD  | 20          | FULL_TIME  |
| 7510       | LEE        | ENGINEER    | 20          | FULL_TIME  |
+------------+------------+-------------+-------------+------------+
4 rows selected (0.643 seconds)
0: jdbc:hive2://localhost:10000> select * from emp order by empno;
WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
+------------+------------+-------------+-------------+------------+
| emp.empno  | emp.ename  |   emp.job   | emp.deptno  | emp.etype  |
+------------+------------+-------------+-------------+------------+
| 7369       | SMITH      | CLERK       | 10          | PART_TIME  |
| 7400       | JONES      | ENGINEER    | 10          | FULL_TIME  |
| 7500       | BROWN      | NIGHTGUARD  | 20          | FULL_TIME  |
| 7510       | LEE        | ENGINEER    | 20          | FULL_TIME  |
+------------+------------+-------------+-------------+------------+
4 rows selected (225.852 seconds)
</code>```

What's it doing that's taking so long? Are there polling periods that I could reduce? I know that Hive isn't optimized for small tasks but this seems ridiculous.

Here's the various files:
hive-site.xml

```<code><?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
  <property>
    <name>hive.mapred.mode</name>
    <value>nostrict</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:derby:;databaseName=metastore_db;create=true</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>org.apache.derby.jdbc.EmbeddedDriver</value>
  </property>
  <property>
    <name>hive.exec.local.scratchdir</name>
    <value>/home/hadoop/tmp</value>
  </property>
  <property>
    <name>hive.downloaded.resources.dir</name>
    <value>/home/hadoop/tmp/${hive.session.id}_resources</value>
  </property>
  <property>
    <name>hive.querylog.location</name>
    <value>/home/hadoop/tmp</value>
  </property>
  <property>
    <name>hive.server2.logging.operation.log.location</name>
    <value>/home/hadoop/tmp/operation_logs</value>
  </property>
</configuration>
</code>```

hdfs.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>dfs.replication</name>
      <value>1</value>
   </property>
   <property>
      <name>dfs.name.dir</name>
      <value>file:///home/hadoop/hadoopinfra/hdfs/namenode</value>
   </property>
   <property>
      <name>dfs.data.dir</name>
      <value>file:///home/hadoop/hadoopinfra/hdfs/datanode</value>
   </property>
</configuration>
</code>```

core-site.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>fs.default.name</name>
      <value>hdfs://localhost:9000</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hive.groups</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hive.hosts</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hadoop.hosts</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hadoop.groups</name>
      <value>*</value>
   </property>
</configuration>
</code>```

mapred-site.xml

```<code><?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>mapreduce.framework.name</name>
      <value>yarn</value>
   </property>
</configuration>
</code>```

yarn-site.xml

```<code><?xml version="1.0"?>
<configuration>
   <property>
      <name>yarn.nodemanager.aux-services</name>
      <value>mapreduce_shuffle</value>
   </property>
</configuration>
</code>```

答:
You can do two things to run your query faster :
1. Use the combination of DISTRIBUTE BY and SORT BY. DISTRIBUTE BY will ensure that all keys with a certain value will end up on the same data node. SORT BY will then sort the data on each node.
2. set the execution engine to Tez before executing your query.

set hive.execution.engine=tez;

I think this will certainly make your query run faster.

Body:
I'm new to Hive and Hadoop. I have Hadoop configured for pseudo-distributed operation with one data node and one name node, all on localhost.

I have a trivial employee table containing 4 records. I can select the records in a reasonable amount of time, but anything beyond that takes really long. For example:

0: jdbc:hive2://localhost:10000> select * from emp;
+------------+------------+-------------+-------------+------------+
| emp.empno  | emp.ename  |   emp.job   | emp.deptno  | emp.etype  |
+------------+------------+-------------+-------------+------------+
| 7369       | SMITH      | CLERK       | 10          | PART_TIME  |
| 7400       | JONES      | ENGINEER    | 10          | FULL_TIME  |
| 7500       | BROWN      | NIGHTGUARD  | 20          | FULL_TIME  |
| 7510       | LEE        | ENGINEER    | 20          | FULL_TIME  |
+------------+------------+-------------+-------------+------------+
4 rows selected (0.643 seconds)
0: jdbc:hive2://localhost:10000> select * from emp order by empno;
WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
+------------+------------+-------------+-------------+------------+
| emp.empno  | emp.ename  |   emp.job   | emp.deptno  | emp.etype  |
+------------+------------+-------------+-------------+------------+
| 7369       | SMITH      | CLERK       | 10          | PART_TIME  |
| 7400       | JONES      | ENGINEER    | 10          | FULL_TIME  |
| 7500       | BROWN      | NIGHTGUARD  | 20          | FULL_TIME  |
| 7510       | LEE        | ENGINEER    | 20          | FULL_TIME  |
+------------+------------+-------------+-------------+------------+
4 rows selected (225.852 seconds)

What's it doing that's taking so long? Are there polling periods that I could reduce? I know that Hive isn't optimized for small tasks but this seems ridiculous.

Here's the various files:
hive-site.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
  <property>
    <name>hive.mapred.mode</name>
    <value>nostrict</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:derby:;databaseName=metastore_db;create=true</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>org.apache.derby.jdbc.EmbeddedDriver</value>
  </property>
  <property>
    <name>hive.exec.local.scratchdir</name>
    <value>/home/hadoop/tmp</value>
  </property>
  <property>
    <name>hive.downloaded.resources.dir</name>
    <value>/home/hadoop/tmp/${hive.session.id}_resources</value>
  </property>
  <property>
    <name>hive.querylog.location</name>
    <value>/home/hadoop/tmp</value>
  </property>
  <property>
    <name>hive.server2.logging.operation.log.location</name>
    <value>/home/hadoop/tmp/operation_logs</value>
  </property>
</configuration>

hdfs.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>dfs.replication</name>
      <value>1</value>
   </property>
   <property>
      <name>dfs.name.dir</name>
      <value>file:///home/hadoop/hadoopinfra/hdfs/namenode</value>
   </property>
   <property>
      <name>dfs.data.dir</name>
      <value>file:///home/hadoop/hadoopinfra/hdfs/datanode</value>
   </property>
</configuration>

core-site.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>fs.default.name</name>
      <value>hdfs://localhost:9000</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hive.groups</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hive.hosts</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hadoop.hosts</name>
      <value>*</value>
   </property>
   <property>
      <name>hadoop.proxyuser.hadoop.groups</name>
      <value>*</value>
   </property>
</configuration>

mapred-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
   <property>
      <name>mapreduce.framework.name</name>
      <value>yarn</value>
   </property>
</configuration>

yarn-site.xml

<?xml version="1.0"?>
<configuration>
   <property>
      <name>yarn.nodemanager.aux-services</name>
      <value>mapreduce_shuffle</value>
   </property>
</configuration>


问:
connection timed out error in online mode and could not open file in offline mode - android studio
```<code>repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.github.PhilJay:MPAndroidChart:v2.2.2'
}
</code>```

I am getting the Error:Connection timed out: connect in online mode whereas while changing the gradle setting to offline, I could not open the library.

答:
Perhaps, your internet connection is too slow.
You can download this library from github and import in your project.

Here is github repository link:
https://github.com/PhilJay/MPAndroidChart

Just click on download button then select download ZIP and after downloading, copy the folder MPChartLib and paste into your project root directory and compile with gradle.

In your settings.gradle, include ':app', ':MDChartLib'
and build.gradle(Module:app),   compile project(':MDChartLib')

Body:
repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.github.PhilJay:MPAndroidChart:v2.2.2'
}

I am getting the Error:Connection timed out: connect in online mode whereas while changing the gradle setting to offline, I could not open the library.


问:
What are some good sql databases for home Vista computer?
I have been trying for a long time to get SQL Server Express on my computer to practice my C#/SQL with and I still haven't gotten it to work.

Are there other programs I can use to setup an SQL database to practice with?  If so, which are the best ones for Vista?

EDIT:
To be clear I am not new to SQL programming, I just haven't done any in a while and want to stay fresh.  So I would like something that has most of the features of forms of SQL I would use professionally.

答:
What aren't you getting to work for Sql Express.  It works on Vista.  I use it on a daily basis.  It no longer comes standard with a "northwind" database, but you an download the AdventureWorks DB.  Can you be more specific about "I still haven't gotten it to work"?

I've also heard good things about firebird

Although I still believe that C# and SQL Express is the best way to go.

OwnerDisplayName: GordonG

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: GordonG

OwnerDisplayName: GregD

LastEditorDisplayName: GregD


问:
INTERVIEW QUESTION : Perl Log file
There is a log file where each line contains fields separated by spaces. One of the fields is the IP address of the source node. We want to find the list of IP Addresses that have the most log entries. Lets say find the top 10 IP Addresses with most log entries.

This is Perl Interview Question. Interviewer wants to know how the candidate would proceed.

P.S: This question was asked to my friend

答:
My response, Mr. or Ms. Interviewer, would be based on the answers to several questions. The first set of those questions follow.  Of course, there may be additional questions generated by the answers to these.

You say "one of the fields."  Do we know which field?  Is it always the same or does it vary?

Will the logs have only IPv4, only IPv6, or a mixture of both?  Is address mapping between IPv4 and IPv6 a concern in counting, or can the mappings be treated as unique source nodes?

How big is the logfile?  How much memory is available to solve the problem?

Are CPAN modules available for use, or is the solution limited to only core modules or some other "approved" modules list?

Title: INTERVIEW QUESTION : Perl Log file


问:
java.lang.NoSuchMethodError: org.mockito.internal.runners.RunnerFactory.createStrict(Ljava/lang/Class;)Lorg/mockito/internal/runners/InternalRunner;
I am writing my Junit test cases for Groovy using Mockito jar, but it is giving me following exception:

```<code>java.lang.NoSuchMethodError: org.mockito.internal.runners.RunnerFactory.createStrict(Ljava/lang/Class;)Lorg/mockito/internal/runners/InternalRunner;
at org.mockito.junit.MockitoJUnitRunner.<init>(MockitoJUnitRunner.java:152)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
</code>```

Below is the jar list that I have:

```<code>cglib-nodep-2.2.2
javassist-3.19.0-GA
junit-4.12
mockito-all-1.10.19
objenesis-2.5
powermock-mockito-1.6.2-full
</code>```

Below is my code. I have added necessary imports:

```<code>package test.service
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.InjectMocks
import org.mockito.Mock
import org.mockito.junit.MockitoJUnitRunner
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
class SyncImplTest {

    @InjectMocks
    SyncThreatImpl  fixture;

    @Mock
    RpcConfigurationLoader rpcConfigurationLoader

    @Test
    public void testRpcConfig(){
        RpcApiInfo rpcApiInfo =  new RpcApiInfo();
        when(rpcConfigurationLoader.loadConfiguration()).thenReturn(rpcApiInfo)
    }

}
</code>```

答:
In Mockito 1.10.19 (which is from 2014), there is no class org.mockito.junit.MockitoJUnitRunner. This was introduced later in 2.x. If you really want to use 1.10.19, you should probably use the then correct class org.mockito.runners.MockitoJUnitRunner which then should work.

But I would strongly recommend using a newer Mockito version instead. mockito-all is simply not the right artifact to depend on anymore. With 2.x this artefact was not maintained anymore.

Body:
I am writing my Junit test cases for Groovy using Mockito jar, but it is giving me following exception:

java.lang.NoSuchMethodError: org.mockito.internal.runners.RunnerFactory.createStrict(Ljava/lang/Class;)Lorg/mockito/internal/runners/InternalRunner;
at org.mockito.junit.MockitoJUnitRunner.<init>(MockitoJUnitRunner.java:152)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Below is the jar list that I have:

cglib-nodep-2.2.2
javassist-3.19.0-GA
junit-4.12
mockito-all-1.10.19
objenesis-2.5
powermock-mockito-1.6.2-full

Below is my code. I have added necessary imports:

package test.service
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.InjectMocks
import org.mockito.Mock
import org.mockito.junit.MockitoJUnitRunner
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
class SyncImplTest {

    @InjectMocks
    SyncThreatImpl  fixture;

    @Mock
    RpcConfigurationLoader rpcConfigurationLoader

    @Test
    public void testRpcConfig(){
        RpcApiInfo rpcApiInfo =  new RpcApiInfo();
        when(rpcConfigurationLoader.loadConfiguration()).thenReturn(rpcApiInfo)
    }

}

ContentLicense: CC BY-SA 4.0


问:
Import error pycrypto google app engine
I'm running a local server in Python with GAE, and importing a 3rd party library, which in turn imports pycrypto. I installed it locally using pip and included it in my app.yaml file, but when I run the server, I get the following error:

ImportError: cannot import name OSRNG

Here's what my app.yaml looks like:

```<code>runtime: python27
threadsafe: 1

handlers:
- url: /.*
  script: main.app

libraries:
- name: pycrypto
  version: "latest"
</code>```

I'm running homebrew python 2.7.

答:
The pycrypto library is built-in in the runtime environment, however you need to install it locally in order to run the local development server, as you did. It might just be a problem with versions, as the supported pycrypto versions are 2.3, 2.6 and 2.6.1.

Try installing the proper version with pip install pycrypto==2.6.1.

Then, change your app.yaml file to the appropriate version:

```<code>libraries:
- name: pycrypto
  version: "2.6.1"
</code>```

Title: Import error pycrypto google app engine

Body:
I'm running a local server in Python with GAE, and importing a 3rd party library, which in turn imports pycrypto. I installed it locally using pip and included it in my app.yaml file, but when I run the server, I get the following error:

ImportError: cannot import name OSRNG

Here's what my app.yaml looks like:

runtime: python27
threadsafe: 1

handlers:
- url: /.*
  script: main.app

libraries:
- name: pycrypto
  version: "latest"

I'm running homebrew python 2.7.

Body:
The pycrypto library is built-in in the runtime environment, however you need to install it locally in order to run the local development server, as you did. It might just be a problem with versions, as the supported pycrypto versions are 2.3, 2.6 and 2.6.1.

Try installing the proper version with pip install pycrypto==2.6.1.

Then, change your app.yaml file to the appropriate version:

libraries:
- name: pycrypto
  version: "2.6.1"


问:
Disable back button in android
How to disable back button in android while logging out the application?</p>

答:
Just using this code: If you want backpressed disable, you dont use super.OnBackPressed();</p>

```<code>@Override
public void onBackPressed() {

}
</code>```

Title: Disable back button in android

Body:
Just using this code: If you want backpressed disable, you dont use super.OnBackPressed();

@Override
public void onBackPressed() {

}


问:
How to wait for Storyboard in another class to complete
So I have two classes

A. MainWindow

B. MoveObjects

1. MainWindow - Calls MoveObject class method to perform the storyboard animation on canvas.

2. MoveObjects - Performs storyboard animations on canvas.

Everything is working fine. What I need is, once the animation is displayed on the Canvas, I want to call a method in MainWindow which is private. But, since its private, I can't call it from MoveObjects and I am unable to get the control back to MainWindow after the storyboard execution is completed.

Right now, its calls the MoveObjects class, displays the animation but doesn't come back to the calling class i.e. MainWindow.

How can I achieve this?

I tried the following code -

```<code>bg.DoWork += (s, el) =>
            {

                Dispatcher.Invoke(new Action(() => {
                MoveObjects.AnimateMSU(expectedSKUQuantitiesAtPPS[(int)SKUTypes.Shirts],
                expectedSKUQuantitiesAtPPS[(int)SKUTypes.Pants],
                expectedSKUQuantitiesAtPPS[(int)SKUTypes.Shoes],
                expectedSKUQuantitiesAtPPS[(int)SKUTypes.Hats],
                StorageGridAnimationCanvas, "Finish");
            }), DispatcherPriority.ContextIdle);

        };

        bg.RunWorkerCompleted += (s, el) =>
        {
             //Call a private method of current class
        };

        bg.RunWorkerAsync();
</code>```

But, bg.RunWorkerCompleted is executed before the animation is displayed on the Canvas. How can I make class MainWindow wait for the MoveObjects class to get completely executed?

答: You can use delegate here. Please find a code sample here.</p>

Body:
So I have two classes

A. MainWindow

B. MoveObjects

1. MainWindow - Calls MoveObject class method to perform the storyboard animation on canvas.

2. MoveObjects - Performs storyboard animations on canvas.

Everything is working fine. What I need is, once the animation is displayed on the Canvas, I want to call a method in MainWindow which is private. But, since its private, I can't call it from MoveObjects and I am unable to get the control back to MainWindow after the storyboard execution is completed.

Right now, its calls the MoveObjects class, displays the animation but doesn't come back to the calling class i.e. MainWindow.

How can I achieve this?

I tried the following code -

bg.DoWork += (s, el) =>
            {

                Dispatcher.Invoke(new Action(() => {
                MoveObjects.AnimateMSU(expectedSKUQuantitiesAtPPS[(int)SKUTypes.Shirts],
                expectedSKUQuantitiesAtPPS[(int)SKUTypes.Pants],
                expectedSKUQuantitiesAtPPS[(int)SKUTypes.Shoes],
                expectedSKUQuantitiesAtPPS[(int)SKUTypes.Hats],
                StorageGridAnimationCanvas, "Finish");
            }), DispatcherPriority.ContextIdle);

        };

        bg.RunWorkerCompleted += (s, el) =>
        {
             //Call a private method of current class
        };

        bg.RunWorkerAsync();

But, bg.RunWorkerCompleted is executed before the animation is displayed on the Canvas. How can I make class MainWindow wait for the MoveObjects class to get completely executed?


问:
server side & end-user web application security and validation methods
I was wondering what security method everyone uses to secure a web application at bank grade if possible.

from the best of my knowledge here are the methods/technologies that i know of.

```<code>Front - End-user Section
-------------------------
SSL (128 bit encryption)
htaccess (protection against bots and using mod-rewrite to hide parameter calls)
input field cleaning
session cleaning before use
PDO access to mysql ( although oracle is better yet expensive)
not being on a shared hosting account.
using a cisco based firewall (not very familiar with these)
restricting what can be uploaded (if the site requires an upload)
blocking off directory index access with htaccess
not storing credit card information locally
encrypting user passwords with sha1 or encryption with salt
(never could figure these out)

not using hidden input fields
turn off global variables
turn off error displays
using another file extension displayed to the user rather than php , aspx, etc.
blocking ping/requests for server/apache information and version.

backend access
-------------------
not having its access being something like /admin (if you know what i mean)
"all of the above listed for end-user"
verifying if the user who logs in exists as an admin
</code>```

rather than using mysql_real_escape_string or htmlentities to clean input fields
then there is filter_input() which doesnt work that good. it kind of messes up the cleaning.
so what do you guys recommend. i know some of you might be thinking this might be a bit too much but if your working on a web application that was to be hit by over 50k users where ecommerce based transactions would occur. what would you do?

thanks

ps: this is what i have in my htaccess to protect against non-friendly bots and restricting access to important files.

```<code>#=============================================================================#
#          Deny access to hidden files
#=============================================================================#
<FilesMatch "\.(htaccess|log|sh)$">
 Order Allow,Deny
 Deny from all
</FilesMatch>

#=============================================================================#
#          Deny access to evil bots / security
#=============================================================================#

RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^JetCar.* [NC]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^GoZilla.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^ia_archiver.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^wget.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^HTTrack.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCapture.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Scooter-W3.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGe.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Webdupe.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Pockey.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^DiscoPump.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InternetNinja.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
RewriteCond %{HTTP_USER_AGENT} ^Custo [OR]
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]
RewriteCond %{HTTP_USER_AGENT} ^HTTrack [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^Indy\ Library [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]
RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR]
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^GoZilla.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCapture.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Webdupe.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Pockey.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^DiscoPump.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InternetSeer.com.* [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://www.hostitcheap.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.bravespider.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.bigweblist.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.weblinkvalidator.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://traffixer.com* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.youradultpaysite.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.paysiteprofits.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.hotlivewebcams.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.paysiteprofits.com/* [OR]
RewriteCond %{REQUEST_URI} FormMail.*
RewriteCond %{HTTP_REFERER} ^www.addresses.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.business-socket.com/* [OR]
RewriteCond %{HTTP_REFERER} ^www.datashaping.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://cheapweb.biz/* [OR]
RewriteCond %{HTTP_REFERER} ^http://traffixer.com* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.hostitcheap.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.weblinkvalidator.com/* [OR]
RewriteCond %{REQUEST_URI} FormMail.*
RewriteRule .* - [F,L]
</code>```

答:
using another file extension displayed
  to the user rather than php , aspx,
  etc.

blocking ping/requests for
  server/apache information and version.

Using an Apache AddHandler to run php under .html (or whatever other file extension) can be fun to confuse amateur scriptkiddies, but anyone who knows what they are doing shouldn't have a hard time figuring out what server model you're running through various other pokes and prods...

encrypting user passwords with sha1 or
  encryption with salt  (never could
  figure these out)

Salting your password hashes is easy. You write a script that runs the password, plus a "key" that varies per user through an encryption method like sha1, and this hash is stored in the database. When a user logs in, the password they supply is ran through the same script and the hashes are compared. The purpose of the "key" is that even if 2 users have the same password, their hashes will still be different due to different keys. However rather then storing hash keys, I find its best to use a more complex script that blends in username and password with multiple encryptions like this:

```<code>$hash = sha1(substr(sha1($password), 0, strlen($_POST['password'])).substr(sha1($loginUsername), 0, (40-strlen($_POST['password']))));
</code>```

which encrypts the password, encrpyts the username, uses the string length of the password to determine how to concatenate substrings of the 2 sha hashs, then encrpyts the whole string again. That might seem a bit excessive but there is no way in hell anyone is going to crack that even if they know the username and associated hash.

not storing credit card information
  locally

actually I believe by law you are not allowed to store credit card numbers, just the last 4 digits and a credit card number hash. I've never had to deal with credit card transactions but this is what we were taught in an e-commerce class I took a few semesters back.

as for input sanitation, when I need something beyond mysql_real_escape_string, I usually write my own regex validation script depending on what the expected input is...

Body:
I was wondering what security method everyone uses to secure a web application at bank grade if possible.

from the best of my knowledge here are the methods/technologies that i know of.

Front - End-user Section
-------------------------
SSL (128 bit encryption)
htaccess (protection against bots and using mod-rewrite to hide parameter calls)
input field cleaning
session cleaning before use
PDO access to mysql ( although oracle is better yet expensive)
not being on a shared hosting account.
using a cisco based firewall (not very familiar with these)
restricting what can be uploaded (if the site requires an upload)
blocking off directory index access with htaccess
not storing credit card information locally
encrypting user passwords with sha1 or encryption with salt
(never could figure these out)

not using hidden input fields
turn off global variables
turn off error displays
using another file extension displayed to the user rather than php , aspx, etc.
blocking ping/requests for server/apache information and version.

backend access
-------------------
not having its access being something like /admin (if you know what i mean)
"all of the above listed for end-user"
verifying if the user who logs in exists as an admin

rather than using mysql_real_escape_string or htmlentities to clean input fields
then there is filter_input() which doesnt work that good. it kind of messes up the cleaning.
so what do you guys recommend. i know some of you might be thinking this might be a bit too much but if your working on a web application that was to be hit by over 50k users where ecommerce based transactions would occur. what would you do?

thanks

ps: this is what i have in my htaccess to protect against non-friendly bots and restricting access to important files.

#=============================================================================#
#          Deny access to hidden files
#=============================================================================#
<FilesMatch "\.(htaccess|log|sh)$">
 Order Allow,Deny
 Deny from all
</FilesMatch>

#=============================================================================#
#          Deny access to evil bots / security
#=============================================================================#

RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^JetCar.* [NC]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^GoZilla.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^ia_archiver.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^wget.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^HTTrack.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCapture.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Scooter-W3.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGe.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Webdupe.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Pockey.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^DiscoPump.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InternetNinja.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
RewriteCond %{HTTP_USER_AGENT} ^Custo [OR]
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]
RewriteCond %{HTTP_USER_AGENT} ^HTTrack [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^Indy\ Library [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]
RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR]
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^GoZilla.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCapture.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Webdupe.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Pockey.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^DiscoPump.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InternetSeer.com.* [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://www.hostitcheap.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.bravespider.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.bigweblist.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.weblinkvalidator.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://traffixer.com* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.youradultpaysite.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.paysiteprofits.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.hotlivewebcams.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.paysiteprofits.com/* [OR]
RewriteCond %{REQUEST_URI} FormMail.*
RewriteCond %{HTTP_REFERER} ^www.addresses.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.business-socket.com/* [OR]
RewriteCond %{HTTP_REFERER} ^www.datashaping.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://cheapweb.biz/* [OR]
RewriteCond %{HTTP_REFERER} ^http://traffixer.com* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.hostitcheap.com/* [OR]
RewriteCond %{HTTP_REFERER} ^http://www.weblinkvalidator.com/* [OR]
RewriteCond %{REQUEST_URI} FormMail.*
RewriteRule .* - [F,L]

Body:
using another file extension displayed
  to the user rather than php , aspx,
  etc.

blocking ping/requests for
  server/apache information and version.

Using an Apache AddHandler to run php under .html (or whatever other file extension) can be fun to confuse amateur scriptkiddies, but anyone who knows what they are doing shouldn't have a hard time figuring out what server model you're running through various other pokes and prods...

encrypting user passwords with sha1 or
  encryption with salt  (never could
  figure these out)

Salting your password hashes is easy. You write a script that runs the password, plus a "key" that varies per user through an encryption method like sha1, and this hash is stored in the database. When a user logs in, the password they supply is ran through the same script and the hashes are compared. The purpose of the "key" is that even if 2 users have the same password, their hashes will still be different due to different keys. However rather then storing hash keys, I find its best to use a more complex script that blends in username and password with multiple encryptions like this:

$hash = sha1(substr(sha1($password), 0, strlen($_POST['password'])).substr(sha1($loginUsername), 0, (40-strlen($_POST['password']))));

which encrypts the password, encrpyts the username, uses the string length of the password to determine how to concatenate substrings of the 2 sha hashs, then encrpyts the whole string again. That might seem a bit excessive but there is no way in hell anyone is going to crack that even if they know the username and associated hash.

not storing credit card information
  locally

actually I believe by law you are not allowed to store credit card numbers, just the last 4 digits and a credit card number hash. I've never had to deal with credit card transactions but this is what we were taught in an e-commerce class I took a few semesters back.

as for input sanitation, when I need something beyond mysql_real_escape_string, I usually write my own regex validation script depending on what the expected input is...


问:
How to use null with kotlin @Parcelize
Here is very simple code:

```<code>@Parcelize
data class Inner(val a: Int): Parcelable

@Parcelize
data class Test(val a: Int, val inner: Inner?): Parcelable

@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
    @Test
    fun testParcel() {
        val test = Test(0, null)

        val parcel = Parcel.obtain()
        parcel.writeParcelable(test, test.describeContents())
    }
}
</code>```

I have nullable property Test.inner. If it is not null, the code works fine but when it is null then I have the exception:

```<code>java.lang.NullPointerException: Attempt to invoke interface method 'void android.os.Parcelable.writeToParcel(android.os.Parcel, int)' on a null object reference
</code>```

How to resolve this? Maybe I do something wrong.

答: The bug has been fixed in Kotlin 1.1.60.</p>

Title: How to use null with kotlin @Parcelize

Body:
Here is very simple code:

@Parcelize
data class Inner(val a: Int): Parcelable

@Parcelize
data class Test(val a: Int, val inner: Inner?): Parcelable

@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
    @Test
    fun testParcel() {
        val test = Test(0, null)

        val parcel = Parcel.obtain()
        parcel.writeParcelable(test, test.describeContents())
    }
}

I have nullable property Test.inner. If it is not null, the code works fine but when it is null then I have the exception:

java.lang.NullPointerException: Attempt to invoke interface method 'void android.os.Parcelable.writeToParcel(android.os.Parcel, int)' on a null object reference

How to resolve this? Maybe I do something wrong.


问:
awk gensub function usage issue
```<code>cat file

^QciProfilePredefined=qci2$ logicalChannelGroupRef QciTable=default,LogicalChannelGroup=2
EUtranCellTDD=.*-1[123456],UeMeasControl=1,ReportConfigA4=1$ a4ThresholdRsrp -140
</code>```

I want to use gensub() to delete the content before the last comma in $1(also delete the comma),without make influence other column which contains comma.

my code:

```<code>awk '{$1=gensub(/.*,/,"",1);print}' file
</code>```

output:

```<code>LogicalChannelGroup=2 logicalChannelGroupRef QciTable=default,LogicalChannelGroup=2
ReportConfigA4=1$ a4ThresholdRsrp -140 a4ThresholdRsrp -140
</code>```

It seems that the ROW 2 content repeated by "4ThresholdRsrp -140".

The output I expected:

```<code>LogicalChannelGroup=2 logicalChannelGroupRef QciTable=default,LogicalChannelGroup=2
ReportConfigA4=1$ a4ThresholdRsrp -140
</code>```

答:
gensub has 4 arguments gensub(regexp, replacement, how [, target])

you forgot to mention the target, default is $0 but you need $1

how argument is used to specify which match to be replaced, for ex: 2nd match or 4th match (like sed 's///3') and also accepts "g" or "G" to specify all matches

```<code>awk '{$1=gensub(/.*,/,"",1,$1);print}'
</code>```

you don't need gensub here, sub will do inplace substitution for first match found. gsub will do inplace substitution for all matches found

```<code>awk '{sub(/.*,/,"",$1);print}'
</code>```

Title: awk gensub function usage issue

Body:
cat file

^QciProfilePredefined=qci2$ logicalChannelGroupRef QciTable=default,LogicalChannelGroup=2
EUtranCellTDD=.*-1[123456],UeMeasControl=1,ReportConfigA4=1$ a4ThresholdRsrp -140

I want to use gensub() to delete the content before the last comma in $1(also delete the comma),without make influence other column which contains comma.

my code:

awk '{$1=gensub(/.*,/,"",1);print}' file

output:

LogicalChannelGroup=2 logicalChannelGroupRef QciTable=default,LogicalChannelGroup=2
ReportConfigA4=1$ a4ThresholdRsrp -140 a4ThresholdRsrp -140

It seems that the ROW 2 content repeated by "4ThresholdRsrp -140".

The output I expected:

LogicalChannelGroup=2 logicalChannelGroupRef QciTable=default,LogicalChannelGroup=2
ReportConfigA4=1$ a4ThresholdRsrp -140

Body:
gensub has 4 arguments gensub(regexp, replacement, how [, target])

you forgot to mention the target, default is $0 but you need $1

how argument is used to specify which match to be replaced, for ex: 2nd match or 4th match (like sed 's///3') and also accepts "g" or "G" to specify all matches

awk '{$1=gensub(/.*,/,"",1,$1);print}'

you don't need gensub here, sub will do inplace substitution for first match found. gsub will do inplace substitution for all matches found

awk '{sub(/.*,/,"",$1);print}'


问:
Comparing 2 seemingly equal strings returns false because one ends with char code 8291. How can I sanitize the string?
I'm trying to compare the string "Anyone" to an object value that is also supposed to be "Anyone" and looks equal when logging to the console.

I'm checking the 2 strings using:

```<code>for char, index in text
    console.log "char " + index + ": " + text.charCodeAt(index)
</code>```

One string returns one extra character with the code 8291. What character is this and how can I remove it?
.trim() and using a regex whitespace remover doesn't seem to work.

答:
Solved using str.replace(/[^\x00-\x7F]/g, "");.
Which removes all non-ascii characters.

Body:
I'm trying to compare the string "Anyone" to an object value that is also supposed to be "Anyone" and looks equal when logging to the console.

I'm checking the 2 strings using:

for char, index in text
    console.log "char " + index + ": " + text.charCodeAt(index)

One string returns one extra character with the code 8291. What character is this and how can I remove it?
.trim() and using a regex whitespace remover doesn't seem to work.


问:
C# static vs instance methods
I'm risking it this might be a newb question but here goes. I'm tempted to add a method to a class that could possible have thousands and thousands of instances in memory at a given time. Now, the other option is creating a static class with a static method, and just create the [static] method there, instead of an instance method in the class. Something like so:

This:

```<code>public static class PetOwner
{
    public static void RenamePet(Pet pet, string newName)
    {
        pet.Name = newName;
    }
}
</code>```

Instead of this:

```<code>public class Pet
{
    public string Name { get; set; }

    public void Rename(string newName)
    {
        this.Name = newName;
    }
}
</code>```

I'm just wondering if the static class alternative would take considerably less memory.

Thanks!

答:
You don't need a method "Rename" at all; you already have one, it's the setter of the Name property.  Instance methods do not require more and more memory on a per instance basis, that would be silly.

Don't make design decisions like this before profiling your code.  Adding an instance method to a class is not going to cause a performance bottleneck, and even if it did, you shouldn't start out with a bad design based on a guess; prove it is a bottleneck and make adjustments as necessary.

Title: C# static vs instance methods

Body:
I'm risking it this might be a newb question but here goes. I'm tempted to add a method to a class that could possible have thousands and thousands of instances in memory at a given time. Now, the other option is creating a static class with a static method, and just create the [static] method there, instead of an instance method in the class. Something like so:

This:

public static class PetOwner
{
    public static void RenamePet(Pet pet, string newName)
    {
        pet.Name = newName;
    }
}

Instead of this:

public class Pet
{
    public string Name { get; set; }

    public void Rename(string newName)
    {
        this.Name = newName;
    }
}

I'm just wondering if the static class alternative would take considerably less memory.

Thanks!


问:
iOS - Animating background issue
I am trying to animate few elements on a screen, here's the code:

```<code>  private func setupAnimations() {

    self.emailAddress.alpha = 0
    self.fullName.alpha = 0
    self.password.alpha = 0
    self.confirmPassword.alpha = 0
    self.signUp.alpha = 0
    self.fullName.leftView?.alpha = 0
    self.emailAddress.leftView?.alpha = 0
    self.password.leftView?.alpha = 0
    self.confirmPassword.leftView?.alpha = 0

    self.emailAddress.center.x += self.view.bounds.width-10
    self.fullName.center.x -= self.view.bounds.width-10
    self.password.center.x -= self.view.bounds.width-10
    self.confirmPassword.center.x += self.view.bounds.width-10
    self.signUp.center.y += self.view.bounds.height/2

    UIView.animate(withDuration: 1.7, delay: 0.2, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.5, options: [.allowUserInteraction,.curveEaseInOut], animations: {

        self.emailAddress.alpha = 1
        self.emailAddress.center.x -= self.view.bounds.width-10
        self.view.layoutIfNeeded()

    }, completion: {(completed) in

        if completed {

            UIView.animate(withDuration: 1, animations: {
                self.fullName.leftView?.alpha = 1
                self.emailAddress.leftView?.alpha = 1
                self.password.leftView?.alpha = 1
                self.confirmPassword.leftView?.alpha = 1
            })

        }

    })

    UIView.animate(withDuration: 1.7, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.5, options: [.allowUserInteraction,.curveEaseInOut], animations: {

        self.fullName.alpha = 1
        self.fullName.center.x += self.view.bounds.width-10
        self.view.layoutIfNeeded()

    }, completion: {(completed) in

        if completed {

            UIView.animate(withDuration: 1, animations: {
                self.fullName.leftView?.alpha = 1
                self.emailAddress.leftView?.alpha = 1
                self.password.leftView?.alpha = 1
                self.confirmPassword.leftView?.alpha = 1
            })

        }

    })
</code>```

And so on.. you get the idea - Im setting the alpha to 0 and center x to be off screen, and animate it "arriving" on the screen, its being called in viewDidLoad(). Everything worked out for a month, but recently I have checked this and here's the problem:

video link: https://streamable.com/lhqvu

The background, which is an UIImage in a superview is also being animated, making the superview (red background) being seen.

Any help would be appreciated. Thank you in advance.

答: add your animation setupAnimations method in viewWillAppear and remove self.view.layoutIfNeeded() from usingSpringWithDamping block. And in storyboard uncheck the safeArea and while setting top constraint to superview uncheck the  Constrain to margins & set zero.

Title: iOS - Animating background issue

Body:
I am trying to animate few elements on a screen, here's the code:

  private func setupAnimations() {

    self.emailAddress.alpha = 0
    self.fullName.alpha = 0
    self.password.alpha = 0
    self.confirmPassword.alpha = 0
    self.signUp.alpha = 0
    self.fullName.leftView?.alpha = 0
    self.emailAddress.leftView?.alpha = 0
    self.password.leftView?.alpha = 0
    self.confirmPassword.leftView?.alpha = 0

    self.emailAddress.center.x += self.view.bounds.width-10
    self.fullName.center.x -= self.view.bounds.width-10
    self.password.center.x -= self.view.bounds.width-10
    self.confirmPassword.center.x += self.view.bounds.width-10
    self.signUp.center.y += self.view.bounds.height/2

    UIView.animate(withDuration: 1.7, delay: 0.2, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.5, options: [.allowUserInteraction,.curveEaseInOut], animations: {

        self.emailAddress.alpha = 1
        self.emailAddress.center.x -= self.view.bounds.width-10
        self.view.layoutIfNeeded()

    }, completion: {(completed) in

        if completed {

            UIView.animate(withDuration: 1, animations: {
                self.fullName.leftView?.alpha = 1
                self.emailAddress.leftView?.alpha = 1
                self.password.leftView?.alpha = 1
                self.confirmPassword.leftView?.alpha = 1
            })

        }

    })

    UIView.animate(withDuration: 1.7, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.5, options: [.allowUserInteraction,.curveEaseInOut], animations: {

        self.fullName.alpha = 1
        self.fullName.center.x += self.view.bounds.width-10
        self.view.layoutIfNeeded()

    }, completion: {(completed) in

        if completed {

            UIView.animate(withDuration: 1, animations: {
                self.fullName.leftView?.alpha = 1
                self.emailAddress.leftView?.alpha = 1
                self.password.leftView?.alpha = 1
                self.confirmPassword.leftView?.alpha = 1
            })

        }

    })

And so on.. you get the idea - Im setting the alpha to 0 and center x to be off screen, and animate it "arriving" on the screen, its being called in viewDidLoad(). Everything worked out for a month, but recently I have checked this and here's the problem:

video link: https://streamable.com/lhqvu

The background, which is an UIImage in a superview is also being animated, making the superview (red background) being seen.

Any help would be appreciated. Thank you in advance.


问:
what is pending_update_count in telegram bot?
i have a telegrambot that works fine (i developed it with php and mysql).

but sometimes it's not working, and when i send getWebhookInfo, sends me a message that includes pending_update_count.

what is pending_update_count?

how to prevent pending_update_count filling?

答: pending_update_count is the number of messages that your bot has not been received and is in queue to be received. Maybe your web hook does not respond with 200 status to Telegram (e.g. returns 500 cause of an error).


问:
Angular2. Method in component is being called multiple times and returns the wrong data
I have a method inside a module that is being called 3 times when the page load and it returns the wrong data. When debugging / checking the console it appears as the right data is being returned but on the screen the data is wrong

in component.html i have

```<code><p ng-if="posting">
 {{ getPlaceholderText('headline') }}
</p>
</code>```

This is the method:

```<code>getPlaceholderText(placeholderName: string): string {

console.log('Looking for placeholder with name "' + placeholderName + '"');

if (this.posting.placeholders != null) {

  this.posting.placeholders.forEach(placeholder => {
    if (placeholder.name === placeholderName) {
      console.log('found placeholder with name "' + placeholderName + '"');
      console.log('Returning value: "' + placeholder.text + '"');
      console.log('');
      return placeholder.text;
    }
  });
} else {
  return 'posting.placeholder is null';
}

console.log('');
console.log('placeholder with name "' + placeholderName + '" not found');
return 'placeholder with name "' + placeholderName + '" not found';
}
</code>```

When the pages is rendered this is output:

```<code>placeholder with name "headline" not found
</code>```

It should have been the value of placeholder.text property. In the console I have this:

```<code>Looking for placeholder with name "headline"
found placeholder with name "headline"
Returning value: "Standard Post 1 headline"

placeholder with name "headline" not found

Looking for placeholder with name "headline"
found placeholder with name "headline"
Returning value: "Standard Post 1 headline"

placeholder with name "headline" not found
</code>```

Anyone can put some light on what is going on here?

Here is the complete code for my component:

```<code>import { Component, OnInit } from '@angular/core';
import { environment } from '../../environments/environment';
import { ActivatedRoute } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { Posting } from '../models/Posting';
import { SiteService } from '../shared/siteService/siteService.service';
import { finalize } from 'rxjs/operators';

@Component({
  selector: 'app-post',
  templateUrl: './post.component.html',
  styleUrls: ['./post.component.scss']
})
export class PostComponent implements OnInit {

  version: string = environment.version;
  postingId: number;
  sub: any;
  isLoading: boolean;
  posting: Posting;
  postingTitle: string;

  constructor(
    private route: ActivatedRoute,
    private titleService: Title,
    private siteService: SiteService) { }

  ngOnInit() {

    this.isLoading = true;
    this.posting = new Posting();

    this.sub = this.route.params.subscribe(params => {
      this.postingId = +params['id'];
      this.postingTitle = params['title'];

      this.titleService.setTitle(this.postingTitle);

      this.siteService.getPost({ id: this.postingId })
        .pipe(finalize(() => { this.isLoading = false; }))
        .subscribe(posting => this.posting = posting);
    });
  }

  getPlaceholderText(placeholderName: string): string {

    console.log('Looking for placeholder with name "' + placeholderName + '"');

    if (this.posting.placeholders != null) {

      this.posting.placeholders.forEach(placeholder => {
        if (placeholder.name === placeholderName) {
          console.log('found placeholder with name "' + placeholderName + '"');
          console.log('Returning value: "' + placeholder.text + '"');
          console.log('');
          return placeholder.text;
        }
      });
    } else {
      return 'posting.placeholder is null';
    }

    console.log('placeholder with name "' + placeholderName + '" not found');
    return 'placeholder with name "' + placeholderName + '" not found';
  }
}
</code>```

答:
Try the following:

 {{ getPlaceholderText('headline') }}

Body:
I have a method inside a module that is being called 3 times when the page load and it returns the wrong data. When debugging / checking the console it appears as the right data is being returned but on the screen the data is wrong

in component.html i have

 {{ getPlaceholderText('headline') }}

This is the method:

getPlaceholderText(placeholderName: string): string {

console.log('Looking for placeholder with name "' + placeholderName + '"');

if (this.posting.placeholders != null) {

  this.posting.placeholders.forEach(placeholder => {
    if (placeholder.name === placeholderName) {
      console.log('found placeholder with name "' + placeholderName + '"');
      console.log('Returning value: "' + placeholder.text + '"');
      console.log('');
      return placeholder.text;
    }
  });
} else {
  return 'posting.placeholder is null';
}

console.log('');
console.log('placeholder with name "' + placeholderName + '" not found');
return 'placeholder with name "' + placeholderName + '" not found';
}

When the pages is rendered this is output:

placeholder with name "headline" not found

It should have been the value of placeholder.text property. In the console I have this:

Looking for placeholder with name "headline"
found placeholder with name "headline"
Returning value: "Standard Post 1 headline"

placeholder with name "headline" not found

Looking for placeholder with name "headline"
found placeholder with name "headline"
Returning value: "Standard Post 1 headline"

placeholder with name "headline" not found

Anyone can put some light on what is going on here?

Here is the complete code for my component:

import { Component, OnInit } from '@angular/core';
import { environment } from '../../environments/environment';
import { ActivatedRoute } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { Posting } from '../models/Posting';
import { SiteService } from '../shared/siteService/siteService.service';
import { finalize } from 'rxjs/operators';

@Component({
  selector: 'app-post',
  templateUrl: './post.component.html',
  styleUrls: ['./post.component.scss']
})
export class PostComponent implements OnInit {

  version: string = environment.version;
  postingId: number;
  sub: any;
  isLoading: boolean;
  posting: Posting;
  postingTitle: string;

  constructor(
    private route: ActivatedRoute,
    private titleService: Title,
    private siteService: SiteService) { }

  ngOnInit() {

    this.isLoading = true;
    this.posting = new Posting();

    this.sub = this.route.params.subscribe(params => {
      this.postingId = +params['id'];
      this.postingTitle = params['title'];

      this.titleService.setTitle(this.postingTitle);

      this.siteService.getPost({ id: this.postingId })
        .pipe(finalize(() => { this.isLoading = false; }))
        .subscribe(posting => this.posting = posting);
    });
  }

  getPlaceholderText(placeholderName: string): string {

    console.log('Looking for placeholder with name "' + placeholderName + '"');

    if (this.posting.placeholders != null) {

      this.posting.placeholders.forEach(placeholder => {
        if (placeholder.name === placeholderName) {
          console.log('found placeholder with name "' + placeholderName + '"');
          console.log('Returning value: "' + placeholder.text + '"');
          console.log('');
          return placeholder.text;
        }
      });
    } else {
      return 'posting.placeholder is null';
    }

    console.log('placeholder with name "' + placeholderName + '" not found');
    return 'placeholder with name "' + placeholderName + '" not found';
  }
}

Body:
Try the following:
<p *ngIf="posting"> {{ getPlaceholderText('headline') }} </p>


问:
How to do dimension reduction in Bag of Words for a Classification Model using Random Forest
I am using Text data Features along with other numerical features for  classification model.

How can I group similar bag of words together in a supervised classification Model. How I can group similar words after countvectorizing , I want reduce the dimension of bag of words .

My code

```<code>#Cleaning the Address Data
stopwords =nltk.corpus.stopwords.words('english')
data['Clean_addr'] = data['Adj_Addr'].apply(lambda x:"".join([item for item in x if item not in stopwords]))
data['Clean_addr']=data['Clean_addr'].apply(lambda x:"".join([item for item in x if  not  item.isdigit()]))
data['Clean_addr']=data['Clean_addr'].apply(lambda x:"".join([item for item in x if item not in string.punctuation]))

#CountVectorizing the Address Data and fitting the sparse matrix to the Dataframe

cv = CountVectorizer( max_features = 1000,analyzer='word')
cv_addr = cv.fit_transform(data.pop('Clean_addr'))
for i, col in enumerate(cv.get_feature_names()):
    data[col] = pd.SparseSeries(cv_addr[:, i].toarray().ravel(), fill_value=0)

#LabelEncoding -Converting Catergocial to Numerical
data['Resi'] = LabelEncoder().fit_transform(data['Resi'])
data['Resi_Area'] = LabelEncoder().fit_transform(data['Resi_Area'])
data['Product'] = LabelEncoder().fit_transform(data['Product'])
data['Phone_Type'] = LabelEncoder().fit_transform(data['Phone_Type'])
data['Co_Name_FLag'] = LabelEncoder().fit_transform(data['Co_Name_FLag'])

#Classification
X_train, X_test, y_train, y_test = train_test_split(train, Y, test_size=0.3,random_state =8)
rus = RandomUnderSampler(random_state=42)
X_train_res, y_train_res = rus.fit_sample(X_train, y_train)
rf=RandomForestClassifier(n_estimators=1000,oob_score=True)

fit_rf=rf.fit(X_train_res,y_train_res)
</code>```

Any help is appreciated.

答:
If you want to reduce the diemension of your bag of words, you can use SelectPercentile from sklearn. Here is an exemple on Iris data :

```<code>from sklearn.feature_selection import SelectPercentile
from sklearn.feature_selection import chi2
import numpy
iris = load_iris()
X, y = iris.data, iris.target
selector = SelectPercentile(score_func=chi2, percentile=50)
X_reduced = selector.fit_transform(X, y)
</code>```

You can easily extend it to a bag of words in your example:

```<code>cv = CountVectorizer( max_features = 1000,analyzer='word')
cv_addr = cv.fit_transform(data.pop('Clean_addr'))
selector = SelectPercentile(score_func=chi2, percentile=50)
X_reduced = selector.fit_transform(cv_addr, Y)
</code>```

After, that, you can do different trials to see which percentile works best, and eventually plot a score by percentile, but also plot the highly scored words with their term frequency associated, here is an example of such a bar plot :

Good luck.

Body:
I am using Text data Features along with other numerical features for  classification model.

How can I group similar bag of words together in a supervised classification Model. How I can group similar words after countvectorizing , I want reduce the dimension of bag of words .

My code

#Cleaning the Address Data
stopwords =nltk.corpus.stopwords.words('english')
data['Clean_addr'] = data['Adj_Addr'].apply(lambda x:"".join([item for item in x if item not in stopwords]))
data['Clean_addr']=data['Clean_addr'].apply(lambda x:"".join([item for item in x if  not  item.isdigit()]))
data['Clean_addr']=data['Clean_addr'].apply(lambda x:"".join([item for item in x if item not in string.punctuation]))

#CountVectorizing the Address Data and fitting the sparse matrix to the Dataframe

cv = CountVectorizer( max_features = 1000,analyzer='word')
cv_addr = cv.fit_transform(data.pop('Clean_addr'))
for i, col in enumerate(cv.get_feature_names()):
    data[col] = pd.SparseSeries(cv_addr[:, i].toarray().ravel(), fill_value=0)

#LabelEncoding -Converting Catergocial to Numerical
data['Resi'] = LabelEncoder().fit_transform(data['Resi'])
data['Resi_Area'] = LabelEncoder().fit_transform(data['Resi_Area'])
data['Product'] = LabelEncoder().fit_transform(data['Product'])
data['Phone_Type'] = LabelEncoder().fit_transform(data['Phone_Type'])
data['Co_Name_FLag'] = LabelEncoder().fit_transform(data['Co_Name_FLag'])

#Classification
X_train, X_test, y_train, y_test = train_test_split(train, Y, test_size=0.3,random_state =8)
rus = RandomUnderSampler(random_state=42)
X_train_res, y_train_res = rus.fit_sample(X_train, y_train)
rf=RandomForestClassifier(n_estimators=1000,oob_score=True)

fit_rf=rf.fit(X_train_res,y_train_res)

Any help is appreciated.

Body:
If you want to reduce the diemension of your bag of words, you can use SelectPercentile from sklearn. Here is an exemple on Iris data :

from sklearn.feature_selection import SelectPercentile
from sklearn.feature_selection import chi2
import numpy
iris = load_iris()
X, y = iris.data, iris.target
selector = SelectPercentile(score_func=chi2, percentile=50)
X_reduced = selector.fit_transform(X, y)

You can easily extend it to a bag of words in your example:

cv = CountVectorizer( max_features = 1000,analyzer='word')
cv_addr = cv.fit_transform(data.pop('Clean_addr'))
selector = SelectPercentile(score_func=chi2, percentile=50)
X_reduced = selector.fit_transform(cv_addr, Y)

After, that, you can do different trials to see which percentile works best, and eventually plot a score by percentile, but also plot the highly scored words with their term frequency associated, here is an example of such a bar plot :

Good luck.


问:
JSF: Mojarra vs. OmniFaces @ViewScoped: @PreDestroy called but bean can't be garbage collected
This question is specific to the OmniFaces @ViewScoped bean (however of interest to wider discussion about memory leakage and resource disposal with JSF @ViewScoped). It is based on the results of this NetBeans8.1 test web app available on GitHub:

Investigation of undesirable holding of references to various forms of JSF @ViewScoped beans by navigation type

https://github.com/webelcomau/JSFviewScopedNav

That test web app has a comprehensive README with complete instructions, as well as annotated test web pages comparing obsolete JSF2.0-style @ManagedBean @ViewScoped, JSF2.2-style CDI-friendly @Named @ViewScoped, and OmniFaces @Named @ViewScoped beans.

The results using JVisualVM for diagnosis are summarised in a downloadable spreadsheet (see also screenshot below), and indicate that while the OmniFaces-2.5.1 @ViewScoped bean invokes @PreDestroy methods under GET-based navigation cases when leaving a view (giving the opportunity to release most resources), it does not seem to permit garbage collection of the actual bean (at least not with the current context parameter settings).

In web.xml the application is set to use:

```<code>com.sun.faces.numberOfViewsInSession 4

com.sun.faces.numberOfLogicalViews 4
</code>```

By default this OmniFaces-specific parameter is commented out:

```<code>org.omnifaces.VIEW_SCOPE_MANAGER_MAX_ACTIVE_VIEW_SCOPES
</code>```

The javax.faces.STATE_SAVING_METHOD defaults to 'server'.

The main question is:

Q1: Is it correct that these OmniFaces @ViewScoped beans can't by design be garbage collected "live" (meaning through say provocation using a Profiler's garbage collectiong action, not waiting until a session is over) ?

Q2: If this is so, how can (should) one best force release of them on navigating away from pages (especially under GET navigations) ?

Q3: If not so (if my results are incorrect because of some other setting) why aren't I witnessing provoked garbage collection of them, and what can I do to ensure they are indeed automatically released ?

Since the test web app is downloadable, well documented and hopefully self-explanatory, I won't give code here, but simply the comparitive results so far, as well as screenshots of the test web app pages in action:

答:
The cause of this problem seems to be due to strange behaviour JVisualVM when attached to Glassfish/Payara.

The test case used for this question is still extremely useful, however the conclusions concerning Garbage Collection in the original post (and images) were based on JVisualVM, and I have since found they are not valid.

Use the NetBeans Profiler instead !

I am now getting completely consistent results for OmniFaces ViewScoped with the test app on forcing GC from within the NetBeans Profiler (with 1 omnifaces view scoped bean left per open tab).

When using JVisualVM attached to GlassFish/Payara I am getting references still held (even after @PreDestroy called) by field sessionListeners of type com.sun.web.server.WebContainerListener within ContainerBase$ContainerBackgroundProcessor, and they won't GC.

The image shows a screenshot of JVisualVM attached to Payara with only 1 tab open but still 9 OmniViewBean instances held, no matter how often GC is forced.

Updated results table using Mojarra-2.3.0 vs OmniFaces-2.6.6 in NetBeans IDE 8.2 Profiler

Updated test app sequence:

Body:
This question is specific to the OmniFaces @ViewScoped bean (however of interest to wider discussion about memory leakage and resource disposal with JSF @ViewScoped). It is based on the results of this NetBeans8.1 test web app available on GitHub:

Investigation of undesirable holding of references to various forms of JSF @ViewScoped beans by navigation type

https://github.com/webelcomau/JSFviewScopedNav

That test web app has a comprehensive README with complete instructions, as well as annotated test web pages comparing obsolete JSF2.0-style @ManagedBean @ViewScoped, JSF2.2-style CDI-friendly @Named @ViewScoped, and OmniFaces @Named @ViewScoped beans.

The results using JVisualVM for diagnosis are summarised in a downloadable spreadsheet (see also screenshot below), and indicate that while the OmniFaces-2.5.1 @ViewScoped bean invokes @PreDestroy methods under GET-based navigation cases when leaving a view (giving the opportunity to release most resources), it does not seem to permit garbage collection of the actual bean (at least not with the current context parameter settings).

In web.xml the application is set to use:

com.sun.faces.numberOfViewsInSession 4

com.sun.faces.numberOfLogicalViews 4

By default this OmniFaces-specific parameter is commented out:

org.omnifaces.VIEW_SCOPE_MANAGER_MAX_ACTIVE_VIEW_SCOPES

The javax.faces.STATE_SAVING_METHOD defaults to 'server'.

The main question is:

Q1: Is it correct that these OmniFaces @ViewScoped beans can't by design be garbage collected "live" (meaning through say provocation using a Profiler's garbage collectiong action, not waiting until a session is over) ?

Q2: If this is so, how can (should) one best force release of them on navigating away from pages (especially under GET navigations) ?

Q3: If not so (if my results are incorrect because of some other setting) why aren't I witnessing provoked garbage collection of them, and what can I do to ensure they are indeed automatically released ?

Since the test web app is downloadable, well documented and hopefully self-explanatory, I won't give code here, but simply the comparitive results so far, as well as screenshots of the test web app pages in action:


问:
Ionic Storage get not setting a public var
I am trying to set the token i have stored in the storage module of Ionic, to a public variable so i can call it later in the file, however when i try and set it and then call the variable from a different function i get a undefined error

code

```<code>import {HttpClient, HttpHeaders} from '@angular/common/http';
import {Component, Injectable} from '@angular/core';
import { Storage } from "@ionic/storage";
import 'rxjs/add/operator/map';

@Injectable()
@Component({
 providers: [HttpClient]
})
export class DataProvider {
 public token:string;

constructor(public http: HttpClient, public storage: Storage) {
}

 authToken(){
  console.log('token function')
  this.storage.get('token').then((val) => {
   this.token = val;
   console.log(this.token);
  });
 }

 getsomething(){
  let headers = new HttpHeaders();
  headers = headers.set('Content-Type', 'application/json');
  this.authToken();
  console.log(this.token);
 }

}
</code>```

答:
You need authToken() to return a promise, since it's asynchronous your getSomething() will execute authToken() and will not wait for it to finish to execute the following console.log(this.token), that's why it's coming as undefined. There's a couple ways you can work this out:

1 - Just get your token inside of your getsomething()

```<code>getsomething(){
  let headers = new HttpHeaders();
  headers = headers.set('Content-Type', 'application/json');
  this.storage.get('token').then((val) => {
    this.token = val;
    console.log(this.token);
    // THE REMAINING CODE YOU NEED TO EXECUTE
  });
}
</code>```

2 - authToken() returns a promise

```<code>authToken = (): Promise<any> => {
  console.log('token function')
  return new Promise<any>(res => {
    this.storage.get('token').then((val) => {
      this.token = val;
      console.log(this.token);
      res(val);
    });
  });
}

getsomething(){
  let headers = new HttpHeaders();
  headers = headers.set('Content-Type', 'application/json');
  this.authToken().then(res => {
    console.log(this.token);
  });
}
</code>```

3 - Get your token in your constructor (if you've already saved it before)

```<code>constructor(public storage: Storage){
  this.storage.get('token').then((val) => {
    this.token = val;
      console.log(this.token);
  });
}
</code>```

Hope this helps.

Body:
I am trying to set the token i have stored in the storage module of Ionic, to a public variable so i can call it later in the file, however when i try and set it and then call the variable from a different function i get a undefined error

code

import {HttpClient, HttpHeaders} from '@angular/common/http';
import {Component, Injectable} from '@angular/core';
import { Storage } from "@ionic/storage";
import 'rxjs/add/operator/map';

@Injectable()
@Component({
 providers: [HttpClient]
})
export class DataProvider {
 public token:string;

constructor(public http: HttpClient, public storage: Storage) {
}

 authToken(){
  console.log('token function')
  this.storage.get('token').then((val) => {
   this.token = val;
   console.log(this.token);
  });
 }

 getsomething(){
  let headers = new HttpHeaders();
  headers = headers.set('Content-Type', 'application/json');
  this.authToken();
  console.log(this.token);
 }

}

Body:
You need authToken() to return a promise, since it's asynchronous your getSomething() will execute authToken() and will not wait for it to finish to execute the following console.log(this.token), that's why it's coming as undefined. There's a couple ways you can work this out:

1 - Just get your token inside of your getsomething()

getsomething(){
  let headers = new HttpHeaders();
  headers = headers.set('Content-Type', 'application/json');
  this.storage.get('token').then((val) => {
    this.token = val;
    console.log(this.token);
    // THE REMAINING CODE YOU NEED TO EXECUTE
  });
}

2 - authToken() returns a promise

authToken = (): Promise<any> => {
  console.log('token function')
  return new Promise<any>(res => {
    this.storage.get('token').then((val) => {
      this.token = val;
      console.log(this.token);
      res(val);
    });
  });
}

getsomething(){
  let headers = new HttpHeaders();
  headers = headers.set('Content-Type', 'application/json');
  this.authToken().then(res => {
    console.log(this.token);
  });
}

3 - Get your token in your constructor (if you've already saved it before)

constructor(public storage: Storage){
  this.storage.get('token').then((val) => {
    this.token = val;
      console.log(this.token);
  });
}

Hope this helps.


问:
SQL Server: how to change the default value of the ONLINE property for an index?
I need to change the default value for the ONLINE option of almost all of the indexes to ON so that rebuilding an indexes with this script:

```<code>ALTER INDEX [Index1]|ALL ON [Table1] REBUILD;
</code>```

will do the same as:

```<code>ALTER INDEX [Index1]|ALL ON [Table1] REBUILD WITH (ONLINE = ON);
</code>```

I have to do it without recreating the indexes.

However, it is strange that creating an index with this script:

```<code>CREATE NONCLUSTERED INDEX [Index1] ON [Table1]
(
  [Column1] ASC
)
WITH (ONLINE = ON)
</code>```

results in an index with the ONLINE option set on OFF :-??

The fix:

Figured out that this cannot be done. The ONLINE option is not saved anywhere, it affects only the current statement that creates or rebuilds the index, even though some of the options are saved in sys.indexes table.
Not specifying ONLINE option runs the script with the default value OFF.
The fix is to update all rebuild index scripts with explicitly ONLINE option on ON and to make sure it will run on a SQL Server version that supports this (Enterprise and Developer editions) and that will rebuild online only allowed indexes.
The indexes that cannot be rebuild online are:

Disabled clustered index

Disabled indexed view

Image, ntext, text, varchar(max), nvarchar(max), varbinary(max), XML index

Columnstore index

Index on a local temp table

答:
I need to change the default value for the ONLINE property.

ONLINE like SORT_IN_TEMPDB is not an index property, it's just an option of CREATE/ALTER INDEX statement.

So this option affects only the current statement and is not saved in metadata for an index.

Body:
I need to change the default value for the ONLINE option of almost all of the indexes to ON so that rebuilding an indexes with this script:

ALTER INDEX [Index1]|ALL ON [Table1] REBUILD;

will do the same as:

ALTER INDEX [Index1]|ALL ON [Table1] REBUILD WITH (ONLINE = ON);

I have to do it without recreating the indexes.

However, it is strange that creating an index with this script:

CREATE NONCLUSTERED INDEX [Index1] ON [Table1]
(
  [Column1] ASC
)
WITH (ONLINE = ON)

results in an index with the ONLINE option set on OFF :-??

The fix:

Figured out that this cannot be done. The ONLINE option is not saved anywhere, it affects only the current statement that creates or rebuilds the index, even though some of the options are saved in sys.indexes table.
Not specifying ONLINE option runs the script with the default value OFF.
The fix is to update all rebuild index scripts with explicitly ONLINE option on ON and to make sure it will run on a SQL Server version that supports this (Enterprise and Developer editions) and that will rebuild online only allowed indexes.
The indexes that cannot be rebuild online are:

Disabled clustered index

Disabled indexed view

Image, ntext, text, varchar(max), nvarchar(max), varbinary(max), XML index

Columnstore index

Index on a local temp table


问:
How can I use a formula in a for loop in java
I am a beginner java programmer, studying off basic youtube videos and overflow forums, and i came across a question on an textbook sheet that asked me to use a for loop program and print this table out as well as fill in each blank

```<code>Number   Square   Cube   (n+1)/(2n-18)
______________________________________
1         #        #          #
2         #        #          #
3         #        #          #
4         #        #          #
5         #        #          #
</code>```

I thought I should try it out to test myself. I came up with the following program that works perfectly for the Number, Square and Cube part of the table, but I don't understand how to generate the numbers using the given formula. The formula I initialized as a variable (double) doesn't print the actual results, and I honestly don't have a clue as to what to do. I'd rather a simple explanation than a complex one and simple changes to the code rather than complex. As I said I am a beginner, and many different methods may go right over my head. Thank you so much in advance (also an extra task asks that I print out the sums of each column. I don't know how to do that at all, and would like an explanation if possible, but wouldn't mind if I don't receive one)

```<code>int number;
int maxValue;

Scanner keyboard = new Scanner(System.in);
System.out.println("how many numbers do you want the max value to be");
maxValue = keyboard.nextInt();

System.out.println("Number\tSquare\tCube (n+1)/(2n-18)");
System.out.println("--------------------------------");
for (number = 1; number <= maxValue; number++) {
    double formula = (number + 1) / (number * 2);
    System.out.println(
        number + "\t\t\t" + number * number + "\t\t\t" +
        number * number * number + "\t\t\t" + formula);
}
</code>```

答:
Your formula is not correct and you are missing few \t.</p>

```<code>    int number;
    int maxValue;

    Scanner keyboard = new Scanner(System.in);
    System.out.println("how many numbers do you want the max value to be");
    maxValue = keyboard.nextInt();

    System.out.println("Number\t\tSquare\t\tCube \t\t(n+1)/(2n-18)");
    System.out.println("-------------------------------------------------------");
    for (number = 1; number <= maxValue; number++) {
        double formula = (number + 1) / (number * 2 - 18);
        System.out
                .println(number + "\t\t" + number * number + "\t\t" + number * number * number + "\t\t" + formula);

    }
</code>```

Body:
I am a beginner java programmer, studying off basic youtube videos and overflow forums, and i came across a question on an textbook sheet that asked me to use a for loop program and print this table out as well as fill in each blank

Number   Square   Cube   (n+1)/(2n-18)
______________________________________
1         #        #          #
2         #        #          #
3         #        #          #
4         #        #          #
5         #        #          #

I thought I should try it out to test myself. I came up with the following program that works perfectly for the Number, Square and Cube part of the table, but I don't understand how to generate the numbers using the given formula. The formula I initialized as a variable (double) doesn't print the actual results, and I honestly don't have a clue as to what to do. I'd rather a simple explanation than a complex one and simple changes to the code rather than complex. As I said I am a beginner, and many different methods may go right over my head. Thank you so much in advance (also an extra task asks that I print out the sums of each column. I don't know how to do that at all, and would like an explanation if possible, but wouldn't mind if I don't receive one)

int number;
int maxValue;

Scanner keyboard = new Scanner(System.in);
System.out.println("how many numbers do you want the max value to be");
maxValue = keyboard.nextInt();

System.out.println("Number\tSquare\tCube (n+1)/(2n-18)");
System.out.println("--------------------------------");
for (number = 1; number <= maxValue; number++) {
    double formula = (number + 1) / (number * 2);
    System.out.println(
        number + "\t\t\t" + number * number + "\t\t\t" +
        number * number * number + "\t\t\t" + formula);
}

Body:
Your formula is not correct and you are missing few \t.

    int number;
    int maxValue;

    Scanner keyboard = new Scanner(System.in);
    System.out.println("how many numbers do you want the max value to be");
    maxValue = keyboard.nextInt();

    System.out.println("Number\t\tSquare\t\tCube \t\t(n+1)/(2n-18)");
    System.out.println("-------------------------------------------------------");
    for (number = 1; number <= maxValue; number++) {
        double formula = (number + 1) / (number * 2 - 18);
        System.out
                .println(number + "\t\t" + number * number + "\t\t" + number * number * number + "\t\t" + formula);

    }