问:
How to make a loop or "sum" formula in Microsoft Excel?
Say that I gain +5 coins from every room I complete. What I'm trying to do is to make a formula in Excel that gets the total coins I've gotten from the first room to the 100th room.

With C++, I guess it would be something like:

```<code>while (lastRoom > 0)
{
totalCoins = lastRoom*5;
lastRoom--;
}
</code>```

totalCoins, being an array so that you can just output the sum of the array.

So if ever, how do you put this code in excel and get it to work? Or is there any other way to get the total coins?

答:
The are infinite solutions.
One is to build a table like this:

```<code>+---+----------+---------------+
|   |    A     |       B       |
+---+----------+---------------+
| 1 | UserID   | RoomCompleted |
| 2 | User 001 | Room 1        |
| 3 | User 002 | Room 1        |
| 4 | User 002 | Room 2        |
| 5 | User 002 | Room 3        |
+---+----------+---------------+
</code>```

them pivot the spreadsheet to get the following:

```<code>+---+----------+-----------------------+
|   |    A     |           B           |
+---+----------+-----------------------+
| 1 | User     | Total Rooms completed |
| 2 | User 001 | 1                     |
| 3 | User 002 | 3                     |
+---+----------+-----------------------+
</code>```

where you have the number of completed rooms for each users. You can now multiplicate the number per 5 as a simple formula or (better) as a calculated filed of the pivot.

Body:
Say that I gain +5 coins from every room I complete. What I'm trying to do is to make a formula in Excel that gets the total coins I've gotten from the first room to the 100th room.

With C++, I guess it would be something like:

while (lastRoom > 0)
{
totalCoins = lastRoom*5;
lastRoom--;
}

totalCoins, being an array so that you can just output the sum of the array.

So if ever, how do you put this code in excel and get it to work? Or is there any other way to get the total coins?

Body:
The are infinite solutions.
One is to build a table like this:

+---+----------+---------------+
|   |    A     |       B       |
+---+----------+---------------+
| 1 | UserID   | RoomCompleted |
| 2 | User 001 | Room 1        |
| 3 | User 002 | Room 1        |
| 4 | User 002 | Room 2        |
| 5 | User 002 | Room 3        |
+---+----------+---------------+

them pivot the spreadsheet to get the following:

+---+----------+-----------------------+
|   |    A     |           B           |
+---+----------+-----------------------+
| 1 | User     | Total Rooms completed |
| 2 | User 001 | 1                     |
| 3 | User 002 | 3                     |
+---+----------+-----------------------+

where you have the number of completed rooms for each users. You can now multiplicate the number per 5 as a simple formula or (better) as a calculated filed of the pivot.


来源: stackexchange

问:
SQL SELECT various names by various id's
I have this 3 tables:

main table:

```<code>  ID | OtherStuff1 | OtherStuff2 | IdProvince | IdTown
-----+-------------+-------------+------------+--------
   1 |   Stuff1    |   Stuff2    |      1     |   1
</code>```

province table:

```<code>ID | ProvinceName
---+--------------
 1 |  ProvName1
</code>```

town table:

```<code>ID |   TownName
---+--------------
 1 |   TwName1
</code>```

Obviously the main table has foreign relationships with the province table and the town table.

The result I want is this one:

```<code>ID | OtherStuff1 | OtherStuff2 | IdProvince |   IdTown
---+-------------+-------------+------------+------------
 1 |   Stuff1    |   Stuff2    | ProvName1  |   TwName1
</code>```

I want to show the main table but with the names instead of the ID's.

I looked up other questions and I tried this one:

```<code>    SELECT *
        FROM main AS a
        INNER JOIN province AS b
        INNER JOIN town AS c
        WHERE a.IdProvince = b.ProvinceName
        AND a.IdTown = c.TownName

    AND Id=1; # this is added by me because I want to filter by id on the
              # main table, I don't want all the rows, just one filtered by ID.
</code>```

And this other one:

```<code> SELECT *
       FROM main AS a,
       INNER JOIN province AS b ON a.IdProvince = b.ProvinceName
       INNER JOIN town AS c ON a.IdTown = c.TownName
       WHERE Id=1;
</code>```

Also I would like that the query could be easy to use in the way that If I have the same problem, but instead of the main table and 2 tables, I have main table and 4 tables I could also use it just adding more "INNER JOINS" for example?

I'm trying to do this but I couldn't get it right, I get this Sql wrong every time and I don't find the correct way to do this, any ideas?

I'm using PDO and I show this on a web page.

"AND Id=1" --> this will be used like this --> "AND Id=:filterID".

I hope I explained myself right!

If you have any doubts just ask, I'll answer as fast as I can!

Thanks in advance!

---------------------------------------------------------------EDIT--------------------------------------------------------------

I already tryed the 3 answers I got and it doesn't work, I don't know why, I will add images to back up so you see.

This one works with no errors but I get no info back

```<code>SELECT a.Id, OtherStuff1, OtherStuff2, IdProvince, IdTown
 FROM main AS a
 INNER JOIN province AS b
 INNER JOIN town AS c
   WHERE a.IdProvince = b.ProvinceName
   AND a.IdTown = c.TownName
AND a.Id=1
</code>```

This is the result

This one the same and no info back, but anyways I get extra columns from the other tables that I don't need there.

```<code>SELECT *
 FROM main AS a ,province AS b , town AS c
  WHERE a.IdProvince = b.ProvinceName
  AND a.IdTown = c.TownName
AND a.Id=1
</code>```

This is the second result

I also tryed this one but I can't get it to work always shows me an error

```<code>SELECT *
   FROM
      (main AS a
      INNER JOIN province AS b ON a.IdProvince = b.ProvinceName) AS d
      INNER JOIN town AS c ON d.IdTown = c.TownName
   WHERE
      Id=1
</code>```

I can't post more than 2 photos because I don't have enough reputation but I paste the error here:

```<code>MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'd
      INNER JOIN town AS c ON d.IdTown = c.TownName
   WHERE
      Id=1 LI' at line 4
</code>```

And in case you ask or doubt, I did put the info in the tables, 1 row each so there is something in, but for some reason it doesn't gives me back that info.

-------------------------------------------------------LAST EDIT-------------------------------------------------------------

The 3 codes worked for me after trying them with a few edits, here are the 3 codes so people who might read this find this helpful.

```<code>ID | ProvinceName
---+--------------
 1 |  ProvName1
</code>```0

```<code>ID | ProvinceName
---+--------------
 1 |  ProvName1
</code>```1

```<code>ID | ProvinceName
---+--------------
 1 |  ProvName1
</code>```2

Thanks a lot to the people who have helped me!

答:
I think you are just using a wrong SQL syntax on the second guess.

Try this instead:

```<code>SELECT *
   FROM
      main AS a INNER JOIN (province AS b, town AS c)
      ON (a.IdProvince = b.Id AND a.IdTown = c.Id)
      WHERE
      a.Id=1;
</code>```

The first guess is by the way old syntax and should not be used.

Edit: adapted to MariaDB Syntax

ContentLicense: CC BY-SA 3.0

Body:
I have this 3 tables:

main table:

  ID | OtherStuff1 | OtherStuff2 | IdProvince | IdTown
-----+-------------+-------------+------------+--------
   1 |   Stuff1    |   Stuff2    |      1     |   1

province table:

ID | ProvinceName
---+--------------
 1 |  ProvName1

town table:

ID |   TownName
---+--------------
 1 |   TwName1

Obviously the main table has foreign relationships with the province table and the town table.

The result I want is this one:

ID | OtherStuff1 | OtherStuff2 | IdProvince |   IdTown
---+-------------+-------------+------------+------------
 1 |   Stuff1    |   Stuff2    | ProvName1  |   TwName1

I want to show the main table but with the names instead of the ID's.

I looked up other questions and I tried this one:

    SELECT *
        FROM main AS a
        INNER JOIN province AS b
        INNER JOIN town AS c
        WHERE a.IdProvince = b.ProvinceName
        AND a.IdTown = c.TownName

    AND Id=1; # this is added by me because I want to filter by id on the
              # main table, I don't want all the rows, just one filtered by ID.

And this other one:

 SELECT *
       FROM main AS a,
       INNER JOIN province AS b ON a.IdProvince = b.ProvinceName
       INNER JOIN town AS c ON a.IdTown = c.TownName
       WHERE Id=1;

Also I would like that the query could be easy to use in the way that If I have the same problem, but instead of the main table and 2 tables, I have main table and 4 tables I could also use it just adding more "INNER JOINS" for example?

I'm trying to do this but I couldn't get it right, I get this Sql wrong every time and I don't find the correct way to do this, any ideas?

I'm using PDO and I show this on a web page.

"AND Id=1" --> this will be used like this --> "AND Id=:filterID".

I hope I explained myself right!

If you have any doubts just ask, I'll answer as fast as I can!

Thanks in advance!

---------------------------------------------------------------EDIT--------------------------------------------------------------

I already tryed the 3 answers I got and it doesn't work, I don't know why, I will add images to back up so you see.

This one works with no errors but I get no info back

SELECT a.Id, OtherStuff1, OtherStuff2, IdProvince, IdTown
 FROM main AS a
 INNER JOIN province AS b
 INNER JOIN town AS c
   WHERE a.IdProvince = b.ProvinceName
   AND a.IdTown = c.TownName
AND a.Id=1

This is the result

This one the same and no info back, but anyways I get extra columns from the other tables that I don't need there.

SELECT *
 FROM main AS a ,province AS b , town AS c
  WHERE a.IdProvince = b.ProvinceName
  AND a.IdTown = c.TownName
AND a.Id=1

This is the second result

I also tryed this one but I can't get it to work always shows me an error

SELECT *
   FROM
      (main AS a
      INNER JOIN province AS b ON a.IdProvince = b.ProvinceName) AS d
      INNER JOIN town AS c ON d.IdTown = c.TownName
   WHERE
      Id=1

I can't post more than 2 photos because I don't have enough reputation but I paste the error here:

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'd
      INNER JOIN town AS c ON d.IdTown = c.TownName
   WHERE
      Id=1 LI' at line 4

And in case you ask or doubt, I did put the info in the tables, 1 row each so there is something in, but for some reason it doesn't gives me back that info.

-------------------------------------------------------LAST EDIT-------------------------------------------------------------

The 3 codes worked for me after trying them with a few edits, here are the 3 codes so people who might read this find this helpful.

SELECT a.Id, OtherStuff1, OtherStuff2, ProvinceName, TownName
    FROM main AS a
    INNER JOIN province AS b ON a.IdProvince = b.Id
    INNER JOIN town AS c ON a.IdTown = c.Id
    WHERE a.Id=1;

