问:
Deleting a record from Firebase by ID
I'm trying to delete records from my FireBase DB, based on the record's ID, but the records are not being deleted.

I've read SO posts like How to delete/remove nodes on Firebase, remove-item-from-firebase and few more, but I cannot solve my problem.

The database's structure is:

```<code>my_project
|
|-messages
 |+Kg87....
 |+Kg9a....
 |+and so on...
</code>```

My code:

```<code>const firebaseConfig = {
    apiKey: "AIza....",
    authDomain: ".firebaseapp.com",
    databaseURL: "https://myProject.firebaseio.com",
    storageBucket: "myproject.appspot.com",
    messagingSenderId: ""
};

firebase.initializeApp(firebaseConfig);
exports.delete =
functions.database.ref('/messages/{pushId}/text')
    .onWrite(event => {
        var db = firebase.database();
        var ref = db.ref("messages");
        //console.log(ref.child("-Kg9a...").toJSON()); //- OK prints https://myproject.firebaseio.com/messages/Kg9a...
        ref.child("-KgOASNRfF2PheKQ6Yfu").remove();  //Does nothing, returns promise - pending
    });
</code>```

To my understanding ref is a reference to the messages node, so ref.child("Kg9a....") is a reference to the desired child.

I don't get any error, but nothing happens. The record remains in the DB.

If I change the last line to console.log(ref.child("Kg9a....").remove()); I see that the log says  Promise { <pending> } but even after few hours nothing happens.

This is not a security rule issue - I've set my security rules to ".read": true, ".write": true and it still doesn't delete the record.

My firebase version is 3.5.0 - I've installed 3.7.1, but when I run firebase -V I get that the version is 3.5.0.

Any advice?

答:
A few changes to get that working. I assume you really want to delete the record that triggered the event, not the literal string ID in your example. You needed to return the promise you were getting back from remove() though I have found even having a then() handler will work but since returning it is documented as necessary I usually do both. Promises are like result/return codes, usually not to be ignored.</p>

```<code>var someId = '-KgOASNRfF2PheKQ6Yfu';
exports.delete =
    functions.database.ref('/messages/{pushId}/text')
        .onWrite(event => {
          if (!event.data.exists()) return;
          var ref = event.data.adminRef.root.child('/messages').child(someId);
          return ref.remove().then(function(){
            console.log('OK, gone');
          }).catch(function(e){
            console.log('OOPS, problem: ' + e.message);
          })
        });
</code>```

Title: Deleting a record from Firebase by ID

Body:
I'm trying to delete records from my FireBase DB, based on the record's ID, but the records are not being deleted.

I've read SO posts like How to delete/remove nodes on Firebase, remove-item-from-firebase and few more, but I cannot solve my problem.

The database's structure is:

my_project
|
|-messages
 |+Kg87....
 |+Kg9a....
 |+and so on...

My code:

const firebaseConfig = {
    apiKey: "AIza....",
    authDomain: ".firebaseapp.com",
    databaseURL: "https://myProject.firebaseio.com",
    storageBucket: "myproject.appspot.com",
    messagingSenderId: ""
};

firebase.initializeApp(firebaseConfig);
exports.delete =
functions.database.ref('/messages/{pushId}/text')
    .onWrite(event => {
        var db = firebase.database();
        var ref = db.ref("messages");
        //console.log(ref.child("-Kg9a...").toJSON()); //- OK prints https://myproject.firebaseio.com/messages/Kg9a...
        ref.child("-KgOASNRfF2PheKQ6Yfu").remove();  //Does nothing, returns promise - pending
    });

To my understanding ref is a reference to the messages node, so ref.child("Kg9a....") is a reference to the desired child.

I don't get any error, but nothing happens. The record remains in the DB.

If I change the last line to console.log(ref.child("Kg9a....").remove()); I see that the log says  Promise { <pending> } but even after few hours nothing happens.

This is not a security rule issue - I've set my security rules to ".read": true, ".write": true and it still doesn't delete the record.

My firebase version is 3.5.0 - I've installed 3.7.1, but when I run firebase -V I get that the version is 3.5.0.

Any advice?

Body:
A few changes to get that working. I assume you really want to delete the record that triggered the event, not the literal string ID in your example. You needed to return the promise you were getting back from remove() though I have found even having a then() handler will work but since returning it is documented as necessary I usually do both. Promises are like result/return codes, usually not to be ignored.

var someId = '-KgOASNRfF2PheKQ6Yfu';
exports.delete =
    functions.database.ref('/messages/{pushId}/text')
        .onWrite(event => {
          if (!event.data.exists()) return;
          var ref = event.data.adminRef.root.child('/messages').child(someId);
          return ref.remove().then(function(){
            console.log('OK, gone');
          }).catch(function(e){
            console.log('OOPS, problem: ' + e.message);
          })
        });


来源: stackexchange

问:
How to get all rows from multi tables using 1 query
I have 4 tables (movies, series, lists and list_titles), the question is: How to do to get all movies, series attached to particular list in list_titles table?

Here is what I have done sqlfiddle.

Query:

```<code>select *
from (
    select srs.*
    from series srs
    left join list_titles lt on lt.type_id = srs.id
    where lt.list_id = 7
        and lt.type_name = 'series'
        and lt.user_id = 1
    ) as a,
    (
        select mo.*
        from movies mo
        left join list_titles tl on tl.type_id = mo.id
        where tl.list_id = 7
            and tl.type_name = 'series'
            and tl.user_id = 1
        ) as b
</code>```

答:
```<code>select * from
(
  select srs.id, srs.title_name from series srs join
    (
    select * from list_titles
      where list_id = 7 and type_name = 'series' and user_id = 1
    ) as part1
  on part1.type_id = srs.id
) as a

union

select * from
(
  select mo.id, mo.title_name from movies mo join
    (
    select * from list_titles
      where list_id = 7 and type_name = 'series' and user_id = 1
    ) as part2
  on part2.type_id = mo.id
) as b;
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have 4 tables (movies, series, lists and list_titles), the question is: How to do to get all movies, series attached to particular list in list_titles table?

Here is what I have done sqlfiddle.

Query:

select *
from (
    select srs.*
    from series srs
    left join list_titles lt on lt.type_id = srs.id
    where lt.list_id = 7
        and lt.type_name = 'series'
        and lt.user_id = 1
    ) as a,
    (
        select mo.*
        from movies mo
        left join list_titles tl on tl.type_id = mo.id
        where tl.list_id = 7
            and tl.type_name = 'series'
            and tl.user_id = 1
        ) as b


问:
Postback with setTimeout function using wrong?
I use the old system, developed on framework 1.0, and running now on framework 2.0
Source code is:

```<code><select name="DropDownList1" AutoPostBack="true" id="DropDownList1" runat="server">
  <option selected="selected" value="One">One</option>
  <option value="Two">Two</option
</select>
</code>```

Generated html:

```<code><select name="DropDownList1" onchange="javascript:setTimeout('__doPostBack(\'DropDownList1\',\'\')', 0)" id="DropDownList1">
  <option selected="selected" value="One">One</option>
  <option value="Two">Two</option>
</select>
</code>```

Its not work until I remove quotes around __doPostBack. Why?
I receive a javascript error 1032: Invalid character.
How I make it work?
Thanks!

答:
Found here, after spent a hours to solve:
https://groups.google.com/forum/#!topic/microsoft.public.scripting.vbscript/q_Yp5Ngczeo

Answer:
If you include a VBScript code block before any other code block on an
ASPX page, the following statement will fail in IE (and the error is
far from obvious since it is untrappable and says only that there is an
Invalid character on line 1, character 2):

"javascript:setTimeout('__doPostBack(\'anyASPXcontrol\',\'\')', 0)"

This is a bug in IE 6 and possibly earlier versions (I only have v6 to
play with.)  I do not know if it affects IE 7 as I have not installed
that for testing lately.  Note that even though the prefix of
"javascript:" is used, the setTimeout function assumes it's calling a
VBScript function, presumably because the first script block is a
VBScript block.

Body:
I use the old system, developed on framework 1.0, and running now on framework 2.0
Source code is:

<select name="DropDownList1" AutoPostBack="true" id="DropDownList1" runat="server">
  <option selected="selected" value="One">One</option>
  <option value="Two">Two</option
</select>

Generated html:

<select name="DropDownList1" onchange="javascript:setTimeout('__doPostBack(\'DropDownList1\',\'\')', 0)" id="DropDownList1">
  <option selected="selected" value="One">One</option>
  <option value="Two">Two</option>
</select>

Its not work until I remove quotes around __doPostBack. Why?
I receive a javascript error 1032: Invalid character.
How I make it work?
Thanks!


问:
How to hide pages of certain page types to the content editor
I want to hide my pages regarding Search functionality for the role of type content editor. How can I do this in Kentico 10?? Please help.</p>

答: What do you mean by hiding content type for a role in search functionality? You can deny read for a certain role on security tab in Pages application (for a page, not for a page type).


问:
querying over multiple data from function in PostgreSQL
I have a function which gives stock levels:

```<code>select * from stocklevel(ID)
</code>```

This function gives stock leverl per ID.
For example:

```<code>select * from stocklevel(23)
</code>```

Result is:

```<code>   ID  datelevel  stocklevel
   23   01.01.17   15
   23   02.01.17   18
   23   05.01.17   20
</code>```

This is the stock level for ID=23.

Not all dates appear, it depends on many things.

I want to use this function to get the stock levels for all parts from my system

basically something like this:

```<code>select *,(select stocklevel from stocklevel(parts.partid) where datelevel = ??? )
from parts
</code>```

OR:

```<code>  select *
  from parts
  left join ( select stocklevel from stocklevel(parts.partid) where datelevel = ??? ) using (ID)
</code>```

Now, the issue is with the WHERE condition I want to specific a specific date like '04.01.17' but if the date does not exist i want it to take the date before that so:

for the ID=23 and date '04.01.17' it should show 18,'02.01.17' .

for the ID=23 and date '15.01.13' it should show nothing.

for the ID=23 and date '05.01.17' it should show 20,'05.01.17' .

How can I do that?

答:
```<code>select *
  from parts
  left join ( select stocklevel
      from stocklevel(parts.partid)
      where datelevel = (select max(datelevel)
            from stocklevel(parts.partid) sl2
            where sl2.datelevel <= '04.01.17') using(ID) ) using (ID)
