问:
Spring RestTemplate 415 Unsupported Media Type
I try to use Spring Restful webservice.

I have created two projects in two eclipse. In one project I have written RestClient program and in another project I have written webservice and stared the webservice over tomcat. I am trying to pass java bean as json communication between client and server.

But I got below exception.

```<code>org.springframework.web.client.HttpClientErrorException: 415 Unsupported Media Type
</code>```

I have tried in many ways but it was unsuccessful. Below is my code snippet.

Client Method :

```<code>private static void postTrack() {
    try {
        final String uri = "http://localhost:8181/RestWS/test";

        Track track = new Track();
        track.setTitle("Singer");
        track.setSinger("Shas");

        RestTemplate restTemplate = new RestTemplate();

        Track responseTrack = restTemplate.postForObject(uri, track, Track.class);

    } catch (Exception e) {
        e.printStackTrace();
    }
}
</code>```

Service Method :

```<code>@RequestMapping(value = "/test", method = RequestMethod.POST, headers = "Accept=application/json")
    public @ResponseBody Track testMethod(@RequestBody Track track) {
        System.out.println(" Inside Test Method : ");
        System.out.println(" In GreetingController.greeting() "+track.getSinger());
        return track;
    }
</code>```

Track Class :

```<code>public class Track {

    String title;
    String singer;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSinger() {
        return singer;
    }

    public void setSinger(String singer) {
        this.singer = singer;
    }

    @Override
    public String toString() {
        return "Track [title=" + title + ", singer=" + singer + "]";
    }
}
</code>```

Also I tried with

```<code>restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
</code>```

And

```<code>MultiValueMap<String, String> header = new LinkedMultiValueMap<String, String>();
header.add("Content-Type", "application/json");
HttpEntity<Object> httpEntity = new HttpEntity<Object>(track, header);
ResponseEntity<Track> response = restTemplate.exchange(uri, HttpMethod.POST, httpEntity, Track.class);
</code>```

答:
Finally it is working by made changes as follows :

Added below lines in servlet xml.

```<code><bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
        <list>
            <ref bean="jsonConverter" />
        </list>
    </property>
</bean>

<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
    <property name="supportedMediaTypes" value="application/json" />
</bean>
</code>```

Add added jackson-core-2.5.0 & jackson-annotations-2.5.0 jars in classpath.

ContentLicense: CC BY-SA 4.0

Body:
I try to use Spring Restful webservice.

I have created two projects in two eclipse. In one project I have written RestClient program and in another project I have written webservice and stared the webservice over tomcat. I am trying to pass java bean as json communication between client and server.

But I got below exception.

org.springframework.web.client.HttpClientErrorException: 415 Unsupported Media Type

I have tried in many ways but it was unsuccessful. Below is my code snippet.

Client Method :