SELECT a.Id, OtherStuff1, OtherStuff2, ProvinceName, TownName
    FROM main AS a
    INNER JOIN (province AS b, town AS c)
    ON (a.IdProvince = b.Id AND a.IdTown = c.Id)
    WHERE a.Id=1;

SELECT a.Id, OtherStuff1, OtherStuff2, ProvinceName, TownName
    FROM main AS a ,province AS b , town AS c
    WHERE a.IdProvince = b.Id
    AND a.IdTown = c.Id
    AND a.Id=1;

Thanks a lot to the people who have helped me!

Body:
I think you are just using a wrong SQL syntax on the second guess.

Try this instead:

SELECT *
   FROM
      main AS a INNER JOIN (province AS b, town AS c)
      ON (a.IdProvince = b.Id AND a.IdTown = c.Id)
      WHERE
      a.Id=1;

The first guess is by the way old syntax and should not be used.

Edit: adapted to MariaDB Syntax


问:
compile scala-spark file to jar file
Im working on a project of frequent item sets, and I use the Algorithm FP-Growth, I depend on the version developed in Scala-Spark

https://github.com/apache/spark/blob/v2.1.0/mllib/src/main/scala/org/apache/spark/mllib/fpm/FPGrowth.scala

I need to modify this code and recompile it to have a jar file that I can include it to Spark-shell , and call its functions in spark

the problem s that spark-shell is un interpreter , and it finds errors in this file, Ive tried Sbt with eclipse but it did not succeded .
what i need is compiler that can use the last version of scala and spark-shel libraries to compile this file to jar file.

答:
Follow this steps:

check out Spark repository

modify files to want to modify

build project

run ./dev/make-distribution.sh script, which is inside Spark repository

run Spark Shell from your Spark distribution

Title: compile scala-spark file to jar file


答:
You can use lead/lag windowing function. It works from SQL Server2012 onwards... Before that you need to do self join with genereated row_number

```<code>select Reference, ModifiedDate as StartDate,
    lead(ModifiedDate, 1, '9999-12-31 00:00:00.000') over(order by Reference) as EndDate
    from #yourreference
</code>```

Table details

```<code>create table #yourreference (Reference int, ModifiedDate datetime)

insert into #yourreference (
Reference ,  ModifiedDate ) values
 (1023175   ,'2017-03-03 16:02:01.723')
,(1023175   ,'2017-03-07 07:59:49.283')
,(1023175   ,'2017-03-12 11:14:40.230')
</code>```

Title: Complex SQL transformation

Body:
This is my source table

Reference   ModifiedDate
------------------------------------
1023175     2017-03-03 16:02:01.723
1023175     2017-03-07 07:59:49.283
1023175     2017-03-12 11:14:40.230

Ineed the following output

Reference   StartDate                 EndDate
---------------------------------------------
1023175   2017-03-03 16:02:01.723     2017-03-07 07:59:49.283
1023175   2017-03-07 07:59:49.283     2017-03-12 11:14:40.230
1023175   2017-03-12 11:14:40.230     9999-12-31 00:00:00.000 (last record should have this value)

Any suggestions on how this can be achieved?

Body:
You can use lead/lag windowing function. It works from SQL Server2012 onwards... Before that you need to do self join with genereated row_number

select Reference, ModifiedDate as StartDate,
    lead(ModifiedDate, 1, '9999-12-31 00:00:00.000') over(order by Reference) as EndDate
    from #yourreference

Table details

create table #yourreference (Reference int, ModifiedDate datetime)

insert into #yourreference (
Reference ,  ModifiedDate ) values
 (1023175   ,'2017-03-03 16:02:01.723')
,(1023175   ,'2017-03-07 07:59:49.283')
,(1023175   ,'2017-03-12 11:14:40.230')


问:
Cannot uninstall angular-cli
I've tried several times to uninstall my angular-cli in order to update it but even if I follow the instructions provided on github:

npm uninstall -g @angular/cli

npm cache clean

npm install -g @angular/cli@latest

When I check using the command ng --version I still get the old version :

```<code> angular-cli: 1.0.0-beta.26

 node: 7.7.1
 os: darwin x64
</code>```

How can i fix this issue? Thanks

答:
I had the same problem. This doesn't work:

```<code>npm uninstall -g angular/cli
npm cache clean
</code>```

instead use:

```<code>npm uninstall -g @ angular/cli
</code>```

Title: Cannot uninstall angular-cli

Body:
I've tried several times to uninstall my angular-cli in order to update it but even if I follow the instructions provided on github:

npm uninstall -g @angular/cli

npm cache clean

npm install -g @angular/cli@latest

When I check using the command ng --version I still get the old version :

 angular-cli: 1.0.0-beta.26

 node: 7.7.1
 os: darwin x64

How can i fix this issue? Thanks

Body:
I had the same problem. This doesn't work:

npm uninstall -g angular/cli
npm cache clean

instead use:

npm uninstall -g @ angular/cli


问:
Visual Studio 2015 diagnostic tools no longer working
I have Visual Studio 2015 Community Edition Update 3 running on Windows 7 SP1 64 bit, which I use to develop C# applications.

I love the diagnostic tools during debugging to spot performance problems early on. However, they stopped working for me sometime in the last month or so (possibly related to installing Update 3, although I have no information to back that up). I see the error message "CPU Profiling while debugging is not available on this version of Windows. To see CPU usage details, run the CPU Usage tool without the debugger (Debug -> Performance Profiler...)."

Things I have tried without success:

Completely uninstalling and reinstalling VS.

Performing a repair on my VS installation

Ensuring "Use {Managed,Native} compatability mode" is disabled in debug options.

Enabling the Diagnostics Hub logging info as described in this question. No error messages that I can see appear in the logs.

This still happens even if I create a new WPF project, so I don't believe it has any project-specific cause.

Are there any other things I can try? Obviously they were working before, so I don't believe the error message about my version of Windows being unsupported.

答: I had the same issue, although deleting the .suo file did not help, I also repaired Visual Studio 2015 Professional and then it worked. So for future readers, if deleting the .suo does not help, try to also repair Visual Studio and vice versa.</p>


问:
Fork off more processes as previous finish, until max is reached
To fork off X processes and have the parent wait for all, I have the following code:

```<code>int maxProcesses = 10;

for (int currentChild = 0; currentChild < maxProcesses; currentChild++) {
    pid_t pid = fork();

    if (pid < 0) {
        // Error
    } else if (pid == 0) {
        // Child
    } else {
        // Parent
        // Should I call waitpid on pid and wait here instead?
    }
}

// Wait for all children
for (int currentChild = 0; currentChild < maxProcesses; currentChild++) {
    wait(NULL);
}
</code>```

Now I would like to modify the code so that of X total processes, Y are forked off first, and then as they finish, more forks are made till desired total number is reached. I have made some changes to the above code, with some questions.

```<code>int totalProcessesToBeForked = 10;
int maxAllowedAtOnce = 5;

for (int currentChild = 0; currentChild < maxAllowedAtOnce; currentChild++) {
    forkChild(currentChild);
}

// Wait for all children
// # How do I modify this to wait for new children forked as well
// # if I move it inside parent, it will make things easier, right?
for (int currentChild = 0; currentChild < maxAllowedAtOnce; currentChild++) {
    wait(NULL);
}

void forkChild(currentChild) {
    pid_t pid = fork();

    if (pid < 0) {
        // Error
    } else if (pid == 0) {
        // Child
    } else {
        // Parent
        // # I think waiting here using waitpid will be better b/c
        // # as new forks are made, parent begins to wait for them
    }
}
</code>```

I will probably need to keep a count of how many children have been forked and compare it to totalProcessesToBeForked, and fork new ones accordingly.

Updated Code v1:

```<code>int maxProcesses = 10;
int maxAllowedAtOnce = 5;

int main(int argc, char* argv[]) {
    // Start timer
    alarm(10);                  // Terminate after 10s
    signal(SIGALRM, onTimeout);
    signal(SIGCHLD, catchChild);

    for (int currentChild = 0; currentChild < maxAllowedAtOnce; currentChild++) {
        forkChild(currentChild);
    }

    // # This sections runs immediately before death of any child is reported
    // # and starts cleanup processes, thus killing any/all running children

    // Completed before timeout
    endTimer = true;
    int timeRemaining = alarm(0);
    if (timeRemaining > 0) {
        printf("\nCompleted w/ %is remaining. Performing cleanup.\n", timeRemaining);

        // Kill children any running child processes, cleanup
        cleanup();
    }

    return 0;
}

void forkChild(currentChild) {
    pid_t pid = fork();

    if (pid < 0) {
        // Error
    } else if (pid == 0) {
        // Child
        execl("/bin/date", "date", 0, 0);
    } else {
        // Parent
        printf("#Log: Started %i.\n", currentChild + 1);
    }
}

void catchChild(int sig) {
    pid_t p;
    int state;
    p=wait(&state);
    printf("Got child %d\n",p);
}

void cleanup() {
    // Cleanup Code
}
</code>```

Example Run:

Edit #2:
http://ideone.com/noUs3m

答:
Instead of using wait as you have done, you want to look into signal handling to handle the child processes dying.

You add before you start forking, this line

```<code>signal(SIGCHLD,catchchild);
</code>```

and this function to your code

```<code>void catchchild(int sig)
  {
  pid_t p;
  int state;
  p=wait(&state);
  printf("Got child %d\n",p);
  }
</code>```

and then whenever a child process dies, your main process will call catchchild.

As you've already worked out, if you have a count of how many children that have been forked, you could have catchchild update that so that your main code will know to fork a new child.

To answer your comment something like the following, except with more error checking

```<code>while(totalProcessesToBeForked)
  {
  if(currentChild < maxAllowedAtOnce)
    {
    forkChild(currentChild);
    totalProcessesToBeForked--;
    }
  sleep(1);
  }
</code>```

Body:
To fork off X processes and have the parent wait for all, I have the following code:

int maxProcesses = 10;

for (int currentChild = 0; currentChild < maxProcesses; currentChild++) {
    pid_t pid = fork();

    if (pid < 0) {
        // Error
    } else if (pid == 0) {
        // Child
    } else {
        // Parent
        // Should I call waitpid on pid and wait here instead?
    }
}

// Wait for all children
for (int currentChild = 0; currentChild < maxProcesses; currentChild++) {
    wait(NULL);
}

Now I would like to modify the code so that of X total processes, Y are forked off first, and then as they finish, more forks are made till desired total number is reached. I have made some changes to the above code, with some questions.

int totalProcessesToBeForked = 10;
int maxAllowedAtOnce = 5;

for (int currentChild = 0; currentChild < maxAllowedAtOnce; currentChild++) {
    forkChild(currentChild);
}

// Wait for all children
// # How do I modify this to wait for new children forked as well
// # if I move it inside parent, it will make things easier, right?
for (int currentChild = 0; currentChild < maxAllowedAtOnce; currentChild++) {
    wait(NULL);
}

