问:
perl6 Is there a way to do editable prompt input?
In bash shell, if you hit up or down arrows, the shell will show you your previous or next command that you entered, and you can edit those commands to be new shell commands.

In perl6, if you do

```<code>my $name = prompt("Enter name: ");
</code>```

it will print "Enter name: " and then ask for input; is there a way to have perl6 give you a default value and then you just edit the default to be the new value. E.g.:

```<code>my $name = prompt("Your name:", "John Doe");
</code>```

and it prints

```<code>Your name: John Doe
</code>```

where the John Doe part is editable, and when you hit enter, the edited string is the value of $name.

https://docs.raku.org/routine/prompt does not show how to do it.

This is useful if you have to enter many long strings each of which is just a few chars different from others.

Thanks.

答:
Well by default, programs are completely unaware of their terminals.

You need your program to communicate with the terminal to do things like pre-fill an input line, and it's unreasonable to expect Perl 6 to handle something like this as part of the core language.

That said, your exact case is handled by the Readline library as long as you have a compatible terminal.

It doesn't look like the perl 6 Readline has pre-input hooks setup so you need to handle the callback and read loop yourself, unfortunately. Here's my rough attempt that does exactly what you want:

use v6;
use Readline;

sub prompt-prefill($question, $suggestion) {
  my $rl = Readline.new;
  my $answer;
  my sub line-handler( Str $line ) {
    rl_callback_handler_remove();
    $answer = $line;
  }

  rl_callback_handler_install( "$question ", &line-handler );

  $rl.insert-text($suggestion);
  $rl.redisplay;
  while (!$answer) {
    $rl.callback-read-char();
  }

  return $answer;
}

my $name = prompt-prefill("What's your name?", "Bob");
say "Hi $name. Go away.";
```

If you are still set on using Linenoise, you might find the 'hints' feature good enough for your needs (it's used extensively by the redis-cli application if you want a demo). See the hint callback used with linenoiseSetHintsCallback in the linenoise example.c file. If that's not good enough you'll have to start digging into the guts of linenoise.

Body:
In bash shell, if you hit up or down arrows, the shell will show you your previous or next command that you entered, and you can edit those commands to be new shell commands.

In perl6, if you do

my $name = prompt("Enter name: ");

it will print "Enter name: " and then ask for input; is there a way to have perl6 give you a default value and then you just edit the default to be the new value. E.g.:

my $name = prompt("Your name:", "John Doe");

and it prints

Your name: John Doe

where the John Doe part is editable, and when you hit enter, the edited string is the value of $name.

https://docs.raku.org/routine/prompt does not show how to do it.

This is useful if you have to enter many long strings each of which is just a few chars different from others.

Thanks.

Body:
Well by default, programs are completely unaware of their terminals.

You need your program to communicate with the terminal to do things like pre-fill an input line, and it's unreasonable to expect Perl 6 to handle something like this as part of the core language.

That said, your exact case is handled by the Readline library as long as you have a compatible terminal.

It doesn't look like the perl 6 Readline has pre-input hooks setup so you need to handle the callback and read loop yourself, unfortunately. Here's my rough attempt that does exactly what you want:

use v6;
use Readline;

sub prompt-prefill($question, $suggestion) {
  my $rl = Readline.new;
  my $answer;
  my sub line-handler( Str $line ) {
    rl_callback_handler_remove();
    $answer = $line;
  }

  rl_callback_handler_install( "$question ", &line-handler );

  $rl.insert-text($suggestion);
  $rl.redisplay;
  while (!$answer) {
    $rl.callback-read-char();
  }

  return $answer;
}

my $name = prompt-prefill("What's your name?", "Bob");
say "Hi $name. Go away.";

If you are still set on using Linenoise, you might find the 'hints' feature good enough for your needs (it's used extensively by the redis-cli application if you want a demo). See the hint callback used with linenoiseSetHintsCallback in the linenoise example.c file. If that's not good enough you'll have to start digging into the guts of linenoise.


来源: stackexchange

问:
Rate-limiting and count-limiting events in RxJS v5, but also allowing pass-through
I have a bunch of events to send up to a service. But the requests are rate limited and each request has a count limit:

1 request per second: bufferTime(1000)

100 event items per request: bufferCount(100)

The problem is, I am not sure how to combine them in a way that makes sense.

Allowing pass-through

Complicating this further, I need to make sure that events go through instantaneously if we don't hit either limit.

For example, I don't want it to actually wait for 100 event items before letting it go through if it's only one single event during a non-busy time.

Legacy API

I also found that there was a bufferWithTimeOrCount that existed in RxJS v4, although I am not sure how I'd use that even if I had it.

Test playground

Here is a JSBin I made for you to test your solution:

http://jsbin.com/fozexehiba/1/edit?js,console,output

Any help would be greatly appreciated.

答:
The bufferTime() operator takes three parameters which combines the functionality of bufferTime and bufferCount. See http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-bufferTime.

With .bufferTime(1000, null, 3) you can make a buffer every 1000ms or when it reaches 3 items. However, this means that it doesn't guarantee 1000ms delay between each buffer.

So you could use something like this which is pretty easy to use (buffers only 3 items for max 1000ms):

```<code>click$
  .scan((a, b) => a + 1, 0)
  .bufferTime(1000, null, 3)
  .filter(buffer => buffer.length > 0)
  .concatMap(buffer => Rx.Observable.of(buffer).delay(1000))
  .timestamp()
  .subscribe(console.log);
</code>```

See live demo: http://jsbin.com/libazer/7/edit?js,console,output

The only difference to what you probably wanted is that the first emission might be delayed by more than 1000ms. This is because both bufferTime() and delay(1000) operators make a delay to ensure that there's always at least 1000ms gap.

ContentLicense: CC BY-SA 3.0

Body:
The bufferTime() operator takes three parameters which combines the functionality of bufferTime and bufferCount. See http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-bufferTime.

With .bufferTime(1000, null, 3) you can make a buffer every 1000ms or when it reaches 3 items. However, this means that it doesn't guarantee 1000ms delay between each buffer.

So you could use something like this which is pretty easy to use (buffers only 3 items for max 1000ms):

click$
  .scan((a, b) => a + 1, 0)
  .bufferTime(1000, null, 3)
  .filter(buffer => buffer.length > 0)
  .concatMap(buffer => Rx.Observable.of(buffer).delay(1000))
  .timestamp()
  .subscribe(console.log);

See live demo: http://jsbin.com/libazer/7/edit?js,console,output

The only difference to what you probably wanted is that the first emission might be delayed by more than 1000ms. This is because both bufferTime() and delay(1000) operators make a delay to ensure that there's always at least 1000ms gap.


问:
Installing Carrot2 on Windows7, 8 or 10
I am trying to install carrot2-workbench-win32.win32.x86_64-3.15.1 on a 32-bit Windows 7. I get an error "the version of this file is not compatible with the version of windows you're running".

Error pop-up

I have JDK8 installed and running all right.

Any suggestions? Do I need to recompile?

答:
We stopped publishing 32-bit builds some time ago, here's the latest 32-bit build:

http://download.carrot2.org/stable/3.13.0/carrot2-workbench-win32.win32.x86-3.13.0.zip

To get the 32-bit binaries of the latest version, you'd indeed need to compile from sources.

Title: Installing Carrot2 on Windows7, 8 or 10


问:
Break statement misplaced in while-loop
I'd like to create a script that asks for the item you want from a list (array), check if the item is on stock, displays the inventory if your type "list" and quit the program (while loop) if you type "quit"

while (true) { // endless loop
  var search = prompt('Type the item you are looking for, type "list" to display the inventory, type "quit" to exit te store.');
  search = search.toLowerCase;
}
if (search = 'quit') {
  break; // if the client types quit, they exit the store, loop ends
} else if search == 'list'{
  write('
We currently have ' + inventory.join(', ') + ' in stock.
');
} else if (inventory.indexOf(search) > - 1) {
  write('
Yes, we have ' + search + ' in our stock.
');
} else {
  write('
Sorry, we don\'t have ' + search + ' in our stock
');
}```

The break statement is out of the loop but I don't really see where it should go ...

Any thoughts?

答:
You should check your data in the while loop and break it there, if needed.

I've also corrected errors and tested the script.

You can find in my comments details about the errors.