private static void postTrack() {
    try {
        final String uri = "http://localhost:8181/RestWS/test";

        Track track = new Track();
        track.setTitle("Singer");
        track.setSinger("Shas");

        RestTemplate restTemplate = new RestTemplate();

        Track responseTrack = restTemplate.postForObject(uri, track, Track.class);

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

Service Method :

@RequestMapping(value = "/test", method = RequestMethod.POST, headers = "Accept=application/json")
    public @ResponseBody Track testMethod(@RequestBody Track track) {
        System.out.println(" Inside Test Method : ");
        System.out.println(" In GreetingController.greeting() "+track.getSinger());
        return track;
    }

Track Class :

public class Track {

    String title;
    String singer;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSinger() {
        return singer;
    }

    public void setSinger(String singer) {
        this.singer = singer;
    }

    @Override
    public String toString() {
        return "Track [title=" + title + ", singer=" + singer + "]";
    }
}

Also I tried with

restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
restTemplate.getMessageConverters().add(new StringHttpMessageConverter());

And

MultiValueMap<String, String> header = new LinkedMultiValueMap<String, String>();
header.add("Content-Type", "application/json");
HttpEntity<Object> httpEntity = new HttpEntity<Object>(track, header);
ResponseEntity<Track> response = restTemplate.exchange(uri, HttpMethod.POST, httpEntity, Track.class);

Body:
Finally it is working by made changes as follows :

Added below lines in servlet xml.

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
        <list>
            <ref bean="jsonConverter" />
        </list>
    </property>
</bean>

<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
    <property name="supportedMediaTypes" value="application/json" />
</bean>

Add added jackson-core-2.5.0 & jackson-annotations-2.5.0 jars in classpath.


来源: stackexchange

问:
Getting the lowest possible sum from numbers' difference
I have to find the lowest possible sum from numbers' difference.

Let's say I have 4 numbers. 1515, 1520, 1500 and 1535. The lowest sum of difference is 30, because 1535 - 1520 = 15 && 1515 - 1500 = 15 and 15 + 15 = 30. If I would do like this: 1520 - 1515 = 5 && 1535 - 1500 = 35 it would be 40 in sum.

Hope you got it, if not, ask me.

Any ideas how to program this? I just found this online, tried to translate from my language to English. It sounds interesting. I can't do bruteforce, because it would take ages to compile. I don't need code, just ideas how to program or little fragment of code.

Thanks.

Edit:
I didn't post everything... One more edition:

I have let's say 8 possible numbers. But I have to take only 6 of them to make the smallest sum. For instance, numbers 1731, 1572, 2041, 1561, 1682, 1572, 1609, 1731, the smallest sum will be 48, but here I have to take only 6 numbers from 8.

答:
I think @marcog's approach can be simplified further.

Take the basic approach that @jonas-kolker proved for finding the smallest differences.  Take the resulting list and sort it.  Take the R smallest entries from this list and use them as your differences.  Proving that this is the smallest sum is trivial.

@marcog's approach is effectively O(N^2) because R == N is a legit option.  This approach should be (2*(N log N))+N aka O(N log N).

This requires a small data structure to hold a difference and the values it was derived from.  But, that is constant per entry.  Thus, space is O(N).

ContentLicense: CC BY-SA 2.5


问:
Making a CSS Drop-down Menu Responsive
I have got a CSS Drop-down menu on a website that I want to make responsive using CSS media queries, but it doesn't respond at certain breakpoints. Am using width and max-width attributes to make it respond but it fails. Please Assist?

HTML

.navbar{
  width:100%;
  max-width:1000px;
  text-align:center;
  margin-top:-8px;
  margin-bottom:23px;
  margin-left:160px;
}
.menu ul{
/*Removes bullets*/
  list-style:none;
}
.menu ul .active{
  background: red; /* For browsers that do not support gradients */
  background: -webkit-linear-gradient(red 20%, green); /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(red 20%, green); /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(red 20%, green); /* For Firefox 3.6 to 15 */
  background: linear-gradient(red 20%, green); /* Standard syntax */
  background: linear-gradient(red 20%, green); /* Standard syntax */
}
/*Styles each list within ul*/
.menu ul li{
  background-color:green;
  border:1px solid #ffffff;
  width:100%;
  max-width:173px;
  height:35px;
  line-height:35px;
  margin:auto;
  text-align:center;
  /*Makes the list dispaly in a horizontal maneer*/
  float:left;
  position:relative;
  border-radius:8px;
  font: 15px;
  font-weight:regular;
}
.menu ul li a{
  text-decoration:none;
  color:white;
  display:block;
}
.menu ul li a:hover{
  background-color:red;
  border-radius:8px;
}
.menu ul ul{
  position:absolute;
  margin-left:-40px;
  display:none;
}
.menu ul li:hover >ul{
  display:block;
}
.menu ul ul ul{
  width:100%;
  margin-left:134px;
  top:0px;
}
@media only screen and (min-width: 1023px)  and (max-width: 1223px) {
  .navbar{
    width:98%;
    max-width:1000px;
  }
  .menu ul li{
    width:98%;
    max-width:173px;
    height:35px;
    line-height:35px;
    margin:auto;
  }
  .menu ul ul ul{
    width:98%;
    margin-left:134px;
    top:0px;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="navbar">
  <div class="menu">
    <ul>
      <li class="active">  Home </li>
      <li>  Arts & Social Sciences <span class="arrow">▼ </span>
        <ul>
          <li>  Sociology</li>
          <li>  Anthropology </li>
          <li>  Linguistics </li>
          <li>  Political Science <span class="arrow">  ⟩</span>
            <ul>
            <li> World Civilization </li>
            <li> Politics of Development </li>
            <li> Comparative Politics</li>
            <li> Globalization </li>
            </ul>
          </li>
        </ul>
      </li>
      <li>  Business & Economics <span class="arrow">▼ </span>
        <ul>
          <li>  Business Management</li>
          <li>  Purchasing and Supplies </li>
          <li>  Economics
            <ul>
              <li> Micro Economics </li>
              <li>  Inflation </li>
              <li> Stock Excahange </li>
              <li> Supply Chain </li>
              <li> Macro-Economics </li>
            </ul>
          </li>
        </ul>
      </li>
      <li>  Education<span class="arrow">▼ </span>
        <ul>
          <li>  Education(Arts)</li>
          <li>  Early Childhood </li>
          <li>  Education(Scienmce)</li>
          <li>  Education & Technology
            <ul>
              <li> Marketing </li>
              <li> Supply Chain </li>
            </ul>
          </li>
        </ul>
      </li>
      <li> Contact Us</li>
    </ul>
  </div>
</div></code>```

答:
(function($) {
  $.fn.menumaker = function(options) {
    var cssmenu = $(this),
      settings = $.extend({
        format: "dropdown",
        sticky: false
      }, options);
    return this.each(function() {
      $(this).find(".button").on('click', function() {
        $(this).toggleClass('menu-opened');
        var mainmenu = $(this).next('ul');
        if (mainmenu.hasClass('open')) {
          mainmenu.slideToggle().removeClass('open');
        } else {
          mainmenu.slideToggle().addClass('open');
          if (settings.format === "dropdown") {
            mainmenu.find('ul').show();
          }
        }
      });
      cssmenu.find('li ul').parent().addClass('has-sub');
      multiTg = function() {
        cssmenu.find(".has-sub").prepend('');
        cssmenu.find('.submenu-button').on('click', function() {
          $(this).toggleClass('submenu-opened');
          if ($(this).siblings('ul').hasClass('open')) {
            $(this).siblings('ul').removeClass('open').slideToggle();
          } else {
            $(this).siblings('ul').addClass('open').slideToggle();
          }
        });
      };
      if (settings.format === 'multitoggle') multiTg();
      else cssmenu.addClass('dropdown');
      if (settings.sticky === true) cssmenu.css('position', 'fixed');
      resizeFix = function() {
        var mediasize = 700;
        if ($(window).width() > mediasize) {
          cssmenu.find('ul').show();
        }
        if ($(window).width() <= mediasize) {
          cssmenu.find('ul').hide().removeClass('open');
        }
      };
      resizeFix();
      return $(window).on('resize', resizeFix);
    });
  };
})(jQuery);

(function($) {
  $(document).ready(function() {
    $("#cssmenu").menumaker({
      format: "multitoggle"
    });
  });
})(jQuery);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
  margin: 0;
  padding: 0;
  text-decoration: none
}

body {
  background: #555;
}

header {
  position: relative;
  width: 100%;
  background: #333;
}

.logo {
  position: relative;
  z-index: 123;
  padding: 10px;
  font: 18px verdana;
  color: #6DDB07;
  float: left;
  width: 15%
}

.logo a {
  color: #6DDB07;
}

nav {
  position: relative;
  width: 980px;
  margin: 0 auto;
}

#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a,
#cssmenu #head-mobile {
  border: 0;
  list-style: none;
  line-height: 1;
  display: block;
  position: relative;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box
}

#cssmenu:after,
#cssmenu>ul:after {
  content: ".";
  display: block;
  clear: both;
  visibility: hidden;
  line-height: 0;
  height: 0
}

#cssmenu #head-mobile {
  display: none
}

#cssmenu {
  font-family: sans-serif;
  background: #333
}

#cssmenu>ul>li {
  float: left
}

#cssmenu>ul>li>a {
  padding: 17px;
  font-size: 12px;
  letter-spacing: 1px;
  text-decoration: none;
  color: #ddd;
  font-weight: 700;
}

#cssmenu>ul>li:hover>a,
#cssmenu ul li.active a {
  color: #fff
}

#cssmenu>ul>li:hover,
#cssmenu ul li.active:hover,
#cssmenu ul li.active,
#cssmenu ul li.has-sub.active:hover {
  background: #448D00!important;
  -webkit-transition: background .3s ease;
  -ms-transition: background .3s ease;
  transition: background .3s ease;
}

#cssmenu>ul>li.has-sub>a {
  padding-right: 30px
}

#cssmenu>ul>li.has-sub>a:after {
  position: absolute;
  top: 22px;
  right: 11px;
  width: 8px;
  height: 2px;
  display: block;
  background: #ddd;
  content: ''
}

#cssmenu>ul>li.has-sub>a:before {
  position: absolute;
  top: 19px;
  right: 14px;
  display: block;
  width: 2px;
  height: 8px;
  background: #ddd;
  content: '';
  -webkit-transition: all .25s ease;
  -ms-transition: all .25s ease;
  transition: all .25s ease
}

#cssmenu>ul>li.has-sub:hover>a:before {
  top: 23px;
  height: 0
}

#cssmenu ul ul {
  position: absolute;
  left: -9999px
}

#cssmenu ul ul li {
  height: 0;
  -webkit-transition: all .25s ease;
  -ms-transition: all .25s ease;
  background: #333;
  transition: all .25s ease
}

#cssmenu ul ul li:hover {}

#cssmenu li:hover>ul {
  left: auto
}

#cssmenu li:hover>ul>li {
  height: 35px
}

#cssmenu ul ul ul {
  margin-left: 100%;
  top: 0
}

#cssmenu ul ul li a {
  border-bottom: 1px solid rgba(150, 150, 150, 0.15);
  padding: 11px 15px;
  width: 170px;
  font-size: 12px;
  text-decoration: none;
  color: #ddd;
  font-weight: 400;
}

#cssmenu ul ul li:last-child>a,
#cssmenu ul ul li.last-item>a {
  border-bottom: 0
}

#cssmenu ul ul li:hover>a,
#cssmenu ul ul li a:hover {
  color: #fff
}

#cssmenu ul ul li.has-sub>a:after {
  position: absolute;
  top: 16px;
  right: 11px;
  width: 8px;
  height: 2px;
  display: block;
  background: #ddd;
  content: ''
}

#cssmenu ul ul li.has-sub>a:before {
  position: absolute;
  top: 13px;
  right: 14px;
  display: block;
  width: 2px;
  height: 8px;
  background: #ddd;
  content: '';
  -webkit-transition: all .25s ease;
  -ms-transition: all .25s ease;
  transition: all .25s ease
}

#cssmenu ul ul>li.has-sub:hover>a:before {
  top: 17px;
  height: 0
}

#cssmenu ul ul li.has-sub:hover,
#cssmenu ul li.has-sub ul li.has-sub ul li:hover {
  background: #363636;
}

#cssmenu ul ul ul li.active a {
  border-left: 1px solid #333
}

#cssmenu>ul>li.has-sub>ul>li.active>a,
#cssmenu>ul ul>li.has-sub>ul>li.active>a {
  border-top: 1px solid #333
}

@media screen and (max-width:700px) {
  .logo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 46px;
    text-align: center;
    padding: 10px 0 0 0;
    float: none
  }
  .logo2 {
    display: none
  }
  nav {
    width: 100%;
  }
  #cssmenu {
    width: 100%
  }
  #cssmenu ul {
    width: 100%;
    display: none
  }
  #cssmenu ul li {
    width: 100%;
    border-top: 1px solid #444
  }
  #cssmenu ul li:hover {
    background: #363636;
  }
  #cssmenu ul ul li,
  #cssmenu li:hover>ul>li {
    height: auto
  }
  #cssmenu ul li a,
  #cssmenu ul ul li a {
    width: 100%;
    border-bottom: 0
  }
  #cssmenu>ul>li {
    float: none
  }
  #cssmenu ul ul li a {
    padding-left: 25px
  }
  #cssmenu ul ul li {
    background: #333!important;
  }
  #cssmenu ul ul li:hover {
    background: #363636!important
  }
  #cssmenu ul ul ul li a {
    padding-left: 35px
  }
  #cssmenu ul ul li a {
    color: #ddd;
    background: none
  }
  #cssmenu ul ul li:hover>a,
  #cssmenu ul ul li.active>a {
    color: #fff
  }
  #cssmenu ul ul,
  #cssmenu ul ul ul {
    position: relative;
    left: 0;
    width: 100%;
    margin: 0;
    text-align: left
  }
  #cssmenu>ul>li.has-sub>a:after,
  #cssmenu>ul>li.has-sub>a:before,
  #cssmenu ul ul>li.has-sub>a:after,
  #cssmenu ul ul>li.has-sub>a:before {
    display: none
  }
  #cssmenu #head-mobile {
    display: block;
    padding: 23px;
    color: #ddd;
    font-size: 12px;
    font-weight: 700
  }
  .button {
    width: 55px;
    height: 46px;
    position: absolute;
    right: 0;
    top: 0;
    cursor: pointer;
    z-index: 12399994;
  }
  .button:after {
    position: absolute;
    top: 22px;
    right: 20px;
    display: block;
    height: 4px;
    width: 20px;
    border-top: 2px solid #dddddd;
    border-bottom: 2px solid #dddddd;
    content: ''
  }
  .button:before {
    -webkit-transition: all .3s ease;
    -ms-transition: all .3s ease;
    transition: all .3s ease;
    position: absolute;
    top: 16px;
    right: 20px;
    display: block;
    height: 2px;
    width: 20px;
    background: #ddd;
    content: ''
  }
  .button.menu-opened:after {
    -webkit-transition: all .3s ease;
    -ms-transition: all .3s ease;
    transition: all .3s ease;
    top: 23px;
    border: 0;
    height: 2px;
    width: 19px;
    background: #fff;
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    transform: rotate(45deg)
  }
  .button.menu-opened:before {
    top: 23px;
    background: #fff;
    width: 19px;
    -webkit-transform: rotate(-45deg);
    -moz-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    -o-transform: rotate(-45deg);
    transform: rotate(-45deg)
  }
  #cssmenu .submenu-button {
    position: absolute;
    z-index: 99;
    right: 0;
    top: 0;
    display: block;
    border-left: 1px solid #444;
    height: 46px;
    width: 46px;
    cursor: pointer
  }
  #cssmenu .submenu-button.submenu-opened {
    background: #262626
  }
  #cssmenu ul ul .submenu-button {
    height: 34px;
    width: 34px
  }
  #cssmenu .submenu-button:after {
    position: absolute;
    top: 22px;
    right: 19px;
    width: 8px;
    height: 2px;
    display: block;
    background: #ddd;
    content: ''
  }
  #cssmenu ul ul .submenu-button:after {
    top: 15px;
    right: 13px
  }
  #cssmenu .submenu-button.submenu-opened:after {
    background: #fff
  }
  #cssmenu .submenu-button:before {
    position: absolute;
    top: 19px;
    right: 22px;
    display: block;
    width: 2px;
    height: 8px;
    background: #ddd;
    content: ''
  }
  #cssmenu ul ul .submenu-button:before {
    top: 12px;
    right: 16px
  }
  #cssmenu .submenu-button.submenu-opened:before {
    display: none
  }
  #cssmenu ul ul ul li.active a {
    border-left: none
  }
  #cssmenu>ul>li.has-sub>ul>li.active>a,
  #cssmenu>ul ul>li.has-sub>ul>li.active>a {
    border-top: none
  }
}</code>```

Responsive

HOME

Arts And Social Science

sociology

Anthropology

Linguistics

Linguistics

Political Science

World Civilization

Politics of Development

Comparative Politics

Globalization

Business & Economics

  Business Management

  Purchasing and Supplies

  Economics

 Micro Economics

  Inflation

 Stock Excahange

 Supply Chain

 Macro-Economics

Education

  Education(Arts)

  Early Childhood

  Education(Scienmce)

  Education & Technology

 Marketing

 Supply Chain

Contact Us

  CSS Menu

```

ContentLicense: CC BY-SA 3.0

Title: Making a CSS Drop-down Menu Responsive

Body:
I have got a CSS Drop-down menu on a website that I want to make responsive using CSS media queries, but it doesn't respond at certain breakpoints. Am using width and max-width attributes to make it respond but it fails. Please Assist?

HTML

.navbar{
  width:100%;
  max-width:1000px;
  text-align:center;
  margin-top:-8px;
  margin-bottom:23px;
  margin-left:160px;
}
.menu ul{
/*Removes bullets*/
  list-style:none;
}
.menu ul .active{
  background: red; /* For browsers that do not support gradients */
  background: -webkit-linear-gradient(red 20%, green); /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(red 20%, green); /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(red 20%, green); /* For Firefox 3.6 to 15 */
  background: linear-gradient(red 20%, green); /* Standard syntax */
  background: linear-gradient(red 20%, green); /* Standard syntax */
}
/*Styles each list within ul*/
.menu ul li{
  background-color:green;
  border:1px solid #ffffff;
  width:100%;
  max-width:173px;
  height:35px;
  line-height:35px;
  margin:auto;
  text-align:center;
  /*Makes the list dispaly in a horizontal maneer*/
  float:left;
  position:relative;
  border-radius:8px;
  font: 15px;
  font-weight:regular;
}
.menu ul li a{
  text-decoration:none;
  color:white;
  display:block;
}
.menu ul li a:hover{
  background-color:red;
  border-radius:8px;
}
.menu ul ul{
  position:absolute;
  margin-left:-40px;
  display:none;
}
.menu ul li:hover >ul{
  display:block;
}
.menu ul ul ul{
  width:100%;
  margin-left:134px;
  top:0px;
}
@media only screen and (min-width: 1023px)  and (max-width: 1223px) {
  .navbar{
    width:98%;
    max-width:1000px;
  }
  .menu ul li{
    width:98%;
    max-width:173px;
    height:35px;
    line-height:35px;
    margin:auto;
  }
  .menu ul ul ul{
    width:98%;
    margin-left:134px;
    top:0px;
  }
}

  Home

  Arts & Social Sciences ▼

  Sociology

  Anthropology

  Linguistics

  Political Science   ⟩

 World Civilization

 Politics of Development

 Comparative Politics

 Globalization

  Business & Economics ▼

  Business Management

  Purchasing and Supplies

  Economics

 Micro Economics

  Inflation

 Stock Excahange

 Supply Chain

 Macro-Economics

  Education▼

  Education(Arts)

  Early Childhood

  Education(Scienmce)

  Education & Technology

 Marketing

 Supply Chain

 Contact Us

Body:
(function($) {
  $.fn.menumaker = function(options) {
    var cssmenu = $(this),
      settings = $.extend({
        format: "dropdown",
        sticky: false
      }, options);
    return this.each(function() {
      $(this).find(".button").on('click', function() {
        $(this).toggleClass('menu-opened');
        var mainmenu = $(this).next('ul');
        if (mainmenu.hasClass('open')) {
          mainmenu.slideToggle().removeClass('open');
        } else {
          mainmenu.slideToggle().addClass('open');
          if (settings.format === "dropdown") {
            mainmenu.find('ul').show();
          }
        }
      });
      cssmenu.find('li ul').parent().addClass('has-sub');
      multiTg = function() {
        cssmenu.find(".has-sub").prepend('<span class="submenu-button"></span>');
        cssmenu.find('.submenu-button').on('click', function() {
          $(this).toggleClass('submenu-opened');
          if ($(this).siblings('ul').hasClass('open')) {
            $(this).siblings('ul').removeClass('open').slideToggle();
          } else {
            $(this).siblings('ul').addClass('open').slideToggle();
          }
        });
      };
      if (settings.format === 'multitoggle') multiTg();
      else cssmenu.addClass('dropdown');
      if (settings.sticky === true) cssmenu.css('position', 'fixed');
      resizeFix = function() {
        var mediasize = 700;
        if ($(window).width() > mediasize) {
          cssmenu.find('ul').show();
        }
        if ($(window).width() <= mediasize) {
          cssmenu.find('ul').hide().removeClass('open');
        }
      };
      resizeFix();
      return $(window).on('resize', resizeFix);
    });
  };
})(jQuery);

(function($) {
  $(document).ready(function() {
    $("#cssmenu").menumaker({
      format: "multitoggle"
    });
  });
})(jQuery);

* {
  margin: 0;
  padding: 0;
  text-decoration: none
}

body {
  background: #555;
}

header {
  position: relative;
  width: 100%;
  background: #333;
}

.logo {
  position: relative;
  z-index: 123;
  padding: 10px;
  font: 18px verdana;
  color: #6DDB07;
  float: left;
  width: 15%
}

.logo a {
  color: #6DDB07;
}

nav {
  position: relative;
  width: 980px;
  margin: 0 auto;
}

#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a,
#cssmenu #head-mobile {
  border: 0;
  list-style: none;
  line-height: 1;
  display: block;
  position: relative;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box
}

#cssmenu:after,
#cssmenu>ul:after {
  content: ".";
  display: block;
  clear: both;
  visibility: hidden;
  line-height: 0;
  height: 0
}

#cssmenu #head-mobile {
  display: none
}

#cssmenu {
  font-family: sans-serif;
  background: #333
}

#cssmenu>ul>li {
  float: left
}

#cssmenu>ul>li>a {
  padding: 17px;
  font-size: 12px;
  letter-spacing: 1px;
  text-decoration: none;
  color: #ddd;
  font-weight: 700;
}

#cssmenu>ul>li:hover>a,
#cssmenu ul li.active a {
  color: #fff
}

#cssmenu>ul>li:hover,
#cssmenu ul li.active:hover,
#cssmenu ul li.active,
#cssmenu ul li.has-sub.active:hover {
  background: #448D00!important;
  -webkit-transition: background .3s ease;
  -ms-transition: background .3s ease;
  transition: background .3s ease;
}

#cssmenu>ul>li.has-sub>a {
  padding-right: 30px
}

#cssmenu>ul>li.has-sub>a:after {
  position: absolute;
  top: 22px;
  right: 11px;
  width: 8px;
  height: 2px;
  display: block;
  background: #ddd;
  content: ''
}

#cssmenu>ul>li.has-sub>a:before {
  position: absolute;
  top: 19px;
  right: 14px;
  display: block;
  width: 2px;
  height: 8px;
  background: #ddd;
  content: '';
  -webkit-transition: all .25s ease;
  -ms-transition: all .25s ease;
  transition: all .25s ease
}

#cssmenu>ul>li.has-sub:hover>a:before {
  top: 23px;
  height: 0
}

#cssmenu ul ul {
  position: absolute;
  left: -9999px
}

#cssmenu ul ul li {
  height: 0;
  -webkit-transition: all .25s ease;
  -ms-transition: all .25s ease;
  background: #333;
  transition: all .25s ease
}

#cssmenu ul ul li:hover {}

#cssmenu li:hover>ul {
  left: auto
}

#cssmenu li:hover>ul>li {
  height: 35px
}

#cssmenu ul ul ul {
  margin-left: 100%;
  top: 0
}

#cssmenu ul ul li a {
  border-bottom: 1px solid rgba(150, 150, 150, 0.15);
  padding: 11px 15px;
  width: 170px;
  font-size: 12px;
  text-decoration: none;
  color: #ddd;
  font-weight: 400;
}

#cssmenu ul ul li:last-child>a,
#cssmenu ul ul li.last-item>a {
  border-bottom: 0
}

#cssmenu ul ul li:hover>a,
#cssmenu ul ul li a:hover {
  color: #fff
}

#cssmenu ul ul li.has-sub>a:after {
  position: absolute;
  top: 16px;
  right: 11px;
  width: 8px;
  height: 2px;
  display: block;
  background: #ddd;
  content: ''
}

#cssmenu ul ul li.has-sub>a:before {
  position: absolute;
  top: 13px;
  right: 14px;
  display: block;
  width: 2px;
  height: 8px;
  background: #ddd;
  content: '';
  -webkit-transition: all .25s ease;
  -ms-transition: all .25s ease;
  transition: all .25s ease
}

#cssmenu ul ul>li.has-sub:hover>a:before {
  top: 17px;
  height: 0
}

#cssmenu ul ul li.has-sub:hover,
#cssmenu ul li.has-sub ul li.has-sub ul li:hover {
  background: #363636;
}

#cssmenu ul ul ul li.active a {
  border-left: 1px solid #333
}

#cssmenu>ul>li.has-sub>ul>li.active>a,
#cssmenu>ul ul>li.has-sub>ul>li.active>a {
  border-top: 1px solid #333
}

@media screen and (max-width:700px) {
  .logo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 46px;
    text-align: center;
    padding: 10px 0 0 0;
    float: none
  }
  .logo2 {
    display: none
  }
  nav {
    width: 100%;
  }
  #cssmenu {
    width: 100%
  }
  #cssmenu ul {
    width: 100%;
    display: none
  }
  #cssmenu ul li {
    width: 100%;
    border-top: 1px solid #444
  }
  #cssmenu ul li:hover {
    background: #363636;
  }
  #cssmenu ul ul li,
  #cssmenu li:hover>ul>li {
    height: auto
  }
  #cssmenu ul li a,
  #cssmenu ul ul li a {
    width: 100%;
    border-bottom: 0
  }
  #cssmenu>ul>li {
    float: none
  }
  #cssmenu ul ul li a {
    padding-left: 25px
  }
  #cssmenu ul ul li {
    background: #333!important;
  }
  #cssmenu ul ul li:hover {
    background: #363636!important
  }
  #cssmenu ul ul ul li a {
    padding-left: 35px
  }
  #cssmenu ul ul li a {
    color: #ddd;
    background: none
  }
  #cssmenu ul ul li:hover>a,
  #cssmenu ul ul li.active>a {
    color: #fff
  }
  #cssmenu ul ul,
  #cssmenu ul ul ul {
    position: relative;
    left: 0;
    width: 100%;
    margin: 0;
    text-align: left
  }
  #cssmenu>ul>li.has-sub>a:after,
  #cssmenu>ul>li.has-sub>a:before,
  #cssmenu ul ul>li.has-sub>a:after,
  #cssmenu ul ul>li.has-sub>a:before {
    display: none
  }
  #cssmenu #head-mobile {
    display: block;
    padding: 23px;
    color: #ddd;
    font-size: 12px;
    font-weight: 700
  }
  .button {
    width: 55px;
    height: 46px;
    position: absolute;
    right: 0;
    top: 0;
    cursor: pointer;
    z-index: 12399994;
  }
  .button:after {
    position: absolute;
    top: 22px;
    right: 20px;
    display: block;
    height: 4px;
    width: 20px;
    border-top: 2px solid #dddddd;
    border-bottom: 2px solid #dddddd;
    content: ''
  }
  .button:before {
    -webkit-transition: all .3s ease;
    -ms-transition: all .3s ease;
    transition: all .3s ease;
    position: absolute;
    top: 16px;
    right: 20px;
    display: block;
    height: 2px;
    width: 20px;
    background: #ddd;
    content: ''
  }
  .button.menu-opened:after {
    -webkit-transition: all .3s ease;
    -ms-transition: all .3s ease;
    transition: all .3s ease;
    top: 23px;
    border: 0;
    height: 2px;
    width: 19px;
    background: #fff;
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    transform: rotate(45deg)
  }
  .button.menu-opened:before {
    top: 23px;
    background: #fff;
    width: 19px;
    -webkit-transform: rotate(-45deg);
    -moz-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    -o-transform: rotate(-45deg);
    transform: rotate(-45deg)
  }
  #cssmenu .submenu-button {
    position: absolute;
    z-index: 99;
    right: 0;
    top: 0;
    display: block;
    border-left: 1px solid #444;
    height: 46px;
    width: 46px;
    cursor: pointer
  }
  #cssmenu .submenu-button.submenu-opened {
    background: #262626
  }
  #cssmenu ul ul .submenu-button {
    height: 34px;
    width: 34px
  }
  #cssmenu .submenu-button:after {
    position: absolute;
    top: 22px;
    right: 19px;
    width: 8px;
    height: 2px;
    display: block;
    background: #ddd;
    content: ''
  }
  #cssmenu ul ul .submenu-button:after {
    top: 15px;
    right: 13px
  }
  #cssmenu .submenu-button.submenu-opened:after {
    background: #fff
  }
  #cssmenu .submenu-button:before {
    position: absolute;
    top: 19px;
    right: 22px;
    display: block;
    width: 2px;
    height: 8px;
    background: #ddd;
    content: ''
  }
  #cssmenu ul ul .submenu-button:before {
    top: 12px;
    right: 16px
  }
  #cssmenu .submenu-button.submenu-opened:before {
    display: none
  }
  #cssmenu ul ul ul li.active a {
    border-left: none
  }
  #cssmenu>ul>li.has-sub>ul>li.active>a,
  #cssmenu>ul ul>li.has-sub>ul>li.active>a {
    border-top: none
  }
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header>
  <nav id='cssmenu'>
    <div class="logo"><a href="index.html">Responsive </a></div>
    <div id="head-mobile"></div>
    <div class="button"></div>
    <ul>
      <li class='active'><a href='#'>HOME</a></li>
      <li><a href='#'>Arts And Social Science</a>
        <ul>
          <li><a href="">sociology</a></li>
          <li><a href="">Anthropology</a></li>
          <li><a href="">Linguistics</a></li>
          <li><a href="">Linguistics</a></li>
          <li><a href="">Political Science</a>
            <ul>
              <li><a href="">World Civilization </a></li>
              <li><a href="">Politics of Development</a></li>
              <li><a href="">Comparative Politics</a></li>
              <li><a href="">Globalization</a></li>
            </ul>
          </li>
        </ul>
      </li>
      <li><a href='#'>Business & Economics</a>
        <ul>
          <li> <a href="#"> Business Management</a></li>
          <li> <a href="#"> Purchasing and Supplies </a></li>
          <li> <a href="#"> Economics </a>
            <ul>
              <li><a href="#"> Micro Economics </a></li>
              <li><a href="#">  Inflation </a></li>
              <li><a href="#"> Stock Excahange </a></li>
              <li><a href="#"> Supply Chain </a></li>
              <li><a href="#"> Macro-Economics </a></li>
            </ul>
          </li>
        </ul>
      </li>
      <li><a href='#'>Education</a>
        <ul>
          <li> <a href="#"> Education(Arts)</a></li>
          <li> <a href="#"> Early Childhood </a></li>
          <li> <a href="#"> Education(Scienmce)</a></li>
          <li> <a href="#"> Education & Technology</a>
            <ul>
              <li><a href=""> Marketing </a></li>
              <li><a href=""> Supply Chain </a></li>
            </ul>
          </li>
        </ul>
      </li>
      <li><a href='#'>Contact Us</a>

      </li>

    </ul>
  </nav>
</header>
<section style='padding-top:20px;font:bold  44px arial;color:#68D800;'>
  CSS Menu
</section>


问:
iruby kernel can't install rbczmq
Just installed the iRuby kernel following the istructions but when i do jupyter-notebook command and start a new notebook kernel dies and there is a problem reported on the terminal about libczmq:

```<code>[I 18:05:11.900 NotebookApp] Kernel started: bcb56cdd-964a-4dae-8a40-76dbcbe7e418

WARNING: ::CZMQ::FFI is not available without libczmq.

Unable to load this gem. The libzmq library (or DLL) could not be found.
If this is a Windows platform, make sure libzmq.dll is on the PATH.
If the DLL was built with mingw, make sure the other two dependent DLLs,
libgcc_s_sjlj-1.dll and libstdc++6.dll, are also on the PATH.
For non-Windows platforms, make sure libzmq is located in this search path:
["/var/lib/gems/2.3.0/gems/ffi-rzmq-core-1.0.6/lib/ffi-rzmq-core/../../ext/libzmq.so", "/home/randomx/anaconda3/bin/libzmq.so", "/home/randomx/bin/libzmq.so", "/home/randomx/.local/bin/libzmq.so", "/usr/local/sbin/libzmq.so", "/usr/local/bin/libzmq.so", "/usr/sbin/libzmq.so", "/usr/bin/libzmq.so", "/sbin/libzmq.so", "/bin/libzmq.so", "/usr/games/libzmq.so", "/usr/local/games/libzmq.so", "/snap/bin/libzmq.so", "/usr/lib/libzmq.so", "/usr/local/lib/libzmq.so", "/opt/local/lib/libzmq.so", "/usr/lib64/libzmq.so"]
You should install cztop, rbczmq or ffi_rzmq before running iruby notebook. See README.
F, [2017-03-26T18:05:12.031981 #13088] FATAL -- : Kernel died: uninitialized constant IRuby::Kernel::Session
/var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/kernel.rb:18:in `initialize'
/var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:70:in `new'
/var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:70:in `run_kernel'
/var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:34:in `run'
/var/lib/gems/2.3.0/gems/iruby-0.3/bin/iruby:5:in `<top (required)>'
/usr/local/bin/iruby:23:in `load'
/usr/local/bin/iruby:23:in `<main>'
/var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/kernel.rb:18:in `initialize': uninitialized constant IRuby::Kernel::Session (NameError)
        from /var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:70:in `new'
        from /var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:70:in `run_kernel'
        from /var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:34:in `run'
        from /var/lib/gems/2.3.0/gems/iruby-0.3/bin/iruby:5:in `<top (required)>'
        from /usr/local/bin/iruby:23:in `load'
        from /usr/local/bin/iruby:23:in `<main>'
[I 18:05:14.903 NotebookApp] KernelRestarter: restarting kernel (1/5)

WARNING: ::CZMQ::FFI is not available without libczmq.
</code>```

So I installed cztop and ffi_rzmq but when i go to install rbczmq I got an error install message like this:

```<code>    config.status: creating src/Makefile
config.status: creating doc/Makefile
config.status: creating src/libczmq.pc
config.status: creating addons/Makefile
config.status: creating src/platform.h
config.status: executing depfiles commands
config.status: executing libtool commands
"make all && make install"
Making all in src
make[1]: ingresso nella directory "/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/czmq/src"
make  all-am
make[2]: ingresso nella directory "/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/czmq/src"
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zauth.lo -MD -MP -MF .deps/zauth.Tpo -c -o zauth.lo zauth.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zauth.lo -MD -MP -MF .deps/zauth.Tpo -c zauth.c -o zauth.o
mv -f .deps/zauth.Tpo .deps/zauth.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zbeacon.lo -MD -MP -MF .deps/zbeacon.Tpo -c -o zbeacon.lo zbeacon.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zbeacon.lo -MD -MP -MF .deps/zbeacon.Tpo -c zbeacon.c -o zbeacon.o
mv -f .deps/zbeacon.Tpo .deps/zbeacon.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zcert.lo -MD -MP -MF .deps/zcert.Tpo -c -o zcert.lo zcert.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zcert.lo -MD -MP -MF .deps/zcert.Tpo -c zcert.c -o zcert.o
mv -f .deps/zcert.Tpo .deps/zcert.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zcertstore.lo -MD -MP -MF .deps/zcertstore.Tpo -c -o zcertstore.lo zcertstore.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zcertstore.lo -MD -MP -MF .deps/zcertstore.Tpo -c zcertstore.c -o zcertstore.o
mv -f .deps/zcertstore.Tpo .deps/zcertstore.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zchunk.lo -MD -MP -MF .deps/zchunk.Tpo -c -o zchunk.lo zchunk.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zchunk.lo -MD -MP -MF .deps/zchunk.Tpo -c zchunk.c -o zchunk.o
mv -f .deps/zchunk.Tpo .deps/zchunk.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zclock.lo -MD -MP -MF .deps/zclock.Tpo -c -o zclock.lo zclock.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zclock.lo -MD -MP -MF .deps/zclock.Tpo -c zclock.c -o zclock.o
mv -f .deps/zclock.Tpo .deps/zclock.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zconfig.lo -MD -MP -MF .deps/zconfig.Tpo -c -o zconfig.lo zconfig.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zconfig.lo -MD -MP -MF .deps/zconfig.Tpo -c zconfig.c -o zconfig.o
mv -f .deps/zconfig.Tpo .deps/zconfig.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zctx.lo -MD -MP -MF .deps/zctx.Tpo -c -o zctx.lo zctx.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zctx.lo -MD -MP -MF .deps/zctx.Tpo -c zctx.c -o zctx.o
mv -f .deps/zctx.Tpo .deps/zctx.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zdir.lo -MD -MP -MF .deps/zdir.Tpo -c -o zdir.lo zdir.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zdir.lo -MD -MP -MF .deps/zdir.Tpo -c zdir.c -o zdir.o
zdir.c: In function ‘zdir_new’:
zdir.c:156:9: error: ‘readdir_r’ is deprecated [-Werror=deprecated-declarations]
         int rc = readdir_r (handle, entry, &result);
         ^~~
In file included from ../include/czmq_prelude.h:257:0,
                 from ../include/czmq.h:31,
                 from zdir.c:35:
/usr/include/dirent.h:183:12: note: declared here
 extern int readdir_r (DIR *__restrict __dirp,
            ^~~~~~~~~
zdir.c:159:13: error: ‘readdir_r’ is deprecated [-Werror=deprecated-declarations]
             rc = readdir_r (handle, entry, &result);
             ^~
In file included from ../include/czmq_prelude.h:257:0,
                 from ../include/czmq.h:31,
                 from zdir.c:35:
/usr/include/dirent.h:183:12: note: declared here
 extern int readdir_r (DIR *__restrict __dirp,
            ^~~~~~~~~
cc1: all warnings being treated as errors
Makefile:774: set di istruzioni per l'obiettivo "zdir.lo" non riuscito
make[2]: *** [zdir.lo] Errore 1
make[2]: uscita dalla directory "/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/czmq/src"
Makefile:586: set di istruzioni per l'obiettivo "all" non riuscito
make[1]: *** [all] Errore 2
make[1]: uscita dalla directory "/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/czmq/src"
Makefile:414: set di istruzioni per l'obiettivo "all-recursive" non riuscito
make: *** [all-recursive] Errore 1
CZMQ compile error!
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
        --with-system-libs
        --without-system-libs
        --with-system-libs
        --without-system-libs

extconf failed, exit code 1
</code>```

I also have installed libtool autogen autoconf automake but installation fails anyway..I got the last version of Kubuntu as os
What can I do? Thank you for help

答:
Solved! I had to install the zeromq source from here
http://zeromq.org/intro:get-the-software</p>

Title: iruby kernel can't install rbczmq

Body:
Just installed the iRuby kernel following the istructions but when i do jupyter-notebook command and start a new notebook kernel dies and there is a problem reported on the terminal about libczmq:

[I 18:05:11.900 NotebookApp] Kernel started: bcb56cdd-964a-4dae-8a40-76dbcbe7e418

WARNING: ::CZMQ::FFI is not available without libczmq.

Unable to load this gem. The libzmq library (or DLL) could not be found.
If this is a Windows platform, make sure libzmq.dll is on the PATH.
If the DLL was built with mingw, make sure the other two dependent DLLs,
libgcc_s_sjlj-1.dll and libstdc++6.dll, are also on the PATH.
For non-Windows platforms, make sure libzmq is located in this search path:
["/var/lib/gems/2.3.0/gems/ffi-rzmq-core-1.0.6/lib/ffi-rzmq-core/../../ext/libzmq.so", "/home/randomx/anaconda3/bin/libzmq.so", "/home/randomx/bin/libzmq.so", "/home/randomx/.local/bin/libzmq.so", "/usr/local/sbin/libzmq.so", "/usr/local/bin/libzmq.so", "/usr/sbin/libzmq.so", "/usr/bin/libzmq.so", "/sbin/libzmq.so", "/bin/libzmq.so", "/usr/games/libzmq.so", "/usr/local/games/libzmq.so", "/snap/bin/libzmq.so", "/usr/lib/libzmq.so", "/usr/local/lib/libzmq.so", "/opt/local/lib/libzmq.so", "/usr/lib64/libzmq.so"]
You should install cztop, rbczmq or ffi_rzmq before running iruby notebook. See README.
F, [2017-03-26T18:05:12.031981 #13088] FATAL -- : Kernel died: uninitialized constant IRuby::Kernel::Session
/var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/kernel.rb:18:in `initialize'
/var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:70:in `new'
/var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:70:in `run_kernel'
/var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:34:in `run'
/var/lib/gems/2.3.0/gems/iruby-0.3/bin/iruby:5:in `<top (required)>'
/usr/local/bin/iruby:23:in `load'
/usr/local/bin/iruby:23:in `'
/var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/kernel.rb:18:in `initialize': uninitialized constant IRuby::Kernel::Session (NameError)
        from /var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:70:in `new'
        from /var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:70:in `run_kernel'
        from /var/lib/gems/2.3.0/gems/iruby-0.3/lib/iruby/command.rb:34:in `run'
        from /var/lib/gems/2.3.0/gems/iruby-0.3/bin/iruby:5:in `<top (required)>'
        from /usr/local/bin/iruby:23:in `load'
        from /usr/local/bin/iruby:23:in `'
[I 18:05:14.903 NotebookApp] KernelRestarter: restarting kernel (1/5)

WARNING: ::CZMQ::FFI is not available without libczmq.

So I installed cztop and ffi_rzmq but when i go to install rbczmq I got an error install message like this:

    config.status: creating src/Makefile
config.status: creating doc/Makefile
config.status: creating src/libczmq.pc
config.status: creating addons/Makefile
config.status: creating src/platform.h
config.status: executing depfiles commands
config.status: executing libtool commands
"make all && make install"
Making all in src
make[1]: ingresso nella directory "/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/czmq/src"
make  all-am
make[2]: ingresso nella directory "/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/czmq/src"
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zauth.lo -MD -MP -MF .deps/zauth.Tpo -c -o zauth.lo zauth.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zauth.lo -MD -MP -MF .deps/zauth.Tpo -c zauth.c -o zauth.o
mv -f .deps/zauth.Tpo .deps/zauth.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zbeacon.lo -MD -MP -MF .deps/zbeacon.Tpo -c -o zbeacon.lo zbeacon.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zbeacon.lo -MD -MP -MF .deps/zbeacon.Tpo -c zbeacon.c -o zbeacon.o
mv -f .deps/zbeacon.Tpo .deps/zbeacon.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zcert.lo -MD -MP -MF .deps/zcert.Tpo -c -o zcert.lo zcert.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zcert.lo -MD -MP -MF .deps/zcert.Tpo -c zcert.c -o zcert.o
mv -f .deps/zcert.Tpo .deps/zcert.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zcertstore.lo -MD -MP -MF .deps/zcertstore.Tpo -c -o zcertstore.lo zcertstore.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zcertstore.lo -MD -MP -MF .deps/zcertstore.Tpo -c zcertstore.c -o zcertstore.o
mv -f .deps/zcertstore.Tpo .deps/zcertstore.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zchunk.lo -MD -MP -MF .deps/zchunk.Tpo -c -o zchunk.lo zchunk.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zchunk.lo -MD -MP -MF .deps/zchunk.Tpo -c zchunk.c -o zchunk.o
mv -f .deps/zchunk.Tpo .deps/zchunk.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zclock.lo -MD -MP -MF .deps/zclock.Tpo -c -o zclock.lo zclock.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zclock.lo -MD -MP -MF .deps/zclock.Tpo -c zclock.c -o zclock.o
mv -f .deps/zclock.Tpo .deps/zclock.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zconfig.lo -MD -MP -MF .deps/zconfig.Tpo -c -o zconfig.lo zconfig.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zconfig.lo -MD -MP -MF .deps/zconfig.Tpo -c zconfig.c -o zconfig.o
mv -f .deps/zconfig.Tpo .deps/zconfig.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zctx.lo -MD -MP -MF .deps/zctx.Tpo -c -o zctx.lo zctx.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zctx.lo -MD -MP -MF .deps/zctx.Tpo -c zctx.c -o zctx.o
mv -f .deps/zctx.Tpo .deps/zctx.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE  -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zdir.lo -MD -MP -MF .deps/zdir.Tpo -c -o zdir.lo zdir.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zdir.lo -MD -MP -MF .deps/zdir.Tpo -c zdir.c -o zdir.o
zdir.c: In function ‘zdir_new’:
zdir.c:156:9: error: ‘readdir_r’ is deprecated [-Werror=deprecated-declarations]
         int rc = readdir_r (handle, entry, &result);
         ^~~
In file included from ../include/czmq_prelude.h:257:0,
                 from ../include/czmq.h:31,
                 from zdir.c:35:
/usr/include/dirent.h:183:12: note: declared here
 extern int readdir_r (DIR *__restrict __dirp,
            ^~~~~~~~~
zdir.c:159:13: error: ‘readdir_r’ is deprecated [-Werror=deprecated-declarations]
             rc = readdir_r (handle, entry, &result);
             ^~
In file included from ../include/czmq_prelude.h:257:0,
                 from ../include/czmq.h:31,
                 from zdir.c:35:
/usr/include/dirent.h:183:12: note: declared here
 extern int readdir_r (DIR *__restrict __dirp,
            ^~~~~~~~~
cc1: all warnings being treated as errors
Makefile:774: set di istruzioni per l'obiettivo "zdir.lo" non riuscito
make[2]: *** [zdir.lo] Errore 1
make[2]: uscita dalla directory "/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/czmq/src"
Makefile:586: set di istruzioni per l'obiettivo "all" non riuscito
make[1]: *** [all] Errore 2
make[1]: uscita dalla directory "/var/lib/gems/2.3.0/gems/rbczmq-1.7.9/ext/czmq/src"
Makefile:414: set di istruzioni per l'obiettivo "all-recursive" non riuscito
make: *** [all-recursive] Errore 1
CZMQ compile error!
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
        --with-system-libs
        --without-system-libs
        --with-system-libs
        --without-system-libs

extconf failed, exit code 1

I also have installed libtool autogen autoconf automake but installation fails anyway..I got the last version of Kubuntu as os
What can I do? Thank you for help


问:
angularjs filter only required text message
I have following code which prints 1.57 lakh View More Details

```<code><h4> Price: {{Object.price}}</h4>
</code>```

Would like to print only 1.57 lakh instead of printing all extra data.
Can we use filters here to eliminate extra data? if yes, How can we achieve this or are there any methods to achieve this?

答:
For a string that changes you can use regex to select the last part of the string

angular.module("app", [])
  .controller("ctrl", function($scope) {
    $scope.price = "1.57 lakh View More Details";

    $scope.replaceText = function(text) {
      return text.replace(/View \w* Details/g, "");
    }
  });```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
  <h4> Price: {{replaceText(price)}}</h4>
</div></code>```

Body:
I have following code which prints 1.57 lakh View More Details

 Price: {{Object.price}}

Would like to print only 1.57 lakh instead of printing all extra data.
Can we use filters here to eliminate extra data? if yes, How can we achieve this or are there any methods to achieve this?

Body:
For a string that changes you can use regex to select the last part of the string

angular.module("app", [])
  .controller("ctrl", function($scope) {
    $scope.price = "1.57 lakh View More Details";

    $scope.replaceText = function(text) {
      return text.replace(/View \w* Details/g, "");
    }
  });

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
  <h4> Price: {{replaceText(price)}}</h4>
</div>


问:
Proper way to declare an enum in Managed C++ 2005?
If I use /clr:oldSyntax the following should work:

```<code>public __value enum IceCreamFlavors
{
   Vanilla,
   Chocolate,
   Sardine,
};
</code>```

what is the equivalent in non-oldSyntax? How do I declare a "managed" enum in Managed C++ for .NET 2.0?

Edit:
when I follow JaredPar's advice, then if I try to pass an IceCreamFlavor to a function with the signature:

```<code>OrderFlavor(IceCreamFlavors flav)
</code>```

by running

```<code>OrderFlavor(IceCreamFlavors::Sardine)
</code>```

I get the error:

```<code>'IceCreamFlavors Sardine' : member function redeclaration not allowed
</code>```

答:
Are you, by any chance, trying to declare your enum inside another class?
ie:

```<code>public ref class Icecream
{
     public enum class flavours
     {
          Mint,
          Vanilla,
          Guac
     };
};
</code>```

If you are, I would guess that you need to move it out so that it is its own class instead of a nested one. (Does managed c++ allow nested classes?)  My impression is that you used to be able to do it unmanaged style inside another class, but since its its own class now, you probably shouldn't be nesting them. I might be wrong. My knowledge of managed c++ and c# is kind of weak.

OwnerDisplayName: brian

Body:
If I use /clr:oldSyntax the following should work:

public __value enum IceCreamFlavors
{
   Vanilla,
   Chocolate,
   Sardine,
};

what is the equivalent in non-oldSyntax? How do I declare a "managed" enum in Managed C++ for .NET 2.0?

Edit:
when I follow JaredPar's advice, then if I try to pass an IceCreamFlavor to a function with the signature:

OrderFlavor(IceCreamFlavors flav)

by running

OrderFlavor(IceCreamFlavors::Sardine)

I get the error:

'IceCreamFlavors Sardine' : member function redeclaration not allowed

LastEditorDisplayName: brian

Body:
Are you, by any chance, trying to declare your enum inside another class?
ie:

public ref class Icecream
{
     public enum class flavours
     {
          Mint,
          Vanilla,
          Guac
     };
};

If you are, I would guess that you need to move it out so that it is its own class instead of a nested one. (Does managed c++ allow nested classes?)  My impression is that you used to be able to do it unmanaged style inside another class, but since its its own class now, you probably shouldn't be nesting them. I might be wrong. My knowledge of managed c++ and c# is kind of weak.


问:
How to save the file by giving the file name from grid row containing columns,name,date,device
```<code>    I have a Grid view With Name time , device , Upload control columns , When i click upload in Grid view , files will be uploaded and saved in a folder, but i need to save the file with name_time_device..

    How to do it any help??

    if (context.Request.Files.Count > 0)
    {
    HttpFileCollection files = context.Request.Files;
    for (int i = 0; i < files.Count; i++)
    {
    HttpPostedFile file = files[i];
    //FileUploadData.tName = Request.QueryString["name"];
    //string fname = context.Server.MapPath("~/FileUploads/") + FileUploadData.Name + "_" + FileUploadData.Id + "/" + DateTime.Now.ToString("ddMMyyyy") + "/" + FileUploadData.deviceID + "_" +
    string fname = context.Server.MapPath("~/uploads/" + file.FileName);
    file.SaveAs(fname);

    }
    context.Response.ContentType = "application/x-zip-compressed";
    context.Response.Write("File Uploaded Successfully!");
    }

    File uploading and saving i am doing in javascript. the file is zipped..and saving it in uploads folder, but it need to be saved with name_id_date_device.zip..

I am using a function In that function i am using ajax call , above code is my generic handler to save the files..
</code>```

file saving is from function, here while saving only i need to pass id_name_device so which ever user clicks upload and upload files his file will be saved by his id_name_device.zip..

```<code>Help??
</code>```

答:
Can you please speicify you are having problem in getting name, time, device from gridview or you have issue with file saving with name "name_id_date_device.zip"?
if you problem is saving file with a specific name and you are ok to get name, time or device from gridview then you should change this:

```<code>  string fname = context.Server.MapPath("~/uploads/" + file.FileName);
</code>```

TO

```<code>string fname = context.Server.MapPath("~/uploads/" + "name_id_date_device.zip");
</code>```

in this way your file will be saved with this given name.

if you want to add your flag with file name just concat it with your filename when you are saving.

```<code>string fname = context.Server.MapPath("~/uploads/" + "what_flag_name_time" + file.FileName);
</code>```

.and if you have anyother problem please be more specific. Thanks

Body:
    I have a Grid view With Name time , device , Upload control columns , When i click upload in Grid view , files will be uploaded and saved in a folder, but i need to save the file with name_time_device..

    How to do it any help??

    if (context.Request.Files.Count > 0)
    {
    HttpFileCollection files = context.Request.Files;
    for (int i = 0; i < files.Count; i++)
    {
    HttpPostedFile file = files[i];
    //FileUploadData.tName = Request.QueryString["name"];
    //string fname = context.Server.MapPath("~/FileUploads/") + FileUploadData.Name + "_" + FileUploadData.Id + "/" + DateTime.Now.ToString("ddMMyyyy") + "/" + FileUploadData.deviceID + "_" +
    string fname = context.Server.MapPath("~/uploads/" + file.FileName);
    file.SaveAs(fname);

    }
    context.Response.ContentType = "application/x-zip-compressed";
    context.Response.Write("File Uploaded Successfully!");
    }

    File uploading and saving i am doing in javascript. the file is zipped..and saving it in uploads folder, but it need to be saved with name_id_date_device.zip..

I am using a function In that function i am using ajax call , above code is my generic handler to save the files..

file saving is from function, here while saving only i need to pass id_name_device so which ever user clicks upload and upload files his file will be saved by his id_name_device.zip..

Help??

Body:
Can you please speicify you are having problem in getting name, time, device from gridview or you have issue with file saving with name "name_id_date_device.zip"?
if you problem is saving file with a specific name and you are ok to get name, time or device from gridview then you should change this:

  string fname = context.Server.MapPath("~/uploads/" + file.FileName);

TO

string fname = context.Server.MapPath("~/uploads/" + "name_id_date_device.zip");

in this way your file will be saved with this given name.

if you want to add your flag with file name just concat it with your filename when you are saving.

string fname = context.Server.MapPath("~/uploads/" + "what_flag_name_time" + file.FileName);

.and if you have anyother problem please be more specific. Thanks


问:
ajax autocomplete same data with multiple textbox jquery
i have one issue with jquery autocomplete, its working with one textbox perfect but when i create multiple textbox using jquery with same ID at that time its working for only first textbox not for another textbox .
my question is i want to create multiple textbox and implement same autocomplete data with all text box

this is my code for create textbox using jquery

```<code>var totalSelect = $('#max_player').val();
    $('#competitor_box').empty();
    for (var i = 1; i <= totalSelect; i++) {
        var ajaxauto = '<div class="form-group col-sm-3"><label for="tournament_name">Pocker # '+i+'</label><input id="autocomplete-ajax" type="text" class="form-control" autocomplete="off"></div>';
        $('#competitor_box').append(ajaxauto);
    }
</code>```

this code for ajax autocomplete

```<code>$('#autocomplete-ajax').autocomplete({
    // serviceUrl: '/autosuggest/service/url',
    lookup: countriesArray,
    lookupFilter: function(suggestion, originalQuery, queryLowerCase) {
        var re = new RegExp('\\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi');
        return re.test(suggestion.value);
    },
    onSelect: function(suggestion) {
        $('#selction-ajax').html('You selected: ' + suggestion.value + ', ' + suggestion.data);
    },
    onHint: function (hint) {
        $('#autocomplete-ajax-x').val(hint);
    },
    onInvalidateSelection: function() {
        $('#selction-ajax').html('You selected: none');
    }
});
</code>```

please help me for this issue its very important for me
thanks all.

答:
```<code>    var totalSelect = $('#max_player').val();
        $('#competitor_box').empty();
        for (var i = 1; i <= totalSelect; i++) {
            var ajaxauto = '<div class="form-group col-sm-3"><label for="tournament_name">Pocker # '+i+'</label><input class="txtAutocomplete" type="text" class="form-control" autocomplete="off"></div>';
            $('#competitor_box').append(ajaxauto);
        }
</code>```

Autocomplete function

```<code>    $('.txtAutocomplete').autocomplete({
        // serviceUrl: '/autosuggest/service/url',
        lookup: countriesArray,
        lookupFilter: function(suggestion, originalQuery, queryLowerCase) {
            var re = new RegExp('\\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi');
            return re.test(suggestion.value);
        },
        onSelect: function(suggestion) {
            $('#selction-ajax').html('You selected: ' + suggestion.value + ', ' + suggestion.data);
        },
        onHint: function (hint) {
            $('#autocomplete-ajax-x').val(hint);
        },
        onInvalidateSelection: function() {
            $('#selction-ajax').html('You selected: none');
        }
    });
</code>```

Body:
i have one issue with jquery autocomplete, its working with one textbox perfect but when i create multiple textbox using jquery with same ID at that time its working for only first textbox not for another textbox .
my question is i want to create multiple textbox and implement same autocomplete data with all text box

this is my code for create textbox using jquery

var totalSelect = $('#max_player').val();
    $('#competitor_box').empty();
    for (var i = 1; i <= totalSelect; i++) {
        var ajaxauto = '
Pocker # '+i+'<input id="autocomplete-ajax" type="text" class="form-control" autocomplete="off">
';
        $('#competitor_box').append(ajaxauto);
    }

this code for ajax autocomplete

$('#autocomplete-ajax').autocomplete({
    // serviceUrl: '/autosuggest/service/url',
    lookup: countriesArray,
    lookupFilter: function(suggestion, originalQuery, queryLowerCase) {
        var re = new RegExp('\\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi');
        return re.test(suggestion.value);
    },
    onSelect: function(suggestion) {
        $('#selction-ajax').html('You selected: ' + suggestion.value + ', ' + suggestion.data);
    },
    onHint: function (hint) {
        $('#autocomplete-ajax-x').val(hint);
    },
    onInvalidateSelection: function() {
        $('#selction-ajax').html('You selected: none');
    }
});

please help me for this issue its very important for me
thanks all.

Body:
    var totalSelect = $('#max_player').val();
        $('#competitor_box').empty();
        for (var i = 1; i <= totalSelect; i++) {
            var ajaxauto = '<div class="form-group col-sm-3"><label for="tournament_name">Pocker # '+i+'</label><input class="txtAutocomplete" type="text" class="form-control" autocomplete="off"></div>';
            $('#competitor_box').append(ajaxauto);
        }

Autocomplete function

    $('.txtAutocomplete').autocomplete({
        // serviceUrl: '/autosuggest/service/url',
        lookup: countriesArray,
        lookupFilter: function(suggestion, originalQuery, queryLowerCase) {
            var re = new RegExp('\\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi');
            return re.test(suggestion.value);
        },
        onSelect: function(suggestion) {
            $('#selction-ajax').html('You selected: ' + suggestion.value + ', ' + suggestion.data);
        },
        onHint: function (hint) {
            $('#autocomplete-ajax-x').val(hint);
        },
        onInvalidateSelection: function() {
            $('#selction-ajax').html('You selected: none');
        }
    });


问:
How can I add Id as Integer in Firebase Database In android?
I want an Id to be integer and  do not want to  used Push.For
example:</p>

```<code>{
   "chats": {
    "1": {
      "title": "Historical Tech Pioneers",
      "messages": {
        "1": { "sender": "ghopper", "message": "Relay malfunction found. Cause: moth." },
        "2": { ... },
     }
    },
    "2": { ... }
  }
}
</code>```

答:
the push() method generate the random key so try this

```<code>mRef.child("chats").child(your_id).setValue();
</code>```

Body:
I want an Id to be integer and  do not want to  used Push.For
example:

{
   "chats": {
    "1": {
      "title": "Historical Tech Pioneers",
      "messages": {
        "1": { "sender": "ghopper", "message": "Relay malfunction found. Cause: moth." },
        "2": { ... },
     }
    },
    "2": { ... }
  }
}

Body:
the push() method generate the random key so try this

mRef.child("chats").child(your_id).setValue();


问:
How should I start designing an AI algorithm for an artillery warfare game?
Here's the background... in my free time I'm designing an artillery warfare game called Staker (inspired by the old BASIC games Tank Wars and Scorched Earth) and I'm programming it in MATLAB. Your first thought might be "Why MATLAB? There are plenty of other languages/software packages that are better for game design." And you would be right. However, I'm a dork and I'm interested in learning the nuts and bolts of how you would design a game from the ground up, so I don't necessarily want to use anything with prefab modules. Also, I've used MATLAB for years and I like the challenge of doing things with it that others haven't really tried to do.

Now to the problem at hand: I want to incorporate AI so that the player can go up against the computer. I've only just started thinking about how to design the algorithm to choose an azimuth angle, elevation angle, and projectile velocity to hit a target, and then adjust them each turn. I feel like maybe I've been overthinking the problem and trying to make the AI too complex at the outset, so I thought I'd pause and ask the community here for ideas about how they would design an algorithm.

Some specific questions:

Are there specific references for AI design that you would suggest I check out?

Would you design the AI players to vary in difficulty in a continuous manner (a difficulty of 0 (easy) to 1 (hard), all still using the same general algorithm) or would you design specific algorithms for a discrete number of AI players (like an easy enemy that fires in random directions or a hard enemy that is able to account for the effects of wind)?

What sorts of mathematical algorithms (pseudocode description) would you start with?

Some additional info: the model I use to simulate projectile motion incorporates fluid drag and the effect of wind. The "fluid" can be air or water. In air, the air density (and thus effect of drag) varies with height above the ground based on some simple atmospheric models. In water, the drag is so great that the projectile usually requires additional thrust. In other words, the projectile can be affected by forces other than just gravity.

答:
Thanks Loren and BCS, I think you've hit upon an idea I was considering (which prompted question #2 above). The pseudocode for an AIs turn would look something like this:

```<code>nSims;        % A variable storing the numbers of projectile simulations
              %    done per turn for the AI (i.e. difficulty)
prevParams;   % A variable storing the previous shot parameters
prevResults;  % A variable storing some measure of accuracy of the last shot
newParams = get_new_guess(prevParams,prevResults);
loop for nSims times,
  newResults = simulate_projectile_flight(newParams);
  newParams = get_new_guess(newParams,newResults);
end
fire_projectile(newParams);
</code>```

In this case, the variable nSims is essentially a measure of "intelligence" for the AI. A "dumb" AI would have nSims=0, and would simply make a new guess each turn (based on results of the previous turn). A "smart" AI would refine its guess nSims times per turn by simulating the projectile flight.

Two more questions spring from this:

1) What goes into the function get_new_guess? How should I adjust the three shot parameters to minimize the distance to the target? For example, if a shot falls short of the target, you can try to get it closer by adjusting the elevation angle only, adjusting the projectile velocity only, or adjusting both of them together.

2) Should get_new_guess be the same for all AIs, with the nSims value being the only determiner of "intelligence"? Or should get_new_guess be dependent on another "intelligence" parameter (like guessAccuracy)?

OwnerDisplayName: gnovice

LastEditorDisplayName: gnovice

Body:
Thanks Loren and BCS, I think you've hit upon an idea I was considering (which prompted question #2 above). The pseudocode for an AIs turn would look something like this:

nSims;        % A variable storing the numbers of projectile simulations
              %    done per turn for the AI (i.e. difficulty)
prevParams;   % A variable storing the previous shot parameters
prevResults;  % A variable storing some measure of accuracy of the last shot
newParams = get_new_guess(prevParams,prevResults);
loop for nSims times,
  newResults = simulate_projectile_flight(newParams);
  newParams = get_new_guess(newParams,newResults);
end
fire_projectile(newParams);

In this case, the variable nSims is essentially a measure of "intelligence" for the AI. A "dumb" AI would have nSims=0, and would simply make a new guess each turn (based on results of the previous turn). A "smart" AI would refine its guess nSims times per turn by simulating the projectile flight.

Two more questions spring from this:

1) What goes into the function get_new_guess? How should I adjust the three shot parameters to minimize the distance to the target? For example, if a shot falls short of the target, you can try to get it closer by adjusting the elevation angle only, adjusting the projectile velocity only, or adjusting both of them together.

2) Should get_new_guess be the same for all AIs, with the nSims value being the only determiner of "intelligence"? Or should get_new_guess be dependent on another "intelligence" parameter (like guessAccuracy)?


问:
Choose one origin as canonical for merge with git
I have a file that was modified in two different repositories and merged in my local repository after a pull. I know that one of the repositories is the actual version that I want, and don't want the merged version of the file. How can I tell git, after the merge has already been applied to the local version, to use one version or the other?</p>

答:
Remotes are just a way for git to fetch commits from somewhere. It's the commits that affect what version of content you see; it doesn't matter where they came from.

Picking a version of a file as "canonical" just means making sure that's the version of the file that's in the canonical repository. The upshot of that is that you probably want to do this in your local repository:

```<code># make sure that origin is the canonical remote
# rename the other one to something else!

# make sure you're up to date
git fetch origin
# check out the desired version of the file
git checkout origin/master path/to/file
# and commit this modification
git commit
</code>```

This could also be done as part of pulling from origin:

```<code># pull from the default remote/branch, hopefully origin/master
git pull --no-commit
# get "their" (origin's) version
git checkout --theirs path/to/file
# commit the merge
git commit
</code>```

The --no-commit option tells git to stop before committing the merge which is part of the pull, so that you'll be able to modify the result of the merge then commit it. If there are conflicts (which may be likely in your case), then it would have stopped anyway to let you resolve them.

Body:
Remotes are just a way for git to fetch commits from somewhere. It's the commits that affect what version of content you see; it doesn't matter where they came from.

Picking a version of a file as "canonical" just means making sure that's the version of the file that's in the canonical repository. The upshot of that is that you probably want to do this in your local repository:

# make sure that origin is the canonical remote
# rename the other one to something else!

# make sure you're up to date
git fetch origin
# check out the desired version of the file
git checkout origin/master path/to/file
# and commit this modification
git commit

This could also be done as part of pulling from origin:

# pull from the default remote/branch, hopefully origin/master
git pull --no-commit
# get "their" (origin's) version
git checkout --theirs path/to/file
# commit the merge
git commit

The --no-commit option tells git to stop before committing the merge which is part of the pull, so that you'll be able to modify the result of the merge then commit it. If there are conflicts (which may be likely in your case), then it would have stopped anyway to let you resolve them.


问:
Rails - Error pages controller and redirecting the user?
Building a small app and I'd like to intercept error pages.

Is it possible to define a controller where all of Rails's failed page requests end up so I can add my custom behavior there?

答:
Correct me if I'm wrong, but I think rescuing the error from the controller won't work because the request hasn't hit any controller yet for you to do a rescue_from. (Just tried this on 4.2.x)

You will need to add a catch-all kind of route into your config/routes.rb, right at the end of the all the others. This basically routes all the traffic that is not recognized to the errors#show action.

```<code>YourApp::Application.routes.draw do
  # ...
  # ...
  get '*path', to: 'errors#show', via: :all
end
</code>```

Then create the ErrorsController and the method for you to parse the URL.

```<code>class ErrorsController < ApplicationController
  def show
    # parse the URL and redirect or simply render the page
  end
end
</code>```

Do note that the above will not help with ActiveRecord::RecordNotFound errors; because they fall into a route pattern for a specific controller. For that, you can add rescue_from in the ApplicationController as such:

```<code>class ApplicationController < ActionController::Base
  rescue_from ActiveRecord::RecordNotFound, with: :foo

  def foo
    # redirect or do something
  end
end
</code>```

Body:
Correct me if I'm wrong, but I think rescuing the error from the controller won't work because the request hasn't hit any controller yet for you to do a rescue_from. (Just tried this on 4.2.x)

You will need to add a catch-all kind of route into your config/routes.rb, right at the end of the all the others. This basically routes all the traffic that is not recognized to the errors#show action.

YourApp::Application.routes.draw do
  # ...
  # ...
  get '*path', to: 'errors#show', via: :all
end

Then create the ErrorsController and the method for you to parse the URL.

class ErrorsController < ApplicationController
  def show
    # parse the URL and redirect or simply render the page
  end
end

Do note that the above will not help with ActiveRecord::RecordNotFound errors; because they fall into a route pattern for a specific controller. For that, you can add rescue_from in the ApplicationController as such:

class ApplicationController < ActionController::Base
  rescue_from ActiveRecord::RecordNotFound, with: :foo

  def foo
    # redirect or do something
  end
end


问:
Swift 3 link from date format
Solution seems to me very simple, but...

```<code>let link = "http://example.com/zzz.aspx?d=yyyyMMddt=1"
var dateformatter = DateFormatter()
dateformatter.dateFormat = link
print(dateformatter.string(from: Date()))
</code>```

I expect to get "http://example.com/zzz.aspx?d=20170403t=1"

答:
All characters in the format string which should be copied verbatim
and not interpreted as date format patterns must be enclosed
in single quotes:</p>

```<code>let link = "'http://example.com/zzz.aspx?d='yyyyMMdd't=1'"
var dateformatter = DateFormatter()
dateformatter.dateFormat = link
print(dateformatter.string(from: Date()))

// http://example.com/zzz.aspx?d=20170403t=1
</code>```

Title: Swift 3 link from date format

Body:
Solution seems to me very simple, but...

let link = "http://example.com/zzz.aspx?d=yyyyMMddt=1"
var dateformatter = DateFormatter()
dateformatter.dateFormat = link
print(dateformatter.string(from: Date()))

I expect to get "http://example.com/zzz.aspx?d=20170403t=1"

Body:
All characters in the format string which should be copied verbatim
and not interpreted as date format patterns must be enclosed
in single quotes:

let link = "'http://example.com/zzz.aspx?d='yyyyMMdd't=1'"
var dateformatter = DateFormatter()
dateformatter.dateFormat = link
print(dateformatter.string(from: Date()))

// http://example.com/zzz.aspx?d=20170403t=1


问:
Android back button app is not closing
i am using the below code for back button but it cant work it does not exit the app if i am pressing the back button of userdevice</p>

```<code>  private Boolean exit = false;

        @Override
        public void onBackPressed() {
            if (exit) {
                this.finish(); // finish activity
            } else {
                Toast.makeText(this, "Press Back again to Exit.",
                        Toast.LENGTH_SHORT).show();
                exit = true;
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        exit = false;
                    }
                }, 3 * 1000);

            }

        }
</code>```

答:
Use this to close the app on pressing back button.  </p>

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

            Intent intent = new Intent(Intent.ACTION_MAIN);
            startMain.addCategory(Intent.CATEGORY_HOME);
            startActivity(intent);
        }
</code>```

Title: Android back button app is not closing

Body:
i am using the below code for back button but it cant work it does not exit the app if i am pressing the back button of userdevice

  private Boolean exit = false;

        @Override
        public void onBackPressed() {
            if (exit) {
                this.finish(); // finish activity
            } else {
                Toast.makeText(this, "Press Back again to Exit.",
                        Toast.LENGTH_SHORT).show();
                exit = true;
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        exit = false;
                    }
                }, 3 * 1000);

            }

        }

Body:
Use this to close the app on pressing back button.

@Override
    public void onBackPressed() {

            Intent intent = new Intent(Intent.ACTION_MAIN);
            startMain.addCategory(Intent.CATEGORY_HOME);
            startActivity(intent);
        }


问:
How do I check if the username value is already in the database in visual basic?
```<code>Private Sub SignUpBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SignUpBtn.Click
    'ttp://www.sourcecodester.com/tutorials/visual-basic-net/7258/adding-and-saving-records-access-database-using-vbnet.html
    Try

        cm = New OleDb.OleDbCommand
        With cm
            .Connection = cn
            .CommandType = CommandType.Text
            .CommandText = "INSERT INTO Users (UserName,UserPassword) VALUES (@Uname,@Pword)"

            .Parameters.Add(New System.Data.OleDb.OleDbParameter("@UserName", System.Data.OleDb.OleDbType.VarChar, 255, Me.Uname.Text))
            .Parameters.Add(New System.Data.OleDb.OleDbParameter("@UserPassword", System.Data.OleDb.OleDbType.VarChar, 255, Me.Pword.Text))

            Me.Uname.Text = MainClass.consoleout

            ' RUN THE COMMAND
            cm.Parameters("@UserName").Value = Me.Uname.Text
            cm.Parameters("@UserPassword").Value = Me.Pword.Text

            cm.ExecuteNonQuery()
            MsgBox("Record saved.", MsgBoxStyle.Information)
            Dim Form1 As New Form1
            Form1.Show()
            Hide()

            Exit Sub
        End With
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical)
    End Try
End Sub
</code>```

I'm trying to make this form with a check that if the username entered is the same as a username in the database. Currently I can save any user over and over again and the record is just repeated in the database. My username text box is called Uname and my password text box is called Pword. The database table is called Users and the columns I trying to put them is called UserName And UserPassword. My database connection has already been declared in the Module. I got all of the coding for this from a website(http://www.sourcecodester.com/tutorials/visual-basic-net/7258/adding-and-saving-records-access-database-using-vbnet.html). I just modified it to suit my conditions. If someone could tell me how to make sure that no 2 usernames are saved in the database I would be very grateful.

答:
make UNAME as primary key
and in code put try catch </p>

Body:
Private Sub SignUpBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SignUpBtn.Click
    'ttp://www.sourcecodester.com/tutorials/visual-basic-net/7258/adding-and-saving-records-access-database-using-vbnet.html
    Try

        cm = New OleDb.OleDbCommand
        With cm
            .Connection = cn
            .CommandType = CommandType.Text
            .CommandText = "INSERT INTO Users (UserName,UserPassword) VALUES (@Uname,@Pword)"

            .Parameters.Add(New System.Data.OleDb.OleDbParameter("@UserName", System.Data.OleDb.OleDbType.VarChar, 255, Me.Uname.Text))
            .Parameters.Add(New System.Data.OleDb.OleDbParameter("@UserPassword", System.Data.OleDb.OleDbType.VarChar, 255, Me.Pword.Text))

            Me.Uname.Text = MainClass.consoleout

            ' RUN THE COMMAND
            cm.Parameters("@UserName").Value = Me.Uname.Text
            cm.Parameters("@UserPassword").Value = Me.Pword.Text

            cm.ExecuteNonQuery()
            MsgBox("Record saved.", MsgBoxStyle.Information)
            Dim Form1 As New Form1
            Form1.Show()
            Hide()

            Exit Sub
        End With
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical)
    End Try