void forkChild(currentChild) {
    pid_t pid = fork();

    if (pid < 0) {
        // Error
    } else if (pid == 0) {
        // Child
    } else {
        // Parent
        // # I think waiting here using waitpid will be better b/c
        // # as new forks are made, parent begins to wait for them
    }
}

I will probably need to keep a count of how many children have been forked and compare it to totalProcessesToBeForked, and fork new ones accordingly.

Updated Code v1:

int maxProcesses = 10;
int maxAllowedAtOnce = 5;

int main(int argc, char* argv[]) {
    // Start timer
    alarm(10);                  // Terminate after 10s
    signal(SIGALRM, onTimeout);
    signal(SIGCHLD, catchChild);

    for (int currentChild = 0; currentChild < maxAllowedAtOnce; currentChild++) {
        forkChild(currentChild);
    }

    // # This sections runs immediately before death of any child is reported
    // # and starts cleanup processes, thus killing any/all running children

    // Completed before timeout
    endTimer = true;
    int timeRemaining = alarm(0);
    if (timeRemaining > 0) {
        printf("\nCompleted w/ %is remaining. Performing cleanup.\n", timeRemaining);

        // Kill children any running child processes, cleanup
        cleanup();
    }

    return 0;
}

void forkChild(currentChild) {
    pid_t pid = fork();

    if (pid < 0) {
        // Error
    } else if (pid == 0) {
        // Child
        execl("/bin/date", "date", 0, 0);
    } else {
        // Parent
        printf("#Log: Started %i.\n", currentChild + 1);
    }
}

void catchChild(int sig) {
    pid_t p;
    int state;
    p=wait(&state);
    printf("Got child %d\n",p);
}

void cleanup() {
    // Cleanup Code
}

Example Run:

Edit #2:
http://ideone.com/noUs3m

Body:
Instead of using wait as you have done, you want to look into signal handling to handle the child processes dying.

You add before you start forking, this line

signal(SIGCHLD,catchchild);

and this function to your code

void catchchild(int sig)
  {
  pid_t p;
  int state;
  p=wait(&state);
  printf("Got child %d\n",p);
  }

and then whenever a child process dies, your main process will call catchchild.

As you've already worked out, if you have a count of how many children that have been forked, you could have catchchild update that so that your main code will know to fork a new child.

To answer your comment something like the following, except with more error checking

while(totalProcessesToBeForked)
  {
  if(currentChild < maxAllowedAtOnce)
    {
    forkChild(currentChild);
    totalProcessesToBeForked--;
    }
  sleep(1);
  }


问:
Efficient nested looping with pandas dataframe
I have a simple panda dataframe like this one:

```<code>d = {'col1': ['a','b','c','d','e'], 'col2': [1,2,3,4,5]}
df = pd.DataFrame(d)
df
  col1  col2
0    a     1
1    b     2
2    c     3
3    d     4
4    e     5
</code>```

And I would need to iterate over it and to get a simple arithmetic results (like a product or so) for all combination of row values. I was thinking to make a matrix and put the values in, like this:

```<code>size = df.shape[0]
mtx = np.zeros(shape=(size, size))
mtx
array([[ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.]])
</code>```

But I somehow 'sense' there is more efficient way to do this than nested looping, like this:

```<code>for index1, c11, c12, in df.itertuples():
    for index2, c21, c22 in df.itertuples():
        mtx[index1][index2] = float(c12) * float(c22)

mtx
array([[  1.,   2.,   3.,   4.,   5.],
       [  2.,   4.,   6.,   8.,  10.],
       [  3.,   6.,   9.,  12.,  15.],
       [  4.,   8.,  12.,  16.,  20.],
       [  5.,  10.,  15.,  20.,  25.]])
</code>```

Any idea will be much appreciated! Thanks!

答:
For oprations like *,+,-,/ you can do the following: (this example is for *, but you can just change the operation in the last row if you want +,- or /)

```<code>import numpy as np
import pandas as pd
d = {'col1': ['a','b','c','d','e'], 'col2': [1,2,3,4,5]}
df = pd.DataFrame(d)
a=np.array([df.col2.tolist()])
a.T*a
</code>```

The result is:

```<code>array([[ 1,  2,  3,  4,  5],
   [ 2,  4,  6,  8, 10],
   [ 3,  6,  9, 12, 15],
   [ 4,  8, 12, 16, 20],
   [ 5, 10, 15, 20, 25]], dtype=int64)
</code>```

Change a.T*a to a.T+a for pairwise sum, and to a.T-a for pairwise difference. If you want pairwise division, you can change it into a.T/a, but remember to include the line a=a.astype(float) above the operation.

Body:
I have a simple panda dataframe like this one:

d = {'col1': ['a','b','c','d','e'], 'col2': [1,2,3,4,5]}
df = pd.DataFrame(d)
df
  col1  col2
0    a     1
1    b     2
2    c     3
3    d     4
4    e     5

And I would need to iterate over it and to get a simple arithmetic results (like a product or so) for all combination of row values. I was thinking to make a matrix and put the values in, like this:

size = df.shape[0]
mtx = np.zeros(shape=(size, size))
mtx
array([[ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.]])

But I somehow 'sense' there is more efficient way to do this than nested looping, like this:

for index1, c11, c12, in df.itertuples():
    for index2, c21, c22 in df.itertuples():
        mtx[index1][index2] = float(c12) * float(c22)

mtx
array([[  1.,   2.,   3.,   4.,   5.],
       [  2.,   4.,   6.,   8.,  10.],
       [  3.,   6.,   9.,  12.,  15.],
       [  4.,   8.,  12.,  16.,  20.],
       [  5.,  10.,  15.,  20.,  25.]])

Any idea will be much appreciated! Thanks!

Body:
For oprations like *,+,-,/ you can do the following: (this example is for *, but you can just change the operation in the last row if you want +,- or /)

import numpy as np
import pandas as pd
d = {'col1': ['a','b','c','d','e'], 'col2': [1,2,3,4,5]}
df = pd.DataFrame(d)
a=np.array([df.col2.tolist()])
a.T*a

The result is:

array([[ 1,  2,  3,  4,  5],
   [ 2,  4,  6,  8, 10],
   [ 3,  6,  9, 12, 15],
   [ 4,  8, 12, 16, 20],
   [ 5, 10, 15, 20, 25]], dtype=int64)

Change a.T*a to a.T+a for pairwise sum, and to a.T-a for pairwise difference. If you want pairwise division, you can change it into a.T/a, but remember to include the line a=a.astype(float) above the operation.


问:
Raw SQL 'Insert Into' in ASP MVC
i'm trying to insert data from a form into two tables in db.

```<code>public ActionResult Cr([Bind(Include = "id,name,time")] appointment appointment, [Bind(Include = "pid,phone")] customer customer , string submit)
        {
        string str1 = "Insert Into appointment.id, appointment.name, appointment.time Values id,name,time"
        string str2= "Insert Into customer.pid, customer.phone Values pid,phone"
        var Query = dbb.Database.SqlQuery<ViewModel.custapp>(str1).ToList();
        var Query = dbb.Database.SqlQuery<ViewModel.custapp>(str2).ToList();
        return View("Index");
        }
</code>```

I am not sure if my code is wrong but the data are not inserted in the tables.

答:
since you are inserting the data your code should be like this

```<code>var sql = @"Insert Into appointment (name, time) Values (@name, @time)";
int noOfRowInserted = dbcontext.Database.ExecuteSqlCommand(sql,
    new SqlParameter("@name", appointment.name),
    new SqlParameter("@time", appointment.time));
</code>```

i used parameters to prevent sql injection and SqlQuery<entity> this command is used when you are returning some data which will be of type entity but in your case you are inserting data. for further information check this
RAW SQL QUERY

Title: Raw SQL 'Insert Into' in ASP MVC

Body:
i'm trying to insert data from a form into two tables in db.

public ActionResult Cr([Bind(Include = "id,name,time")] appointment appointment, [Bind(Include = "pid,phone")] customer customer , string submit)
        {
        string str1 = "Insert Into appointment.id, appointment.name, appointment.time Values id,name,time"
        string str2= "Insert Into customer.pid, customer.phone Values pid,phone"
        var Query = dbb.Database.SqlQuery<ViewModel.custapp>(str1).ToList();
        var Query = dbb.Database.SqlQuery<ViewModel.custapp>(str2).ToList();
        return View("Index");
        }

I am not sure if my code is wrong but the data are not inserted in the tables.

Body:
since you are inserting the data your code should be like this

var sql = @"Insert Into appointment (name, time) Values (@name, @time)";
int noOfRowInserted = dbcontext.Database.ExecuteSqlCommand(sql,
    new SqlParameter("@name", appointment.name),
    new SqlParameter("@time", appointment.time));

i used parameters to prevent sql injection and SqlQuery<entity> this command is used when you are returning some data which will be of type entity but in your case you are inserting data. for further information check this
RAW SQL QUERY


问:
How To Resize A Div & Keep The Aspect Ratio
I have a div that will have a background image of the size 1170px x 929px. As I resize the width i.e. shrink it, I would like the height to also shrink so that the aspect ratio is kept. Can someone explain how this can be done using CSS? All I have so far is the following

```<code><section class="box">
            <article class="container ">
                <div class="content margin_tp_80 margin_bm_40 map_london">
                </div>
            </article>
        </section>
</code>```

Any help would be great thanks.

答:
Bootstrap has class which will do it for you.</p>

```<code><img class="d-block img-fluid" src="https://healthintelasia.com/wp-content/uploads/2013/09/asia-1500-X-600-banner.jpg" alt="First slide">
</code>```

Body:
I have a div that will have a background image of the size 1170px x 929px. As I resize the width i.e. shrink it, I would like the height to also shrink so that the aspect ratio is kept. Can someone explain how this can be done using CSS? All I have so far is the following

Any help would be great thanks.

Body:
Bootstrap has class which will do it for you.

<img class="d-block img-fluid" src="https://healthintelasia.com/wp-content/uploads/2013/09/asia-1500-X-600-banner.jpg" alt="First slide">


问:
How to get a call to the controller when the selectbox is changed?
When the selectbox, with countries are changed, I want to put the name of the capital of the country in the Where field. How can I setup this to get a call back to the controller when the country is changed?

