问:
Reversing array elements in C programming
I am new to C and I have a problem. I need to reverse the elements of arrays in the following program. Can I get a very simple explanation of what I am doing wrong and how I could go on about fixing it?

Here's the output I get:

```Enter number 0: 0
Enter number 1: 1
Enter number 2: 2
Enter number 3: 3
Enter number 4: 4
Enter number 5: 5
Enter number 6: 6
Enter number 7: 7
Element 0 is: 7
Element 1 is: 6
Element 2 is: 5
Element 3 is: 4
Element 4 is: 4
Element 5 is: 5
Element 6 is: 6
Element 7 is: 7
```

My code:

```<code>#include <stdio.h>

void reverse(int a[], int i)
{
    int j=7,b;
    for (i=0; i<=7; i++)
    {
        b=a[i];
        a[i]=a[j];
        a[j]=b;
        printf("Element %d is: %d\n", i,a[i]);
        j--;
    }
}

int main(void)
{
    int a[8];
    int i;
    for(i=0;i<=7;i++)
    {
        printf("Enter number %d: ",i);
        scanf("%d", &a[i]);
    }
    reverse(a, 8);
    return 0;
}
</code>```

答:
You could also copy over the array in a new one:</p>

```<code>#include <stdio.h>

void reverse(int a[], int i)
{
    int b[i];
    int j;

    for(j=0; j<i; j++){
        b[j] = a[i-1-j];
        printf("Element %d is: %d\n", j, b[j]);
    }
}

int main(void)
{
    int a[8];
    int i;
    for(i=0;i<=7;i++)
    {
        printf("Enter number %d: ",i);
        scanf("%d", &a[i]);
    }
    reverse(a, 8);
    return 0;
}
</code>```

Body:
I am new to C and I have a problem. I need to reverse the elements of arrays in the following program. Can I get a very simple explanation of what I am doing wrong and how I could go on about fixing it?

Here's the output I get:

Enter number 0: 0
Enter number 1: 1
Enter number 2: 2
Enter number 3: 3
Enter number 4: 4
Enter number 5: 5
Enter number 6: 6
Enter number 7: 7
Element 0 is: 7
Element 1 is: 6
Element 2 is: 5
Element 3 is: 4
Element 4 is: 4
Element 5 is: 5
Element 6 is: 6
Element 7 is: 7

My code:

#include <stdio.h>

void reverse(int a[], int i)
{
    int j=7,b;
    for (i=0; i<=7; i++)
    {
        b=a[i];
        a[i]=a[j];
        a[j]=b;
        printf("Element %d is: %d\n", i,a[i]);
        j--;
    }
}

int main(void)
{
    int a[8];
    int i;
    for(i=0;i<=7;i++)
    {
        printf("Enter number %d: ",i);
        scanf("%d", &a[i]);
    }
    reverse(a, 8);
    return 0;
}

Body:
You could also copy over the array in a new one:

#include <stdio.h>

void reverse(int a[], int i)
{
    int b[i];
    int j;

    for(j=0; j<i; j++){
        b[j] = a[i-1-j];
        printf("Element %d is: %d\n", j, b[j]);
    }
}

int main(void)
{
    int a[8];
    int i;
    for(i=0;i<=7;i++)
    {
        printf("Enter number %d: ",i);
        scanf("%d", &a[i]);
    }
    reverse(a, 8);
    return 0;
}


来源: stackexchange

问:
ASP.NET Core Browser Link `Unable to get property 'files'`
In the Microsoft Virtual Academy course 'Introduction to ASP.NET Core (formerly ASP.NET 5)', video 3, at 39:00, they demonstrate how Browser Link can sync code selection between Edge's F12 tools and Visual Studio. I haven't been able to see the same functionality out of the box. I don't know if there's a setting, or something special to enable this. If there is, it wasn't shown in the course video, but then again the video is a couple months old. I've never seen this functionality before.

Browser Link is connected to Visual Studio from Edge, as can be seen in the Browser Link Dashboard in VS. That's all fine.

There is a console log in Edge that seems relevant;

```<code>Browser Link: Failed to invoke return value callback:
TypeError: Unable to get property 'files' of undefined or null reference.
browserLink (64,492)
</code>```

I found the only function in the BrowserLink js that references 'files' and started going up the stack trace. It seems to expect a JSON from localhost:9640/5b39911a4f384282a7625405b2d603cf/browserLinkSignalR with multiple elements, [1] being a list of source files, but is actually null, so catches and posts that console log.

Nothing useful on Google, or their GitHub issues. If there was a relevant Github repo I could be pointed to, I could look it up.

Microsoft Visual Studio Enterprise 2015 Version 14.0.25421.03 Update 3

Microsoft .NET Core Tools (Preview 2)   14.1.20624.0

"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"

Edge 25.10586.0.0

答:
Whenever i'm doing something new like this, i would try to find an example project that is leveraging the same feature somewhere on github.  I would then build that project and see if it works.  If the example project works and yours does not. I would then begin checking using statements, project configuration properties (right click project in solution explorer/properties), web config settings, includes, references and all included library versions.  You should be able to figure this out by following those steps. I would be willing to bet that it is something nominal like a missing app or web config setting.  Things of that nature can be difficult to detect without a working example project or proper instructions.

See this microsoft.com tutorial, although its not for the same version of visual studio, it may have some information that can lead you in the right direction.
Microsft.com Browser Link tutorial

ContentLicense: CC BY-SA 3.0

Body:
In the Microsoft Virtual Academy course 'Introduction to ASP.NET Core (formerly ASP.NET 5)', video 3, at 39:00, they demonstrate how Browser Link can sync code selection between Edge's F12 tools and Visual Studio. I haven't been able to see the same functionality out of the box. I don't know if there's a setting, or something special to enable this. If there is, it wasn't shown in the course video, but then again the video is a couple months old. I've never seen this functionality before.

Browser Link is connected to Visual Studio from Edge, as can be seen in the Browser Link Dashboard in VS. That's all fine.

There is a console log in Edge that seems relevant;

Browser Link: Failed to invoke return value callback:
TypeError: Unable to get property 'files' of undefined or null reference.
browserLink (64,492)

I found the only function in the BrowserLink js that references 'files' and started going up the stack trace. It seems to expect a JSON from localhost:9640/5b39911a4f384282a7625405b2d603cf/browserLinkSignalR with multiple elements, [1] being a list of source files, but is actually null, so catches and posts that console log.

Nothing useful on Google, or their GitHub issues. If there was a relevant Github repo I could be pointed to, I could look it up.

Microsoft Visual Studio Enterprise 2015 Version 14.0.25421.03 Update 3

Microsoft .NET Core Tools (Preview 2)   14.1.20624.0

"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"

Edge 25.10586.0.0


问:
React-Native: Avoid Text Wrapping
I have the title of a song and its duration showing in one line. The song title needs to show an ellipsis but the duration should never wrap or show ellipsis. I've tried several combinations but fail to make this work right for long titles. The duration either goes off screen when the name shows ellipsis or the duration wraps. I can't hardcode a fixed width on the duration as it can change size.</p>

```<code><View style={{flexDirection: 'row'}}>
    <Text numberOfLines={2} style={{fontSize: 16, textAlign: 'left'}}>{title}</Text>
    <Text style={{flex: 1, fontSize: 13, textAlign: 'right', marginTop: 2}}>{duration}</Text>
</View>
</code>```

答:
Possibly below solution should satify your creteria

```<code> return (
        <View style={{flexDirection: 'row', flex: 1, justifyContent: 'space-around', marginTop: 50}}>
            <Text numberOfLines={2} style={{fontSize: 16, flex: 1}}>{title}</Text>
            <Text style={{fontSize: 13, marginTop: 2}}>{duration}</Text>
        </View>
    );
</code>```

Please check and let me know if does not work.

Title: React-Native: Avoid Text Wrapping

Body:
I have the title of a song and its duration showing in one line. The song title needs to show an ellipsis but the duration should never wrap or show ellipsis. I've tried several combinations but fail to make this work right for long titles. The duration either goes off screen when the name shows ellipsis or the duration wraps. I can't hardcode a fixed width on the duration as it can change size.

<View style={{flexDirection: 'row'}}>
    <Text numberOfLines={2} style={{fontSize: 16, textAlign: 'left'}}>{title}</Text>
    <Text style={{flex: 1, fontSize: 13, textAlign: 'right', marginTop: 2}}>{duration}</Text>
</View>

Body:
Possibly below solution should satify your creteria

 return (
        <View style={{flexDirection: 'row', flex: 1, justifyContent: 'space-around', marginTop: 50}}>
            <Text numberOfLines={2} style={{fontSize: 16, flex: 1}}>{title}</Text>
            <Text style={{fontSize: 13, marginTop: 2}}>{duration}</Text>
        </View>
    );

Please check and let me know if does not work.

ContentLicense: CC BY-SA 4.0


问:
Install actual version during beta/alpha test (Android)
I would like someone else to test a migration process of my app.

My App actually has version 10.

My App published to Alpha has version 11.

I added the tester to the list of Alpha testers and he can install the new version 11 successfully.

Now the question :
How can my tester install the older version 10, even the tester is in the list of alpha testers, without removing him from the Alpha-Testers list ?
Are there 2 different links, where we can install both the newer and older version without manipulating the list of testers ?

答:
I think this is not possible because it only depends on version codes,  the highest will be installed:

