问:
How to check if the inputted data exist in database
I would like to know if what am I lacking here, I can't compare the 'id' from the Textfield to the data from the database.

For example:

If TextField1 == to the data in the database.

Output: Swept by GSW.

```<code>Connection con = connect.getConnection();
        String query = "SELECT * FROM item_list WHERE id = ?";

        Statement st;
        ResultSet rs;
        int id;

        try{
            st = con.createStatement();
            rs = st.executeQuery(query);

            while(rs.next()){
              id = rs.getInt("id");

              if(Integer.parseInt(TF[0].getText()) == id){
                System.out.println(id);
                }
            }
        }catch(SQLException exc){
            System.out.println("Not Found!");
        }
</code>```

Kindly Check the Image Output.
I attached the image file below.

Sample Output

答:
you can use intValue() for Integer object obvious if your object is not null

```<code> while(rs.next()){
      id = rs.getInt("id");

      if(Integer.parseInt(TF[0].getText()).intValue() == id){
           System.out.println(id);
      }
}
</code>```

Body:
I would like to know if what am I lacking here, I can't compare the 'id' from the Textfield to the data from the database.

For example:

If TextField1 == to the data in the database.

Output: Swept by GSW.

Connection con = connect.getConnection();
        String query = "SELECT * FROM item_list WHERE id = ?";

        Statement st;
        ResultSet rs;
        int id;

        try{
            st = con.createStatement();
            rs = st.executeQuery(query);

            while(rs.next()){
              id = rs.getInt("id");

              if(Integer.parseInt(TF[0].getText()) == id){
                System.out.println(id);
                }
            }
        }catch(SQLException exc){
            System.out.println("Not Found!");
        }

Kindly Check the Image Output.
I attached the image file below.

Sample Output

Body:
you can use intValue() for Integer object obvious if your object is not null

 while(rs.next()){
      id = rs.getInt("id");

      if(Integer.parseInt(TF[0].getText()).intValue() == id){
           System.out.println(id);
      }
}


来源: stackexchange

问:
Android design game card UI
I need help with the design of my card game.

I having a Vector of cards (player cards), each item appers in ImageView (Already done and working).

```<code>private Vector<Card> myCards;
</code>```

I having a LinearLayout that holding 5 imageView's.

```<code><LinearLayout
android:id="@+id/myCardsLayout"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:paddingBottom="10dip">

<ImageView
    android:id="@+id/my_card_1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:onClick="goToMainMenu"
    />

<ImageView
    android:id="@+id/my_card_2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
        android:onClick="goToMainMenu"
      />

    <ImageView
        android:id="@+id/my_card_3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:onClick="goToMainMenu"
     />

    <ImageView
        android:id="@+id/my_card_4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:onClick="goToMainMenu"
    />

    <ImageView
        android:id="@+id/my_card_5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:onClick="goToMainMenu"
   />
</LinearLayout>
</code>```

I want to choose the cards that i want to drop by click on the card, And that the player will see this by jumping the card slightly up (or another recommended way).

I will implement that on android:onClick function (goToMainMenu is a temporary statement).

Any idea ? Thanks!

UPDATE1

```<code>  public void myCard1OnClick(View view) {
    view.setSelected(true);
    if(view.isSelected()) {
        int y = view.getTop();
        view.setTop(y - 30);
    }
    else{
        int y = view.getTop();
        view.setTop(y + 30);
    }
}
</code>```

答: You can make an onclick function on cards that moves and give them a function that takes their x and y cordinates and then you just inflate y to move up.</p>

ContentLicense: CC BY-SA 3.0

Title: Android design game card UI

Body:
I need help with the design of my card game.

I having a Vector of cards (player cards), each item appers in ImageView (Already done and working).

private Vector<Card> myCards;

I having a LinearLayout that holding 5 imageView's.

<LinearLayout
android:id="@+id/myCardsLayout"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:paddingBottom="10dip">

<ImageView
    android:id="@+id/my_card_1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:onClick="goToMainMenu"
    />

<ImageView
    android:id="@+id/my_card_2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
        android:onClick="goToMainMenu"
      />

    <ImageView
        android:id="@+id/my_card_3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:onClick="goToMainMenu"
     />

    <ImageView
        android:id="@+id/my_card_4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:onClick="goToMainMenu"
    />

    <ImageView
        android:id="@+id/my_card_5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:onClick="goToMainMenu"
   />
</LinearLayout>

I want to choose the cards that i want to drop by click on the card, And that the player will see this by jumping the card slightly up (or another recommended way).

I will implement that on android:onClick function (goToMainMenu is a temporary statement).

Any idea ? Thanks!

UPDATE1

  public void myCard1OnClick(View view) {
    view.setSelected(true);
    if(view.isSelected()) {
        int y = view.getTop();
        view.setTop(y - 30);
    }
    else{
        int y = view.getTop();
        view.setTop(y + 30);
    }
}


问:
Is IHierarchicalEnumerable the prefered way of dealing with hierarchical data?
I'm building an asp.net mvc app, I want to build up an hierarchical structure, is IHierarchicalEnumerable and IHierarchyData the best way to implement a hierarchical structure?</p>

答: Those two interfaces were written with ASP.NET WebForms in mind (they are not strongly-typed, so that WebForms DataSources can work with hierarchies of arbitrary object types). For an MVC application, you will probably be better off writing your own classes to describe the data hierarchy.</p>

ContentLicense: CC BY-SA 2.5


问:
how to angular-fullstack generator with angular 4
I have installed yeoman generator angular-fullstack- generator. but, I need front end should have framework with angular 4. Where can I find the generator for that. am new to yeoman, so not much sure on generators.</p>

答: You can search for generators here: http://yeoman.io/generators/</p>


问:
To subtract two dates without Using DateAdd Function or DateDiff Function
How i got this output, can you please explain the reason behind it?

```<code>declare @a datetime = '2017-06-08 16:02:22.467',
        @b datetime = '2017-10-23 00:00:00.000'

select DAY(@a - @b)

select @a - @b
</code>```

Output:

```<code>17
1899-08-17 16:02:22.467
</code>```

答:
Well when you substracting 2 dates zero value for datetime type is 1900-01-01 00:00:00.00.

But from SQL 2008 microsoft created new type datetime2 and as far as you get overflow (negative value) in here it casts result to datetime2 that statrs from 0001-01-01 00:00:00.00

DAY function only get date part from your datetime or datetime2 type.

Body:
How i got this output, can you please explain the reason behind it?

declare @a datetime = '2017-06-08 16:02:22.467',
        @b datetime = '2017-10-23 00:00:00.000'

select DAY(@a - @b)

select @a - @b

Output:

17
1899-08-17 16:02:22.467


问:
Run-time error when executing SQL in VBA
I am getting Run-time error '-2147217900 (80040e14) Incorrect syntax new '11999999' when trying to pull data in from a SQL server database in to a Recordset in VBA, this is my first time using VBA so forgive the lack of perfection.

My code is as follows;

```<code>Set connection = New ADODB.Connection
Dim newData As ADODB.Recordset

connection.ConnectionString = "my connection string" 'not posting this for security reasons'
connection.Open

Set newData = connectionExecute(BSMARTOpenFaults )
</code>```

I have my query stored as a multiline string as I prefer it becuase it looks better with SQL statements.

```<code>Private Const BSMARTOpenFaults = "select count(*) from call" _
& "where (" _
& "   call_id between 11000000 and 11999999" _
& "or call_id between 12000000 and 12999999" _
& "or call_id between 14000000 and 14999999" _
& "or call_id between 16000000 and 19999999" _
& "or call_id between 26000000 and 26999999" _
& "or call_id between 31000000 and 31999999" _
& "or call_id between 73000000 and 73999999)" _
& "and call_status <> 2 -- all open calls" _
& "and call_type = 'FT'"
</code>```

Judging by the error its falling on the SQL query (or its just a coincedence that the two numbers are the same) but I am not sure on how to fix it because when I run the query on SQL Server Management Studio the query executes and returns a result (21 to be exact) so it is confusing me as to why it won't execute and returns an invalid syntax error when attempting in VBA, is this an incorrect way of formatting SQL statements in VBA?

答:
General tip what to do, when you are debugging SQL in VBA:

declare the BSMARTOpenFaults as a public for the test.

Go to the immediate window and write ?BSMARTOpenFaults

See the output.

Examine the output.

See that callwhere is one word.

Change the code to Const BSMARTOpenFaults = "select count(*) from call " _ so the words are 2.

Body:
I am getting Run-time error '-2147217900 (80040e14) Incorrect syntax new '11999999' when trying to pull data in from a SQL server database in to a Recordset in VBA, this is my first time using VBA so forgive the lack of perfection.

My code is as follows;

Set connection = New ADODB.Connection
Dim newData As ADODB.Recordset

connection.ConnectionString = "my connection string" 'not posting this for security reasons'
connection.Open

Set newData = connectionExecute(BSMARTOpenFaults )

I have my query stored as a multiline string as I prefer it becuase it looks better with SQL statements.

Private Const BSMARTOpenFaults = "select count(*) from call" _
& "where (" _
& "   call_id between 11000000 and 11999999" _
& "or call_id between 12000000 and 12999999" _
& "or call_id between 14000000 and 14999999" _
& "or call_id between 16000000 and 19999999" _
& "or call_id between 26000000 and 26999999" _
& "or call_id between 31000000 and 31999999" _
& "or call_id between 73000000 and 73999999)" _
& "and call_status <> 2 -- all open calls" _
& "and call_type = 'FT'"

Judging by the error its falling on the SQL query (or its just a coincedence that the two numbers are the same) but I am not sure on how to fix it because when I run the query on SQL Server Management Studio the query executes and returns a result (21 to be exact) so it is confusing me as to why it won't execute and returns an invalid syntax error when attempting in VBA, is this an incorrect way of formatting SQL statements in VBA?


问:
Laravel 5.4 artisan serve htaccess / and Routes::get for existing folders at /public
I'm still trying things with Laravel 5.4.
however running

```<code>php artisan server
</code>```

is not taking .htaccess file in /public into consideration, no matter what i edit in there it's still not processing it, the artisan serve runs at 127.0.0.1:8000

--- i reached this issue cuz i was looking for one other thing which is:

i wanted to have a route::get for the /images folder which is already located at /public, removing -d from htaccess conditions should solve this normally, thus making apache redirect requests even from folders to index.php,

so while testing locally using php artisan serve i noticed that changes or even clearing the htaccess file does not change the behavior of laravel.

Thank you for your time.