```<code><div class="well">
    <form method="post" asp-action="Jobs" asp-antiforgery="true">
        <div class="form-inline">
            <div class="input-group">
                <span class="input-group-addon">@Localizer["Country"]</span>
                <select class="form-control" asp-for="CountryCode" asp-items="ViewBag.Countries" value="@Model.CountryCode">
                    <option disabled selected value="">@Localizer["ChooseCountry"]</option>
                </select>
           </div>
            <div class="input-group">
                <span class="input-group-addon">@Localizer["Where"]</span>
                <input asp-for="Where" class="form-control" placeholder=@Localizer["EnterCityToSearch"] value="@Model.Where"/>
            </div>
            <div class="input-group">
                <span class="input-group-addon">@Localizer["What"]</span>
                <input asp-for="What" class="form-control" placeholder="@Localizer["EnterTypeOfJob"]" value=@Model.What>
            </div>
            <button type="submit" class="btn btn-primary">
                @Localizer["Search"]
                <span class="glyphicon glyphicon-search"></span>
            </button>
        </div>
    </form>
    @*<a  class="text" role="button" asp-action="ChangeSearchMetode" asp-antiforgery="true">Link Button</a>*@
 </div>
</code>```

Thanks for helping!

答:
I assume that you are using Jquery as well. You can achieve this as:

```<code>$("#CountryCode").on('change', function(){

      $.ajax({
            url: 'controller action url here'
            type: "POST",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify({ Id: $("#CountryCode").val()}),
            cache: false,
            async: true,
            success: function(data) {
                //now u have data. set it where and as u want
            },
            error: function() {
                //your exceptional handler
            }
       });
});
</code>```

I'm assuming that your controller action is expecting a paramater with the name Id. The above ajax function will hit your controller action method. In controller, you should return your data in json and use it in success function of your ajax call

Body:
When the selectbox, with countries are changed, I want to put the name of the capital of the country in the Where field. How can I setup this to get a call back to the controller when the country is changed?

    <form method="post" asp-action="Jobs" asp-antiforgery="true">

                @Localizer["Country"]
                <select class="form-control" asp-for="CountryCode" asp-items="ViewBag.Countries" value="@Model.CountryCode">
                    <option disabled selected value="">@Localizer["ChooseCountry"]</option>
                </select>

                @Localizer["Where"]
                <input asp-for="Where" class="form-control" placeholder=@Localizer["EnterCityToSearch"] value="@Model.Where"/>

                @Localizer["What"]
                <input asp-for="What" class="form-control" placeholder="@Localizer["EnterTypeOfJob"]" value=@Model.What>

            <button type="submit" class="btn btn-primary">
                @Localizer["Search"]

            </button>

    </form>
    @*Link Button*@

Thanks for helping!

Body:
I assume that you are using Jquery as well. You can achieve this as:

$("#CountryCode").on('change', function(){

      $.ajax({
            url: 'controller action url here'
            type: "POST",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify({ Id: $("#CountryCode").val()}),
            cache: false,
            async: true,
            success: function(data) {
                //now u have data. set it where and as u want
            },
            error: function() {
                //your exceptional handler
            }
       });
});

I'm assuming that your controller action is expecting a paramater with the name Id. The above ajax function will hit your controller action method. In controller, you should return your data in json and use it in success function of your ajax call


问:
Text justification in android
I know that this question have been asked previously. Some are:

Android TextView Justify Text

Can I set property of Textview like justify?

But after passing some years(!) there is no good solution for this. Using third-party libraries is not a good solution hence they are not working accurate and even worse, using them makes your app works slow.

Even with a two up votes, this question have never got an answer:

Android Text Justification in TextView (NOT WebView) Without Third Party Library

So, my question is, how come something this much common, useful, necessary and simple thing is not solved by google??? Isn't there a good solution after passing this much time? Thank you all.

答:
You can extend standart TextView and overwrite onTextChanged method.
Than you need implement justify. What i'm currently do.

If you are lucky, you will able to implement your own component :)

For use it you can just specify full package name of your class in your xml layout.

Please keep this thread updateable.

Title: Text justification in android


问:
Service Fabric: Use Refresh Mode for Faster Debugging
The Service Fabric Team announced in their blog post that Service Fabric now supports Refresh Mode in Preview when debugging on a 1 Node cluster in Visual Studio 2015.

I've just installed the new Service Fabric SDK from the Web Platform Installer and have a .Net Core Web Application Service I'd like to try this out with.

Is there anything else I need to do to configure the Service/Application for Refresh Mode? I haven't noticed any new controls as such in Visual Studio. I can only hit Debug as normal.

答:
It's a new option in the Application Debug Mode values, in the properties of your SF Application project. </p>

<p>(from the detailed release notes document)</p>

Body:
It's a new option in the Application Debug Mode values, in the properties of your SF Application project.

(from the detailed release notes document)


问:
Triangle asterisks of for loop
Guys I need your assistance I should accomplish several tasks given by supervisor to make triangle using for loop. But I can't get the exact one. Please help me with that!

Here is an illustration how the final output should look like:

Task 2
input
N (example: N = 5)

output

```<code>    *
   **
  ***
 ****
*****
</code>```

Task 3
input
N (example: N = 5)

output

```<code>* * *
 * *
* * *
 * *
* * *
</code>```

Task 4
input
    N (example: N = 5)

output

```<code>*****
*   *
*   *
*   *
*****
</code>```

and this is my code:

```<code>function mixedTriangle (n) {
    for (var i = 0; i < n; i++) {
        for (var j = 0; j <= i; j++) {
            document.write('*');
        }
        document.write('<br>');
    }
}
mixedTriangle(5);
</code>```

答:
this is my take on it (scaling width with n):

first one you want to walk backwards on the columns so we start at the right side.

for the second function the we switch the pattern for each row other than that it's just using modulus to switch for each column

last one you just need the border which basically means minimum column or row or maximum column or row

```<code><script type="text/javascript">
    var fullSign = '*';
    var emptySign = '  ';
    var newRowSign = '<br>';

    function mixedTriangle (n) {
        for (var row = 1; row <= n; row++) {
            for (var col = n; col > 0; col--) {
                if(col <= row)
                    document.write(fullSign);
                else
                    document.write(emptySign);
            }
            document.write('<br>');
        }
    }

    function mixedTriangle2(n) {
        for (var row = 0; row < n; row++) {
            for (var col = 0; col < n; col++) {
                if(row % 2 == 0) {
                    if(col % 2 == 0)
                        document.write(fullSign);
                    else
                        document.write(emptySign);
                }
                else {
                    if(col % 2 == 1)
                        document.write(fullSign);
                    else
                        document.write(emptySign);
                }
            }
            document.write(newRowSign);
        }
    }

    function mixedTriangle3(n) {
        for (var row = 1; row <= n; row++) {
            for (var col = 1; col <= n; col++) {
                if(row == 1 || col == 1 || col == n || row == n)
                    document.write(fullSign);
                else
                    document.write(emptySign);
            }
            document.write(newRowSign);
        }
    }

    // mixedTriangle(5);
    // mixedTriangle2(5);
    mixedTriangle3(5);
</script>
</code>```

Title: Triangle asterisks of for loop

Body:
Guys I need your assistance I should accomplish several tasks given by supervisor to make triangle using for loop. But I can't get the exact one. Please help me with that!

Here is an illustration how the final output should look like:

Task 2
input
N (example: N = 5)

output

    *
   **
  ***
 ****
*****

Task 3
input
N (example: N = 5)

output

* * *
 * *
* * *
 * *
* * *

Task 4
input
    N (example: N = 5)

output

*****
*   *
*   *
*   *
*****

and this is my code:

