问:
Issue with tooltip on d3 line chart
So I am trying to implement a tool tip for my line chart using Mark's answer/example from here Multiseries line chart with mouseover tooltip

I'm able to get the tooltip line appear as I hover over my data points however I'm blocked by an error in I assume my x.invert function.

```<code>Uncaught ReferenceError: x is not defined
</code>```

I've checked to see if this is supported d3v4 and researched other examples but no luck.

in my Here is my full code in jsfiddle, thanks in advance.

https://jsfiddle.net/zos5jfzp/

答:
There is some mistakes in your code:

Uncaught ReferenceError: x is not defined comes from you name your scale xScale and not x

You have the same problem for your y scale, rename it to yScale

You try to get all lines with a query selector on line but you didn't assign a class to lines.

```<code>vis.append('svg:path')
    .attr('class', 'graph-line')
    .attr('d', lineGen(d.values))
    .style("stroke", function() {
        return d.color = color(d.key);
    })
    .attr('stroke-width', 2)
    .attr("id", 'tag' + d.key.replace(/[^\w]|_/g, ''))
    .attr('fill', 'none');
</code>```

And

```<code>var lines = document.getElementsByClassName('graph-line');
</code>```

Finally, you have to change

```<code>idx = bisect(d.Count, xDate);
</code>```

to

```<code>idx = bisect(d.values, xDate);
</code>```

Here is the updated fiddle: https://jsfiddle.net/zos5jfzp/1/

Title: Issue with tooltip on d3 line chart

Body:
So I am trying to implement a tool tip for my line chart using Mark's answer/example from here Multiseries line chart with mouseover tooltip

I'm able to get the tooltip line appear as I hover over my data points however I'm blocked by an error in I assume my x.invert function.

Uncaught ReferenceError: x is not defined

I've checked to see if this is supported d3v4 and researched other examples but no luck.

in my Here is my full code in jsfiddle, thanks in advance.

https://jsfiddle.net/zos5jfzp/

Body:
There is some mistakes in your code:

Uncaught ReferenceError: x is not defined comes from you name your scale xScale and not x

You have the same problem for your y scale, rename it to yScale

You try to get all lines with a query selector on line but you didn't assign a class to lines.

vis.append('svg:path')
    .attr('class', 'graph-line')
    .attr('d', lineGen(d.values))
    .style("stroke", function() {
        return d.color = color(d.key);
    })
    .attr('stroke-width', 2)
    .attr("id", 'tag' + d.key.replace(/[^\w]|_/g, ''))
    .attr('fill', 'none');

And

var lines = document.getElementsByClassName('graph-line');

Finally, you have to change

idx = bisect(d.Count, xDate);

to

idx = bisect(d.values, xDate);

Here is the updated fiddle: https://jsfiddle.net/zos5jfzp/1/


来源: stackexchange

问:
How to parse multiple pdf conversion into hadoop (example)
i have one million pdf , how to convert into text using hadoop and used this for analytics.
The goal is to use the power of hadoop for extracting pdf data as a text.</p>

答:
I have processed a single pdf file on Hadoop not tried with multiple file but i believe it will work fine for multiple files too..

Complete code is available on the below link

http://ybhavesh.blogspot.in/2015/12/poc-sensex-log-data-processing-pdf-file.html

Hope this helps!!..

ContentLicense: CC BY-SA 3.0


问:
Deleting objects in memory using Python
I am trying this approach to delete an object in python. I read the documentation of Python stating that garbage collector will automatically delete the object that is not referenced.

```<code>def check():
    class newOb():
        def __init__(self,value):
            self.value = value
            print self.value
            return None

    class ob:
        ins = {}
        def cr(self,someuniqueid,value) :
            newV = newOb(value)
            ob.ins[someuniqueid] = newV ## saving this object refernce to the ob class ins dictionary
            return newV

    #### Accessing Object ###
    someuniqueid  = 12
    c = ob()
    d = c.cr(someuniqueid,123)
    print d.value ## will print 123
    # now deleting the associated object
    del c.ins[someuniqueid]

check()
</code>```

At the last step, I am removing the object reference from the memory
is using above procedure will delete the object from memory

If not then what is wrong with code and how to correct it

答: You would need to do del d as well, since d is also holding a reference to the same object. Calling del will only decrement the reference count and remove the particular reference from usage, but the actual in memory object is not garbage collected until the reference count hits 0.

Title: Deleting objects in memory using Python

Body:
I am trying this approach to delete an object in python. I read the documentation of Python stating that garbage collector will automatically delete the object that is not referenced.

def check():
    class newOb():
        def __init__(self,value):
            self.value = value
            print self.value
            return None

    class ob:
        ins = {}
        def cr(self,someuniqueid,value) :
            newV = newOb(value)
            ob.ins[someuniqueid] = newV ## saving this object refernce to the ob class ins dictionary
            return newV

    #### Accessing Object ###
    someuniqueid  = 12
    c = ob()
    d = c.cr(someuniqueid,123)
    print d.value ## will print 123
    # now deleting the associated object
    del c.ins[someuniqueid]

check()

At the last step, I am removing the object reference from the memory
is using above procedure will delete the object from memory

If not then what is wrong with code and how to correct it


问:
sp_columns order by primary key column
exec sp_columns 'table' returns all column names in COLUMN_NAMES column:

```<code>TABLE_QUALIFIER     TABLE_OWNER     TABLE_NAME          COLUMN_NAME             DATA_TYPE   TYPE_NAME       PRECISION   LENGTH  SCALE   RADIX   NULLABLE    REMARKS     COLUMN_DEF  SQL_DATA_TYPE   SQL_DATETIME_SUB    CHAR_OCTET_LENGTH   ORDINAL_POSITION    IS_NULLABLE SS_DATA_TYPE
transdata           dbo             Flow                Distance                6           float           15          8       NULL    10      1           NULL        NULL        6               NULL                NULL                9                   YES         109
transdata           dbo             Flow                FlowID                  4           int identity    10          4       0       10      0           NULL        NULL        4               NULL                NULL                10                  NO          56
</code>```

What I want is the COLUMN_NAMES to show primary key column(s) first, followed by non-primary key columns. Is this even possible with sp_columns?

Ordering by primary key should fix this but sp_columns doesn't return primary key info.

```<code>TABLE_QUALIFIER     TABLE_OWNER     TABLE_NAME          COLUMN_NAME             DATA_TYPE   TYPE_NAME       PRECISION   LENGTH  SCALE   RADIX   NULLABLE    REMARKS     COLUMN_DEF  SQL_DATA_TYPE   SQL_DATETIME_SUB    CHAR_OCTET_LENGTH   ORDINAL_POSITION    IS_NULLABLE SS_DATA_TYPE
transdata           dbo             Flow                FlowID                  4           int identity    10          4       0       10      0           NULL        NULL        4               NULL                NULL                10                  NO          56
transdata           dbo             Flow                Distance                6           float           15          8       NULL    10      1           NULL        NULL        6               NULL                NULL                9                   YES         109
</code>```

答:
Your task is too complicated to simple exec a SP.
You should write query yourself (IC columns is null if column not a PK):

```<code>SELECT
    TableName   = OBJECT_NAME(C.object_id),
    ColumnName  = C.name,
    ColumnType  = TYPE_NAME(C.system_type_Id),
    IsPK        = IIF(IC.object_id IS NULL, 0, 1)
FROM sys.columns                C
LEFT JOIN sys.key_constraints   KC  ON KC.parent_object_id = C.object_id AND kc.type = 'PK'
LEFT JOIN sys.index_columns     IC  ON KC.parent_object_id = IC.object_id  AND KC.unique_index_id = IC.index_id AND IC.column_id = C.column_id
WHERE C.object_id = OBJECT_ID(@TableName)
ORDER BY ...
</code>```

Here is similar question: How can I select the primary key columns from a table?

Title: sp_columns order by primary key column

Body:
exec sp_columns 'table' returns all column names in COLUMN_NAMES column:

TABLE_QUALIFIER     TABLE_OWNER     TABLE_NAME          COLUMN_NAME             DATA_TYPE   TYPE_NAME       PRECISION   LENGTH  SCALE   RADIX   NULLABLE    REMARKS     COLUMN_DEF  SQL_DATA_TYPE   SQL_DATETIME_SUB    CHAR_OCTET_LENGTH   ORDINAL_POSITION    IS_NULLABLE SS_DATA_TYPE
transdata           dbo             Flow                Distance                6           float           15          8       NULL    10      1           NULL        NULL        6               NULL                NULL                9                   YES         109
transdata           dbo             Flow                FlowID                  4           int identity    10          4       0       10      0           NULL        NULL        4               NULL                NULL                10                  NO          56

What I want is the COLUMN_NAMES to show primary key column(s) first, followed by non-primary key columns. Is this even possible with sp_columns?

Ordering by primary key should fix this but sp_columns doesn't return primary key info.

TABLE_QUALIFIER     TABLE_OWNER     TABLE_NAME          COLUMN_NAME             DATA_TYPE   TYPE_NAME       PRECISION   LENGTH  SCALE   RADIX   NULLABLE    REMARKS     COLUMN_DEF  SQL_DATA_TYPE   SQL_DATETIME_SUB    CHAR_OCTET_LENGTH   ORDINAL_POSITION    IS_NULLABLE SS_DATA_TYPE
transdata           dbo             Flow                FlowID                  4           int identity    10          4       0       10      0           NULL        NULL        4               NULL                NULL                10                  NO          56
transdata           dbo             Flow                Distance                6           float           15          8       NULL    10      1           NULL        NULL        6               NULL                NULL                9                   YES         109

Body:
Your task is too complicated to simple exec a SP.
You should write query yourself (IC columns is null if column not a PK):

SELECT
    TableName   = OBJECT_NAME(C.object_id),
    ColumnName  = C.name,
    ColumnType  = TYPE_NAME(C.system_type_Id),
    IsPK        = IIF(IC.object_id IS NULL, 0, 1)
FROM sys.columns                C
LEFT JOIN sys.key_constraints   KC  ON KC.parent_object_id = C.object_id AND kc.type = 'PK'
LEFT JOIN sys.index_columns     IC  ON KC.parent_object_id = IC.object_id  AND KC.unique_index_id = IC.index_id AND IC.column_id = C.column_id
WHERE C.object_id = OBJECT_ID(@TableName)
ORDER BY ...

Here is similar question: How can I select the primary key columns from a table?