while (true) { // endless loop
  var search = prompt('Type the item you are looking for, type "list" to display the inventory, type "quit" to exit te store.');
  search = search.toLowerCase();
      // After getting user input you want to check it and decide accordingly if
  // you want to stop the loop or you want to ask the user for input again
  if (search == 'quit') { // *** ERROR *** In your code you used a
// single = and that doesn't work for comparison in Javascript
    break; // if the client types quit, they exit the store, loop ends
  } else if (search == 'list') {// *** ERROR *** If you have more than a single if you need to always use parenthesis
    console.log('
We currently have ' + inventory.join(', ') + ' in stock.
');
  } else if (inventory.indexOf(search) > -1) {
    console.log('
Yes, we have ' + search + ' in our stock.
');
  } else {
    console.log('
Sorry, we don\'t have ' + search + ' in our stock
');
  }

}```

Title: Break statement misplaced in while-loop

Body:
I'd like to create a script that asks for the item you want from a list (array), check if the item is on stock, displays the inventory if your type "list" and quit the program (while loop) if you type "quit"

while (true) { // endless loop
  var search = prompt('Type the item you are looking for, type "list" to display the inventory, type "quit" to exit te store.');
  search = search.toLowerCase;
}
if (search = 'quit') {
  break; // if the client types quit, they exit the store, loop ends
} else if search == 'list'{
  write('
We currently have ' + inventory.join(', ') + ' in stock.
');
} else if (inventory.indexOf(search) > - 1) {
  write('
Yes, we have ' + search + ' in our stock.
');
} else {
  write('
Sorry, we don\'t have ' + search + ' in our stock
');
}

The break statement is out of the loop but I don't really see where it should go ...

Any thoughts?

Body:
You should check your data in the while loop and break it there, if needed.

I've also corrected errors and tested the script.

You can find in my comments details about the errors.

while (true) { // endless loop
  var search = prompt('Type the item you are looking for, type "list" to display the inventory, type "quit" to exit te store.');
  search = search.toLowerCase();
      // After getting user input you want to check it and decide accordingly if
  // you want to stop the loop or you want to ask the user for input again
  if (search == 'quit') { // *** ERROR *** In your code you used a
// single = and that doesn't work for comparison in Javascript
    break; // if the client types quit, they exit the store, loop ends
  } else if (search == 'list') {// *** ERROR *** If you have more than a single if you need to always use parenthesis
    console.log('<p>We currently have ' + inventory.join(', ') + ' in stock.</p>');
  } else if (inventory.indexOf(search) > -1) {
    console.log('<p>Yes, we have ' + search + ' in our stock.</p>');
  } else {
    console.log('<p>Sorry, we don\'t have ' + search + ' in our stock</p>');
  }

}


问:
Webix - Rest Mode Support - Datatable - Set ID column for CRUD operation
I'm following these instructions, and adapted this example.
The problem is that my data ID isn't named ID.
So when I tried to change the data, the ID sent to my REST API is some crazy number.

Is there a way to configure which datatable column or field from my JSON will be used as ID?

OR

Will I need to change the name returned from my REST API and how the best way to do this without changing the structure of the database?

JSON Output:

```<code>[
    {
        "nu_unidade": "sample string 2",
        "nome": "sample string 4",
    },{
        "nu_unidade": "sample string 2",
        "nome": "sample string 4",
    },{
        "nu_unidade": "sample string 2",
        "nome": "sample string 4",
    }
]
</code>```

ASP Net Model:

```<code>namespace Site.Models {
    using System;
    using System.Collections.Generic;
    public partial class Unidade {
        public string nu_unidade { get; set; }
        public string nome { get; set; }
    }
}
</code>```

Using:

Webix 4.2

.Net Framework 4.0

Web API 1.0

EF 5.0

答:
I pretty sure Webix can't work without an "id" field (It automatically create a one with random big interger). If your API can't send it, maybe you could try to map data in webix datatable : http://docs.webix.com/datatable__data_mapping.html

```<code>columns:[
    {
        id:"id",
        map:"#nu_unidade#",
        header:"Id"
    }
],
</code>```

Or you could force id at data initialization :

```<code>scheme: {
   $init:function(obj){
       obj.id = obj.nu_unidade;
     }
}
</code>```

Body:
I'm following these instructions, and adapted this example.
The problem is that my data ID isn't named ID.
So when I tried to change the data, the ID sent to my REST API is some crazy number.

Is there a way to configure which datatable column or field from my JSON will be used as ID?

OR

Will I need to change the name returned from my REST API and how the best way to do this without changing the structure of the database?

JSON Output:

[
    {
        "nu_unidade": "sample string 2",
        "nome": "sample string 4",
    },{
        "nu_unidade": "sample string 2",
        "nome": "sample string 4",
    },{
        "nu_unidade": "sample string 2",
        "nome": "sample string 4",
    }
]

ASP Net Model:

namespace Site.Models {
    using System;
    using System.Collections.Generic;
    public partial class Unidade {
        public string nu_unidade { get; set; }
        public string nome { get; set; }
    }
}

Using:

Webix 4.2

.Net Framework 4.0

Web API 1.0

EF 5.0

Body:
I pretty sure Webix can't work without an "id" field (It automatically create a one with random big interger). If your API can't send it, maybe you could try to map data in webix datatable : http://docs.webix.com/datatable__data_mapping.html

columns:[
    {
        id:"id",
        map:"#nu_unidade#",
        header:"Id"
    }
],

Or you could force id at data initialization :

scheme: {
   $init:function(obj){
       obj.id = obj.nu_unidade;
     }
}


问:
IE 6-7 don't obey padding/margin
I my footer I have 3 columns with padding: 10px 20px 0px;

In those I have some headlines (h1/h2) with margin-top: 10px;

This looks ok in all browsers except from IE 6 and 7

In IE 6 and 7 the headlines is placed 10px from the top of the container. (the top padding is missing, but the left/right padding is ok)

Why?

http://www.hr-relocation.com/test.html

```<code>.footercolumn {
    width: 260px;
    height: 170px;
    padding: 10px 20px 0px;
    text-align: left;
    overflow: hidden;
    background: url(../gfx/footerbg.gif) no-repeat top left;
    float: left;
}

.footercolumn h1, .footercolumn h2, .footercolumn h3 {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.2em;
    font-weight: bold;
    color: #c5037b;
    display: block;
}
</code>```

答:
Thanks for alle the answers and sugestion...

Working hard all night i came up with a solution that workd for all IE :-)

adding a

 in top of the container div with this css solved the problem

```<code>clear: { both !important; display: block !important; height: 0 !important; margin: 0 !important; overflow: hidden !important; padding: 0 !important; width: 0 !important; }
</code>```

ContentLicense: CC BY-SA 4.0

Title: IE 6-7 don't obey padding/margin

Body:
I my footer I have 3 columns with padding: 10px 20px 0px;

In those I have some headlines (h1/h2) with margin-top: 10px;

This looks ok in all browsers except from IE 6 and 7

In IE 6 and 7 the headlines is placed 10px from the top of the container. (the top padding is missing, but the left/right padding is ok)

Why?

http://www.hr-relocation.com/test.html

.footercolumn {
    width: 260px;
    height: 170px;
    padding: 10px 20px 0px;
    text-align: left;
    overflow: hidden;
    background: url(../gfx/footerbg.gif) no-repeat top left;
    float: left;
}

.footercolumn h1, .footercolumn h2, .footercolumn h3 {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.2em;
    font-weight: bold;
    color: #c5037b;
    display: block;
}

Body:
Thanks for alle the answers and sugestion...

Working hard all night i came up with a solution that workd for all IE :-)

adding a <div class="clearall"></div> in top of the container div with this css solved the problem

clear: { both !important; display: block !important; height: 0 !important; margin: 0 !important; overflow: hidden !important; padding: 0 !important; width: 0 !important; }

ContentLicense: CC BY-SA 2.5


问:
Tree and its preorder traversal - Code error
```<code>#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;

struct Node  //Tree Node
{
    int key;
    struct Node *left;
    struct Node *right;
};

int nodes[21], counter; //nodes[] array keeps all the nodes of the tree
                        //in increasing order
                        //counter tracks the current index of the array

void preorder(Node* node){    //Preorder traversal of the tree
    if(node==NULL){
        return;
    }
    preorder(node->left);
    nodes[counter++]=node->key;
    preorder(node->right);
}

struct Node* createNode(int key){     //Tree Node Creation
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode->key = key;
    newNode->left = NULL;
    newNode->right = NULL;
    return newNode;
}

void createTree(struct Node* newNode, struct Node* node){  //Creates a
                                                     //binary search tree
    if(!node){
        node=newNode;    //Problem Line
        return;
    }
    if(newNode->key<node->key){
        createTree(newNode, node->left);
    }
    else if(newNode->key>node->key){
        createTree(newNode, node->right);
    }
}

int main(){
    int node_count, node_value;
    struct Node* root = NULL;
    cout<<"Enter number of nodes"<<endl;
    cin>>node_count;
    cout<<"Enter node values in a space-separated format"<<endl;
    for(int i=0;i<node_count;i++){
        cin>>node_value;
        struct Node* newNode = createNode(node_value);
        if(!root){
            root = newNode;
        }
        else{
            createTree(newNode, root);
        }
        cout<<root->left<<" "<<root->right<<endl;
    }
    counter=0;
    preorder(root);
    for(int i=0;i<counter;i++){
        cout<<nodes[i]<<" ";
    }
    cout<<endl;

    getch();
    return 0;
}
</code>```

<p>Above is the code for creating a BST and then storing its preorder traversal in an array. I have mentioned the problem line(the assignment of the pointer is not happening). Can someone, please help me out with this. </p>

答:
Assigning to a pointer is not going to affect the value after you return from the function.... Please read more about pointer point to pointer and passing-arguments by reference in cpp

The following codes may solve parts of your problem, but not all, I believe there must be more problems in your codes but I don't wanna waste time to debug them.

```<code>void createTree(struct Node* &newNode, struct Node* &node){  //Creates a
                                                     //binary search tree
    if(!node){
        node=newNode;    //Problem Line
        return;
    }
    if(newNode->key<node->key){
        createTree(newNode, node->left);
    }
    else if(newNode->key>node->key){
        createTree(newNode, node->right);
    }
}
</code>```

Body:
#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;

struct Node  //Tree Node
{
    int key;
    struct Node *left;
    struct Node *right;
};

int nodes[21], counter; //nodes[] array keeps all the nodes of the tree
                        //in increasing order
                        //counter tracks the current index of the array

void preorder(Node* node){    //Preorder traversal of the tree
    if(node==NULL){
        return;
    }
    preorder(node->left);
    nodes[counter++]=node->key;
    preorder(node->right);
}

struct Node* createNode(int key){     //Tree Node Creation
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode->key = key;
    newNode->left = NULL;
    newNode->right = NULL;
    return newNode;
}

void createTree(struct Node* newNode, struct Node* node){  //Creates a
                                                     //binary search tree
    if(!node){
        node=newNode;    //Problem Line
        return;
    }
    if(newNode->key<node->key){
        createTree(newNode, node->left);
    }
    else if(newNode->key>node->key){
        createTree(newNode, node->right);
    }
}

int main(){
    int node_count, node_value;
    struct Node* root = NULL;
    cout<<"Enter number of nodes"<<endl;
    cin>>node_count;
    cout<<"Enter node values in a space-separated format"<<endl;
    for(int i=0;i<node_count;i++){
        cin>>node_value;
        struct Node* newNode = createNode(node_value);
        if(!root){
            root = newNode;
        }
        else{
            createTree(newNode, root);
        }
        cout<<root->left<<" "<<root->right<<endl;
    }
    counter=0;
    preorder(root);
    for(int i=0;i<counter;i++){
        cout<<nodes[i]<<" ";
    }
    cout<<endl;

    getch();
    return 0;
}

Above is the code for creating a BST and then storing its preorder traversal in an array. I have mentioned the problem line(the assignment of the pointer is not happening). Can someone, please help me out with this.

Body:
Assigning to a pointer is not going to affect the value after you return from the function.... Please read more about pointer point to pointer and passing-arguments by reference in cpp

The following codes may solve parts of your problem, but not all, I believe there must be more problems in your codes but I don't wanna waste time to debug them.

void createTree(struct Node* &newNode, struct Node* &node){  //Creates a
                                                     //binary search tree
    if(!node){
        node=newNode;    //Problem Line
        return;
    }
    if(newNode->key<node->key){
        createTree(newNode, node->left);
    }
    else if(newNode->key>node->key){
        createTree(newNode, node->right);
    }
}


问:
jQuery not triggering change event on dropdown
I'm trying to trigger the dropdown change event in jQuery (wordpress) but it's not working.

```<code>jQuery("select.buDropDown").each(function() { this.selectedIndex = 0 }).trigger('change');
</code>```

Running this in console only changes the selectedIndex to 0, but never triggers the change event that shows/hides certain elements on the page.

However, running this in console, everything triggers fine:

```<code>$("select.buDropDown").each(function() { this.selectedIndex = 0 }).trigger('change');
</code>```

I can't find any reasons why "$" would work but not "jQuery"

I tried wrapping it in:

```<code>jQuery(function($) {}
</code>```

to be able to use $ instead, but in the wordpress code it still doesn't trigger the change events

Any ideas?

答:
Thank you for all contributions, you gave me some ideas I wanted to follow, and the following worked for my situation:

```<code>$("select.buDropDown").each(function() {
        this.selectedIndex = 0;
     });
    $('select.buDropDown').parent().children('div').each(function() { $(this).hide(); });
</code>```

Even though the dropdown's respective change events would have taken care of it, resetting to the original state is fine.

Body:
I'm trying to trigger the dropdown change event in jQuery (wordpress) but it's not working.

jQuery("select.buDropDown").each(function() { this.selectedIndex = 0 }).trigger('change');

Running this in console only changes the selectedIndex to 0, but never triggers the change event that shows/hides certain elements on the page.

However, running this in console, everything triggers fine:

$("select.buDropDown").each(function() { this.selectedIndex = 0 }).trigger('change');

I can't find any reasons why "$" would work but not "jQuery"

I tried wrapping it in:

jQuery(function($) {}

to be able to use $ instead, but in the wordpress code it still doesn't trigger the change events

Any ideas?

Body:
Thank you for all contributions, you gave me some ideas I wanted to follow, and the following worked for my situation:

$("select.buDropDown").each(function() {
        this.selectedIndex = 0;
     });
    $('select.buDropDown').parent().children('div').each(function() { $(this).hide(); });

Even though the dropdown's respective change events would have taken care of it, resetting to the original state is fine.


问:
Mysql Change Int default value zero to null
Hi i'm working laravel 5 with mysql. I did store zipcode into my database it working well but when the field is empty it stored zero(0) but i want to store empty value in database.

I'm also changed mysql using alter table like below
ALTER TABLE insurances CHANGE COLUMN zipcode4 zipcode4 int(4) unsigned DEFAULT NULL;
but it wont work, have any idea ?

Thanks in advance

答:
the prevous default were 0, so after changing the default they still keep it, to update it after having changed the default, do something like:

```<code>UPDATE mytable set zipcode4=NULL WHERE zipcode4=0
</code>```

the new values will correctly put NULL if not value is provided

Body:
the prevous default were 0, so after changing the default they still keep it, to update it after having changed the default, do something like:

UPDATE mytable set zipcode4=NULL WHERE zipcode4=0

the new values will correctly put NULL if not value is provided


问:
Array of type int doesn't get modified from the function call
For some reason that I'm not aware of, array from main() doesn't get to be modified when it should. Isn't  "a" passed by reference? Can someone please guide me a little bit?

Here is the code:

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

void sort(int list[])
{
    //int list[] = { 4, 3, 2, 1, 10 };
    int n = sizeof(list) / sizeof(int);
    int min = 0;
    int temp = 0;
    for (int i = 0; i < n; i++)
    {
        min = i;
        //profiler.countOperation("compSort", n, 1);
        for (int j = i + 1; j < n; j++)
        {
            if (list[j] < list[min])
            {
                min = j;
                //profiler.countOperation("compSort", n, 1);
                    }
        }
        if (min != i)
        {
            //profiler.countOperation("compSort", n, 1);
            temp = list[min];
            list[min] = list[i];
            list[i] = temp;
        }
    }
}

int main()
{
    int a[5] = {4, 3, 2, 1, 10};
    sort(a);
    printf("%d\n", a[0]);
    for (int i = 0; i < 5; i++)
    {
        printf("%d", a[i]);
    }
    return 0;
    /*int arr[MAX_SIZE];
    for(int t = 0; t < 1; t++)
    {
        for (int n = 100; n < 3000; n = n + 300)
        {
            FillRandomArray(arr, n);
            sort();
            printf("done %d \n", n);

            if (!IsSorted(arr, n)
            {
                printf("error sort \n");
            }
        }
    }
    profiler.addSeries("TotalSort", "cmpSel", "atribSel");
    profiler.createGroup("SortMediu", "TotalSort", "cmpSel", "atribSel");
    profiler.showReport();*/
}
</code>```

答:
Array passed to function in that way decays to pointer so

```<code>int n = sizeof(list) / sizeof(int);
</code>```

Result in sizeof(int *)/sizeof(int)

You can use VLAs to sole the problem

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

void sort(size_t n, int list[n])
{
    size_t min = 0;
    int temp = 0;

    for (size_t i = 0; i < n; i++)
    {
        min = i;
        //profiler.countOperation("compSort", n, 1);
        for (size_t j = i + 1; j < n; j++)
        {
            if (list[j] < list[min])
            {
                min = j;
                //profiler.countOperation("compSort", n, 1);
            }
        }
        if (min != i)
        {
            //profiler.countOperation("compSort", n, 1);
            temp = list[min];
            list[min] = list[i];
            list[i] = temp;
        }
    }
}

int main(void)
{
    int a[5] = { 4, 3, 2, 1, 10 };
    sort(sizeof(a) / sizeof(a[0]), a);
    printf("%d\n", a[0]);
    for (int i = 0; i < 5; i++)
    {
        printf("%d", a[i]);
    }
    printf("\n");

    return 0;
}
</code>```

Body:
For some reason that I'm not aware of, array from main() doesn't get to be modified when it should. Isn't  "a" passed by reference? Can someone please guide me a little bit?

Here is the code:

#include "stdio.h"

void sort(int list[])
{
    //int list[] = { 4, 3, 2, 1, 10 };
    int n = sizeof(list) / sizeof(int);
    int min = 0;
    int temp = 0;
    for (int i = 0; i < n; i++)
    {
        min = i;
        //profiler.countOperation("compSort", n, 1);
        for (int j = i + 1; j < n; j++)
        {
            if (list[j] < list[min])
            {
                min = j;
                //profiler.countOperation("compSort", n, 1);
                    }
        }
        if (min != i)
        {
            //profiler.countOperation("compSort", n, 1);
            temp = list[min];
            list[min] = list[i];
            list[i] = temp;
        }
    }
}

int main()
{
    int a[5] = {4, 3, 2, 1, 10};
    sort(a);
    printf("%d\n", a[0]);
    for (int i = 0; i < 5; i++)
    {
        printf("%d", a[i]);
    }
    return 0;
    /*int arr[MAX_SIZE];
    for(int t = 0; t < 1; t++)
    {
        for (int n = 100; n < 3000; n = n + 300)
        {
            FillRandomArray(arr, n);
            sort();
            printf("done %d \n", n);

            if (!IsSorted(arr, n)
            {
                printf("error sort \n");
            }
        }
    }
    profiler.addSeries("TotalSort", "cmpSel", "atribSel");
    profiler.createGroup("SortMediu", "TotalSort", "cmpSel", "atribSel");
    profiler.showReport();*/
}

Body:
Array passed to function in that way decays to pointer so

int n = sizeof(list) / sizeof(int);

Result in sizeof(int *)/sizeof(int)

You can use VLAs to sole the problem

#include "stdio.h"

void sort(size_t n, int list[n])
{
    size_t min = 0;
    int temp = 0;

    for (size_t i = 0; i < n; i++)
    {
        min = i;
        //profiler.countOperation("compSort", n, 1);
        for (size_t j = i + 1; j < n; j++)
        {
            if (list[j] < list[min])
            {
                min = j;
                //profiler.countOperation("compSort", n, 1);
            }
        }
        if (min != i)
        {
            //profiler.countOperation("compSort", n, 1);
            temp = list[min];
            list[min] = list[i];
            list[i] = temp;
        }
    }
}

int main(void)
{
    int a[5] = { 4, 3, 2, 1, 10 };
    sort(sizeof(a) / sizeof(a[0]), a);
    printf("%d\n", a[0]);
    for (int i = 0; i < 5; i++)
    {
        printf("%d", a[i]);
    }
    printf("\n");

    return 0;
}


问:
Using React Router v4 is it possible to create multi level routes in child components?
So I'm fairly new to the React framework, and I have decided to use Router v4, even though it is in beta, at the time of writing this, it seems to be the best way to go about things.

I have a router that shows one of two components

```<code>import React from 'react';
import { HashRouter as Router, Route } from 'react-router-dom';
import Category from './category/Category';
import Hist from './hist/Hist';

const Controls = React.createClass({
  render: function() {
    return (
      <Router>
        <div>
          <Route path='/category/:categoryId' component={Category}} />
          <Route path='/Hist' component={Hist} />
        </div>
      </Router>
    );
  }
});

export default Controls;
</code>```

This works like a charm, of course, what I want to do now is to have some more routing inside of the Category component. I have tried something like this:

```<code>import React from 'react';
import { Route, Link } from 'react-router-dom';

const Category = React.createClass({
  render: function() {
    return (
      <div>
        <ul>
          <li><Link to='/category/1'>Category 1</Link></li>
          <li><Link to='/category/2'>Category 2</Link></li>
        </ul>
        <div className='category-display'>
          <Route path='/category/1'>This is Category 1</Route>
          <Route path='/category/2'>This is Category 2</Route>
        </div>
      </div>
    );
  }
});
</code>```

But this is giving me a weird error saying something like

```<code>Uncaught Error: React.Children.only expected to receive a single React element child.
</code>```

Is it even possible to pull off a stunt like this or does anyone have any other good suggestions for me?

Or is the best solution to rethink and implement some sort of conditional rendering depending on the route I get to the Category component as props from the first router.

Update:

I realised that <Route> does not seem to accept contents, so I added a component called Display and imported it like so:

```<code>import React from 'react';
import { Route, Link } from 'react-router-dom';
import Display

const Category = React.createClass({
  render: function() {
    return (
      <div>
        <ul>
          <li><Link to='/category/1'>Category 1</Link></li>
          <li><Link to='/category/2'>Category 2</Link></li>
        </ul>
        <div className='category-display'>
          <Route path='/category/1' component={Display} />
          <Route path='/category/2' component={Display} />
        </div>
      </div>
    );
  }
});
</code>```

However Display is not rendered. Any ideas as to why this is would be greatly appreciated.

答:
So it actually turns out that my update (see question above) did the trick. The Display component was at fault here, not the router.

So to recap if anyone else stumbles upon this:

<Route> does not accept any contents, one could have used the render function of <Route> to do some quick testing. Everything is neatly summarised in the React Router API documentation.

Cheers!

Body:
So I'm fairly new to the React framework, and I have decided to use Router v4, even though it is in beta, at the time of writing this, it seems to be the best way to go about things.

I have a router that shows one of two components

import React from 'react';
import { HashRouter as Router, Route } from 'react-router-dom';
import Category from './category/Category';
import Hist from './hist/Hist';

const Controls = React.createClass({
  render: function() {
    return (
      <Router>

          <Route path='/category/:categoryId' component={Category}} />
          <Route path='/Hist' component={Hist} />

      </Router>
    );
  }
});

export default Controls;

This works like a charm, of course, what I want to do now is to have some more routing inside of the Category component. I have tried something like this:

import React from 'react';
import { Route, Link } from 'react-router-dom';

const Category = React.createClass({
  render: function() {
    return (

<Link to='/category/1'>Category 1</Link>

<Link to='/category/2'>Category 2</Link>

          <Route path='/category/1'>This is Category 1</Route>
          <Route path='/category/2'>This is Category 2</Route>

    );
  }
});

But this is giving me a weird error saying something like

Uncaught Error: React.Children.only expected to receive a single React element child.

Is it even possible to pull off a stunt like this or does anyone have any other good suggestions for me?

Or is the best solution to rethink and implement some sort of conditional rendering depending on the route I get to the Category component as props from the first router.

Update:

I realised that <Route> does not seem to accept contents, so I added a component called Display and imported it like so:

import React from 'react';
import { Route, Link } from 'react-router-dom';
import Display

const Category = React.createClass({
  render: function() {
    return (

<Link to='/category/1'>Category 1</Link>

<Link to='/category/2'>Category 2</Link>

          <Route path='/category/1' component={Display} />
          <Route path='/category/2' component={Display} />

    );
  }
});

However Display is not rendered. Any ideas as to why this is would be greatly appreciated.


问:
Undefined variable: "$navbar-height". error in Ruby On Rails
I have just deployed the site and get following error:

```<code>Sass::SyntaxError in MainSite#home

Undefined variable: "$navbar-height".
</code>```

I am not customizing anything and same code works on my local server but not on production server. I have been researching from last 5 days and read more than 10 articles but nothing has worked. Please provide your suggestion and here is the log trace:

```<code>rails_admin (0.8.1) app/assets/stylesheets/rails_admin/base/theming.scss:16
sass (3.4.22) lib/sass/script/tree/variable.rb:49:in `_perform'
sass (3.4.22) lib/sass/script/tree/node.rb:58:in `perform'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:397:in `visit_prop'
sass (3.4.22) lib/sass/tree/visitors/base.rb:36:in `visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:160:in `block in visit'
sass (3.4.22) lib/sass/stack.rb:79:in `block in with_base'
sass (3.4.22) lib/sass/stack.rb:115:in `with_frame'
sass (3.4.22) lib/sass/stack.rb:79:in `with_base'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:160:in `visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:433:in `block (2 levels) in visit_rule'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:433:in `map'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:433:in `block in visit_rule'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:181:in `with_environment'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:431:in `visit_rule'
sass (3.4.22) lib/sass/tree/visitors/base.rb:36:in `visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:160:in `block in visit'
sass (3.4.22) lib/sass/stack.rb:79:in `block in with_base'
sass (3.4.22) lib/sass/stack.rb:115:in `with_frame'
sass (3.4.22) lib/sass/stack.rb:79:in `with_base'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:160:in `visit'
sass (3.4.22) lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
sass (3.4.22) lib/sass/tree/visitors/base.rb:52:in `map'
sass (3.4.22) lib/sass/tree/visitors/base.rb:52:in `visit_children'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:169:in `block in visit_children'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:181:in `with_environment'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:168:in `visit_children'
sass (3.4.22) lib/sass/tree/visitors/base.rb:36:in `block in visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:188:in `visit_root'
sass (3.4.22) lib/sass/tree/visitors/base.rb:36:in `visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:159:in `visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:8:in `visit'
sass (3.4.22) lib/sass/tree/root_node.rb:36:in `css_tree'
sass (3.4.22) lib/sass/tree/root_node.rb:20:in `render'
sass (3.4.22) lib/sass/engine.rb:281:in `render'
sass-rails (5.0.4) lib/sass/rails/template.rb:47:in `evaluate'
tilt (2.0.2) lib/tilt/template.rb:99:in `render'
sprockets (3.6.0) lib/sprockets/legacy_tilt_processor.rb:25:in `call'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:75:in `call_processor'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:56:in `reverse_each'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:56:in `call_processors'
sprockets (3.6.0) lib/sprockets/loader.rb:134:in `load_from_unloaded'
sprockets (3.6.0) lib/sprockets/loader.rb:60:in `block in load'
sprockets (3.6.0) lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
sprockets (3.6.0) lib/sprockets/loader.rb:44:in `load'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:20:in `block in initialize'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:47:in `yield'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:47:in `load'
sprockets (3.6.0) lib/sprockets/bundle.rb:23:in `block in call'
sprockets (3.6.0) lib/sprockets/utils.rb:183:in `dfs'
sprockets (3.6.0) lib/sprockets/bundle.rb:24:in `call'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:75:in `call_processor'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:56:in `reverse_each'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:56:in `call_processors'
sprockets (3.6.0) lib/sprockets/loader.rb:134:in `load_from_unloaded'
sprockets (3.6.0) lib/sprockets/loader.rb:60:in `block in load'
sprockets (3.6.0) lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
sprockets (3.6.0) lib/sprockets/loader.rb:44:in `load'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:20:in `block in initialize'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:47:in `yield'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:47:in `load'
sprockets (3.6.0) lib/sprockets/base.rb:66:in `find_asset'
sprockets (3.6.0) lib/sprockets/base.rb:73:in `find_all_linked_assets'
sprockets (3.6.0) lib/sprockets/manifest.rb:142:in `block in find'
sprockets (3.6.0) lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
sprockets (3.6.0) lib/sprockets/path_utils.rb:223:in `block in stat_tree'
sprockets (3.6.0) lib/sprockets/path_utils.rb:207:in `block in stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `each'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:222:in `stat_tree'
sprockets (3.6.0) lib/sprockets/path_utils.rb:226:in `block in stat_tree'
sprockets (3.6.0) lib/sprockets/path_utils.rb:207:in `block in stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `each'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:222:in `stat_tree'
sprockets (3.6.0) lib/sprockets/path_utils.rb:226:in `block in stat_tree'
sprockets (3.6.0) lib/sprockets/path_utils.rb:207:in `block in stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `each'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:222:in `stat_tree'
sprockets (3.6.0) lib/sprockets/legacy.rb:105:in `each'
sprockets (3.6.0) lib/sprockets/legacy.rb:105:in `block in logical_paths'
sprockets (3.6.0) lib/sprockets/legacy.rb:104:in `each'
sprockets (3.6.0) lib/sprockets/legacy.rb:104:in `logical_paths'
sprockets (3.6.0) lib/sprockets/manifest.rb:140:in `find'
sprockets-rails (3.0.4) lib/sprockets/railtie.rb:49:in `each'
sprockets-rails (3.0.4) lib/sprockets/railtie.rb:49:in `map'
sprockets-rails (3.0.4) lib/sprockets/railtie.rb:49:in `precompiled_assets'
sprockets-rails (3.0.4) lib/sprockets/railtie.rb:34:in `asset_precompiled?'
sprockets-rails (3.0.4) lib/sprockets/railtie.rb:214:in `block (3 levels) in <class:Railtie>'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:345:in `call'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:345:in `precompiled?'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:349:in `raise_unless_precompiled_asset'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:323:in `digest_path'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:311:in `asset_path'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:89:in `block in resolve_asset_path'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:229:in `block in resolve_asset'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:228:in `each'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:228:in `detect'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:228:in `resolve_asset'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:88:in `resolve_asset_path'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:78:in `compute_asset_path'
actionview (4.2.6) lib/action_view/helpers/asset_url_helper.rb:135:in `asset_path'
actionview (4.2.6) lib/action_view/helpers/asset_url_helper.rb:292:in `image_path'
actionview (4.2.6) lib/action_view/helpers/asset_tag_helper.rb:176:in `favicon_link_tag'
app/views/layouts/main_site.html.erb:12:in `_app_views_layouts_main_site_html_erb___2923942470482702653_69847020960300'
actionview (4.2.6) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.6) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.6) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.6) lib/action_view/template.rb:143:in `render'
actionview (4.2.6) lib/action_view/renderer/template_renderer.rb:66:in `render_with_layout'
actionview (4.2.6) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.6) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.6) lib/action_view/renderer/renderer.rb:46:in `render_template'
actionview (4.2.6) lib/action_view/renderer/renderer.rb:27:in `render'
actionview (4.2.6) lib/action_view/rendering.rb:100:in `_render_template'
actionpack (4.2.6) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.2.6) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (4.2.6) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.2.6) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.6) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.6) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (4.2.6) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/home/root_zap/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
activesupport (4.2.6) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (4.2.6) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:43:in `render'
meta-tags (2.1.0) lib/meta_tags/controller_helper.rb:26:in `render_with_meta_tags'
remotipart (1.2.1) lib/remotipart/render_overrides.rb:14:in `render_with_remotipart'
actionpack (4.2.6) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.2.6) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.2.6) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.6) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.6) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.6) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
activesupport (4.2.6) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.6) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.6) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
activesupport (4.2.6) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
activesupport (4.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.6) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.6) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.6) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.6) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.6) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.6) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.6) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.6) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:74:in `call'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:43:in `serve'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:817:in `call'
rack-pjax (0.8.0) lib/rack/pjax.rb:12:in `call'
apartment (1.0.2) lib/apartment/reloader.rb:18:in `call'
simple_captcha2 (0.4.0) lib/simple_captcha/middleware.rb:26:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) lib/warden/manager.rb:34:in `catch'
warden (1.2.6) lib/warden/manager.rb:34:in `call'
rack (1.6.4) lib/rack/etag.rb:24:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
remotipart (1.2.1) lib/remotipart/middleware.rb:27:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.6) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
activerecord (4.2.6) lib/active_record/migration.rb:377:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.6) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.6) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:20:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.6) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.6) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.6) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
actionpack (4.2.6) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.6) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/static.rb:120:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.6) lib/rails/engine.rb:518:in `call'
railties (4.2.6) lib/rails/application.rb:165:in `call'
/home/root_zap/.rvm/gems/ruby-2.0.0-p643@redmine/gems/passenger-5.0.23/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
/home/root_zap/.rvm/gems/ruby-2.0.0-p643@redmine/gems/passenger-5.0.23/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:152:in `accept_and_process_next_request'
/home/root_zap/.rvm/gems/ruby-2.0.0-p643@redmine/gems/passenger-5.0.23/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop'
/home/root_zap/.rvm/gems/ruby-2.0.0-p643@redmine/gems/passenger-5.0.23/src/ruby_supportlib/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads'
/home/root_zap/.rvm/gems/ruby-2.0.0-p643@redmine/gems/passenger-5.0.23/src/ruby_supportlib/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
</code>```