function mixedTriangle (n) {
    for (var i = 0; i < n; i++) {
        for (var j = 0; j <= i; j++) {
            document.write('*');
        }
        document.write('
');
    }
}
mixedTriangle(5);

Body:
this is my take on it (scaling width with n):

first one you want to walk backwards on the columns so we start at the right side.

for the second function the we switch the pattern for each row other than that it's just using modulus to switch for each column

last one you just need the border which basically means minimum column or row or maximum column or row

<script type="text/javascript">
    var fullSign = '*';
    var emptySign = '&nbsp;&nbsp;';
    var newRowSign = '<br>';

    function mixedTriangle (n) {
        for (var row = 1; row <= n; row++) {
            for (var col = n; col > 0; col--) {
                if(col <= row)
                    document.write(fullSign);
                else
                    document.write(emptySign);
            }
            document.write('<br>');
        }
    }

    function mixedTriangle2(n) {
        for (var row = 0; row < n; row++) {
            for (var col = 0; col < n; col++) {
                if(row % 2 == 0) {
                    if(col % 2 == 0)
                        document.write(fullSign);
                    else
                        document.write(emptySign);
                }
                else {
                    if(col % 2 == 1)
                        document.write(fullSign);
                    else
                        document.write(emptySign);
                }
            }
            document.write(newRowSign);
        }
    }

    function mixedTriangle3(n) {
        for (var row = 1; row <= n; row++) {
            for (var col = 1; col <= n; col++) {
                if(row == 1 || col == 1 || col == n || row == n)
                    document.write(fullSign);
                else
                    document.write(emptySign);
            }
            document.write(newRowSign);
        }
    }

    // mixedTriangle(5);
    // mixedTriangle2(5);
    mixedTriangle3(5);
</script>


问:
Firefox won't render CSS styles on content loaded with jQuery AJAX
I have a website that lets users comment on books and articles, and the main form has a search input for finding a relevant book or article (sources).  I use jQuery to dynamically load new sources from an outside site based on the search terms entered, and then also return sources in a list using AJAX.  I have two problems:

Right now, after the user enters four characters, the jQuery runs with every new keypress event.  What's a better way to wait for the user to stop typing, and then only run the jQuery event then?

In Firefox, the list is not styled though the CSS for the list is contained in the main CSS sheet already associated with the page. (This works just fine in Chrome and Safari.)

I use CodeIgniter, but most of the example code should be accessible regardless of familiarity with CI.  As said above, all CSS right now is in one sheet that is associated with this page.

Here is the basic form html:

```<code><?=form_open('/scrawls/add')?>
<h2>Add a Scrawl</h2>
<div id="scrawl-source-container">
    <p class="form-par">Search for a reference:</p>
    <input type="text" name="scrawl_source_search" id="scrawl-source-search">
    <div id="scrawl-source-suggestions">
        // this is where the list of suggestions is inserted
    </div>
</div>
<input type="hidden" name="scrawl_source_id" value=0 id="scrawl-source-id">
// redacted code here that deals with other fields
<div id="selected-ref">
    You've selected: <span id="selected-ref-name"></span>
</div>
// redacted code here that deals with other fields
<?=form_submit('scrawl_submit','Post')?>
<?=form_close()?>
</code>```

Here is the javascript (not my strongsuit):

```<code>$(document).ready(function() {

$("input#scrawl-source-search").keypress(function() {
    var length = $(this).val().length;
    // check to see if there are more than four characters in the input field
    if (length > 4) {
        // need to make some sort of loading div here
        // make Ajax request to find matching sources
        $.post("http://mysite.com/refs/refMatch",{ term:$("input#scrawl-source-search").val()}, function(data) {
            if (data=="No output") {
                $("div#scrawl-source-suggestions").show();
                $("div#scrawl-source-suggestions").html("No matches.");
            } else {
                $("div#scrawl-source-suggestions").html(data).hide();
                $("div#scrawl-source-suggestions").slideDown();
            }
          });
    }
});
});
</code>```

The 'refMatch" page which is accessed via AJAX checks an external site to see if there are any new additions that need to be made to the database, then outputs matches from the db.  Here is the output file:

```<code><?php
if(isset($refs))
{
echo '<ul class="autocomplete-list">';
foreach($refs as $r)
{
    echo '<li class="autocomplete-entry">';
    echo '<span class="source-id" style="display:none">'.$r->ref_id.'</span><span class="source-title">'.$r->ref_title.'</span>';
    if($r->ref_author != '') {
        echo ' by <span class="source-author">'.$r->ref_author.'</span>';
    }
    echo '</li>';
}
echo '</ul>';
} else {
    echo "No output";
}
</code>```

So, to repeat my questions, why is FF not styling the AJAX output?  And what's a better way to trigger the jQuery AJAX call?

答:
I'm not positive what the problem is, but there's a few curious things about your post. Given that this works in Chrome and Safari, it would seem that your markup/styles are correct though. Can you provide the URL to your site?

First, are you adding CSS classes to your elements via Javascript? If so, then the styles you add will only affect those elements which are part of the DOM at that point in time, so you might be experiencing a race condition, that actually happens to work in Chrome and Safari, but not Firefox.

Second, you mention that you're using jQuery to load data from an outside source (an external web site I presume). This violates the Same Origin Policy and I would expect this to fail in all browsers. This might be the cause of some problems.

I strongly suggest using Firebug to troubleshoot this. You can use it to inspect HTML and really see what's going on.

ContentLicense: CC BY-SA 2.5

Body:
I have a website that lets users comment on books and articles, and the main form has a search input for finding a relevant book or article (sources).  I use jQuery to dynamically load new sources from an outside site based on the search terms entered, and then also return sources in a list using AJAX.  I have two problems:

Right now, after the user enters four characters, the jQuery runs with every new keypress event.  What's a better way to wait for the user to stop typing, and then only run the jQuery event then?

In Firefox, the list is not styled though the CSS for the list is contained in the main CSS sheet already associated with the page. (This works just fine in Chrome and Safari.)

I use CodeIgniter, but most of the example code should be accessible regardless of familiarity with CI.  As said above, all CSS right now is in one sheet that is associated with this page.

Here is the basic form html:

<?=form_open('/scrawls/add')?>

Add a Scrawl

Search for a reference:

    <input type="text" name="scrawl_source_search" id="scrawl-source-search">

        // this is where the list of suggestions is inserted

<input type="hidden" name="scrawl_source_id" value=0 id="scrawl-source-id">
// redacted code here that deals with other fields

    You've selected:

// redacted code here that deals with other fields
<?=form_submit('scrawl_submit','Post')?>
<?=form_close()?>

Here is the javascript (not my strongsuit):

$(document).ready(function() {

$("input#scrawl-source-search").keypress(function() {
    var length = $(this).val().length;
    // check to see if there are more than four characters in the input field
    if (length > 4) {
        // need to make some sort of loading div here
        // make Ajax request to find matching sources
        $.post("http://mysite.com/refs/refMatch",{ term:$("input#scrawl-source-search").val()}, function(data) {
            if (data=="No output") {
                $("div#scrawl-source-suggestions").show();
                $("div#scrawl-source-suggestions").html("No matches.");
            } else {
                $("div#scrawl-source-suggestions").html(data).hide();
                $("div#scrawl-source-suggestions").slideDown();
            }
          });
    }
});
});

The 'refMatch" page which is accessed via AJAX checks an external site to see if there are any new additions that need to be made to the database, then outputs matches from the db.  Here is the output file:

<?php
if(isset($refs))
{
echo '
';
foreach($refs as $r)
{
    echo '
';
    echo ''.$r->ref_id.''.$r->ref_title.'';
    if($r->ref_author != '') {
        echo ' by '.$r->ref_author.'';
    }
    echo '
';
}
echo '
';
} else {
    echo "No output";
}

So, to repeat my questions, why is FF not styling the AJAX output?  And what's a better way to trigger the jQuery AJAX call?


问:
Checking If Database In Restoring State
I'm running a T-SQL script that drops a database and then restores it.  The script runs against a SQL Server 2008 database.  Sometimes there is a problem with the backup file and the database gets stuck in the restoring state.

```<code>IF EXISTS (SELECT 1 FROM master.dbo.sysdatabases WHERE name = 'dbname')
BEGIN
    ALTER DATABASE [dbname]
    SET SINGLE_USER WITH
    ROLLBACK IMMEDIATE
END

IF EXISTS (SELECT 1 FROM master.dbo.sysdatabases WHERE name = 'dbname')
BEGIN
    DROP DATABASE [dbname]
END

RESTORE DATABASE [dbname]
FROM  DISK = N'C:\dbname.bak'
WITH  FILE = 1,
NOUNLOAD,
STATS = 10
</code>```

The next time the script runs the script generates the error message

```<code>ALTER DATABASE is not permitted while a database is in the Restoring state.
</code>```

What is the best way to check if the database is in the restoring state before trying to run the ALTER DATABASE command?

EDIT: The RESTORE DATABASE command that I'm running doesn't use the NO RECOVERY option.

答:
Method 2:

```<code>SELECT
    state,
    state_desc
     FROM sys.databases
WHERE [name] = 'Databasename'
</code>```

It is give me exact result.

Title: Checking If Database In Restoring State

Body:
I'm running a T-SQL script that drops a database and then restores it.  The script runs against a SQL Server 2008 database.  Sometimes there is a problem with the backup file and the database gets stuck in the restoring state.

IF EXISTS (SELECT 1 FROM master.dbo.sysdatabases WHERE name = 'dbname')
BEGIN
    ALTER DATABASE [dbname]
    SET SINGLE_USER WITH
    ROLLBACK IMMEDIATE
END

IF EXISTS (SELECT 1 FROM master.dbo.sysdatabases WHERE name = 'dbname')
BEGIN
    DROP DATABASE [dbname]
END

RESTORE DATABASE [dbname]
FROM  DISK = N'C:\dbname.bak'
WITH  FILE = 1,
NOUNLOAD,
STATS = 10

The next time the script runs the script generates the error message

ALTER DATABASE is not permitted while a database is in the Restoring state.

What is the best way to check if the database is in the restoring state before trying to run the ALTER DATABASE command?

EDIT: The RESTORE DATABASE command that I'm running doesn't use the NO RECOVERY option.

Body:
Method 2:

SELECT
    state,
    state_desc
     FROM sys.databases
WHERE [name] = 'Databasename'

It is give me exact result.


问:
How to display the axis to the right?
I have 3 axes (velue-axis)

Can one axis be displayed on the left

Other two axes to display on the right?

http://demos.telerik.com/kendo-ui/line-charts/multiple-axes
(In this example, the axis is located on the right, but I do not know how to configure it)

Thanks.

答:
Granted this isn't entirely clear when you first look at the demo. The important thing to look at is this section:

```<code> categoryAxis: {
                 categories: [],
                 axisCrossingValues:[]//This is the fella you are looking for.
               }
</code>```

I have tweaked the demo slightly to show you one of the axis in the middle of the chart. http://dojo.telerik.com/ASidu

The number is simply the position column on the chart that the axis should be rendered. By default if this in't set then all axis should be on the left hand side as normal. but if we start applying a number greater than 0 then the axis will shift. So in the example we have 3 value axis set up:

```<code> valueAxes: [{
                    name: "rain",
                    color: "#007eff",
                    min: 0,
                    max: 60
                }, {
                    name: "wind",
                    color: "#73c100",
                    min: 0,
                    max: 60
                }, {
                    name: "temp",
                    min: -30,
                    max: 30
                }],
</code>```

so if we look at them from crossing the y-axis (i.e. the bottom axis) we have 31 columns available to us 1- 31 so in my tweak I have applied this to the crossingAxis:

```<code>axisCrossingValues: [32, 15, 0]
</code>```

This is effectively telling each of the value axes where they should be positioned:

so:

"rain" should be at position 32

"wind" should be at position 15

"temp" should be at position 0

So the order in which you add your value axes will determine which setting they take based on the order you include them.

Hopefully that helps clear things up for you. If you need any more info let me know and I will update accordingly

Title: How to display the axis to the right?

Body:
Granted this isn't entirely clear when you first look at the demo. The important thing to look at is this section:

 categoryAxis: {
                 categories: [],
                 axisCrossingValues:[]//This is the fella you are looking for.
               }

I have tweaked the demo slightly to show you one of the axis in the middle of the chart. http://dojo.telerik.com/ASidu

The number is simply the position column on the chart that the axis should be rendered. By default if this in't set then all axis should be on the left hand side as normal. but if we start applying a number greater than 0 then the axis will shift. So in the example we have 3 value axis set up:

 valueAxes: [{
                    name: "rain",
                    color: "#007eff",
                    min: 0,
                    max: 60
                }, {
                    name: "wind",
                    color: "#73c100",
                    min: 0,
                    max: 60
                }, {
                    name: "temp",
                    min: -30,
                    max: 30
                }],

so if we look at them from crossing the y-axis (i.e. the bottom axis) we have 31 columns available to us 1- 31 so in my tweak I have applied this to the crossingAxis:

axisCrossingValues: [32, 15, 0]

This is effectively telling each of the value axes where they should be positioned:

so:

"rain" should be at position 32

"wind" should be at position 15

"temp" should be at position 0

So the order in which you add your value axes will determine which setting they take based on the order you include them.

Hopefully that helps clear things up for you. If you need any more info let me know and I will update accordingly


问:
Is there a way to pull the Earnings metric with more than two decimal places precision?
Right now, when querying the Adsense Management API for Ad earnings over a date range,  I get a JSON array which contains an 'Earnings' metric for each day, rounded to two decimal places. There is also a 'totals' JSON object which contains the total of the all the days requested. The sum of each day's value does not match the reported total. </p>

<p>I suspect that the earnings for each day is rounded off to two decimal places and the accuracy lost adds up to the missing amount. Is there a way I can get the unrounded values Adsense is using to calculate the totals? Or can I somehow get more decimal places of precision in the Earnings metric. </p>

答:
One roundabout way to do is to request earnings in currency where 1 unit of that currency is a fraction of dollar. For e.g. INR (1 INR ~= 0.015 USD). And then convert that back to USD. For e.g if the actual earning is 0.003 USD, then in INR it would be reported as INR 0.19 by the API, which then you can convert back to USD using current exchange rate. It will not be 100% accurate, but at least you will be able handle very small values.
The java api call is AdSense.Reports.Generate setCurrency(java.lang.String currency);</p>

Body:
Right now, when querying the Adsense Management API for Ad earnings over a date range,  I get a JSON array which contains an 'Earnings' metric for each day, rounded to two decimal places. There is also a 'totals' JSON object which contains the total of the all the days requested. The sum of each day's value does not match the reported total.

I suspect that the earnings for each day is rounded off to two decimal places and the accuracy lost adds up to the missing amount. Is there a way I can get the unrounded values Adsense is using to calculate the totals? Or can I somehow get more decimal places of precision in the Earnings metric.


问:
unsupported: Symbol in Cucumber on Rails
I am trying to call each on an ActiveRecord object/list in RoR as shown in the following chunk of code.

```<code> 41 Then /I should (not )?see movies with ratings: (.*)/ do |not_see, rating_li>
 42   @movies = Movie.where(:rating, rating_list.split(", "))
 43   rating_list.split(",").map do |x|
 44     x.strip
 45   end.each do |rating|
 46     if not_see
 47       @movies.each do |movie|
 48         @movie.title
 49       end
 50     else
 51       puts "hello"
 52     end
 53   end
 54 end
</code>```

And this produces the following error message:

```<code>And I should not see movies with ratings: G, PG-13, NC-17 # features/step_definitions/movie_steps.rb:41
  unsupported: Symbol (RuntimeError)
  ./features/step_definitions/movie_steps.rb:47:in `block (2 levels) in <top (required)>'
  ./features/step_definitions/movie_steps.rb:45:in `each'
  ./features/step_definitions/movie_steps.rb:45:in `/I should (not )?see movies with ratings: (.*)/'
  features/filter_movie_list.feature:33:in `And I should not see movies with ratings: G, PG-13, NC-17'
</code>```

Removing line 47 in the code above gets rid of the error. Why is that? As far as I can tell, all of these are valid Ruby code. What am I missing?

Thank you all!

答:
The line of code that was causing the error is line 42. The call to where should have been:

```<code>Movie.where(:rating => rating_list.split(","))
</code>```

"=>" and not ","

Body:
I am trying to call each on an ActiveRecord object/list in RoR as shown in the following chunk of code.

 41 Then /I should (not )?see movies with ratings: (.*)/ do |not_see, rating_li>
 42   @movies = Movie.where(:rating, rating_list.split(", "))
 43   rating_list.split(",").map do |x|
 44     x.strip
 45   end.each do |rating|
 46     if not_see
 47       @movies.each do |movie|
 48         @movie.title
 49       end
 50     else
 51       puts "hello"
 52     end
 53   end
 54 end

And this produces the following error message:

And I should not see movies with ratings: G, PG-13, NC-17 # features/step_definitions/movie_steps.rb:41
  unsupported: Symbol (RuntimeError)
  ./features/step_definitions/movie_steps.rb:47:in `block (2 levels) in <top (required)>'
  ./features/step_definitions/movie_steps.rb:45:in `each'
  ./features/step_definitions/movie_steps.rb:45:in `/I should (not )?see movies with ratings: (.*)/'
  features/filter_movie_list.feature:33:in `And I should not see movies with ratings: G, PG-13, NC-17'

Removing line 47 in the code above gets rid of the error. Why is that? As far as I can tell, all of these are valid Ruby code. What am I missing?

Thank you all!

Body:
The line of code that was causing the error is line 42. The call to where should have been:

Movie.where(:rating => rating_list.split(","))

"=>" and not ","


问:
How to remove underline from a name on hover
I have such html:

```<code><legend class="green-color"><a name="section1">Section</a></legend>

legend.green-color{
    color:green;
}
</code>```

In my case Section looking green, but when i put mouse pointer on it it became looking like an a href, but i want it stay just the same without underline and changing color.

Is it possible to achieve without changing css or with minimum css change?

or may be somehow with jquery?

答:
legend.green-color{
    color:green !important;
}```

ContentLicense: CC BY-SA 4.0

Body:
I have such html:

<legend class="green-color">Section</legend>

legend.green-color{
    color:green;
}

In my case Section looking green, but when i put mouse pointer on it it became looking like an a href, but i want it stay just the same without underline and changing color.

Is it possible to achieve without changing css or with minimum css change?

or may be somehow with jquery?


问:
Generic function to create controls at runtime
I want to add controls to my aspx web form at runtime using C#.

I would like to write a generic function which will create any type of control (Eg: textbox, lable, button etc).

Any ideas please.
Thanks
BB

答:
I suppose you could do something like this:</p>

```<code>public void CreateControl<W>(Func<W> controlConstructor) where W : WebControl
{
         W control = controlConstructor();

         //add control and configure it, etc etc
}
</code>```

Body:
I suppose you could do something like this:

public void CreateControl<W>(Func<W> controlConstructor) where W : WebControl
{
         W control = controlConstructor();

         //add control and configure it, etc etc
}


问:
How to make css for class in single page?
Here is my style:

```<code><style>
      ul {
          padding:0 0 0 0;
          margin:0 0 0 0;
      }
      ul li {
          list-style:none;
          margin-bottom:25px;
      }
      ul li img {
          cursor: pointer;
      }
      .modal-body {
          padding:5px !important;
      }
      .modal-content {
          border-radius:0;
      }
      .modal-dialog img {
          text-align:center;
          margin:0 auto;
      }
    .controls{
        width:50px;
        display:block;
        font-size:11px;
        padding-top:8px;
        font-weight:bold;
    }
    .next {
        float:right;
        text-align:right;
    }
      /*override modal for demo only*/
      .modal-dialog {
          max-width:500px;
          padding-top: 90px;
      }
      @media screen and (min-width: 768px){
          .modal-dialog {
              width:500px;
              padding-top: 90px;
          }
      }
      @media screen and (max-width:1500px){
          #ads {
              display:none;
          }
      }

        .dock {
            border: 4px dotted #cccccc;
            background-color: #ededed;
            width: 600px;
            height: 300px;
            color: #aaa;
            font-size: 18px;
            text-align: center;
            padding-top: 100px;
        }
        .dock_hover {
            border: 4px dotted #4d90fe;
            background-color: #e7f0ff;
            width: 600px;
            height: 300px;
            color: #4d90fe;
            font-size: 18px;
            text-align: center;
            padding-top: 100px;
        }
  </style>