End Sub

I'm trying to make this form with a check that if the username entered is the same as a username in the database. Currently I can save any user over and over again and the record is just repeated in the database. My username text box is called Uname and my password text box is called Pword. The database table is called Users and the columns I trying to put them is called UserName And UserPassword. My database connection has already been declared in the Module. I got all of the coding for this from a website(http://www.sourcecodester.com/tutorials/visual-basic-net/7258/adding-and-saving-records-access-database-using-vbnet.html). I just modified it to suit my conditions. If someone could tell me how to make sure that no 2 usernames are saved in the database I would be very grateful.


问:
How to crop jpeg image by 8 lines from 4928x3264 to 4920x3264 (16.1mp to 16mp) without loosing any quality?
How to cut those 8 lines without recompressing the rest of the image?

I want to upload my pictures with original size to google photos but 16.1mp counts against my quota, 16mp doesn't count against my quota. I want to have e.g. 7.1Mb file size preserved, not compressed to 1Mb on google photos.

答:
Your are obviously looking for a way to apply lossless transforms to a JPEG file. In your specific case, a lossless cropping operation is required.

Since the JPEG compression algorithm works on 8x8 pixels blocks (in most cases), one has good reason to think that removing some "lines" of blocks should lead to a valid cropped JPEG file with preserved quality and compression ratio.