</code>```

untested...

Body:
I have a function which gives stock levels:

select * from stocklevel(ID)

This function gives stock leverl per ID.
For example:

select * from stocklevel(23)

Result is:

   ID  datelevel  stocklevel
   23   01.01.17   15
   23   02.01.17   18
   23   05.01.17   20

This is the stock level for ID=23.

Not all dates appear, it depends on many things.

I want to use this function to get the stock levels for all parts from my system

basically something like this:

select *,(select stocklevel from stocklevel(parts.partid) where datelevel = ??? )
from parts

OR:

  select *
  from parts
  left join ( select stocklevel from stocklevel(parts.partid) where datelevel = ??? ) using (ID)

Now, the issue is with the WHERE condition I want to specific a specific date like '04.01.17' but if the date does not exist i want it to take the date before that so:

for the ID=23 and date '04.01.17' it should show 18,'02.01.17' .

for the ID=23 and date '15.01.13' it should show nothing.

for the ID=23 and date '05.01.17' it should show 20,'05.01.17' .

How can I do that?

Body:
select *
  from parts
  left join ( select stocklevel
      from stocklevel(parts.partid)
      where datelevel = (select max(datelevel)
            from stocklevel(parts.partid) sl2
            where sl2.datelevel <= '04.01.17') using(ID) ) using (ID)

untested...


答:
Assuming that you cannot use STRING_SPLIT() function (available from SQL Server 2016) you will first need a function to tokenise a varchar column. There are hundreds of them in the web, I leave it up to you though to pick the most suitable and well-tested.

For my example I will go with this, which works for your sample:

```<code>CREATE FUNCTION [dbo].[fnSplitString]
(
    @string NVARCHAR(MAX),
    @delimiter CHAR(1)
)
RETURNS @output TABLE(splitdata NVARCHAR(MAX)
)
BEGIN
    DECLARE @start INT, @end INT
    SELECT @start = 1, @end = CHARINDEX(@delimiter, @string)
    WHILE @start < LEN(@string) + 1 BEGIN
        IF @end = 0
            SET @end = LEN(@string) + 1

        INSERT INTO @output (splitdata)
        VALUES(SUBSTRING(@string, @start, @end - @start))
        SET @start = @end + 1
        SET @end = CHARINDEX(@delimiter, @string, @start)

    END
    RETURN
END
</code>```

Applying the split function

```<code>select t.date, x.splitdata
from test t
cross apply dbo.fnSplitString(
   coalesce(col1, '') + coalesce(col2, '')
   + coalesce(col3, '') + coalesce(col4, '')
, '/') x
where coalesce(x.splitdata, '') <> ''
</code>```

rextester demo

Note that in the demo I used the Id column instead of the date column.

Title: Return date from value exploded in some columns on SQL Server

Body:
I would like to return the date for each string exploded by slash on SQL Server.

My database table:

id | date       | col1        | col2      | col3  | col4
---+------------+-------------+-----------+-------+------------
1  | 2017-04-02 | /txt1/txt2  |           |       |
2  | 2017-04-03 |             | /txt1/txt4|       |
3  | 2017-04-04 |             |/txt2/txt3 |       |
4  | 2017-04-05 |             |/txt4      |       |/txt5/txt6

Result wanted:

2017-04-02 txt1
2017-04-02 txt2
2017-04-03 txt1
2017-04-03 txt4
2017-04-04 txt2
2017-04-04 txt3
2017-04-05 txt4
2017-04-05 txt5
2017-04-05 txt6

Thank you
Pierre

Body:
Assuming that you cannot use STRING_SPLIT() function (available from SQL Server 2016) you will first need a function to tokenise a varchar column. There are hundreds of them in the web, I leave it up to you though to pick the most suitable and well-tested.

For my example I will go with this, which works for your sample:

CREATE FUNCTION [dbo].[fnSplitString]
(
    @string NVARCHAR(MAX),
    @delimiter CHAR(1)
)
RETURNS @output TABLE(splitdata NVARCHAR(MAX)
)
BEGIN
    DECLARE @start INT, @end INT
    SELECT @start = 1, @end = CHARINDEX(@delimiter, @string)
    WHILE @start < LEN(@string) + 1 BEGIN
        IF @end = 0
            SET @end = LEN(@string) + 1

        INSERT INTO @output (splitdata)
        VALUES(SUBSTRING(@string, @start, @end - @start))
        SET @start = @end + 1
        SET @end = CHARINDEX(@delimiter, @string, @start)

    END
    RETURN
END

Applying the split function

select t.date, x.splitdata
from test t
cross apply dbo.fnSplitString(
   coalesce(col1, '') + coalesce(col2, '')
   + coalesce(col3, '') + coalesce(col4, '')
, '/') x
where coalesce(x.splitdata, '') <> ''

rextester demo

Note that in the demo I used the Id column instead of the date column.


问:
Detecting scrolling up is not working Well
i'm trying to use this code to get scrolling direction the problem is when scroll up the detection is not going well

```<code>$(window).bind('DOMMouseScroll scroll mousewheel', function(event) {

    if (event.originalEvent.wheelDelta >= 0) {
          console.log('scroll up');
        }else {
          console.log('scroll down');
    });

});
</code>```

Here's a screen capture of the result enter image description here it shows scroll up then scroll down but i'm not scrolling down

答:
You have way too many events bound.

Try this code, the only difference is that I use it on a div.

```<code>$('div').bind('mousewheel', function(event) {

    if (event.originalEvent.wheelDelta >= 0) {
          console.log('scroll up');
        }else {
          console.log('scroll down');
    }

});
</code>```

Here is a working JS fiddle:

https://jsfiddle.net/r1sjv2tv/

Edit: The above answer works, albeit only when using wheel scroll.
However, the window can also be scrolled with mouse. If you to handle it as well, it will get a bit more complex.

I have made a solution that listens to onscroll event and simply compares the current scrolltop position with the last scrolltop position to determine the direction of a scroll.

```<code>$('div').bind('scroll', function(event) {

  if ($(this).scrollTop() < $(this).data('last-scroll')) {
    console.log('scroll up');
  } else {
    console.log('scroll down');
  }

  $(this).data('last-scroll',$(this).scrollTop());
});
</code>```

This works independent of the original event trigger.

Please see the fiddle:

https://jsfiddle.net/r1sjv2tv/2/

Body:
i'm trying to use this code to get scrolling direction the problem is when scroll up the detection is not going well

$(window).bind('DOMMouseScroll scroll mousewheel', function(event) {

    if (event.originalEvent.wheelDelta >= 0) {
          console.log('scroll up');
        }else {
          console.log('scroll down');
    });

});

Here's a screen capture of the result enter image description here it shows scroll up then scroll down but i'm not scrolling down

Body:
You have way too many events bound.

Try this code, the only difference is that I use it on a div.

$('div').bind('mousewheel', function(event) {

    if (event.originalEvent.wheelDelta >= 0) {
          console.log('scroll up');
        }else {
          console.log('scroll down');
    }

});

Here is a working JS fiddle:

https://jsfiddle.net/r1sjv2tv/

Edit: The above answer works, albeit only when using wheel scroll.
However, the window can also be scrolled with mouse. If you to handle it as well, it will get a bit more complex.

I have made a solution that listens to onscroll event and simply compares the current scrolltop position with the last scrolltop position to determine the direction of a scroll.

$('div').bind('scroll', function(event) {

  if ($(this).scrollTop() < $(this).data('last-scroll')) {
    console.log('scroll up');
  } else {
    console.log('scroll down');
  }

  $(this).data('last-scroll',$(this).scrollTop());
});

This works independent of the original event trigger.

Please see the fiddle:

https://jsfiddle.net/r1sjv2tv/2/


问:
Bootstrap container gets margin-top 0
Why does my .container main_container div hang on the header? (Its not because the 2 php error message, i tried)

If i give the div about 100px margin-top, it will be okay, but that isn't a good method.

After the header, I added a clearfix div, but it did nothing.

Fiddle

```<code>    <nav class="navbar navbar-default navbar-fixed-top mainHeader">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="<?php echo $host; ?>"><?php echo $siteName; ?></a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav navbar-right">
        <?php
        $top_menuDown = mysqli_query($kapcs, "SELECT * FROM top_menu WHERE top_menu_id IN (1,3,4,5,6,7) ORDER BY top_menu_sorrend ASC");
        if(mysqli_num_rows($top_menuDown) > 0 )
        {
            while($top_nav = mysqli_fetch_assoc($top_menuDown))
            {
                echo '<li><a class="top_menu_to_link" href="'.$host.'/'.$top_nav['top_menu_seo'].'" title="'.$top_nav['top_menu_nev'].'">'.$top_nav['top_menu_nev'].'</a></li>';
            }
        }
        ?>
      </ul>
    </div>
  </div>