Here is my Gemfile

```<code>source 'https://rubygems.org'

# Use rails as a framework
gem 'rails', '4.2.0'

gem 'rails_admin_nestable', '~> 0.3.2'

# Use postgresql as the database for Active Record
gem 'pg'

# Use devise for authentication
gem 'devise'

# Use passenger for server
gem 'passenger'

# Use rails_admin for admin section
gem 'rails_admin'

# Use paperclip for image section
gem "paperclip"

# Use paperclip for image section
gem 'feedjira', '~> 1.6.0'

# Use simple_captcha2 for captcha image section
gem 'simple_captcha2', :require => 'simple_captcha'

# Use meta tags for seo section
gem 'meta-tags', :require => 'meta_tags'

# Use apartment for subdomain and database schema
gem 'apartment'

# Use whenever for CRON jobs
gem 'whenever', :require => false

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Use ckeditor to display rich textare
gem "ckeditor"

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.1.0'

# Turbolinks makes following links in your web application faster.
gem 'turbolinks'

# Build JSON APIs with ease.
gem 'jbuilder', '~> 2.0'

# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  #gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  # gem for deploying google maps in your application
  gem 'geocoder'
  gem 'gmaps4rails'
  gem 'quiet_assets'
end
</code>```

Here is lock file (not working)