A cross-platform command-line program called jpegtran is dedicated to applying such lossless transforms. It is available here: http://jpegclub.org/jpegtran/

Reading the linux manual is a good start: https://linux.die.net/man/1/jpegtran

And here is an exemple of the command to use in your case:

```<code>jpegtran -crop WxH+X+Y input.jpg > output.jpg
</code>```

W: width in pixels, H: height in pixels, X,Y: starting point position in pixels

Body:
Your are obviously looking for a way to apply lossless transforms to a JPEG file. In your specific case, a lossless cropping operation is required.

Since the JPEG compression algorithm works on 8x8 pixels blocks (in most cases), one has good reason to think that removing some "lines" of blocks should lead to a valid cropped JPEG file with preserved quality and compression ratio.

A cross-platform command-line program called jpegtran is dedicated to applying such lossless transforms. It is available here: http://jpegclub.org/jpegtran/

Reading the linux manual is a good start: https://linux.die.net/man/1/jpegtran

And here is an exemple of the command to use in your case:

jpegtran -crop WxH+X+Y input.jpg > output.jpg

W: width in pixels, H: height in pixels, X,Y: starting point position in pixels


答: why did you use the same ID for severals input ? use classes if you have to tag multiples elements, for example .autocomplete-ajax-input on each textbox. And then declare your autocomple function with $('.autocomplete-ajax-input').autocomplete