</nav>
<div class="clearfix"></div>
</code>```

答:
You have to use padding-top/margin-top to the body element. The reason is explained by @makshh. So just try to customize it based on screen size using Javascript.

Updated Fiddle

Here is an example--

$(window).resize(function() {
  if ($(".navbar.navbar-default.navbar-fixed-top.mainHeader").height() > 100) {
    $("html, body").css("padding-top", "150px");
  }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<title>Főoldal</title>

<body style="padding-top:100px;">
  <nav class="navbar navbar-default navbar-fixed-top mainHeader">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
        Nemzeti Reptéri Parkoló
      </div>
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li>Kezdőlap</li>
          <li>Információk</li>
          <li>Hírek, érdekességek</li>
          <li>Kapcsolat</li>
          <li>Árlista</li>
          <li>Galéria</li>
        </ul>
      </div>
    </div>
  </nav>
  <div class="clearfix"></div>
  <div class="container main_container">
    <div class="homepage_slideshow hidden-xs">
      <div class="home-slider-wrapper hidden-xs">
        <ul class="bxslider">
          <li><img src="https://kemenyem.hu/images/homepage_slideshow/93-3.jpg" title="Teszt kép 1" alt="Teszt kép 1" /></li>
          <li><img src="https://kemenyem.hu/images/homepage_slideshow/393-1.jpg" title="Teszt kép 2" alt="Teszt kép 2" /></li>
        </ul>
      </div>
    </div>
    <!--Slider end-->
    <div class="col-md-9 left_side">
      <div class="left_title_div">
        <h3 class="left_title">Parkolóhely foglalás online</h3>
      </div>
      <div class="content">
        <h3><strong>A megrendelés, árajánlatkérés menete</strong></h3>

        <p>Amennyiben árajánlatot szeretne kérni, azt a termékeknél a "Még jobb árat szeretnék" gombra, vagy a menüben az "Ajánlatkérés" menüpontra
          való kattintással teheti meg.</p>

        <p>A megjelenő ajánlatkérő ablakban / oldalon kérjük töltse ki az összes mezőt, és küldje el részünkre.</p>

        <p>Munkatársaink 2 munkanapon belül felveszik Önnel a kapcsolatot az Ön által megadott elérhetőségek valamelyikén.</p>

        <h3><strong>Fizetés</strong></h3>

        <p>Megrendelését előre utalással, vagy személyesen valamelyik telephelyünkön készpénzzel tudja fizetni. A budapesti telephelyünkön lehetőség van bankkártyás fizetésre
          is.</p>

        <h3><strong>Szállítás</strong></h3>

        <p>A részletes szállítási információkat megtekintheti a "Szállítás" menüpontban.</p>

        <h3><strong>Árak</strong></h3>

        <p>A weboldalon feltüntetett árak gyári árak, tartalmazzák a 27% ÁFÁ-t, de nem tartalmazzák a raklapok díját, a szállítást, és a lerakást.</p>
      </div>

      <div class="left_title_div">
        <h3 class="left_title">Legfrissebb hírek</h3>
      </div>
      <div class="news_box news_list">
        <div class="row main_hir_box">
          <div class="col-md-3 main_hir_box_thumb_div">
            <img src="https://kemenyem.hu/images/news/th_remy-metailler-hafjell_147-82712.jpg" class="img-responsive main_hir_img imageHoverOpacity" alt="Jobb lett az instant futtatás az új Android Studio 2.3-ban">
          </div>
          <div class="col-md-9 main_hir_box_data_div">
            <h2 class="main_hir_title_list">Jobb lett az instant futtatás az új Android Studio 2.3-ban</h2>
            <span class="main_hir_box_date">HÍREK | 2017-03-15 16:27</span>
            <p class="main_hir_box_desc">A Google a napokban új kiadást jelentett be integrált mobilos fejlesztőkörnyezetéből. Az új Android Studio 2.3 sok stabilitási fejlesztés mellett néhány érdekes funkcionális fejlesztést is hoz, amik az app-ok tervezését, tesztelését és a bennük
              történő hibakeresést egyaránt segítik majd.</p>
          </div>
        </div>
        <div class="row main_hir_box">
          <div class="col-md-3 main_hir_box_thumb_div">
            <img src="https://kemenyem.hu/images/news/thumb_ne-style-001-2532861600.jpg" class="img-responsive main_hir_img imageHoverOpacity" alt="Így fejleszthetsz egy PHP-SQL alkalmazást Git-tel az Azure-ba 2">
          </div>
          <div class="col-md-9 main_hir_box_data_div">
            <h2 class="main_hir_title_list">Így fejleszthetsz egy PHP-SQL alkalmazást Git-tel az Azure-ba 2</h2>
            <span class="main_hir_box_date">HÍREK | 2017-03-15 16:27</span>
            <p class="main_hir_box_desc">A bemutató feltételezi, hogy a gépeden már fel van telepítve a PHP, az SQL Server Express kiadása, valamint a Microsoft SQL Server meghajtói a PHP-hez és a Git verziókezelő is. A cikk során a következőket fogjuk megtanulni:</p>
          </div>
        </div>
        <div class="row main_hir_box">
          <div class="col-md-3 main_hir_box_thumb_div">
            <img src="https://kemenyem.hu/images/news/th_s1600_0815_km_01-12894.jpg" class="img-responsive main_hir_img imageHoverOpacity" alt="Óriásposzteren mutatja be a Visual Studio 2017 újdonságait a Microsoft">
          </div>
          <div class="col-md-9 main_hir_box_data_div">
            <h2 class="main_hir_title_list">Óriásposzteren mutatja be a Visual Studio 2017 újdonságait a Microsoft</h2>
            <span class="main_hir_box_date">HÍREK | 2017-03-15 16:25</span>
            <p class="main_hir_box_desc">A Microsoft a hét elején Visual Studio blogjában egy olyan, általa poszternek hívott dokumentumot tett közzé, amelyben múlt héten bemutatott új integrált fejlesztői környezete legfontosabb újdonságait mutatja be. A máshol csak infografikának
              hívott összeállításban az általános, produktivitást javító fejlesztések mellett unit-tesztelést segítő újdonságok, sőt, a C++, a C# és az ASP.NET újdonságai is említésre kerülnek.</p>
          </div>
        </div>
        <div class="row main_hir_box">
          <div class="col-md-3 main_hir_box_thumb_div">
            <img src="https://kemenyem.hu/images/news/th_p-dsc04186-81966.jpg" class="img-responsive main_hir_img imageHoverOpacity" alt="Új korszakot nyit a most elkészült LLVM és a Clang 4.0">
          </div>
          <div class="col-md-9 main_hir_box_data_div">
            <h2 class="main_hir_title_list">Új korszakot nyit a most elkészült LLVM és a Clang 4.0</h2>
            <span class="main_hir_box_date">HÍREK | 2017-03-15 16:24</span>
            <p class="main_hir_box_desc">Az LLVM fejlesztői a napokban "final" jelöléssel látták el az LLVM és a Clang következő, 4-es verzióját. Bár a hivatalos bejelentés és a csomagok közzétételére vélhetően csak ezen a héten kerül majd sor, a fordító-infrastruktúra
              és a hozzá kapcsolódó C/C++ fordító legújabb kiadása ezzel elkészültnek tekinthető.</p>
          </div>
        </div>
      </div>
    </div>
    <div class="col-md-3 right_side">
      <div class="left_title_div">
        <h3 class="left_title">Hírlevél</h3>
      </div>
      <div class="sidebar_data_div">
        <div class="sidebar_data">
          <p class="sidebar_text">Iratkozzon fel hírlevelünkre, hogy mindíg értesüljön az újdonsgokról, friss hírekről.</p>
          <form action="files/newsletter.php" method="post" id="SidebarNewsletterForm">
            <input type="text" id="newsletterName" name="NewsletterName" placeholder="Az Ön neve" class="form-control sidebar_input">
            <input type="text" id="NewsletterEmail" name="NewsletterEmail" placeholder="E-mail címe" class="form-control sidebar_input">
            <button type="button" id="NewsletterButton" name="NewsletterButton" class="sidebar_button"><i class="fa fa-envelope-o" aria-hidden="true"></i> Feliratkozás</button>
          </form>
        </div>
      </div>
    </div>
  </div>
  <footer class="footer-basic-centered">
    <p class="footer-links">
      KezdőlapInformációkHírek, érdekességekKapcsolatÁrlista
      <a
        class="footer_menu_to_link" href="https://kemenyem.hu/galeria" title="Galéria">Galéria</a>
    </p>
    <p class="footer-company-name">2017 <br />
      <b>Notice</b>: Undefined index: k_nev in <b>/home/grashu/public_html/kemenyem.hu/files/footer.php</b> on line <b>15</b><br /> © - Minden jog fentartva!</p>
  </footer>
  <div class="modal fade" id="newsletterModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header"><button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Bezárás</span></button>
          <h4 class="modal-title" id="myModalLabel">Értesítés</h4>
        </div>
        <div class="modal-body">
          <p id="newsletterResult"></p>
        </div>
      </div>
    </div>
  </div>
  <i class="fa fa-chevron-up scrollToTopIcon" aria-hidden="true"></i></body></code>```

Hope this helps!

Title: Bootstrap container gets margin-top 0

Body:
Why does my .container main_container div hang on the header? (Its not because the 2 php error message, i tried)

If i give the div about 100px margin-top, it will be okay, but that isn't a good method.

After the header, I added a clearfix div, but it did nothing.

Fiddle

      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        Toggle navigation

      </button>
      <a class="navbar-brand" href="<?php echo $host; ?>"><?php echo $siteName; ?>

        <?php
        $top_menuDown = mysqli_query($kapcs, "SELECT * FROM top_menu WHERE top_menu_id IN (1,3,4,5,6,7) ORDER BY top_menu_sorrend ASC");
        if(mysqli_num_rows($top_menuDown) > 0 )
        {
            while($top_nav = mysqli_fetch_assoc($top_menuDown))
            {
                echo '
'.$top_nav['top_menu_nev'].'
';
            }
        }
        ?>

Body:
You have to use padding-top/margin-top to the body element. The reason is explained by @makshh. So just try to customize it based on screen size using Javascript.

Updated Fiddle

Here is an example--

$(window).resize(function() {
  if ($(".navbar.navbar-default.navbar-fixed-top.mainHeader").height() > 100) {
    $("html, body").css("padding-top", "150px");
  }
});

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<title>Főoldal</title>