[note]
htaccess works if i run laravel from apache, or anything but php artisan serve. so my question is only about the serve command and it's behavior.

答:
PHP has a basic web server feature. this server feature is what is used when you run php artisan serve. .htaccess is an Apache server feature not a PHP feature.

PHP is not built to be a full blown web server so it doesn't have all the configuration options you would find on say Apache or Nginx

Body:
I'm still trying things with Laravel 5.4.
however running

php artisan server

is not taking .htaccess file in /public into consideration, no matter what i edit in there it's still not processing it, the artisan serve runs at 127.0.0.1:8000

--- i reached this issue cuz i was looking for one other thing which is:

i wanted to have a route::get for the /images folder which is already located at /public, removing -d from htaccess conditions should solve this normally, thus making apache redirect requests even from folders to index.php,

so while testing locally using php artisan serve i noticed that changes or even clearing the htaccess file does not change the behavior of laravel.

Thank you for your time.

[note]
htaccess works if i run laravel from apache, or anything but php artisan serve. so my question is only about the serve command and it's behavior.


答:
You're not setting the value of the id parameter in the statement.  Not familiar with Java but in C# it would be something like
statement.Parameters.AddWithValue("@id", id)

Title: How to check if the inputted data exist in database


问:
ExtJs manually firing Click event, button param is different from mouse click
So, I have a login controller, you can click login with mouse or press Enter key, like this:

```<code>Ext.define('My.controller.Login', {
    extend: 'Ext.app.Controller',

    init: function(application) {
        this.control({
            "#idLogin button": {click: this.onButton},
            "#idLogin form > *": {specialkey: this.onKey}
        });
    },

    onButton: function(button, e, eOpts) {
        var win = button.up('window'); // the login window
        //do more stuff...
    },

    onKey: function (field, el) {
        if (el.getKey() == Ext.EventObject.ENTER) //ENTER key performs Login
            Ext.getCmp('#idLogin button').fireEvent('click');
    }
});
</code>```

I realised when I use the mouse to click the Login button, onButton function works properly, button.up() returns me the Login window.

However, if I pressed Enter key and fires the onKey function to do fireEvent('click'), in this case the onButton fires up but parameter button NOT the same as the button parameter received when you click by mouse! And this time, button.up() function is undefined.

Question is, why does fireEvent('click') give me a different button parameter?

答:
A more general way:

```<code>document.querySelector("what-ever-el-selector").click();
</code>```

Tested on extjs 4.2.6

Cheers

Body:
So, I have a login controller, you can click login with mouse or press Enter key, like this:

Ext.define('My.controller.Login', {
    extend: 'Ext.app.Controller',

    init: function(application) {
        this.control({
            "#idLogin button": {click: this.onButton},
            "#idLogin form > *": {specialkey: this.onKey}
        });
    },

    onButton: function(button, e, eOpts) {
        var win = button.up('window'); // the login window
        //do more stuff...
    },

    onKey: function (field, el) {
        if (el.getKey() == Ext.EventObject.ENTER) //ENTER key performs Login
            Ext.getCmp('#idLogin button').fireEvent('click');
    }
});

I realised when I use the mouse to click the Login button, onButton function works properly, button.up() returns me the Login window.

However, if I pressed Enter key and fires the onKey function to do fireEvent('click'), in this case the onButton fires up but parameter button NOT the same as the button parameter received when you click by mouse! And this time, button.up() function is undefined.

Question is, why does fireEvent('click') give me a different button parameter?

Body:
A more general way:

document.querySelector("what-ever-el-selector").click();

Tested on extjs 4.2.6

Cheers


问:
Regex IF condition
I'm looking for a way to filter new IP-Addresses in my host file.
I created a script which updates my host file every time when I call it with data from the matrix enterprise manager. It works fine. But I have to find a solution that only 10.XX.XX.XX or 172.XX.XX.XX addresses are allowed to update.</p>

```<code>Param(
  $newHost = $args[0],
  $newIP = $args[1]
)

$SourceFile = "hosts"
$Match = "$newHost"

(Get-Content $SourceFile) | % {if ($_ -notmatch $Match) {$_}} | Set-Content $SourceFile

Start-Sleep -Seconds 1

$tab = [char]9
$enter = $newIP + $tab + $newHost

if ($newIP XXXX)  #--> here should be a regex if condition... no clue how it works..

$enter | Add-Content -Path hosts
</code>```

答:
Some of the comments above use regex to validate the entire IPv4 address. If you are confident that the IP address you are checking is valid, then you can use "^(10|172)\." to verify just the first octet of the address as per your question:

```<code>if($newIP -match "^(10|172)\.") { ... }
</code>```

If you do want to validate the whole address, there is an alternative way to do this by converting $newIP to a [System.Net.IPAddress] type. If this fails the result will be nothing (null), which is implicitly false, so the following gives you a true/false check that a string is a valid IP address:

```<code>[bool]($newIP -as [System.Net.IPAddress])
</code>```

You could use this to validate the input to the function written by Ansgar:

```<code>[Parameter(Mandatory=$true)]
[ValidateScript({[bool]($_ -as [System.Net.IPAddress]})
[string]$IPAddress
</code>```

Title: Regex IF condition

Body:
I'm looking for a way to filter new IP-Addresses in my host file.
I created a script which updates my host file every time when I call it with data from the matrix enterprise manager. It works fine. But I have to find a solution that only 10.XX.XX.XX or 172.XX.XX.XX addresses are allowed to update.

Param(
  $newHost = $args[0],
  $newIP = $args[1]
)

$SourceFile = "hosts"
$Match = "$newHost"

(Get-Content $SourceFile) | % {if ($_ -notmatch $Match) {$_}} | Set-Content $SourceFile

Start-Sleep -Seconds 1

$tab = [char]9
$enter = $newIP + $tab + $newHost

if ($newIP XXXX)  #--> here should be a regex if condition... no clue how it works..

$enter | Add-Content -Path hosts

Body:
Some of the comments above use regex to validate the entire IPv4 address. If you are confident that the IP address you are checking is valid, then you can use "^(10|172)\." to verify just the first octet of the address as per your question:

if($newIP -match "^(10|172)\.") { ... }

If you do want to validate the whole address, there is an alternative way to do this by converting $newIP to a [System.Net.IPAddress] type. If this fails the result will be nothing (null), which is implicitly false, so the following gives you a true/false check that a string is a valid IP address:

[bool]($newIP -as [System.Net.IPAddress])

You could use this to validate the input to the function written by Ansgar:

[Parameter(Mandatory=$true)]
[ValidateScript({[bool]($_ -as [System.Net.IPAddress]})
[string]$IPAddress


问:
Div tag get down while hover it
While I hover Div tag, Another Div tag will appear in front of the prev Div. When i didn't put any words, it works. but when i put h3 tag, the div goes down.

here is the HTML

```<code><div id="content">
    <h1 class="head-content">Biscuits</h1>
    <div class="line"></div>
    <a href="#">
        <div class="list-content">
            <div class="detail-content">
                <h3>Biscuits 1</h3>
                <p>Price: IDR 12000</p>
            </div>
        </div>
    </a>
    <a href="#">
        <div class="list-content">
            <div class="detail-content">

            </div>
        </div>
    </a>
    <a href="#">
        <div class="list-content">
            <div class="detail-content">

            </div>
        </div>
    </a>
</div>
</code>```

here is CSS

```<code>#content{
        width:50%;
    }
    .line{
        border-top: 5px solid black;
    }
    .list-content{
        display:inline-block;
        width:25%;
        height:200px;
        background-color: black;
        margin-top: 10px;
    }
    .detail-content{
        display: none;
    }
    .list-content:hover .detail-content{
        display: block;
        width:100%;
        height:75%;
        background-color: rgba(255,255,255,0.6);
    }
</code>```

thank you before

答:
Because the .list-content items are inline blocks, when you add a text content you have to vertically align them. Add vertical-align: top to .list-content:

```<code>.list-content {
  display: inline-block;
  width: 25%;
  height: 200px;
  background-color: black;
  margin-top: 10px;
  vertical-align: top;
}
</code>```

And remove the top margin from :

```<code>h3 {
  margin-top: 0;
}
</code>```

{
  width: 50%;
}

.line {
  border-top: 5px solid black;
}

.list-content {
  display: inline-block;
  width: 25%;
  height: 200px;
  background-color: black;
  margin-top: 10px;
  vertical-align: top;
}

.detail-content {
  display: none;
  width: 100%;
  height: 75%;
  background-color: rgba(255, 255, 255, 0.6);
}

.list-content:hover .detail-content {
  display: block;
}

h3 {
  margin-top: 0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="content">
  <h1 class="head-content">Biscuits</h1>
  <div class="line"></div>

    <div class="list-content">
      <div class="detail-content">
        <h3>Biscuits 1</h3>
        <p>Price: IDR 12000</p>
      </div>
    </div>

    <div class="list-content">
      <div class="detail-content">

      </div>
    </div>

    <div class="list-content">
      <div class="detail-content">

      </div>
    </div>

</div></code>```

Title: Div tag get down while hover it

Body:
While I hover Div tag, Another Div tag will appear in front of the prev Div. When i didn't put any words, it works. but when i put h3 tag, the div goes down.

here is the HTML

Biscuits

Biscuits 1

Price: IDR 12000

here is CSS

#content{
        width:50%;
    }
    .line{
        border-top: 5px solid black;
    }
    .list-content{
        display:inline-block;
        width:25%;
        height:200px;
        background-color: black;
        margin-top: 10px;
    }
    .detail-content{
        display: none;
    }
    .list-content:hover .detail-content{
        display: block;
        width:100%;
        height:75%;
        background-color: rgba(255,255,255,0.6);
    }

thank you before

Body:
Because the .list-content items are inline blocks, when you add a text content you have to vertically align them. Add vertical-align: top to .list-content:

.list-content {
  display: inline-block;
  width: 25%;
  height: 200px;
  background-color: black;
  margin-top: 10px;
  vertical-align: top;
}

And remove the top margin from :

h3 {
  margin-top: 0;
}

{
  width: 50%;
}

.line {
  border-top: 5px solid black;
}

.list-content {
  display: inline-block;
  width: 25%;
  height: 200px;
  background-color: black;
  margin-top: 10px;
  vertical-align: top;
}

.detail-content {
  display: none;
  width: 100%;
  height: 75%;
  background-color: rgba(255, 255, 255, 0.6);
}

.list-content:hover .detail-content {
  display: block;
}

h3 {
  margin-top: 0;
}

<div id="content">
  <h1 class="head-content">Biscuits</h1>
  <div class="line"></div>
  <a href="#">
    <div class="list-content">
      <div class="detail-content">
        <h3>Biscuits 1</h3>
        <p>Price: IDR 12000</p>
      </div>
    </div>
  </a>
  <a href="#">
    <div class="list-content">
      <div class="detail-content">

      </div>
    </div>
  </a>
  <a href="#">
    <div class="list-content">
      <div class="detail-content">

      </div>
    </div>
  </a>
</div>


问:
How to get all branches/jobs of a multibranch pipeline job?
Is there a way to get the names of all branches that the scan of a multibranch pipeline job has gathered?

I would like to set up a nightly build with dependencies on existing build jobs and therefore need to check if the multibranch jobs contain some certain  branches. An other way would be to check for an existing job.

答:
I found a way by using the Jenkins API.

In case anyone else is having this question: here is my groovy solution:
(Critics and edits welcome)

```<code>import java.util.ArrayList
import hudson.model.*;

def ArrayList<String> call(String pipelineName) {

    def hi = hudson.model.Hudson.instance;
    def item = hi.getItemByFullName(pipelineName);
    def jobs = item.getAllJobs();

    def arr = new ArrayList<String>();

    Iterator<?> iterator = jobs.iterator();
    while (iterator.hasNext()) {
        def job = iterator.next();
        arr.add(pipelineName + "/" + job.name);
    }
    return arr;
}
</code>```

Body:
I found a way by using the Jenkins API.

In case anyone else is having this question: here is my groovy solution:
(Critics and edits welcome)

import java.util.ArrayList
import hudson.model.*;

def ArrayList<String> call(String pipelineName) {

    def hi = hudson.model.Hudson.instance;
    def item = hi.getItemByFullName(pipelineName);
    def jobs = item.getAllJobs();

    def arr = new ArrayList<String>();

    Iterator<?> iterator = jobs.iterator();
    while (iterator.hasNext()) {
        def job = iterator.next();
        arr.add(pipelineName + "/" + job.name);
    }
    return arr;
}


问:
The character encoding of a framed document was not declared
So, i've been searching in everywhere for a resolution to my problem, but i think i've tried everything but my code is not working at all.

I'm trying to put some text of a txt file in a iframe, and it's actually reading it, but, when i try to change the css, appears the message in the title: "The character encoding of a framed document was not declared."

This is my code:

```<code>    <!DOCTYPE  html>
<html lang = "pt">
<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style>
h1{
    position: absolute;
    left:85px;
    top:0px;
}
.LOGO{
    position: absolute;
    width:70px;
    height:70px;
    z-index: 2;
}
.portugal{
    position: absolute;
    top: 65px;
    left: 0px;
    width:auto;
    height:auto;
    z-index: 1;
}
.PT01{
    position: relative;
    top: 438px;
    left:560px;
    width:20px;
    height:20px;
    z-index: 3;
}

</style>
</head>
<body>
<script>
    var x = document.getElementsByTagName("PT01");
    if(x.id == 'PT01'){
        $("#div1").css("border-style","none");
        $("#div1").css("position",'relative');
        $("#div1").css("top",'315px');
        $("#div1").css("left",'535px');
        $("#div1").css("width",'auto');
        $("#div1").css("height",'auto');
        $("#div1").css("zIndex",'4');
    }

</script>

    <img class = "LOGO" src = "http://www.chronopost.pt/sites/all/themes/custom/quimera/favicon.ico"/> <h1> Informações Package Chronopost </h1>
    <img class = "portugal" src = "http://s2.thingpic.com/images/HV/9N2YRDXBuosfkppy9Jut8Tvx.png"/>
    <img class = "PT01"  name = "PT01" src = "http://www.chronopost.pt/sites/all/themes/custom/quimera/favicon.ico"/>
    <iframe id='div1' src = "PT01.txt">
    </iframe>

</body>
</html>
</code>```

I hope you can help me with this! I'm just a student and i'm trying to learn more.
Thank you!

答:
Possible duplicate here

You can try this, add this between your iframe tag:

```<code><meta http-equiv="Content-type" content="text/html;charset=UTF-8">
</code>```

Body:
So, i've been searching in everywhere for a resolution to my problem, but i think i've tried everything but my code is not working at all.

I'm trying to put some text of a txt file in a iframe, and it's actually reading it, but, when i try to change the css, appears the message in the title: "The character encoding of a framed document was not declared."

This is my code:

    <!DOCTYPE  html>

    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">

 Informações Package Chronopost

I hope you can help me with this! I'm just a student and i'm trying to learn more.
Thank you!

Body:
Possible duplicate here

You can try this, add this between your iframe tag:

<meta http-equiv="Content-type" content="text/html;charset=UTF-8">


问:
laravel get the filename of all records od my database
I want to get from all of my records the value of the filename fields but i have this error. Can anyone help me?

My Code:

$acao = Acao::where('estado_id', '1');

              if($acao->count() >= 1) {

                $filename = $acao->imagem;

                $path = asset('images/acoes/'.$filename);

                return view ('CFAE.index', compact('path'))->withAcoes($acao);

              }else{

                return view ('CFAE.index')->withAcoes($acao);

              }

And the laravel show me this error:

Undefined property: Illuminate\Database\Eloquent\Builder::$imagem

答:
When you do

```<code>$acao = Acao::where('estado_id', '1')->get();
</code>```

you get collection of models not model so you need to do

```<code>foreach($acao as $val)
{
   $val->imagem
}
</code>```

or you could use

```<code>$acao = Acao::where('estado_id', '1')->first();
</code>```

Body:
When you do

$acao = Acao::where('estado_id', '1')->get();

you get collection of models not model so you need to do

foreach($acao as $val)
{
   $val->imagem
}

or you could use

$acao = Acao::where('estado_id', '1')->first();


问:
How ro seperate between 2 related sql queries using PHP and MySQL
I have a PHP code with a MySQL database and javascript that select data from the database and display it on Google map using 3 dependent dropdown list

The problem is that I have 2 SQL queries where one depends on the result of the other.

I need to get just one result from the first SQL query in order to compared in the second SQL query.

SQL query #1:

```<code><!--  the below part  of code work as it should   --!>
<!--create  dropdown list site names-->

<form method ="post" action ="" name="submit_form">
        <table border="0" width="30%">
            <tr>
               <td>Site Name</td>
               <td>Owner Name</td>
               <td>Company Name</td>
               <td>Subcontractor Name</td>
             </tr>
             <tr>
               <td><select id="site_name"  name = "site_name">
                      <option value="">Select Site</option>
                 <?php

                     $query_site_name =$wpdb->get_results("select DISTINCT
                        i.siteNAME,
                        i.ownerID,
                        i.companyID,
                        o.ownerNAME,
                        x.companyNAME
                       from site_info i
                       LEFT
                       JOIN owner_info o
                       on i.ownerID = o.ownerID
                       LEFT
                       JOIN company_info x
                       on i.companyID = x.companyID
                       ");
                      foreach($query_site_name as $row)
                      {
                      echo "<option value = '".$row ->ownerID.", ".$row ->companyID.",".$row ->ownerNAME.",".$row ->companyNAME.",".$row ->siteNAME."'>".$row->siteNAME."</option>";

                       //echo "<option value = ' ".$row ->ownerNAME.",".$row ->companyNAME.",".$row ->siteNAME."'>".$row->siteNAME."</option>";

                     var_dump($query_site_name);
                      }

                 ?>

                </select></td>
</code>```

where in the below SQL query, the variable $site_name will take the result from the first SQL query.

SQL query #2:

```<code>$sql = $wpdb->prepare("select i.siteID
     , i.siteNAME
     , i.equipmentTYPE
     , c.latitude
     , c.longitude
     , c.height
     , o.ownerNAME
     , o.ownerCONTACT
     , x.companyNAME
     , y.subcontractorCOMPANY
     , y.subcontractorNAME
     , y.subcontractorCONTACT
  from site_info i
  LEFT
  JOIN owner_info o
    on i.ownerID = o.ownerID
  LEFT
  JOIN company_info x
    on i.companyID = x.companyID
  LEFT
  JOIN subcontractor_info y
    on i.subcontractorID = y.subcontractorID
    LEFT JOIN site_coordinates2 c
    on i.siteID=c.siteID
    where
    i.siteNAME = %s
    AND
    o.ownerNAME = %s
    AND
    x.companyNAME = %s
   ",$site_name,$owner_name,$company_name);

 $query_submit =$wpdb->get_results($sql, OBJECT);

    echo "<br>";
    echo "<br>";
echo $sql;
</code>```

as it shows in the image the first variable has many values where what I want is just the  word Bsalim  in order to display the marker on the map.

答:
I'm not sure if answers your question, but why once you receive the result from the first query you don't apply a regex to catch just the name that you want (There should be a pattern on the database result for the site_name) an then when you perform the second query you just enter the result of the regex?

If necessary on the second query you can search partial names like %Bsalim%.

Hope it helped.

Body:
I have a PHP code with a MySQL database and javascript that select data from the database and display it on Google map using 3 dependent dropdown list

The problem is that I have 2 SQL queries where one depends on the result of the other.

I need to get just one result from the first SQL query in order to compared in the second SQL query.

SQL query #1:

<form method ="post" action ="" name="submit_form">

               Site Name
               Owner Name
               Company Name
               Subcontractor Name

               <select id="site_name"  name = "site_name">
                      <option value="">Select Site</option>
                 <?php

                     $query_site_name =$wpdb->get_results("select DISTINCT
                        i.siteNAME,
                        i.ownerID,
                        i.companyID,
                        o.ownerNAME,
                        x.companyNAME
                       from site_info i
                       LEFT
                       JOIN owner_info o
                       on i.ownerID = o.ownerID
                       LEFT
                       JOIN company_info x
                       on i.companyID = x.companyID
                       ");
                      foreach($query_site_name as $row)
                      {
                      echo "<option value = '".$row ->ownerID.", ".$row ->companyID.",".$row ->ownerNAME.",".$row ->companyNAME.",".$row ->siteNAME."'>".$row->siteNAME."</option>";

                       //echo "<option value = ' ".$row ->ownerNAME.",".$row ->companyNAME.",".$row ->siteNAME."'>".$row->siteNAME."</option>";

                     var_dump($query_site_name);
                      }

                 ?>

                </select>

where in the below SQL query, the variable $site_name will take the result from the first SQL query.

SQL query #2:

$sql = $wpdb->prepare("select i.siteID
     , i.siteNAME
     , i.equipmentTYPE
     , c.latitude
     , c.longitude
     , c.height
     , o.ownerNAME
     , o.ownerCONTACT
     , x.companyNAME
     , y.subcontractorCOMPANY
     , y.subcontractorNAME
     , y.subcontractorCONTACT
  from site_info i
  LEFT
  JOIN owner_info o
    on i.ownerID = o.ownerID
  LEFT
  JOIN company_info x
    on i.companyID = x.companyID
  LEFT
  JOIN subcontractor_info y
    on i.subcontractorID = y.subcontractorID
    LEFT JOIN site_coordinates2 c
    on i.siteID=c.siteID
    where
    i.siteNAME = %s
    AND
    o.ownerNAME = %s
    AND
    x.companyNAME = %s
   ",$site_name,$owner_name,$company_name);

 $query_submit =$wpdb->get_results($sql, OBJECT);

    echo "
";
    echo "
";
echo $sql;

as it shows in the image the first variable has many values where what I want is just the  word Bsalim  in order to display the marker on the map.


问:
Fancybox 3.1 transition effect between slides
according to this https://codepen.io/fancyapps/pen/LyNXqr
transition effect between slides, can have "rotate" "fade "circular" and much more. I am already using FB 3.1

Currently in the code below i have put the transition effect to be rotate but it does not work. Pls tell the complete and exact code and where it should be placed. Because i am very new to JS, as i know only much about HTML and CSS.

```<code>  $.fancybox.defaults.loop = true;

                        $('[data-fancybox="project1"]').fancybox({
                        slideShow : {
                        autoStart : true,
                        preload: '40',
                        transitionEffect : "rotate",

                                     },

                            });

                    $('[data-fancybox="project2"]').fancybox({
                        slideShow : {
                        autoStart : true,
                        transitionEffect : "rotate",
                                     },

                            });

                    $('[data-fancybox="project3"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project4"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project5"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project6"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project7"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project8"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project9"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });
</code>```

答:
Spot the difference -

```<code>$('[data-fancybox="project2"]').fancybox({
        slideShow : {
            autoStart : true,
            transitionEffect : "rotate"
        }
    });
</code>```

and

```<code>$('[data-fancybox="project2"]').fancybox({
    slideShow : {
        autoStart : true
    },
    transitionEffect : "rotate"
});
</code>```

Body:
according to this https://codepen.io/fancyapps/pen/LyNXqr
transition effect between slides, can have "rotate" "fade "circular" and much more. I am already using FB 3.1

Currently in the code below i have put the transition effect to be rotate but it does not work. Pls tell the complete and exact code and where it should be placed. Because i am very new to JS, as i know only much about HTML and CSS.

  $.fancybox.defaults.loop = true;

                        $('[data-fancybox="project1"]').fancybox({
                        slideShow : {
                        autoStart : true,
                        preload: '40',
                        transitionEffect : "rotate",

                                     },

                            });

                    $('[data-fancybox="project2"]').fancybox({
                        slideShow : {
                        autoStart : true,
                        transitionEffect : "rotate",
                                     },

                            });

                    $('[data-fancybox="project3"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project4"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project5"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project6"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project7"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project8"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

                    $('[data-fancybox="project9"]').fancybox({
                        slideShow : {
                        autoStart : true
                                     },

                            });

Body:
Spot the difference -

$('[data-fancybox="project2"]').fancybox({
        slideShow : {
            autoStart : true,
            transitionEffect : "rotate"
        }
    });

and

$('[data-fancybox="project2"]').fancybox({
    slideShow : {
        autoStart : true
    },
    transitionEffect : "rotate"
});


问:
xpath - Predicate with attribute issue
I have a value which I am trying to trim down to 4 characters which is contained in an xml sub-element with the attribute WEIGHT.

```<code>  <addinfo>
    <info type="COMMODITY_CODE">39253000</info>
    <info type="WEIGHT">0.04700</info>
  </addinfo>
</code>```

The full path is documents/invoice/detailline/addinfo/info type="WEIGHT"

My template says:

```<code>  <xsl:template match="documents/invoice/detailline/addinfo/info[@type='WEIGHT']">
<xsl:element name="{name()}" namespace="{namespace-uri()}">
  <xsl:value-of select="substring(.,  '0', '5')" />
</xsl:element>
</code>```

It should be trimming the value 0.04700 down to a total of 4 characters (0.47). Instead it is doing this, but also eliminating the type attribute "WEIGHT".

Transform Output:

```<code>  <addinfo>
    <info type="COMMODITY_CODE">39253000</info>
    <info>0.04</info>
  </addinfo>
</code>```

答:
It's doing exactly what you're asking it to do: creating an element with the same name, and putting the trimmed value in it. To include the type attribute in the result, you can make a copy of it:

```<code><xsl:template match="documents/invoice/detailline/addinfo/info[@type='WEIGHT']">
  <xsl:element name="{name()}" namespace="{namespace-uri()}">
    <xsl:copy-of select="@*" />
    <xsl:value-of select="substring(., 1, 4)" />
  </xsl:element>
</xsl:template>
</code>```

FYI, the numbering in substring() (and most other things in XPath) starts at 1, and the second and third parameters are numbers, not strings. I've fixed that above.

Title: xpath - Predicate with attribute issue

Body:
I have a value which I am trying to trim down to 4 characters which is contained in an xml sub-element with the attribute WEIGHT.

  <addinfo>
    <info type="COMMODITY_CODE">39253000</info>
    <info type="WEIGHT">0.04700</info>
  </addinfo>

The full path is documents/invoice/detailline/addinfo/info type="WEIGHT"

My template says:

  <xsl:template match="documents/invoice/detailline/addinfo/info[@type='WEIGHT']">
<xsl:element name="{name()}" namespace="{namespace-uri()}">
  <xsl:value-of select="substring(.,  '0', '5')" />
</xsl:element>

It should be trimming the value 0.04700 down to a total of 4 characters (0.47). Instead it is doing this, but also eliminating the type attribute "WEIGHT".

Transform Output:

  <addinfo>
    <info type="COMMODITY_CODE">39253000</info>
    <info>0.04</info>
  </addinfo>

Body:
It's doing exactly what you're asking it to do: creating an element with the same name, and putting the trimmed value in it. To include the type attribute in the result, you can make a copy of it:

<xsl:template match="documents/invoice/detailline/addinfo/info[@type='WEIGHT']">
  <xsl:element name="{name()}" namespace="{namespace-uri()}">
    <xsl:copy-of select="@*" />
    <xsl:value-of select="substring(., 1, 4)" />
  </xsl:element>
</xsl:template>

FYI, the numbering in substring() (and most other things in XPath) starts at 1, and the second and third parameters are numbers, not strings. I've fixed that above.


问:
How to make multiline TextBox pass MouseWheel events so that container is scrollable
I have a panel (UserControl) which needs to be mousewheel scrollable. On the panel are a number of multiline textboxes. Even though they do not have scroll bars, they capture the mousewheel events when they have focus. How can I pass the events through to the parent control, so that the panel scrolls with the mousewheel when the multiline textbox is selected?</p>

答:
A more straightforward method is to trap the mousewheel event.  On firing, it's easy to move the caret up or down then use ScrollToCaret() to make htat line visible.</p>

```<code>    private void ScrollTextBox(object sender, MouseEventArgs e)
        // Mouse wheel has been turned while text box has focus
    {

        // Check scroll amount (+ve is upwards)
        int deltaWheel = e.Delta;
        if (deltaWheel != 0)
        {
            // Find total number of lines
            int nLines = edtAddress.Lines.Length;
            if (nLines > 0)
            {
                // Find line containing caret
                int iLine = edtAddress.GetLineFromCharIndex(edtAddress.SelectionStart);
                if (iLine >= 0)
                {
                    // Scroll down
                    if (deltaWheel > 0)
                    {
                        // Move caret to start of previous line
                        if (iLine > 0)
                        {
                            int position = edtAddress.GetFirstCharIndexFromLine(iLine - 1);
                            edtAddress.Select(position, 0);

                        }
                    }
                    else // Scroll up
                    {
                        // Move caret to start of next line
                        if (iLine < (nLines - 1))
                        {
                            int position = edtAddress.GetFirstCharIndexFromLine(iLine + 1);
                            edtAddress.Select(position, 0);
                        }
                    }

                    // Scroll to new caret position
                    edtAddress.ScrollToCaret();
                }
            }

        }

    }
</code>```

Body:
A more straightforward method is to trap the mousewheel event.  On firing, it's easy to move the caret up or down then use ScrollToCaret() to make htat line visible.

    private void ScrollTextBox(object sender, MouseEventArgs e)
        // Mouse wheel has been turned while text box has focus
    {

        // Check scroll amount (+ve is upwards)
        int deltaWheel = e.Delta;
        if (deltaWheel != 0)
        {
            // Find total number of lines
            int nLines = edtAddress.Lines.Length;
            if (nLines > 0)
            {
                // Find line containing caret
                int iLine = edtAddress.GetLineFromCharIndex(edtAddress.SelectionStart);
                if (iLine >= 0)
                {
                    // Scroll down
                    if (deltaWheel > 0)
                    {
                        // Move caret to start of previous line
                        if (iLine > 0)
                        {
                            int position = edtAddress.GetFirstCharIndexFromLine(iLine - 1);
                            edtAddress.Select(position, 0);

                        }
                    }
                    else // Scroll up
                    {
                        // Move caret to start of next line
                        if (iLine < (nLines - 1))
                        {
                            int position = edtAddress.GetFirstCharIndexFromLine(iLine + 1);
                            edtAddress.Select(position, 0);
                        }
                    }

                    // Scroll to new caret position
                    edtAddress.ScrollToCaret();
                }
            }

        }

    }


问:
How to use custom field for search in django admin
i have a model and is registered to the admin and i have used custom field to display in the list

```<code>class ReportsAdmin(admin.ModelAdmin):
    def investment(self, inst):
        return models.OrderDetail.objects.filter(user=inst.user).distinct().count()

    list_display = ['investment']
    search_fields = ['investment']
</code>```

i want to search using the investment field in django admin but always getting Cannot resolve keyword 'investment' into field. choices are the Model fields.

is there any way by which i can search using the investment field?

答:
Well, this is not allowed:

ModelAdmin.search_fields

Set search_fields to enable a search box on the admin change list
  page. This should be set to a list of field names that will be
  searched whenever somebody submits a search query in that text box.

These fields should be some kind of text field, such as CharField or
  TextField. You can also perform a related lookup on a ForeignKey or
  ManyToManyField with the lookup API “follow” notation:

You don't have such a field at all (never mind that the field has to be a TextField or CharField). What you actually have is a method in your admin class, which cannot be searched at the database level. Ie what's in the search_fields translates to like '%search_term%' type queries executed at the db.

Body:
i have a model and is registered to the admin and i have used custom field to display in the list

class ReportsAdmin(admin.ModelAdmin):
    def investment(self, inst):
        return models.OrderDetail.objects.filter(user=inst.user).distinct().count()

    list_display = ['investment']
    search_fields = ['investment']

i want to search using the investment field in django admin but always getting Cannot resolve keyword 'investment' into field. choices are the Model fields.

is there any way by which i can search using the investment field?


问:
How To Change DataType of a DataColumn in a DataTable?
I have:

```<code>DataTable Table = new DataTable;
SqlConnection = new System.Data.SqlClient.SqlConnection("Data Source=" + ServerName + ";Initial Catalog=" + DatabaseName + ";Integrated Security=SSPI; Connect Timeout=120");

SqlDataAdapter adapter = new SqlDataAdapter("Select * from " + TableName, Connection);
adapter.FillSchema(Table, SchemaType.Source);
adapter.Fill(Table);

DataColumn column = DataTable.Columns[0];
</code>```

What I want to do is:

Assume currently column.DataType.Name is "Double". I want it to become "Int32".

How do I achieve this?

答:
DataTable DT = ...
// Rename column to OLD:
DT.Columns["ID"].ColumnName = "ID_OLD";
// Add column with new type:
DT.Columns.Add( "ID", typeof(int) );
// copy data from old column to new column with new type:
foreach( DataRow DR in DT.Rows )
{ DR["ID"] = Convert.ToInt32( DR["ID_OLD"] ); }
// remove "OLD" column
DT.Columns.Remove( "ID_OLD" );
```

ContentLicense: CC BY-SA 4.0

Body:
I have:

DataTable Table = new DataTable;
SqlConnection = new System.Data.SqlClient.SqlConnection("Data Source=" + ServerName + ";Initial Catalog=" + DatabaseName + ";Integrated Security=SSPI; Connect Timeout=120");

SqlDataAdapter adapter = new SqlDataAdapter("Select * from " + TableName, Connection);
adapter.FillSchema(Table, SchemaType.Source);
adapter.Fill(Table);

DataColumn column = DataTable.Columns[0];

What I want to do is:

Assume currently column.DataType.Name is "Double". I want it to become "Int32".

How do I achieve this?


答:
```<code>declare @a datetime = '2017-06-08 16:02:22.467',
        @b datetime = '2017-10-23 00:00:00.000'

select datediff(day, @a, @b)
</code>```

it returns 137, so difference between these two days are 137.

```<code>declare @c as datetime = null;
select isnull(@c, 0)
</code>```

it return 1900-01-01 00:00:00.000, it means the default value for the datetime is 1900-01-01 00:00:00.000

In your case this select @a-@b minus operation is subtracting the actual difference of 137 days with the default value.

```<code>select dateadd(day, -137, '1900-01-01 00:00:00.000')
</code>```

it returns 1899-08-17 00:00:00.000

if it is select @b-@a, it will return 1900-05-17 07:57:37.533 i.e, it will add 137 days from the default value.

and DAY() function simply returns the day of the given date.

So for the 1899-08-17 the DAY() should be 17

Title: To subtract two dates without Using DateAdd Function or DateDiff Function

Body:
How i got this output, can you please explain the reason behind it?

declare @a datetime = '2017-06-08 16:02:22.467',
        @b datetime = '2017-10-23 00:00:00.000'

select DAY(@a - @b)

select @a - @b

Output:

17
1899-08-17 16:02:22.467

Body:
declare @a datetime = '2017-06-08 16:02:22.467',
        @b datetime = '2017-10-23 00:00:00.000'

select datediff(day, @a, @b)

it returns 137, so difference between these two days are 137.

declare @c as datetime = null;
select isnull(@c, 0)

it return 1900-01-01 00:00:00.000, it means the default value for the datetime is 1900-01-01 00:00:00.000

In your case this select @a-@b minus operation is subtracting the actual difference of 137 days with the default value.

select dateadd(day, -137, '1900-01-01 00:00:00.000')

it returns 1899-08-17 00:00:00.000

if it is select @b-@a, it will return 1900-05-17 07:57:37.533 i.e, it will add 137 days from the default value.

and DAY() function simply returns the day of the given date.

So for the 1899-08-17 the DAY() should be 17


问:
How do I return multiple values from render function in Datatables?
My knowledge in Javascript is quite poor and my question may appear a bit stupid. Anyway, here we go:
I have a column in Data-tables that fetches URLs from a MySQL database.The URLs points to images stored elsewhere. I use render function to do the job(see code below) as I can´t target the integer of the column(as it differs due to being situated in a hidden responsive child row)). That works fine.
Now I also want to add my own CSS to the image in the row.

How can I add this to my js below?

```<code>{ "data": "img",
  className: "min-phone",
  "render": function ( data, type, row) {
                return '<img src="http://beginning.of.url.to.image' + data + '" />';
           }
 }
</code>```

答:
You can use css class to get around this problem.

Based on the device you can add css class like below.

return '';

or

return '';

Body:
My knowledge in Javascript is quite poor and my question may appear a bit stupid. Anyway, here we go:
I have a column in Data-tables that fetches URLs from a MySQL database.The URLs points to images stored elsewhere. I use render function to do the job(see code below) as I can´t target the integer of the column(as it differs due to being situated in a hidden responsive child row)). That works fine.
Now I also want to add my own CSS to the image in the row.

How can I add this to my js below?

{ "data": "img",
  className: "min-phone",
  "render": function ( data, type, row) {
                return '';
           }
 }

Body:
You can use css class to get around this problem.

Based on the device you can add css class like below.

return '<img src="http://beginning.of.url.to.image' + data + '" class="medium-screen" />';

or

return '<img src="http://beginning.of.url.to.image' + data + '" class="large-screen" />';


问:
How to get cURL information
I have a cURL script that makes connection to a page:

```<code><?php
// create curl resource
$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, "example.com");

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
$output = curl_exec($ch);

// close curl resource to free up system resources
curl_close($ch);
?>
</code>```

And that page gives an output like:

```<code>{
  "status" : "fail",
  "data" : {
    "error_message" : "Destination address 37428963298746238 is invalid for Network=BTC."
  }
}
</code>```

How do I get "error_message" to $error_message with PHP?

答:
You can get error like that:</p>

```<code>$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, "example.com");

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
$output = curl_exec($ch);

// close curl resource to free up system resources
curl_close($ch);
$error = json_decode($output);
dd($error);
?>
</code>```

Title: How to get cURL information

Body:
I have a cURL script that makes connection to a page:

<?php
// create curl resource
$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, "example.com");

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
$output = curl_exec($ch);

// close curl resource to free up system resources
curl_close($ch);
?>

And that page gives an output like:

{
  "status" : "fail",
  "data" : {
    "error_message" : "Destination address 37428963298746238 is invalid for Network=BTC."
  }
}

How do I get "error_message" to $error_message with PHP?

Body:
You can get error like that:

$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, "example.com");

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
$output = curl_exec($ch);

// close curl resource to free up system resources
curl_close($ch);
$error = json_decode($output);
dd($error);
?>


问:
Adding image to word document
I have written a below simple word addin to insert an image into word document,
but when I execute this code , image does not get added to document.

```<code>var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH4AAAAsCAMAAACUu/xGAAAAq1BMVEUAAABlZVJlZVKsrJthYU+zs6Grq5ylpZazs6FlZVJfX01lZVJlZVKsrJurq5urq5xlZVKtrZ1lZVJlZVKvr52zs6GysqCoqJeqqpmzs6Grq5xlZVJgYE6zs6Gnp5mrq5yiopRjY1CRkX2rq5yzs6FlZVKRkX2goJKKineRkX2Pj3yrq5yIiHWRkX2RkX2RkX1lZVKRkX2rq5yzs6GoqJdfX02goJKHh3SHh3VrpzVsAAAAMHRSTlMAQIDHx3+Ax0Ag7qBgIA9AEFCPMLOgMO7bYKBQ24+zYNuzkY9wcAXu0oiocPFBMHYlVbK0AAAD3UlEQVRYw6SW7Y6qMBCGB0IkLfKdnB9ocFmjru7HERL03P+VnXY6bdmWjcF9f2inxjydvjMDcHy99zP693oEpTpQYjBR7W4VmzA81GoZCDn/ycrValVmYOJcKBWL1/4HnUEpupLGxOI47iQmDkfc4GEBEFyNQkClzYDKQQs3VmJBufu6G7zRWNMeUzEHUnLVWs/gy9vg4NNB4wUIPOG2h7e8NcV0HRt7QPDxfzTd4ptleB5F6ro3NtsIc7UnjMKKXyuN30ZS+PuLRMW7PN+l2vlhAZ6yqCZmcrm05stfOrwVpvEBaJWStIOpVk/gC8Rb62tjRj25Fx/fEsgqE27cluKB8GR9hDFzeX44CFbmJb9/Cn8w1ldA5tO9VD/gc8FpveTbxfi1LXWOl10Z80c0Yx7/jpyyjRtd9zuxU8ZL8FEYJjZFpg6yIfOpKsf1FJ+EUkzddKkabQ+o0zCcwMN/vZm+uLh4UmW7nptTCBVq5nUF4Y0CgBaNVip18jsPn370909cfX708/gusF3fkQfrKZHXHh45Wi8meRefvfVCfwGOZ9zx8TZ9TjWY2M6vVf4jm8e3WYrDJ1Vj4N3FHwVd6vKFCxefBMFmq7ub6UI7TMZw0SEv8ryPDVaoxPiWufhL/02zY0cm3ZH1VgxIIYa1U/nIibH/EZjjp4M/9w/x9FijbyuqdzOVH+BbWQJxHMupd4pjINhDPKVH1lslBl9g6OKb73j0wmoBHrMj691nsJ0QLn4l0/09nrIm6wv7nGdQqwjGucvPJSWjN4z8aXyBlkfK+i2gmDI/HENGjXA9uPhsUJ22p2OQFg3daaFx0/9qnWBRbOl9hHlvOw3OW/xs4Hf4rcnYzj+OeFOIHj4dtG7/2y+b3IhBGAqjUiQWQ9JI/ErDpop6gcei9z9ZIXHIhLaLSGRW8zYxIuaTZccxqsGfHDXvH4cf37Z4e3ihxVOTp5bf4E8N2u+3PWB2SP7tXsfsFl80rtOeZX/gvz6//7tmnFFzD2mkxnFgL710ToHH1eCcm/LU2aA9m027v+kBH8ipyHbACxAMWaV5I4v2ZgAzIxkUGXIqkn3xrhw4wVe8hoMmOwBmYJMiJy+lHPriNcSyrvgEgUS2h/vl1BcvSqgcZsPbbABrhgdgvhgvS6hIYsPP8MwTVR5SLZA4573xHMpCV7xGZBFmxyProfR64yNCgKh4hygjXIuvpdcbPyEayA2vsEpRHcgl6gtzr8A9ho0RlgQnBPoK4tV45gBfGQZ6KQBDqzRcjdeAqQwHUfYp+SohcQdc1/Ukm4Gw4dV6vqTkM+uQpRv8E2VPF/sPp9xSb2qlGH4AAAAASUVORK5CYII="; // assumes gets a docx file as base64

// Run a batch operation against the Word object model.
Word.run(function (context) {

    // Create a proxy object for the document body.
    var body = context.document.body;

    // Queue a command to insert the image.
    body.insertInlinePictureFromBase64(img, 'End');

    // Synchronize the document state by executing the queued commands,
    // and return a promise to indicate task completion.
    return context.sync().then(function () {
        // app.showNotification('Image inserted successfully.');
        console.log('doneeeee');
    });
})
.catch(function (error) {

});
</code>```

Any idea what could be the issue.

答: You need to remove "data:image/png;base64," from the image src.</p>

Title: Adding image to word document

Body:
I have written a below simple word addin to insert an image into word document,
but when I execute this code , image does not get added to document.

var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH4AAAAsCAMAAACUu/xGAAAAq1BMVEUAAABlZVJlZVKsrJthYU+zs6Grq5ylpZazs6FlZVJfX01lZVJlZVKsrJurq5urq5xlZVKtrZ1lZVJlZVKvr52zs6GysqCoqJeqqpmzs6Grq5xlZVJgYE6zs6Gnp5mrq5yiopRjY1CRkX2rq5yzs6FlZVKRkX2goJKKineRkX2Pj3yrq5yIiHWRkX2RkX2RkX1lZVKRkX2rq5yzs6GoqJdfX02goJKHh3SHh3VrpzVsAAAAMHRSTlMAQIDHx3+Ax0Ag7qBgIA9AEFCPMLOgMO7bYKBQ24+zYNuzkY9wcAXu0oiocPFBMHYlVbK0AAAD3UlEQVRYw6SW7Y6qMBCGB0IkLfKdnB9ocFmjru7HERL03P+VnXY6bdmWjcF9f2inxjydvjMDcHy99zP693oEpTpQYjBR7W4VmzA81GoZCDn/ycrValVmYOJcKBWL1/4HnUEpupLGxOI47iQmDkfc4GEBEFyNQkClzYDKQQs3VmJBufu6G7zRWNMeUzEHUnLVWs/gy9vg4NNB4wUIPOG2h7e8NcV0HRt7QPDxfzTd4ptleB5F6ro3NtsIc7UnjMKKXyuN30ZS+PuLRMW7PN+l2vlhAZ6yqCZmcrm05stfOrwVpvEBaJWStIOpVk/gC8Rb62tjRj25Fx/fEsgqE27cluKB8GR9hDFzeX44CFbmJb9/Cn8w1ldA5tO9VD/gc8FpveTbxfi1LXWOl10Z80c0Yx7/jpyyjRtd9zuxU8ZL8FEYJjZFpg6yIfOpKsf1FJ+EUkzddKkabQ+o0zCcwMN/vZm+uLh4UmW7nptTCBVq5nUF4Y0CgBaNVip18jsPn370909cfX708/gusF3fkQfrKZHXHh45Wi8meRefvfVCfwGOZ9zx8TZ9TjWY2M6vVf4jm8e3WYrDJ1Vj4N3FHwVd6vKFCxefBMFmq7ub6UI7TMZw0SEv8ryPDVaoxPiWufhL/02zY0cm3ZH1VgxIIYa1U/nIibH/EZjjp4M/9w/x9FijbyuqdzOVH+BbWQJxHMupd4pjINhDPKVH1lslBl9g6OKb73j0wmoBHrMj691nsJ0QLn4l0/09nrIm6wv7nGdQqwjGucvPJSWjN4z8aXyBlkfK+i2gmDI/HENGjXA9uPhsUJ22p2OQFg3daaFx0/9qnWBRbOl9hHlvOw3OW/xs4Hf4rcnYzj+OeFOIHj4dtG7/2y+b3IhBGAqjUiQWQ9JI/ErDpop6gcei9z9ZIXHIhLaLSGRW8zYxIuaTZccxqsGfHDXvH4cf37Z4e3ihxVOTp5bf4E8N2u+3PWB2SP7tXsfsFl80rtOeZX/gvz6//7tmnFFzD2mkxnFgL710ToHH1eCcm/LU2aA9m027v+kBH8ipyHbACxAMWaV5I4v2ZgAzIxkUGXIqkn3xrhw4wVe8hoMmOwBmYJMiJy+lHPriNcSyrvgEgUS2h/vl1BcvSqgcZsPbbABrhgdgvhgvS6hIYsPP8MwTVR5SLZA4573xHMpCV7xGZBFmxyProfR64yNCgKh4hygjXIuvpdcbPyEayA2vsEpRHcgl6gtzr8A9ho0RlgQnBPoK4tV45gBfGQZ6KQBDqzRcjdeAqQwHUfYp+SohcQdc1/Ukm4Gw4dV6vqTkM+uQpRv8E2VPF/sPp9xSb2qlGH4AAAAASUVORK5CYII="; // assumes gets a docx file as base64

// Run a batch operation against the Word object model.
Word.run(function (context) {

    // Create a proxy object for the document body.
    var body = context.document.body;

    // Queue a command to insert the image.
    body.insertInlinePictureFromBase64(img, 'End');

    // Synchronize the document state by executing the queued commands,
    // and return a promise to indicate task completion.
    return context.sync().then(function () {
        // app.showNotification('Image inserted successfully.');
        console.log('doneeeee');
    });
})
.catch(function (error) {

});

Any idea what could be the issue.


问:
Eclipse Maven Plugin Configuration Problem
I have followed this thread

now when i try to build using maven plugin installed i am getting following error.
goal i executed was clean -X install

```<code>Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
-> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project trojantime: Compilation failure
Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:581)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
    ... 14 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
</code>```

in Installed JRE from preferences it is JRE set and

here is the snapshot of about>installation>configuration>

```<code>*** Platform Details:

*** System properties:
awt.toolkit=sun.awt.windows.WToolkit
com.sun.management.jmxremote=
eclipse.application=org.eclipse.ui.ide.workbench
eclipse.commands=-os
win32
-ws
win32
-arch
x86
-showsplash
D:\eclipse VT preconfigured\eclipse\\plugins\org.eclipse.platform_3.3.202.v201002111343\splash.bmp
-launcher
D:\eclipse VT preconfigured\eclipse\eclipse.exe
-name
Eclipse
--launcher.library
D:\eclipse VT preconfigured\eclipse\plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519\eclipse_1206.dll
-startup
D:\eclipse VT preconfigured\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
-showlocation
-product
org.eclipse.epp.package.jee.product
-vm
c:\Program Files\Java\jdk1.6.0_04\jre\bin\client\jvm.dll
eclipse.home.location=file:/D:/eclipse VT preconfigured/eclipse/
eclipse.launcher=D:\eclipse VT preconfigured\eclipse\eclipse.exe
eclipse.p2.data.area=@config.dir/../p2/
eclipse.p2.profile=epp.package.jee
eclipse.product=org.eclipse.epp.package.jee.product
eclipse.startTime=1279882656890
eclipse.vm=c:\Program Files\Java\jdk1.6.0_04\jre\bin\client\jvm.dll
eclipse.vmargs=-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx740m
-Xss4m
-XX:PermSize=128m
-XX:MaxPermSize=128m
-XX:CompileThreshold=5
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-Dcom.sun.management.jmxremote
-Djava.class.path=D:\eclipse VT preconfigured\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
file.encoding=Cp1252
file.encoding.pkg=sun.io
file.separator=\
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.awt.printerjob=sun.awt.windows.WPrinterJob
java.class.path=D:\eclipse VT preconfigured\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
java.class.version=50.0
java.endorsed.dirs=c:\Program Files\Java\jdk1.6.0_04\jre\lib\endorsed
java.ext.dirs=c:\Program Files\Java\jdk1.6.0_04\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
java.home=c:\Program Files\Java\jdk1.6.0_04\jre
java.io.tmpdir=C:\DOCUME~1\argus\LOCALS~1\Temp\
java.library.path=D:\eclipse VT preconfigured\eclipse;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;c:/Program Files/Java/jdk1.6.0_04/jre/bin/client;c:/Program Files/Java/jdk1.6.0_04/jre/bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\TortoiseSVN\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.6.0_04\bin;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Documents and Settings\argus\My Documents\apache-ant-1.7.1-bin\apache-ant-1.7.1\bin;C:\Documents and Settings\argus\My Documents\apache-maven-2.0.10\bin;C:\Documents and Settings\argus\My Documents\groovy-binary-1.7.3\groovy-1.7.3\bin;C:\Documents and Settings\argus\My Documents\patch-2.5.9-7-bin\bin
java.rmi.server.randomIDs=true
java.runtime.name=Java(TM) SE Runtime Environment
java.runtime.version=1.6.0_04-b12
java.specification.name=Java Platform API Specification
java.specification.vendor=Sun Microsystems Inc.
java.specification.version=1.6
java.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi
java.version=1.6.0_04
java.vm.info=mixed mode
java.vm.name=Java HotSpot(TM) Client VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.vendor=Sun Microsystems Inc.
java.vm.version=10.0-b19
line.separator=
.
.
.
</code>```

答:
I had also this kind of problems.

In my case it turned out that JAVA_HOME was defined for my user only while PATH was set for the system and maven plugin used default JRE instead of JDK.
So make sure that JAVA_HOME and PATH are in the same scope (I put both variables for system and added JAVA_HOME as the first part in PATH).

Hope it helps someone.

Body:
I have followed this thread

now when i try to build using maven plugin installed i am getting following error.
goal i executed was clean -X install

Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
-> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project trojantime: Compilation failure
Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:581)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
    ... 14 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

in Installed JRE from preferences it is JRE set and

here is the snapshot of about>installation>configuration>

*** Platform Details:

*** System properties:
awt.toolkit=sun.awt.windows.WToolkit
com.sun.management.jmxremote=
eclipse.application=org.eclipse.ui.ide.workbench
eclipse.commands=-os
win32
-ws
win32
-arch
x86
-showsplash
D:\eclipse VT preconfigured\eclipse\\plugins\org.eclipse.platform_3.3.202.v201002111343\splash.bmp
-launcher
D:\eclipse VT preconfigured\eclipse\eclipse.exe
-name
Eclipse
--launcher.library
D:\eclipse VT preconfigured\eclipse\plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519\eclipse_1206.dll
-startup
D:\eclipse VT preconfigured\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
-showlocation
-product
org.eclipse.epp.package.jee.product
-vm
c:\Program Files\Java\jdk1.6.0_04\jre\bin\client\jvm.dll
eclipse.home.location=file:/D:/eclipse VT preconfigured/eclipse/
eclipse.launcher=D:\eclipse VT preconfigured\eclipse\eclipse.exe
eclipse.p2.data.area=@config.dir/../p2/
eclipse.p2.profile=epp.package.jee
eclipse.product=org.eclipse.epp.package.jee.product
eclipse.startTime=1279882656890
eclipse.vm=c:\Program Files\Java\jdk1.6.0_04\jre\bin\client\jvm.dll
eclipse.vmargs=-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx740m
-Xss4m
-XX:PermSize=128m
-XX:MaxPermSize=128m
-XX:CompileThreshold=5
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-Dcom.sun.management.jmxremote
-Djava.class.path=D:\eclipse VT preconfigured\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
file.encoding=Cp1252
file.encoding.pkg=sun.io
file.separator=\
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.awt.printerjob=sun.awt.windows.WPrinterJob
java.class.path=D:\eclipse VT preconfigured\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
java.class.version=50.0
java.endorsed.dirs=c:\Program Files\Java\jdk1.6.0_04\jre\lib\endorsed
java.ext.dirs=c:\Program Files\Java\jdk1.6.0_04\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
java.home=c:\Program Files\Java\jdk1.6.0_04\jre
java.io.tmpdir=C:\DOCUME~1\argus\LOCALS~1\Temp\
java.library.path=D:\eclipse VT preconfigured\eclipse;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;c:/Program Files/Java/jdk1.6.0_04/jre/bin/client;c:/Program Files/Java/jdk1.6.0_04/jre/bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\TortoiseSVN\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.6.0_04\bin;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Documents and Settings\argus\My Documents\apache-ant-1.7.1-bin\apache-ant-1.7.1\bin;C:\Documents and Settings\argus\My Documents\apache-maven-2.0.10\bin;C:\Documents and Settings\argus\My Documents\groovy-binary-1.7.3\groovy-1.7.3\bin;C:\Documents and Settings\argus\My Documents\patch-2.5.9-7-bin\bin
java.rmi.server.randomIDs=true
java.runtime.name=Java(TM) SE Runtime Environment
java.runtime.version=1.6.0_04-b12
java.specification.name=Java Platform API Specification
java.specification.vendor=Sun Microsystems Inc.
java.specification.version=1.6
java.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi
java.version=1.6.0_04
java.vm.info=mixed mode
java.vm.name=Java HotSpot(TM) Client VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.vendor=Sun Microsystems Inc.
java.vm.version=10.0-b19
line.separator=
.
.
.


问:
How to check if the inputted data exist in database
I would like to know if what am I lacking here, I can't compare the 'id' from the Textfield to the data from the database.

For example:

If TextField1 == to the data in the database.

Output: Swept by GSW.

```<code>Connection con = connect.getConnection();
        String query = "SELECT * FROM item_list WHERE id = ?";

        Statement st;
        ResultSet rs;
        int id;

        try{
            st = con.createStatement();
            rs = st.executeQuery(query);

            while(rs.next()){
              id = rs.getInt("id");

              if(Integer.parseInt(TF[0].getText()) == id){
                System.out.println(id);
                }
            }
        }catch(SQLException exc){
            System.out.println("Not Found!");
        }
</code>```

Kindly Check the Image Output.
I attached the image file below.

Sample Output

答:
Here are some mistake I see

You use a parameter in the query, "SELECT * FROM item_list WHERE id = ?";so use a PreparedStatement

Set the parameter to that PreparedStatement ps = connection.preparedStatement(query); with ps.setInt(1, Integer.parseInt(TF[0].getText()));

Don't catch the exception without logging it, here your query as a syntax error but you don't know it.

careful with uppercase in the database field name "Id"

This might not be everything ...

And of course, now that you get only the row with that ID, you can simply check if there is at least one row return to validate that it exists.

Body:
I would like to know if what am I lacking here, I can't compare the 'id' from the Textfield to the data from the database.

For example:

If TextField1 == to the data in the database.

Output: Swept by GSW.

Connection con = connect.getConnection();
        String query = "SELECT * FROM item_list WHERE id = ?";

        Statement st;
        ResultSet rs;
        int id;

        try{
            st = con.createStatement();
            rs = st.executeQuery(query);

            while(rs.next()){
              id = rs.getInt("id");

              if(Integer.parseInt(TF[0].getText()) == id){
                System.out.println(id);
                }
            }
        }catch(SQLException exc){
            System.out.println("Not Found!");
        }

Kindly Check the Image Output.
I attached the image file below.

Sample Output


问:
Svg using angular 2 and typescript not rendering with *ngFor
I'm playing around with Angular2, using typescript and there is something that is not rendering as I hoped for, I don't know what I'm doing wrong.

This code is working

```<code>import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: `
        <svg viewBox="0 0 900 500" preserveAspectRatio="xMidYMid meet">
            <svg:circle cx=50 cy=50 r=10 />
            <svg:circle cx=71 cy=71 r=20 />
            <svg:circle cx=106 cy=106 r=30 />
        </svg>
    `
})
export class AppComponent {
}
</code>```

But when I'm trying to bind it on an object with *ngFor, it's not rendering...

```<code>@Component({
    selector: 'my-app',
    template: `
        <svg viewBox="0 0 900 500" preserveAspectRatio="xMidYMid meet">
            <svg:circle *ngFor="#circle of circles"
                  [attr.cx]="circle.x"
                  [attr.cy]="circle.y"
                  [attr.r]="circle.radius" />
        </svg>
    `
})
export class AppComponent {
    circles = [
        {x: 50, y: 50, radius: 10},
        {x: 75, y: 75, radius: 20},
        {x: 115, y: 115, radius: 30}
    ];
}
</code>```

I'm trying to follow this tutorial (http://teropa.info/blog/2016/02/28/metabubbles-generative-art-with-angular-2.html#drawing-svg-circles) using typescript instead ...

Seems to be a duplicate of AngularJS 2 and SVG <ellipse> elements not rendered

Dom elements not generated for every iteration and properties(attributes) not generated...

THIS IS NOW FIXED
It works in Chrome, but not in IE 11.
IE Console was not displaying the javascript errors and chrome console was. That how I managed to fix my issue trying to solve the javascript errors I had.

I turned out to change the SystemJS config. Instead of using the following config as stated there https://angular.io/docs/ts/latest/quickstart.html#!#tsconfig

```<code>System.config({
        packages: {
          app: {
            format: 'register',
            defaultExtension: 'js'
          }
        }
      });
</code>```

I used it :

```<code>System.config({
    transpiler: 'typescript',
    typescriptOptions: {
        emitDecoratorMetadata: true
    },
    map: {
        app: "./app"
    },
    packages: {
        app: {
            main: './main',
            defaultExtension: 'js'
        }
    }
});
</code>```

That's one part I'm not understanding very well, are those typescriptoptions are overrideing tsconfig.json file? I don't know yet... I don't know yet what is this mapping for and what are the packages, but at least I can go on with my learning

答:
you can try this.

defining your circle component

```<code>@Component({
    selector: 'g[circle]',
    templateUrl: './circle.component.html',
    styleUrls: ['./circle.component.scss']
})
</code>```

circle.component.hmtl :

```<code><svg:circle
            [attr.cx]="circle?.x"
            [attr.cy]="circle?.y"
            [attr.r]="radius"

            [attr.fill]="circle?.fill"
             />
</code>```

and your root html will be like

```<code><svg>
<g circle *ngFor="let circle of circles"
                    [attr.fill-opacity]="opacity"
                    [attr.transform]="scale"
                    [circle]="circle"
                     />
</svg>
</code>```

similarly you can use all the other svg shapes by creating similar components with selector as defied above.

You can use this library which provides all the svg elements

https://www.npmjs.com/package/angular-svg

Body:
I'm playing around with Angular2, using typescript and there is something that is not rendering as I hoped for, I don't know what I'm doing wrong.

This code is working

import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: `
        <svg viewBox="0 0 900 500" preserveAspectRatio="xMidYMid meet">
            <svg:circle cx=50 cy=50 r=10 />
            <svg:circle cx=71 cy=71 r=20 />
            <svg:circle cx=106 cy=106 r=30 />
        </svg>
    `
})
export class AppComponent {
}