问:
Bootstrap 3 table-responsive not working. X-scrollbar appears on whole site rather than table
When my screen width decreases smaller than the minimum width my table is able to display, rather than getting a horizontal scrollbar on the table-responsive wrapper, it is increasing the width of my whole site. I have tried every SO solution I've come across with no luck.

I suspect this has something to do with my flexbox styling. Basically, I've styled my site so that my main page content section (which lives inside

) will take up the remaining height of the viewport after the footer and sticky header are accounted for. So far I've had no issues, besides this one.

How can I stop the table from expanding the width of my site?

EDIT: Here's a JSFiddle in case you don't like SO's built-in snippet functionality.

$(document).ready(function() {
  $("a").on("click", function(e) {
    e.preventDefault();
  })
  $("form").on("submit", function(e) {
    e.preventDefault();
  })
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

form.page-wrapper {
  padding: 51px 0 0;
  position: static;
  height: 100%;
  display: flex;
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  flex-direction: column;
}

section#body-content {
  -ms-flex: 1 0 auto;
  -webkit-flex: 1 0 auto;
  flex: 1 0 auto;
  display: flex;
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  flex-direction: column;
}

section#body-content #subheader {
  background: #7e5bbd;
  padding-top: 35px;
  padding-bottom: 35px;
}

#aspnet-placeholder-content {
  flex: 1 0 auto;
}

footer {
  background: url("https://s25.postimg.org/4ylsw3w0v/brushed-metal-horizontal-darker-450.jpg") center top;
  padding-top: 30px;
  padding-bottom: 30px;
  margin-top: 20px;
}

@media (min-width: 768px) {
  footer .footer-content div:first-child {
    text-align: right;
    border-right: 1px solid #868686;
  }
  footer .footer-content div:nth-child(2) {
    text-align: left;
    border-left: 1px solid #868686;
  }
}

footer h5 {
  color: #868686;
}

@media (max-width: 767px) {
  .padding-left-none-sm,
  .padding-right-none-sm {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (min-width: 768px) {
  .padding-left-none-sm {
    padding-left: 0;
  }
  .padding-right-none-sm {
    padding-right: 0;
  }
  .text-right-sm {
    text-align: right;
  }
  .text-left-sm {
    text-align: left;
  }
}</code>```

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

  <form class="page-wrapper">

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

          </button>
          Logo

Home

              Service

Create Ticket

View Tickets

              Proposals

              Projects

              Documents

            <button type="submit" class="btn btn-secondary" id="btnLogout">Sign out</button>

              <select id="ddlLocations" class="form-control">
                  <option selected="selected" value="0">(select option)</option>
                  <option value="7889">Option 1</option>
                  <option value="8736">Option 2</option>
                  <option value="10398">Option 3</option>
                </select>

Page Title

                System
                Location Type
                Location
                Wired
                Equipped
                Programmed
                Tested

                Access Control
                Computer Station
                2nd Floor IT Room

                Security Office

                Badging Station
                Security Desk

                Panel Location
                1st Floor Comm and Data Room

                IT Closet

Footer text

Copyright stuff

  </form>
```

答:
I have changed some css and style and class in your demo and here is the link

```<code><form class="page-wrapper">
  <header class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class=navbar-brand>Logo</a>
      </div>
      <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li id="liHome"><a href="/">Home</a></li>
          <li class="dropdown" id="liService">
            <a href="/" data-toggle="dropdown" class="dropdown-toggle">
                            Service <i style="font-size:x-small; opacity:0.4;" class="fa fa-chevron-down" aria-hidden="true"></i>
                        </a>
            <ul class="dropdown-menu dropdown-menu-left">
              <li><a href="/">Create Ticket</a></li>
              <li><a href="/>">View Tickets</a></li>
            </ul>
          </li>
          <li id="liProposals">
            <a href="/">
                            Proposals
                        </a>
          </li>
          <li id="liProjects">
            <a href="/">
                            Projects
                        </a>
          </li>
          <li id="liDocuments">
            <a href="/">
                            Documents
                        </a>
          </li>
        </ul>
      </div>
    </div>
  </header>
  <section id="body-content" class="continer">
    <div id="subheader">
      <div class="container">
        <div class="col-sm-2 col-sm-push-10 padding-right-none-sm" style="text-align: right;">
          <button type="submit" class="btn btn-secondary" id="btnLogout"><strong>Sign out</strong></button>
        </div>
        <div class="col-sm-5 col-sm-pull-2 padding-left-none-sm">
          <div class="button-group">
            <select id="ddlLocations" class="form-control">
              <option selected="selected" value="0">(select option)</option>
              <option value="7889">Option 1</option>
              <option value="8736">Option 2</option>
              <option value="10398">Option 3</option>
            </select>
          </div>
        </div>
      </div>
    </div>
    <div id="aspnet-placeholder-content" style="padding:0 15px">
      <!--This is where page-specific server-gen"tblLocsted content from ASP.NET will render-->
      <h3>Page Title</h3>
      <br />
      <div class=" table-responsive">
        <table id="tblLocs" class="table table-striped">
          <tbody>
            <tr>
              <th>System</th>
              <th>Location Type</th>
              <th>Location</th>
              <th style="text-align: center;">Wired</th>
              <th style="text-align: center;">Equipped</th>
              <th style="text-align: center;">Programmed</th>
              <th style="text-align: center;">Tested</th>
            </tr>
            <tr>
              <td>Access Control</td>
              <td>Computer Station</td>
              <td>2nd Floor IT Room</td>
              <td style="text-align:center;"><i class="fa fa-check-square-o" title="Task complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
            </tr>
            <tr>
              <td> </td>
              <td> </td>
              <td>Security Office</td>
              <td style="text-align:center;"><i class="fa fa-check-square-o" title="Task complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
            </tr>
            <tr>
              <td> </td>
              <td>Badging Station</td>
              <td>Security Desk</td>
              <td style="text-align:center;"><i class="fa fa-check-square-o" title="Task complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
            </tr>
            <tr>
              <td> </td>
              <td>Panel Location</td>
              <td>1st Floor Comm and Data Room</td>
              <td style="text-align:center;"><i class="fa fa-check-square-o" title="Task complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
            </tr>
            <tr>
              <td> </td>
              <td> </td>
              <td>IT Closet</td>
              <td style="text-align:center;"><i class="fa fa-check-square-o" title="Task complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  </section>
  <footer>
    <div class="container">
      <div class="row text-center footer-content">
        <div class="col-sm-6">
          <h5>Footer text</h5>
        </div>
        <div class="col-sm-6">
          <h5>Copyright stuff</h5>
        </div>
      </div>
    </div>
  </footer>
</form>

$(document).ready(function() {
  $("a").on("click", function(e) {
    e.preventDefault();
  })
  $("form").on("submit", function(e) {
    e.preventDefault();
  })
});
</code>```

DemoLink

```<code>body {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

form.page-wrapper {
  padding: 51px 0 0;
  position: static;
  height: 100%;
  display: flex;
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  flex-direction: column;
}

section#body-content {
  -ms-flex: 1 0 auto;
  -webkit-flex: 1 0 auto;
  flex: 1 0 auto;
  display: flex;
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  flex-direction: column;
}

section#body-content #subheader {
  background: #7e5bbd;
  padding-top: 35px;
  padding-bottom: 35px;
}

#aspnet-placeholder-content {
  flex: 1 0 auto;
}

footer {
  background: url("https://s25.postimg.org/4ylsw3w0v/brushed-metal-horizontal-darker-450.jpg") center top;
  padding-top: 30px;
  padding-bottom: 30px;
  margin-top: 20px;
}

@media (min-width: 768px) {
  footer .footer-content div:first-child {
    text-align: right;
    border-right: 1px solid #868686;
  }
  footer .footer-content div:nth-child(2) {
    text-align: left;
    border-left: 1px solid #868686;
  }
}

footer h5 {
  color: #868686;
}

@media (max-width: 767px) {
  .padding-left-none-sm,
  .padding-right-none-sm {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (min-width: 768px) {
  .padding-left-none-sm {
    padding-left: 0;
  }
  .padding-right-none-sm {
    padding-right: 0;
  }
  .text-right-sm {
    text-align: right;
  }
  .text-left-sm {
    text-align: left;
  }
}
</code>```

Body:
When my screen width decreases smaller than the minimum width my table is able to display, rather than getting a horizontal scrollbar on the table-responsive wrapper, it is increasing the width of my whole site. I have tried every SO solution I've come across with no luck.

I suspect this has something to do with my flexbox styling. Basically, I've styled my site so that my main page content section (which lives inside

) will take up the remaining height of the viewport after the footer and sticky header are accounted for. So far I've had no issues, besides this one.

How can I stop the table from expanding the width of my site?

EDIT: Here's a JSFiddle in case you don't like SO's built-in snippet functionality.

$(document).ready(function() {
  $("a").on("click", function(e) {
    e.preventDefault();
  })
  $("form").on("submit", function(e) {
    e.preventDefault();
  })
});

body {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

form.page-wrapper {
  padding: 51px 0 0;
  position: static;
  height: 100%;
  display: flex;
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  flex-direction: column;
}

section#body-content {
  -ms-flex: 1 0 auto;
  -webkit-flex: 1 0 auto;
  flex: 1 0 auto;
  display: flex;
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  flex-direction: column;
}

section#body-content #subheader {
  background: #7e5bbd;
  padding-top: 35px;
  padding-bottom: 35px;
}

#aspnet-placeholder-content {
  flex: 1 0 auto;
}

footer {
  background: url("https://s25.postimg.org/4ylsw3w0v/brushed-metal-horizontal-darker-450.jpg") center top;
  padding-top: 30px;
  padding-bottom: 30px;
  margin-top: 20px;
}

@media (min-width: 768px) {
  footer .footer-content div:first-child {
    text-align: right;
    border-right: 1px solid #868686;
  }
  footer .footer-content div:nth-child(2) {
    text-align: left;
    border-left: 1px solid #868686;
  }
}

footer h5 {
  color: #868686;
}