```<code> remote: https://rubygems.org/
  specs:
    actionmailer (4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.0)
      actionview (= 4.2.0)
      activesupport (= 4.2.0)
      rack (~> 1.6.0)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    actionview (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    activejob (4.2.0)
      activesupport (= 4.2.0)
      globalid (>= 0.3.0)
    activemodel (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
    activerecord (4.2.0)
      activemodel (= 4.2.0)
      activesupport (= 4.2.0)
      arel (~> 6.0)
    activesupport (4.2.0)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    airbrussh (1.0.1)
      sshkit (>= 1.6.1, != 1.7.0)
    apartment (1.0.2)
      activerecord (>= 3.1.2, < 5.0)
      rack (>= 1.3.6)
    arel (6.0.3)
    autoprefixer-rails (6.3.6)
      execjs
    bcrypt (3.1.11)
    binding_of_caller (0.7.2)
      debug_inspector (>= 0.0.1)
    bootstrap-sass (3.3.6)
      autoprefixer-rails (>= 5.2.1)
      sass (>= 3.3.4)
    builder (3.2.2)
    capistrano (3.5.0)
      airbrussh (>= 1.0.0)
      capistrano-harrow
      i18n
      rake (>= 10.0.0)
      sshkit (>= 1.9.0)
    capistrano-bundler (1.1.4)
      capistrano (~> 3.1)
      sshkit (~> 1.2)
    capistrano-harrow (0.3.2)
    capistrano-rails (1.1.6)
      capistrano (~> 3.1)
      capistrano-bundler (~> 1.1)
    chronic (0.10.2)
    ckeditor (4.1.6)
      cocaine
      orm_adapter (~> 0.5.0)
    climate_control (0.0.3)
      activesupport (>= 3.0)
    cocaine (0.5.8)
      climate_control (>= 0.0.3, < 1.0)
    coffee-rails (4.1.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.1.x)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.10.0)
    concurrent-ruby (1.0.1)
    curb (0.9.3)
    debug_inspector (0.0.2)
    devise (4.0.1)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 4.1.0, < 5.1)
      responders
      warden (~> 1.2.3)
    erubis (2.7.0)
    execjs (2.6.0)
    feedjira (1.6.0)
      curb (~> 0.8)
      loofah (~> 2.0)
      sax-machine (~> 1.0)
    geocoder (1.3.4)
    globalid (0.3.6)
      activesupport (>= 4.1.0)
    gmaps4rails (2.1.2)
    i18n (0.7.0)
    jbuilder (2.4.1)
      activesupport (>= 3.0.0, < 5.1)
      multi_json (~> 1.2)
    jquery-rails (4.1.1)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    json (1.8.3)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    mail (2.6.4)
      mime-types (>= 1.16, < 4)
    meta-tags (2.1.0)
      actionpack (>= 3.0.0)
    mime-types (3.0)
      mime-types-data (~> 3.2015)
    mime-types-data (3.2016.0221)
    mimemagic (0.3.0)
    mini_portile2 (2.0.0)
    minitest (5.8.4)
    multi_json (1.11.3)
    net-scp (1.2.1)
      net-ssh (>= 2.6.5)
    net-ssh (3.1.1)
    nokogiri (1.6.7.2)
      mini_portile2 (~> 2.0.0.rc2)
    orm_adapter (0.5.0)
    paperclip (4.3.6)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
      cocaine (~> 0.5.5)
      mime-types
      mimemagic (= 0.3.0)
    passenger (5.0.27)
      rack
      rake (>= 0.8.1)
    pg (0.18.4)
    quiet_assets (1.1.0)
      railties (>= 3.1, < 5.0)
    rack (1.6.4)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.0)
      actionmailer (= 4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      activemodel (= 4.2.0)
      activerecord (= 4.2.0)
      activesupport (= 4.2.0)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.0)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.7)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.3)
      loofah (~> 2.0)
    railties (4.2.0)
      actionpack (= 4.2.0)
      activesupport (= 4.2.0)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (11.1.2)
    rdoc (4.2.2)
      json (~> 1.4)
    responders (2.1.2)
      railties (>= 4.2.0, < 5.1)
    sass (3.4.22)
    sass-rails (5.0.4)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    sax-machine (1.3.2)
    sdoc (0.4.1)
      json (~> 1.7, >= 1.7.7)
      rdoc (~> 4.0)
    simple_captcha2 (0.4.0)
      rails (>= 4.1)
    spring (1.7.1)
    sprockets (3.6.0)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.0.4)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sshkit (1.10.0)
      net-scp (>= 1.1.2)
      net-ssh (>= 2.8.0)
    thor (0.19.1)
    thread_safe (0.3.5)
    tilt (2.0.2)
    turbolinks (2.5.3)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    uglifier (3.0.0)
      execjs (>= 0.3.0, < 3)
    warden (1.2.6)
      rack (>= 1.0)
    web-console (2.3.0)
      activemodel (>= 4.0)
      binding_of_caller (>= 0.7.2)
      railties (>= 4.0)
      sprockets-rails (>= 2.0, < 4.0)
    whenever (0.9.4)
      chronic (>= 0.6.3)

PLATFORMS
  ruby

DEPENDENCIES
  apartment
  bcrypt (~> 3.1.7)
  bootstrap-sass
  capistrano-rails
  ckeditor
  coffee-rails (~> 4.1.0)
  devise
  feedjira (~> 1.6.0)
  geocoder
  gmaps4rails
  jbuilder (~> 2.0)
  jquery-rails
  meta-tags
  paperclip
  passenger
  pg
  quiet_assets
  rails (= 4.2.0)
  sass-rails (~> 5.0)
  sdoc (~> 0.4.0)
  simple_captcha2
  spring
  turbolinks
  uglifier (>= 1.3.0)
  web-console (~> 2.0)
  whenever
</code>```