But when I'm trying to bind it on an object with *ngFor, it's not rendering...

@Component({
    selector: 'my-app',
    template: `
        <svg viewBox="0 0 900 500" preserveAspectRatio="xMidYMid meet">
            <svg:circle *ngFor="#circle of circles"
                  [attr.cx]="circle.x"
                  [attr.cy]="circle.y"
                  [attr.r]="circle.radius" />
        </svg>
    `
})
export class AppComponent {
    circles = [
        {x: 50, y: 50, radius: 10},
        {x: 75, y: 75, radius: 20},
        {x: 115, y: 115, radius: 30}
    ];
}

I'm trying to follow this tutorial (http://teropa.info/blog/2016/02/28/metabubbles-generative-art-with-angular-2.html#drawing-svg-circles) using typescript instead ...

Seems to be a duplicate of AngularJS 2 and SVG <ellipse> elements not rendered

Dom elements not generated for every iteration and properties(attributes) not generated...

THIS IS NOW FIXED
It works in Chrome, but not in IE 11.
IE Console was not displaying the javascript errors and chrome console was. That how I managed to fix my issue trying to solve the javascript errors I had.

I turned out to change the SystemJS config. Instead of using the following config as stated there https://angular.io/docs/ts/latest/quickstart.html#!#tsconfig