Title: ajax autocomplete same data with multiple textbox jquery


问:
In C# can you define an alias to a value tuple with names?
I know it's possible to define aliases in C# with the using keyword.

e.g.

```<code>using ResponseKey = System.ValueTuple<System.Guid, string, string>;
</code>```

However, is it possible to define one using the new syntax for value tuples?

```<code>using ResponseKey = (Guid venueId, string contentId, string answer);
</code>```

This syntax does not appear to work. Should it?

答:
Updated. As of C# 10, you can define either a struct or class-based record to fulfill this requirement:

```<code>public record struct ResponseKey(Guid venueId, string contentId, string answer);
public record class ResponseKey(Guid venueId, string contentId, string answer);
</code>```

Note that class is optional for the second definition.

This has been requested, and recorded in the Roslyn repo on Github. However it received a mixed reception there, and the proposed record types, would more than cover this requirement.

The issue was closed in the Roslyn repo but is now being tracked in the C# language repo.

Body:
I know it's possible to define aliases in C# with the using keyword.

e.g.

using ResponseKey = System.ValueTuple<System.Guid, string, string>;

However, is it possible to define one using the new syntax for value tuples?

using ResponseKey = (Guid venueId, string contentId, string answer);

This syntax does not appear to work. Should it?

Body:
Updated. As of C# 10, you can define either a struct or class-based record to fulfill this requirement:

public record struct ResponseKey(Guid venueId, string contentId, string answer);
public record class ResponseKey(Guid venueId, string contentId, string answer);

Note that class is optional for the second definition.

This has been requested, and recorded in the Roslyn repo on Github. However it received a mixed reception there, and the proposed record types, would more than cover this requirement.

The issue was closed in the Roslyn repo but is now being tracked in the C# language repo.


问:
AngularJS - hide category if item from the same not in results array
I am working on product filter and this is what I have.

```<code>$scope.categories = {meat: [array of products], bread: [array of products], drinks: [array of products]}
$scope.filterQuery = '';
</code>```

Every category has it's own "PRODUCTS" array with items. I am using ngRepeat to filter (via filterQuery) through categories and ngRepeat again so I can show products inside categories.

My question is: If I'm using input field with ngModel to provide products filtering, how can I hide categories if products from the same are not in results array?

My code inside component:

```<code><div class="component-wrapper" ng-repeat="(key, data) in categories">
CATEGORY
<div class="products" ng-repeat="item in results = (data | filter: filterQuery)">Product</div>
</code>```

答:
Since you have products bound to results, you can check for its length at run time and hide its category using ng-hide="results.length == 0"

See working demo

Body:
I am working on product filter and this is what I have.

$scope.categories = {meat: [array of products], bread: [array of products], drinks: [array of products]}
$scope.filterQuery = '';