<body style="padding-top:100px;">
  <nav class="navbar navbar-default navbar-fixed-top mainHeader">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
        <a class="navbar-brand" href="https://kemenyem.hu">Nemzeti Reptéri Parkoló</a>
      </div>
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li><a class="top_menu_to_link" href="https://kemenyem.hu/" title="Kezdőlap">Kezdőlap</a></li>
          <li><a class="top_menu_to_link" href="https://kemenyem.hu/informaciok" title="Információk">Információk</a></li>
          <li><a class="top_menu_to_link" href="https://kemenyem.hu/erdekessegek" title="Hírek, érdekességek">Hírek, érdekességek</a></li>
          <li><a class="top_menu_to_link" href="https://kemenyem.hu/kapcsolat" title="Kapcsolat">Kapcsolat</a></li>
          <li><a class="top_menu_to_link" href="https://kemenyem.hu/arlista" title="Árlista">Árlista</a></li>
          <li><a class="top_menu_to_link" href="https://kemenyem.hu/galeria" title="Galéria">Galéria</a></li>
        </ul>
      </div>
    </div>
  </nav>
  <div class="clearfix"></div>
  <div class="container main_container">
    <div class="homepage_slideshow hidden-xs">
      <div class="home-slider-wrapper hidden-xs">
        <ul class="bxslider">
          <li><img src="https://kemenyem.hu/images/homepage_slideshow/93-3.jpg" title="Teszt kép 1" alt="Teszt kép 1" /></li>
          <li><img src="https://kemenyem.hu/images/homepage_slideshow/393-1.jpg" title="Teszt kép 2" alt="Teszt kép 2" /></li>
        </ul>
      </div>
    </div>
    <!--Slider end-->
    <div class="col-md-9 left_side">
      <div class="left_title_div">
        <h3 class="left_title">Parkolóhely foglalás online</h3>
      </div>
      <div class="content">
        <h3><strong>A megrendel&eacute;s, &aacute;raj&aacute;nlatk&eacute;r&eacute;s&nbsp;menete</strong></h3>

        <p>Amennyiben &aacute;raj&aacute;nlatot szeretne k&eacute;rni, azt a term&eacute;kekn&eacute;l a &quot;M&eacute;g jobb &aacute;rat szeretn&eacute;k&quot; gombra, vagy a men&uuml;ben az &quot;Aj&aacute;nlatk&eacute;r&eacute;s&quot; men&uuml;pontra
          val&oacute; kattint&aacute;ssal&nbsp;teheti meg.</p>

        <p>A megjelenő aj&aacute;nlatk&eacute;rő ablakban / oldalon k&eacute;rj&uuml;k t&ouml;ltse ki az &ouml;sszes mezőt, &eacute;s k&uuml;ldje el r&eacute;sz&uuml;nkre.</p>

        <p>Munkat&aacute;rsaink 2 munkanapon bel&uuml;l felveszik &Ouml;nnel a kapcsolatot az &Ouml;n &aacute;ltal megadott el&eacute;rhetős&eacute;gek valamelyik&eacute;n.</p>

        <h3><strong>Fizet&eacute;s</strong></h3>

        <p>Megrendel&eacute;s&eacute;t előre utal&aacute;ssal, vagy szem&eacute;lyesen valamelyik telephely&uuml;nk&ouml;n k&eacute;szp&eacute;nzzel tudja fizetni. A budapesti telephely&uuml;nk&ouml;n lehetős&eacute;g van bankk&aacute;rty&aacute;s fizet&eacute;sre
          is.</p>

        <h3><strong>Sz&aacute;ll&iacute;t&aacute;s</strong></h3>

        <p>A r&eacute;szletes sz&aacute;ll&iacute;t&aacute;si inform&aacute;ci&oacute;kat megtekintheti a &quot;Sz&aacute;ll&iacute;t&aacute;s&quot; men&uuml;pontban.</p>

        <h3><strong>&Aacute;rak</strong></h3>

        <p>A weboldalon felt&uuml;ntetett &aacute;rak gy&aacute;ri &aacute;rak, tartalmazz&aacute;k a 27% &Aacute;F&Aacute;-t, de nem tartalmazz&aacute;k a raklapok d&iacute;j&aacute;t, a sz&aacute;ll&iacute;t&aacute;st, &eacute;s a lerak&aacute;st.</p>
      </div>

      <div class="left_title_div">
        <h3 class="left_title">Legfrissebb hírek</h3>
      </div>
      <div class="news_box news_list">
        <div class="row main_hir_box">
          <div class="col-md-3 main_hir_box_thumb_div">
            <a href="https://kemenyem.hu/hir/13/jobb-lett-az" title="Jobb lett az instant futtatás az új Android Studio 2.3-ban" class="main_hir_img_link"><img src="https://kemenyem.hu/images/news/th_remy-metailler-hafjell_147-82712.jpg" class="img-responsive main_hir_img imageHoverOpacity" alt="Jobb lett az instant futtatás az új Android Studio 2.3-ban"></a>
          </div>
          <div class="col-md-9 main_hir_box_data_div">
            <h2 class="main_hir_title_list"><a href="https://kemenyem.hu/hir/13/jobb-lett-az" title="Jobb lett az instant futtatás az új Android Studio 2.3-ban" class="main_hir_title_link_list">Jobb lett az instant futtatás az új Android Studio 2.3-ban</a></h2>
            <span class="main_hir_box_date">HÍREK | 2017-03-15 16:27</span>
            <p class="main_hir_box_desc">A Google a napokban új kiadást jelentett be integrált mobilos fejlesztőkörnyezetéből. Az új Android Studio 2.3 sok stabilitási fejlesztés mellett néhány érdekes funkcionális fejlesztést is hoz, amik az app-ok tervezését, tesztelését és a bennük
              történő hibakeresést egyaránt segítik majd.</p>
          </div>
        </div>
        <div class="row main_hir_box">
          <div class="col-md-3 main_hir_box_thumb_div">
            <a href="https://kemenyem.hu/hir/12/igy-fejleszthetsz-egy-php-sql-alkalmazast-git-tel-az-azure-ba" title="Így fejleszthetsz egy PHP-SQL alkalmazást Git-tel az Azure-ba 2" class="main_hir_img_link"><img src="https://kemenyem.hu/images/news/thumb_ne-style-001-2532861600.jpg" class="img-responsive main_hir_img imageHoverOpacity" alt="Így fejleszthetsz egy PHP-SQL alkalmazást Git-tel az Azure-ba 2"></a>
          </div>
          <div class="col-md-9 main_hir_box_data_div">
            <h2 class="main_hir_title_list"><a href="https://kemenyem.hu/hir/12/igy-fejleszthetsz-egy-php-sql-alkalmazast-git-tel-az-azure-ba" title="Így fejleszthetsz egy PHP-SQL alkalmazást Git-tel az Azure-ba 2" class="main_hir_title_link_list">Így fejleszthetsz egy PHP-SQL alkalmazást Git-tel az Azure-ba 2</a></h2>
            <span class="main_hir_box_date">HÍREK | 2017-03-15 16:27</span>
            <p class="main_hir_box_desc">A bemutató feltételezi, hogy a gépeden már fel van telepítve a PHP, az SQL Server Express kiadása, valamint a Microsoft SQL Server meghajtói a PHP-hez és a Git verziókezelő is. A cikk során a következőket fogjuk megtanulni:</p>
          </div>
        </div>
        <div class="row main_hir_box">
          <div class="col-md-3 main_hir_box_thumb_div">
            <a href="https://kemenyem.hu/hir/11/oriasposzteren-mutatja-be-a-visual-studio-2017-ujdonsagait-a-microsoft" title="Óriásposzteren mutatja be a Visual Studio 2017 újdonságait a Microsoft" class="main_hir_img_link"><img src="https://kemenyem.hu/images/news/th_s1600_0815_km_01-12894.jpg" class="img-responsive main_hir_img imageHoverOpacity" alt="Óriásposzteren mutatja be a Visual Studio 2017 újdonságait a Microsoft"></a>
          </div>
          <div class="col-md-9 main_hir_box_data_div">
            <h2 class="main_hir_title_list"><a href="https://kemenyem.hu/hir/11/oriasposzteren-mutatja-be-a-visual-studio-2017-ujdonsagait-a-microsoft" title="Óriásposzteren mutatja be a Visual Studio 2017 újdonságait a Microsoft" class="main_hir_title_link_list">Óriásposzteren mutatja be a Visual Studio 2017 újdonságait a Microsoft</a></h2>
            <span class="main_hir_box_date">HÍREK | 2017-03-15 16:25</span>
            <p class="main_hir_box_desc">A Microsoft a hét elején Visual Studio blogjában egy olyan, általa poszternek hívott dokumentumot tett közzé, amelyben múlt héten bemutatott új integrált fejlesztői környezete legfontosabb újdonságait mutatja be. A máshol csak infografikának
              hívott összeállításban az általános, produktivitást javító fejlesztések mellett unit-tesztelést segítő újdonságok, sőt, a C++, a C# és az ASP.NET újdonságai is említésre kerülnek.</p>
          </div>
        </div>
        <div class="row main_hir_box">
          <div class="col-md-3 main_hir_box_thumb_div">
            <a href="https://kemenyem.hu/hir/10/uj-korszakot-nyit-a-most-elkeszult-llvm-es-a-clang-4-0" title="Új korszakot nyit a most elkészült LLVM és a Clang 4.0" class="main_hir_img_link"><img src="https://kemenyem.hu/images/news/th_p-dsc04186-81966.jpg" class="img-responsive main_hir_img imageHoverOpacity" alt="Új korszakot nyit a most elkészült LLVM és a Clang 4.0"></a>
          </div>
          <div class="col-md-9 main_hir_box_data_div">
            <h2 class="main_hir_title_list"><a href="https://kemenyem.hu/hir/10/uj-korszakot-nyit-a-most-elkeszult-llvm-es-a-clang-4-0" title="Új korszakot nyit a most elkészült LLVM és a Clang 4.0" class="main_hir_title_link_list">Új korszakot nyit a most elkészült LLVM és a Clang 4.0</a></h2>
            <span class="main_hir_box_date">HÍREK | 2017-03-15 16:24</span>
            <p class="main_hir_box_desc">Az LLVM fejlesztői a napokban &quot;final&quot; jelöléssel látták el az LLVM és a Clang következő, 4-es verzióját. Bár a hivatalos bejelentés és a csomagok közzétételére vélhetően csak ezen a héten kerül majd sor, a fordító-infrastruktúra
              és a hozzá kapcsolódó C/C++ fordító legújabb kiadása ezzel elkészültnek tekinthető.</p>
          </div>
        </div>
      </div>
    </div>
    <div class="col-md-3 right_side">
      <div class="left_title_div">
        <h3 class="left_title">Hírlevél</h3>
      </div>
      <div class="sidebar_data_div">
        <div class="sidebar_data">
          <p class="sidebar_text">Iratkozzon fel hírlevelünkre, hogy mindíg értesüljön az újdonsgokról, friss hírekről.</p>
          <form action="files/newsletter.php" method="post" id="SidebarNewsletterForm">
            <input type="text" id="newsletterName" name="NewsletterName" placeholder="Az Ön neve" class="form-control sidebar_input">
            <input type="text" id="NewsletterEmail" name="NewsletterEmail" placeholder="E-mail címe" class="form-control sidebar_input">
            <button type="button" id="NewsletterButton" name="NewsletterButton" class="sidebar_button"><i class="fa fa-envelope-o" aria-hidden="true"></i> Feliratkozás</button>
          </form>
        </div>
      </div>
    </div>
  </div>
  <footer class="footer-basic-centered">
    <p class="footer-links">
      <a class="footer_menu_to_link" href="https://kemenyem.hu/" title="Kezdőlap">Kezdőlap</a><a class="footer_menu_to_link" href="https://kemenyem.hu/informaciok" title="Információk">Információk</a><a class="footer_menu_to_link" href="https://kemenyem.hu/erdekessegek"
        title="Hírek, érdekességek">Hírek, érdekességek</a><a class="footer_menu_to_link" href="https://kemenyem.hu/kapcsolat" title="Kapcsolat">Kapcsolat</a><a class="footer_menu_to_link" href="https://kemenyem.hu/arlista" title="Árlista">Árlista</a>
      <a
        class="footer_menu_to_link" href="https://kemenyem.hu/galeria" title="Galéria">Galéria</a>
    </p>
    <p class="footer-company-name">2017 <br />
      <b>Notice</b>: Undefined index: k_nev in <b>/home/grashu/public_html/kemenyem.hu/files/footer.php</b> on line <b>15</b><br /> &copy; - Minden jog fentartva!</p>
  </footer>
  <div class="modal fade" id="newsletterModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header"><button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Bezárás</span></button>
          <h4 class="modal-title" id="myModalLabel">Értesítés</h4>
        </div>
        <div class="modal-body">
          <p id="newsletterResult"></p>
        </div>
      </div>
    </div>
  </div>
  <a href="#" class="scrollToTop" title="Oldal tetejére"><i class="fa fa-chevron-up scrollToTopIcon" aria-hidden="true"></i></a></body>