答:
I have removed below line form my application code that work for me</p>

```<code>config.assets.precompile += %w( *.js *.css)
</code>```

Body:
I have just deployed the site and get following error:

Sass::SyntaxError in MainSite#home

Undefined variable: "$navbar-height".

I am not customizing anything and same code works on my local server but not on production server. I have been researching from last 5 days and read more than 10 articles but nothing has worked. Please provide your suggestion and here is the log trace:

rails_admin (0.8.1) app/assets/stylesheets/rails_admin/base/theming.scss:16
sass (3.4.22) lib/sass/script/tree/variable.rb:49:in `_perform'
sass (3.4.22) lib/sass/script/tree/node.rb:58:in `perform'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:397:in `visit_prop'
sass (3.4.22) lib/sass/tree/visitors/base.rb:36:in `visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:160:in `block in visit'
sass (3.4.22) lib/sass/stack.rb:79:in `block in with_base'
sass (3.4.22) lib/sass/stack.rb:115:in `with_frame'
sass (3.4.22) lib/sass/stack.rb:79:in `with_base'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:160:in `visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:433:in `block (2 levels) in visit_rule'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:433:in `map'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:433:in `block in visit_rule'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:181:in `with_environment'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:431:in `visit_rule'
sass (3.4.22) lib/sass/tree/visitors/base.rb:36:in `visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:160:in `block in visit'
sass (3.4.22) lib/sass/stack.rb:79:in `block in with_base'
sass (3.4.22) lib/sass/stack.rb:115:in `with_frame'
sass (3.4.22) lib/sass/stack.rb:79:in `with_base'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:160:in `visit'
sass (3.4.22) lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
sass (3.4.22) lib/sass/tree/visitors/base.rb:52:in `map'
sass (3.4.22) lib/sass/tree/visitors/base.rb:52:in `visit_children'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:169:in `block in visit_children'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:181:in `with_environment'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:168:in `visit_children'
sass (3.4.22) lib/sass/tree/visitors/base.rb:36:in `block in visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:188:in `visit_root'
sass (3.4.22) lib/sass/tree/visitors/base.rb:36:in `visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:159:in `visit'
sass (3.4.22) lib/sass/tree/visitors/perform.rb:8:in `visit'
sass (3.4.22) lib/sass/tree/root_node.rb:36:in `css_tree'
sass (3.4.22) lib/sass/tree/root_node.rb:20:in `render'
sass (3.4.22) lib/sass/engine.rb:281:in `render'
sass-rails (5.0.4) lib/sass/rails/template.rb:47:in `evaluate'
tilt (2.0.2) lib/tilt/template.rb:99:in `render'
sprockets (3.6.0) lib/sprockets/legacy_tilt_processor.rb:25:in `call'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:75:in `call_processor'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:56:in `reverse_each'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:56:in `call_processors'
sprockets (3.6.0) lib/sprockets/loader.rb:134:in `load_from_unloaded'
sprockets (3.6.0) lib/sprockets/loader.rb:60:in `block in load'
sprockets (3.6.0) lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
sprockets (3.6.0) lib/sprockets/loader.rb:44:in `load'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:20:in `block in initialize'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:47:in `yield'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:47:in `load'
sprockets (3.6.0) lib/sprockets/bundle.rb:23:in `block in call'
sprockets (3.6.0) lib/sprockets/utils.rb:183:in `dfs'
sprockets (3.6.0) lib/sprockets/bundle.rb:24:in `call'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:75:in `call_processor'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:56:in `reverse_each'
sprockets (3.6.0) lib/sprockets/processor_utils.rb:56:in `call_processors'
sprockets (3.6.0) lib/sprockets/loader.rb:134:in `load_from_unloaded'
sprockets (3.6.0) lib/sprockets/loader.rb:60:in `block in load'
sprockets (3.6.0) lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
sprockets (3.6.0) lib/sprockets/loader.rb:44:in `load'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:20:in `block in initialize'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:47:in `yield'
sprockets (3.6.0) lib/sprockets/cached_environment.rb:47:in `load'
sprockets (3.6.0) lib/sprockets/base.rb:66:in `find_asset'
sprockets (3.6.0) lib/sprockets/base.rb:73:in `find_all_linked_assets'
sprockets (3.6.0) lib/sprockets/manifest.rb:142:in `block in find'
sprockets (3.6.0) lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
sprockets (3.6.0) lib/sprockets/path_utils.rb:223:in `block in stat_tree'
sprockets (3.6.0) lib/sprockets/path_utils.rb:207:in `block in stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `each'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:222:in `stat_tree'
sprockets (3.6.0) lib/sprockets/path_utils.rb:226:in `block in stat_tree'
sprockets (3.6.0) lib/sprockets/path_utils.rb:207:in `block in stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `each'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:222:in `stat_tree'
sprockets (3.6.0) lib/sprockets/path_utils.rb:226:in `block in stat_tree'
sprockets (3.6.0) lib/sprockets/path_utils.rb:207:in `block in stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `each'
sprockets (3.6.0) lib/sprockets/path_utils.rb:204:in `stat_directory'
sprockets (3.6.0) lib/sprockets/path_utils.rb:222:in `stat_tree'
sprockets (3.6.0) lib/sprockets/legacy.rb:105:in `each'
sprockets (3.6.0) lib/sprockets/legacy.rb:105:in `block in logical_paths'
sprockets (3.6.0) lib/sprockets/legacy.rb:104:in `each'
sprockets (3.6.0) lib/sprockets/legacy.rb:104:in `logical_paths'
sprockets (3.6.0) lib/sprockets/manifest.rb:140:in `find'
sprockets-rails (3.0.4) lib/sprockets/railtie.rb:49:in `each'
sprockets-rails (3.0.4) lib/sprockets/railtie.rb:49:in `map'
sprockets-rails (3.0.4) lib/sprockets/railtie.rb:49:in `precompiled_assets'
sprockets-rails (3.0.4) lib/sprockets/railtie.rb:34:in `asset_precompiled?'
sprockets-rails (3.0.4) lib/sprockets/railtie.rb:214:in `block (3 levels) in <class:Railtie>'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:345:in `call'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:345:in `precompiled?'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:349:in `raise_unless_precompiled_asset'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:323:in `digest_path'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:311:in `asset_path'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:89:in `block in resolve_asset_path'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:229:in `block in resolve_asset'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:228:in `each'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:228:in `detect'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:228:in `resolve_asset'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:88:in `resolve_asset_path'
sprockets-rails (3.0.4) lib/sprockets/rails/helper.rb:78:in `compute_asset_path'
actionview (4.2.6) lib/action_view/helpers/asset_url_helper.rb:135:in `asset_path'
actionview (4.2.6) lib/action_view/helpers/asset_url_helper.rb:292:in `image_path'
actionview (4.2.6) lib/action_view/helpers/asset_tag_helper.rb:176:in `favicon_link_tag'
app/views/layouts/main_site.html.erb:12:in `_app_views_layouts_main_site_html_erb___2923942470482702653_69847020960300'
actionview (4.2.6) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.6) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.6) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.6) lib/action_view/template.rb:143:in `render'
actionview (4.2.6) lib/action_view/renderer/template_renderer.rb:66:in `render_with_layout'
actionview (4.2.6) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.6) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.6) lib/action_view/renderer/renderer.rb:46:in `render_template'
actionview (4.2.6) lib/action_view/renderer/renderer.rb:27:in `render'
actionview (4.2.6) lib/action_view/rendering.rb:100:in `_render_template'
actionpack (4.2.6) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.2.6) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (4.2.6) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.2.6) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.6) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.6) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (4.2.6) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/home/root_zap/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
activesupport (4.2.6) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (4.2.6) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:43:in `render'
meta-tags (2.1.0) lib/meta_tags/controller_helper.rb:26:in `render_with_meta_tags'
remotipart (1.2.1) lib/remotipart/render_overrides.rb:14:in `render_with_remotipart'
actionpack (4.2.6) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.2.6) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.2.6) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.6) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.6) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.6) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
activesupport (4.2.6) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.6) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.6) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
activesupport (4.2.6) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
activesupport (4.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.6) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.6) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.6) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.6) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.6) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.6) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.6) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.6) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.6) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:74:in `call'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:43:in `serve'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:817:in `call'
rack-pjax (0.8.0) lib/rack/pjax.rb:12:in `call'
apartment (1.0.2) lib/apartment/reloader.rb:18:in `call'
simple_captcha2 (0.4.0) lib/simple_captcha/middleware.rb:26:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) lib/warden/manager.rb:34:in `catch'
warden (1.2.6) lib/warden/manager.rb:34:in `call'
rack (1.6.4) lib/rack/etag.rb:24:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
remotipart (1.2.1) lib/remotipart/middleware.rb:27:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.6) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
activerecord (4.2.6) lib/active_record/migration.rb:377:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.6) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.6) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:20:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.6) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.6) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.6) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
actionpack (4.2.6) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.6) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/static.rb:120:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.6) lib/rails/engine.rb:518:in `call'
railties (4.2.6) lib/rails/application.rb:165:in `call'
/home/root_zap/.rvm/gems/ruby-2.0.0-p643@redmine/gems/passenger-5.0.23/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
/home/root_zap/.rvm/gems/ruby-2.0.0-p643@redmine/gems/passenger-5.0.23/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:152:in `accept_and_process_next_request'
/home/root_zap/.rvm/gems/ruby-2.0.0-p643@redmine/gems/passenger-5.0.23/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop'
/home/root_zap/.rvm/gems/ruby-2.0.0-p643@redmine/gems/passenger-5.0.23/src/ruby_supportlib/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads'
/home/root_zap/.rvm/gems/ruby-2.0.0-p643@redmine/gems/passenger-5.0.23/src/ruby_supportlib/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'