</code>```

And I want to control

```<code>ul li {
          list-style:none;
          margin-bottom:25px;
      }
</code>```

without making change for my default page. margin-bottom must be 0px
And here is my ul li

```<code><ul class="row">
    <li class="col-lg-3 col-md-3 ">
    <img class="img-responsive" src="images/photodune-174908-rocking-the-night-away-xs.jpg">
    </li>
    <li class="col-lg-3 col-md-3 ">
    <img class="img-responsive" src="images/photodune-287182-blah-blah-blah-yellow-road-sign-xs.jpg">
    </li>
    <li class="col-lg-3 col-md-3 ">
    <img class="img-responsive" src="images/photodune-460760-colors-xs.jpg">
    </li>
</ul>
</code>```

Is it possible to change margin-bottom:0px through given class to ul li ? I've read the reference css style change just for one page but I don't know how to implement its code. That's why I ask a question for this.
Here is the page while margin-bottom:0px

Here is the page while margin-bottom:25px

I want to fix the picture with margin-bottom:25px but I don't want to change totally of the page.
Here's full of my script page:

```<!DOCTYPE html>
<?php include('akses.php'); ?>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Basarnas</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">

    <link href="../css/sb-admin.css" rel="stylesheet">

    <link href="../font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                    Toggle navigation

                </button>
                Operator Komunikasi

                     <?php echo $_SESSION['operatorkomunikasi']; ?>

                             Settings

                             Log Out

                         Home

                         Informasi Bencana

                         Monitoring Operasi SAR

    Direktorat Operasi dan Latihan
                  BASARNAS

                            Data Informasi Bencana

                                  List Informasi Bencana

                                 Berita SAR

        <?php  if (isset($_POST['submit'])) {
        $key = md5('vxcygnusloiv');
        function encrypt($string, $key){
        $string = rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_ECB)));
        return $string;
        }

        $conn = new Mongo();
        $db = $conn->selectDB('basarnas');

        $id = $_POST['id'];
        $kategori = $_POST['kategoribencana'];
        $kepalaoperasi = $_POST['kepalaoperasi'];
        $kepalaoperasii = $_POST['kepalaoperasii'];

        $query = $db->informasi_bencana;
        $queryy = $db->user;
        $queryyy = $db->pegawai;
        if ($kategori == "Bencana Besar") {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasi, $key), "level"=>encrypt("Kepala Kantor Pusat BASARNAS", $key)));
        $nResults = $cursor->count();
        if ($nResults == 0){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim karena tidak ada yang menjabat sebagai (Kepala '.$kepalaoperasi.').

';
        }else {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasi, $key), "level"=>encrypt("Kepala Kantor Pusat BASARNAS", $key)));
        foreach($cursor as $doc){
        $selected = array('_id'=> new MongoId($doc['idpegawai']));
        $cursorr=$queryyy->find($selected);
        foreach($cursorr as $docc){
        $nip_kepala = decrypt($docc['nip'], $key);
        $nama_kepala = decrypt($docc['nama'], $key);
        $query->update(array("_id"=>new MongoId($id)), array('$set'=>array("status"=>encrypt("berita", $key), "status_berita"=>encrypt("Pending Berita SAR", $key), "kategori"=>encrypt($kategori, $key), "smc"=>encrypt($kepalaoperasi, $key), "nip_kepala"=>encrypt($nip_kepala, $key), "nama_kepala"=>encrypt($nama_kepala, $key), "chat_pusat_daerah"=>encrypt("", $key), "status_chat_pusat"=>0, "status_chat_daerah"=>0)));
        if ($query){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR berhasil dikirim ke ('.$kepalaoperasi.').

';
        }else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim ke ('.$kepalaoperasi.').

';
        }
        }
        }
        }
        } elseif ($kategori == "Bencana Kecil"){
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasii, $key), "level"=>encrypt("Kepala Kantor SAR Daerah", $key)));
        $nResults = $cursor->count();
        if ($nResults == 0){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim karena tidak ada yang menjabat sebagai (Kepala '.$kepalaoperasii.').

';
        }else {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasii, $key), "level"=>encrypt("Kepala Kantor SAR Daerah", $key)));
        foreach($cursor as $doc){
        $selected = array('_id'=> new MongoId($doc['idpegawai']));
        $cursorr=$queryyy->find($selected);
        foreach($cursorr as $docc){
        $nip_kepala = decrypt($docc['nip'], $key);
        $nama_kepala = decrypt($docc['nama'], $key);
        $query->update(array("_id"=>new MongoId($id)), array('$set'=>array("status"=>encrypt("berita", $key), "status_berita"=>encrypt("Pending Berita SAR", $key), "kategori"=>encrypt($kategori, $key), "smc"=>encrypt($kepalaoperasii, $key), "nip_kepala"=>encrypt($nip_kepala, $key), "nama_kepala"=>encrypt($nama_kepala, $key), "chat_pusat_daerah"=>encrypt("", $key), "status_chat_pusat"=>0, "status_chat_daerah"=>0)));
        if ($query){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR berhasil dikirim ke ('.$kepalaoperasii.').

';
        }else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim ke ('.$kepalaoperasii.').

';
        }
        }
        }
        }
        } else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim.