Alpha testing group users are eligible for the alpha, beta, or
  production version of your app (with the highest version code that's
  compatible with their device). Beta testing group users are only
  eligible for the beta or production version of your app (with the
  highest version code that's compatible with their device).

This means your alpha APKs should have the highest version codes,
  followed by beta, and finally production.

If a beta APK is uploaded with a higher version code than an alpha
  APK, alpha users who can install both will install the beta APK
  instead of the alpha APK.

If a production APK is uploaded with a
  higher version code than an alpha or beta APK, some or all of your
  alpha and beta users will install the production APK, instead of APKs
  of the testing tracks.

I thought that perhaps using Beta and Alpha channels but I found this answer:

Another difference is that alpha test APK's version code should be
  higher than beta test one. If you upload a higher version of APK on beta
  test channel, alpha test will automatically be closed. (This principle
  applies for production APK too. APK version code should be 'Production
  < Beta < Alpha'.)

Adding the same tester to Beta and Alpha and trying something like this:

Prod version with same code than Beta and version code 10

Beta version with same code than Prod and version code 11

The tester can install Beta version.

Upload Alpha version with code under test and version code 12

The tester can update to Alpha version and test migration.

If all correct, upload Prod version with tested code and version code 13

And upload Beta version with same code than Prod and version code 14

The tester can install Beta version.

Add feature to test and upload Alpha version with version code 15

The tester can update to Alpha version and test migration.

...


问:
detect page from shebang in url with php or javascript
In a PHP file, i am using a javascript to integrate Spreadshop app into my website.

When an user clicks on an article, it display the article using an URL like this:

```<code>https://www.example.com/#!-A108148940
</code>```

I need to extract the article ID from this url ( 108148940 ) to display an image ( /images/108148940.jpg ) using PHP or Javascript, but only if we are currently viewing the article page (i.e. look for #!-A in the url)

This is the first time i'm forced to use shebang. Why isn't there an easy way to extract the variable just like $_GET['whatever'] with php ?

答:
PHP, being a server-side scripting language, won't be able to see the location's hash when the page loads; it's only available to the browser and its client.

Luckily, you can use JavaScript. Here's a fully mocked up example:

var articleId = null;

var noArticleMsgEl = document.getElementById('no-article-msg');
var articleEl = document.getElementById('article');
var imgEl = document.getElementById('img');
var idLabelEl = document.getElementById('id-label');
var hashLabelEl = document.getElementById('hash-label');

var updateUi = function() {
  if (articleId) {
    noArticleMsgEl.style.display = 'none';
    article.style.display = 'block';
    imgEl.src = 'http://lorempixel.com/' + articleId + '/' + articleId;
    idLabelEl.innerText = articleId || 'null';
    hashLabelEl.innerText = window.location.hash || 'null';
  }
}

var handleHashChange = function() {
  var hash = window.location.hash;
  if (hash) {
    var hashMatches = window.location.hash.match(/#!-A(\d+)/)
    var newArticleId = hashMatches && hashMatches[1] || null;
    if (articleId !== newArticleId) {
      articleId = newArticleId;
      updateUi();
    }
  }
};

// Listen and execute if the hash changes
window.addEventListener('hashchange', handleHashChange);

// Execute once on page load
handleHashChange();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#no-article-msg {
  color: #444;
  text-align: center;
  padding: 10px;
}

#article {
  display: none;
  border: 1px solid #666;
  border-radius: 2px;
  text-align: center;
  padding: 10px;
}

#img {
  width: 75px;
  height: 75px;
  background: #fafafa;
}</code>```

Click One:
Article 101 |
Article 152 |
Article 200 |
Article 164

No Article Loaded.

  Current Hash:

  Current Article Id:

```

Body:
In a PHP file, i am using a javascript to integrate Spreadshop app into my website.

When an user clicks on an article, it display the article using an URL like this:

https://www.example.com/#!-A108148940

I need to extract the article ID from this url ( 108148940 ) to display an image ( /images/108148940.jpg ) using PHP or Javascript, but only if we are currently viewing the article page (i.e. look for #!-A in the url)

This is the first time i'm forced to use shebang. Why isn't there an easy way to extract the variable just like $_GET['whatever'] with php ?

Body:
PHP, being a server-side scripting language, won't be able to see the location's hash when the page loads; it's only available to the browser and its client.

Luckily, you can use JavaScript. Here's a fully mocked up example:

var articleId = null;

var noArticleMsgEl = document.getElementById('no-article-msg');
var articleEl = document.getElementById('article');
var imgEl = document.getElementById('img');
var idLabelEl = document.getElementById('id-label');
var hashLabelEl = document.getElementById('hash-label');

var updateUi = function() {
  if (articleId) {
    noArticleMsgEl.style.display = 'none';
    article.style.display = 'block';
    imgEl.src = 'http://lorempixel.com/' + articleId + '/' + articleId;
    idLabelEl.innerText = articleId || 'null';
    hashLabelEl.innerText = window.location.hash || 'null';
  }
}

var handleHashChange = function() {
  var hash = window.location.hash;
  if (hash) {
    var hashMatches = window.location.hash.match(/#!-A(\d+)/)
    var newArticleId = hashMatches && hashMatches[1] || null;
    if (articleId !== newArticleId) {
      articleId = newArticleId;
      updateUi();
    }
  }
};

// Listen and execute if the hash changes
window.addEventListener('hashchange', handleHashChange);

// Execute once on page load
handleHashChange();

#no-article-msg {
  color: #444;
  text-align: center;
  padding: 10px;
}

#article {
  display: none;
  border: 1px solid #666;
  border-radius: 2px;
  text-align: center;
  padding: 10px;
}

#img {
  width: 75px;
  height: 75px;
  background: #fafafa;
}

Click One:
<a href="#!-A101">Article 101</a> |
<a href="#!-A152">Article 152</a> |
<a href="#!-A200">Article 200</a> |
<a href="#!-A164">Article 164</a>

<br><br>
<div id="no-article-msg">No Article Loaded.</div>
<article id="article">
  <img id="img" /><br>
  <small><u>Current Hash:</u> <span id="hash-label"></span></small><br>
  <small><u>Current Article Id:</u> <span id="id-label"></span></small><br>
</article>


问:
importing a database into phpmyadmin #1044 - Access denied for user
I have recently purchased web hosting service at godaddy. I have already completed my project and i used xampp. Now i want to import the database which i  arleady have. I tried to do it in the normal way by clicking on import and choosing the file. But i'm getting this error

How can I fix this?

答: Must Ensure that your User_Name, Password and Database name are correct. If you are Deal with database 'sampled' then type 'sampled' in query instead of 'db' also must ensure that you don't have to use quota(') in Statement. For More and Accurate Detail visit Following link: http://onephin.com/1044-access-denied-user-user_namelocalhost-database-database_name/</p>


问:
How can I deploy Application in geronimo 3.0.1?
I am new to handling geronimo.Today I installed geronimo 3.0.1 in my system,already I have built web-Application and it is in folder format, I don't know where to put this folder. How can I test the application whether working or not.

Thank

答:
You can use this command line inside bin folder of geronimo:
deploy -port [port]--user [user] --password [password] deploy D:\projects\td-selection-esb\dist\td-selection-esb-*.war

After deploying successfully it will be inside the repository folder of geronimo.


问:
please help with a simple Prolog question
I have the following Prolog code in my program:

```<code>conn([oxford_circus, baker_street], 4).
conn([baker_street, kings_cross], 5).
conn([oxford_circus, warren_street], 3).
conn([warren_street, tottenham], 2).
conn([oxford_circus, tottenham], 2).
conn([tottenham, holborn], 1).
conn([holbor, kings_cross], 4).

s(N, M, C) :-
  conn(L, C),
  member(N, L),
  member(M, L).
</code>```

Now I call the s predicate as s(oxford_circus, M, C)., but unfortunately it does fail, instead of telling me for example:

```<code>M = baker_street
C = 4
</code>```

I am sure this is a very simple error, but it seems I can't find it :(

Thanks in advance for any guidance!

Cheers!

答:
It works as you expect in my swi prolog.
Could it be than you need to use a proper command line?
For example the typical problem with swi prolog is not to use -s or -c flag.</p>

ContentLicense: CC BY-SA 2.5

Body:
I have the following Prolog code in my program:

conn([oxford_circus, baker_street], 4).
conn([baker_street, kings_cross], 5).
conn([oxford_circus, warren_street], 3).
conn([warren_street, tottenham], 2).
conn([oxford_circus, tottenham], 2).
conn([tottenham, holborn], 1).
conn([holbor, kings_cross], 4).

s(N, M, C) :-
  conn(L, C),
  member(N, L),
  member(M, L).

Now I call the s predicate as s(oxford_circus, M, C)., but unfortunately it does fail, instead of telling me for example:

M = baker_street
C = 4

I am sure this is a very simple error, but it seems I can't find it :(

Thanks in advance for any guidance!

Cheers!