System.config({
        packages: {
          app: {
            format: 'register',
            defaultExtension: 'js'
          }
        }
      });

I used it :

System.config({
    transpiler: 'typescript',
    typescriptOptions: {
        emitDecoratorMetadata: true
    },
    map: {
        app: "./app"
    },
    packages: {
        app: {
            main: './main',
            defaultExtension: 'js'
        }
    }
});

That's one part I'm not understanding very well, are those typescriptoptions are overrideing tsconfig.json file? I don't know yet... I don't know yet what is this mapping for and what are the packages, but at least I can go on with my learning

Body:
you can try this.

defining your circle component

@Component({
    selector: 'g[circle]',
    templateUrl: './circle.component.html',
    styleUrls: ['./circle.component.scss']
})

circle.component.hmtl :

<svg:circle
            [attr.cx]="circle?.x"
            [attr.cy]="circle?.y"
            [attr.r]="radius"

            [attr.fill]="circle?.fill"
             />

and your root html will be like

<svg>
<g circle *ngFor="let circle of circles"
                    [attr.fill-opacity]="opacity"
                    [attr.transform]="scale"
                    [circle]="circle"
                     />
</svg>

similarly you can use all the other svg shapes by creating similar components with selector as defied above.

You can use this library which provides all the svg elements

https://www.npmjs.com/package/angular-svg