Every category has it's own "PRODUCTS" array with items. I am using ngRepeat to filter (via filterQuery) through categories and ngRepeat again so I can show products inside categories.

My question is: If I'm using input field with ngModel to provide products filtering, how can I hide categories if products from the same are not in results array?

My code inside component:

CATEGORY

Product


问:
Get first value of Model's List in jQuery (document).ready using Razor?
How can I get the value of the first item from the model's List? My ViewModel:

```<code>namespace TestWeb
{
  public class NavViewModel
  {
    public NavViewModel()
    {
      NavStepList = new List<NavStep>();
    }

    public List<NavStep> NavStepList { get; set; }
  }
}
</code>```

In my View:

```<code>@using TestWeb
@model NavViewModel

<script>
  $(document).ready(function () {
    var Testvalue = @Model.NavStepList.First();
  });
</script>
</code>```

I want the first value of NavStepList. However an error occurs when I call this function:

TestWeb is undefined

I already test with testing value assign to NavStepList but the error still occurs.

My NavStep Class Property:

```<code>public class NavStep{
        public int NavStepId { get; set; }
        public int SortId { get; set; }
        public string StepName { get; set; }
        public string IdentifierKey { get; set; }
        public bool IsAvailible { get; set; }
}
</code>```

答:
Case

The @NavViewModel model exists on server.