问:
How to make a method run only once in the lifetime of application
I have a method that fills in a file with default values and I call that method in the constructor. I want that method to run only once ( I mean by only once so when the user press the play button /in eclipse/ then that method will not run in the second press.

I have tried something like this but it doesn't work :

```<code>private boolean defaultExecuted;
public synchronized void defaultStatsFile()
{
    if (defaultExecuted)
    {
        return;
    }
    else
    {
        fileReadNWrite.configWriter("panel1", "non-US incidents");
        fileReadNWrite.configWriter("panel2", "Hoaxes");
        fileReadNWrite.configWriter("panel3", "Under NUFORC investigation");
        fileReadNWrite.configWriter("panel4", "Likliest Shape");
        defaultExecuted = true;
    }

}
</code>```

Is there a smarter way to fill in a file only once ?

Please if something is not clear comment and I will reply.
Any help is appreciated.

答:
Better you fill data in static block

like : including proper exception handling in Main class , this way no need to dependent on constructor to load default data in file.

```<code>static {
            fileReadNWrite.configWriter("panel1", "non-US incidents");
            fileReadNWrite.configWriter("panel2", "Hoaxes");
            fileReadNWrite.configWriter("panel3", "Under NUFORC investigation");
            fileReadNWrite.configWriter("panel4", "Likliest Shape");
            defaultExecuted = true;
}
</code>```

Body:
I have a method that fills in a file with default values and I call that method in the constructor. I want that method to run only once ( I mean by only once so when the user press the play button /in eclipse/ then that method will not run in the second press.

I have tried something like this but it doesn't work :

private boolean defaultExecuted;
public synchronized void defaultStatsFile()
{
    if (defaultExecuted)
    {
        return;
    }
    else
    {
        fileReadNWrite.configWriter("panel1", "non-US incidents");
        fileReadNWrite.configWriter("panel2", "Hoaxes");
        fileReadNWrite.configWriter("panel3", "Under NUFORC investigation");
        fileReadNWrite.configWriter("panel4", "Likliest Shape");
        defaultExecuted = true;
    }

}

Is there a smarter way to fill in a file only once ?

Please if something is not clear comment and I will reply.
Any help is appreciated.

Body:
Better you fill data in static block

like : including proper exception handling in Main class , this way no need to dependent on constructor to load default data in file.

static {
            fileReadNWrite.configWriter("panel1", "non-US incidents");
            fileReadNWrite.configWriter("panel2", "Hoaxes");
            fileReadNWrite.configWriter("panel3", "Under NUFORC investigation");
            fileReadNWrite.configWriter("panel4", "Likliest Shape");
            defaultExecuted = true;
}


问:
Simple buffer overflow via xinetd
I'm trying to make a simple buffer overflow tutorial that runs the program below as a service on port 8000 via xinetd. Code was compiled using

```<code>gcc -o bof bof.c -fno-stack-protector
</code>```

ubuntu has stack protection turned off as well.

Exploiting locally i.e

```<code>python -c ---snippet--- | ./bof
</code>```

is successful and the hidden function was executed, displaying text file contents.

However, running it as a service and performing

```<code>python -c ---snippet--- | nc localhost 8000
</code>```

returns nothing when exploiting. Am I missing something here?

```<code>#include <stdio.h>

void secret()
{
    int c;
    FILE *file;
    file = fopen("congratulations.txt", "r");
    if (file) {
    while ((c= getc(file)) !=EOF)
    putchar(c);
    fclose(file);

}

void textdisplay()
{
    char buffer[56];

    scanf("%s", buffer);
    printf("You entered: %s\n", buffer);
}

int main()
{
    textdisplay();

    return 0;
}
</code>```

答:
This is an issue that I am running into as well. Almost exactly the same.

However, here is one piece that I have found out that might be helpful to you. I believe the issue has something to do with xinetd not executing the binary as a terminal and having job control.

So what I did was to have xinetd do:

```<code>server = /usr/bin/python
server_args = /opt/shell.py
</code>```

Then within the /opt/shell.py I had:

```<code>import pty
pty.spawn("/opt/oflow.elf")
</code>```

/opt/oflow.elf being my overflowed binary

When I do this, I can actually send and receive data. Thats when I run the following command via netcat to try and overflow the service remotely:

```<code>**printf "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80AAAAAAAAAAAAAAAAAAAAAAAAABCDEFGHIJKLMNOPQ\x7c\xfc\xff\xbf" | nc 192.168.1.2 9000**
</code>```

This does nothing. However, I test the local version and it works PERFECTLY.  Works every time.

Not when its being wrapped in a python pty and xinetd.

When I run the xinetd pointing directly to /opt/oflow.elf, I get absolutely nothing back from netcat.

So that doesn't exactly answer your question but it should whittle it down for you.

UPDATED COMPLETE ANSWER:

I figured out why this wasnt working. No need to use python at all. After every printf statement you must also include:

```<code>fflush(stdout);
</code>```

Otherwise, xinetd doesnt know to send the stdout.

You may also need to do this for stdin:

```<code>fflush(stdin);
</code>```

Title: Simple buffer overflow via xinetd

Body:
I'm trying to make a simple buffer overflow tutorial that runs the program below as a service on port 8000 via xinetd. Code was compiled using

gcc -o bof bof.c -fno-stack-protector

ubuntu has stack protection turned off as well.

Exploiting locally i.e

python -c ---snippet--- | ./bof

is successful and the hidden function was executed, displaying text file contents.

However, running it as a service and performing

python -c ---snippet--- | nc localhost 8000

returns nothing when exploiting. Am I missing something here?

#include <stdio.h>

void secret()
{
    int c;
    FILE *file;
    file = fopen("congratulations.txt", "r");
    if (file) {
    while ((c= getc(file)) !=EOF)
    putchar(c);
    fclose(file);

}

void textdisplay()
{
    char buffer[56];

    scanf("%s", buffer);
    printf("You entered: %s\n", buffer);
}

int main()
{
    textdisplay();

    return 0;
}

Body:
This is an issue that I am running into as well. Almost exactly the same.

However, here is one piece that I have found out that might be helpful to you. I believe the issue has something to do with xinetd not executing the binary as a terminal and having job control.

So what I did was to have xinetd do:

server = /usr/bin/python
server_args = /opt/shell.py

Then within the /opt/shell.py I had:

import pty
pty.spawn("/opt/oflow.elf")

/opt/oflow.elf being my overflowed binary

When I do this, I can actually send and receive data. Thats when I run the following command via netcat to try and overflow the service remotely:

**printf "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80AAAAAAAAAAAAAAAAAAAAAAAAABCDEFGHIJKLMNOPQ\x7c\xfc\xff\xbf" | nc 192.168.1.2 9000**

This does nothing. However, I test the local version and it works PERFECTLY.  Works every time.

Not when its being wrapped in a python pty and xinetd.

When I run the xinetd pointing directly to /opt/oflow.elf, I get absolutely nothing back from netcat.

So that doesn't exactly answer your question but it should whittle it down for you.

UPDATED COMPLETE ANSWER:

I figured out why this wasnt working. No need to use python at all. After every printf statement you must also include:

fflush(stdout);

Otherwise, xinetd doesnt know to send the stdout.

You may also need to do this for stdin:

fflush(stdin);


答:
What you want to do it move through only half of the length of your array else you're reversing the array twice.</p>

```<code>void reverse(int a[], int len)
{
    int i;
    int j=len-1,b;
    for(i=0;i<len/2;i++)
    {
        b=a[i];
        a[i]=a[j];
        a[j]=b;
        j--;
    }

    for(i = 0; i < len; i++) {
        printf("Element %d is: %d\n", i,a[i]);
    }
}
</code>```

Title: Reversing array elements in C programming

Body:
What you want to do it move through only half of the length of your array else you're reversing the array twice.

void reverse(int a[], int len)
{
    int i;
    int j=len-1,b;
    for(i=0;i<len/2;i++)
    {
        b=a[i];
        a[i]=a[j];
        a[j]=b;
        j--;
    }

    for(i = 0; i < len; i++) {
        printf("Element %d is: %d\n", i,a[i]);
    }
}


问:
Using radio button values in php to make one of three divs appear
Hi I have a dropdown menu system that has three radio buttons in the first section that are disguised as images. After selecting one of these radio buttons I would like it for it to change the next section to the corresponding div (laptop, tablet or phone). The part that I am confused on is how to get the value from the radio button WITHOUT having to use a submit button. I would then like to use php to echo out the correct div. I'm thinking that I would have to echo out a variable after running an if statement to compare the radio button values. I just can't seem to find out how to trigger the script without using a submit button.

JS FIDDLE (Doesn't include php)

https://jsfiddle.net/4crj2ash/

HTML

```<code>   <button class="accordion">
                    <h2 class="text-center">Screen Type</h2></button>
                <div class="panel text-center" id="type_panel">
                    <label class="icon-select">
                        <input type="radio" name="type" id="laptop_button" value="laptop" /> <img src="icons/iconmonstr-laptop-4-120.png" alt="laptop"> </label>
                    <label class="icon-select">
                        <input type="radio" name="type" id="tablet_button" value="tablet" /> <img src="icons/iconmonstr-tablet-1-120.png" alt="tablet"> </label>
                    <label class="icon-select">
                        <input type="radio" name="type" id="phone_button" value="phone" /> <img src="icons/iconmonstr-smartphone-3-120.png" alt="phone"> </label>
                </div>
                <button class="accordion">
                    <h2 class="text-center">Model</h2></button>

               <?php echo $finalval; ?>
</code>```

CSS

```<code>#pricing_holder {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-bottom: 20px;
}

.icon-select {
    margin-right: 20px;
    margin-left: 20px;
}

#col1 {
    float: left;
    width: 285px;
    height: 65px;
}

#col2 {
    float: none;
    height: 65px;
    overflow: hidden;
    display: table-cell;
}

#col3 {
    float: right;
    height: 65px;
}

button.accordion {
    background-color: #ffffff;
    color: #444;
    cursor: pointer;
    padding: 12px;
    width: 75%;
    text-align: left;
    outline: none;
    transition: 0.4s;
    border-left: 1px solid grey;
    border-right: 1px solid grey;
    border-top: 1px solid grey;
    border-radius: 4px;
    border-bottom: none;
}

button.accordion.active,
button.accordion:hover {
    background-color: #6fdd7a;
    color: #ffffff;
}

div.panel {
    padding: 0px 18px;
    background-color: #ffffff;
    max-height: 0;
    overflow: hidden;
    width: 71%;
    display: block;
    transition: max-height 0.2s ease-out;
    border: 1px solid grey;
}

label > input {
    visibility: hidden;
    position: absolute;
}

label > input + img {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 2px;
    -webkit-transition: all 0.25s linear;
}

label > input:checked + img {
    background-color: #6fdd7a;
}

.invisible {
    display: none;
}

.control {
    font-size: 18px;
    position: relative;
    display: block;
    margin-bottom: 15px;
    padding-left: 30px;
    cursor: pointer;
}

.control input {
    position: absolute;
    z-index: -1;
    opacity: 0;
}

.control__indicator {
    position: absolute;
    top: 2px;
    left: 0;
    width: 20px;
    height: 20px;
    background: #e6e6e6;
}

.control--radio .control__indicator {
    border-radius: 50%;
}

.control:hover input ~ .control__indicator,
.control input:focus ~ .control__indicator {
    background: #ccc;
}

.control input:checked ~ .control__indicator {
    background: #6fdd7a;
}

.control:hover input:not([disabled]):checked ~ .control__indicator,
.control input:checked:focus ~ .control__indicator {
    background: #6fdd7a;
}

.control__indicator:after {
    position: absolute;
    display: none;
    content: '';
}

.control input:checked ~ .control__indicator:after {
    display: block;
}

.control--checkbox .control__indicator:after {
    top: 4px;
    left: 8px;
    width: 3px;
    height: 8px;
    transform: rotate(45deg);
    border: solid #fff;
    border-width: 0 2px 2px 0;
}

.control--checkbox input:disabled ~ .control__indicator:after {
    border-color: #7b7b7b;
}

.control--radio .control__indicator:after {
    top: 7px;
    left: 7px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
}

.control--radio input:disabled ~ .control__indicator:after {
    background: #7b7b7b;
}
</code>```

JS

```<code>var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
  acc[i].onclick = function() {
    this.classList.toggle("active");
    var panel = this.nextElementSibling;
    if (panel.style.maxHeight){
      panel.style.maxHeight = null;
    } else {
      panel.style.maxHeight = panel.scrollHeight + "px";
    }
  }
}

var typeselect = $("input[name='type']:checked").attr('id');

$("laptop_button").click(function(){
    $("laptop_panel").toggleClass("invisible");
});

$("tablet_button").click(function(){
    $("tablet_panel").toggleClass("invisible");
});

$("phone_button").click(function(){
    $("phone_panel").toggleClass("invisible");
});
</code>```

PHP

```<code> <?php

    if (radval == 'phone') {
        $finalval = '<div class="panel" id="laptop_panel">
                    <div id="col1">
                        <label class="control control--radio">LAPTOP
                            <input type="radio" name="radio-laptop" />
                            <div class="control__indicator"></div>
                        </label>
                    </div>
                    <div id="col3">
                        <label class="control control--radio">LAPTOP2
                            <input type="radio" name="radio-laptop" />
                            <div class="control__indicator"></div>
                        </label>
                    </div>
                    <div id="col2">
                        <label class="control control--radio">LAPTOP3
                            <input type="radio" name="radio-laptop" />
                            <div class="control__indicator"></div>
                        </label>
                    </div>
                </div>';
    } elseif (radval == 'tablet') {
        $finalval = ' <div class="panel" id="tablet_panel">
                    <div id="col1">
                        <label class="control control--radio">TABLET1
                            <input type="radio" name="radio-tablet" />
                            <div class="control__indicator"></div>
                        </label>
                    </div>
                    <div id="col3">
                        <label class="control control--radio">TABLET2
                            <input type="radio" name="radio-tablet" />
                            <div class="control__indicator"></div>
                        </label>
                    </div>
                    <div id="col2">
                        <label class="control control--radio">TABLET3
                            <input type="radio" name="radio-tablet" />
                            <div class="control__indicator"></div>
                        </label>
                    </div>
                </div>';
    } elseif (radval == 'laptop') {
        $finalval = '<div class="panel" id="phone_panel">
                    <div id="col1">
                        <label class="control control--radio">iPhone 3
                            <input type="radio" name="radio-phone" />
                            <div class="control__indicator"></div>
                        </label>
                    </div>
                    <div id="col3">
                        <label class="control control--radio">Microsoft Lumia 430
                            <input type="radio" name="radio-phone" />
                            <div class="control__indicator"></div>
                        </label>
                    </div>
                    <div id="col2">
                        <label class="control control--radio">Galaxy S3
                            <input type="radio" name="radio-phone" />
                            <div class="control__indicator"></div>
                        </label>
                    </div>
                </div>';
    } else {
        echo '<p>Something went wrong</p>';
    }

?>
</code>```

I'm lost on what types of functions and way I should use them so for what i didn't know i filled with pseudo code.

答:
If you include Value on your radio button, like below, you can actually pull the value on each click/change.

html

```<code><input type="radio" name="type" id="laptop_button" value="laptop" />
...

<input type="radio" name="type" id="tablet_button" value="tablet" />
...

<input type="radio" name="type" id="phone_button" value="phone" />
...

  <button class="accordion type-accordion">
    <h2 class="text-center">
      Model
      <span id="selectedType"></span>
    </h2>
  </button>
</code>```

code

```<code>$("input[name='type']").change(function(e) {
  var selectedType = $(this).val();
  $("#selectedType").html(selectedType.toUpperCase());
}
</code>```

And to highlight issues with your code.
Below code will not work because you missed # ID selection. To select ID (get element by ID) in jQuery, you need to include # tag.
e.g. $("#laptop_button")

```<code>$("laptop_button").click(function(){
    $("laptop_panel").toggleClass("invisible");
});

$("tablet_button").click(function(){
    $("tablet_panel").toggleClass("invisible");
});

$("phone_button").click(function(){
    $("phone_panel").toggleClass("invisible");
});
</code>```

Just for fun, I have completed your Screen Type and Device selection accordion.

$(".accordion").click(function(e) {
  $(this).toggleClass("active");

  var nextPanel = $(this).next(".panel");
  console.log(nextPanel);

  if ($(this).hasClass("active")) {
    // showPanel(nextPanel);
    nextPanel.showPanel();

    // hide default_panel when type is already selected
    if ((nextPanel.attr("id") === "default_panel") && ($("#selectedType").html() !== "")) {
      // hidePanel(nextPanel);
      nextPanel.hidePanel();
    }

  } else {
    // hidePanel(nextPanel);
    nextPanel.hidePanel();
  }

});

$("input[name='type']").change(function(e) {

  var selectedType = $(this).val();
  var selectedTypeID = "#" + selectedType + "_panel";

  $("#selectedType").html(selectedType.toUpperCase());

  // hide all device panel
  // $(".device-panel")
  //  .hide()
  //   .each(function() {
  //    hidePanel($(this));
  //   });
  $(".device-panel").hidePanel();

  // hide default panel if device type is selected
  $("#default_panel").hidePanel();

  // ensure that type-accordion button is always 'active'
  $(".type-accordion").removeClass("active").addClass("active");

  console.log("selected device type", selectedType, $(selectedTypeID));

  // showPanel( $(selectedTypeID) );
  $(selectedTypeID).showPanel();
});

// extend jQuery object
(function($) {

  $.fn.showPanel = function() {
    $(this)
      .show()
      .css("height", $(this)[0].scrollHeight + "px")
      .css("max-height", $(this)[0].scrollHeight + "px");
  };

  $.fn.hidePanel = function() {
    $(this)
      .hide()
      .css("height", "0px")
      .css("max-height", "0px");
  };

}(jQuery));

/*
function showPanel(panel) {
  panel
    .show()
    .css("height", panel[0].scrollHeight + "px")
    .css("max-height", panel[0].scrollHeight + "px");
}

function hidePanel(panel) {
  panel
   .hide()
    .css("height", "0px")
    .css("max-height", "0px");
}
*/```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#pricing_holder {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-bottom: 20px;
}

.icon-select {
  margin-right: 20px;
  margin-left: 20px;
}

#col1 {
  float: left;
  width: 285px;
  height: 65px;
}

#col2 {
  float: none;
  height: 65px;
  overflow: hidden;
  display: table-cell;
}

#col3 {
  float: right;
  height: 65px;
}

button.accordion {
  background-color: #ffffff;
  color: #444;
  cursor: pointer;
  padding: 12px;
  width: 75%;
  text-align: left;
  outline: none;
  transition: 0.4s;
  border-left: 1px solid grey;
  border-right: 1px solid grey;
  border-top: 1px solid grey;
  border-radius: 4px;
  border-bottom: none;
}

button.accordion.active,
button.accordion:hover {
  background-color: #6fdd7a;
  color: #ffffff;
}

div.panel {
  padding: 0px 18px;
  background-color: #ffffff;
  max-height: 0;
  overflow: hidden;
  width: 71%;
  display: block;
  transition: max-height 0.2s ease-out;
  border: 1px solid grey;
}

label>input {
  visibility: hidden;
  position: absolute;
}

label>input+img {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 2px;
  -webkit-transition: all 0.25s linear;
}

label>input:checked+img {
  background-color: #6fdd7a;
}

.invisible {
  display: none;
}

.control {
  font-size: 18px;
  position: relative;
  display: block;
  margin-bottom: 15px;
  padding-left: 30px;
  cursor: pointer;
}

.control input {
  position: absolute;
  z-index: -1;
  opacity: 0;
}

.control__indicator {
  position: absolute;
  top: 2px;
  left: 0;
  width: 20px;
  height: 20px;
  background: #e6e6e6;
}

.control--radio .control__indicator {
  border-radius: 50%;
}

.control:hover input~.control__indicator,
.control input:focus~.control__indicator {
  background: #ccc;
}

.control input:checked~.control__indicator {
  background: #6fdd7a;
}

.control:hover input:not([disabled]):checked~.control__indicator,
.control input:checked:focus~.control__indicator {
  background: #6fdd7a;
}

.control__indicator:after {
  position: absolute;
  display: none;
  content: '';
}

.control input:checked~.control__indicator:after {
  display: block;
}

.control--checkbox .control__indicator:after {
  top: 4px;
  left: 8px;
  width: 3px;
  height: 8px;
  transform: rotate(45deg);
  border: solid #fff;
  border-width: 0 2px 2px 0;
}

.control--checkbox input:disabled~.control__indicator:after {
  border-color: #7b7b7b;
}

.control--radio .control__indicator:after {
  top: 7px;
  left: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}

.control--radio input:disabled~.control__indicator:after {
  background: #7b7b7b;
}</code>```

  <button class="accordion">

Screen Type
</button>

          <input type="radio" name="type" id="laptop_button" value="laptop" />

          <input type="radio" name="type" id="tablet_button" value="tablet" />

          <input type="radio" name="type" id="phone_button" value="phone" />

  <button class="accordion type-accordion">

            Model

      </button>

Please select a Device Type above

      LAPTOP
            <input type="radio" name="radio-laptop" />

      LAPTOP2
            <input type="radio" name="radio-laptop" />

      LAPTOP3
            <input type="radio" name="radio-laptop" />

      TABLET1
            <input type="radio" name="radio-tablet" />

      TABLET2
            <input type="radio" name="radio-tablet" />

      TABLET3
            <input type="radio" name="radio-tablet" />

      iPhone 3
            <input type="radio" name="radio-phone" />

      Microsoft Lumia 430
            <input type="radio" name="radio-phone" />

      Galaxy S3
            <input type="radio" name="radio-phone" />

```

Body:
Hi I have a dropdown menu system that has three radio buttons in the first section that are disguised as images. After selecting one of these radio buttons I would like it for it to change the next section to the corresponding div (laptop, tablet or phone). The part that I am confused on is how to get the value from the radio button WITHOUT having to use a submit button. I would then like to use php to echo out the correct div. I'm thinking that I would have to echo out a variable after running an if statement to compare the radio button values. I just can't seem to find out how to trigger the script without using a submit button.

JS FIDDLE (Doesn't include php)

https://jsfiddle.net/4crj2ash/

HTML

   <button class="accordion">

Screen Type
</button>

                        <input type="radio" name="type" id="laptop_button" value="laptop" />

                        <input type="radio" name="type" id="tablet_button" value="tablet" />

                        <input type="radio" name="type" id="phone_button" value="phone" />

                <button class="accordion">

Model
</button>

               <?php echo $finalval; ?>

CSS

#pricing_holder {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-bottom: 20px;
}

.icon-select {
    margin-right: 20px;
    margin-left: 20px;
}

#col1 {
    float: left;
    width: 285px;
    height: 65px;
}

#col2 {
    float: none;
    height: 65px;
    overflow: hidden;
    display: table-cell;
}

#col3 {
    float: right;
    height: 65px;
}

button.accordion {
    background-color: #ffffff;
    color: #444;
    cursor: pointer;
    padding: 12px;
    width: 75%;
    text-align: left;
    outline: none;
    transition: 0.4s;
    border-left: 1px solid grey;
    border-right: 1px solid grey;
    border-top: 1px solid grey;
    border-radius: 4px;
    border-bottom: none;
}

button.accordion.active,
button.accordion:hover {
    background-color: #6fdd7a;
    color: #ffffff;
}

div.panel {
    padding: 0px 18px;
    background-color: #ffffff;
    max-height: 0;
    overflow: hidden;
    width: 71%;
    display: block;
    transition: max-height 0.2s ease-out;
    border: 1px solid grey;
}

label > input {
    visibility: hidden;
    position: absolute;
}

label > input + img {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 2px;
    -webkit-transition: all 0.25s linear;
}

label > input:checked + img {
    background-color: #6fdd7a;
}

.invisible {
    display: none;
}

.control {
    font-size: 18px;
    position: relative;
    display: block;
    margin-bottom: 15px;
    padding-left: 30px;
    cursor: pointer;
}

.control input {
    position: absolute;
    z-index: -1;
    opacity: 0;
}

.control__indicator {
    position: absolute;
    top: 2px;
    left: 0;
    width: 20px;
    height: 20px;
    background: #e6e6e6;
}

.control--radio .control__indicator {
    border-radius: 50%;
}

.control:hover input ~ .control__indicator,
.control input:focus ~ .control__indicator {
    background: #ccc;
}

.control input:checked ~ .control__indicator {
    background: #6fdd7a;
}

.control:hover input:not([disabled]):checked ~ .control__indicator,
.control input:checked:focus ~ .control__indicator {
    background: #6fdd7a;
}

.control__indicator:after {
    position: absolute;
    display: none;
    content: '';
}

.control input:checked ~ .control__indicator:after {
    display: block;
}

.control--checkbox .control__indicator:after {
    top: 4px;
    left: 8px;
    width: 3px;
    height: 8px;
    transform: rotate(45deg);
    border: solid #fff;
    border-width: 0 2px 2px 0;
}

.control--checkbox input:disabled ~ .control__indicator:after {
    border-color: #7b7b7b;
}

.control--radio .control__indicator:after {
    top: 7px;
    left: 7px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
}

.control--radio input:disabled ~ .control__indicator:after {
    background: #7b7b7b;
}

JS

var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
  acc[i].onclick = function() {
    this.classList.toggle("active");
    var panel = this.nextElementSibling;
    if (panel.style.maxHeight){
      panel.style.maxHeight = null;
    } else {
      panel.style.maxHeight = panel.scrollHeight + "px";
    }
  }
}

var typeselect = $("input[name='type']:checked").attr('id');

$("laptop_button").click(function(){
    $("laptop_panel").toggleClass("invisible");
});

$("tablet_button").click(function(){
    $("tablet_panel").toggleClass("invisible");
});

$("phone_button").click(function(){
    $("phone_panel").toggleClass("invisible");
});

PHP

 <?php

    if (radval == 'phone') {
        $finalval = '

                        LAPTOP
                            <input type="radio" name="radio-laptop" />

                        LAPTOP2
                            <input type="radio" name="radio-laptop" />

                        LAPTOP3
                            <input type="radio" name="radio-laptop" />

';
    } elseif (radval == 'tablet') {
        $finalval = '

                        TABLET1
                            <input type="radio" name="radio-tablet" />

                        TABLET2
                            <input type="radio" name="radio-tablet" />

                        TABLET3
                            <input type="radio" name="radio-tablet" />

';
    } elseif (radval == 'laptop') {
        $finalval = '

                        iPhone 3
                            <input type="radio" name="radio-phone" />

                        Microsoft Lumia 430
                            <input type="radio" name="radio-phone" />

                        Galaxy S3
                            <input type="radio" name="radio-phone" />

';
    } else {
        echo '
Something went wrong
';
    }

?>

I'm lost on what types of functions and way I should use them so for what i didn't know i filled with pseudo code.

Body:
If you include Value on your radio button, like below, you can actually pull the value on each click/change.

html

<input type="radio" name="type" id="laptop_button" value="laptop" />
...

<input type="radio" name="type" id="tablet_button" value="tablet" />
...

<input type="radio" name="type" id="phone_button" value="phone" />
...

  <button class="accordion type-accordion">
    <h2 class="text-center">
      Model
      <span id="selectedType"></span>
    </h2>
  </button>

code

$("input[name='type']").change(function(e) {
  var selectedType = $(this).val();
  $("#selectedType").html(selectedType.toUpperCase());
}

And to highlight issues with your code.
Below code will not work because you missed # ID selection. To select ID (get element by ID) in jQuery, you need to include # tag.
e.g. $("#laptop_button")

$("laptop_button").click(function(){
    $("laptop_panel").toggleClass("invisible");
});

$("tablet_button").click(function(){
    $("tablet_panel").toggleClass("invisible");
});

$("phone_button").click(function(){
    $("phone_panel").toggleClass("invisible");
});

Just for fun, I have completed your Screen Type and Device selection accordion.

$(".accordion").click(function(e) {
  $(this).toggleClass("active");

  var nextPanel = $(this).next(".panel");
  console.log(nextPanel);

  if ($(this).hasClass("active")) {
    // showPanel(nextPanel);
    nextPanel.showPanel();

    // hide default_panel when type is already selected
    if ((nextPanel.attr("id") === "default_panel") && ($("#selectedType").html() !== "")) {
      // hidePanel(nextPanel);
      nextPanel.hidePanel();
    }

  } else {
    // hidePanel(nextPanel);
    nextPanel.hidePanel();
  }

});

$("input[name='type']").change(function(e) {

  var selectedType = $(this).val();
  var selectedTypeID = "#" + selectedType + "_panel";

  $("#selectedType").html(selectedType.toUpperCase());

  // hide all device panel
  // $(".device-panel")
  //  .hide()
  //   .each(function() {
  //    hidePanel($(this));
  //   });
  $(".device-panel").hidePanel();

  // hide default panel if device type is selected
  $("#default_panel").hidePanel();

  // ensure that type-accordion button is always 'active'
  $(".type-accordion").removeClass("active").addClass("active");

  console.log("selected device type", selectedType, $(selectedTypeID));

  // showPanel( $(selectedTypeID) );
  $(selectedTypeID).showPanel();
});

// extend jQuery object
(function($) {

  $.fn.showPanel = function() {
    $(this)
      .show()
      .css("height", $(this)[0].scrollHeight + "px")
      .css("max-height", $(this)[0].scrollHeight + "px");
  };

  $.fn.hidePanel = function() {
    $(this)
      .hide()
      .css("height", "0px")
      .css("max-height", "0px");
  };

}(jQuery));

/*
function showPanel(panel) {
  panel
    .show()
    .css("height", panel[0].scrollHeight + "px")
    .css("max-height", panel[0].scrollHeight + "px");
}

function hidePanel(panel) {
  panel
   .hide()
    .css("height", "0px")
    .css("max-height", "0px");
}
*/

#pricing_holder {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-bottom: 20px;
}

.icon-select {
  margin-right: 20px;
  margin-left: 20px;
}

#col1 {
  float: left;
  width: 285px;
  height: 65px;
}

#col2 {
  float: none;
  height: 65px;
  overflow: hidden;
  display: table-cell;
}

#col3 {
  float: right;
  height: 65px;
}

button.accordion {
  background-color: #ffffff;
  color: #444;
  cursor: pointer;
  padding: 12px;
  width: 75%;
  text-align: left;
  outline: none;
  transition: 0.4s;
  border-left: 1px solid grey;
  border-right: 1px solid grey;
  border-top: 1px solid grey;
  border-radius: 4px;
  border-bottom: none;
}

button.accordion.active,
button.accordion:hover {
  background-color: #6fdd7a;
  color: #ffffff;
}

div.panel {
  padding: 0px 18px;
  background-color: #ffffff;
  max-height: 0;
  overflow: hidden;
  width: 71%;
  display: block;
  transition: max-height 0.2s ease-out;
  border: 1px solid grey;
}

label>input {
  visibility: hidden;
  position: absolute;
}

label>input+img {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 2px;
  -webkit-transition: all 0.25s linear;
}

label>input:checked+img {
  background-color: #6fdd7a;
}

.invisible {
  display: none;
}

.control {
  font-size: 18px;
  position: relative;
  display: block;
  margin-bottom: 15px;
  padding-left: 30px;
  cursor: pointer;
}

.control input {
  position: absolute;
  z-index: -1;
  opacity: 0;
}

.control__indicator {
  position: absolute;
  top: 2px;
  left: 0;
  width: 20px;
  height: 20px;
  background: #e6e6e6;
}

.control--radio .control__indicator {
  border-radius: 50%;
}

.control:hover input~.control__indicator,
.control input:focus~.control__indicator {
  background: #ccc;
}

.control input:checked~.control__indicator {
  background: #6fdd7a;
}

.control:hover input:not([disabled]):checked~.control__indicator,
.control input:checked:focus~.control__indicator {
  background: #6fdd7a;
}

.control__indicator:after {
  position: absolute;
  display: none;
  content: '';
}

.control input:checked~.control__indicator:after {
  display: block;
}

.control--checkbox .control__indicator:after {
  top: 4px;
  left: 8px;
  width: 3px;
  height: 8px;
  transform: rotate(45deg);
  border: solid #fff;
  border-width: 0 2px 2px 0;
}

.control--checkbox input:disabled~.control__indicator:after {
  border-color: #7b7b7b;
}

.control--radio .control__indicator:after {
  top: 7px;
  left: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}

.control--radio input:disabled~.control__indicator:after {
  background: #7b7b7b;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div id="pricing_holder">
  <button class="accordion">
        <h2 class="text-center">Screen Type</h2></button>

  <div class="panel text-center" id="type_panel">
    <label class="icon-select">
          <input type="radio" name="type" id="laptop_button" value="laptop" /> <img height="70px" src="https://iconmonstr.com/wp-content/g/gd/makefg.php?i=../assets/preview/2012/png/iconmonstr-laptop-4.png&r=0&g=0&b=0" alt="laptop"> </label>
    <label class="icon-select">
          <input type="radio" name="type" id="tablet_button" value="tablet" /> <img height="70px" src="https://iconmonstr.com/wp-content/g/gd/makefg.php?i=../assets/preview/2012/png/iconmonstr-tablet-1.png&r=0&g=0&b=0" alt="tablet"> </label>
    <label class="icon-select">
          <input type="radio" name="type" id="phone_button" value="phone" /> <img height="70px" src="https://cdns.iconmonstr.com/wp-content/assets/preview/2012/240/iconmonstr-smartphone-4.png" alt="phone"> </label>
  </div>

  <button class="accordion type-accordion">
        <h2 class="text-center">
            Model
            <span id="selectedType"></span>
            </h2>
      </button>

  <div class="panel" id="default_panel">
    <label>
          <h3 class="text-center">Please select a Device Type above</h3></label>
  </div>
  <div class="panel device-panel " id="laptop_panel">
    <div id="col1">
      <label class="control control--radio">LAPTOP
            <input type="radio" name="radio-laptop" />
            <div class="control__indicator"></div>
          </label>
    </div>
    <div id="col3">
      <label class="control control--radio">LAPTOP2
            <input type="radio" name="radio-laptop" />
            <div class="control__indicator"></div>
          </label>
    </div>
    <div id="col2">
      <label class="control control--radio">LAPTOP3
            <input type="radio" name="radio-laptop" />
            <div class="control__indicator"></div>
          </label>
    </div>
  </div>
  <div class="panel device-panel " id="tablet_panel">
    <div id="col1">
      <label class="control control--radio">TABLET1
            <input type="radio" name="radio-tablet" />
            <div class="control__indicator"></div>
          </label>
    </div>
    <div id="col3">
      <label class="control control--radio">TABLET2
            <input type="radio" name="radio-tablet" />
            <div class="control__indicator"></div>
          </label>
    </div>
    <div id="col2">
      <label class="control control--radio">TABLET3
            <input type="radio" name="radio-tablet" />
            <div class="control__indicator"></div>
          </label>
    </div>
  </div>
  <div class="panel device-panel " id="phone_panel">
    <div id="col1">
      <label class="control control--radio">iPhone 3
            <input type="radio" name="radio-phone" />
            <div class="control__indicator"></div>
          </label>
    </div>
    <div id="col3">
      <label class="control control--radio">Microsoft Lumia 430
            <input type="radio" name="radio-phone" />
            <div class="control__indicator"></div>
          </label>
    </div>
    <div id="col2">
      <label class="control control--radio">Galaxy S3
            <input type="radio" name="radio-phone" />
            <div class="control__indicator"></div>
          </label>
    </div>
  </div>

</div>


问:
How to nest a table within a table?
I've seen a similar topic, but not for my specific situation. I need to nest a table within the table and it will take up several cells, but when I try to nest a table it deletes the surrounding table at the same time. I included a picture of how it should look after my code and my code is how it looks currently. Can someone explain how this is done? Much appreciated.

/*
   CSS for Lounge Project
   Filename: styles.css

   Author:   Justus Self
   Date:     3/21/17
   HTML5 and CSS3 Illustrated Unit I, Lounge Independent Project
*/

/*Reset Styles*/
html, body{
   font-size: 14px;
   width: 100%;
   }
a, body, footer, header, h1, h2, h3, img, li, nav, p, ul, table, tbody, td, tfoot, th, thead, tr{
   border: 0;
   padding: 0;
   margin: 0;
}
img {
   max-width: 100%;
   height: auto;
   width: auto;
}

/*Drink font colors*/

h2.green {
  color: green;
}
h2.blue {
  color: blue;
}
h2.purple {
  color: purple;
}
h2.red {
  color: red;
}
h2.yellow {
  color: gold;
}

/*center and border image*/

img.smlounge {
  display: block;
  margin-left: auto;
  margin-right: auto;
  border: 3px solid;
  border-color: red;
}

/*Table styles*/

td, th {
  border: 1px solid black;
  font-size: 1.3em;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  padding: 0 1em ;
}
table {
  border-collapse: collapse;
  margin: 0 auto;
}
td[colspan="2"] {
  width: 20%;
}
.drink-name {
  text-align: left;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <title>Head First Lounge Elixirs</title>

  <!--
   Elixir page for Lounge Project
   Filename: elixir.html

   Author:   Justus Self
   Date:     3/21/17
   HTML5 and CSS3 Illustrated Unit I, Lounge Independent Project
   -->

  <link type="text/css" rel="stylesheet" href="../lounge.css" />
</head>

<body>
  <h1>Our Elixirs</h1>

  <h2 class="green">Green Tea Cooler</h2>
  <p>
    <img src="../images/green.jpg" alt="Green Tea Cooler" /> Chock full of vitamins and minerals, this elixir combines the healthful benefits of green tea with a twist of chamomile blossoms and ginger root.
  </p>
  <hr/>
  <h2 class="blue">Raspberry Ice Concentration</h2>
  <p>
    <img src="../images/lightblue.jpg" alt="Rasberry Ice Concentration" /> Combining raspberry juice with lemon grass, citrus peel and rosehips, this icy drink will make your mind feel clear and crisp.
  </p>
  <hr/>
  <h2 class="purple">Blueberry Bliss Elixir</h2>
  <p>
    <img src="../images/blue.jpg" alt="Blueberry Bliss Elixir" /> Blueberries and cherry essence mixed into a base of elderflower herb tea will put you in a relaxed state of bliss in no time.
  </p>
  <hr/>
  <h2 class="red">Cranberry Antioxidant Blast</h2>
  <p>
    <img src="../images/red.jpg" alt="Cranberry Antioxidant Blast" /> Wake up to the flavors of cranberry and hibiscus in this vitamin C rich elixir.
  </p>
  <hr/>
  <h2 class="yellow">Lemon Breeze</h2>
  <p><img src="../images/yellow.gif" alt="Lemon Breeze Drink" /> The ultimate healthy drink, this elixir combines herbal botanicals, minerals, and vitamins with a twist of lemon into a smooth citrus wonder that will keep your immune system going all day
    and all night.
  </p>
  <hr/>
  <br/>
  <table>
    <thead>
      <tr>
        <th colspan="6">Our Drink Prices</th>
      </tr>
      <tr>
        <th colspan="2">Drink</th>
        <th colspan="2">Size</th>
        <th colspan="2">Price</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td rowspan="2" colspan="2" class="drink-name">Green Tea Cooler</td>
        <td colspan="2">16 oz.</td>
        <td colspan="2">$3.75</td>
      </tr>
      <tr>
        <td colspan="2">24 oz.</td>
        <td colspan="2">$4.75</td>
      </tr>
      <tr>
        <td rowspan="2" colspan="2" class="drink-name">Raspberry Ice Concentration</td>
        <td colspan="2">16 oz.</td>
        <td colspan="2">$3.75</td>
      </tr>
      <tr>
        <td colspan="2">24 oz.</td>
        <td colspan="2">$4.75</td>
      </tr>
      <tr>
        <td colspan="2" class="drink-name">Cranberry Antioxidant Blast</td>
        <td colspan="2">20 oz.</td>
        <td colspan="2">$4.75</td>
      </tr>
      <tr>
        <td rowspan="2" colspan="2" class="drink-name">Lemon Breeze</td>
        <td>Iced</td>
        <td>16 oz.</td>
        <td>$3.75</td>
      </tr>
      <tr>
        <td>Frozen</td>
        <td>20 oz.</td>
        <td>$4.75</td>
      </tr>
    </tbody>
  </table>
  <p>Back to the Lounge</p>

  <footer>
    ©2016, Head First Online Lounge<br /> All trademarks and registered trademarks appearing on this site are the property of their respective owners.
  </footer>
</body>

</html></code>```

How the table should look

答:
Do it like this (of course you'll need to fix the font size and styling, and do the other side too. Ok try this. you still need to fix the font sizing

```<code><table>
<thead>
  <tr>
    <th colspan="6">Our Drink Prices</th>
  </tr>
  <tr>
    <th colspan="2">Drink</th>
    <th colspan="2">Size</th>
    <th colspan="2">Price</th>
  </tr>
</thead>
<tbody>
  <tr>
    <td rowspan="2" colspan="2" class="drink-name">Green Tea Cooler</td>
    <td colspan="2">16 oz.</td>
    <td colspan="2">$3.75</td>
  </tr>
  <tr>
    <td colspan="2">24 oz.</td>
    <td colspan="2">$4.75</td>
  </tr>
  <tr>
    <td rowspan="2" colspan="2" class="drink-name">Raspberry Ice Concentration</td>
    <td colspan="2">16 oz.</td>
    <td colspan="2">$3.75</td>
  </tr>
  <tr>
    <td colspan="2">24 oz.</td>
    <td colspan="2">$4.75</td>
  </tr>
  <tr>
    <td colspan="2" class="drink-name">Cranberry Antioxidant Blast</td>
    <td colspan="2">20 oz.</td>
    <td colspan="2">$4.75</td>
  </tr>
  <tr>
    <td rowspan="2" colspan="2" class="drink-name">Lemon Breeze</td>
    <td colspan="2" rowspan="2" class="nested">

    <table>
    <tbody>
    <tr><td>Iced</td><td>16 oz</td></tr>
    <tr><td>Frozen</td><td>20 oz</td></tr>
    </tbody>
    </table>

    </td>

    <td>$3.75</td>
  </tr>
  <tr>

    <td>$4.75</td>
  </tr>
</tbody>
</code>```

```<code>/*
   CSS for Lounge Project
   Filename: styles.css

   Author:   Justus Self
   Date:     3/21/17
   HTML5 and CSS3 Illustrated Unit I, Lounge Independent Project
*/

/*Reset Styles*/
html, body{
   font-size: 14px;
   width: 100%;
   }
a, body, footer, header, h1, h2, h3, img, li, nav, p, ul, table, tbody, td, tfoot, th, thead, tr{
   border: 0;
   padding: 0;
   margin: 0;
}
img {
   max-width: 100%;
   height: auto;
   width: auto;
}

/*Drink font colors*/

h2.green {
  color: green;
}
h2.blue {
  color: blue;
}
h2.purple {
  color: purple;
}
h2.red {
  color: red;
}
h2.yellow {
  color: gold;
}

/*center and border image*/

img.smlounge {
  display: block;
  margin-left: auto;
  margin-right: auto;
  border: 3px solid;
  border-color: red;
}

/*Table styles*/

td, th, td td {
  border: 1px solid black;
  font-size: 1.3em;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  padding: 0 1em ;
}
table {
  border-collapse: collapse;
  margin: 0 auto;
  width:100%
}
table table{
  margin:1%;
  width:98%;

}
table table td{
  width:50%;
}
table table tr, table table tbody{
  width:100%
}
.nested{padding:0;}
td[colspan="2"] {
  width: 20%;
}
.drink-name {
  text-align: left;
}
</code>```

Title: How to nest a table within a table?

Body:
I've seen a similar topic, but not for my specific situation. I need to nest a table within the table and it will take up several cells, but when I try to nest a table it deletes the surrounding table at the same time. I included a picture of how it should look after my code and my code is how it looks currently. Can someone explain how this is done? Much appreciated.

/*
   CSS for Lounge Project
   Filename: styles.css

   Author:   Justus Self
   Date:     3/21/17
   HTML5 and CSS3 Illustrated Unit I, Lounge Independent Project
*/

/*Reset Styles*/
html, body{
   font-size: 14px;
   width: 100%;
   }
a, body, footer, header, h1, h2, h3, img, li, nav, p, ul, table, tbody, td, tfoot, th, thead, tr{
   border: 0;
   padding: 0;
   margin: 0;
}
img {
   max-width: 100%;
   height: auto;
   width: auto;
}

/*Drink font colors*/

h2.green {
  color: green;
}
h2.blue {
  color: blue;
}
h2.purple {
  color: purple;
}
h2.red {
  color: red;
}
h2.yellow {
  color: gold;
}

/*center and border image*/

img.smlounge {
  display: block;
  margin-left: auto;
  margin-right: auto;
  border: 3px solid;
  border-color: red;
}

/*Table styles*/

td, th {
  border: 1px solid black;
  font-size: 1.3em;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  padding: 0 1em ;
}
table {
  border-collapse: collapse;
  margin: 0 auto;
}
td[colspan="2"] {
  width: 20%;
}
.drink-name {
  text-align: left;
}

<!DOCTYPE html>

  <meta charset="utf-8" />
  <title>Head First Lounge Elixirs</title>

  <link type="text/css" rel="stylesheet" href="../lounge.css" />

Our Elixirs

Green Tea Cooler

     Chock full of vitamins and minerals, this elixir combines the healthful benefits of green tea with a twist of chamomile blossoms and ginger root.

Raspberry Ice Concentration

     Combining raspberry juice with lemon grass, citrus peel and rosehips, this icy drink will make your mind feel clear and crisp.

Blueberry Bliss Elixir

     Blueberries and cherry essence mixed into a base of elderflower herb tea will put you in a relaxed state of bliss in no time.

Cranberry Antioxidant Blast

     Wake up to the flavors of cranberry and hibiscus in this vitamin C rich elixir.

Lemon Breeze

 The ultimate healthy drink, this elixir combines herbal botanicals, minerals, and vitamins with a twist of lemon into a smooth citrus wonder that will keep your immune system going all day
    and all night.

        Our Drink Prices

        Drink
        Size
        Price

        Green Tea Cooler
        16 oz.
        $3.75

        24 oz.
        $4.75

        Raspberry Ice Concentration
        16 oz.
        $3.75

        24 oz.
        $4.75

        Cranberry Antioxidant Blast
        20 oz.
        $4.75

        Lemon Breeze
        Iced
        16 oz.
        $3.75

        Frozen
        20 oz.
        $4.75

Back to the Lounge

    ©2016, Head First Online Lounge
 All trademarks and registered trademarks appearing on this site are the property of their respective owners.

How the table should look

Body:
Do it like this (of course you'll need to fix the font size and styling, and do the other side too. Ok try this. you still need to fix the font sizing

<table>
<thead>
  <tr>
    <th colspan="6">Our Drink Prices</th>
  </tr>
  <tr>
    <th colspan="2">Drink</th>
    <th colspan="2">Size</th>
    <th colspan="2">Price</th>
  </tr>
</thead>
<tbody>
  <tr>
    <td rowspan="2" colspan="2" class="drink-name">Green Tea Cooler</td>
    <td colspan="2">16 oz.</td>
    <td colspan="2">$3.75</td>
  </tr>
  <tr>
    <td colspan="2">24 oz.</td>
    <td colspan="2">$4.75</td>
  </tr>
  <tr>
    <td rowspan="2" colspan="2" class="drink-name">Raspberry Ice Concentration</td>
    <td colspan="2">16 oz.</td>
    <td colspan="2">$3.75</td>
  </tr>
  <tr>
    <td colspan="2">24 oz.</td>
    <td colspan="2">$4.75</td>
  </tr>
  <tr>
    <td colspan="2" class="drink-name">Cranberry Antioxidant Blast</td>
    <td colspan="2">20 oz.</td>
    <td colspan="2">$4.75</td>
  </tr>
  <tr>
    <td rowspan="2" colspan="2" class="drink-name">Lemon Breeze</td>
    <td colspan="2" rowspan="2" class="nested">

    <table>
    <tbody>
    <tr><td>Iced</td><td>16 oz</td></tr>
    <tr><td>Frozen</td><td>20 oz</td></tr>
    </tbody>
    </table>

    </td>

    <td>$3.75</td>
  </tr>
  <tr>

    <td>$4.75</td>
  </tr>
</tbody>

/*
   CSS for Lounge Project
   Filename: styles.css

   Author:   Justus Self
   Date:     3/21/17
   HTML5 and CSS3 Illustrated Unit I, Lounge Independent Project
*/

/*Reset Styles*/
html, body{
   font-size: 14px;
   width: 100%;
   }
a, body, footer, header, h1, h2, h3, img, li, nav, p, ul, table, tbody, td, tfoot, th, thead, tr{
   border: 0;
   padding: 0;
   margin: 0;
}
img {
   max-width: 100%;
   height: auto;
   width: auto;
}

/*Drink font colors*/

h2.green {
  color: green;
}
h2.blue {
  color: blue;
}
h2.purple {
  color: purple;
}
h2.red {
  color: red;
}
h2.yellow {
  color: gold;
}

/*center and border image*/

img.smlounge {
  display: block;
  margin-left: auto;
  margin-right: auto;
  border: 3px solid;
  border-color: red;
}

/*Table styles*/

td, th, td td {
  border: 1px solid black;
  font-size: 1.3em;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  padding: 0 1em ;
}
table {
  border-collapse: collapse;
  margin: 0 auto;
  width:100%
}
table table{
  margin:1%;
  width:98%;

}
table table td{
  width:50%;
}
table table tr, table table tbody{
  width:100%
}
.nested{padding:0;}
td[colspan="2"] {
  width: 20%;
}
.drink-name {
  text-align: left;
}


问:
Proper Git merging as is relates to repo history
Here is the scenario:

I have one branch named 'develop'. I branch off from this branch, the new branch is 'foo2'. After 3 commits on foo2, I then checkout develop branch and merge the changes on foo2 into develop:

git merge foo2

I then run:

git log --graph

I do not see foo2 in the graph. Did I do something incorrect with merging? Or is it something else entirely?

The branch foo2 still exists

答:
Because it’s fast forward merge. The graphs to illustrate as below:

```<code>…---A            develop
     \
      B---C---D  foo2
</code>```

After git merge foo2, develop and foo2 are both point to commit D, so you just find the graph as a line:

```<code>…---A---B---C---D       develop/foo2
</code>```

And you can use any of below command to view it more clearly:

```<code>git log --oneline --decorate --graph --all
gitk --all
</code>```

Body:
Because it’s fast forward merge. The graphs to illustrate as below:

…---A            develop
     \
      B---C---D  foo2

After git merge foo2, develop and foo2 are both point to commit D, so you just find the graph as a line:

…---A---B---C---D       develop/foo2

And you can use any of below command to view it more clearly:

git log --oneline --decorate --graph --all
gitk --all


问:
C# DateTime format in Arrays
Currently my function outputs date as 6/6/2016 and I need to be able to make it as 06/06/2016 for all the data. I found DateTime.Now.ToString("dd") is a solution. But when I do parts[0].DateTime.Now.ToString("dd") it doesn't accept it.</p>

```<code>private static string FormatDate(string sDate)
{
    // "6/16/1989"
    //mysql format 06-16-1989

    string[] parts = sDate.Split('/');

    //sDay.DateTime.Now.ToString("dd");

    return $"'{parts[2]}-{parts[1]}-{parts[0]}'";
}
</code>```

答:
First, you can parse the string to a DateTime via:

```<code>var dt = DateTime.Parse(sDate);
</code>```

Then you could use the DateTime.ToString formatting methods, e.g.:

```<code>dt.ToString("MM-dd-yyyy");
</code>```

Alternatively:

```<code>return dt.ToString("MM") + "-" + dt.ToString("dd") + "-" dt.ToString("yy");
</code>```

Title: C# DateTime format in Arrays

Body:
Currently my function outputs date as 6/6/2016 and I need to be able to make it as 06/06/2016 for all the data. I found DateTime.Now.ToString("dd") is a solution. But when I do parts[0].DateTime.Now.ToString("dd") it doesn't accept it.

private static string FormatDate(string sDate)
{
    // "6/16/1989"
    //mysql format 06-16-1989

    string[] parts = sDate.Split('/');

    //sDay.DateTime.Now.ToString("dd");

    return $"'{parts[2]}-{parts[1]}-{parts[0]}'";
}

Body:
First, you can parse the string to a DateTime via:

var dt = DateTime.Parse(sDate);

Then you could use the DateTime.ToString formatting methods, e.g.:

dt.ToString("MM-dd-yyyy");

Alternatively:

return dt.ToString("MM") + "-" + dt.ToString("dd") + "-" dt.ToString("yy");


答:
window.location.hash should hold the information you require; however, you can write a function to accept it or a string:

console.log( getArticle('https://www.example.com/#!-A108148940') );
console.log( getArticle(window.location.hash) ); // may be null

function getArticle(url) {
  var re = new RegExp(/#!\-A(\d+)$/);
  if ( re.test(url) )
    return RegExp.$1;
  return null;
}```

Title: detect page from shebang in url with php or javascript


问:
Changing only the thickness but not the length of a line segment in R
I was wondering how I can ONLY increase the thickness of the line segment (which is supposed to go from -2 to 2) in my R plot without increasing the length of it? (see my R code below)

Note: Apparently, lwd proportionally increases the length in addition to the thickness of a line segment. For example, in the plot below, even though the line segment is set to go from -2 to 2, the length of the red line segment has gone beyond -2 and 2.

Here is my R code:

```<code>curve(dnorm(x), -4, 4, lwd = 3)
segments(-2, 0, 2, 0, col = 'red', lend = 2, lwd = 20)
</code>```

答:
you want lend = 1 or lend = "butt"

```<code>curve(dnorm(x), -4, 4, lwd = 3)
segments(-2, 0, 2, 0, col = 'red', lwd = 20, lend = "butt")
</code>```

And workaround using polygon

```<code>curve(dnorm(x), -4, 4, lwd = 3)
polygon(x = c(-2,2,2,-2), y = c(0,0,0.02,0.02), col = "red", border = NA)
</code>```

Body:
I was wondering how I can ONLY increase the thickness of the line segment (which is supposed to go from -2 to 2) in my R plot without increasing the length of it? (see my R code below)

Note: Apparently, lwd proportionally increases the length in addition to the thickness of a line segment. For example, in the plot below, even though the line segment is set to go from -2 to 2, the length of the red line segment has gone beyond -2 and 2.

Here is my R code:

curve(dnorm(x), -4, 4, lwd = 3)
segments(-2, 0, 2, 0, col = 'red', lend = 2, lwd = 20)

Body:
you want lend = 1 or lend = "butt"

curve(dnorm(x), -4, 4, lwd = 3)
segments(-2, 0, 2, 0, col = 'red', lwd = 20, lend = "butt")

And workaround using polygon

curve(dnorm(x), -4, 4, lwd = 3)
polygon(x = c(-2,2,2,-2), y = c(0,0,0.02,0.02), col = "red", border = NA)


问:
MS Word VBA to delete empty lines
I am new to VBA Macros but I have a word 2016 template and it has the following sections:

```<code>Base Amount: $
Service Fee: $
Sales Tax % $
Other tax %: $
Tax 2 %: $
</code>```

My goal is if an amount is missing from any of the lines, then delete that line. I tried recording the macro and then making changes but no luck.

答:
Updated:  Below is a modified version of your code that will spin thru all rows of a table (in MS-Word) and delete every row that contains only a '$' in column 3 and column 4 is empty.</p>

```<code>Option Explicit

' This subroutine will spin thru all rows of data in a table in MS-Word (except the first row, which is the header).
' If column 3 contains only a '$' AND column 4 is empty, the row will be deleted.
' All rows with only the '$' in column 3 and empty cell 4 will be deleted.

Sub TEST()
Dim i       As Long
'Dim char    As String

    With Selection.Tables(1)
        For i = .Rows.Count To 1 Step -1
            'char = .Cell(i, 3).Range.Text
            'Debug.Print Asc(Mid(char, 1, 1)) & vbTab & Asc(Mid(char, 2, 1)) '& vbTab & Asc(Mid(char, 3, 1))
            'Debug.Print ">" & .Cell(i, 2).Range.Text & "<"
            If Len(.Cell(i, 4).Range.Text) = 2 And Left(.Cell(i, 3).Range.Text, 1) = "$" Then
                .Rows(i).Delete
            End If
        Next i
    End With
End Sub
</code>```

Title: MS Word VBA to delete empty lines

Body:
I am new to VBA Macros but I have a word 2016 template and it has the following sections:

Base Amount: $
Service Fee: $
Sales Tax % $
Other tax %: $
Tax 2 %: $

My goal is if an amount is missing from any of the lines, then delete that line. I tried recording the macro and then making changes but no luck.

Body:
Updated:  Below is a modified version of your code that will spin thru all rows of a table (in MS-Word) and delete every row that contains only a '$' in column 3 and column 4 is empty.

Option Explicit

' This subroutine will spin thru all rows of data in a table in MS-Word (except the first row, which is the header).
' If column 3 contains only a '$' AND column 4 is empty, the row will be deleted.
' All rows with only the '$' in column 3 and empty cell 4 will be deleted.

Sub TEST()
Dim i       As Long
'Dim char    As String

    With Selection.Tables(1)
        For i = .Rows.Count To 1 Step -1
            'char = .Cell(i, 3).Range.Text
            'Debug.Print Asc(Mid(char, 1, 1)) & vbTab & Asc(Mid(char, 2, 1)) '& vbTab & Asc(Mid(char, 3, 1))
            'Debug.Print ">" & .Cell(i, 2).Range.Text & "<"
            If Len(.Cell(i, 4).Range.Text) = 2 And Left(.Cell(i, 3).Range.Text, 1) = "$" Then
                .Rows(i).Delete
            End If
        Next i
    End With
End Sub


问:
Edit excel file with python
I tried to edit an existing excel file. My file is test.xlsx, with two sheets are All and Summary. Following step:

```<code> import pandas as pd

 df = pd.read_csv('abc.csv')
 number_rows = len(df.index)
 writer = pd.ExcelWriter('test.xlsx')
 df.to_excel(writer, sheet_name = 'All',startrow = number_rows)
 writer.save()
</code>```

I want to edit(append data to sheet name All) but when run this code, it seem to be the sheet name Summary and All deleted and it create a new sheet name All and write my new data to it. So, how to append data to excel sheet without delete existing data? Thank you.

答:
You can use openpyxl engine along-with startrow parameter.
You also need to ;

read csv to df first

open xlsx as workbook using openpyxl

create writer object using openpyxl as engine

Add sheets to writer object

Add df to writer object

Your Code (modified):

```<code>import pandas as pd
from openpyxl import load_workbook

df = pd.read_csv('abc.csv')
number_rows = len(df.index)
book = load_workbook('test.xlsx')
writer = pd.ExcelWriter('test.xlsx', engine='openpyxl')
writer.book = book
writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
df.to_excel(writer, sheet_name = 'All',startrow = number_rows)
writer.save()
</code>```

Title: Edit excel file with python

Body:
I tried to edit an existing excel file. My file is test.xlsx, with two sheets are All and Summary. Following step:

 import pandas as pd

 df = pd.read_csv('abc.csv')
 number_rows = len(df.index)
 writer = pd.ExcelWriter('test.xlsx')
 df.to_excel(writer, sheet_name = 'All',startrow = number_rows)
 writer.save()

I want to edit(append data to sheet name All) but when run this code, it seem to be the sheet name Summary and All deleted and it create a new sheet name All and write my new data to it. So, how to append data to excel sheet without delete existing data? Thank you.

Body:
You can use openpyxl engine along-with startrow parameter.
You also need to ;

read csv to df first

open xlsx as workbook using openpyxl

create writer object using openpyxl as engine

Add sheets to writer object

Add df to writer object

Your Code (modified):

import pandas as pd
from openpyxl import load_workbook

df = pd.read_csv('abc.csv')
number_rows = len(df.index)
book = load_workbook('test.xlsx')
writer = pd.ExcelWriter('test.xlsx', engine='openpyxl')
writer.book = book
writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
df.to_excel(writer, sheet_name = 'All',startrow = number_rows)
writer.save()


问:
SQL Server subscription requires actual server name using azure
I have created an Azure VM, along with sql server.   I can connect to it just fine.  I'm able to create databases.  What my goal is to move entirely to the azure cloud.

Locally on-premise I created a publication.

Now I'm trying to set the Azure db as a subscriber

Error

```<code>Cannot connect to myazuredatabase.westus.cloudapp.azure.com,1433.

===================================

SQL Server replication requires the actual server name to make a connection to the server. Specify the actual server name, 'myazuredatabase'. (Replication.Utilities)
</code>```

I followed a pluralsight guide, it is a bit outdated.   I do have DNS name etc..    what is wrong?

答:
Just tested it with snapshot replication after back to the office. In your scenario, you would need to setup 2 aliases in your environment:

Alias on your local machine for SSMS. This needs to be done under SSCM>>SQL Native Client Configuration(32bit).

Alias on on-premise server. This needs to be done under SSCM>>SQL Native Client Configuration if you have 64 bit SQL Server. Otherwise just setup it under SSCM>>SQL Native Client Configuration(32bit).

Here's what you alias should look like:

Body:
I have created an Azure VM, along with sql server.   I can connect to it just fine.  I'm able to create databases.  What my goal is to move entirely to the azure cloud.

Locally on-premise I created a publication.

Now I'm trying to set the Azure db as a subscriber

Error

Cannot connect to myazuredatabase.westus.cloudapp.azure.com,1433.

===================================

SQL Server replication requires the actual server name to make a connection to the server. Specify the actual server name, 'myazuredatabase'. (Replication.Utilities)

I followed a pluralsight guide, it is a bit outdated.   I do have DNS name etc..    what is wrong?


问:
How do I check if a list is empty?
For example, if passed the following:

```<code>a = []
</code>```

How do I check to see if a is empty?

答:
Being inspired by dubiousjim's solution, I propose to use an additional general check of whether is it something iterable:

```<code>import collections
def is_empty(a):
    return not a and isinstance(a, collections.Iterable)
</code>```

Note: a string is considered to be iterable—add and not isinstance(a,(str,unicode)) if you want the empty string to be excluded

Test:

```<code>>>> is_empty('sss')
False
>>> is_empty(555)
False
>>> is_empty(0)
False
>>> is_empty('')
True
>>> is_empty([3])
False
>>> is_empty([])
True
>>> is_empty({})
True
>>> is_empty(())
True
</code>```

OwnerDisplayName: Ray Vega

Title: How do I check if a list is empty?

Body:
For example, if passed the following:

a = []

How do I check to see if a is empty?

Body:
Being inspired by dubiousjim's solution, I propose to use an additional general check of whether is it something iterable:

import collections
def is_empty(a):
    return not a and isinstance(a, collections.Iterable)

Note: a string is considered to be iterable—add and not isinstance(a,(str,unicode)) if you want the empty string to be excluded

Test:

>>> is_empty('sss')
False
>>> is_empty(555)
False
>>> is_empty(0)
False
>>> is_empty('')
True
>>> is_empty([3])
False
>>> is_empty([])
True
>>> is_empty({})
True
>>> is_empty(())
True


问:
Accessing a web service in a Flash CS3 AS3 project
Since CS3 doesn't have a web service component, as previous versions had, is there a good, feature-complete, AS3-only (no Flex dependencies) library for accessing web services with AS3?</p>

答: What type of service are you trying to consume? URLLoader can handle soap requests (urlRequest.requestHeaders.push(new URLRequestHeader("Content-Type", "application/soap+xml"));) and NetConnection can handle most other stuff (AMF/Remoting).

OwnerDisplayName: RickDT

OwnerDisplayName: TypeOneError


问:
jqGrid or dataTable, which better?
i'm interest to use jQuery dataTable...
could you tell me and give me an example how to use that..and i've been heard about jqGrid too..which better from both of them?

i've been try to download dataTable..

```<code><script type="text/javascript" src="jquery.dataTables.js"></script>
<script type="text/javascript">
 $(document).ready(function() {
  $('#showdata').dataTable( {
 //what must i fill in this area?
});
});
</script>
</code>```

答:
I'm using DataTables too. I was attracted by the docs, the api and the flexibility. In my project I have an ajax front end where the table contains editable controls and column sorting/filtering. Some grids have all the data on the client, some pull their data from paged server calls, depending on the volume of data.

The developer has total control over the column rendering. I recommend it if you want flexibility. It's worth it. The author, Allan Jardine, is clearly very talented

Title: jqGrid or dataTable, which better?


问:
Displaying SQL Data With jQuery
In a PHP file, I'm running a query on my database that returns specific values from every new record inserted into a table. Using a while loop, the query fetches the data and echos it out in a table I have created.

Now, using jQuery's ajax load method with setInterval on 1 second, the data from the php file appears on my page the way I want it to.

However, the problem I'm having now is figuring out how to display more details about individual users when their respective "table" is clicked. These details would appear via jQuery's show/hide. How would I link the ID of the record to what I click so it shows details about that specific user?

I've created a diagram explaining what I'm trying to do, as I'm relatively new to PHP and not sure if I'm explaining myself correctly.

Working Demo

container.php

```<code><html lang="en">
<head>
  <meta charset="utf-8">

  <title>Show and Hide User Info</title>
  <meta name="description" content="">
  <meta name="author" content="">

  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

  <style>
  body {
    background-color: #000;
    color: #fff;
    font-family: tahoma, arial, verdana;
    font-size: 12px;
  }

  #users {
    background-color: #828282;
    width: 300px;
  }

  #userdetails {
    background-color: #828282;
    width: 300px;
    margin-top: 10px;
  }

  .user {
    padding: 5px;
    border-bottom: 1px solid white;
    width: 300px;
    background-color: #828282;
  }

  .user:hover {
    background-color: #282828;
    cursor: pointer;
  }

  #back:hover {
    background-color: #ffcc00;
    cursor: pointer;
    color: #000;
  }

  </style>

</head>

<body>

<div id="userlist"></div>

<div id="userdetails"></div>

<script>
setInterval(function(){
   $("#userlist").load("userlist.php");
}, 1000);
$('#userdetails').hide();
$(document).on("click",".user", function() {
    var data_id = $(this).attr("data-id");
      $.get("userdetails.php", {id: data_id}).done(function(data) {
      $('#userdetails').html(data);
      $('#userdetails').show();
      $('#userlist').hide();
  });
})
$(document).on("click","#back", function() {
  $('#userlist').show();
  $('#userdetails').hide();
});
 </script>

</body>
</html>
</code>```

userlist.php

```<code><?php

include 'dbh.php';

$result = $conn->query("SELECT * FROM users");

if ($result->num_rows > 0) {

  while ($row = $result->fetch_assoc()) {

    $color = array("ADMIN"=>"#ebc45b", "MOD"=>"#8fce61", "USER"=>"#9b9ed2");

?>

  <table data-id="<?php echo $row['id']; ?>" class="user">
    <tr>
      <td align="left"><?php echo $row['address']; ?></td>
      <td align="right"><?php echo $row['zip']; ?></td>
    </tr>
    <tr>
      <td align="left"><?php echo $row['city']; ?></td>
      <td align="right"><?php echo $row['state']; ?></td>
    </tr>
    <tr>
      <td align="left"><span style="color: <?php echo $color[$row['user_level']]; ?>"><?php echo $row['user_level']; ?></span></td>
      <td align="right">"member since..."</td>
    </tr>
  </table>

<?php
  }
}
?>
</code>```

userdetails.php

```<code><?php

include 'dbh.php';

$result = $conn->query("SELECT * FROM users WHERE id=" . $_GET["id"]);

if ($result->num_rows > 0) {

  while ($row = $result->fetch_assoc()) {

?>
<div>
<span id="back">BACK</span>
</div>
<table data-id="<?php echo $row['id']; ?>" class="user">
<tr>
  <td align="left">First Name:</td>
  <td align="right"><?php echo $row['first_name']; ?></td>
</tr>
<tr>
  <td align="left">Last Name:</td>
  <td align="right"><?php echo $row['last_name']; ?></td>
</tr>
<tr>
  <td align="left">Age:</td>
  <td align="right"><?php echo $row['age']; ?></td>
<tr>
</tr>
  <td align="left">Sex:</td>
  <td align="right"><?php echo $row['sex']; ?></td>
</tr>
</table>

<?php
 }
}
?>
</code>```

答:
I think your userlist gets loaded after one second, so your table click may not be triggering.
Can you try this.

```<code>$(document).on("click",".user", function() {
    var data_id = $(this).attr("data-id");
      $.get("userdetails.php", {id: data_id}).done(function(data) {
      $('#userdetails').html(data);
      $('#userdetails').show();
      $('.user').hide();
  });
})
</code>```

Even your userdetails's table class name is same as userlist's table class name.

Title: Displaying SQL Data With jQuery

Body:
In a PHP file, I'm running a query on my database that returns specific values from every new record inserted into a table. Using a while loop, the query fetches the data and echos it out in a table I have created.

Now, using jQuery's ajax load method with setInterval on 1 second, the data from the php file appears on my page the way I want it to.

However, the problem I'm having now is figuring out how to display more details about individual users when their respective "table" is clicked. These details would appear via jQuery's show/hide. How would I link the ID of the record to what I click so it shows details about that specific user?

I've created a diagram explaining what I'm trying to do, as I'm relatively new to PHP and not sure if I'm explaining myself correctly.

Working Demo

container.php

  <meta charset="utf-8">

  <title>Show and Hide User Info</title>
  <meta name="description" content="">
  <meta name="author" content="">

userlist.php

<?php

include 'dbh.php';

$result = $conn->query("SELECT * FROM users");

if ($result->num_rows > 0) {

  while ($row = $result->fetch_assoc()) {

    $color = array("ADMIN"=>"#ebc45b", "MOD"=>"#8fce61", "USER"=>"#9b9ed2");

?>

  <table data-id="<?php echo $row['id']; ?>" class="user">

      <?php echo $row['address']; ?>
      <?php echo $row['zip']; ?>

      <?php echo $row['city']; ?>
      <?php echo $row['state']; ?>

      <span style="color: <?php echo $color[$row['user_level']]; ?>"><?php echo $row['user_level']; ?>
      "member since..."

<?php
  }
}
?>

userdetails.php

<?php

include 'dbh.php';

$result = $conn->query("SELECT * FROM users WHERE id=" . $_GET["id"]);

if ($result->num_rows > 0) {

  while ($row = $result->fetch_assoc()) {

?>

BACK

<table data-id="<?php echo $row['id']; ?>" class="user">

  First Name:
  <?php echo $row['first_name']; ?>

  Last Name:
  <?php echo $row['last_name']; ?>

  Age:
  <?php echo $row['age']; ?>

  Sex:
  <?php echo $row['sex']; ?>

<?php
 }
}
?>

Body:
I think your userlist gets loaded after one second, so your table click may not be triggering.
Can you try this.

$(document).on("click",".user", function() {
    var data_id = $(this).attr("data-id");
      $.get("userdetails.php", {id: data_id}).done(function(data) {
      $('#userdetails').html(data);
      $('#userdetails').show();
      $('.user').hide();
  });
})

Even your userdetails's table class name is same as userlist's table class name.