问:
Swift: I'm not able to make autolayout constraints work for my UIScrollView
I'm trying to make a simple layout that should scroll vertically when views are too many to fit on the screen.

So this is what I have so far:

I created a scrollview and a container view like that

```<code>let mainScrollView: UIScrollView = {

    let scrollView = UIScrollView()

    scrollView.isUserInteractionEnabled = true
    scrollView.translatesAutoresizingMaskIntoConstraints = false

    return scrollView
}()

let containerView: UIView = {

    let view = UIView()

    view.backgroundColor = .lightGray
    view.translatesAutoresizingMaskIntoConstraints = false

    return view
}()
</code>```

Then I added the scrollview to the main view, added the container view to the scrollview and a couple of labels to the container view

```<code>view.addSubview(mainScrollView)
mainScrollView.addSubview(containerView)

containerView.addSubview(firstLabel)
containerView.addSubview(secondLabel)
</code>```

I pinned the scrollview to the main view, and the container view to the scrollview. After that I started adding the labels inside the container view like this

```<code>mainScrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
mainScrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
mainScrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
mainScrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true

containerView.topAnchor.constraint(equalTo: mainScrollView.layoutMarginsGuide.topAnchor).isActive = true
containerView.bottomAnchor.constraint(equalTo: mainScrollView.layoutMarginsGuide.bottomAnchor).isActive = true
containerView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
containerView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true

firstLabel.centerXAnchor.constraint(equalTo: containerView.centerXAnchor).isActive = true
firstLabel.topAnchor.constraint(equalTo: containerView.topAnchor, constant: 30).isActive = true
firstLabel.widthAnchor.constraint(equalToConstant: 50).isActive = true
firstLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true

secondLabel.centerXAnchor.constraint(equalTo: containerView.centerXAnchor).isActive = true
secondLabel.topAnchor.constraint(equalTo: firstLabel.bottomAnchor, constant: 750).isActive = true
secondLabel.widthAnchor.constraint(equalToConstant: 50).isActive = true
secondLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true
</code>```