Hope this helps!


问:
Why does Trace.WriteLine("Test") not appear when targeting .net 4.0 but does when 3.5
I have just noticed that when i call the following code from a console app

```<code>for (int i = 0; i < 10; i++)
{
  Trace.WriteLine("Logging");
  Debug.WriteLine("Logging Debug");
}
</code>```

if I am targeting .net 4.0 no messages appear in the debugview app although I am capturing all outputs.

If I change to target 3.5 it appears fine.

What's changed and how can I fix it?

答:
This is actually by design.
From Microsoft Connect :

The CLR has a new debugging
  architecture where the CLR is native
  debugging the application even when
  managed only attached, and therefore
  MS-SysInternals DebugView will not
  work.

ContentLicense: CC BY-SA 2.5

Body:
I have just noticed that when i call the following code from a console app

for (int i = 0; i < 10; i++)
{
  Trace.WriteLine("Logging");
  Debug.WriteLine("Logging Debug");
}

if I am targeting .net 4.0 no messages appear in the debugview app although I am capturing all outputs.

If I change to target 3.5 it appears fine.

What's changed and how can I fix it?


问:
Parsing image of a point cloud with opencv
I have a point cloud
and would like to extract the coordinates of the points from it.

The following python opencv (3.2.0-dev) script is used for the extraction.

```<code>image = cv2.imread(PIC_FILE)
image_gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
_,image_thres = cv2.threshold(image_gray, 230, 255, cv2.THRESH_BINARY)
image_thres = 255 - image_thres
pixelpoints = np.transpose(np.nonzero(image_thres))
</code>```

But the problem is that for a point, which are containing multiple pixels in the picture, I get multiple point coordinates.

Currently the value len(pixelpoints) is about 9000, which seems to be much more than we can see in the picture.

How can I collapse these multiple pixels into one single coordinate, which - for example - is the center of a point?

答:
I am pretty sure you will not be able to achieve the wished for results with the image you provided. At least, not with high precision. Given the first pixel points result in something like:

[ 13 118][ 13 125][ 13 126][ 13 127][ 13 131][ 13 132][ 13 133][ 14 117][ 14 118][ 14 119][ 14 123][ 14 124][ 14 125][ 14 126][ 14 127][ 14 131][ 14 132][ 14 133]

You could of course group these according to one of their axes. You could also set a maximum number of pixelpoints to be related to a single dot. However, your image also includes multiple areas in which the dots are placed all together, overlapping, so you could never know for sure how many dots there are in these areas. Furthermore, the dots are not similar in shape, some are 3 pixels wide, others just 2, etc. And they keep rotating.

Overall.. you might be able to finetune your guess, but you won't get a perfect match with the current image.

PS: I am not as familiar with bumpy though.. maybe it has some functions to create a better estimation, but still these algorithms are likely to achieve an educated guess at best with the provided image.

Body:
I have a point cloud
and would like to extract the coordinates of the points from it.

The following python opencv (3.2.0-dev) script is used for the extraction.

image = cv2.imread(PIC_FILE)
image_gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
_,image_thres = cv2.threshold(image_gray, 230, 255, cv2.THRESH_BINARY)
image_thres = 255 - image_thres
pixelpoints = np.transpose(np.nonzero(image_thres))

But the problem is that for a point, which are containing multiple pixels in the picture, I get multiple point coordinates.

Currently the value len(pixelpoints) is about 9000, which seems to be much more than we can see in the picture.

How can I collapse these multiple pixels into one single coordinate, which - for example - is the center of a point?


问:
What does underscore stand for in this code
How does following code work? This code is from Racket documentation https://docs.racket-lang.org/plot/renderer2d.html?q=2d%20renderers#%28part.2.D.Line_.Renderers%29 (see function points on this page). This is not usual function definition statement. What does the underscore stand for here?

```<code>(define xs (build-list 5 (λ _ (random))))
</code>```

The xs gets following value:

```<code>> xs
'(0.9520057193043618 0.1339193598495859 0.0019128879992944899 0.7511052254656998 0.4442323053722083)
</code>```