@media (max-width: 767px) {
  .padding-left-none-sm,
  .padding-right-none-sm {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (min-width: 768px) {
  .padding-left-none-sm {
    padding-left: 0;
  }
  .padding-right-none-sm {
    padding-right: 0;
  }
  .text-right-sm {
    text-align: right;
  }
  .text-left-sm {
    text-align: left;
  }
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

  <form class="page-wrapper">

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

          </button>
          Logo

Home

              Service

Create Ticket

View Tickets

              Proposals

              Projects

              Documents

            <button type="submit" class="btn btn-secondary" id="btnLogout">Sign out</button>

              <select id="ddlLocations" class="form-control">
                  <option selected="selected" value="0">(select option)</option>
                  <option value="7889">Option 1</option>
                  <option value="8736">Option 2</option>
                  <option value="10398">Option 3</option>
                </select>

Page Title

                System
                Location Type
                Location
                Wired
                Equipped
                Programmed
                Tested

                Access Control
                Computer Station
                2nd Floor IT Room

                Security Office

                Badging Station
                Security Desk

                Panel Location
                1st Floor Comm and Data Room

                IT Closet

Footer text

Copyright stuff

  </form>

Body:
I have changed some css and style and class in your demo and here is the link

<form class="page-wrapper">
  <header class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class=navbar-brand>Logo</a>
      </div>
      <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li id="liHome"><a href="/">Home</a></li>
          <li class="dropdown" id="liService">
            <a href="/" data-toggle="dropdown" class="dropdown-toggle">
                            Service <i style="font-size:x-small; opacity:0.4;" class="fa fa-chevron-down" aria-hidden="true"></i>
                        </a>
            <ul class="dropdown-menu dropdown-menu-left">
              <li><a href="/">Create Ticket</a></li>
              <li><a href="/>">View Tickets</a></li>
            </ul>
          </li>
          <li id="liProposals">
            <a href="/">
                            Proposals
                        </a>
          </li>
          <li id="liProjects">
            <a href="/">
                            Projects
                        </a>
          </li>
          <li id="liDocuments">
            <a href="/">
                            Documents
                        </a>
          </li>
        </ul>
      </div>
    </div>
  </header>
  <section id="body-content" class="continer">
    <div id="subheader">
      <div class="container">
        <div class="col-sm-2 col-sm-push-10 padding-right-none-sm" style="text-align: right;">
          <button type="submit" class="btn btn-secondary" id="btnLogout"><strong>Sign out</strong></button>
        </div>
        <div class="col-sm-5 col-sm-pull-2 padding-left-none-sm">
          <div class="button-group">
            <select id="ddlLocations" class="form-control">
              <option selected="selected" value="0">(select option)</option>
              <option value="7889">Option 1</option>
              <option value="8736">Option 2</option>
              <option value="10398">Option 3</option>
            </select>
          </div>
        </div>
      </div>
    </div>
    <div id="aspnet-placeholder-content" style="padding:0 15px">
      <!--This is where page-specific server-gen"tblLocsted content from ASP.NET will render-->
      <h3>Page Title</h3>
      <br />
      <div class=" table-responsive">
        <table id="tblLocs" class="table table-striped">
          <tbody>
            <tr>
              <th>System</th>
              <th>Location Type</th>
              <th>Location</th>
              <th style="text-align: center;">Wired</th>
              <th style="text-align: center;">Equipped</th>
              <th style="text-align: center;">Programmed</th>
              <th style="text-align: center;">Tested</th>
            </tr>
            <tr>
              <td>Access Control</td>
              <td>Computer Station</td>
              <td>2nd Floor IT Room</td>
              <td style="text-align:center;"><i class="fa fa-check-square-o" title="Task complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>Security Office</td>
              <td style="text-align:center;"><i class="fa fa-check-square-o" title="Task complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>Badging Station</td>
              <td>Security Desk</td>
              <td style="text-align:center;"><i class="fa fa-check-square-o" title="Task complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>Panel Location</td>
              <td>1st Floor Comm and Data Room</td>
              <td style="text-align:center;"><i class="fa fa-check-square-o" title="Task complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>IT Closet</td>
              <td style="text-align:center;"><i class="fa fa-check-square-o" title="Task complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
              <td style="text-align:center;"><i class="fa fa-square-o" title="Task not yet complete"></i></td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  </section>
  <footer>
    <div class="container">
      <div class="row text-center footer-content">
        <div class="col-sm-6">
          <h5>Footer text</h5>
        </div>
        <div class="col-sm-6">
          <h5>Copyright stuff</h5>
        </div>
      </div>
    </div>
  </footer>
</form>

$(document).ready(function() {
  $("a").on("click", function(e) {
    e.preventDefault();
  })
  $("form").on("submit", function(e) {
    e.preventDefault();
  })
});

DemoLink

body {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

form.page-wrapper {
  padding: 51px 0 0;
  position: static;
  height: 100%;
  display: flex;
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  flex-direction: column;
}

section#body-content {
  -ms-flex: 1 0 auto;
  -webkit-flex: 1 0 auto;
  flex: 1 0 auto;
  display: flex;
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  flex-direction: column;
}

section#body-content #subheader {
  background: #7e5bbd;
  padding-top: 35px;
  padding-bottom: 35px;
}

#aspnet-placeholder-content {
  flex: 1 0 auto;
}

footer {
  background: url("https://s25.postimg.org/4ylsw3w0v/brushed-metal-horizontal-darker-450.jpg") center top;
  padding-top: 30px;
  padding-bottom: 30px;
  margin-top: 20px;
}

@media (min-width: 768px) {
  footer .footer-content div:first-child {
    text-align: right;
    border-right: 1px solid #868686;
  }
  footer .footer-content div:nth-child(2) {
    text-align: left;
    border-left: 1px solid #868686;
  }
}

footer h5 {
  color: #868686;
}

@media (max-width: 767px) {
  .padding-left-none-sm,
  .padding-right-none-sm {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (min-width: 768px) {
  .padding-left-none-sm {
    padding-left: 0;
  }
  .padding-right-none-sm {
    padding-right: 0;
  }
  .text-right-sm {
    text-align: right;
  }
  .text-left-sm {
    text-align: left;
  }
}


问:
Finding difference of two columns with where clause - MySQL
I'm trying to get the difference of two columns(OTHER AND SENIOR) with WHERE clause along with the Sum of their amount. The formulas are working fine, however, I'm not getting the result I want.

I tried to do it using INNER JOIN and unfortunately its not the result that I expected

Here's my query:

```<code>select a.ID as EMPLOYEE,
sum(a.amount) as other,
sum(b.amount) as senior,
(sum(a.amount) - sum(b.amount)) as result
from gndsale a
INNER join gndsale
b ON a.ID= b.ID
where a.TYPE = "5" and b.seniortype = "10"
group by a.ID
</code>```

Result:

What I want to do is get the difference of Column (Other) where type = 5 and Column (Senior)  where seniortype = 10

Here is my query for Senior:

```<code> select ID as EMPLOYEE, sum(amount)
 from gndsale
 where seniortype = "10"
 group by ID
</code>```

Result:

Here is my query for Other:

```<code>select ID as employee, sum(amount)
from gndsale
where type = "5"
group by ID
</code>```

The result should be

9907 = 530

9912 = 63.71

Anyone can help me with this? :(

Sample/Expected output:

答:
You might give this a try:

```<code>SELECT
    a.`employee`,
    sum(a.`amount`) - sum(b.`amount`) as total
FROM `gndsale` a
JOIN `gndsale` b
ON a.`employee` = b.`employee` and b.`senior_type` = "10"
WHERE a.`type` = "5"
GROUP BY a.`employee`
ORDER BY a.`employee`;
</code>```

It simply joins your two queries.

Body:
I'm trying to get the difference of two columns(OTHER AND SENIOR) with WHERE clause along with the Sum of their amount. The formulas are working fine, however, I'm not getting the result I want.

I tried to do it using INNER JOIN and unfortunately its not the result that I expected

Here's my query:

select a.ID as EMPLOYEE,
sum(a.amount) as other,
sum(b.amount) as senior,
(sum(a.amount) - sum(b.amount)) as result
from gndsale a
INNER join gndsale
b ON a.ID= b.ID
where a.TYPE = "5" and b.seniortype = "10"
group by a.ID

Result:

What I want to do is get the difference of Column (Other) where type = 5 and Column (Senior)  where seniortype = 10

Here is my query for Senior:

 select ID as EMPLOYEE, sum(amount)
 from gndsale
 where seniortype = "10"
 group by ID

Result:

Here is my query for Other:

select ID as employee, sum(amount)
from gndsale
where type = "5"
group by ID

The result should be

9907 = 530

9912 = 63.71

Anyone can help me with this? :(

Sample/Expected output:

Body:
You might give this a try:

SELECT
    a.`employee`,
    sum(a.`amount`) - sum(b.`amount`) as total
FROM `gndsale` a
JOIN `gndsale` b
ON a.`employee` = b.`employee` and b.`senior_type` = "10"
WHERE a.`type` = "5"
GROUP BY a.`employee`
ORDER BY a.`employee`;

It simply joins your two queries.


问:
No source code is available for type com.google.gwt.ajaxloader.client.AjaxLoader;
I am migrating an project someone else built to newer packages and I have traced the root of my errors to this
 No source code is available for type com.google.gwt.ajaxloader.client.AjaxLoader; did you forget to inherit a required module?
I am new to GWT and not really sure how it works 100% under the hood so I am having trouble applying solutions to similar posts to solve this error.

答:
GWT needs source code as opposed to .class files to do its work.
So any references you might have from your client code towards any jars, etc, need to also include source code.

In your case, you either need the source of com.google.gwt.ajaxloader.client.AjaxLoader, or remove any references towards the mentioned class, from your GWT code.


问:
link_to helper doesn't work for me
the controller file drummer.rb

and I use both old controller/action way and new resource way, either work
the view file index.html.erb:

```<code><ul>
<% @drummer_list.each do |d| %>
  <li>
    <%= link_to :controller => 'drummers',:action => 'show', :id => '@drummer'  do %>
      <%=  d.first_name + ' ' + d.last_name %>
    <% end %>
  </li>
<% end %>
</ul>
</code>```

the resource way:

```<code><ul>
<% @drummer_list.each do |d| %>
  <li>
    <%= link_to drummers_path(@drummer)  do %>
      <%=  d.first_name + ' ' + d.last_name %>
    <% end %>
  </li>
<% end %>
</ul>
</code>```

when I click each link, in the browser url bar give me this

```<code>http://localhost:3000/drummers/@drummer
</code>```

it should give me

```<code>http://localhost:3000/drummers/1
</code>```

I think the problem is about the @drummer, I'm not sure about the it.

答:
This should do it :)</p>

```<code><ul>
<% @drummer_list.each do |d| %>
  <li>
    <%= link_to "#{d.first_name} #{d.last_name}", drummers_path(d) %>
  </li>
<% end %>
</ul>
</code>```

ContentLicense: CC BY-SA 2.5

Title: link_to helper doesn't work for me

Body:
the controller file drummer.rb

and I use both old controller/action way and new resource way, either work
the view file index.html.erb:

<% @drummer_list.each do |d| %>

    <%= link_to :controller => 'drummers',:action => 'show', :id => '@drummer'  do %>
      <%=  d.first_name + ' ' + d.last_name %>
    <% end %>

<% end %>

the resource way:

<% @drummer_list.each do |d| %>

    <%= link_to drummers_path(@drummer)  do %>
      <%=  d.first_name + ' ' + d.last_name %>
    <% end %>

<% end %>

when I click each link, in the browser url bar give me this

http://localhost:3000/drummers/@drummer

it should give me

http://localhost:3000/drummers/1

I think the problem is about the @drummer, I'm not sure about the it.

Body:
This should do it :)

<ul>
<% @drummer_list.each do |d| %>
  <li>
    <%= link_to "#{d.first_name} #{d.last_name}", drummers_path(d) %>
  </li>
<% end %>
</ul>


问:
JavaScript isset() equivalent
In PHP you can do if(isset($array['foo'])) { ... }. In JavaScript you often use if(array.foo) { ... } to do the same, but this is not exactly the same statement. The condition will also evaluate to false if array.foo does exists but is false or 0 (and probably other values as well).

What is the perfect equivalent of PHP's isset in JavaScript?

In a broader sense, a general, complete guide on JavaScript's handling of variables that don't exist, variables without a value, etc. would be convenient.

Update: 11 years and 11 months ago I posted this question, and wow, it still gets a lot of activity. Now, I'm pretty sure that when I wrote this, I only wanted to know how to check for the presence of a property in an associative array (a.k.a. dictionary), and as such the correct (for me) answers involve hasOwnProperty or the in operator. I wasn't interested in checking local or global variables.

But while I remember that well, that intent is not quite clear in the question as written, or even directly contradicted by it! I never mentioned the associative array, and PHP's isset does also do those other things. Let this be a lesson to all of us about how important it is to properly state your requirements in a question, and also how global variables, local variables, object properties, dictionary keys and what-have-you aren't Huey, Dewey, and Louie.

In the meantime (heh), many many people have provided answers to that effect as well, so for those of you who found this question through Google, well, I'm glad my vagueness helped in a way I guess. Anyway, just wanted to clarify that.

答:
To check wether html block is existing or not, I'm using this code:</p>

```<code>if (typeof($('selector').html()) != 'undefined') {
    // $('selector') is existing
    // your code here
}
</code>```

ContentLicense: CC BY-SA 4.0

Title: JavaScript isset() equivalent

Body:
To check wether html block is existing or not, I'm using this code:

if (typeof($('selector').html()) != 'undefined') {
    // $('selector') is existing
    // your code here
}


问:
Django - joining multiple tables (models) and filtering out based on their attribute
I'm new to django and ORM in general, and so have trouble coming up with query which would join multiple tables.

I have 4 Models that need joining - Category, SubCategory, Product and Packaging, example values would be:

Category: 'male'

SubCategory: 'shoes'

Product: 'nikeXYZ'

Packaging: 'size_36: 1'

Each of the Model have FK to the model above (ie. SubCategory has field category etc).

My question is - how can I filter Product given a Category (e.g. male) and only show products which have Packaging attribute available set to True? Obviously I want to minimise the hits on my database (ideally do it with 1 SQL query).

I could do something along these lines:

```<code>available = Product.objects.filter(packaging__available=True)
subcategories = SubCategory.objects.filter(category_id=<id_of_male>)
products = available.filter(subcategory_id__in=subcategories)
</code>```

but then that requires 2 hits on database at least (available, subcategories) I think. Is there a way to do it in one go?

答:
Try to read:
this
You can query with _set, multi __ (to link models by FK) or create list ids</p>

Body:
I'm new to django and ORM in general, and so have trouble coming up with query which would join multiple tables.

I have 4 Models that need joining - Category, SubCategory, Product and Packaging, example values would be:

Category: 'male'

SubCategory: 'shoes'

Product: 'nikeXYZ'

Packaging: 'size_36: 1'

Each of the Model have FK to the model above (ie. SubCategory has field category etc).

My question is - how can I filter Product given a Category (e.g. male) and only show products which have Packaging attribute available set to True? Obviously I want to minimise the hits on my database (ideally do it with 1 SQL query).

I could do something along these lines:

available = Product.objects.filter(packaging__available=True)
subcategories = SubCategory.objects.filter(category_id=<id_of_male>)
products = available.filter(subcategory_id__in=subcategories)

but then that requires 2 hits on database at least (available, subcategories) I think. Is there a way to do it in one go?


问:
how to get ng-template to work in ionic 2 project
I had previously attempted to use virtual scroll for an array of cards that will have a varying amount of items. Virtual scroll wouldn't work with my cards and it was suggested I try ng-template which kept giving me an error in the terminal that said this :

Error: Template parse errors:  [01:38:47]  'ng-template' is not a
  known element:  [01:38:47]  1. If 'ng-template' is an Angular
  component, then verify that it is part of this module.  [01:38:47]  2.
  If 'ng-template' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA"
  to the '@NgModule.schemas' of this

The other solutions I've tried to get virtual scroll to work have left me with a blank, white, unrendered page, which is strange because you'd think if there was an error the terminal would have told me and the build would fail. I want to try to figure out how to make ng-template work for me. Googling hasn't turned up sufficient examples.
This is how I was originally using virtualScroll, which is the wrong way to do it. I've tried swapping in div and list elements to put the virtualScroll property on and I get the same result of a blank page.

HTML

```<code><ion-content id="content">
   <ion-card id="card" *ngFor="let event of listOfEvents
     [virtualScroll]="listOfEvents">
     <ion-item *virtualItem="let event">
       <ion-row>
         <ion-col>
           <span class="showDetails">Guests Needed:</span> {{event.guests}}
         </ion-col>
         <ion-col>
           <span class="showDetails">Cover:</span> {{event.coverCharge}}
         </ion-col>
         <ion-col>
           <span class="showDetails">Drink Min:</span>{{event.drinkMin}
         </ion-col>
       </ion-row>
    </ion-item>
  </ion-card>
</ion-content>
</code>```

答: The <ng-template> element has been introduced in the angular version 4.0.0-rc.1. You should either update to the latest angular version (advised), or use the <template> tag

Body:
I had previously attempted to use virtual scroll for an array of cards that will have a varying amount of items. Virtual scroll wouldn't work with my cards and it was suggested I try ng-template which kept giving me an error in the terminal that said this :

Error: Template parse errors:  [01:38:47]  'ng-template' is not a
  known element:  [01:38:47]  1. If 'ng-template' is an Angular
  component, then verify that it is part of this module.  [01:38:47]  2.
  If 'ng-template' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA"
  to the '@NgModule.schemas' of this

The other solutions I've tried to get virtual scroll to work have left me with a blank, white, unrendered page, which is strange because you'd think if there was an error the terminal would have told me and the build would fail. I want to try to figure out how to make ng-template work for me. Googling hasn't turned up sufficient examples.
This is how I was originally using virtualScroll, which is the wrong way to do it. I've tried swapping in div and list elements to put the virtualScroll property on and I get the same result of a blank page.

HTML

<ion-content id="content">
   <ion-card id="card" *ngFor="let event of listOfEvents
     [virtualScroll]="listOfEvents">
     <ion-item *virtualItem="let event">
       <ion-row>
         <ion-col>
           Guests Needed: {{event.guests}}
         </ion-col>
         <ion-col>
           Cover: {{event.coverCharge}}
         </ion-col>
         <ion-col>
           Drink Min:{{event.drinkMin}
         </ion-col>
       </ion-row>
    </ion-item>
  </ion-card>
</ion-content>


问:
How can we display backend data in react.js?
How we display data which we get from backend in and display in react.js?
The backend data is below. I want to get the date and time value and notes from that object.

Here I use global variable to store the response and the stor the global variable into state variable.

I need to render notes data and date and time from backend and display in the render method.

```<code>$.ajax({
        method: 'GET',
        url: 'http//.. //...',
        data: userDetails,
        dataType: 'json',
        jsonp: false,
        success: function(response) {
          MyVariables.userRecordFeed = response;
          console.log(  MyVariables.userRecordFeed)
          record_exist= response[0].record_exist
          MyVariables.medata_content= response[0].notes
          console.log(MyVariables.medata_content);
        }.bind(this),
        error: function() {
          console.log('There is a problem with server');
        }
      });

      this.setState({userRecordFeed:MyVariables.userRecordFeed, loadRecordNewsfeed: MyVariables.loadRecordNewsfeed, loadRecordOverlay: MyVariables.loadRecordOverlay,
           showAddRecordIconsIntro: MyVariables.showAddRecordIconsIntro})

    }
  render()
  {
      if(record_exist === 'yes') {
          console.log('exists');
      }
      else {
             userRecordFeedData = <div className="card">
             <div className="row card-header">
                 <div className="col-xs-2 col-sm-2 col-md-2 card-name-icon">
                   <span className="card-name-symbol">AJ</span>
                 </div>
                 <div className="col-xs-8 col-sm-8 col-md-8 card-name-time-date">
                    <div className="card-name">
                      Joined Medata
                    </div>
                    <div className="card-date">
                      5/04/2017
                    </div>
                    <span className="card-time">
                      12:55 PM
                    </span>
                </div>
                <div className="col-xs-2 col-sm-2 col-md-2 card-functionality">
                  <span className=" functionality-icon fa fa-ellipsis-v"></span>
                </div>
            </div>
            <div className="row card-bottom">
                 <div className="col-xs-2 col-sm-2 col-md-2 card-bottom-dots">
                   <div className="bottom_left_side_menu_icon">
                   </div>
                   <div className="bottom_left_side_menu_icon">
                   </div>
                   <div className="bottom_left_side_menu_icon">
                   </div>
                   <div className="bottom_left_side_menu_icon">
                   </div>
                   <div className="bottom_left_side_menu_icon">
                   </div>
                   <div className="bottom_left_side_menu_icon">
                   </div>
                   <div className="bottom_left_side_menu_icon">
                   </div>
                   <div className="card-bottom_left_side_menu_icon">
                   </div>
                   <div className="card-bottom_left_side_menu_icon">
                   </div>
                   <div className="landing-join-bottom_left_side_menu_icon">
                   </div>
                 </div>
                 <div className="col-xs-9 col-sm-9 col-md-9 ">
                   <p className="">Lorem Ipsum is simply dummy text of the printing and typesetting industry
                     Lorem Ipsum has been the industry  standard dummy text ever since the 1500</p>

                   </div>
                 <div className="col-xs-1 col-sm-1 col-md-1"></div>
            </div>
          </div>
        }

        return(
          <div >{userReacordFeedData}
          </div>
        }
    }
</code>```

The backend data is in this format:

```<code>Object
conditon
:
"something"
created_on_date_time
:
"6/23/2017 5:33:57 AM"
name
:
"Nitesh"
notes
:
"Lorem Ipsum is simply dummy text of the printing and typesetting industry  Lorem Ipsum has been the industry  standard dummy text ever since the 1500"
record_exist
:
"no"
</code>```

答:
This is an example which should help you out or give you an idea, at least.

```<code>class App extends React.Component {

  constructor() {
    super();
    this.state = { countries: null };
  }

  componentDidMount() {
    fetch('https://restcountries.eu/rest/v2/name/united', {
        method: 'GET',
    })
    .then(results => results.json())
    .then(data => this.setState({ countries: data }))
    .catch(function(error) {console.log(error)});
  }

  _renderCountries(country, index) {
    return <li key={index}>{country.name} - {country.subregion}</li>
  }

    render() {
    const { countries } = this.state;

    return (
        <div>
        <h1>LIST OF COUNTRIES:</h1>
          <ul>
            {
            countries ?
            countries.map(this._renderCountries)
            :
            "no data to display"
          }
          </ul>
        </div>
    );
  }
}
</code>```

I used fetch in this example. try the fiddle here

Body:
How we display data which we get from backend in and display in react.js?
The backend data is below. I want to get the date and time value and notes from that object.

Here I use global variable to store the response and the stor the global variable into state variable.

I need to render notes data and date and time from backend and display in the render method.

$.ajax({
        method: 'GET',
        url: 'http//.. //...',
        data: userDetails,
        dataType: 'json',
        jsonp: false,
        success: function(response) {
          MyVariables.userRecordFeed = response;
          console.log(  MyVariables.userRecordFeed)
          record_exist= response[0].record_exist
          MyVariables.medata_content= response[0].notes
          console.log(MyVariables.medata_content);
        }.bind(this),
        error: function() {
          console.log('There is a problem with server');
        }
      });

      this.setState({userRecordFeed:MyVariables.userRecordFeed, loadRecordNewsfeed: MyVariables.loadRecordNewsfeed, loadRecordOverlay: MyVariables.loadRecordOverlay,
           showAddRecordIconsIntro: MyVariables.showAddRecordIconsIntro})

    }
  render()
  {
      if(record_exist === 'yes') {
          console.log('exists');
      }
      else {
             userRecordFeedData =

                   AJ

                      Joined Medata

                      5/04/2017

                      12:55 PM

Lorem Ipsum is simply dummy text of the printing and typesetting industry
                     Lorem Ipsum has been the industry  standard dummy text ever since the 1500

        }

        return(

{userReacordFeedData}

        }
    }

The backend data is in this format:

Object
conditon
:
"something"
created_on_date_time
:
"6/23/2017 5:33:57 AM"
name
:
"Nitesh"
notes
:
"Lorem Ipsum is simply dummy text of the printing and typesetting industry  Lorem Ipsum has been the industry  standard dummy text ever since the 1500"
record_exist
:
"no"

Body:
This is an example which should help you out or give you an idea, at least.

class App extends React.Component {

  constructor() {
    super();
    this.state = { countries: null };
  }

  componentDidMount() {
    fetch('https://restcountries.eu/rest/v2/name/united', {
        method: 'GET',
    })
    .then(results => results.json())
    .then(data => this.setState({ countries: data }))
    .catch(function(error) {console.log(error)});
  }

  _renderCountries(country, index) {
    return <li key={index}>{country.name} - {country.subregion}</li>
  }

    render() {
    const { countries } = this.state;

    return (
        <div>
        <h1>LIST OF COUNTRIES:</h1>
          <ul>
            {
            countries ?
            countries.map(this._renderCountries)
            :
            "no data to display"
          }
          </ul>
        </div>
    );
  }
}

I used fetch in this example. try the fiddle here


问:
filter for custom column in grid view which is not in table yii2
I have added this 'sla_status' field in gridview and every thing is working fine only issue is I am unable to set filter values for this.
'sla_status' is not in my table.

```<code>[
            'label' => Yii::t('app','Sla Status'),
            'format' => 'raw',
            'filterType' => GridView::FILTER_SELECT2,
            'filter' => $status,
            'filterWidgetOptions' => [
                    'options' => [
                            'placeholder' => Yii::t('app','All...' )
                    ],
                    'pluginOptions' => [
                            'allowClear' => true
                    ]
            ],

            'headerOptions' => ['style' => 'text-align:center;color:#337ab7'],
            'value' => function ($model, $key, $index, $widget)
            {           }
            ]
</code>```

and $status is $status = array('0'=>Yii::t('app', 'Inactive'),'1'=>Yii::t('app', 'Active'));

答:
Add your field "sla_status" to "safe" in rules method of your model or search model like

[['sla_status'], 'safe'],

Body:
I have added this 'sla_status' field in gridview and every thing is working fine only issue is I am unable to set filter values for this.
'sla_status' is not in my table.

[
            'label' => Yii::t('app','Sla Status'),
            'format' => 'raw',
            'filterType' => GridView::FILTER_SELECT2,
            'filter' => $status,
            'filterWidgetOptions' => [
                    'options' => [
                            'placeholder' => Yii::t('app','All...' )
                    ],
                    'pluginOptions' => [
                            'allowClear' => true
                    ]
            ],

            'headerOptions' => ['style' => 'text-align:center;color:#337ab7'],
            'value' => function ($model, $key, $index, $widget)
            {           }
            ]

and $status is $status = array('0'=>Yii::t('app', 'Inactive'),'1'=>Yii::t('app', 'Active'));


问:
C# Split Date and Time format into Datatable
I have a CSV with a server log. I need to split the date/time format as attached image into my datatable.

Sample of CSV txt file

10.115.10.74 - - [20/Mar/2016:03:38:14 +0800] "GET /portal/images/banners/iot.jpg HTTP/1.1" 404 918 "http://www.utem.edu.my/portal/" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"

172.16.75.219 - - [20/Mar/2016:03:38:17 +0800] "GET / HTTP/1.1" 200 98 "http://192.168.0.1:8090/httpclient.html" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36"

Is there any way I can do to achieve something like this?

What I have tried so far

```<code>string[] raw_text = System.IO.File.ReadAllLines("C:\\log4.csv");

string[] data_col = null;

int x = 0;
foreach (string text_line in raw_text)
{
    //MessageBox.Show(text_line);
    data_col = text_line.Split(' ', '<', '>', '[', ']', '-', '"', ';', '(', ')', '+', ':');

    if (x == 1)
    {
        for (int i = 0; i <= data_col.Count() - 1; i++)
        {
            my_datatable.Columns.Add(data_col[i]);
        }

        x++;
    }
    else
    {

        my_datatable.Rows.Add(data_col);
    }
</code>```

答:
I based this answer from your existing source code. Adjust it to your needs.

From the sample log file:

```<code>10.115.10.74 - - [20/Mar/2016:03:38:14 +0800] "GET /portal/images/banners/iot.jpg HTTP/1.1" 404 918 "http://www.utem.edu.my/portal/" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"
172.16.75.219 - - [20/Mar/2016:03:38:17 +0800] "GET / HTTP/1.1" 200 98 "http://192.168.0.1:8090/httpclient.html" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36"
</code>```

Console application:

```<code>class Foo
{
    public string IPAddress { get; set; }
    public string Date { get; set; }
    public string Time { get; set; }
    public string TimeZone { get; set; }
    public string Request { get; set; }
}

class Program
{
    static void Main(string[] args)
    {
        string[] lines = File.ReadAllLines("Log.txt");

        DataTable dt = new DataTable();
        dt.Columns.Add("IP Address");
        dt.Columns.Add("Date");
        dt.Columns.Add("Time");
        dt.Columns.Add("GMT");
        dt.Columns.Add("Method");

        foreach(string line in lines)
        {
            string[] split = line.Split(' ', '<', '>', '[', ']', '-', '"', ';', '(', ')', '+', ':');

            split = split.Where(r => !string.IsNullOrWhiteSpace(r)).ToArray();

            Foo foo = new Foo();

            foo.IPAddress = split[0];
            foo.Date = split[1];
            foo.Time = string.Format("{0}:{1}:{2}", split[2], split[3], split[4]);
            foo.TimeZone = split[5];
            foo.Request = split[6];

            dt.Rows.Add(foo.IPAddress, foo.Date, foo.Time, foo.TimeZone, foo.Request);
        }

        foreach(DataRow dr in dt.Rows)
        {
            Console.WriteLine(string.Format("{0} {1} {2} {3} {4}", dr[0], dr[1], dr[2], dr[3], dr[4]));
        }

        Console.ReadLine();
    }
}
</code>```

Output:

Body:
I have a CSV with a server log. I need to split the date/time format as attached image into my datatable.

Sample of CSV txt file

10.115.10.74 - - [20/Mar/2016:03:38:14 +0800] "GET /portal/images/banners/iot.jpg HTTP/1.1" 404 918 "http://www.utem.edu.my/portal/" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"

172.16.75.219 - - [20/Mar/2016:03:38:17 +0800] "GET / HTTP/1.1" 200 98 "http://192.168.0.1:8090/httpclient.html" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36"

Is there any way I can do to achieve something like this?

What I have tried so far

string[] raw_text = System.IO.File.ReadAllLines("C:\\log4.csv");

string[] data_col = null;

int x = 0;
foreach (string text_line in raw_text)
{
    //MessageBox.Show(text_line);
    data_col = text_line.Split(' ', '<', '>', '[', ']', '-', '"', ';', '(', ')', '+', ':');

    if (x == 1)
    {
        for (int i = 0; i <= data_col.Count() - 1; i++)
        {
            my_datatable.Columns.Add(data_col[i]);
        }

        x++;
    }
    else
    {

        my_datatable.Rows.Add(data_col);
    }

Body:
I based this answer from your existing source code. Adjust it to your needs.

From the sample log file:

10.115.10.74 - - [20/Mar/2016:03:38:14 +0800] "GET /portal/images/banners/iot.jpg HTTP/1.1" 404 918 "http://www.utem.edu.my/portal/" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"
172.16.75.219 - - [20/Mar/2016:03:38:17 +0800] "GET / HTTP/1.1" 200 98 "http://192.168.0.1:8090/httpclient.html" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36"

Console application:

class Foo
{
    public string IPAddress { get; set; }
    public string Date { get; set; }
    public string Time { get; set; }
    public string TimeZone { get; set; }
    public string Request { get; set; }
}

class Program
{
    static void Main(string[] args)
    {
        string[] lines = File.ReadAllLines("Log.txt");

        DataTable dt = new DataTable();
        dt.Columns.Add("IP Address");
        dt.Columns.Add("Date");
        dt.Columns.Add("Time");
        dt.Columns.Add("GMT");
        dt.Columns.Add("Method");

        foreach(string line in lines)
        {
            string[] split = line.Split(' ', '<', '>', '[', ']', '-', '"', ';', '(', ')', '+', ':');

            split = split.Where(r => !string.IsNullOrWhiteSpace(r)).ToArray();

            Foo foo = new Foo();

            foo.IPAddress = split[0];
            foo.Date = split[1];
            foo.Time = string.Format("{0}:{1}:{2}", split[2], split[3], split[4]);
            foo.TimeZone = split[5];
            foo.Request = split[6];

            dt.Rows.Add(foo.IPAddress, foo.Date, foo.Time, foo.TimeZone, foo.Request);
        }

        foreach(DataRow dr in dt.Rows)
        {
            Console.WriteLine(string.Format("{0} {1} {2} {3} {4}", dr[0], dr[1], dr[2], dr[3], dr[4]));
        }

        Console.ReadLine();
    }
}

Output:


问:
Problems when bringing node with angular OR how to create a mean app without using angular-cli
I am using angular4. I used angular-cli to create my project.

I want to use node.js as server side language with mongodb. So, I found a tutorial here to connect node.js with angular.

But there are two problems with it:

dist folder is created.

auto refresh server like using nodemon or similar is lost

problem with dist folder

My site depends heavily on images. I keep all the images in a folder called images which is located under assets folder created by angular-cli

So, when I run the server, all the assets will be copied to the dist directory, which will take time and (more important) space on the webserver. Another problem is that If I upload new images, then it will be copied to the images folder inside dist folder, so I have to manually copy those images to my original dist folder.

Another copy of images folder in dist folder will take double space than my original app. So, I have to pay more money for hosting to use more space.

problem with auto-refresh server

before using node, I just typed this command

```<code>ng serve
</code>```

and my application started. Then when I change any code and save the file, the changes were reflected in the browser without restarting the server.

But when I started to use node, I have to manually restart the server whenever I make changes to my code.

Question:

Is there any way that prevents app to create images folder inside dist folder to save space. I mean can I use original Images folder instead of creating one inside dist?

Or is there any other way that a node application and angular application work together?

If anybody knows a solution that does not use dist folder, then I would love to use that solution. As my need is satisfied. Auto-refresh server is not important to me in this case.

So, if anybody knows a way of how to create a mean app without angular-cli,
 then I think that is very near to my solution.

答:
You can change dist folder's name  to any name you want. you just need to find file .angular-cli.json in your main root folder and change json</p>

```<code>"apps": [
    {
      ...,
      "outDir": "dist", // dist to any name e.g. public, ...
      ...
   }
]
</code>```

Body:
I am using angular4. I used angular-cli to create my project.

I want to use node.js as server side language with mongodb. So, I found a tutorial here to connect node.js with angular.

But there are two problems with it:

dist folder is created.

auto refresh server like using nodemon or similar is lost

problem with dist folder

My site depends heavily on images. I keep all the images in a folder called images which is located under assets folder created by angular-cli

So, when I run the server, all the assets will be copied to the dist directory, which will take time and (more important) space on the webserver. Another problem is that If I upload new images, then it will be copied to the images folder inside dist folder, so I have to manually copy those images to my original dist folder.

Another copy of images folder in dist folder will take double space than my original app. So, I have to pay more money for hosting to use more space.

problem with auto-refresh server

before using node, I just typed this command

ng serve

and my application started. Then when I change any code and save the file, the changes were reflected in the browser without restarting the server.

But when I started to use node, I have to manually restart the server whenever I make changes to my code.

Question:

Is there any way that prevents app to create images folder inside dist folder to save space. I mean can I use original Images folder instead of creating one inside dist?

Or is there any other way that a node application and angular application work together?

If anybody knows a solution that does not use dist folder, then I would love to use that solution. As my need is satisfied. Auto-refresh server is not important to me in this case.

So, if anybody knows a way of how to create a mean app without angular-cli,
 then I think that is very near to my solution.

Body:
You can change dist folder's name  to any name you want. you just need to find file .angular-cli.json in your main root folder and change json

"apps": [
    {
      ...,
      "outDir": "dist", // dist to any name e.g. public, ...
      ...
   }
]


问:
jquery - get position problem in Firefox
I have the following code which gets the left and top position of the element you are hovered over. It produces the right results in safari and IE but fails to get the position of the img that you hover over in Firefox - it returns 0, 0. Can anyone see why this might be??

I think it might be something to do with setting it as the variable as it seems to work if I place it straight in the function. I need to set it as a variable though so it can return to its original state.

```<code>$.fn.hoverAnimationTwo = function () {
    return $(this).each(function () {

        var originalLeftTwo = parseInt($(this).css("left"));
        var originalTopTwo  = parseInt($(this).css("top"));

        return $(this).hover(function () {
            $(this).animate({
                width: "17px",
                height: "17px",
                left: originalLeftTwo - 5,
                top: originalTopTwo - 5
            }, 100);
        },function () {

            $(this).animate({
                width: "7px",
                height: "7px",
                left: originalLeftTwo,
                top: originalTopTwo
            }, 100);
        });
    });
}

$(".myImg").hoverAnimationTwo();
</code>```

The other thing which is very odd is that I can copy all of my code into jsfiddle and it seems to work.

EDIT:
OK... so it turns out this isn't a javascript issue as such. It is because elsewhere in the page I had given an element a class beginning with a numeric character which is entirely my bad and I should know better!

答:
Browsers seem to have some inconsistencies when relying on CSS properties. Have you tried using .position() or .offset() (whichever is applicable to your needs)?

http://api.jquery.com/offset/ or http://api.jquery.com/position/

Body:
I have the following code which gets the left and top position of the element you are hovered over. It produces the right results in safari and IE but fails to get the position of the img that you hover over in Firefox - it returns 0, 0. Can anyone see why this might be??

I think it might be something to do with setting it as the variable as it seems to work if I place it straight in the function. I need to set it as a variable though so it can return to its original state.

$.fn.hoverAnimationTwo = function () {
    return $(this).each(function () {

        var originalLeftTwo = parseInt($(this).css("left"));
        var originalTopTwo  = parseInt($(this).css("top"));

        return $(this).hover(function () {
            $(this).animate({
                width: "17px",
                height: "17px",
                left: originalLeftTwo - 5,
                top: originalTopTwo - 5
            }, 100);
        },function () {

            $(this).animate({
                width: "7px",
                height: "7px",
                left: originalLeftTwo,
                top: originalTopTwo
            }, 100);
        });
    });
}

$(".myImg").hoverAnimationTwo();

The other thing which is very odd is that I can copy all of my code into jsfiddle and it seems to work.

EDIT:
OK... so it turns out this isn't a javascript issue as such. It is because elsewhere in the page I had given an element a class beginning with a numeric character which is entirely my bad and I should know better!


问:
C# Console Application display invalid input in while loop
I have this C# console application code here that reads text from a file.
when a user inputs a value, it searches the file for lines that contain that value.
In my case, the console will ask for a room number, the console will then search room.txt for the room number thats split with ','

```<code>class Program
{
    static void Main(string[] args)
    {
        int counter = 0;
        string line;
        string roomNumber;

        Console.WriteLine("Enter room number");
        roomNumber = Console.ReadLine();
        // Read the file and display it line by line.
        System.IO.StreamReader file = new
              System.IO.StreamReader("room.txt");
        while ((line = file.ReadLine()) != null)
        {
            string[] words = line.Split(',');
            if (roomNumber == words[1])
            {
                Console.WriteLine(line);
            }
                counter++;
        }

        file.Close();

        // Suspend the screen.
         Console.ReadLine();
        }
    }
}
</code>```

How do i make it so that it will write "Invalid room number" when it cant find it in the text file, and then loop back to asking the room number.

答:
If you want to keep your current code, you can just use a do while loop which will check a boolean specifying if you found a line or not, and exit the loop only when a value is found.

```<code>class Program
{
    static void Main(string[] args)
    {
        int counter = 0;
        bool lineFound = false;
        string line;
        string roomNumber;

        do
        {
            Console.WriteLine("Enter room number");
            roomNumber = Console.ReadLine();
            // Read the file and display it line by line.
            using (StreamReader file = new StreamReader("room.txt"))
            {
                while ((line = file.ReadLine()) != null)
                {
                    string[] words = line.Split(',');
                    if (roomNumber == words[1])
                    {
                        Console.WriteLine(line);
                        lineFound = true;
                    }
                        counter++;
                }

                if(!lineFound)
                {
                    Console.WriteLine("Invalid room number");
                }
            }

        } while(!lineFound);

        // Suspend the screen.
         Console.ReadLine();
        }
    }
}
</code>```

Body:
I have this C# console application code here that reads text from a file.
when a user inputs a value, it searches the file for lines that contain that value.
In my case, the console will ask for a room number, the console will then search room.txt for the room number thats split with ','

class Program
{
    static void Main(string[] args)
    {
        int counter = 0;
        string line;
        string roomNumber;

        Console.WriteLine("Enter room number");
        roomNumber = Console.ReadLine();
        // Read the file and display it line by line.
        System.IO.StreamReader file = new
              System.IO.StreamReader("room.txt");
        while ((line = file.ReadLine()) != null)
        {
            string[] words = line.Split(',');
            if (roomNumber == words[1])
            {
                Console.WriteLine(line);
            }
                counter++;
        }

        file.Close();

        // Suspend the screen.
         Console.ReadLine();
        }
    }
}

How do i make it so that it will write "Invalid room number" when it cant find it in the text file, and then loop back to asking the room number.

Body:
If you want to keep your current code, you can just use a do while loop which will check a boolean specifying if you found a line or not, and exit the loop only when a value is found.

class Program
{
    static void Main(string[] args)
    {
        int counter = 0;
        bool lineFound = false;
        string line;
        string roomNumber;

        do
        {
            Console.WriteLine("Enter room number");
            roomNumber = Console.ReadLine();
            // Read the file and display it line by line.
            using (StreamReader file = new StreamReader("room.txt"))
            {
                while ((line = file.ReadLine()) != null)
                {
                    string[] words = line.Split(',');
                    if (roomNumber == words[1])
                    {
                        Console.WriteLine(line);
                        lineFound = true;
                    }
                        counter++;
                }

                if(!lineFound)
                {
                    Console.WriteLine("Invalid room number");
                }
            }

        } while(!lineFound);

        // Suspend the screen.
         Console.ReadLine();
        }
    }
}


问:
Discovering Hazelcast Cluster Groups
I'm using a couple of Hazelcast clusters for separate purposes and don't want them to interact so have used different cluster groups. I've written a simple monitor application to keep track of the members of each cluster, but wondered if there's a way of determining which cluster groups are reachable? The monitor connects as a client and I've had to hard code cluster group names in my application configuration so it can attempt to create a connection with each. That's fine for the moment with only two groups but as my usage expands it would be helpful if I could programmatically determine all the clusters available for connection - is this possible?

Thanks

答:
A possible solution:
Instantiate two clients with different configs, one is configured for cluster1 and the other for cluster2. Attach, client lifecycle listener to each client. Look for CLIENT_DISCONNECTED and CLIENT_CONNECTED events.</p>

Title: Discovering Hazelcast Cluster Groups


问:
PHP sum two different minutes
i have two different break time

default break time

extra break time

here i want to sum of two times and display 12 hrs format

EX :

```<code>$default_time = "00:30";
 $extra_time   = "00:25";
</code>```

my expected output : 00:55

but now display 01:00

this is my code

```<code>$default_time = $work_data->break_time;
$break_time =  $work_data->extra_time;
$total_break = strtotime($default_time)+strtotime($break_time);
echo date("h:i",strtotime($total_break));
</code>```

答:
You could try the following:

```<code>$default_time = $work_data->break_time;
$date_start = new DateTime($default_time);
$break_time =  $work_data->extra_time;
$interval = new DateInterval("PT" . str_replace(":", "H", $break_time) . "M");
$date_end = $date_start->add($interval);
echo $date_end->format("H:i");
</code>```

Note that this doesn't account for times which span a 24 hour period

Title: PHP sum two different minutes

Body:
i have two different break time

default break time

extra break time

here i want to sum of two times and display 12 hrs format

EX :

$default_time = "00:30";
 $extra_time   = "00:25";

my expected output : 00:55

but now display 01:00

this is my code

$default_time = $work_data->break_time;
$break_time =  $work_data->extra_time;
$total_break = strtotime($default_time)+strtotime($break_time);
echo date("h:i",strtotime($total_break));

Body:
You could try the following:

$default_time = $work_data->break_time;
$date_start = new DateTime($default_time);
$break_time =  $work_data->extra_time;
$interval = new DateInterval("PT" . str_replace(":", "H", $break_time) . "M");
$date_end = $date_start->add($interval);
echo $date_end->format("H:i");

Note that this doesn't account for times which span a 24 hour period


问:
How to use declared variable for SQL statement by using "IN" condition
I am trying to write some code but it doesn't work. It only those TypeT description. How can I display the TypeT and TypeS condition for below case?

```<code>DECLARE @PaymentType VARCHAR(20) = '';

SELECT @PaymentType = LISTID
FROM LIST
WHERE LISTCONFIG IN ('TypeT', 'TypeS')

SELECT *
FROM LIST
WHERE LISTID IN  (@PaymentType)
</code>```

答:
Another sollution is using dynamic strings. If your sql version is below 2016</p>

```<code>DECLARE @PaymentType VARCHAR(20)
SELECT @PaymentType= isnull(@PaymentType+',','')+LISTID FROM list WHERE LISTID IN ('TypeT','TypeS')
exec('SELECT * FROM LIST WHERE LISTID IN  ('+@PaymentType+')')
</code>```

Body:
I am trying to write some code but it doesn't work. It only those TypeT description. How can I display the TypeT and TypeS condition for below case?

DECLARE @PaymentType VARCHAR(20) = '';

SELECT @PaymentType = LISTID
FROM LIST
WHERE LISTCONFIG IN ('TypeT', 'TypeS')

SELECT *
FROM LIST
WHERE LISTID IN  (@PaymentType)

Body:
Another sollution is using dynamic strings. If your sql version is below 2016

DECLARE @PaymentType VARCHAR(20)
SELECT @PaymentType= isnull(@PaymentType+',','')+LISTID FROM list WHERE LISTID IN ('TypeT','TypeS')
exec('SELECT * FROM LIST WHERE LISTID IN  ('+@PaymentType+')')


答:
I think this should work but it's not tested:

```<code>Product.objects.filter(packaging__available=True,subcategories__category_id__in=[id_of_male])
</code>```

it isn't tested but I think that subcategories should be plural (related_name), if you didn't set related_name, then subcategory__set instead od subcategories should work.

Probably subcategories__category_id__in=[id_of_male] can be switched to .._id=id_of_male.

Title: Django - joining multiple tables (models) and filtering out based on their attribute

Body:
I think this should work but it's not tested:

Product.objects.filter(packaging__available=True,subcategories__category_id__in=[id_of_male])

it isn't tested but I think that subcategories should be plural (related_name), if you didn't set related_name, then subcategory__set instead od subcategories should work.

Probably subcategories__category_id__in=[id_of_male] can be switched to .._id=id_of_male.


问:
JSON root key configuration
{
 "name:Sagar": {
  "Subject1": "Maths",
  "Subject2": "science",
  "Subject3": "English",
  "Subject4": "French"
 }
}

how to parse this json payload ?  Normally we use "name":"Sagar" but know my query is "name:sagar" . Please help me to solve this type of JSON payload .

答:
you did not specify the language, so here is Javascript example. The main idea is that, you parse JSON as normal and then you take the root key and explode it by ":" and then use only the value after ":"</p>

```<code>var object = JSON.parse(jsonstring);
for(var i in object) {
  var name = i.split(":");
  object[name[1]] = object[i];
  delete object[i];
}
</code>```

Title: JSON root key configuration

Body:
you did not specify the language, so here is Javascript example. The main idea is that, you parse JSON as normal and then you take the root key and explode it by ":" and then use only the value after ":"

var object = JSON.parse(jsonstring);
for(var i in object) {
  var name = i.split(":");
  object[name[1]] = object[i];
  delete object[i];
}


问:
How to change marker Image in Mapbox?
I am new to mapbox. I am getting trouble in marker image change in mapbox map.
I got the code from https://www.mapbox.com/mapbox-gl-js/example/custom-marker-icons/  I can't change  the marker image.

Here is my code:

```<code>var geojson = {
"type": "FeatureCollection",
"features": [
    {
        "type": "Feature",
        "properties": {
            "message": "IN",
            "iconSize": [30, 30]
        },
        "geometry": {
            "type": "Point",
            "coordinates":<?php echo $in; ?>
        }
    },
    {
        "type": "Feature",
        "properties": {
            "message": "Check IN",
            "iconSize": [30, 30]
        },
        "geometry": {
            "type": "Point",
            "coordinates":<?php echo $c; ?>
        }
    },
    {
        "type": "Feature",
        "properties": {
            "message": "OUT",
            "iconSize": [30, 30]
        },
        "geometry": {
            "type": "Point",
            "coordinates":<?php echo $o; ?>
        }
    }
    ]
};

geojson.features.forEach(function(marker) {

    var el = document.createElement('div');
    el.className = 'marker';
    el.style.backgroundImage = 'url(images/check_in.jpg)';
    el.style.width = marker.properties.iconSize[0] + 'px';
    el.style.height = marker.properties.iconSize[1] + 'px';

    el.addEventListener('click', function() {
        window.alert(marker.properties.message);
    });

    new mapboxgl.Marker(el, {offset: [-marker.properties.iconSize[0] / 2, -marker.properties.iconSize[1] / 2]})
        .setLngLat(marker.geometry.coordinates)
        .addTo(map);
});
</code>```

答:
This if from their website:

```<code>geojson.features.forEach(function(marker) {
    // create a DOM element for the marker
    var el = document.createElement('div');
    el.className = 'marker';
    el.style.backgroundImage = 'url(https://placekitten.com/g/' + marker.properties.iconSize.join('/') + '/)';
    el.style.width = marker.properties.iconSize[0] + 'px';
    el.style.height = marker.properties.iconSize[1] + 'px';

    el.addEventListener('click', function() {
        window.alert(marker.properties.message);
    });

    // add marker to map
    new mapboxgl.Marker(el, {offset: [-marker.properties.iconSize[0] / 2, -marker.properties.iconSize[1] / 2]})
        .setLngLat(marker.geometry.coordinates)
        .addTo(map);
});
</code>```

I think you missed + marker.properties.iconSize.join('/') + '/)'; in this part: el.style.backgroundImage = 'url(https://placekitten.com/g/' + marker.properties.iconSize.join('/') + '/)';

Title: How to change marker Image in Mapbox?

Body:
I am new to mapbox. I am getting trouble in marker image change in mapbox map.
I got the code from https://www.mapbox.com/mapbox-gl-js/example/custom-marker-icons/  I can't change  the marker image.

Here is my code:

var geojson = {
"type": "FeatureCollection",
"features": [
    {
        "type": "Feature",
        "properties": {
            "message": "IN",
            "iconSize": [30, 30]
        },
        "geometry": {
            "type": "Point",
            "coordinates":<?php echo $in; ?>
        }
    },
    {
        "type": "Feature",
        "properties": {
            "message": "Check IN",
            "iconSize": [30, 30]
        },
        "geometry": {
            "type": "Point",
            "coordinates":<?php echo $c; ?>
        }
    },
    {
        "type": "Feature",
        "properties": {
            "message": "OUT",
            "iconSize": [30, 30]
        },
        "geometry": {
            "type": "Point",
            "coordinates":<?php echo $o; ?>
        }
    }
    ]
};

geojson.features.forEach(function(marker) {

    var el = document.createElement('div');
    el.className = 'marker';
    el.style.backgroundImage = 'url(images/check_in.jpg)';
    el.style.width = marker.properties.iconSize[0] + 'px';
    el.style.height = marker.properties.iconSize[1] + 'px';

    el.addEventListener('click', function() {
        window.alert(marker.properties.message);
    });

    new mapboxgl.Marker(el, {offset: [-marker.properties.iconSize[0] / 2, -marker.properties.iconSize[1] / 2]})
        .setLngLat(marker.geometry.coordinates)
        .addTo(map);
});

Body:
This if from their website:

geojson.features.forEach(function(marker) {
    // create a DOM element for the marker
    var el = document.createElement('div');
    el.className = 'marker';
    el.style.backgroundImage = 'url(https://placekitten.com/g/' + marker.properties.iconSize.join('/') + '/)';
    el.style.width = marker.properties.iconSize[0] + 'px';
    el.style.height = marker.properties.iconSize[1] + 'px';

    el.addEventListener('click', function() {
        window.alert(marker.properties.message);
    });

    // add marker to map
    new mapboxgl.Marker(el, {offset: [-marker.properties.iconSize[0] / 2, -marker.properties.iconSize[1] / 2]})
        .setLngLat(marker.geometry.coordinates)
        .addTo(map);
});

I think you missed + marker.properties.iconSize.join('/') + '/)'; in this part: el.style.backgroundImage = 'url(https://placekitten.com/g/' + marker.properties.iconSize.join('/') + '/)';


问:
Class Cast Exception when DeSerializing an Object
Overview

I am new to Android development and I am trying to serialize and then deserialize the value of an object but I am getting exception.

Exception

FATAL EXCEPTION: main

java.lang.ClassCastException: java.io.File cannot be cast to com.testingapplication.SchoolNameDetails
com.testingapplication.fragment.HomeFragment$1.onClick(HomeFragment.java:62)

What I tried

SchoolNameDetails class is as follows:

```<code>public class SchoolNameDetails implements Serializable {
private int id;
private String schoolname;
private String level;
private String pkno;
private String nano;
private String ucname;
private String officeno;
private static final long serialVersionUID = 46548923;

public SchoolNameDetails(){}

public SchoolNameDetails(String schoolname, String level, String pkno,String nano, String ucname, String officeno){
    this.schoolname=schoolname;
    this.level=level;
    this.pkno=pkno;
    this.nano=nano;
    this.ucname=ucname;
    this.officeno=officeno;
}

public SchoolNameDetails(int id, String schoolname, String level, String pkno,String nano, String ucname, String officeno){
    this.id=id;
    this.schoolname=schoolname;
    this.level=level;
    this.pkno=pkno;
    this.nano=nano;
    this.ucname=ucname;
    this.officeno=officeno;
}

public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public String getSchoolname() {
    return schoolname;
}
public void setSchoolname(String schoolname) {
    this.schoolname = schoolname;
}
public String getLevel() {
    return level;
}
public void setLevel(String level) {
    this.level = level;
}
public String getPkno() {
    return pkno;
}
public void setPkno(String pkno) {
    this.pkno = pkno;
}
public String getNano() {
    return nano;
}
public void setNano(String nano) {
    this.nano = nano;
}
public String getUcname() {
    return ucname;
}
public void setUcname(String ucname) {
    this.ucname = ucname;
}
public String getOfficeno() {
    return officeno;
}
public void setOfficeno(String officeno) {
    this.officeno = officeno;
}
</code>```

}

and here I am serializing the object

```<code>@Override
protected void onStop() {
    super.onStop();
    SchoolNameDetails details = new SchoolNameDetails();
    details.setSchoolname(t2.getText().toString());
    details.setLevel(t2a.getText().toString());
    details.setPkno(t5.getText().toString());
    details.setNano(t6.getText().toString());
    details.setUcname(t7.getText().toString());
    details.setOfficeno(t8.getText().toString());

    saveObject(details);

}

public void saveObject(SchoolNameDetails d) {
    try
    {
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("/sdcard/save_object.ser")));
        oos.flush();
        oos.close();
    }
    catch(Exception ex)
    {
        Log.v("Error",ex.getMessage());
        ex.printStackTrace();
    }

}
</code>```

and Here I am deserializing the object in my Fragment class

```<code>@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_home,
            container, false);
    Button b1= (Button) view.findViewById(R.id.button1);
    final TextView t1 = (TextView) view.findViewById(R.id.textView1);
    b1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            SchoolNameDetails details = (SchoolNameDetails)loadSerializedObject(new File("/sdcard/save_object.ser"));
            System.out.println("Name : " + details.getSchoolname());
        }

    });

    return view;
}
public Object loadSerializedObject(File f)
{
    try
    {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f));
        Object o = ois.readObject();

    }
    catch(Exception ex)
    {
        Log.v("Error : ","" + ex.getMessage());
        ex.printStackTrace();
    }
    return f;
}
</code>```

Now the last return value gives exception. i tried with return null but then it gives null pointer exception.Please Help I am stuck in this for hours and haven't found any solution

答: You're returning f at the end of the function. But you have to return o (what you've got from method ois.readObject().</p>

Body:
Overview

I am new to Android development and I am trying to serialize and then deserialize the value of an object but I am getting exception.

Exception

FATAL EXCEPTION: main

java.lang.ClassCastException: java.io.File cannot be cast to com.testingapplication.SchoolNameDetails
com.testingapplication.fragment.HomeFragment$1.onClick(HomeFragment.java:62)

What I tried

SchoolNameDetails class is as follows:

public class SchoolNameDetails implements Serializable {
private int id;
private String schoolname;
private String level;
private String pkno;
private String nano;
private String ucname;
private String officeno;
private static final long serialVersionUID = 46548923;

public SchoolNameDetails(){}

public SchoolNameDetails(String schoolname, String level, String pkno,String nano, String ucname, String officeno){
    this.schoolname=schoolname;
    this.level=level;
    this.pkno=pkno;
    this.nano=nano;
    this.ucname=ucname;
    this.officeno=officeno;
}

public SchoolNameDetails(int id, String schoolname, String level, String pkno,String nano, String ucname, String officeno){
    this.id=id;
    this.schoolname=schoolname;
    this.level=level;
    this.pkno=pkno;
    this.nano=nano;
    this.ucname=ucname;
    this.officeno=officeno;
}

public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public String getSchoolname() {
    return schoolname;
}
public void setSchoolname(String schoolname) {
    this.schoolname = schoolname;
}
public String getLevel() {
    return level;
}
public void setLevel(String level) {
    this.level = level;
}
public String getPkno() {
    return pkno;
}
public void setPkno(String pkno) {
    this.pkno = pkno;
}
public String getNano() {
    return nano;
}
public void setNano(String nano) {
    this.nano = nano;
}
public String getUcname() {
    return ucname;
}
public void setUcname(String ucname) {
    this.ucname = ucname;
}
public String getOfficeno() {
    return officeno;
}
public void setOfficeno(String officeno) {
    this.officeno = officeno;
}

}

and here I am serializing the object

@Override
protected void onStop() {
    super.onStop();
    SchoolNameDetails details = new SchoolNameDetails();
    details.setSchoolname(t2.getText().toString());
    details.setLevel(t2a.getText().toString());
    details.setPkno(t5.getText().toString());
    details.setNano(t6.getText().toString());
    details.setUcname(t7.getText().toString());
    details.setOfficeno(t8.getText().toString());

    saveObject(details);

}

public void saveObject(SchoolNameDetails d) {
    try
    {
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("/sdcard/save_object.ser")));
        oos.flush();
        oos.close();
    }
    catch(Exception ex)
    {
        Log.v("Error",ex.getMessage());
        ex.printStackTrace();
    }

}