';
        }
        }
        $key = md5('vxcygnusloiv');
        function decrypt($string, $key){
        $string = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($string), MCRYPT_MODE_ECB));
        return $string;
        }
        $conn = new Mongo();
        $db = $conn->selectDB('basarnas');
        $query = $db->informasi_bencana;
        $cursor=$query->find(array("_id"=>new MongoId($_GET['id'])));
        foreach($cursor as $id=>$doc){
        if (decrypt($doc['jenis_kejadian'], $key) == "" || decrypt($doc['lokasi_kejadian'], $key) == "" || decrypt($doc['no_telp_lain'], $key) == "" || decrypt($doc['catatan'], $key) == "") {
        $status = "disabled";
        }else{
        $status = "";
        }
        ?>

 Form Pembuatan Berita SAR

                                <form class="form-signin" action="" method="post">

                                            Waktu Kejadian:<input type="hidden" name="id" value="<?php echo $doc['_id']; ?>"/>
                                            <input type="text" class="form-control" name="waktulaporan" value="<?php echo date('Y/m/d, H:i', $doc['waktu_laporan']->sec); ?>" disabled/>

                                            Nama Pelapor:
                                            <input type="text" class="form-control" name="namapelapor" value="<?php echo decrypt($doc['nama_pelapor'], $key); ?>" disabled/>

                                            No Telepon Pelapor:
                                            <input type="text" class="form-control" name="notelp" value="<?php echo decrypt($doc['no_telp'], $key); ?>" disabled/>

                                            Jenis Kejadian:
                                            <input type="text" class="form-control" name="jeniskejadian" value="<?php echo decrypt($doc['jenis_kejadian'], $key); ?>" disabled/>

                                            Lokasi Kejadian:
                                            <input type="text" class="form-control" name="lokasikejadian" value="<?php echo decrypt($doc['lokasi_kejadian'], $key); ?>" disabled/>

                                            No Telepon Lain Yang Bisa Dihubungi:
                                            <input type="text" class="form-control" name="notelplain" value="<?php echo decrypt($doc['no_telp_lain'], $key); ?>" disabled/>

                                            Catatan Tambahan:
                                            <textarea class="form-control" rows="3" name="catatan" disabled><?php echo decrypt($doc['catatan'], $key); ?></textarea>

                                            Kategori Bencana:
                                            <select class="form-control" name="kategoribencana" onchange="kategori(this);" required>
                                                <option value=""></option>
                                                <option value="Bencana Besar">Bencana Besar</option>
                                                <option value="Bencana Kecil">Bencana Kecil</option>
                                            </select>

<input type="hidden" name="kepalaoperasi" value="Kantor Pusat BASARNAS"/>
                                            <input type="text" class="form-control" value="Kantor Pusat BASARNAS" disabled/>

                                            Pilih Kantor SAR:
                                            <select class="form-control" name="kepalaoperasii" required>
                                                <option value="Kantor SAR Daerah Aceh">Kantor SAR Daerah Aceh</option>
                                                <option value="Kantor SAR Daerah Medan">Kantor SAR Daerah Medan</option>
                                                <option value="Kantor SAR Daerah Padang">Kantor SAR Daerah Padang</option>
                                                <option value="Kantor SAR Daerah Pekanbaru">Kantor SAR Daerah Pekanbaru</option>
                                                <option value="Kantor SAR Daerah Jambi">Kantor SAR Daerah Jambi</option>
                                                <option value="Kantor SAR Daerah Tanjung Pinang">Kantor SAR Daerah Tanjung Pinang</option>
                                                <option value="Kantor SAR Daerah Pangkal Pinang">Kantor SAR Daerah Pangkal Pinang</option>
                                                <option value="Kantor SAR Daerah Bengkulu">Kantor SAR Daerah Bengkulu</option>
                                                <option value="Kantor SAR Daerah Palembang">Kantor SAR Daerah Palembang</option>
                                                <option value="Kantor SAR Daerah Lampung">Kantor SAR Daerah Lampung</option>
                                                <option value="Kantor SAR Daerah Jakarta">Kantor SAR Daerah Jakarta</option>
                                                <option value="Kantor SAR Daerah Bandung">Kantor SAR Daerah Bandung</option>
                                                <option value="Kantor SAR Daerah Semarang">Kantor SAR Daerah Semarang</option>
                                                <option value="Kantor SAR Daerah Surabaya">Kantor SAR Daerah Surabaya</option>
                                                <option value="Kantor SAR Daerah Denpasar">Kantor SAR Daerah Denpasar</option>
                                                <option value="Kantor SAR Daerah Mataram">Kantor SAR Daerah Mataram</option>
                                                <option value="Kantor SAR Daerah Kupang">Kantor SAR Daerah Kupang</option>
                                                <option value="Kantor SAR Daerah Banjarmasin">Kantor SAR Daerah Banjarmasin</option>
                                                <option value="Kantor SAR Daerah Balikpapan">Kantor SAR Daerah Balikpapan</option>
                                                <option value="Kantor SAR Daerah Merauke">Kantor SAR Daerah Merauke</option>
                                                <option value="Kantor SAR Daerah Pontianak">Kantor SAR Daerah Pontianak</option>
                                                <option value="Kantor SAR Daerah Palu">Kantor SAR Daerah Palu</option>
                                                <option value="Kantor SAR Daerah Makassar">Kantor SAR Daerah Makassar</option>
                                                <option value="Kantor SAR Daerah Kendari">Kantor SAR Daerah Kendari</option>
                                                <option value="Kantor SAR Daerah Ternate">Kantor SAR Daerah Ternate</option>
                                                <option value="Kantor SAR Daerah Ambon">Kantor SAR Daerah Ambon</option>
                                                <option value="Kantor SAR Daerah Jayapura">Kantor SAR Daerah Jayapura</option>
                                                <option value="Kantor SAR Daerah Sorong">Kantor SAR Daerah Sorong</option>
                                                <option value="Kantor SAR Daerah Biak">Kantor SAR Daerah Biak</option>
                                                <option value="Kantor SAR Daerah Timika">Kantor SAR Daerah Timika</option>
                                                <option value="Kantor SAR Daerah Manokwari">Kantor SAR Daerah Manokwari</option>
                                                <option value="Kantor SAR Daerah Merauke">Kantor SAR Daerah Merauke</option>
                                            </select>

                                                    Upload Dokumen Foto Pendukung

0%

Drag & Drop Photos Here

                                    <button class="btn btn-primary" name="submit" <?php echo $status;?>>Kirim Berita </button>

                                </form>

                                <?php } ?>

 Informasi Pengiriman Berita SAR

Jika tombol (Kirim Berita) dalam keadaan "disabled" maka pastikan untuk mengisi semua kolom data informasi bencana secara lengkap. Karena syarat untuk pengiriman berita SAR diharuskan untuk mengisi
                                    form secara lengkap meskipun pada catatan tambahan tidak ada yang perlu untuk diisi tetapi usahakan untuk mengisinya seperti "Tidak ada". Untuk mengisi kolom data informasi bencana yang belum diisi dapat menuju link ini <?php echo "" ?>Edit Informasi Bencana

```

答:
If you want to change it only on one subpage you have to add a class or id somewhere at any parent element and write your selectors from there.

That one page will get then

```<code><body class="foo">
</code>```

and the css could be

```<code>body.foo ul.row{
    font-size: 1em;
}

