问:
Codeigniter3 framework does not send HTML template in mail
Please, do not mark this question as "similar" because I have tried everything. I have a registration where the user gets verification message to his mail. However, I receive mail like this

How can I solve this problem?

Here is my code:

```<code>private $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://mail.wtf.az',
        'smtp_port' => 465,
        'smtp_user' => 'no-reply@wtf.az',
        'smtp_pass' => 'mypasss',
        'mailtype'  => 'html',
        'charset'   => 'utf-8',
        'wordwrap' => TRUE
    );

function sendEmail($to_email)
    {
        $from_email = 'no-reply@wtf.az'; //change this to yours
        $subject = 'Verify Your Email Address';
        $data['link'] = 'https://wtf.az/test/user/verify/<?= md5($to_email); ?>';

        $message = $this->load->view('registration/mailing', $data, true);

        //send mail
        $this->email->set_header('Content-type', 'text/html');
        $this->email->from($from_email, 'WTF');
        $this->email->to($to_email);
        $this->email->subject($subject);
        $this->email->message($message);
        $this->email->set_newline("\r\n");
        $result = $this->email->send();
        return $result;
    }
</code>```

答:
please try $this->email->set_mailtype("html"); </p>

```<code>function sendEmail($to_email)
{
    $from_email = 'no-reply@wtf.az'; //change this to yours
    $subject = 'Verify Your Email Address';
    $data['link'] = 'https://wtf.az/test/user/verify/<?= md5($to_email); ?>';

    $message = $this->load->view('registration/mailing', $data, true);

    //send mail
    $this->email->set_header('Content-type', 'text/html');
    $this->email->from($from_email, 'WTF');
    $this->email->to($to_email);
    $this->email->subject($subject);
    $this->email->message($message);
    $this->email->set_newline("\r\n");
    $this->email->set_mailtype("html");
    $result = $this->email->send();
    return $result;
}
</code>```

Body:
Please, do not mark this question as "similar" because I have tried everything. I have a registration where the user gets verification message to his mail. However, I receive mail like this

How can I solve this problem?

Here is my code:

private $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://mail.wtf.az',
        'smtp_port' => 465,
        'smtp_user' => 'no-reply@wtf.az',
        'smtp_pass' => 'mypasss',
        'mailtype'  => 'html',
        'charset'   => 'utf-8',
        'wordwrap' => TRUE
    );

function sendEmail($to_email)
    {
        $from_email = 'no-reply@wtf.az'; //change this to yours
        $subject = 'Verify Your Email Address';
        $data['link'] = 'https://wtf.az/test/user/verify/<?= md5($to_email); ?>';

        $message = $this->load->view('registration/mailing', $data, true);

        //send mail
        $this->email->set_header('Content-type', 'text/html');
        $this->email->from($from_email, 'WTF');
        $this->email->to($to_email);
        $this->email->subject($subject);
        $this->email->message($message);
        $this->email->set_newline("\r\n");
        $result = $this->email->send();
        return $result;
    }

Body:
please try $this->email->set_mailtype("html");

function sendEmail($to_email)
{
    $from_email = 'no-reply@wtf.az'; //change this to yours
    $subject = 'Verify Your Email Address';
    $data['link'] = 'https://wtf.az/test/user/verify/<?= md5($to_email); ?>';

    $message = $this->load->view('registration/mailing', $data, true);

    //send mail
    $this->email->set_header('Content-type', 'text/html');
    $this->email->from($from_email, 'WTF');
    $this->email->to($to_email);
    $this->email->subject($subject);
    $this->email->message($message);
    $this->email->set_newline("\r\n");
    $this->email->set_mailtype("html");
    $result = $this->email->send();
    return $result;
}


来源: stackexchange

问:
JavaScript - How to make sure array manipulations are persistent inside a function?
I am trying to write a JavaScript function (ES5) that will take in an array, filter it, and set the original array to the new one.

Here is my plunk: https://plnkr.co/edit/OWeOjJ3SLVGYRaweyy3Z

Here is the basic pseudocode of what I am trying to do:

```<code>var result = [{ 'date': '20171116' }, { 'date': '20171115' }];
var data = { 'date': '2017116' };
deleteEntry(data, result);
console.log(result); //should  have one entry

function deleteEntry(data, result) {
  result = result.filter(function(item) {
    return item.date !== data.date;
  });
}
</code>```

I believe the issue is to do with array references. I am not sure how to accomplish the task.

答:
You should return the modified array and assign it's response to the result variable:

```<code>function deleteEntry(data, result) {
  return result.filter(function(item) {
    return item.date !== data.date;
  });
}

result = deleteEntry(data, result);
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am trying to write a JavaScript function (ES5) that will take in an array, filter it, and set the original array to the new one.

Here is my plunk: https://plnkr.co/edit/OWeOjJ3SLVGYRaweyy3Z

Here is the basic pseudocode of what I am trying to do:

var result = [{ 'date': '20171116' }, { 'date': '20171115' }];
var data = { 'date': '2017116' };
deleteEntry(data, result);
console.log(result); //should  have one entry

function deleteEntry(data, result) {
  result = result.filter(function(item) {
    return item.date !== data.date;
  });
}

I believe the issue is to do with array references. I am not sure how to accomplish the task.

Body:
You should return the modified array and assign it's response to the result variable:

function deleteEntry(data, result) {
  return result.filter(function(item) {
    return item.date !== data.date;
  });
}

result = deleteEntry(data, result);


问:
Want to make font-awesome icons thinner
I was working with font awesome icons but the problem is they have default font weight . i want it a little bit thinner. but its not working

my html code

```<code>    <span class="fa-stack fa-lg fa-5x color-red">
    <i class="fa fa-circle-thin fa-stack-2x"></i>
    <i class="fa fa-trophy"></i>
    </span>
</code>```

my css code

```<code>    .fa-trophy{
      font-weight:lighter;
     }
</code>```

答:
I know this is an old question, but hopefully my answer can help someone who wants a thinner circle when stacking two font awesome icons. I spent a lot of time and energy before I stumbled across this article which helped me in the right direction. My solution:

```<code><span class="fa-stack fa-3x">
   <i class="fa fa-circle fa-stack-2x icon-circle"></i>
   <i class="fa fa-leaf fa-stack-1x"></i>
</span>

.icon-circle{
color: transparent !important;
border: 5px solid #YourColor;
border-radius: 50%;}
</code>```

When I clean up my code I can probably remove the !important tag, but this is how my code looks 5 minutes after I found my solution.

Title: Want to make font-awesome icons thinner

Body:
I was working with font awesome icons but the problem is they have default font weight . i want it a little bit thinner. but its not working

my html code

my css code

    .fa-trophy{
      font-weight:lighter;
     }

Body:
I know this is an old question, but hopefully my answer can help someone who wants a thinner circle when stacking two font awesome icons. I spent a lot of time and energy before I stumbled across this article which helped me in the right direction. My solution:

<span class="fa-stack fa-3x">
   <i class="fa fa-circle fa-stack-2x icon-circle"></i>
   <i class="fa fa-leaf fa-stack-1x"></i>
</span>

.icon-circle{
color: transparent !important;
border: 5px solid #YourColor;
border-radius: 50%;}

When I clean up my code I can probably remove the !important tag, but this is how my code looks 5 minutes after I found my solution.

ContentLicense: CC BY-SA 4.0


问:
How to use the Developer Tools in IE 7?
could any one tell me how to use the Developer Tools in IE 7?I am using the .Net programming language .Wanna to debug the javascript and jquery.</p>

答:
Add

```<code>debugger;
</code>```

to the script where you want to debug. It will also prompt the Visual Studio to handle from there if it is installed

example

```<code><script type="text/javascript">
debugger;
alert("Hello World");
</script>
</code>```

For debugging script in IE8 developer tool bar

http://msdn.microsoft.com/en-us/library/dd565628(VS.85).aspx#dbugjscript

For IE7 sepecif JavaScript debugging you can also refer to this answer
Debugging JavaScript in IE7

ContentLicense: CC BY-SA 2.5

Title: How to use the Developer Tools in IE 7?

Body:
Add

debugger;

to the script where you want to debug. It will also prompt the Visual Studio to handle from there if it is installed

example

<script type="text/javascript">
debugger;
alert("Hello World");
</script>

For debugging script in IE8 developer tool bar

http://msdn.microsoft.com/en-us/library/dd565628(VS.85).aspx#dbugjscript

For IE7 sepecif JavaScript debugging you can also refer to this answer
Debugging JavaScript in IE7

OwnerDisplayName: Sreedhar K

LastEditorDisplayName: Sreedhar K


问:
Datetimepicker hidden when using in grid
I  have a grid with several input fields, also a datetimeinput. On click the calendar is partially hidden:

If i set overflow-y: visible; it's working, but the grid leaves the div on the right side.

I searched longtime and tried many given solutions, but nothing works.

答:
I created a custom solution:</p>

```<code>    $(".delivery_date").datetimepicker({
    format: 'DD.MM.YYYY',
    widgetPositioning: {
        horizontal: 'auto',
        vertical: 'bottom'
    }
});

var tableContentHeight;

$('.delivery_date').on("dp.show",function (e) {
    tableContentHeight = $('#table_content').height();
    var closestRow = this.closest( "tr" ).id;
    var closestRowPosition = $('#' + closestRow).position();
    if(closestRowPosition.top + 250 > tableContentHeight){
        var newTableContentHeight = tableContentHeight + 250;
    }
    $( "#table_content" ).height( newTableContentHeight);
});