Here is my Gemfile

source 'https://rubygems.org'

# Use rails as a framework
gem 'rails', '4.2.0'

gem 'rails_admin_nestable', '~> 0.3.2'

# Use postgresql as the database for Active Record
gem 'pg'

# Use devise for authentication
gem 'devise'

# Use passenger for server
gem 'passenger'

# Use rails_admin for admin section
gem 'rails_admin'

# Use paperclip for image section
gem "paperclip"

# Use paperclip for image section
gem 'feedjira', '~> 1.6.0'

# Use simple_captcha2 for captcha image section
gem 'simple_captcha2', :require => 'simple_captcha'

# Use meta tags for seo section
gem 'meta-tags', :require => 'meta_tags'

# Use apartment for subdomain and database schema
gem 'apartment'

# Use whenever for CRON jobs
gem 'whenever', :require => false

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Use ckeditor to display rich textare
gem "ckeditor"

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.1.0'

# Turbolinks makes following links in your web application faster.
gem 'turbolinks'

# Build JSON APIs with ease.
gem 'jbuilder', '~> 2.0'

# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  #gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  # gem for deploying google maps in your application
  gem 'geocoder'
  gem 'gmaps4rails'
  gem 'quiet_assets'
end

Here is lock file (not working)

 remote: https://rubygems.org/
  specs:
    actionmailer (4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.0)
      actionview (= 4.2.0)
      activesupport (= 4.2.0)
      rack (~> 1.6.0)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    actionview (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    activejob (4.2.0)
      activesupport (= 4.2.0)
      globalid (>= 0.3.0)
    activemodel (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
    activerecord (4.2.0)
      activemodel (= 4.2.0)
      activesupport (= 4.2.0)
      arel (~> 6.0)
    activesupport (4.2.0)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    airbrussh (1.0.1)
      sshkit (>= 1.6.1, != 1.7.0)
    apartment (1.0.2)
      activerecord (>= 3.1.2, < 5.0)
      rack (>= 1.3.6)
    arel (6.0.3)
    autoprefixer-rails (6.3.6)
      execjs
    bcrypt (3.1.11)
    binding_of_caller (0.7.2)
      debug_inspector (>= 0.0.1)
    bootstrap-sass (3.3.6)
      autoprefixer-rails (>= 5.2.1)
      sass (>= 3.3.4)
    builder (3.2.2)
    capistrano (3.5.0)
      airbrussh (>= 1.0.0)
      capistrano-harrow
      i18n
      rake (>= 10.0.0)
      sshkit (>= 1.9.0)
    capistrano-bundler (1.1.4)
      capistrano (~> 3.1)
      sshkit (~> 1.2)
    capistrano-harrow (0.3.2)
    capistrano-rails (1.1.6)
      capistrano (~> 3.1)
      capistrano-bundler (~> 1.1)
    chronic (0.10.2)
    ckeditor (4.1.6)
      cocaine
      orm_adapter (~> 0.5.0)
    climate_control (0.0.3)
      activesupport (>= 3.0)
    cocaine (0.5.8)
      climate_control (>= 0.0.3, < 1.0)
    coffee-rails (4.1.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.1.x)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.10.0)
    concurrent-ruby (1.0.1)
    curb (0.9.3)
    debug_inspector (0.0.2)
    devise (4.0.1)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 4.1.0, < 5.1)
      responders
      warden (~> 1.2.3)
    erubis (2.7.0)
    execjs (2.6.0)
    feedjira (1.6.0)
      curb (~> 0.8)
      loofah (~> 2.0)
      sax-machine (~> 1.0)
    geocoder (1.3.4)
    globalid (0.3.6)
      activesupport (>= 4.1.0)
    gmaps4rails (2.1.2)
    i18n (0.7.0)
    jbuilder (2.4.1)
      activesupport (>= 3.0.0, < 5.1)
      multi_json (~> 1.2)
    jquery-rails (4.1.1)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    json (1.8.3)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    mail (2.6.4)
      mime-types (>= 1.16, < 4)
    meta-tags (2.1.0)
      actionpack (>= 3.0.0)
    mime-types (3.0)
      mime-types-data (~> 3.2015)
    mime-types-data (3.2016.0221)
    mimemagic (0.3.0)
    mini_portile2 (2.0.0)
    minitest (5.8.4)
    multi_json (1.11.3)
    net-scp (1.2.1)
      net-ssh (>= 2.6.5)
    net-ssh (3.1.1)
    nokogiri (1.6.7.2)
      mini_portile2 (~> 2.0.0.rc2)
    orm_adapter (0.5.0)
    paperclip (4.3.6)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
      cocaine (~> 0.5.5)
      mime-types
      mimemagic (= 0.3.0)
    passenger (5.0.27)
      rack
      rake (>= 0.8.1)
    pg (0.18.4)
    quiet_assets (1.1.0)
      railties (>= 3.1, < 5.0)
    rack (1.6.4)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.0)
      actionmailer (= 4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      activemodel (= 4.2.0)
      activerecord (= 4.2.0)
      activesupport (= 4.2.0)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.0)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.7)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.3)
      loofah (~> 2.0)
    railties (4.2.0)
      actionpack (= 4.2.0)
      activesupport (= 4.2.0)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (11.1.2)
    rdoc (4.2.2)
      json (~> 1.4)
    responders (2.1.2)
      railties (>= 4.2.0, < 5.1)
    sass (3.4.22)
    sass-rails (5.0.4)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    sax-machine (1.3.2)
    sdoc (0.4.1)
      json (~> 1.7, >= 1.7.7)
      rdoc (~> 4.0)
    simple_captcha2 (0.4.0)
      rails (>= 4.1)
    spring (1.7.1)
    sprockets (3.6.0)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.0.4)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sshkit (1.10.0)
      net-scp (>= 1.1.2)
      net-ssh (>= 2.8.0)
    thor (0.19.1)
    thread_safe (0.3.5)
    tilt (2.0.2)
    turbolinks (2.5.3)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    uglifier (3.0.0)
      execjs (>= 0.3.0, < 3)
    warden (1.2.6)
      rack (>= 1.0)
    web-console (2.3.0)
      activemodel (>= 4.0)
      binding_of_caller (>= 0.7.2)
      railties (>= 4.0)
      sprockets-rails (>= 2.0, < 4.0)
    whenever (0.9.4)
      chronic (>= 0.6.3)