The problem is that for some reason the scrollview is not able to calculate it's height and it doesn't scroll vertically. The second label remains invisible because it's too "low" on the screen.

I tried setting the bottom constraint of the container view to the bottom of the second label but I'm going nowhere honestly.

What am I missing? How can I set constraints to make the scrollview scroll with autolayout (without setting a specific height of the container view)?

答:
Scrollview scrolls in either direction. So any view added to it would need some additional constraints to let the Scrollview calculate its content size.

You have pinned the container view to scroll view. If you are looking at a vertically scrolling view like a table view then you need to also set the width of the scroll to the container view so that it can calculate the width.

Next for height, its automatically calculated based on the UI elements added in the container view. Ensure that all of the labels have leading, trailing to the container and vertical spacing to each other and top of the container view. This will let the scroll view know the height needed.

```<code>    self.scrollView.translatesAutoresizingMaskIntoConstraints = false
    self.contentView.translatesAutoresizingMaskIntoConstraints = false
    self.label1.translatesAutoresizingMaskIntoConstraints = false
    self.label2.translatesAutoresizingMaskIntoConstraints = false
    self.label3.translatesAutoresizingMaskIntoConstraints = false

    self.contentView.addSubview(self.label1)
    self.contentView.addSubview(self.label2)
    self.contentView.addSubview(self.label3)

    self.scrollView.addSubview(self.contentView)
    self.view.addSubview(self.scrollView)

    NSLayoutConstraint.activate([
        self.scrollView.topAnchor.constraint(equalTo: self.view.topAnchor),
        self.scrollView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
        self.scrollView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
        self.scrollView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor)
    ])

    NSLayoutConstraint.activate([
        self.contentView.topAnchor.constraint(equalTo: self.scrollView.topAnchor),
        self.contentView.trailingAnchor.constraint(equalTo: self.scrollView.trailingAnchor),
        self.contentView.bottomAnchor.constraint(equalTo: self.scrollView.bottomAnchor),
        self.contentView.leadingAnchor.constraint(equalTo: self.scrollView.leadingAnchor),
        self.contentView.widthAnchor.constraint(equalTo: self.scrollView.widthAnchor)
    ])

    NSLayoutConstraint.activate([
        self.label1.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor),
        self.label2.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor),
        self.label3.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor),
        self.label1.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor),
        self.label2.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor),
        self.label3.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor)
    ])

    NSLayoutConstraint.activate([
        self.label1.topAnchor.constraint(equalTo: self.contentView.topAnchor),
        self.label2.topAnchor.constraint(equalTo: self.label1.bottomAnchor),
        self.label3.topAnchor.constraint(equalTo: self.label2.bottomAnchor),
        self.label3.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor)
    ])
</code>```