jQuery script are running  on client (browser)

Problem

How to access server side object on client?

Solution : Serialize sever side object to client

As we can not directly access server-side objects on client
We need to serialize the model (full/part).

```<code>var flatmodel = [@Html.Raw(Json.Encode(Model.NavStepList.First()))][0];
</code>```

Now flatmodel is JavaScript variable and we can access property via flatmodel.

Body:
How can I get the value of the first item from the model's List? My ViewModel:

namespace TestWeb
{
  public class NavViewModel
  {
    public NavViewModel()
    {
      NavStepList = new List<NavStep>();
    }

    public List<NavStep> NavStepList { get; set; }
  }
}

In my View:

@using TestWeb
@model NavViewModel

I want the first value of NavStepList. However an error occurs when I call this function:

TestWeb is undefined

I already test with testing value assign to NavStepList but the error still occurs.

My NavStep Class Property:

public class NavStep{
        public int NavStepId { get; set; }
        public int SortId { get; set; }
        public string StepName { get; set; }
        public string IdentifierKey { get; set; }
        public bool IsAvailible { get; set; }
}

Body:
Case

The @NavViewModel model exists on server.

jQuery script are running  on client (browser)

Problem

How to access server side object on client?

Solution : Serialize sever side object to client

As we can not directly access server-side objects on client
We need to serialize the model (full/part).

var flatmodel = [@Html.Raw(Json.Encode(Model.NavStepList.First()))][0];

Now flatmodel is JavaScript variable and we can access property via flatmodel.