PLATFORMS
  ruby

DEPENDENCIES
  apartment
  bcrypt (~> 3.1.7)
  bootstrap-sass
  capistrano-rails
  ckeditor
  coffee-rails (~> 4.1.0)
  devise
  feedjira (~> 1.6.0)
  geocoder
  gmaps4rails
  jbuilder (~> 2.0)
  jquery-rails
  meta-tags
  paperclip
  passenger
  pg
  quiet_assets
  rails (= 4.2.0)
  sass-rails (~> 5.0)
  sdoc (~> 0.4.0)
  simple_captcha2
  spring
  turbolinks
  uglifier (>= 1.3.0)
  web-console (~> 2.0)
  whenever

Body:
I have removed below line form my application code that work for me

config.assets.precompile += %w( *.js *.css)


问:
Select with a size doesnt have the same behavior than normal

<select size=5>
  <option>
    Option 1
  </option>
  <option>
    Option 2
  </option>
  <option>
    Option 3
  </option>
  <option>
    Option 4
  </option>
</select>

   <input value="input1" />
   <input value="input2"/>
   <input value="input3"/>
   <input value="input4"/>
   <input value="input5"/>

   <button>Add an option</button>
   <button>Delete an option</button>
   <button>Save an option</button>

```

Context : i want to simply do a select list but it look like it doesn't have the same behavior with a size than normal mode .
The widget i want to create is a select box with a list of option, you can add or delete an option, and when you click on a specific option, i do an ajax call to get all the information of the selected option and it fills on the inputs, you can save those input for this option by using the save button
At the load of the window, i get all the option linked to the accout and it automaticaly create the select .

Problems : it look very simple to code this, but i have a lot of rules to implement, like if you switch to another option and you dont have save the current option, a comfirm bix appear and ask you if you want to save or not the current option, if you say yes it's good you go the next option and it fills the input with the other, if you say no the select have to stay to the previous option but with this kind of select you cannot select something like i've tried to save the previous option and then put the selected="selected" on it and also try to focus() on it but it doesnt work with this kind of select

Questions : do you have some example of this kind of widget or do you have some js library who include this kind of widget ?

Edit : https://jsfiddle.net/e883gp9z/1/

答:
The issue is because the logic you're using to store the last selected option and reset it when needed is flawed. It's much simpler to use the string value rather than the element reference. You can also perform the logic in a single change event handler - there's no need for the setTimeout() or click handler. Try this:

var lastSelected = $('#values').val();

$("#values").change(function() {
  if (confirm("Voulez vous sauvegarder avant de quitter ?")) {
    // do code
  } else {
    $(this).val(lastSelected);
  }

  lastSelected = $(this).val();
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="values" size=5>
  <option selected="selected">Option 1</option>
  <option>Option 2</option>
  <option>Option 3</option>
  <option>Option 4</option>
</select></code>```