And when run, it won't complain about any constraint issues either. Same can be done for horizontal scroll.

Body:
I'm trying to make a simple layout that should scroll vertically when views are too many to fit on the screen.

So this is what I have so far:

I created a scrollview and a container view like that

let mainScrollView: UIScrollView = {

    let scrollView = UIScrollView()

    scrollView.isUserInteractionEnabled = true
    scrollView.translatesAutoresizingMaskIntoConstraints = false

    return scrollView
}()

let containerView: UIView = {

    let view = UIView()

    view.backgroundColor = .lightGray
    view.translatesAutoresizingMaskIntoConstraints = false

    return view
}()

Then I added the scrollview to the main view, added the container view to the scrollview and a couple of labels to the container view

view.addSubview(mainScrollView)
mainScrollView.addSubview(containerView)

containerView.addSubview(firstLabel)
containerView.addSubview(secondLabel)

I pinned the scrollview to the main view, and the container view to the scrollview. After that I started adding the labels inside the container view like this

mainScrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
mainScrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
mainScrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
mainScrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true

containerView.topAnchor.constraint(equalTo: mainScrollView.layoutMarginsGuide.topAnchor).isActive = true
containerView.bottomAnchor.constraint(equalTo: mainScrollView.layoutMarginsGuide.bottomAnchor).isActive = true
containerView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
containerView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true

firstLabel.centerXAnchor.constraint(equalTo: containerView.centerXAnchor).isActive = true
firstLabel.topAnchor.constraint(equalTo: containerView.topAnchor, constant: 30).isActive = true
firstLabel.widthAnchor.constraint(equalToConstant: 50).isActive = true
firstLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true

secondLabel.centerXAnchor.constraint(equalTo: containerView.centerXAnchor).isActive = true
secondLabel.topAnchor.constraint(equalTo: firstLabel.bottomAnchor, constant: 750).isActive = true
secondLabel.widthAnchor.constraint(equalToConstant: 50).isActive = true
secondLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true

The problem is that for some reason the scrollview is not able to calculate it's height and it doesn't scroll vertically. The second label remains invisible because it's too "low" on the screen.

I tried setting the bottom constraint of the container view to the bottom of the second label but I'm going nowhere honestly.

What am I missing? How can I set constraints to make the scrollview scroll with autolayout (without setting a specific height of the container view)?

Body:
Scrollview scrolls in either direction. So any view added to it would need some additional constraints to let the Scrollview calculate its content size.

You have pinned the container view to scroll view. If you are looking at a vertically scrolling view like a table view then you need to also set the width of the scroll to the container view so that it can calculate the width.

Next for height, its automatically calculated based on the UI elements added in the container view. Ensure that all of the labels have leading, trailing to the container and vertical spacing to each other and top of the container view. This will let the scroll view know the height needed.

    self.scrollView.translatesAutoresizingMaskIntoConstraints = false
    self.contentView.translatesAutoresizingMaskIntoConstraints = false
    self.label1.translatesAutoresizingMaskIntoConstraints = false
    self.label2.translatesAutoresizingMaskIntoConstraints = false
    self.label3.translatesAutoresizingMaskIntoConstraints = false

    self.contentView.addSubview(self.label1)
    self.contentView.addSubview(self.label2)
    self.contentView.addSubview(self.label3)

    self.scrollView.addSubview(self.contentView)
    self.view.addSubview(self.scrollView)

    NSLayoutConstraint.activate([
        self.scrollView.topAnchor.constraint(equalTo: self.view.topAnchor),
        self.scrollView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
        self.scrollView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
        self.scrollView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor)
    ])

    NSLayoutConstraint.activate([
        self.contentView.topAnchor.constraint(equalTo: self.scrollView.topAnchor),
        self.contentView.trailingAnchor.constraint(equalTo: self.scrollView.trailingAnchor),
        self.contentView.bottomAnchor.constraint(equalTo: self.scrollView.bottomAnchor),
        self.contentView.leadingAnchor.constraint(equalTo: self.scrollView.leadingAnchor),
        self.contentView.widthAnchor.constraint(equalTo: self.scrollView.widthAnchor)
    ])

    NSLayoutConstraint.activate([
        self.label1.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor),
        self.label2.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor),
        self.label3.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor),
        self.label1.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor),
        self.label2.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor),
        self.label3.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor)
    ])

    NSLayoutConstraint.activate([
        self.label1.topAnchor.constraint(equalTo: self.contentView.topAnchor),
        self.label2.topAnchor.constraint(equalTo: self.label1.bottomAnchor),
        self.label3.topAnchor.constraint(equalTo: self.label2.bottomAnchor),
        self.label3.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor)
    ])

And when run, it won't complain about any constraint issues either. Same can be done for horizontal scroll.