and Here I am deserializing the object in my Fragment class

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_home,
            container, false);
    Button b1= (Button) view.findViewById(R.id.button1);
    final TextView t1 = (TextView) view.findViewById(R.id.textView1);
    b1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            SchoolNameDetails details = (SchoolNameDetails)loadSerializedObject(new File("/sdcard/save_object.ser"));
            System.out.println("Name : " + details.getSchoolname());
        }

    });

    return view;
}
public Object loadSerializedObject(File f)
{
    try
    {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f));
        Object o = ois.readObject();

    }
    catch(Exception ex)
    {
        Log.v("Error : ","" + ex.getMessage());
        ex.printStackTrace();
    }
    return f;
}

Now the last return value gives exception. i tried with return null but then it gives null pointer exception.Please Help I am stuck in this for hours and haven't found any solution


问:
SQL 2008 Full Text Search from Classic ASP?
I have a legacy app in which I need to enable search.

Recently we've switched to SQL 2008 and I was wondering to do it with it's Full Text Search.

However my question is...is there API available for Classic ASP? Any references?

答:
I think full text search is a completly service side feature and that you only send normal SQL queries in which case normal ADODB should be sufficent to use it.

But I have never tried fulltext service my self so I am not a 100 % sure.


问:
Escape sequence for bold text in Bixolon printer
What is correct syntax for creating Escape Sequences that work with Bixolon printers? I would like to see some samples for bold text that will work on SPP-R200III Bixolon printer. Thanks in advance.</p>

答:
Here are some examples of Escape Sequences that can be used with Bixolon printers:</p>

```<code>//Double-strike mode
printline = "\x1BG1" + printline + "\x1BG0";

// Underline mode 1
printline = "\x1B" + "\x2D" + "\x1" + printline + "\x1B" + "\x2D" + "\x0";

// Underline mode 2
printline = "\x1B" + "\x2D" + "\x2" + printline + "\x1B" + "\x2D" + "\x0";

// Emphasized mode
printline = "\x1B\x21\x8" + printline + "\x1B\x21\x0";
</code>```

Body:
Here are some examples of Escape Sequences that can be used with Bixolon printers:

//Double-strike mode
printline = "\x1BG1" + printline + "\x1BG0";

// Underline mode 1
printline = "\x1B" + "\x2D" + "\x1" + printline + "\x1B" + "\x2D" + "\x0";

// Underline mode 2
printline = "\x1B" + "\x2D" + "\x2" + printline + "\x1B" + "\x2D" + "\x0";

// Emphasized mode
printline = "\x1B\x21\x8" + printline + "\x1B\x21\x0";