$('.delivery_date').on("dp.hide",function (e) {
    $( "#table_content" ).height( tableContentHeight);
});
</code>```

Body:
I created a custom solution:

    $(".delivery_date").datetimepicker({
    format: 'DD.MM.YYYY',
    widgetPositioning: {
        horizontal: 'auto',
        vertical: 'bottom'
    }
});

var tableContentHeight;

$('.delivery_date').on("dp.show",function (e) {
    tableContentHeight = $('#table_content').height();
    var closestRow = this.closest( "tr" ).id;
    var closestRowPosition = $('#' + closestRow).position();
    if(closestRowPosition.top + 250 > tableContentHeight){
        var newTableContentHeight = tableContentHeight + 250;
    }
    $( "#table_content" ).height( newTableContentHeight);
});

$('.delivery_date').on("dp.hide",function (e) {
    $( "#table_content" ).height( tableContentHeight);
});


问:
mysql table import wizard fails to import a csv file
I am trying to import a csv file (Window 10), created by notepad++, using semicolons as delimiters, extension .csv.

I use Mysql Workbench 6.3, import wizard. Encode in notepad++ is UTF-8, and the mysql table I am trying to load is utf-8 default collation

Import wizard fails to import and shows two messages:
Table data Import: Can't analyze the file, please try to change encoding type. If that doesn't help, maybe the file is no: csv, or the file is empty

Unhandled exception: 'ascii' codec can't encode character u'\xfa' in position 1: ordinal not in range (128)

How can I do to trace this error. I tried several encodings for the file, but the error persists.

thanks

答: While you are saving the excel data using "Save as" option select msdos .csv format. Note that there are 3 csv format out of it select only MS-DOS .csv as highlighted in image.


问:
Buidling a new package for buildroot: hub-ctrl
I'm trying to build a new package for using in buildroot this useful program to power on/off the different USB ports from the raspberry pi.

The GIT repository is on this site:

https://github.com/codazoda/hub-ctrl.c

And this is the hub-ctrl.mk I've built:

```<code>################################################################################
#
# hub-ctrl
#
################################################################################

HUB_CTRL_VERSION = 42095e522859059e8a5f4ec05c1e3def01a870a9
HUB_CTRL_SITE = https://github.com/codazoda/hub-ctrl.c
HUB_CTRL_SITE_METHOD = git
HUB_CTRL_LICENSE = GPLv2+

define HUB_CTRL_BUILD_CMDS
    $(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D)
endef

define HUB_CTRL_INSTALL_TARGET_CMDS
    # Install predictead application
    $(INSTALL) -m 4755 -D $(@D)/hub-ctrl $(TARGET_DIR)/usr/sbin/hub-ctrl;
endef

$(eval $(generic-package))
</code>```

Up to now, everything is ok. But I realize that the repository it doesn't have a Makefile, so I decided to build one on my own, but I have errors. I don't know how to link the include and library folder. I'm not an expert building makefiles so I need some help. This is my Makefile:

```<code>PROJECT_ROOT = .
OUTDIR = $(PROJECT_ROOT)/bin
BASE_NAME = hub-ctrl
NAME = $(BASE_NAME)$(D)
OBJ = $(BASE_NAME).o
INC =
LIBS = -lusb
MKDIR = mkdir -p
MV = mv

# Master rule
.PHONY: all
all: $(NAME)

# Output binary
$(NAME): $(OBJ)
    $(CC) $(CFLAGS) $(INC) $(OBJ) -o $(BASE_NAME) $(LIBS)
    -@$(MV) $(BASE_NAME) $(OUTDIR)/$(BASE_NAME)
    rm *.o

# Intermediate object files
$(OBJ): %.o: %.c
    @$(MKDIR) $(OUTDIR)
    $(CC) $(CFLAGS) $(LIBS) $(INC) -c $<

# Cleanup intermediate objects
.PHONY: clean_obj
clean_obj:
    rm -f $(OBJ)
    @echo "obj cleaned up!"

# Cleanup everything
.PHONY: clean
clean: clean_obj
    rm -rf $(OUTDIR)/$(BASE_NAME)
    @echo "all cleaned up!"
</code>```

This is the error I've got:

hub-ctrl.c:12:17: fatal error: usb.h: No such file or directory
 #include
                 ^
compilation terminated.

Any suggestion?

Best regards.

答:
I've followed the indications of Peter Korsgaard. I'm using the package uhubctl from buildroot-2017.11-rc1 and I've added this package to my buildroot-2016.02 custom platform. Everything is working fine, and I'm able to power off the usb ports in my HW platform.

Thank you very much to Peter Korsgaard for his advice.

Body:
I'm trying to build a new package for using in buildroot this useful program to power on/off the different USB ports from the raspberry pi.

The GIT repository is on this site:

https://github.com/codazoda/hub-ctrl.c

And this is the hub-ctrl.mk I've built:

################################################################################
#
# hub-ctrl
#
################################################################################

HUB_CTRL_VERSION = 42095e522859059e8a5f4ec05c1e3def01a870a9
HUB_CTRL_SITE = https://github.com/codazoda/hub-ctrl.c
HUB_CTRL_SITE_METHOD = git
HUB_CTRL_LICENSE = GPLv2+

define HUB_CTRL_BUILD_CMDS
    $(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D)
endef

define HUB_CTRL_INSTALL_TARGET_CMDS
    # Install predictead application
    $(INSTALL) -m 4755 -D $(@D)/hub-ctrl $(TARGET_DIR)/usr/sbin/hub-ctrl;
endef

$(eval $(generic-package))

Up to now, everything is ok. But I realize that the repository it doesn't have a Makefile, so I decided to build one on my own, but I have errors. I don't know how to link the include and library folder. I'm not an expert building makefiles so I need some help. This is my Makefile:

PROJECT_ROOT = .
OUTDIR = $(PROJECT_ROOT)/bin
BASE_NAME = hub-ctrl
NAME = $(BASE_NAME)$(D)
OBJ = $(BASE_NAME).o
INC =
LIBS = -lusb
MKDIR = mkdir -p
MV = mv

# Master rule
.PHONY: all
all: $(NAME)

# Output binary
$(NAME): $(OBJ)
    $(CC) $(CFLAGS) $(INC) $(OBJ) -o $(BASE_NAME) $(LIBS)
    -@$(MV) $(BASE_NAME) $(OUTDIR)/$(BASE_NAME)
    rm *.o

# Intermediate object files
$(OBJ): %.o: %.c
    @$(MKDIR) $(OUTDIR)
    $(CC) $(CFLAGS) $(LIBS) $(INC) -c $<

# Cleanup intermediate objects
.PHONY: clean_obj
clean_obj:
    rm -f $(OBJ)
    @echo "obj cleaned up!"

# Cleanup everything
.PHONY: clean
clean: clean_obj
    rm -rf $(OUTDIR)/$(BASE_NAME)
    @echo "all cleaned up!"

This is the error I've got:

hub-ctrl.c:12:17: fatal error: usb.h: No such file or directory
 #include
                 ^
compilation terminated.

Any suggestion?

Best regards.


问:
How to get create table script of existing in oracle 10g using Query
I want create same table in other schema, for which i want get create table script of existing in oracle 10g using Query

Please tell me how to get it..

答:
If you really want a SQL statement, you can use the dbms_metadata package</p>

```<code>select dbms_metadata.get_ddl( 'TABLE', 'EMP', 'SCOTT' )
from dual;
</code>```

Body:
If you really want a SQL statement, you can use the dbms_metadata package

select dbms_metadata.get_ddl( 'TABLE', 'EMP', 'SCOTT' )
from dual;


问:
How to get the search box value in
 tag - HTML,JS
Am new to javascript i foud this one in w3schools.com -  Entering pincode in search box will show in
 tag !! How to do ? any help appreciated. Thanks in advance

HTML :

```<code><form class="form1" role="search" method="get" action="search-pincode.html">
<input class="pincode1" type="number" placeholder="Enter Postcode" id="user-pincode">
<button class="submit" type="submit" formaction="search-pincode.html" onclick="myFunction()">Check</button>
</form>
</code>```

JS SCRIPT :

```<code>    <script>
    function myFunction() {
    var x = document.getElementById("user-pincode").value;
    document.getElementById("user-pincode-show").innerHTML = x;
    }
    </script>
</code>```

OUTPUT : search-pincode.html

```<code>                <h1 class="search-h1-contact">
                Yes, we install CCTV in <p id="user-pincode-show"></p>
                </h1>
</code>```

答:
For one, you will not see the result long enough because after clicking the button, you are being redirected to search-pincode.html. Try changing type="submit" to type="button"

function myFunction() {
  var x = document.getElementById("user-pincode").value;
  document.getElementById("user-pincode-show").innerHTML = x;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><form class="form1" role="search" method="get" action="search-pincode.html">
  <input type="number" placeholder="Enter Postcode" id="user-pincode">
  <button type="button" onclick="myFunction()">Check</button>
</form>

<h1 class="search-h1-contact">
  Yes, we install CCTV in
  <p id="user-pincode-show"></p>
</h1></code>```

If what you are planning is to pass the value of the input to search-pincode.html, and user-pincode-show is inside it, then using JavaScript is not proper way to do it

Title: How to get the search box value in <p> tag - HTML,JS

Body:
Am new to javascript i foud this one in w3schools.com -  Entering pincode in search box will show in
 tag !! How to do ? any help appreciated. Thanks in advance

HTML :

<form class="form1" role="search" method="get" action="search-pincode.html">
<input class="pincode1" type="number" placeholder="Enter Postcode" id="user-pincode">
<button class="submit" type="submit" formaction="search-pincode.html" onclick="myFunction()">Check</button>
</form>

JS SCRIPT :

OUTPUT : search-pincode.html

                Yes, we install CCTV in

Body:
For one, you will not see the result long enough because after clicking the button, you are being redirected to search-pincode.html. Try changing type="submit" to type="button"

function myFunction() {
  var x = document.getElementById("user-pincode").value;
  document.getElementById("user-pincode-show").innerHTML = x;
}

<form class="form1" role="search" method="get" action="search-pincode.html">
  <input type="number" placeholder="Enter Postcode" id="user-pincode">
  <button type="button" onclick="myFunction()">Check</button>
</form>

<h1 class="search-h1-contact">
  Yes, we install CCTV in
  <p id="user-pincode-show"></p>
</h1>

If what you are planning is to pass the value of the input to search-pincode.html, and user-pincode-show is inside it, then using JavaScript is not proper way to do it


问:
Slick Slider - Box Shadows are cut off
The problem is that the slick slider div has overflow: hidden; so the box-shadows of the slides divs keep getting cut off.

Anybody ran into this problem too?

Here is a little fiddle demonstrating the problem:
https://jsfiddle.net/2zvcud0u/

HTML

```<code>  <div class="slider row">
    <div class="col-sm-4">
      <div class="drop-shadow">
        <div class="content">
          <p>Lorem ipsum dolor sit amet</p>
        </div>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="drop-shadow">
        <div class="content">
          <p>Lorem ipsum dolor sit amet</p>
        </div>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="drop-shadow">
        <div class="content">
          <p>Lorem ipsum dolor sit amet</p>
        </div>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="drop-shadow">
        <div class="content">
          <p>Lorem ipsum dolor sit amet</p>
        </div>
      </div>
    </div>
  </div>
</div>
</code>```