答:
A lambda can either have a list of identifiers as parameter names (such as (lambda (a b c) the-body )) or a single identifier (such as (lambda args the-body), which will then hold the list of all arguments.

The function given to build-list takes one parameter (the current index). It is customary to name parameters _ when you don't intend to use their value.

So since we don't care about the current index when creating a random list, the parameter is named _. This could also be written as (lambda (_), but since we don't care about any of the (one) parameters, we can just write (lambda _ as well.

Body:
How does following code work? This code is from Racket documentation https://docs.racket-lang.org/plot/renderer2d.html?q=2d%20renderers#%28part.2.D.Line_.Renderers%29 (see function points on this page). This is not usual function definition statement. What does the underscore stand for here?

(define xs (build-list 5 (λ _ (random))))

The xs gets following value:

> xs
'(0.9520057193043618 0.1339193598495859 0.0019128879992944899 0.7511052254656998 0.4442323053722083)


问:
Generating PDF's from form responses with a template.
I'm currently using Form Publisher add in to make PDF's from the form responses with my required template but it is allowing me to generate only 100 files in a month. I have requirement with minimum of 500 files in month and I cannot afford premium license purchase for Form Publisher. Please help me with the basic script to generate PDF's based on form response data with my desired template.

I will share the template and sample sheet if it can be done.

Regards
Gopikrishna

答:
This snippet creates a PDF file using a Google Doc template and the values in a Google Spreadsheet. Just past it into the script editor of the GSheet you are using.</p>

```<code>// Replace this with ID of your template document.
var TEMPLATE_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'

// var TEMPLATE_ID = '1wtGEp27HNEVwImeh2as7bRNw-tO4HkwPGcAsTrSNTPc' // Demo template

// You can specify a name for the new PDF file here, or leave empty to use the
// name of the template.
var PDF_FILE_NAME = ''

/**
 * Eventhandler for spreadsheet opening - add a menu.
 */

function onOpen() {

  SpreadsheetApp
    .getUi()
    .createMenu('Create PDF')
    .addItem('Create PDF', 'createPdf')
    .addToUi()

} // onOpen()

/**
 * Take the fields from the active row in the active sheet
 * and, using a Google Doc template, create a PDF doc with these
 * fields replacing the keys in the template. The keys are identified
 * by having a % either side, e.g. %Name%.
 *
 * @return {Object} the completed PDF file
 */

function createPdf() {

  if (TEMPLATE_ID === '') {

    SpreadsheetApp.getUi().alert('TEMPLATE_ID needs to be defined in code.gs')
    return
  }

  // Set up the docs and the spreadsheet access

  var copyFile = DriveApp.getFileById(TEMPLATE_ID).makeCopy(),
      copyId = copyFile.getId(),
      copyDoc = DocumentApp.openById(copyId),
      copyBody = copyDoc.getActiveSection(),
      activeSheet = SpreadsheetApp.getActiveSheet(),
      numberOfColumns = activeSheet.getLastColumn(),
      activeRowIndex = activeSheet.getActiveRange().getRowIndex(),
      activeRow = activeSheet.getRange(activeRowIndex, 1, 1, numberOfColumns).getValues(),
      headerRow = activeSheet.getRange(1, 1, 1, numberOfColumns).getValues(),
      columnIndex = 0

  // Replace the keys with the spreadsheet values

  for (;columnIndex < headerRow[0].length; columnIndex++) {

    copyBody.replaceText('%' + headerRow[0][columnIndex] + '%',
                         activeRow[0][columnIndex])
  }

  // Create the PDF file, rename it if required and delete the doc copy

  copyDoc.saveAndClose()

  var newFile = DriveApp.createFile(copyFile.getAs('application/pdf'))

  if (PDF_FILE_NAME !== '') {

    newFile.setName(PDF_FILE_NAME)
  }

  copyFile.setTrashed(true)

  SpreadsheetApp.getUi().alert('New PDF file created in the root of your Google Drive')

} // createPdf()
</code>```

Body:
This snippet creates a PDF file using a Google Doc template and the values in a Google Spreadsheet. Just past it into the script editor of the GSheet you are using.

// Replace this with ID of your template document.
var TEMPLATE_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'

// var TEMPLATE_ID = '1wtGEp27HNEVwImeh2as7bRNw-tO4HkwPGcAsTrSNTPc' // Demo template

// You can specify a name for the new PDF file here, or leave empty to use the
// name of the template.
var PDF_FILE_NAME = ''

/**
 * Eventhandler for spreadsheet opening - add a menu.
 */

function onOpen() {

  SpreadsheetApp
    .getUi()
    .createMenu('Create PDF')
    .addItem('Create PDF', 'createPdf')
    .addToUi()

} // onOpen()

/**
 * Take the fields from the active row in the active sheet
 * and, using a Google Doc template, create a PDF doc with these
 * fields replacing the keys in the template. The keys are identified
 * by having a % either side, e.g. %Name%.
 *
 * @return {Object} the completed PDF file
 */

function createPdf() {

  if (TEMPLATE_ID === '') {

    SpreadsheetApp.getUi().alert('TEMPLATE_ID needs to be defined in code.gs')
    return
  }

  // Set up the docs and the spreadsheet access

  var copyFile = DriveApp.getFileById(TEMPLATE_ID).makeCopy(),
      copyId = copyFile.getId(),
      copyDoc = DocumentApp.openById(copyId),
      copyBody = copyDoc.getActiveSection(),
      activeSheet = SpreadsheetApp.getActiveSheet(),
      numberOfColumns = activeSheet.getLastColumn(),
      activeRowIndex = activeSheet.getActiveRange().getRowIndex(),
      activeRow = activeSheet.getRange(activeRowIndex, 1, 1, numberOfColumns).getValues(),
      headerRow = activeSheet.getRange(1, 1, 1, numberOfColumns).getValues(),
      columnIndex = 0

  // Replace the keys with the spreadsheet values

  for (;columnIndex < headerRow[0].length; columnIndex++) {

    copyBody.replaceText('%' + headerRow[0][columnIndex] + '%',
                         activeRow[0][columnIndex])
  }

  // Create the PDF file, rename it if required and delete the doc copy

  copyDoc.saveAndClose()

  var newFile = DriveApp.createFile(copyFile.getAs('application/pdf'))

  if (PDF_FILE_NAME !== '') {

    newFile.setName(PDF_FILE_NAME)
  }

  copyFile.setTrashed(true)

  SpreadsheetApp.getUi().alert('New PDF file created in the root of your Google Drive')

} // createPdf()


问:
How to dynamically filled cardviews according to device width
I am making an app where I want to maintain cards of fixed width. So How to dynamically filled cardviews according to device width.

For Ex. for a normal size phone there should be two column of cards and for big size screen there are three column of cards when app in portait mode in both phones.

Like this :
3 column cards example
2 column cards example

答:
Got the solution,

need to use the GridView:

```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="app.appmax.fest1.Dialogs.CustomGridView.MenuHome">

     <GridView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:columnWidth="100dp"
         android:layout_marginLeft="8dp"
         android:layout_marginTop="8dp"
         android:stretchMode="columnWidth"
         android:id="@+id/gridview1"
         android:numColumns="auto_fit"
         >

     </GridView>

</RelativeLayout>
</code>```

Body:
Got the solution,

need to use the GridView:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="app.appmax.fest1.Dialogs.CustomGridView.MenuHome">

     <GridView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:columnWidth="100dp"
         android:layout_marginLeft="8dp"
         android:layout_marginTop="8dp"
         android:stretchMode="columnWidth"
         android:id="@+id/gridview1"
         android:numColumns="auto_fit"
         >

     </GridView>

</RelativeLayout>


问:
User asks twice and the second time the user gets different answer?
Well, my code is a little bit long so I just put the first part when you see x ==1 part actually it has seven parts like this. My aim is like you chose 1A and it gives you the table (that part I did it.) What I want is if the user writes 1A again the system must say sorry. How can I do this without using any packages?</p>

```<code>import java.util.Scanner;
class deneme{
    public  void printTable(String [ ][ ] seat){
        for(int r=0; r<seat.length; r++){
            for(int c = 0; c< seat[0].length; c++){
                System.out.print(seat[r][c]);
            }
            System.out.println();
        }
    }

   public static void main(String[] args) {
    deneme k = new deneme();
       String [][] seat = {{"1","A","B","C","D"},{"2","A","B","C","D"},{"3","A","B","C","D"},{"4","A","B","C","D"},{"5","A","B","C","D"},{"6","A","B","C","D"},{"7","A","B","C","D"}};
     Scanner read = new Scanner(System.in);
     int x = 6;
     String s;
     String d;

        while(x <= 7){
            System.out.println("Please choose your seat number (1 to 7).But if you want to terminate the program please write 0");
            s = read.nextLine();
            x = Integer.parseInt(s);
            System.out.println("Please choose your seat row (A to D)");
            d = read.nextLine();

        if(x == 1){
            if((d.equals("A")|| d.equals("a"))){
                seat[0][1] = "X";
                k.printTable(seat);

            }

            else if((d.equals("B")|| d.equals("b")) ){
                seat[0][2] = "X";
                System.out.println("Your seat is chosen ");
                k.printTable(seat);

            }

            else if((d.equals("C")|| d.equals("c")) ){
                seat[0][3] = "X";
                System.out.println(" Your seat is chosen ");
                k.printTable(seat);

            }

            else if((d.equals("D")|| d.equals("d")) ){
                seat[0][4] = "X";
                System.out.println(" Your seat is chosen " );
                k.printTable(seat);

            }

        }
</code>```

答:
Lots of stuff you can do to clean up your code, but... specifically to your question, you're never checking to see if seat[x][y] already has an "X" in it before writing an "X" to it.

If you perform a simple if-check on the value of the array, and it already equals "X", you can then print your message instead of writing to the array (and possibly overwriting a previously-chosen seat selection).

Body:
Well, my code is a little bit long so I just put the first part when you see x ==1 part actually it has seven parts like this. My aim is like you chose 1A and it gives you the table (that part I did it.) What I want is if the user writes 1A again the system must say sorry. How can I do this without using any packages?

import java.util.Scanner;
class deneme{
    public  void printTable(String [ ][ ] seat){
        for(int r=0; r<seat.length; r++){
            for(int c = 0; c< seat[0].length; c++){
                System.out.print(seat[r][c]);
            }
            System.out.println();
        }
    }

   public static void main(String[] args) {
    deneme k = new deneme();
       String [][] seat = {{"1","A","B","C","D"},{"2","A","B","C","D"},{"3","A","B","C","D"},{"4","A","B","C","D"},{"5","A","B","C","D"},{"6","A","B","C","D"},{"7","A","B","C","D"}};
     Scanner read = new Scanner(System.in);
     int x = 6;
     String s;
     String d;

        while(x <= 7){
            System.out.println("Please choose your seat number (1 to 7).But if you want to terminate the program please write 0");
            s = read.nextLine();
            x = Integer.parseInt(s);
            System.out.println("Please choose your seat row (A to D)");
            d = read.nextLine();

        if(x == 1){
            if((d.equals("A")|| d.equals("a"))){
                seat[0][1] = "X";
                k.printTable(seat);

            }

            else if((d.equals("B")|| d.equals("b")) ){
                seat[0][2] = "X";
                System.out.println("Your seat is chosen ");
                k.printTable(seat);

            }

            else if((d.equals("C")|| d.equals("c")) ){
                seat[0][3] = "X";
                System.out.println(" Your seat is chosen ");
                k.printTable(seat);

            }

            else if((d.equals("D")|| d.equals("d")) ){
                seat[0][4] = "X";
                System.out.println(" Your seat is chosen " );
                k.printTable(seat);

            }

        }


问:
AngularJS material push element to the right of the page
I'm trying to push / float a drop-down to the right with no success, tried also to apply float: right; on md-input-container:

```<code><div layout="row" layout-align="right">
    <div class="md-select-sort">
        <md-input-container>
            <label>Sort By</label>
            <md-select ng-model="sort">
                <md-optgroup label="Sort By">
                    <md-option value="DateLastModified">Date Last Modified (Asc)</md-option>
                    <md-option value="-DateLastModified">Date Last Modified (Desc)</md-option>
                    <md-option value="DateCreated">Date Created (Asc)</md-option>
                    <md-option value="-DateCreated">Date Created (Desc)</md-option>
                </md-optgroup>
            </md-select>
        </md-input-container>
    </div>
</div>
</code>```

There is a specifiec way to accomplish that? Why just float: right don't work?

答:
Just use layout-align="end center" and you will be fine like in this demo plnkr.

```<code><div layout="row" layout-align="end center">
    <div class="md-select-sort">
        <md-input-container>
            <label>Sort By</label>
            <md-select ng-model="sort">
                <md-optgroup label="Sort By">
                    <md-option value="DateLastModified">Date Last Modified (Asc)</md-option>
                    <md-option value="-DateLastModified">Date Last Modified (Desc)</md-option>
                    <md-option value="DateCreated">Date Created (Asc)</md-option>
                    <md-option value="-DateCreated">Date Created (Desc)</md-option>
                </md-optgroup>
            </md-select>
        </md-input-container>
    </div>
</div>
</code>```

Body:
I'm trying to push / float a drop-down to the right with no success, tried also to apply float: right; on md-input-container:

        <md-input-container>
            Sort By
            <md-select ng-model="sort">
                <md-optgroup label="Sort By">
                    <md-option value="DateLastModified">Date Last Modified (Asc)</md-option>
                    <md-option value="-DateLastModified">Date Last Modified (Desc)</md-option>
                    <md-option value="DateCreated">Date Created (Asc)</md-option>
                    <md-option value="-DateCreated">Date Created (Desc)</md-option>
                </md-optgroup>
            </md-select>
        </md-input-container>

There is a specifiec way to accomplish that? Why just float: right don't work?

Body:
Just use layout-align="end center" and you will be fine like in this demo plnkr.

<div layout="row" layout-align="end center">
    <div class="md-select-sort">
        <md-input-container>
            <label>Sort By</label>
            <md-select ng-model="sort">
                <md-optgroup label="Sort By">
                    <md-option value="DateLastModified">Date Last Modified (Asc)</md-option>
                    <md-option value="-DateLastModified">Date Last Modified (Desc)</md-option>
                    <md-option value="DateCreated">Date Created (Asc)</md-option>
                    <md-option value="-DateCreated">Date Created (Desc)</md-option>
                </md-optgroup>
            </md-select>
        </md-input-container>
    </div>
</div>


问:
Vagrant stuck connection timeout retrying
My vagrant was working perfectly fine last night. I've just turned the PC on, hit vagrant up, and this is what I get:

```<code>==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
</code>```

Has anyone had this before? vagrant isn't widely covered on the web yet and I can't find a reason why this is occurring.

答:
Here is how it worked for me:

After "vagrant up" started the virtual machine, turned off the machine and go to the new virtual machine settings in virtualbox. Then go to "Network" -> "Advanced"

Adapter Type: I changed from "Intel PRO XXXXX" to "PCNet-Fast" (or any other adpter other than Intel PRO did work)

Body:
My vagrant was working perfectly fine last night. I've just turned the PC on, hit vagrant up, and this is what I get:

==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...

Has anyone had this before? vagrant isn't widely covered on the web yet and I can't find a reason why this is occurring.


问:
Windows EventLog: How fast are operations with it?
I have a service application that is processing client requests over TCP and writing any events into Windows EventLog. Since this application is expected to service many clients and lots of requests from each client in a short amount of time (let's say between 1 and 50 requests per second), I'm curious to know how intensive (CPU wise and time wise) and how fast can writing into Windows EventLog be?

More specifically, how intensive are the operations of connecting to, reading from and writing to EventLog?

答: Maybe Microsoft Message Queuing (MSMQ) is an alternative to the Windows EventLog. It is available in all current versions of Windows, and offers high speed, loosely coupled messaging.</p>


问:
Ionic2 Xcode Build Failure Cocoapods?
Hi I am building an app using ionic2 and recently installed the push plugin (I'm normally a windows user) I wanted to install this on iOS so on my Mac mini I installed push plugin then was required to install cocoa pods which I did.

Now when I try to install my app in Xcode on an actual iPhone device I get the error in Xcode:

ld: library not found for -lPods-MyApp
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Showing Recent Errors Only
ld: library not found for -lPods-MyApp

clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have no idea how to debug this and am at a complete loss. I have tried ionic platform rm iOS then add iOS but I still get the same error.

Anyone else had this issue or can point in the right direction? A day spent on this so far and still banging my head against the wall!

Thanks

答: Makesure you are opening the .xcworkspace file not the .xcproject after the PODS installation is completed. You may also refer to this answer: Error "library not found for"</p>

Title: Ionic2 Xcode Build Failure Cocoapods?


问:
Json from a get API Call C#
I have a GET API Call as below:

```<code>static void Main()
{
    RunAsync().Wait();
}

static async Task RunAsync()
{
    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri("myurl");
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("usr", "pwd");
        HttpResponseMessage response = await client.GetAsync("");
        if (response.IsSuccessStatusCode)
        {
            Console.WriteLine(response.Content);
        }
    }
}
</code>```

How do I read the JSON response from the API ?

I was trying to do this:

```<code> response.Content = new ObjectContent<Response>(new Response()
                    {
                        responseCode = Response.ResponseCodes.ItemNotFound
                    }, new JsonMediaTypeFormatter(), "application/json");
</code>```

but I have not been successful yet. Could someone help please?

UPDATE:

My updated code looks like this now:

```<code>static async Task RunAsync()
{
    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri("myurl");
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("BT", "pwd");
        HttpResponseMessage response = await client.GetAsync("");
        if (response.IsSuccessStatusCode)
        {
            Console.WriteLine(response.Content);
            var json = await response.Content.ReadAsStringAsync();
            Product myprod = JsonConvert.DeserializeObject<Product>(json);

            var results = myprod.result;

            for(int i=1;i<=results.Count;i++)
            {
                var value1 = results[0][0];
                var value2 = results[0][1];
                var value3 = "Nilisha";
                using (SqlConnection conn = new SqlConnection())
                {
                    conn.ConnectionString = "Server=[xx.xx.xx.xx];Database=[Mydb];User ID=sa;Password=abc@321;Trusted_Connection=true";
                    conn.Open();
                    SqlCommand insertCommand = new SqlCommand("INSERT INTO PortalData (LCID, TimeStamp, Name) VALUES ( @1, @2, @3)", conn);
                    insertCommand.Parameters.Add(new SqlParameter("1", value1));
                    insertCommand.Parameters.Add(new SqlParameter("2", value2));
                    insertCommand.Parameters.Add(new SqlParameter("3", value3));

                    Console.WriteLine("Commands executed! Total rows affected are " + insertCommand.ExecuteNonQuery());
                    conn.Close();
                }
            }
            Console.ReadLine();
        }
    }
}
</code>```

Are we allowed to use insert db calls inside the static async Task RunAsync() function ?

答:
The simplest approach with the current example is

```<code>var json = await response.Content.ReadAsStringAsync();
</code>```

If trying to convert it to a strongly typed class then use

```<code>var model = await response.Content.ReadAsAsync<Product>();
</code>```

UPDATE:

Based on sample data provided in comments the following was derived.

```<code>[TestClass]
public class JsonNetDateSerializationTests {
    [TestMethod]
    public void GetResults() {
        //Arrange
        var json = "{\"result\": [[\"2016-10-31 01:29:42 495000\", 1033], [\"2016-11-01 22:29:07 169000\", 1033], [\"2016-10-31 01:31:51 550000\", 1033], [\"2016-11-01 22:41:11 357000\", 1033], [\"2016-11-01 22:41:11 357000\", 1033], [\"2016-11-01 22:52:09 848000\", 1033], [\"2016-11-03 01:48:13 038000\", 1033], [\"2016-11-03 01:48:13 038000\", 1033]], \"columns\": [\"ctime\", \"records\"], \"elapsed\": 0.000726}";

        //Act
        var actual = JsonConvert.DeserializeObject<Data>(json);

        //Assert
        Assert.IsNotNull(actual);

        var results = actual.result;

        var value1a = results[0][0];
        var value1b = results[0][1];

    }

    public class Data {
        public IList<IList<object>> result { get; set; }
        public IList<string> columns { get; set; }
        public double elapsed { get; set; }
    }
}
</code>```

Where the resulting values were

```<code>value1a => "2016-10-31 01:29:42 495000"
value1b => 1033
</code>```

Title: Json from a get API Call C#

Body:
I have a GET API Call as below:

static void Main()
{
    RunAsync().Wait();
}

static async Task RunAsync()
{
    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri("myurl");
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("usr", "pwd");
        HttpResponseMessage response = await client.GetAsync("");
        if (response.IsSuccessStatusCode)
        {
            Console.WriteLine(response.Content);
        }
    }
}

How do I read the JSON response from the API ?

I was trying to do this:

 response.Content = new ObjectContent<Response>(new Response()
                    {
                        responseCode = Response.ResponseCodes.ItemNotFound
                    }, new JsonMediaTypeFormatter(), "application/json");

but I have not been successful yet. Could someone help please?

UPDATE:

My updated code looks like this now:

static async Task RunAsync()
{
    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri("myurl");
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("BT", "pwd");
        HttpResponseMessage response = await client.GetAsync("");
        if (response.IsSuccessStatusCode)
        {
            Console.WriteLine(response.Content);
            var json = await response.Content.ReadAsStringAsync();
            Product myprod = JsonConvert.DeserializeObject<Product>(json);

            var results = myprod.result;

            for(int i=1;i<=results.Count;i++)
            {
                var value1 = results[0][0];
                var value2 = results[0][1];
                var value3 = "Nilisha";
                using (SqlConnection conn = new SqlConnection())
                {
                    conn.ConnectionString = "Server=[xx.xx.xx.xx];Database=[Mydb];User ID=sa;Password=abc@321;Trusted_Connection=true";
                    conn.Open();
                    SqlCommand insertCommand = new SqlCommand("INSERT INTO PortalData (LCID, TimeStamp, Name) VALUES ( @1, @2, @3)", conn);
                    insertCommand.Parameters.Add(new SqlParameter("1", value1));
                    insertCommand.Parameters.Add(new SqlParameter("2", value2));
                    insertCommand.Parameters.Add(new SqlParameter("3", value3));

                    Console.WriteLine("Commands executed! Total rows affected are " + insertCommand.ExecuteNonQuery());
                    conn.Close();
                }
            }
            Console.ReadLine();
        }
    }
}

Are we allowed to use insert db calls inside the static async Task RunAsync() function ?

Body:
The simplest approach with the current example is

var json = await response.Content.ReadAsStringAsync();

If trying to convert it to a strongly typed class then use

var model = await response.Content.ReadAsAsync<Product>();

UPDATE:

Based on sample data provided in comments the following was derived.

[TestClass]
public class JsonNetDateSerializationTests {
    [TestMethod]
    public void GetResults() {
        //Arrange
        var json = "{\"result\": [[\"2016-10-31 01:29:42 495000\", 1033], [\"2016-11-01 22:29:07 169000\", 1033], [\"2016-10-31 01:31:51 550000\", 1033], [\"2016-11-01 22:41:11 357000\", 1033], [\"2016-11-01 22:41:11 357000\", 1033], [\"2016-11-01 22:52:09 848000\", 1033], [\"2016-11-03 01:48:13 038000\", 1033], [\"2016-11-03 01:48:13 038000\", 1033]], \"columns\": [\"ctime\", \"records\"], \"elapsed\": 0.000726}";

        //Act
        var actual = JsonConvert.DeserializeObject<Data>(json);

        //Assert
        Assert.IsNotNull(actual);

        var results = actual.result;

        var value1a = results[0][0];
        var value1b = results[0][1];

    }

    public class Data {
        public IList<IList<object>> result { get; set; }
        public IList<string> columns { get; set; }
        public double elapsed { get; set; }
    }
}

Where the resulting values were

value1a => "2016-10-31 01:29:42 495000"
value1b => 1033


问:
Constraint stops DELETE in my own procedure, yet same DELETE runs in SQLPlus
On running two DELETE statements inside my own Package.Procedure:

```<code>DELETE FROM ENT_PLANT_RELATIVE WHERE CHILD_ID = plant_id;
DELETE FROM ENT_PLANT_ITEM WHERE PLANT_ID = plant_id;
</code>```

... I receive an integrity constraint violation on the second DELETE (first works correctly):

```<code>SQL> call P.DeletePlantItem(112808,1,:err);
ORA-02292: integrity constraint
(XXXXX.EAITA_PLANT_ITEM_ID_FK) violated - child record found
</code>```

There are no child records containing the FK in the table containing the constraint of that name:

```<code>SQL> select count(plant_item_id) from ent_application_item_to_access
where plant_item_id = 112808;

COUNT(PLANT_ITEM_ID)
--------------------
                   0
</code>```

... and there is only one column in that table using PLANT_ITEM_ID.

On running the suspect DELETE statement directly (copied from the procedure) in SQL*Plus (from which I call the procedure), it works as expected.

I have:

disabled the first integrity constraint shown, only to have another similar constraint appear on another table, similarly not containing the FK

disabled the second similar integrity constraint shown...ditto

inserted a single record into the master table and the one child table I am trying to delete from, and tried again with identical results to previously existing records

manually inserted a single item into ENT_PLANT_ITEM, commented out the unnecessary DELETE in the procedure, and tried to call it: same results

tried a COMMIT immediately after the first (successful) deletion from the child table (ENT_PLANT_RELATIVE)

used put_line to obtain the SQLERRM contains shown above identifying the constraint

checked for the existence of triggers inserting records (unnecessarily, I feel, as no child data exists in the table showing the constraint issue)

used IF to logically break the procedure into two separate procedures handling the two DELETE statements separately: same results

checked privileges as much as I know how, although I assume that because I can DELETE from one context (SQLPlus), and create the Package and Procedure in the first place, I should be able to from the Procedure (call)

also assumed that SQLERRM would report a privilege error

read the on-line Oracle documentation on constraints

read as many Stack Overflow questions as I could find that refer to constraints and referential integrity

The package definition is:

```<code>CREATE OR REPLACE PACKAGE P AS
    PROCEDURE InsertPlantItem(plant_desc IN VARCHAR2, parent_desc IN VARCHAR2, test IN NUMBER, err OUT VARCHAR2);
    PROCEDURE DeletePlantItem(plant_id IN NUMBER, test IN NUMBER, err OUT VARCHAR2);
END P;
</code>```

In summary, why can I delete row x in table y from the SQL*Plus command line but not via a stored procedure I created because of a constraint in a table I don't have any keys in?

答:
The problem was indeed in the second DELETE statement:

```<code>DELETE FROM ENT_PLANT_ITEM WHERE PLANT_ID = plant_id;
</code>```

I had created an IN parameter called plant_id, passing in a 6-digit number not realising I was effectively asking the procedure to delete all items in the database where a constraint wasn't going to stop it. It's rather more obvious in all capitals:

```<code>DELETE FROM ENT_PLANT_ITEM WHERE PLANT_ID = PLANT_ID;
</code>```

A column name obviously has higher precedence than a parameter.

Body:
On running two DELETE statements inside my own Package.Procedure:

DELETE FROM ENT_PLANT_RELATIVE WHERE CHILD_ID = plant_id;
DELETE FROM ENT_PLANT_ITEM WHERE PLANT_ID = plant_id;

... I receive an integrity constraint violation on the second DELETE (first works correctly):

SQL> call P.DeletePlantItem(112808,1,:err);
ORA-02292: integrity constraint
(XXXXX.EAITA_PLANT_ITEM_ID_FK) violated - child record found

There are no child records containing the FK in the table containing the constraint of that name:

SQL> select count(plant_item_id) from ent_application_item_to_access
where plant_item_id = 112808;

COUNT(PLANT_ITEM_ID)
--------------------
                   0

... and there is only one column in that table using PLANT_ITEM_ID.

On running the suspect DELETE statement directly (copied from the procedure) in SQL*Plus (from which I call the procedure), it works as expected.

I have:

disabled the first integrity constraint shown, only to have another similar constraint appear on another table, similarly not containing the FK

disabled the second similar integrity constraint shown...ditto

inserted a single record into the master table and the one child table I am trying to delete from, and tried again with identical results to previously existing records

manually inserted a single item into ENT_PLANT_ITEM, commented out the unnecessary DELETE in the procedure, and tried to call it: same results

tried a COMMIT immediately after the first (successful) deletion from the child table (ENT_PLANT_RELATIVE)

used put_line to obtain the SQLERRM contains shown above identifying the constraint

checked for the existence of triggers inserting records (unnecessarily, I feel, as no child data exists in the table showing the constraint issue)

used IF to logically break the procedure into two separate procedures handling the two DELETE statements separately: same results

checked privileges as much as I know how, although I assume that because I can DELETE from one context (SQLPlus), and create the Package and Procedure in the first place, I should be able to from the Procedure (call)

also assumed that SQLERRM would report a privilege error

read the on-line Oracle documentation on constraints

read as many Stack Overflow questions as I could find that refer to constraints and referential integrity

The package definition is:

CREATE OR REPLACE PACKAGE P AS
    PROCEDURE InsertPlantItem(plant_desc IN VARCHAR2, parent_desc IN VARCHAR2, test IN NUMBER, err OUT VARCHAR2);
    PROCEDURE DeletePlantItem(plant_id IN NUMBER, test IN NUMBER, err OUT VARCHAR2);
END P;

In summary, why can I delete row x in table y from the SQL*Plus command line but not via a stored procedure I created because of a constraint in a table I don't have any keys in?

Body:
The problem was indeed in the second DELETE statement:

DELETE FROM ENT_PLANT_ITEM WHERE PLANT_ID = plant_id;

I had created an IN parameter called plant_id, passing in a 6-digit number not realising I was effectively asking the procedure to delete all items in the database where a constraint wasn't going to stop it. It's rather more obvious in all capitals:

DELETE FROM ENT_PLANT_ITEM WHERE PLANT_ID = PLANT_ID;

A column name obviously has higher precedence than a parameter.


问:
C array of pointers to double
I'm getting a memory problem in c++ code, for sure I'm wrong but I don't get the problem. I've declare an array of three pointer to double and allocate memory.

```<code>double *myDoubles[3];

for(int i=0;i<3;i++) {
   myDoubles[i]= (double *) malloc(1000*sizeof(double));
}

myDoubles[2][999]=10.55;
</code>```

Whats wrong?

EDIT

As @EdHeal comments and also @PhilippKiener I should not be using malloc at all. But it's difficult to forget malloc before 25 years with it.
After all my problem was another bug in another place and actually I was writing out of limits :). My fault!

答:
First things first: don't cast the pointer malloc returns. void* to (in your case) double* is implicit (and expected), casting it explicitly is generally considered bad practice.

Now on to your problem; malloc allocates the given number of bytes and returns a pointer to those bytes. You allocate 1000 bytes, but what you want is to allocate enough bytes for 1000 doubles. The reason for your error is that a double is larger than a single byte - it's 8 bytes. You can get the size of a type with sizeof(type); to allocate enough memory for your 1000 doubles, you'd therefore have to change the line inside the loop to:

```<code>myDoubles[i] = malloc(1000 * sizeof(double));
</code>```

To get to know the size of the type on your system, you can put

```<code>printf("Size of double: %d", sizeof(double));
</code>```

In your code.

Edit:

Now, since you're working with C++, you should not be using malloc at all. C++ makes life easier and gives you new!

The allocating line should be

```<code>myDoubles[i] = new double[1000];
</code>```

The nice thing abour new is that it does not need the size supplied... you give it a type and an amount; it computes the bytes needed for you. But beware, instead of free you should use

```<code>delete[] myDoubles[i];
</code>```

Title: C array of pointers to double

Body:
I'm getting a memory problem in c++ code, for sure I'm wrong but I don't get the problem. I've declare an array of three pointer to double and allocate memory.

double *myDoubles[3];

for(int i=0;i<3;i++) {
   myDoubles[i]= (double *) malloc(1000*sizeof(double));
}

myDoubles[2][999]=10.55;

Whats wrong?

EDIT

As @EdHeal comments and also @PhilippKiener I should not be using malloc at all. But it's difficult to forget malloc before 25 years with it.
After all my problem was another bug in another place and actually I was writing out of limits :). My fault!

Body:
First things first: don't cast the pointer malloc returns. void* to (in your case) double* is implicit (and expected), casting it explicitly is generally considered bad practice.

Now on to your problem; malloc allocates the given number of bytes and returns a pointer to those bytes. You allocate 1000 bytes, but what you want is to allocate enough bytes for 1000 doubles. The reason for your error is that a double is larger than a single byte - it's 8 bytes. You can get the size of a type with sizeof(type); to allocate enough memory for your 1000 doubles, you'd therefore have to change the line inside the loop to:

myDoubles[i] = malloc(1000 * sizeof(double));

To get to know the size of the type on your system, you can put

printf("Size of double: %d", sizeof(double));

In your code.

Edit:

Now, since you're working with C++, you should not be using malloc at all. C++ makes life easier and gives you new!

The allocating line should be

myDoubles[i] = new double[1000];

The nice thing abour new is that it does not need the size supplied... you give it a type and an amount; it computes the bytes needed for you. But beware, instead of free you should use

delete[] myDoubles[i];


问:
What are best practices/methods in preventing ajax requests and or form submisions from pages that my server did not serve?
Knowing that anyone can see my AJAX URL string and or forms how can I prevent calls or submissions from pages that my server did not serve?</p>

答: Verifying the source of the form submission is best done by using cookies/sessions. Authenticating each request is your best protection against such cross-site attacks.</p>


问:
How to set  to default property given 's property already define in css
My web pages have a lot of  without class and their property were set in css as below:

```<code>a{
text-decoration:none;
color:black;
}

a:hover, a:active{
color:green;
}
</code>```

And now I have  tags that with class="tnc" and I want it to have the default property which is blue color text with underline and when active it change to red color text.

I tried this but not work:

```<code>a.tnc{
color: initial;
text-decoration: initial;
}

a.tnc:hover, a.tnc:active{
color: initial;
}
</code>```

Any help is appreciated. :)

a:hover, a:active{
 color:green;
}

a.tnc{
 color: initial !important;
 text-decoration: initial;
}

a.tnc:hover, a.tnc:active{
 color: initial;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>I agree with the terms and conditions</code>```

答:
You can use the not selector

a:not(.tnc) {
  text-decoration: none;
  color: black;
}

a:not(.tnc):hover,
a:not(.tnc):active {
  color: green;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test</code>```

Title: How to set <a class="class"> to default property given <a>'s property already define in css

Body:
My web pages have a lot of  without class and their property were set in css as below:

a{
text-decoration:none;
color:black;
}

a:hover, a:active{
color:green;
}

And now I have  tags that with class="tnc" and I want it to have the default property which is blue color text with underline and when active it change to red color text.

I tried this but not work:

a.tnc{
color: initial;
text-decoration: initial;
}

a.tnc:hover, a.tnc:active{
color: initial;
}

Any help is appreciated. :)

a:hover, a:active{
 color:green;
}

a.tnc{
 color: initial !important;
 text-decoration: initial;
}

a.tnc:hover, a.tnc:active{
 color: initial;
}

I agree with the terms and conditions

Body:
You can use the not selector

a:not(.tnc) {
  text-decoration: none;
  color: black;
}

a:not(.tnc):hover,
a:not(.tnc):active {
  color: green;
}

<a href="#">Test</a><br>
<a href="#">Test</a><br>
<a href="#">Test</a><br>
<a href="#">Test</a><br>
<a href="#" class="tnc">Test</a><br>
<a href="#">Test</a><br>
<a href="#" class="tnc">Test</a>