body.foo ul.row li{
    list-style-type: none;
}
</code>```

Body:
Here is my style:

And I want to control

ul li {
          list-style:none;
          margin-bottom:25px;
      }

without making change for my default page. margin-bottom must be 0px
And here is my ul li

Is it possible to change margin-bottom:0px through given class to ul li ? I've read the reference css style change just for one page but I don't know how to implement its code. That's why I ask a question for this.
Here is the page while margin-bottom:0px

Here is the page while margin-bottom:25px

I want to fix the picture with margin-bottom:25px but I don't want to change totally of the page.
Here's full of my script page:

<!DOCTYPE html>
<?php include('akses.php'); ?>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Basarnas</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">

    <link href="../css/sb-admin.css" rel="stylesheet">

    <link href="../font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                    Toggle navigation

                </button>
                Operator Komunikasi

                     <?php echo $_SESSION['operatorkomunikasi']; ?>

                             Settings

                             Log Out

                         Home

                         Informasi Bencana

                         Monitoring Operasi SAR

    Direktorat Operasi dan Latihan
                  BASARNAS

                            Data Informasi Bencana

                                  List Informasi Bencana

                                 Berita SAR

        <?php  if (isset($_POST['submit'])) {
        $key = md5('vxcygnusloiv');
        function encrypt($string, $key){
        $string = rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_ECB)));
        return $string;
        }

        $conn = new Mongo();
        $db = $conn->selectDB('basarnas');

        $id = $_POST['id'];
        $kategori = $_POST['kategoribencana'];
        $kepalaoperasi = $_POST['kepalaoperasi'];
        $kepalaoperasii = $_POST['kepalaoperasii'];

        $query = $db->informasi_bencana;
        $queryy = $db->user;
        $queryyy = $db->pegawai;
        if ($kategori == "Bencana Besar") {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasi, $key), "level"=>encrypt("Kepala Kantor Pusat BASARNAS", $key)));
        $nResults = $cursor->count();
        if ($nResults == 0){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim karena tidak ada yang menjabat sebagai (Kepala '.$kepalaoperasi.').

';
        }else {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasi, $key), "level"=>encrypt("Kepala Kantor Pusat BASARNAS", $key)));
        foreach($cursor as $doc){
        $selected = array('_id'=> new MongoId($doc['idpegawai']));
        $cursorr=$queryyy->find($selected);
        foreach($cursorr as $docc){
        $nip_kepala = decrypt($docc['nip'], $key);
        $nama_kepala = decrypt($docc['nama'], $key);
        $query->update(array("_id"=>new MongoId($id)), array('$set'=>array("status"=>encrypt("berita", $key), "status_berita"=>encrypt("Pending Berita SAR", $key), "kategori"=>encrypt($kategori, $key), "smc"=>encrypt($kepalaoperasi, $key), "nip_kepala"=>encrypt($nip_kepala, $key), "nama_kepala"=>encrypt($nama_kepala, $key), "chat_pusat_daerah"=>encrypt("", $key), "status_chat_pusat"=>0, "status_chat_daerah"=>0)));
        if ($query){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR berhasil dikirim ke ('.$kepalaoperasi.').

';
        }else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim ke ('.$kepalaoperasi.').

';
        }
        }
        }
        }
        } elseif ($kategori == "Bencana Kecil"){
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasii, $key), "level"=>encrypt("Kepala Kantor SAR Daerah", $key)));
        $nResults = $cursor->count();
        if ($nResults == 0){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim karena tidak ada yang menjabat sebagai (Kepala '.$kepalaoperasii.').

';
        }else {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasii, $key), "level"=>encrypt("Kepala Kantor SAR Daerah", $key)));
        foreach($cursor as $doc){
        $selected = array('_id'=> new MongoId($doc['idpegawai']));
        $cursorr=$queryyy->find($selected);
        foreach($cursorr as $docc){
        $nip_kepala = decrypt($docc['nip'], $key);
        $nama_kepala = decrypt($docc['nama'], $key);
        $query->update(array("_id"=>new MongoId($id)), array('$set'=>array("status"=>encrypt("berita", $key), "status_berita"=>encrypt("Pending Berita SAR", $key), "kategori"=>encrypt($kategori, $key), "smc"=>encrypt($kepalaoperasii, $key), "nip_kepala"=>encrypt($nip_kepala, $key), "nama_kepala"=>encrypt($nama_kepala, $key), "chat_pusat_daerah"=>encrypt("", $key), "status_chat_pusat"=>0, "status_chat_daerah"=>0)));
        if ($query){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR berhasil dikirim ke ('.$kepalaoperasii.').

';
        }else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim ke ('.$kepalaoperasii.').

';
        }
        }
        }
        }
        } else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim.

';
        }
        }
        $key = md5('vxcygnusloiv');
        function decrypt($string, $key){
        $string = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($string), MCRYPT_MODE_ECB));
        return $string;
        }
        $conn = new Mongo();
        $db = $conn->selectDB('basarnas');
        $query = $db->informasi_bencana;
        $cursor=$query->find(array("_id"=>new MongoId($_GET['id'])));
        foreach($cursor as $id=>$doc){
        if (decrypt($doc['jenis_kejadian'], $key) == "" || decrypt($doc['lokasi_kejadian'], $key) == "" || decrypt($doc['no_telp_lain'], $key) == "" || decrypt($doc['catatan'], $key) == "") {
        $status = "disabled";
        }else{
        $status = "";
        }
        ?>

 Form Pembuatan Berita SAR

                                <form class="form-signin" action="" method="post">

                                            Waktu Kejadian:<input type="hidden" name="id" value="<?php echo $doc['_id']; ?>"/>
                                            <input type="text" class="form-control" name="waktulaporan" value="<?php echo date('Y/m/d, H:i', $doc['waktu_laporan']->sec); ?>" disabled/>

                                            Nama Pelapor:
                                            <input type="text" class="form-control" name="namapelapor" value="<?php echo decrypt($doc['nama_pelapor'], $key); ?>" disabled/>

                                            No Telepon Pelapor:
                                            <input type="text" class="form-control" name="notelp" value="<?php echo decrypt($doc['no_telp'], $key); ?>" disabled/>

                                            Jenis Kejadian:
                                            <input type="text" class="form-control" name="jeniskejadian" value="<?php echo decrypt($doc['jenis_kejadian'], $key); ?>" disabled/>

                                            Lokasi Kejadian:
                                            <input type="text" class="form-control" name="lokasikejadian" value="<?php echo decrypt($doc['lokasi_kejadian'], $key); ?>" disabled/>

                                            No Telepon Lain Yang Bisa Dihubungi:
                                            <input type="text" class="form-control" name="notelplain" value="<?php echo decrypt($doc['no_telp_lain'], $key); ?>" disabled/>

                                            Catatan Tambahan:
                                            <textarea class="form-control" rows="3" name="catatan" disabled><?php echo decrypt($doc['catatan'], $key); ?></textarea>

                                            Kategori Bencana:
                                            <select class="form-control" name="kategoribencana" onchange="kategori(this);" required>
                                                <option value=""></option>
                                                <option value="Bencana Besar">Bencana Besar</option>
                                                <option value="Bencana Kecil">Bencana Kecil</option>
                                            </select>

<input type="hidden" name="kepalaoperasi" value="Kantor Pusat BASARNAS"/>
                                            <input type="text" class="form-control" value="Kantor Pusat BASARNAS" disabled/>

                                            Pilih Kantor SAR:
                                            <select class="form-control" name="kepalaoperasii" required>
                                                <option value="Kantor SAR Daerah Aceh">Kantor SAR Daerah Aceh</option>
                                                <option value="Kantor SAR Daerah Medan">Kantor SAR Daerah Medan</option>
                                                <option value="Kantor SAR Daerah Padang">Kantor SAR Daerah Padang</option>
                                                <option value="Kantor SAR Daerah Pekanbaru">Kantor SAR Daerah Pekanbaru</option>
                                                <option value="Kantor SAR Daerah Jambi">Kantor SAR Daerah Jambi</option>
                                                <option value="Kantor SAR Daerah Tanjung Pinang">Kantor SAR Daerah Tanjung Pinang</option>
                                                <option value="Kantor SAR Daerah Pangkal Pinang">Kantor SAR Daerah Pangkal Pinang</option>
                                                <option value="Kantor SAR Daerah Bengkulu">Kantor SAR Daerah Bengkulu</option>
                                                <option value="Kantor SAR Daerah Palembang">Kantor SAR Daerah Palembang</option>
                                                <option value="Kantor SAR Daerah Lampung">Kantor SAR Daerah Lampung</option>
                                                <option value="Kantor SAR Daerah Jakarta">Kantor SAR Daerah Jakarta</option>
                                                <option value="Kantor SAR Daerah Bandung">Kantor SAR Daerah Bandung</option>
                                                <option value="Kantor SAR Daerah Semarang">Kantor SAR Daerah Semarang</option>
                                                <option value="Kantor SAR Daerah Surabaya">Kantor SAR Daerah Surabaya</option>
                                                <option value="Kantor SAR Daerah Denpasar">Kantor SAR Daerah Denpasar</option>
                                                <option value="Kantor SAR Daerah Mataram">Kantor SAR Daerah Mataram</option>
                                                <option value="Kantor SAR Daerah Kupang">Kantor SAR Daerah Kupang</option>
                                                <option value="Kantor SAR Daerah Banjarmasin">Kantor SAR Daerah Banjarmasin</option>
                                                <option value="Kantor SAR Daerah Balikpapan">Kantor SAR Daerah Balikpapan</option>
                                                <option value="Kantor SAR Daerah Merauke">Kantor SAR Daerah Merauke</option>
                                                <option value="Kantor SAR Daerah Pontianak">Kantor SAR Daerah Pontianak</option>
                                                <option value="Kantor SAR Daerah Palu">Kantor SAR Daerah Palu</option>
                                                <option value="Kantor SAR Daerah Makassar">Kantor SAR Daerah Makassar</option>
                                                <option value="Kantor SAR Daerah Kendari">Kantor SAR Daerah Kendari</option>
                                                <option value="Kantor SAR Daerah Ternate">Kantor SAR Daerah Ternate</option>
                                                <option value="Kantor SAR Daerah Ambon">Kantor SAR Daerah Ambon</option>
                                                <option value="Kantor SAR Daerah Jayapura">Kantor SAR Daerah Jayapura</option>
                                                <option value="Kantor SAR Daerah Sorong">Kantor SAR Daerah Sorong</option>
                                                <option value="Kantor SAR Daerah Biak">Kantor SAR Daerah Biak</option>
                                                <option value="Kantor SAR Daerah Timika">Kantor SAR Daerah Timika</option>
                                                <option value="Kantor SAR Daerah Manokwari">Kantor SAR Daerah Manokwari</option>
                                                <option value="Kantor SAR Daerah Merauke">Kantor SAR Daerah Merauke</option>
                                            </select>

                                                    Upload Dokumen Foto Pendukung

0%

Drag & Drop Photos Here

                                    <button class="btn btn-primary" name="submit" <?php echo $status;?>>Kirim Berita </button>

                                </form>

                                <?php } ?>

 Informasi Pengiriman Berita SAR

Jika tombol (Kirim Berita) dalam keadaan "disabled" maka pastikan untuk mengisi semua kolom data informasi bencana secara lengkap. Karena syarat untuk pengiriman berita SAR diharuskan untuk mengisi
                                    form secara lengkap meskipun pada catatan tambahan tidak ada yang perlu untuk diisi tetapi usahakan untuk mengisinya seperti "Tidak ada". Untuk mengisi kolom data informasi bencana yang belum diisi dapat menuju link ini <?php echo "" ?>Edit Informasi Bencana

Body:
If you want to change it only on one subpage you have to add a class or id somewhere at any parent element and write your selectors from there.

That one page will get then

<body class="foo">

and the css could be

body.foo ul.row{
    font-size: 1em;
}

body.foo ul.row li{
    list-style-type: none;
}


问:
Android Visible view
we are using this code to visible view :

```<code>btnviewarray[x].setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        int secid=v.getId();
        for(int zt=0;bzt<dcountlinks;bzt++)
        {
            if(mybtnids[zt]==secid)
            {
                myid=zt;
            }
        }
        //Toast.makeText(getActivity(), dcountpeople[myid], Toast.LENGTH_LONG).show();
        lnralllinksview.VISIBLE(View.GONE);
        lnrallpeopleview.VISIBLE(View.GONE);
    }
});
</code>```

when this code running we are getting Method call Excepted error

答:
It should be like</p>

```<code>lnralllinksview.setVisibility(View.GONE);
lnrallpeopleview.setVisibility(View.GONE);
</code>```

Title: Android Visible view

Body:
we are using this code to visible view :

btnviewarray[x].setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        int secid=v.getId();
        for(int zt=0;bzt<dcountlinks;bzt++)
        {
            if(mybtnids[zt]==secid)
            {
                myid=zt;
            }
        }
        //Toast.makeText(getActivity(), dcountpeople[myid], Toast.LENGTH_LONG).show();
        lnralllinksview.VISIBLE(View.GONE);
        lnrallpeopleview.VISIBLE(View.GONE);
    }
});

when this code running we are getting Method call Excepted error

Body:
It should be like

lnralllinksview.setVisibility(View.GONE);
lnrallpeopleview.setVisibility(View.GONE);