CSS

```<code>.row{
  margin: 20px 0;
}

.drop-shadow {
  box-shadow: 0px 0px 43px 0px rgba(0, 0, 0, 0.35);
}

.content{
  margin: 10px;
}
</code>```

JS

```<code>$('.slider').slick({
  autoplay: false,
  dots: false,
  arrows: false,
  infinite: false,
  speed: 300,
  slidesToShow: 3,
  slidesToScroll: 1,
  swipeToSlide: true,
  responsive: [{
    breakpoint: 992,
    settings: {
      slidesToShow: 2
    }
  }, {
    breakpoint: 768,
    settings: {
      slidesToShow: 1
    }
  }]
});
</code>```

Thanks for any suggestions

答:
Alright folks, i think i found a quiet easy solution.

We put a wrapper div around the slider with following CSS:

```<code>.slider-wrapper {
    width: calc(100% + 30px); //we need more width for the shadows on the edges
    padding: 0 15px; //space for the shadows
    margin-left: -15px; //put the div in its original position
    overflow: hidden; //hide the overflow
}
</code>```

We make the slick-list div overflow visible:

```<code>.slick-list {
  overflow: visible;
}
</code>```

Thats it for the first part.

Another problem is that the box-shadow of the first element in the overflow is still visible.

This should fix it:

```<code>.slick-slide .drop-shadow {
  box-shadow: none; //no shadow for a hidden slide
  transition: box-shadow 0.1s ease-in-out; //little effect to fade the shadow
}

.slick-slide.slick-active .drop-shadow {
  box-shadow: 0px 0px 43px 0px rgba(0, 0, 0, 0.35); //only the active slides have the shadow
}
</code>```

Here's another demo fiddle:
https://jsfiddle.net/cc5fmwaL/2/

I hope i could help someone out and feel free to revise this quick solution.

Title: Slick Slider - Box Shadows are cut off

Body:
The problem is that the slick slider div has overflow: hidden; so the box-shadows of the slides divs keep getting cut off.

Anybody ran into this problem too?

Here is a little fiddle demonstrating the problem:
https://jsfiddle.net/2zvcud0u/

HTML

Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet

CSS

.row{
  margin: 20px 0;
}

.drop-shadow {
  box-shadow: 0px 0px 43px 0px rgba(0, 0, 0, 0.35);
}

.content{
  margin: 10px;
}

JS

$('.slider').slick({
  autoplay: false,
  dots: false,
  arrows: false,
  infinite: false,
  speed: 300,
  slidesToShow: 3,
  slidesToScroll: 1,
  swipeToSlide: true,
  responsive: [{
    breakpoint: 992,
    settings: {
      slidesToShow: 2
    }
  }, {
    breakpoint: 768,
    settings: {
      slidesToShow: 1
    }
  }]
});

Thanks for any suggestions

Body:
Alright folks, i think i found a quiet easy solution.

We put a wrapper div around the slider with following CSS:

.slider-wrapper {
    width: calc(100% + 30px); //we need more width for the shadows on the edges
    padding: 0 15px; //space for the shadows
    margin-left: -15px; //put the div in its original position
    overflow: hidden; //hide the overflow
}

We make the slick-list div overflow visible:

.slick-list {
  overflow: visible;
}

Thats it for the first part.

Another problem is that the box-shadow of the first element in the overflow is still visible.

This should fix it:

.slick-slide .drop-shadow {
  box-shadow: none; //no shadow for a hidden slide
  transition: box-shadow 0.1s ease-in-out; //little effect to fade the shadow
}

.slick-slide.slick-active .drop-shadow {
  box-shadow: 0px 0px 43px 0px rgba(0, 0, 0, 0.35); //only the active slides have the shadow
}

Here's another demo fiddle:
https://jsfiddle.net/cc5fmwaL/2/

I hope i could help someone out and feel free to revise this quick solution.


问:
how to provide ignore regex for sublimerge?
I'd like to be able to provide a regular expression for text to ignore when creating diff's with sublimerge. Is that possible?</p>

答:
From Borys, the author of sublimerge:

Please take a look at http://www.sublimerge.com/sm3/docs/configuration.html#default-settings-diff-algorithm - there is a „intraline_unimportant_regexps” setting that should do what you want, however this is not a live setting so it requires the diff to be re-processed.