Body:
<select size=5>
  <option>
    Option 1
  </option>
  <option>
    Option 2
  </option>
  <option>
    Option 3
  </option>
  <option>
    Option 4
  </option>
</select>

   <input value="input1" />
   <input value="input2"/>
   <input value="input3"/>
   <input value="input4"/>
   <input value="input5"/>

   <button>Add an option</button>
   <button>Delete an option</button>
   <button>Save an option</button>

Context : i want to simply do a select list but it look like it doesn't have the same behavior with a size than normal mode .
The widget i want to create is a select box with a list of option, you can add or delete an option, and when you click on a specific option, i do an ajax call to get all the information of the selected option and it fills on the inputs, you can save those input for this option by using the save button
At the load of the window, i get all the option linked to the accout and it automaticaly create the select .

Problems : it look very simple to code this, but i have a lot of rules to implement, like if you switch to another option and you dont have save the current option, a comfirm bix appear and ask you if you want to save or not the current option, if you say yes it's good you go the next option and it fills the input with the other, if you say no the select have to stay to the previous option but with this kind of select you cannot select something like i've tried to save the previous option and then put the selected="selected" on it and also try to focus() on it but it doesnt work with this kind of select

Questions : do you have some example of this kind of widget or do you have some js library who include this kind of widget ?

Edit : https://jsfiddle.net/e883gp9z/1/

Body:
The issue is because the logic you're using to store the last selected option and reset it when needed is flawed. It's much simpler to use the string value rather than the element reference. You can also perform the logic in a single change event handler - there's no need for the setTimeout() or click handler. Try this:

var lastSelected = $('#values').val();

$("#values").change(function() {
  if (confirm("Voulez vous sauvegarder avant de quitter ?")) {
    // do code
  } else {
    $(this).val(lastSelected);
  }

  lastSelected = $(this).val();
})

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="values" size=5>
  <option selected="selected">Option 1</option>
  <option>Option 2</option>
  <option>Option 3</option>
  <option>Option 4</option>
</select>