In sublimerge3 (2?) there is a "Recompare buffers" option in the "sublimerge" section of the right click context menu (when you're viewing a diff). Also F5 will re-process the diff.

Note that at present this only changes the highlight on "unimportant" differences, they still appear when you 'go to next diff'.


问:
pymssql, can't execute EXEC command sql
i'm trying to execute this type of sql command with python but that doesn't work

```<code>import pymssql

_conn = pymssql.connect(** SQL parameter)
_cur = _conn.cursor()
_cur.execute("EXEC(SELECT * something)")
</code>```

i got this error.

Thanks.

答:
The EXECUTE command takes a string, not plain SQL commands:

```<code>EXEC('SELECT * something')
</code>```

But I'm not sure why you're doing this, you could just pass the SELECT statement directly.

Title: pymssql, can't execute EXEC command sql

Body:
i'm trying to execute this type of sql command with python but that doesn't work

import pymssql

_conn = pymssql.connect(** SQL parameter)
_cur = _conn.cursor()
_cur.execute("EXEC(SELECT * something)")

i got this error.

Thanks.

Body:
The EXECUTE command takes a string, not plain SQL commands:

EXEC('SELECT * something')

But I'm not sure why you're doing this, you could just pass the SELECT statement directly.


问:
How to use lseek to read the last character of a file
I'm trying to read the characters from a file in reverse order using lseek.

So far, I have:

```<code> int finished = 1;
 char temp[1];

    while (finished > 0) {

 lseek(fileID,0,2);

 finished = read(fileID, &temp, 1);

 cout << temp[0];

    }
</code>```

But read always returns 0.

Any ideas on what to do?

答:
Surely the call to lseek() should be

```<code>lseek(fileID, -1, SEEK_END);
</code>```

You are seeking to the end of file and you need to be one byte short.

Body:
I'm trying to read the characters from a file in reverse order using lseek.

So far, I have:

 int finished = 1;
 char temp[1];

    while (finished > 0) {

 lseek(fileID,0,2);

 finished = read(fileID, &temp, 1);

 cout << temp[0];

    }

But read always returns 0.

Any ideas on what to do?

Body:
Surely the call to lseek() should be

lseek(fileID, -1, SEEK_END);

You are seeking to the end of file and you need to be one byte short.


问:
Ubuntu 16.04 Spyder 3.2.4 shortcut ctrl + 1 not working
I have a strange problem with my installation of Spyder 3.2.4 on Ubuntu 16.04.
The "toggle comment" command in the editor works when invoked from the menu, but does not with its corresponding shortcut

Ctrl + 1

I tried to change the shortcut, tried to uninstall Anaconda and reinstall it, but the shortcut still does not work.

P.S. Other shortcuts with Ctrl do no work either.

答:
Ok, it seems to be a bug related to shortcuts in Spyder on Ubuntu 16.04. The issue can be found at:
https://github.com/spyder-ide/spyder/issues/5426
and is still open as of today.

UPDATE on Dec 28: still not working in 3.2.5

UPDATE on Jan 09 '18: I discovered that I need to push shift to make the shortcut work, so that the shortcut defined in Spyder Preferences by

```<code>Ctrl+1
</code>```

works by typing

```<code>Ctrl+Shift+1
</code>```

UPDATE on Jan 10 '18: In version 3.2.6, the shortcut can be redefined and Spyder does not crash.

Body:
Ok, it seems to be a bug related to shortcuts in Spyder on Ubuntu 16.04. The issue can be found at:
https://github.com/spyder-ide/spyder/issues/5426
and is still open as of today.

UPDATE on Dec 28: still not working in 3.2.5

UPDATE on Jan 09 '18: I discovered that I need to push shift to make the shortcut work, so that the shortcut defined in Spyder Preferences by

Ctrl+1

works by typing

Ctrl+Shift+1

UPDATE on Jan 10 '18: In version 3.2.6, the shortcut can be redefined and Spyder does not crash.


问:
MongoDb $addFields and $match
In my mongodb query, I use $addFields to add ID field which concatenated of other three fields.   My problem is that I get no result if I $match that new added field with value that I want to query. For other fields, they work just fine.

 order of aggregation

what is in aggregation

```<code>data = await model.aggregate([
            {
                $project: {
                    projectName: 1,
                    price: 1,
                    'document': '$$ROOT'
                }
            },
            {
                $addFields:{
                    'document.id': {$concat: ['$document.propertyId.prefix','$document.propertyId.number']}
                }
            },
            {
                $match: {
                    $and: [
                        {
                            $or: [
                                {id: {$regex: '.*' + req.query.search + '.*', $options: "i"}},
                                {projectName: {$regex: '.*' + req.query.search + '.*', $options: "i"}},

                                /*This also doesnt work*/
                                // {'document.id': {$regex: '.*' + req.query.search + '.*', $options: "i"}},
                                // {'document.projectName': {$regex: '.*' + req.query.search + '.*', $options: "i"}},
                            ]
                        }
                    ]
                }
            },
            {
                $replaceRoot: {newRoot: "$document"}
            },
            {
                $sort: {
                    [sortBy]: sortType
                }
            },
        ]);
</code>```

答:
Next time please add a sample of your document so people can reproduce your problem. Having said that I don't see where your problem is. I created some data to reproduce your usecase. So I added the following document:

```<code>{
    "_id" : ObjectId("5a0d5d376c9b762a7c035ec4"),
    "projectName" : "some stack test",
    "price" : NumberInt(45),
    "propertyId" : {
        "prefix" : "a",
        "number" : "7"
    }
}
</code>```

Then I executed your script (without the sort) and it works fine:

```<code>db.yourCollectionName.aggregate([
    {
        $project: {
            "projectName": 1,
            "price": 1,
            "document": '$$ROOT'
        }
    },
    {
        $addFields: {
            "document.id": {
                $concat: ['$document.propertyId.prefix', '$document.propertyId.number']
            }
        }
    },
    {
        $match: {
            $and: [{
                $or: [{
                        "projectName": {
                            $regex: '.*' + "some stack test"
                        }
                    },

                    {
                        "document.id": {
                            $regex: '.*' + "a" + '.*',
                            $options: "7"
                        }
                    }
                ]
            }]

        }
    },
    {
        $replaceRoot: {
            newRoot: "$document"
        }
    }
])
</code>```

The fact that you get no results is probably due to your request parameters. Besides how can the "projectName"have the same search parameters as your "document.id" Do they even match?
Check your match pipeline again:

```<code>{"projectName": {$regex: '.*' + req.query.search + '.*', $options: "i"}},
{'document.id': {$regex: '.*' + req.query.search + '.*', $options: "i"}}
</code>```

Title: MongoDb $addFields and $match

Body:
In my mongodb query, I use $addFields to add ID field which concatenated of other three fields.   My problem is that I get no result if I $match that new added field with value that I want to query. For other fields, they work just fine.

 order of aggregation

what is in aggregation

data = await model.aggregate([
            {
                $project: {
                    projectName: 1,
                    price: 1,
                    'document': '$$ROOT'
                }
            },
            {
                $addFields:{
                    'document.id': {$concat: ['$document.propertyId.prefix','$document.propertyId.number']}
                }
            },
            {
                $match: {
                    $and: [
                        {
                            $or: [
                                {id: {$regex: '.*' + req.query.search + '.*', $options: "i"}},
                                {projectName: {$regex: '.*' + req.query.search + '.*', $options: "i"}},

                                /*This also doesnt work*/
                                // {'document.id': {$regex: '.*' + req.query.search + '.*', $options: "i"}},
                                // {'document.projectName': {$regex: '.*' + req.query.search + '.*', $options: "i"}},
                            ]
                        }
                    ]
                }
            },
            {
                $replaceRoot: {newRoot: "$document"}
            },
            {
                $sort: {
                    [sortBy]: sortType
                }
            },
        ]);

Body:
Next time please add a sample of your document so people can reproduce your problem. Having said that I don't see where your problem is. I created some data to reproduce your usecase. So I added the following document:

{
    "_id" : ObjectId("5a0d5d376c9b762a7c035ec4"),
    "projectName" : "some stack test",
    "price" : NumberInt(45),
    "propertyId" : {
        "prefix" : "a",
        "number" : "7"
    }
}

Then I executed your script (without the sort) and it works fine:

db.yourCollectionName.aggregate([
    {
        $project: {
            "projectName": 1,
            "price": 1,
            "document": '$$ROOT'
        }
    },
    {
        $addFields: {
            "document.id": {
                $concat: ['$document.propertyId.prefix', '$document.propertyId.number']
            }
        }
    },
    {
        $match: {
            $and: [{
                $or: [{
                        "projectName": {
                            $regex: '.*' + "some stack test"
                        }
                    },

                    {
                        "document.id": {
                            $regex: '.*' + "a" + '.*',
                            $options: "7"
                        }
                    }
                ]
            }]

        }
    },
    {
        $replaceRoot: {
            newRoot: "$document"
        }
    }
])

The fact that you get no results is probably due to your request parameters. Besides how can the "projectName"have the same search parameters as your "document.id" Do they even match?
Check your match pipeline again:

{"projectName": {$regex: '.*' + req.query.search + '.*', $options: "i"}},
{'document.id': {$regex: '.*' + req.query.search + '.*', $options: "i"}}


问:
Simple Hello World program for OpenWRT
I am trying to learn OpenWRT.
I have downloaded the sdk.
Created a simple helloworld.cpp file inside the packages\helloworld folder
created the following Makefile inside the packages\helloworld

Makefile

```<code>include $(TOPDIR)/rules.mk
PKG_NAME:=helloworld
PKG_RELEASE:=1

PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/helloworld
    SECTION:=utils
    CATEGORY:=Utilities
    TITLE:=Helloworld -- prints a snarky message
    Package/PKG_NAME/description:=\
    If you can't figure out what this program does, \\\
    you're probably brain-dead and need immediate \\\
    medical attention.
endef

define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Package/helloworld/install
    $(INSTALL_DIR) $(1)/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef

$(eval $(call BuildPackage,helloworld))
</code>```

After that I ran make command from the sdk root

I am getting the following error

```<code>> naro_uClibc-0.9.33.2$ make V=s make[1]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> make[2]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> make[3]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/helloworld' CFLAGS="-O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts
> -Wno-error=unused-but-set-variable  -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/include " CXXFLAGS="-O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts
> -Wno-error=unused-but-set-variable  -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/include "
> LDFLAGS="-L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/lib
> -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/lib -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/lib -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/lib " make -j1 -C
> /home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.
> AR=i486-openwrt-linux-uclibc-ar AS="ccache_cc -c -O2 -pipe -march=i486
> -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable" LD=i486-openwrt-linux-uclibc-ld NM=i486-openwrt-linux-uclibc-nm
> CC="ccache_cc" GCC="ccache_cc" CXX="ccache_cxx"
> RANLIB=i486-openwrt-linux-uclibc-ranlib
> STRIP=i486-openwrt-linux-uclibc-strip
> OBJCOPY=i486-openwrt-linux-uclibc-objcopy
> OBJDUMP=i486-openwrt-linux-uclibc-objdump
> SIZE=i486-openwrt-linux-uclibc-size CROSS="i486-openwrt-linux-uclibc-"
> ARCH="i386" ; make[4]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld'
> make[4]: *** Notargets specified and no makefile found.  Stop.
> make[4]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld'
> Makefile:32: recipe for target
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.built'
> failed make[3]: ***
> [/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.built]
> Error 2 make[3]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/helloworld' package/Makefile:105: recipe for target 'package/helloworld/compile'
> failed make[2]: *** [package/helloworld/compile] Error 2 make[2]:
> Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> package/Makefile:101: recipe for target
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/stamp/.package_compile' failed make[1]: ***
> [/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/stamp/.package_compile] Error 2 make[1]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> /home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/include/toplevel.mk:144:
> recipe for target 'world' failed make: *** [world] Error 2
</code>```

Can anyone please help me to find out what is the error?

答:
I also added own package in openwrt, and this is my Makefile refer this. I hope this will helps.</p>

```<code>include $(TOPDIR)/rules.mk

PKG_NAME:=viva
PKG_VERSION:=1.4
PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_MAINTAINER:=Vishal <yourname@domain.for.your.name>
PKG_LICENSE:=ISC

include $(INCLUDE_DIR)/package.mk

define Package/viva/default
  CATEGORY:=Network
  SUBMENU:=Web Servers/Proxies
  TITLE:=Webpage for package creation
endef

define Package/viva
  $(Package/viva/default)
  DEPENDS:=+uhttpd
endef

define Package/viva/description
    A web page used for illustrating package creation
endef

define Package/viva/install
    $(CP) ./files/* $(1)/
endef

define Build/Compile
    true
endef

$(eval $(call BuildPackage,viva))
</code>```

Title: Simple Hello World program for OpenWRT

Body:
I am trying to learn OpenWRT.
I have downloaded the sdk.
Created a simple helloworld.cpp file inside the packages\helloworld folder
created the following Makefile inside the packages\helloworld

Makefile

include $(TOPDIR)/rules.mk
PKG_NAME:=helloworld
PKG_RELEASE:=1

PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/helloworld
    SECTION:=utils
    CATEGORY:=Utilities
    TITLE:=Helloworld -- prints a snarky message
    Package/PKG_NAME/description:=\
    If you can't figure out what this program does, \\\
    you're probably brain-dead and need immediate \\\
    medical attention.
endef

define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Package/helloworld/install
    $(INSTALL_DIR) $(1)/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef

$(eval $(call BuildPackage,helloworld))

After that I ran make command from the sdk root

I am getting the following error

> naro_uClibc-0.9.33.2$ make V=s make[1]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> make[2]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> make[3]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/helloworld' CFLAGS="-O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts
> -Wno-error=unused-but-set-variable  -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/include " CXXFLAGS="-O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts
> -Wno-error=unused-but-set-variable  -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/include
> -I/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/include "
> LDFLAGS="-L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/usr/lib
> -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/lib -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/usr/lib -L/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-i386_gcc-4.6-linaro_uClibc-0.9.33.2/lib " make -j1 -C
> /home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.
> AR=i486-openwrt-linux-uclibc-ar AS="ccache_cc -c -O2 -pipe -march=i486
> -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable" LD=i486-openwrt-linux-uclibc-ld NM=i486-openwrt-linux-uclibc-nm
> CC="ccache_cc" GCC="ccache_cc" CXX="ccache_cxx"
> RANLIB=i486-openwrt-linux-uclibc-ranlib
> STRIP=i486-openwrt-linux-uclibc-strip
> OBJCOPY=i486-openwrt-linux-uclibc-objcopy
> OBJDUMP=i486-openwrt-linux-uclibc-objdump
> SIZE=i486-openwrt-linux-uclibc-size CROSS="i486-openwrt-linux-uclibc-"
> ARCH="i386" ; make[4]: Entering directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld'
> make[4]: *** Notargets specified and no makefile found.  Stop.
> make[4]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld'
> Makefile:32: recipe for target
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.built'
> failed make[3]: ***
> [/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/build_dir/target-i386_uClibc-0.9.33.2/helloworld/.built]
> Error 2 make[3]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/package/helloworld' package/Makefile:105: recipe for target 'package/helloworld/compile'
> failed make[2]: *** [package/helloworld/compile] Error 2 make[2]:
> Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> package/Makefile:101: recipe for target
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/stamp/.package_compile' failed make[1]: ***
> [/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-i386_uClibc-0.9.33.2/stamp/.package_compile] Error 2 make[1]: Leaving directory
> '/home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2'
> /home/sukesh/Desktop/SDK/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/include/toplevel.mk:144:
> recipe for target 'world' failed make: *** [world] Error 2

Can anyone please help me to find out what is the error?

Body:
I also added own package in openwrt, and this is my Makefile refer this. I hope this will helps.

include $(TOPDIR)/rules.mk

PKG_NAME:=viva
PKG_VERSION:=1.4
PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_MAINTAINER:=Vishal <yourname@domain.for.your.name>
PKG_LICENSE:=ISC

include $(INCLUDE_DIR)/package.mk

define Package/viva/default
  CATEGORY:=Network
  SUBMENU:=Web Servers/Proxies
  TITLE:=Webpage for package creation
endef

define Package/viva
  $(Package/viva/default)
  DEPENDS:=+uhttpd
endef

define Package/viva/description
    A web page used for illustrating package creation
endef

define Package/viva/install
    $(CP) ./files/* $(1)/
endef

define Build/Compile
    true
endef

$(eval $(call BuildPackage,viva))


问:
Unable to filter DataFrame using Window function in Spark
I try to use a logical expression based on a window-function to detect duplicate records:

```<code>df
.where(count("*").over(Window.partitionBy($"col1",$"col2"))>lit(1))
.show
</code>```

this gives in Spark 2.1.1:

```<code>java.lang.ClassCastException: org.apache.spark.sql.catalyst.plans.logical.Project cannot be cast to org.apache.spark.sql.catalyst.plans.logical.Aggregate
</code>```

on the other hand, it works if i assign the result of the window-function to a new column and then filter that column:

```<code>df
.withColumn("count", count("*").over(Window.partitionBy($"col1",$"col2"))
.where($"count">lit(1)).drop($"count")
.show
</code>```

I wonder how I can write this without using an temporary column?

答:
I guess window functions cannot be used within the filter. You have to create an additional column and filter this one.

What you could do is to draw the window function into the select.

```<code>df.select(col("1"), col("2"), lag(col("2"), 1).over(window).alias("2_lag"))).filter(col("2_lag")==col("2"))
</code>```

Then you have it in one statement.

Body:
I try to use a logical expression based on a window-function to detect duplicate records:

df
.where(count("*").over(Window.partitionBy($"col1",$"col2"))>lit(1))
.show

this gives in Spark 2.1.1:

java.lang.ClassCastException: org.apache.spark.sql.catalyst.plans.logical.Project cannot be cast to org.apache.spark.sql.catalyst.plans.logical.Aggregate

on the other hand, it works if i assign the result of the window-function to a new column and then filter that column:

df
.withColumn("count", count("*").over(Window.partitionBy($"col1",$"col2"))
.where($"count">lit(1)).drop($"count")
.show

I wonder how I can write this without using an temporary column?

Body:
I guess window functions cannot be used within the filter. You have to create an additional column and filter this one.

What you could do is to draw the window function into the select.

df.select(col("1"), col("2"), lag(col("2"), 1).over(window).alias("2_lag"))).filter(col("2_lag")==col("2"))

Then you have it in one statement.


问:
Code Golf: Countdown Number Game

Challenge

Here is the task, inspired by the well-known British TV game show Countdown. The challenge should be pretty clear even without any knowledge of the game, but feel free to ask for clarifications.

And if you fancy seeing a clip of this game in action, check out this YouTube clip. It features the wonderful late Richard Whitely in 1997.

You are given 6 numbers, chosen at random from the set {1, 2, 3, 4, 5, 6, 8, 9, 10, 25, 50, 75, 100}, and a random target number between 100 and 999. The aim is to use the six given numbers and the four common arithmetic operations (addition, subtraction, multiplication, division; all over the rational numbers) to generate the target - or as close as possible either side. Each number may only be used once at most, while each arithmetic operator may be used any number of times (including zero.) Note that it does not matter how many numbers are used.

Write a function that takes the target number and set of 6 numbers (can be represented as list/collection/array/sequence) and returns the solution in any standard numerical notation (e.g. infix, prefix, postfix). The function must always return the closest-possible result to the target, and must run in at most 1 minute on a standard PC. Note that in the case where more than one solution exists, any single solution is sufficient.

Examples:

{50, 100, 4, 2, 2, 4}, target 203

e.g. 100 * 2 + 2 + (4 / 4) (exact)

e.g. (100 + 50) * 4 * 2 / (4 + 2) (exact)

{25, 4, 9, 2, 3, 10}, target 465

e.g. (25 + 10 - 4) * (9 * 2 - 3) (exact)

{9, 8, 10, 5, 9, 7}, target 241

e.g. ((10 + 9) * 9 * 7) + 8) / 5 (exact)

{3, 7, 6, 2, 1, 7}, target 824

e.g. ((7 * 3) - 1) * 6 - 2) * 7 (= 826; off by 2)

Rules

Other than mentioned in the problem statement, there are no further restrictions. You may write the function in any standard language (standard I/O is not necessary). The aim as always is to solve the task with the smallest number of characters of code.

Saying that, I may not simply accept the answer with the shortest code. I'll also be looking at elegance of the code and time complexity of the algorithm!

My Solution

I'm attempting an F# solution when I find the free time - will post it here when I have something!

Format

Please post all answers in the following format for the purpose of easy comparison:

Language

Number of characters: ???

Fully obfuscated function:

```<code>(code here)
</code>```

Clear (ideally commented) function:

```<code>(code here)
</code>```

Any notes on the algorithm/clever shortcuts it takes.

答:
Ruby 1.9.2 second attempt

Number of characters: 492 440(426)

Again there is a problem with the non-exact answer.  This time this is easily fast enough but for some reason the closest it gets to 824 is 819 instead of 826.

I decided to put this in a new answer since it is using a very different method to my last attempt.

Removing the total of the output (as its not required by spec) is -14 characters.

Fully Obfuscated

```<code>def r d,c;d>4?[0]:(k=c.pop;a=[];r(d+1,c).each{|b|a<<[b,k,nil];a<<[nil,k,b]};a)end
def f t,n;[0,2].each{|a|Array===t[a] ?f(t[a],n): t[a]=n.pop}end
def d t;Float===t ?t:d(t[0]).send(t[1],d(t[2]))end
def o c;Float===c ?c.round: "(#{o c[0]}#{c[1]}#{o c[2]})"end
w=a=%w{+ - * /}
4.times{w=w.product a}
*n,l=$<.each(' ').map(&:to_f)
h={}
w.each{|y|r(0,y.flatten).each{|t|f t,n.dup;h[d t]=o t}}
puts h[k=h.keys.min_by{|i|(l-i).abs}]+"=#{k.round}"
</code>```

Decoded

```<code>Coming soon
</code>```

Test script

```<code>#!/usr/bin/env ruby
[
  [[50,100,4,2,2,4],203],
  [[25,4,9,2,3,10],465],
  [[9,8,10,5,9,7],241],
  [[3,7,6,2,1,7],824]
].each do |b|
  start = Time.now
  puts "{[#{b[0]*', '}] #{b[1]}}  gives #{`echo "#{b[0]*' '} #{b[1]}" | ruby count-golf.rb`.strip} in #{Time.now-start}"
end
</code>```

Output

```<code>→ ./test.rb
{[50, 100, 4, 2, 2, 4] 203}  gives ((4-((2-(2*4))/100))*50)=203 in 1.089726252
{[25, 4, 9, 2, 3, 10] 465}  gives ((10*(((3+2)*9)+4))-25)=465 in 1.039455671
{[9, 8, 10, 5, 9, 7] 241}  gives (7+(((9/(5/10))+8)*9))=241 in 1.045774539
{[3, 7, 6, 2, 1, 7] 824}  gives ((((7-(1/2))*6)*7)*3)=819 in 1.012330419
</code>```

Details

This constructs the set of ternary trees representing all possible combinations of 5 operators.  It then goes through and inserts all permutations of the input numbers into the leaves of these trees.  Finally it simply iterates through these possible equations storing them into a hash with the result as index.  Then it's easy enough to pick the closest value to the required answer from the hash and display it.

Title: Code Golf: Countdown Number Game

Body:
Challenge

Here is the task, inspired by the well-known British TV game show Countdown. The challenge should be pretty clear even without any knowledge of the game, but feel free to ask for clarifications.

And if you fancy seeing a clip of this game in action, check out this YouTube clip. It features the wonderful late Richard Whitely in 1997.

You are given 6 numbers, chosen at random from the set {1, 2, 3, 4, 5, 6, 8, 9, 10, 25, 50, 75, 100}, and a random target number between 100 and 999. The aim is to use the six given numbers and the four common arithmetic operations (addition, subtraction, multiplication, division; all over the rational numbers) to generate the target - or as close as possible either side. Each number may only be used once at most, while each arithmetic operator may be used any number of times (including zero.) Note that it does not matter how many numbers are used.

Write a function that takes the target number and set of 6 numbers (can be represented as list/collection/array/sequence) and returns the solution in any standard numerical notation (e.g. infix, prefix, postfix). The function must always return the closest-possible result to the target, and must run in at most 1 minute on a standard PC. Note that in the case where more than one solution exists, any single solution is sufficient.

Examples:

{50, 100, 4, 2, 2, 4}, target 203

e.g. 100 * 2 + 2 + (4 / 4) (exact)

e.g. (100 + 50) * 4 * 2 / (4 + 2) (exact)

{25, 4, 9, 2, 3, 10}, target 465

e.g. (25 + 10 - 4) * (9 * 2 - 3) (exact)

{9, 8, 10, 5, 9, 7}, target 241

e.g. ((10 + 9) * 9 * 7) + 8) / 5 (exact)

{3, 7, 6, 2, 1, 7}, target 824

e.g. ((7 * 3) - 1) * 6 - 2) * 7 (= 826; off by 2)

Rules

Other than mentioned in the problem statement, there are no further restrictions. You may write the function in any standard language (standard I/O is not necessary). The aim as always is to solve the task with the smallest number of characters of code.

Saying that, I may not simply accept the answer with the shortest code. I'll also be looking at elegance of the code and time complexity of the algorithm!

My Solution

I'm attempting an F# solution when I find the free time - will post it here when I have something!

Format

Please post all answers in the following format for the purpose of easy comparison:

Language

Number of characters: ???

Fully obfuscated function:

(code here)

Clear (ideally commented) function:

(code here)

Any notes on the algorithm/clever shortcuts it takes.

Body:
Ruby 1.9.2 second attempt

Number of characters: 492 440(426)

Again there is a problem with the non-exact answer.  This time this is easily fast enough but for some reason the closest it gets to 824 is 819 instead of 826.

I decided to put this in a new answer since it is using a very different method to my last attempt.

Removing the total of the output (as its not required by spec) is -14 characters.

Fully Obfuscated

def r d,c;d>4?[0]:(k=c.pop;a=[];r(d+1,c).each{|b|a<<[b,k,nil];a<<[nil,k,b]};a)end
def f t,n;[0,2].each{|a|Array===t[a] ?f(t[a],n): t[a]=n.pop}end
def d t;Float===t ?t:d(t[0]).send(t[1],d(t[2]))end
def o c;Float===c ?c.round: "(#{o c[0]}#{c[1]}#{o c[2]})"end
w=a=%w{+ - * /}
4.times{w=w.product a}
*n,l=$<.each(' ').map(&:to_f)
h={}
w.each{|y|r(0,y.flatten).each{|t|f t,n.dup;h[d t]=o t}}
puts h[k=h.keys.min_by{|i|(l-i).abs}]+"=#{k.round}"

Decoded

Coming soon

Test script

#!/usr/bin/env ruby
[
  [[50,100,4,2,2,4],203],
  [[25,4,9,2,3,10],465],
  [[9,8,10,5,9,7],241],
  [[3,7,6,2,1,7],824]
].each do |b|
  start = Time.now
  puts "{[#{b[0]*', '}] #{b[1]}}  gives #{`echo "#{b[0]*' '} #{b[1]}" | ruby count-golf.rb`.strip} in #{Time.now-start}"
end

Output

→ ./test.rb
{[50, 100, 4, 2, 2, 4] 203}  gives ((4-((2-(2*4))/100))*50)=203 in 1.089726252
{[25, 4, 9, 2, 3, 10] 465}  gives ((10*(((3+2)*9)+4))-25)=465 in 1.039455671
{[9, 8, 10, 5, 9, 7] 241}  gives (7+(((9/(5/10))+8)*9))=241 in 1.045774539
{[3, 7, 6, 2, 1, 7] 824}  gives ((((7-(1/2))*6)*7)*3)=819 in 1.012330419

Details

This constructs the set of ternary trees representing all possible combinations of 5 operators.  It then goes through and inserts all permutations of the input numbers into the leaves of these trees.  Finally it simply iterates through these possible equations storing them into a hash with the result as index.  Then it's easy enough to pick the closest value to the required answer from the hash and display it.


问:
House price prediction using Neural Network- network not learning
I am using pybrain to predict house prices in the house price dataset. I downloaded the dataset from below link:
https://www.kaggle.com/apratim87/housingdata/data

I picked 6 columns to predict the price
    'bedrooms','bathrooms','sqft_living','sqft_lot','floors','zipcode'

I took a neural network with 6 input units,1 hidden layer with 3 neurons and 1 unit in the output.

I have normalized the data. Code is as below:

```<code> house_df = pd.read_csv("kc_house_data.csv")
 print(house_df.head())
df = house_df.dropna(axis=0)
df = df[(df != 0).all(1)]
df.reset_index(drop=True,inplace=True)
X_org=house_df[['bedrooms','bathrooms','sqft_living','sqft_lot','floors','zipcode']]
y_org=house_df[['price']]

scaler = Normalizer().fit(X_org)
X = scaler.transform(X_org)
target_scaler = preprocessing.MinMaxScaler()
y=target_scaler.fit_transform(y_org)

ds=SupervisedDataSet(X.shape[1],y.shape[1])
for i in range(len(X)):
    ds.addSample(X.iloc[i,:].values,y.iloc[i,:].values)

train,rest=ds.splitWithProportion(0.60)
test,validation=rest.splitWithProportion(0.50)

print('Training Set Size='+str(len(train)))
print('Test Set Size='+str(len(test)))
print('Validation Set Size='+str(len(validation)))

#creating a neural network
def buildNN(invar,hidden,out):
    net=buildNetwork(invar,hidden,out,hiddenclass=SigmoidLayer,outclass=SoftmaxLayer)
    trainer=BackpropTrainer(net,dataset=train,momentum=0.1,verbose=True,weightdecay=0.01)
    trn_err,val_err=trainer.trainUntilConvergence(dataset=train,maxEpochs=50)

    #trainer.trainOnDataset(trndata,500)
    tst,=plt.plot(trn_err,'b',label='Test Error')
    vali,=plt.plot(val_err,'r',label='Validation Error')
    plt.legend(handles=[tst, vali])
    plt.ylabel('Error')
    plt.xlabel('Number of Epochs')
    plt.show()
     #testing it on test data
     out=net.activateOnDataset(test).argmax(axis=1)
    test_error=percentError(out,test['price'])
    #on validation data
    out=net.activateOnDataset(validation).argmax(axis=1)
    vali_error=percentError(out,validation['price'])
    return  test_error,vali_error

print('Neaural network with 6 input, 3 hidden units, 1 output')
nn3_testerr,nn3_valierr=buildNN(6,3,1)
</code>```

I get constant error and my program is not learning. Can you please suggest what might be the issue?

Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278

答: Ideally, you need to have two dense layers and a higher number of neurons per each layer. Another important point to note is mean normalization of your feature matrix. Instead of Sigmoid, Try Relu or Elu as the activation function.</p>

Body:
I am using pybrain to predict house prices in the house price dataset. I downloaded the dataset from below link:
https://www.kaggle.com/apratim87/housingdata/data

I picked 6 columns to predict the price
    'bedrooms','bathrooms','sqft_living','sqft_lot','floors','zipcode'

I took a neural network with 6 input units,1 hidden layer with 3 neurons and 1 unit in the output.

I have normalized the data. Code is as below:

 house_df = pd.read_csv("kc_house_data.csv")
 print(house_df.head())
df = house_df.dropna(axis=0)
df = df[(df != 0).all(1)]
df.reset_index(drop=True,inplace=True)
X_org=house_df[['bedrooms','bathrooms','sqft_living','sqft_lot','floors','zipcode']]
y_org=house_df[['price']]

scaler = Normalizer().fit(X_org)
X = scaler.transform(X_org)
target_scaler = preprocessing.MinMaxScaler()
y=target_scaler.fit_transform(y_org)

ds=SupervisedDataSet(X.shape[1],y.shape[1])
for i in range(len(X)):
    ds.addSample(X.iloc[i,:].values,y.iloc[i,:].values)

train,rest=ds.splitWithProportion(0.60)
test,validation=rest.splitWithProportion(0.50)

print('Training Set Size='+str(len(train)))
print('Test Set Size='+str(len(test)))
print('Validation Set Size='+str(len(validation)))

#creating a neural network
def buildNN(invar,hidden,out):
    net=buildNetwork(invar,hidden,out,hiddenclass=SigmoidLayer,outclass=SoftmaxLayer)
    trainer=BackpropTrainer(net,dataset=train,momentum=0.1,verbose=True,weightdecay=0.01)
    trn_err,val_err=trainer.trainUntilConvergence(dataset=train,maxEpochs=50)

    #trainer.trainOnDataset(trndata,500)
    tst,=plt.plot(trn_err,'b',label='Test Error')
    vali,=plt.plot(val_err,'r',label='Validation Error')
    plt.legend(handles=[tst, vali])
    plt.ylabel('Error')
    plt.xlabel('Number of Epochs')
    plt.show()
     #testing it on test data
     out=net.activateOnDataset(test).argmax(axis=1)
    test_error=percentError(out,test['price'])
    #on validation data
    out=net.activateOnDataset(validation).argmax(axis=1)
    vali_error=percentError(out,validation['price'])
    return  test_error,vali_error

print('Neaural network with 6 input, 3 hidden units, 1 output')
nn3_testerr,nn3_valierr=buildNN(6,3,1)

I get constant error and my program is not learning. Can you please suggest what might be the issue?

Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278
Total error:  0.441892335278


问:
Can't find the function url for Firebase webhook in Google Assistant tutorial
I've been doing the Codelabs tutorial on "Facts about You: Build a conversational app for the Google Assistant" but have run into a problem.

Page 4 of the tutorial is devoted to using Cloud Functions for Firebase for setting up a webhook to provide custom responses. Step 7 on that page says "Once the Cloud Functions is deployed, the Function URL will be printed in the Firebase CLI logs. This URL is separate from the Project Console URL.”

My problem is that I only see the Console URL. I don’t see a Function URL anywhere.

Can anyone please clarify where I should find the Function URL? My app won’t run properly without knowing the endpoint URL for the webhoook.

Thanks!

答:
I ran into the same problem.

It works when I deploy the file from here.

After comparing with my own file, I realized that missed two lines in failed case:

```<code>const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
</code>```

Body:
I ran into the same problem.

It works when I deploy the file from here.

After comparing with my own file, I realized that missed two lines in failed case:

const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);


问:
Counting number of characters in loaded file in textarea?
I can count number of characters when I'm typing in textarea

function count_up(obj){
  document.getElementById('numbers').innerHTML = obj.value.length;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><textarea name="textField" class="text_edit" id="my_text"  onkeyup="count_up(this);"></textarea><br/>
<span id="numbers">0</span></code>```

but I want to count number of characters in file when I load it to textarea. This function is ok, but I must add something to loaded text if I want to count characters in my file(it's
unintuitive). Can I do something to fix it?

答:
textarea {
        width: 100%;
        height: 150px;
        padding: 12px 20px;
        box-sizing: border-box;
        border: 2px solid #ccc;
        border-radius: 4px;
        background-color: #f8f8f8;
        font-size: 16px;
        resize: none;
    }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><textarea name="" id="" cols="30" rows="10"  onkeyup="countCharToMax(this)"></textarea>
        <div id="charNum">0/30</div>

    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script>
        function countCharToMax(val) {
            var max = 30;
            var min = 0;
            var len = val.value.length;
            if (len >= max) {
                val.value = val.value.substring(min, max);
                $('#charNum').text(len + '/'+max);
            } else {
                $('#charNum').text(len + '/'+max);

            }
        };
    </script></code>```

Body:
I can count number of characters when I'm typing in textarea

function count_up(obj){
  document.getElementById('numbers').innerHTML = obj.value.length;
}

<textarea name="textField" class="text_edit" id="my_text"  onkeyup="count_up(this);"></textarea>

0

but I want to count number of characters in file when I load it to textarea. This function is ok, but I must add something to loaded text if I want to count characters in my file(it's
unintuitive). Can I do something to fix it?

Body:
textarea {
        width: 100%;
        height: 150px;
        padding: 12px 20px;
        box-sizing: border-box;
        border: 2px solid #ccc;
        border-radius: 4px;
        background-color: #f8f8f8;
        font-size: 16px;
        resize: none;
    }

<textarea name="" id="" cols="30" rows="10"  onkeyup="countCharToMax(this)"></textarea>
        <div id="charNum">0/30</div>

    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script>
        function countCharToMax(val) {
            var max = 30;
            var min = 0;
            var len = val.value.length;
            if (len >= max) {
                val.value = val.value.substring(min, max);
                $('#charNum').text(len + '/'+max);
            } else {
                $('#charNum').text(len + '/'+max);

            }
        };
    </script>


问:
Getting the field of an object
I have objects like below

```<code>{
"user": "58a9bf92e0f78000055dd932",
"type": "template_created",
"count": 2
}
</code>```

I need to get 'user' field, ..->type returns "template_created" and ..->count gives its value but ..->user returns null. These objects come from mongodb aggregation framework by the way.

答:
It looks, like your objects are json-encoded. This means, you can use the native php functions json_encode() and json_decode() to process them. In your example, you can deserialize the object by calling

```<code>$obj = json_decode($str);
</code>```

with $str being the data you show above. Now you can access the fields of this object with standard php access methods like

```<code>$type = $obj->type;
</code>```

Hope this helps!

Title: Getting the field of an object

Body:
I have objects like below

{
"user": "58a9bf92e0f78000055dd932",
"type": "template_created",
"count": 2
}

I need to get 'user' field, ..->type returns "template_created" and ..->count gives its value but ..->user returns null. These objects come from mongodb aggregation framework by the way.

Body:
It looks, like your objects are json-encoded. This means, you can use the native php functions json_encode() and json_decode() to process them. In your example, you can deserialize the object by calling

$obj = json_decode($str);

with $str being the data you show above. Now you can access the fields of this object with standard php access methods like

$type = $obj->type;

Hope this helps!


问:
Odoo doesn't show the field label in xpath
I'm adding a custom string field (stock_value) to the 'product.supplierinfo' module in Odoo enterprise 11 but I can't get it to display the label correctly.

I inherited the module and then added a new field to the module and to the view trough xpath.

Problem: the string related to the new field is not shown.

Module:

```<code>class class_name(models.Model):
    _inherit                        = 'product.supplierinfo'
    stock_value                     = fields.Integer(string="Stock")
</code>```

View:

```<code><!-- Stock value in the vendors -->
<record id="view_product_product_supplierinfo_form_view" model="ir.ui.view">
    <field name="name">product.supplierinfo.product.form</field>
    <field name="model">product.supplierinfo</field>
    <field name="inherit_id" ref="product.product_supplierinfo_form_view"/>
    <field name="arch" type="xml">
    <xpath expr="//field[@name='price']" position="after">
        <field name="stock_value" />
    </xpath>
    </field>
</record>
</code>```

Result: as you can see theres a zero bellow the price value but the string label 'Stock' is not shown.

Other thing is tried:

Adding the next code:

```<code><separator />
<label for="stock_value" string="Stock Value"/>
</code>```

Gives me

Putting the field inside a group gives me

I also tried changing the position to 'before' in this last view but I cannot manage to make it look as it should. I tried using @string but that no longer works.

Thank you in advantage for your help.

答:
The problem is that the field price is inside a div container, so you have to put your field after this div (which is the parent of the field price in the DOM). Thus, you have to tell xpath that you want to put your field after the DOM parent of the field price, not just after the field as you have in your code. Depending on the style you are looking for, you can select any of the following options:

Option 1 (you could add class="oe_inline to your field too"):

```<code><!-- Stock value in the vendors -->
<record id="view_product_product_supplierinfo_form_view" model="ir.ui.view">
    <field name="name">product.supplierinfo.product.form</field>
    <field name="model">product.supplierinfo</field>
    <field name="inherit_id" ref="product.product_supplierinfo_form_view"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='price']/.." position="after">
            <label for="stock_value"/>
            <div>
                <field name="stock_value"/>
            </div>
        </xpath>
    </field>
</record>
</code>```

Option 2:

```<code><!-- Stock value in the vendors -->
<record id="view_product_product_supplierinfo_form_view" model="ir.ui.view">
    <field name="name">product.supplierinfo.product.form</field>
    <field name="model">product.supplierinfo</field>
    <field name="inherit_id" ref="product.product_supplierinfo_form_view"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='price']/.." position="after">
            <field name="stock_value"/>
        </xpath>
    </field>
</record>
</code>```

Body:
I'm adding a custom string field (stock_value) to the 'product.supplierinfo' module in Odoo enterprise 11 but I can't get it to display the label correctly.

I inherited the module and then added a new field to the module and to the view trough xpath.

Problem: the string related to the new field is not shown.

Module:

class class_name(models.Model):
    _inherit                        = 'product.supplierinfo'
    stock_value                     = fields.Integer(string="Stock")

View:

<record id="view_product_product_supplierinfo_form_view" model="ir.ui.view">
    <field name="name">product.supplierinfo.product.form</field>
    <field name="model">product.supplierinfo</field>
    <field name="inherit_id" ref="product.product_supplierinfo_form_view"/>
    <field name="arch" type="xml">
    <xpath expr="//field[@name='price']" position="after">
        <field name="stock_value" />
    </xpath>
    </field>
</record>

Result: as you can see theres a zero bellow the price value but the string label 'Stock' is not shown.

Other thing is tried:

Adding the next code:

<separator />

Gives me

Putting the field inside a group gives me

I also tried changing the position to 'before' in this last view but I cannot manage to make it look as it should. I tried using @string but that no longer works.

Thank you in advantage for your help.

Body:
The problem is that the field price is inside a div container, so you have to put your field after this div (which is the parent of the field price in the DOM). Thus, you have to tell xpath that you want to put your field after the DOM parent of the field price, not just after the field as you have in your code. Depending on the style you are looking for, you can select any of the following options:

Option 1 (you could add class="oe_inline to your field too"):

<!-- Stock value in the vendors -->
<record id="view_product_product_supplierinfo_form_view" model="ir.ui.view">
    <field name="name">product.supplierinfo.product.form</field>
    <field name="model">product.supplierinfo</field>
    <field name="inherit_id" ref="product.product_supplierinfo_form_view"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='price']/.." position="after">
            <label for="stock_value"/>
            <div>
                <field name="stock_value"/>
            </div>
        </xpath>
    </field>
</record>

Option 2:

<!-- Stock value in the vendors -->
<record id="view_product_product_supplierinfo_form_view" model="ir.ui.view">
    <field name="name">product.supplierinfo.product.form</field>
    <field name="model">product.supplierinfo</field>
    <field name="inherit_id" ref="product.product_supplierinfo_form_view"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='price']/.." position="after">
            <field name="stock_value"/>
        </xpath>
    </field>
</record>


问:
How to get a Control byId from a SAPUI5 Fragment
I have a dialog which is in a Fragment. So after entering the details into it and clicking the submit button, the text which was filled into the input should be displayed as a MessageToast. But I am getting the error : ' Cannot read property 'getValue' of undefined '.

Below is the code :

```<code>    onAddMovie: function() {
        var view = this.getView();
        var createDialog = view.byId("CreateDialog");
        var oDummyController = {
            // This is when I clicked the Submit button in dialog
            submitDialog: function() {
            var user = sap.ui.core.Fragment.byId("createDialog", "movie_name").getValue();
                MessageToast.show(user);
                createDialog.close();
            },
            closeDialog: function() {
                createDialog.close();
            }
        };

        if (!createDialog) {
            createDialog = sap.ui.xmlfragment(view.getId(), "Admin.view.Dialog", oDummyController);
        }
        view.addDependent(createDialog);
        createDialog.open();
        if (!createDialog.isOpen()) {
            //do sth
        }
    },
</code>```

Above is the function in which the dialog is getting displayed and after pressing submit button , the text in the input should be displayed in a MessageToast.

XML :

```<code>        <core:FragmentDefinition  xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:l="sap.ui.layout">

        <Dialog id="createDialog" title="Input Movie Details" width="100%" class="sapuiMediumMargin" confirm="handleClose" close="handleClose">
            <l:VerticalLayout class="sapUiContentPadding" width="100%">
            <l:content>
                <Input width="100%" placeholder="Movie Name" id="movie_name"/>
                <HBox alignItems="Center" renderType="Bare">
                    <Label text="Year of Release" width="50%"/>
                    <ActionSelect selectedItem="Element sap.ui.core.ListItem#__item0" selectedKey="item1" class="sapUiLargeMarginBegin" selectedItemId="__item0" id="__select0" width="50%">
                        <items>
                            <core:ListItem text="2017" key="item1" id="__item0"/>
                            <core:ListItem text="2016" key="item2" id="__item1"/>
                            <core:ListItem text="2015" key="item3" id="__item2"/></items>
                    </ActionSelect>
                </HBox>
                <HBox alignItems="Center" renderType="Bare">
                    <Label text="Date of Screening" width="50%"/>
                    <DatePicker class="sapUiLargeMarginBegin" width="50%" id="__picker0"/>
                </HBox>
                <HBox alignItems="Center">
                    <Label text="Movie Rating"/>
                    <RadioButtonGroup width="100%" columns="3" selectedIndex="-1" id="__group0">
                        <buttons>
                            <RadioButton selected="true" groupName="__group0" text="Universal" id="__button0"/>
                            <RadioButton groupName="__group0" text="Adult" id="__button1"/>
                            <RadioButton groupName="__group0" text="U/A" id="__button2"/></buttons>
                    </RadioButtonGroup>
                </HBox>
                        <HBox alignItems="Center" width="100%" renderType="Bare">
                    <Label text="Enable Booking" width="70%"/>
                <CheckBox id="__box0" width="30%" textDirection="LTR"/>
            </HBox>
                <FlexBox alignItems="End" alignContent="Center" justifyContent="End" class="sapUiTinyMarginTop">

                    <SegmentedButton selectedButton="__button3" id="__button21">
                            <buttons>
                                <Button text="Submit" id="__submit" press="submitDialog"/>
                                <Button text="Cancel" id="__button41" press="closeDialog"/></buttons>
                        </SegmentedButton>
                            </FlexBox>
                </l:content>
            </l:VerticalLayout>
        </Dialog>

    </core:FragmentDefinition>
</code>```

答:
Since you are creating the dialog with the views id

```<code>sap.ui.xmlfragment(view.getId(), "Admin.view.Dialog", oDummyController);
</code>```

all control ids in that fragment will be prefixed with the views id (this.getView().getId(), e.g. __xmlview1).

That has the big advantage that all fragment controls are accessible via this.getView().getId() and therefore really 'feel' like they were part of the view and can be treated as such (esp. useful when using fragments to structure view code).

That is why you need to use

```<code>this.getView().byId("movie_name");
</code>```

Which will end up querying for a control with an id like __xmlview1--movie_name (-- is used as separator by SAPUI5).

General Behaviour of byId methods

Generally speaking the byId methods behave like this:

```<code>this.getView().byId(sId) === sap.ui.getCore().byId(sViewId + '--' + sId));
sViewId + '--' + sId === this.getView().createId(sId)
sap.ui.core.Fragment.byId(sFragmentId, sId) === sap.ui.getCore().byId(sFragmentId + '--' + sId));
</code>```

HINT

Be aware of potential ID conflicts between the controls of your view(s) and your fragment(s)!

Body:
I have a dialog which is in a Fragment. So after entering the details into it and clicking the submit button, the text which was filled into the input should be displayed as a MessageToast. But I am getting the error : ' Cannot read property 'getValue' of undefined '.

Below is the code :

    onAddMovie: function() {
        var view = this.getView();
        var createDialog = view.byId("CreateDialog");
        var oDummyController = {
            // This is when I clicked the Submit button in dialog
            submitDialog: function() {
            var user = sap.ui.core.Fragment.byId("createDialog", "movie_name").getValue();
                MessageToast.show(user);
                createDialog.close();
            },
            closeDialog: function() {
                createDialog.close();
            }
        };

        if (!createDialog) {
            createDialog = sap.ui.xmlfragment(view.getId(), "Admin.view.Dialog", oDummyController);
        }
        view.addDependent(createDialog);
        createDialog.open();
        if (!createDialog.isOpen()) {
            //do sth
        }
    },

Above is the function in which the dialog is getting displayed and after pressing submit button , the text in the input should be displayed in a MessageToast.

XML :

        <core:FragmentDefinition  xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:l="sap.ui.layout">

        <Dialog id="createDialog" title="Input Movie Details" width="100%" class="sapuiMediumMargin" confirm="handleClose" close="handleClose">
            <l:VerticalLayout class="sapUiContentPadding" width="100%">
            <l:content>
                <Input width="100%" placeholder="Movie Name" id="movie_name"/>
                <HBox alignItems="Center" renderType="Bare">

                    <ActionSelect selectedItem="Element sap.ui.core.ListItem#__item0" selectedKey="item1" class="sapUiLargeMarginBegin" selectedItemId="__item0" id="__select0" width="50%">
                        <items>
                            <core:ListItem text="2017" key="item1" id="__item0"/>
                            <core:ListItem text="2016" key="item2" id="__item1"/>
                            <core:ListItem text="2015" key="item3" id="__item2"/></items>
                    </ActionSelect>
                </HBox>
                <HBox alignItems="Center" renderType="Bare">

                    <DatePicker class="sapUiLargeMarginBegin" width="50%" id="__picker0"/>
                </HBox>
                <HBox alignItems="Center">

                    <RadioButtonGroup width="100%" columns="3" selectedIndex="-1" id="__group0">
                        <buttons>
                            <RadioButton selected="true" groupName="__group0" text="Universal" id="__button0"/>
                            <RadioButton groupName="__group0" text="Adult" id="__button1"/>
                            <RadioButton groupName="__group0" text="U/A" id="__button2"/></buttons>
                    </RadioButtonGroup>
                </HBox>
                        <HBox alignItems="Center" width="100%" renderType="Bare">

                <CheckBox id="__box0" width="30%" textDirection="LTR"/>
            </HBox>
                <FlexBox alignItems="End" alignContent="Center" justifyContent="End" class="sapUiTinyMarginTop">

                    <SegmentedButton selectedButton="__button3" id="__button21">
                            <buttons>
                                <Button text="Submit" id="__submit" press="submitDialog"/>
                                <Button text="Cancel" id="__button41" press="closeDialog"/></buttons>
                        </SegmentedButton>
                            </FlexBox>
                </l:content>
            </l:VerticalLayout>
        </Dialog>

    </core:FragmentDefinition>

Body:
Since you are creating the dialog with the views id

sap.ui.xmlfragment(view.getId(), "Admin.view.Dialog", oDummyController);

all control ids in that fragment will be prefixed with the views id (this.getView().getId(), e.g. __xmlview1).

That has the big advantage that all fragment controls are accessible via this.getView().getId() and therefore really 'feel' like they were part of the view and can be treated as such (esp. useful when using fragments to structure view code).

That is why you need to use

this.getView().byId("movie_name");

Which will end up querying for a control with an id like __xmlview1--movie_name (-- is used as separator by SAPUI5).

General Behaviour of byId methods

Generally speaking the byId methods behave like this:

this.getView().byId(sId) === sap.ui.getCore().byId(sViewId + '--' + sId));
sViewId + '--' + sId === this.getView().createId(sId)
sap.ui.core.Fragment.byId(sFragmentId, sId) === sap.ui.getCore().byId(sFragmentId + '--' + sId));

HINT

Be aware of potential ID conflicts between the controls of your view(s) and your fragment(s)!


问:
Error importing TensorFlow GPU in Jupyter Notebook
I am trying to import TensorFlow but end up with this error.

```<code>ImportError                               Traceback (most recent call last)
/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/__init__.py in <module>()
     60     sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)
---> 61     from tensorflow.python import pywrap_tensorflow
     62     sys.setdlopenflags(_default_dlopen_flags)

/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
     27             return _mod
---> 28     _pywrap_tensorflow = swig_import_helper()
     29     del swig_import_helper

/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py in swig_import_helper()
     23             try:
---> 24                 _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
     25             finally:

/Users/Aakaash/miniconda3/lib/python3.5/imp.py in load_module(name, file, filename, details)
    241         else:
--> 242             return load_dynamic(name, filename, file)
    243     elif type_ == PKG_DIRECTORY:

/Users/Aakaash/miniconda3/lib/python3.5/imp.py in load_dynamic(name, path, file)
    341             name=name, loader=loader, origin=path)
--> 342         return _load(spec)
    343

ImportError: dlopen(/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Library not loaded: @rpath/libcudart.8.0.dylib
  Referenced from: /Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so
  Reason: image not found

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-7-a649b509054f> in <module>()
----> 1 import tensorflow

/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/__init__.py in <module>()
     22
     23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
     25 # pylint: enable=wildcard-import
     26

/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/__init__.py in <module>()
     70 for some common reasons and solutions.  Include the entire stack trace
     71 above this error message when asking for help.""" % traceback.format_exc()
---> 72   raise ImportError(msg)
     73
     74 # Protocol buffers

ImportError: Traceback (most recent call last):
  File "/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 61, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
  File "/Users/Aakaash/miniconda3/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/Users/Aakaash/miniconda3/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: dlopen(/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Library not loaded: @rpath/libcudart.8.0.dylib
  Referenced from: /Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so
  Reason: image not found

Failed to load the native TensorFlow runtime.

See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
</code>```

I am able to import the CPU Version of the TensorFlow with no issue. I am also able to import TensorFlow in Python Console launched from Terminal. The path to python executable is same in both Console and Jupyter Notebook (sys.executable gave same output in Console and Jupyter Notebook).

TensorFlow version - 1.0.0

Python Version - 3.5.2

Cuda Version - 8.0

答: In my case when starting Jupyter notebook the LD_LIBRARY_PATH was cleared even if exported it in .bashrc and .profile on Ubuntu. Only starting the notebook server with env VARIABLE=$VARIABLE jupyter notebook solved it.

Body:
I am trying to import TensorFlow but end up with this error.

ImportError                               Traceback (most recent call last)
/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/__init__.py in <module>()
     60     sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)
---> 61     from tensorflow.python import pywrap_tensorflow
     62     sys.setdlopenflags(_default_dlopen_flags)

/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
     27             return _mod
---> 28     _pywrap_tensorflow = swig_import_helper()
     29     del swig_import_helper

/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py in swig_import_helper()
     23             try:
---> 24                 _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
     25             finally:

/Users/Aakaash/miniconda3/lib/python3.5/imp.py in load_module(name, file, filename, details)
    241         else:
--> 242             return load_dynamic(name, filename, file)
    243     elif type_ == PKG_DIRECTORY:

/Users/Aakaash/miniconda3/lib/python3.5/imp.py in load_dynamic(name, path, file)
    341             name=name, loader=loader, origin=path)
--> 342         return _load(spec)
    343

ImportError: dlopen(/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Library not loaded: @rpath/libcudart.8.0.dylib
  Referenced from: /Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so
  Reason: image not found

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-7-a649b509054f> in <module>()
----> 1 import tensorflow

/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/__init__.py in <module>()
     22
     23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
     25 # pylint: enable=wildcard-import
     26

/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/__init__.py in <module>()
     70 for some common reasons and solutions.  Include the entire stack trace
     71 above this error message when asking for help.""" % traceback.format_exc()
---> 72   raise ImportError(msg)
     73
     74 # Protocol buffers

ImportError: Traceback (most recent call last):
  File "/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 61, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
  File "/Users/Aakaash/miniconda3/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/Users/Aakaash/miniconda3/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: dlopen(/Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Library not loaded: @rpath/libcudart.8.0.dylib
  Referenced from: /Users/Aakaash/miniconda3/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so
  Reason: image not found

Failed to load the native TensorFlow runtime.

See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

I am able to import the CPU Version of the TensorFlow with no issue. I am also able to import TensorFlow in Python Console launched from Terminal. The path to python executable is same in both Console and Jupyter Notebook (sys.executable gave same output in Console and Jupyter Notebook).

TensorFlow version - 1.0.0

Python Version - 3.5.2

Cuda Version - 8.0


问:
how to handle empty JSON responses?
```<code>[]
</code>```

this is the JSON response i'm getting when calling a webservice. i need to print nothing to show if the response is empty.

```<code>$http({
        method:'POST',
        url: 'http://xxxxxx',
        headers: {
           Content-Type: 'application/json',
           Accept: 'application/json'
        },
        data: JSON.stringify(x)
}).then(function (response) {
        $scope.details=response.data;
        if($scope.invoiceDetails == null){
           console.log("nothing to show");
        }
    });
</code>```

This is the code i'm using now. But it is not working. Someone please give me some suggestions.

答:
```<code>if ($scope.details.length === 0)
{
    console.log("nothing to show");
}
</code>```

Title: how to handle empty JSON responses?

Body:
[]

this is the JSON response i'm getting when calling a webservice. i need to print nothing to show if the response is empty.

$http({
        method:'POST',
        url: 'http://xxxxxx',
        headers: {
           Content-Type: 'application/json',
           Accept: 'application/json'
        },
        data: JSON.stringify(x)
}).then(function (response) {
        $scope.details=response.data;
        if($scope.invoiceDetails == null){
           console.log("nothing to show");
        }
    });

This is the code i'm using now. But it is not working. Someone please give me some suggestions.