问:
How to create 3 columns in the drop-down list using jQuery UI selectMenu widget?
I was given a task for creating a drop-down list consisting of 3 columns (in each row) as shown in the below image.

Now, I realized that the Selectmenu widget of the jQuery UI will fulfill my requirement and therefore, I used the following code (as given on their official documentation page).

```<code><!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>selectmenu demo</title>

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">

<style>

label { display: block; }

select { width: 200px; }

.overflow { height: 200px; }

</style>

<script src="//code.jquery.com/jquery-1.12.4.js"></script>

<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

</head>

<body>

<label for="number">Select a number:</label>

<select name="number" id="number">

<option value="1">1</option>

<option value="2" selected>2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>

<option value="11">11</option>

<option value="12">12</option>

<option value="13">13</option>

<option value="14">14</option>

<option value="15">15</option>

<option value="16">16</option>

<option value="17">17</option>

<option value="18">18</option>

<option value="19">19</option>

</select>

<script>

$( "#number" )

.selectmenu()

.selectmenu( "menuWidget" )

.addClass( "overflow" );

</script>

</body>

</html>
</code>```

The problem was that I was looking to create 3 columns instead of the 1 default column. So, I tried two options for aligning the text content inside the option tag.

Putting the text inside the span tag.

Putting the text inside a table made of one row and three columns (cells).

Given below is the code which I tried.

```<code><option value="1">
        <span align="left">Apple</span>
        <span align="center">Mango</span>
        <span align="right">Orange</span>
        </option>
      <option value="2" selected>
      <table>
        <tr>
          <td align="left">1</td>
          <td align="center">2</td>
          <td align="right">3</td>
        </tr>
        </table>
      </option>
</code>```

But this didn't fix my problem as I was getting the Output as shown in the below image.

Since I'm a beginner in HTML, CSS, and jQuery, therefore, I have no idea of what to do next for creating a drop-down list containing 3 columns in each row. Please note that I'll select the whole row consisting of all the 3 columns (as shown in the below image) and not any cell of any particular column.Can anyone kindly suggest what can be done to fix this problem and create the dropdown list as shown in the first image?

答:
That's invalid HTML and I assume most browser will ignore that.

Use an extension point if you want to change the rendering:
http://api.jqueryui.com/selectmenu/#method-_renderItem

Body:
I was given a task for creating a drop-down list consisting of 3 columns (in each row) as shown in the below image.

Now, I realized that the Selectmenu widget of the jQuery UI will fulfill my requirement and therefore, I used the following code (as given on their official documentation page).

<!doctype html>

<meta charset="utf-8">

<title>selectmenu demo</title>

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">

Select a number:

<select name="number" id="number">

<option value="1">1</option>

<option value="2" selected>2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>

<option value="11">11</option>

<option value="12">12</option>

<option value="13">13</option>

<option value="14">14</option>

<option value="15">15</option>

<option value="16">16</option>

<option value="17">17</option>

<option value="18">18</option>

<option value="19">19</option>

</select>

The problem was that I was looking to create 3 columns instead of the 1 default column. So, I tried two options for aligning the text content inside the option tag.

Putting the text inside the span tag.

Putting the text inside a table made of one row and three columns (cells).

Given below is the code which I tried.

<option value="1">
        Apple
        Mango
        Orange
        </option>
      <option value="2" selected>

          1
          2
          3

      </option>

But this didn't fix my problem as I was getting the Output as shown in the below image.

Since I'm a beginner in HTML, CSS, and jQuery, therefore, I have no idea of what to do next for creating a drop-down list containing 3 columns in each row. Please note that I'll select the whole row consisting of all the 3 columns (as shown in the below image) and not any cell of any particular column.Can anyone kindly suggest what can be done to fix this problem and create the dropdown list as shown in the first image?


来源: stackexchange

问:
Angular CLI version for Angular 4.4.6
I am going through angular 4.4.6 documentation and I want to install the same version in my system, but when i do

npm install -g @angular/cli

It installs the latest CLI i.e. 1.5.5 and whenever i create the projects on angular, my angular version is v5.0.5 which is the latest angular version.
Which angular/cli version should I use for Angular 4.4.6?

答:
You want @angular/cli version 1.4.9:

```<code>npm install @angular/cli@1.4.9
</code>```

Checkout the branches and tags on the GitHub project site and open package.json to find out which version of @angular is supported by each CLI release:

ContentLicense: CC BY-SA 3.0

Title: Angular CLI version for Angular 4.4.6

Body:
You want @angular/cli version 1.4.9:

npm install @angular/cli@1.4.9

Checkout the branches and tags on the GitHub project site and open package.json to find out which version of @angular is supported by each CLI release:


问:
How do I make multiple galleries on one page using Fancybox?
I'm trying to make 3 galleries for my website all using Fancybox's class="imglist" with data-fancybox="images" data-caption="". I've tried following How to create separate Fancybox galleries on the same page? for help but it doesn't seem to work. I am using FancyBox v3.2.10.

An example of my code:

```<code><h3 class="dropdown clear">Print Design</h3>
<div id="print" class="imglist">
    <a href="images/work/img1.jpg" class="fancybox" rel="gallery01" data-fancybox="images" data-caption="">
        <div class="thumb thumb1"></div></a>
    <a href="images/work/img2.jpg" class="fancybox" rel="gallery01" data-fancybox="">
        <div class="thumb thumb2"></div></a>
    <a href="images/work/img3.jpg" class="fancybox" rel="gallery01" data-fancybox="images" data-caption="">
        <div class="thumb thumb3"></div></a>
    <a href="images/work/img4.jpg" class="fancybox" rel="gallery01" data-fancybox="images" data-caption="">
        <div class="thumb thumb4"></div></a>
</div>
<h3 class="dropdown clear">Photography</h3>
<div id="photo" class="imglist">
    <a href="images/work/photo1.jpg" class="fancybox" rel="gallery02" data-fancybox="images" data-caption="">
        <div class="photothumb photothumb1"></div></a>
    <a href="images/work/photo2.jpg" class="fancybox" rel="gallery02" data-fancybox="images" data-caption="">
        <div class="photothumb photothumb2"></div></a>
    <a href="images/work/photo3.jpg" class="fancybox" rel="gallery02" data-fancybox="images" data-caption="">
        <div class="photothumb photothumb3"></div></a>
    <a href="images/work/photo4.jpg" class="fancybox" rel="gallery02" data-fancybox="images" data-caption="">
        <div class="photothumb photothumb4"></div></a>
</div>
</code>```

As you can see I attempted to use the rel="gallery01" method but they just all stack into one big gallery of 8 images when I want two different galleries of 4 images. Any ideas?

Last but not least on a side note, is there any way to remove the play/pause and fullscreen buttons when viewing images in fancy box? I find them to be quite useless and just take up un-needed space.

Thank you for your time.

答:
Galleries are created by adding the same data-fancybox attribute value, therefore replace rel="gallery01" with data-fancybox="gallery01" (and similarly for the rest of links).

You can use buttons option to customize buttons in the toolbar, example:

```<code>// Options for all groups
$('[data-fancybox^="gallery"]').fancybox({
  thumbs : {
    autoStart : true
  },
  buttons : [
    'zoom',
    'close'
  ]
});
</code>```

Demo - https://codepen.io/anon/pen/XzwOyw?editors=1010

Also, see documentation and samples here - http://fancyapps.com/fancybox/3/docs/#usage

Body:
I'm trying to make 3 galleries for my website all using Fancybox's class="imglist" with data-fancybox="images" data-caption="". I've tried following How to create separate Fancybox galleries on the same page? for help but it doesn't seem to work. I am using FancyBox v3.2.10.

An example of my code:

Print Design

Photography

As you can see I attempted to use the rel="gallery01" method but they just all stack into one big gallery of 8 images when I want two different galleries of 4 images. Any ideas?

Last but not least on a side note, is there any way to remove the play/pause and fullscreen buttons when viewing images in fancy box? I find them to be quite useless and just take up un-needed space.

Thank you for your time.

Body:
Galleries are created by adding the same data-fancybox attribute value, therefore replace rel="gallery01" with data-fancybox="gallery01" (and similarly for the rest of links).

You can use buttons option to customize buttons in the toolbar, example:

// Options for all groups
$('[data-fancybox^="gallery"]').fancybox({
  thumbs : {
    autoStart : true
  },
  buttons : [
    'zoom',
    'close'
  ]
});

Demo - https://codepen.io/anon/pen/XzwOyw?editors=1010

Also, see documentation and samples here - http://fancyapps.com/fancybox/3/docs/#usage


问:
Any way to convert my JSP project into Spring, though it has so many JSP files?
I have a project which is coded in JSP. It has about 60 jsp files. Now i want to change the code from jsp to spring. So is there any way to do this.
Should i write each jsp file in spring individually or any short cut for this transformation .
How to start please give any suggestion.
Note: There is DATABASE connectivity also.
Thanks

答:
My suggestion is follow Spring model view controller design pattern. some points

1.Add dispatcher servlet in your web.xml file

2.Create spring mvc controllers for each jsp page request.

3.Create service layer for businness logic and transaction management.

4.Create DAO layer for database operations like save,update,delete,getbyId,getAll entites.

5.Follow spring mvc reference doc for more configuration and application context.

6.Study how MVC works and you can use URLRewrite filter for url's security.

Apart from this for database persistant layer my suggestion is to use Hibernate Framework.


问:
Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I am currently using SQLite for Windows Forms but while running the project it is showing the error:

Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I had added the DLL of System.Data.SQLite.dll but it is showing the same error. Please can any one help me by giving the perfect answer regarding this problem? Thanks in advance

答:
I had exactly the same problem for the UWP project in a Xamarin.Forms application.
Adding reference to "SQLite for Universal Windows Platform" to the UWP project solved the problem.


问:
Which one to use: Java Swing or GTK+ for GNOME desktop application?
I am considering developing a GNOME desktop application with a graphical user interface. I know GTK+ is the first choice, especially when developing for the GNOME environment. End users also consider GTK+ as the first choice for applications they use. I am, however, considering future improvements: what if my application will need a port to another environments or OS like KDE or Mac or Windows? Which is the best way to go: Java Swing (because it's platform independent) or GTK+?</p>

答:
My users generally prefer Swing, but GTK applications are only slightly more difficult to maintain cross-platform.

GTK doesn't run natively on Mac OS X;

GTK and its dependencies can be built using MacPorts, and popular open source tools such as Gimp and Inkscape include the required libraries in the application bundle.

it requires to install an X server.

X11 for Mac is "fully integrated with Mac OS X."

Addendum: As @ptomato notes, the portfile offers both Quartz and X11 variants.

ContentLicense: CC BY-SA 2.5


问:
Filter an unfiltered table against a whitelist table
Introduction

Hi, I'm currently trying to build a filtering system based on MySQL, and I've encountered an issue right now with how to do about it. I've provided two tables in the sample table link below, there's a whitelist table, which contains the whitelisted item, and unsorted table, which is the list of items that will be checked against the whitelist.

PS: The whitelist is changing from time to time

The problem

If it were just to match if the three columns match exactly, it'd be a very easy job, however the problem is, if the columns in the white list is NULL, then that means it's a wildcard (This behavior can be changed, if someone can provide with better ways to do it), meaning any value in that column is accepted. All three columns must pass before the entry is accepted.

And that's where it gets me stuck =\

Example

Sample Table: http://rextester.com/HMYT21528 or below (same thing)

```<code>-- unsorted data

create table unsorted (
    ID int AUTO_INCREMENT,
    country char(10) null,
    region  char(10) null,
    item    char(10),
    PRIMARY KEY (ID)
);

insert into unsorted(country, region, item) VALUES

(null, null, "Apple"), (null, "East", "Apple"), (null, "West", "Apple"),
("US", null, "Apple"), ("US", "East", "Apple"), ("US", "West", "Apple"),
("CHINA", null, "Apple"), ("CHINA", "East", "Apple"), ("CHINA", "West", "Apple"),

(null, null, "Banana"), (null, "East", "Banana"), (null, "West", "Banana"),
("US", null, "Banana"), ("US", "East", "Banana"), ("US", "West", "Banana"),
("CHINA", null, "Banana"), ("CHINA", "East", "Banana"), ("CHINA", "West", "Banana"),

(null, null, "Cat"), (null, "East", "Cat"), (null, "West", "Cat"),
("US", null, "Cat"), ("US", "East", "Cat"), ("US", "West", "Cat"),
("CHINA", null, "Cat"), ("CHINA", "East", "Cat"), ("CHINA", "West", "Cat"),

(null, null, "Donkey"), (null, "East", "Donkey"), (null, "West", "Donkey"),
("US", null, "Donkey"), ("US", "East", "Donkey"), ("US", "West", "Donkey"),
("CHINA", null, "Donkey"), ("CHINA", "East", "Donkey"), ("CHINA", "West", "Donkey");

-- white list data

create table whitelist (
    country char(10) null,
    region  char(10) null,
    item    char(10) not null
);

insert into whitelist(country, region, item) VALUES

("US", "West", "Apple"),
(null, "East", "Banana"),
("CHINA", null, "Cat"),
(null, null, "Donkey");
</code>```

There's a column in the white list that looks like this: [ Country: Null, Region: East, Item: Banana ]

What it means is that for any entry in the unsorted list, as long as the item is Banana from East Region, we'll accept it.

Another example would be [ Country: null, Region: null, Item: Donkey ]

What it means is that we'll take any donkey from any country or region, because why not?

Expected Output

From the example above, my expected output from the list would be as follows

```<code>[ 6, US, West Apple ]

[ 11, Null, East, Banana ]
[ 14, US, East, Banana ]
[ 17, China, East, Banana ]

[ 25, China, Null, Cat ]
[ 26, China, East, Cat ]
[ 27, China, West, Cat ]

[ 28, Null, Null, Donkey ]
[ 29, Null, East, Donkey ]
[ 30, Null, West, Donkey ]
[ 31, US, Null, Donkey ]
[ 32, US, East, Donkey ]
[ 33, US, West, Donkey ]
[ 34, China, Null, Donkey ]
[ 35, China, East, Donkey ]
[ 36, China, West, Donkey ]
</code>```

Edit: to reply to comments

@Sloan Thrasher

```<code>SELECT a.*
FROM `unsorted` a
JOIN `whitelist` b
ON IF(b.`country` IS NULL,true,a.`country` = b.`country`) AND
    IF(b.`region` IS NULL,true,a.`region` = b.`region`) AND
    IF(b.`item` IS NULL,true,a.`item` = b.`item`);
</code>```

Since there's no 'id' column on the whitelist, so your where clause would cause an error, also the select should be selecting the unsorted for the result, if I were to select table b, I'd only see filters, instead of the filtered data that I'd like to see.

答:
Here's another way to write it:

```<code>SELECT a.*
FROM unsorted a JOIN whitelist b
 ON a.country <=> COALESCE(b.country, a.country)
AND a.region  <=> COALESCE(b.region, a.region)
AND a.item    <=> COALESCE(b.item, a.item)
</code>```

Similar logic to @SloanThrasher's answer, but it uses some different logical operators.

Body:
Introduction

Hi, I'm currently trying to build a filtering system based on MySQL, and I've encountered an issue right now with how to do about it. I've provided two tables in the sample table link below, there's a whitelist table, which contains the whitelisted item, and unsorted table, which is the list of items that will be checked against the whitelist.

PS: The whitelist is changing from time to time

The problem

If it were just to match if the three columns match exactly, it'd be a very easy job, however the problem is, if the columns in the white list is NULL, then that means it's a wildcard (This behavior can be changed, if someone can provide with better ways to do it), meaning any value in that column is accepted. All three columns must pass before the entry is accepted.

And that's where it gets me stuck =\

Example

Sample Table: http://rextester.com/HMYT21528 or below (same thing)

-- unsorted data

create table unsorted (
    ID int AUTO_INCREMENT,
    country char(10) null,
    region  char(10) null,
    item    char(10),
    PRIMARY KEY (ID)
);

insert into unsorted(country, region, item) VALUES

(null, null, "Apple"), (null, "East", "Apple"), (null, "West", "Apple"),
("US", null, "Apple"), ("US", "East", "Apple"), ("US", "West", "Apple"),
("CHINA", null, "Apple"), ("CHINA", "East", "Apple"), ("CHINA", "West", "Apple"),

(null, null, "Banana"), (null, "East", "Banana"), (null, "West", "Banana"),
("US", null, "Banana"), ("US", "East", "Banana"), ("US", "West", "Banana"),
("CHINA", null, "Banana"), ("CHINA", "East", "Banana"), ("CHINA", "West", "Banana"),

(null, null, "Cat"), (null, "East", "Cat"), (null, "West", "Cat"),
("US", null, "Cat"), ("US", "East", "Cat"), ("US", "West", "Cat"),
("CHINA", null, "Cat"), ("CHINA", "East", "Cat"), ("CHINA", "West", "Cat"),

(null, null, "Donkey"), (null, "East", "Donkey"), (null, "West", "Donkey"),
("US", null, "Donkey"), ("US", "East", "Donkey"), ("US", "West", "Donkey"),
("CHINA", null, "Donkey"), ("CHINA", "East", "Donkey"), ("CHINA", "West", "Donkey");

-- white list data

create table whitelist (
    country char(10) null,
    region  char(10) null,
    item    char(10) not null
);

insert into whitelist(country, region, item) VALUES

("US", "West", "Apple"),
(null, "East", "Banana"),
("CHINA", null, "Cat"),
(null, null, "Donkey");

There's a column in the white list that looks like this: [ Country: Null, Region: East, Item: Banana ]

What it means is that for any entry in the unsorted list, as long as the item is Banana from East Region, we'll accept it.

Another example would be [ Country: null, Region: null, Item: Donkey ]

What it means is that we'll take any donkey from any country or region, because why not?

Expected Output

From the example above, my expected output from the list would be as follows

[ 6, US, West Apple ]

[ 11, Null, East, Banana ]
[ 14, US, East, Banana ]
[ 17, China, East, Banana ]

[ 25, China, Null, Cat ]
[ 26, China, East, Cat ]
[ 27, China, West, Cat ]

[ 28, Null, Null, Donkey ]
[ 29, Null, East, Donkey ]
[ 30, Null, West, Donkey ]
[ 31, US, Null, Donkey ]
[ 32, US, East, Donkey ]
[ 33, US, West, Donkey ]
[ 34, China, Null, Donkey ]
[ 35, China, East, Donkey ]
[ 36, China, West, Donkey ]

Edit: to reply to comments

@Sloan Thrasher

SELECT a.*
FROM `unsorted` a
JOIN `whitelist` b
ON IF(b.`country` IS NULL,true,a.`country` = b.`country`) AND
    IF(b.`region` IS NULL,true,a.`region` = b.`region`) AND
    IF(b.`item` IS NULL,true,a.`item` = b.`item`);

Since there's no 'id' column on the whitelist, so your where clause would cause an error, also the select should be selecting the unsorted for the result, if I were to select table b, I'd only see filters, instead of the filtered data that I'd like to see.

Body:
Here's another way to write it:

SELECT a.*
FROM unsorted a JOIN whitelist b
 ON a.country <=> COALESCE(b.country, a.country)
AND a.region  <=> COALESCE(b.region, a.region)
AND a.item    <=> COALESCE(b.item, a.item)

Similar logic to @SloanThrasher's answer, but it uses some different logical operators.


问:
Is there any api in the wordpress to get the view count of posts. I mean without using any plugins
For eg : https://ww.abcd.com/news/wp-json/wp/v2/posts/007
will give all the details about the post with id 007 but not the view count of that post,similarly it doesn't also give the images that are included in that post.

Any ideas how to get those details without using any external plugins ?

答:
Yes you can do it this way:

1) - add this code to the functions.php of your wordpress theme

```<code>function getPostViews($postID){
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "0 View";
    }
    return $count.' Views';
}
function setPostViews($postID) {
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
// Remove issues with prefetching adding extra views
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
</code>```

2) - This part of the tracking views code will set the post views. Just place this snippet below within the single.php inside the wordpress loop

```<code>setPostViews(get_the_ID());
</code>```

3) - to display the view count:

```<code>echo getPostViews(get_the_ID());
</code>```

Body:
Yes you can do it this way:

1) - add this code to the functions.php of your wordpress theme

function getPostViews($postID){
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "0 View";
    }
    return $count.' Views';
}
function setPostViews($postID) {
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
// Remove issues with prefetching adding extra views
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

2) - This part of the tracking views code will set the post views. Just place this snippet below within the single.php inside the wordpress loop

setPostViews(get_the_ID());

3) - to display the view count:

echo getPostViews(get_the_ID());


问:
Is there a way to execute JavaScript in Perl?
I've worked some years now in Perl building Web scrapers, and given the problem that spam represents, and how scraping Web pages would turn out to be much more easier to those folks if, for example, Perl's LWP::UserAgent could handle its cup of JavaScript, I'm amazed no one has built a JS engine for it yet.

What am I missing here?

Thanks in advance. Regards.

PS: I'm not a spammer. Just curious.

答: There is also Win32::IE::Mechanize, Mozilla::Mechanize. But the previously mentioned WWW::Selenium is the most DWIW and well-supported if you have access to browsers and can run the Selenium server. Selenium is a Java critter that runs the browser interactions for you. It has IDEs for several browsers and can write code for you—by recording browser actions—in several languages including Perl or you can hand write it. It’s test-centric, where it excels, but there is no reason not to be use it for general automation/scraping.


问:
Errors when trying to call a method
I have been looking around online, and I am still unsure of how to call a method in my child class. I am trying to call the pay() method in Executive, and when I type in the following code into my if statement, I keep getting an error.

```<code>staff[3].awardBonus(bonus);
</code>```

I keep getting an error with this method. I'm not sure how to call that method... Thanks for any help!`import java.util.Scanner;

```<code>    import java.util.Scanner;
public class Tester
{
    public static void main (String args[])
    {
        Scanner scan = new Scanner(System.in);
        StaffMember[] staff = new StaffMember[4];
        String internName = "Susan 2";
        String empName = "Tyler O.";
        String hrName = "Becky R.";
        String execName = "Daniel H.";
        String address = "Brighton";
        String phone = "420 - 0000";
        String SSN = "12345789";
        double rate = 1000;

        staff [0] = new Intern(internName, address, phone);
        staff [1] = new Employee(empName, address, phone, SSN, rate);
        staff [2] = new HourlyEmployee(hrName, address, phone, SSN, rate);
        staff [3] = new Executive(execName, address, phone, SSN, rate);

        for (StaffMember staffPrint : staff)
        {
            System.out.println (staffPrint.toString() + "\n");
        }

        System.out.println("If you would like to give an executive a bonus, press 1. \nIf you would like to increase the hours of an hourly employee, press 2.");
        int input = scan.nextInt();
        if(input == 1)
        {
            double bonus = 0;
            System.out.println("Enter the bonus for your employee: ");
            bonus = scan.nextDouble();

        }
 }
</code>```

Here is the Executive class, Employee class and the StaffMember class

```<code>public class Executive extends Employee
{
    public Executive(String name, String address, String phone, String SSN, double rate)
    {
        super(name, address, phone, SSN, rate);
    }

    public double pay()
    {
        double money = super.pay();
        return money;
    }

    public String toString()
    {
        String employee = super.toString();
        return employee;
    }

    public void awardBonus(double execBonus)
    {
        rate += execBonus;
    }
}
</code>```

Employee

```<code>    public class Employee extends StaffMember
{
    String SSN;
    double rate;

    public Employee(String name, String address, String phone, String SSN, double rate)
    {
        super(name, address, phone);
        this.SSN = SSN;
        this.rate = rate;
    }

    public double pay()
    {
        return rate;
    }

    public String toString()
    {
        String employee = "";
        employee = ("Name: " + name + "\nAddress: " + address + "\nPhone Number: " + phone + "\nSocial Security Number: " + SSN + "\nPay: " + pay());
        return employee;
    }
}
</code>```

StaffMember

```<code>public abstract class StaffMember
{
    String name;
    String address;
    String phone;

    public StaffMember(String name, String address, String phone)
    {
        this.name = name;
        this.address = address;
        this.phone = phone;
    }

    public String toString()
    {
        String employee = "";
        employee = ("Name: " + name + "\nAddress: " + address + "\nPhone Number: " + phone);
        return employee;
    }

    public abstract double pay();
}
</code>```

答:
You can use:

```<code>// Check if staff[3] is really an Executive
if(staff[3] instanceof Executive) {
    // Cast staff[3] to an Executive
    Executive executive = ((Executive)staff[3]);
    // Now you can call awardBonus
    executive.awardBonus(bonus);
}
</code>```

Because staff is an StaffMember-array which doesn't contains the methode awardBonus.

You know that staff[3] is an Executive, but your program doesn't. Therefore you have to check if staff[3] is an instanceof Executive so you can safely cast it to an Executive with Executive executive = (Executive)staff[3].

Title: Errors when trying to call a method

Body:
I have been looking around online, and I am still unsure of how to call a method in my child class. I am trying to call the pay() method in Executive, and when I type in the following code into my if statement, I keep getting an error.

staff[3].awardBonus(bonus);

I keep getting an error with this method. I'm not sure how to call that method... Thanks for any help!`import java.util.Scanner;

    import java.util.Scanner;
public class Tester
{
    public static void main (String args[])
    {
        Scanner scan = new Scanner(System.in);
        StaffMember[] staff = new StaffMember[4];
        String internName = "Susan 2";
        String empName = "Tyler O.";
        String hrName = "Becky R.";
        String execName = "Daniel H.";
        String address = "Brighton";
        String phone = "420 - 0000";
        String SSN = "12345789";
        double rate = 1000;

        staff [0] = new Intern(internName, address, phone);
        staff [1] = new Employee(empName, address, phone, SSN, rate);
        staff [2] = new HourlyEmployee(hrName, address, phone, SSN, rate);
        staff [3] = new Executive(execName, address, phone, SSN, rate);

        for (StaffMember staffPrint : staff)
        {
            System.out.println (staffPrint.toString() + "\n");
        }

        System.out.println("If you would like to give an executive a bonus, press 1. \nIf you would like to increase the hours of an hourly employee, press 2.");
        int input = scan.nextInt();
        if(input == 1)
        {
            double bonus = 0;
            System.out.println("Enter the bonus for your employee: ");
            bonus = scan.nextDouble();

        }
 }

Here is the Executive class, Employee class and the StaffMember class

public class Executive extends Employee
{
    public Executive(String name, String address, String phone, String SSN, double rate)
    {
        super(name, address, phone, SSN, rate);
    }

    public double pay()
    {
        double money = super.pay();
        return money;
    }

    public String toString()
    {
        String employee = super.toString();
        return employee;
    }

    public void awardBonus(double execBonus)
    {
        rate += execBonus;
    }
}

Employee

    public class Employee extends StaffMember
{
    String SSN;
    double rate;

    public Employee(String name, String address, String phone, String SSN, double rate)
    {
        super(name, address, phone);
        this.SSN = SSN;
        this.rate = rate;
    }

    public double pay()
    {
        return rate;
    }

    public String toString()
    {
        String employee = "";
        employee = ("Name: " + name + "\nAddress: " + address + "\nPhone Number: " + phone + "\nSocial Security Number: " + SSN + "\nPay: " + pay());
        return employee;
    }
}

StaffMember

public abstract class StaffMember
{
    String name;
    String address;
    String phone;

    public StaffMember(String name, String address, String phone)
    {
        this.name = name;
        this.address = address;
        this.phone = phone;
    }

    public String toString()
    {
        String employee = "";
        employee = ("Name: " + name + "\nAddress: " + address + "\nPhone Number: " + phone);
        return employee;
    }

    public abstract double pay();
}

Body:
You can use:

// Check if staff[3] is really an Executive
if(staff[3] instanceof Executive) {
    // Cast staff[3] to an Executive
    Executive executive = ((Executive)staff[3]);
    // Now you can call awardBonus
    executive.awardBonus(bonus);
}

Because staff is an StaffMember-array which doesn't contains the methode awardBonus.

You know that staff[3] is an Executive, but your program doesn't. Therefore you have to check if staff[3] is an instanceof Executive so you can safely cast it to an Executive with Executive executive = (Executive)staff[3].


问:
mysql how to rollback deleted table after 20 minute with or without transaction?
i want to rollback deleted table after 20 minutes.

can i do it with or without transaction.?

答:
You always have a transaction. As long as it's not committed you can perform a rollback.
But it sounds like you want to roll back to a specific point. If so, you can define a savepoint:

```<code>SAVEPOINT mySavePoint;

-- Do something

ROLLBACK TO mySavePoint;
</code>```

savepoint commit rollback in mysql

Body:
You always have a transaction. As long as it's not committed you can perform a rollback.
But it sounds like you want to roll back to a specific point. If so, you can define a savepoint:

SAVEPOINT mySavePoint;

-- Do something

ROLLBACK TO mySavePoint;

savepoint commit rollback in mysql


问:
C# built-in events
After reading the following piece of code :

```<code>[SerializableAttribute]
public delegate void EventHandler<TEventArgs>
(
   object sender,
   TEventArgs e
)
</code>```

Why did not Microsoft guys give Object type for the "e" parameter just like the sender parameter? am I missing something major here?

答:
You can make your own event args class that has some useful properties on it. Like the mouse click event args (can't remember the proper name) has an X and Y prop to tell you what point was clicked. Thanks to generics you don't need the casting you would with just a plain old object. You'd just have

```<code>MyEventHandler<MouseClickedEventArgs>(object sender, MouseClickedEventArgs e).
</code>```

And everything is strongly typed

Title: C# built-in events

Body:
After reading the following piece of code :

[SerializableAttribute]
public delegate void EventHandler<TEventArgs>
(
   object sender,
   TEventArgs e
)

Why did not Microsoft guys give Object type for the "e" parameter just like the sender parameter? am I missing something major here?

Body:
You can make your own event args class that has some useful properties on it. Like the mouse click event args (can't remember the proper name) has an X and Y prop to tell you what point was clicked. Thanks to generics you don't need the casting you would with just a plain old object. You'd just have

MyEventHandler<MouseClickedEventArgs>(object sender, MouseClickedEventArgs e).

And everything is strongly typed


问:
tcpdf in codeigniter not working
I use tcpdf to generate data into pdf but I got no result and no error.

JS

```<code>obj.fnExportpdf = () => {
    return app.callModel('romans/pdfTest'
    // onerror
    , function (jqXHR, status, errorMessage){
            alert ('ERROR: '+errorMessage);
            return false;
    }
    // onsuccess
    , function (response, status, jqXHR){
            return ;
    }
    // hide progressbar
    , false
    );
}
</code>```

Model

```<code> function pdfTest(){
    $this->load->library("Pdf");
    $pdf = new Pdf('P', 'mm', 'A4', true, 'UTF-8', false);
    $pdf->SetCreator(PDF_CREATOR);
    // Add a page
    $pdf->AddPage();
    $html = "<h1>Test Page</h1>";
    $pdf->writeHTML($html, true, false, true, false, '');
    ob_clean();
    return $pdf->Output('samplepdf.pdf','I');

}
</code>```

but when I click pdftest it shows the result. click image

答:
Download TCPD from here

Create a new file: /application/libraries/Pdf.php:

```<code><?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once dirname(__FILE__) . '/tcpdf/tcpdf.php';

class Pdf extends TCPDF
{
    function __construct()
    {
        parent::__construct();
    }
}

/* End of file Pdf.php */
/* Location: ./application/libraries/Pdf.php */
</code>```

To create a new PDF you would do something like this in your controller:

```<code>$this->load->library('Pdf');

$pdf = new Pdf('P', 'mm', 'A4', true, 'UTF-8', false);
$pdf->SetTitle('My Title');
$pdf->SetHeaderMargin(30);
$pdf->SetTopMargin(20);
$pdf->setFooterMargin(20);
$pdf->SetAutoPageBreak(true);
$pdf->SetAuthor('Author');
$pdf->SetDisplayMode('real', 'default');

$pdf->AddPage();

$pdf->Write(5, 'Some sample text');
$pdf->Output('My-File-Name.pdf', 'I');
</code>```

Title: tcpdf in codeigniter not working

Body:
I use tcpdf to generate data into pdf but I got no result and no error.

JS

obj.fnExportpdf = () => {
    return app.callModel('romans/pdfTest'
    // onerror
    , function (jqXHR, status, errorMessage){
            alert ('ERROR: '+errorMessage);
            return false;
    }
    // onsuccess
    , function (response, status, jqXHR){
            return ;
    }
    // hide progressbar
    , false
    );
}

Model

 function pdfTest(){
    $this->load->library("Pdf");
    $pdf = new Pdf('P', 'mm', 'A4', true, 'UTF-8', false);
    $pdf->SetCreator(PDF_CREATOR);
    // Add a page
    $pdf->AddPage();
    $html = "
Test Page
";
    $pdf->writeHTML($html, true, false, true, false, '');
    ob_clean();
    return $pdf->Output('samplepdf.pdf','I');

}

but when I click pdftest it shows the result. click image

Body:
Download TCPD from here

Create a new file: /application/libraries/Pdf.php:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once dirname(__FILE__) . '/tcpdf/tcpdf.php';

class Pdf extends TCPDF
{
    function __construct()
    {
        parent::__construct();
    }
}

/* End of file Pdf.php */
/* Location: ./application/libraries/Pdf.php */

To create a new PDF you would do something like this in your controller:

$this->load->library('Pdf');

$pdf = new Pdf('P', 'mm', 'A4', true, 'UTF-8', false);
$pdf->SetTitle('My Title');
$pdf->SetHeaderMargin(30);
$pdf->SetTopMargin(20);
$pdf->setFooterMargin(20);
$pdf->SetAutoPageBreak(true);
$pdf->SetAuthor('Author');
$pdf->SetDisplayMode('real', 'default');

$pdf->AddPage();

$pdf->Write(5, 'Some sample text');
$pdf->Output('My-File-Name.pdf', 'I');


问:
Why in some cases when the player is moving to the left he is leaving in 1.5 distance the grid area?
```<code>using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using System.IO;

public class DirsFinder : MonoBehaviour
{
    public Transform player;
    public float playerMoveSpeed = 1f;
    public float playerRotationSpeed = 0.5f;
    public float distanceToTravel = 1.5f;
    public bool randomDir = true;

    private Transform start;
    private Transform end;
    private GridGenerator gridgenerator;
    private List<Vector3> possibleDirections = new List<Vector3>();
    private Vector3 selectedDirection;
    private float m_distanceTraveled = 0f;
    private List<Vector3> visitedList = new List<Vector3>();
    private List<Vector3> toBeVisitedList = new List<Vector3>();
    private Vector3 playerPosition;

    public void FindDir()
    {
        gridgenerator = GetComponent<GridGenerator>();
        GenerateStartEnd();
        FindDirections();
        m_distanceTraveled = 0;
    }

    private void FindDirections()
    {
        possibleDirections = new List<Vector3>();
        playerPosition = player.localPosition;
        m_distanceTraveled = 0;

        if (playerPosition.x > 0)
        {
            // can go left
            possibleDirections.Add(Vector3.left);
        }

        if (playerPosition.x + gridgenerator.spaceBetweenBlocks < gridgenerator.gridWidth * gridgenerator.spaceBetweenBlocks)
        {
            // can go right
            possibleDirections.Add(Vector3.right);
        }

        if (playerPosition.z > 0)
        {
            // can go backward
            possibleDirections.Add(Vector3.back);
        }

        if (playerPosition.z + gridgenerator.spaceBetweenBlocks < gridgenerator.gridHeight * gridgenerator.spaceBetweenBlocks)
        {
            // can go forward
            possibleDirections.Add(Vector3.forward);
        }

        if (randomDir == true)
        {
            selectedDirection = possibleDirections[Random.Range(0, possibleDirections.Count)];
        }
        player.forward = selectedDirection;
    }

    private void Update()
    {
        if (m_distanceTraveled < distanceToTravel)
        {
            Vector3 oldPosition = player.position;
            player.position += selectedDirection * Time.deltaTime * playerMoveSpeed;
            m_distanceTraveled += Vector3.Distance(oldPosition, player.position);
        }

        if (m_distanceTraveled >= distanceToTravel)
        {
            FindDirections();
        }
    }

    private List<Vector3> GenerateStartEnd()
    {
        GameObject walls = GameObject.Find("Walls");
        List<Transform> wallsParents = new List<Transform>();
        List<Vector3> startEndPos = new List<Vector3>();

        foreach (Transform child in walls.transform)
        {
            wallsParents.Add(child);
        }

        for (int i = 0; i < 2; i++)
        {
            wallsParents.Remove(wallsParents[Random.Range(0, wallsParents.Count)]);
        }

        var childsWall0 = wallsParents[0].GetComponentsInChildren<Transform>().ToList();
        var childsWall1 = wallsParents[1].GetComponentsInChildren<Transform>().ToList();
        childsWall0.RemoveAt(0);
        childsWall1.RemoveAt(0);

        start = childsWall0[Random.Range(0, childsWall0.Count)];
        player.position = start.position;
        end = childsWall1[Random.Range(0, childsWall1.Count)];
        end.tag = "End";
        startEndPos.Add(start.position);
        startEndPos.Add(end.position);

        start.GetComponent<Renderer>().material.color = Color.red;
        end.GetComponent<Renderer>().material.color = Color.blue;

        return startEndPos;
    }
}
</code>```

In the method FindDirections i assign the player to be facing to the selected random direction:

```<code>player.forward = selectedDirection;
</code>```

Then in the Update i'm moving the player to specific distance each time 1.5f And checking when the player traveled 1.5 distance call FindDirections again and over again. I checked with a break point it keep getting back to the FindDirections and getting a new random direction.

But in some cases when the player is walking to the left since it's random i saw it on the left side only so far didn't see it yet on the right side of the grid.

But when he is getting to the left in some cases he is keep moving by 1.5 out of the grid left wall out of the grid.

In the screenshot two cases where the player left the grid area on the left then he walk on this area and then back to the grid area.

It started when i started to move the player with the limit distance of 1.5 and the travel distance.

Not sure why it happen.

答:
Your problem might be caused by floating-point precision.
This piece of code

```<code> if (playerPosition.x > 0)
</code>```

…evaluates true if playerPosition.x is a small value such as 0.000001.
You could avoid this by using small margin in comparison.

```<code> const float margin = 0.001f;
 ...
 if (playerPosition.x - margin > 0f) // (pos.x - bounds.leftx) < margin
</code>```

Better approach would be to use integers as grip positions.

Another thing is that you update player.position in Update() but use player.localPosition in FindDirections(). I’m not sure if this is intended.
(However, if the player transform has no parent, localPosition is same as position.)

EDIT: You could also force the player position to nearest multiple of 1.5f before setting a new direction:

```<code>if (m_distanceTraveled >= distanceToTravel)
{
// round x and z to nearest multiple of distanceToTravel
var tmpPos = player.position;
tmpPos.x = Mathf.Round(player.position.x / distanceToTravel) * distanceToTravel;
tmpPos.z = Mathf.Round(player.position.z / distanceToTravel) * distanceToTravel;
player.position = tmpPos;
FindDirections();
}
</code>```

Body:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using System.IO;

public class DirsFinder : MonoBehaviour
{
    public Transform player;
    public float playerMoveSpeed = 1f;
    public float playerRotationSpeed = 0.5f;
    public float distanceToTravel = 1.5f;
    public bool randomDir = true;

    private Transform start;
    private Transform end;
    private GridGenerator gridgenerator;
    private List<Vector3> possibleDirections = new List<Vector3>();
    private Vector3 selectedDirection;
    private float m_distanceTraveled = 0f;
    private List<Vector3> visitedList = new List<Vector3>();
    private List<Vector3> toBeVisitedList = new List<Vector3>();
    private Vector3 playerPosition;

    public void FindDir()
    {
        gridgenerator = GetComponent<GridGenerator>();
        GenerateStartEnd();
        FindDirections();
        m_distanceTraveled = 0;
    }

    private void FindDirections()
    {
        possibleDirections = new List<Vector3>();
        playerPosition = player.localPosition;
        m_distanceTraveled = 0;

        if (playerPosition.x > 0)
        {
            // can go left
            possibleDirections.Add(Vector3.left);
        }

        if (playerPosition.x + gridgenerator.spaceBetweenBlocks < gridgenerator.gridWidth * gridgenerator.spaceBetweenBlocks)
        {
            // can go right
            possibleDirections.Add(Vector3.right);
        }

        if (playerPosition.z > 0)
        {
            // can go backward
            possibleDirections.Add(Vector3.back);
        }

        if (playerPosition.z + gridgenerator.spaceBetweenBlocks < gridgenerator.gridHeight * gridgenerator.spaceBetweenBlocks)
        {
            // can go forward
            possibleDirections.Add(Vector3.forward);
        }

        if (randomDir == true)
        {
            selectedDirection = possibleDirections[Random.Range(0, possibleDirections.Count)];
        }
        player.forward = selectedDirection;
    }

    private void Update()
    {
        if (m_distanceTraveled < distanceToTravel)
        {
            Vector3 oldPosition = player.position;
            player.position += selectedDirection * Time.deltaTime * playerMoveSpeed;
            m_distanceTraveled += Vector3.Distance(oldPosition, player.position);
        }

        if (m_distanceTraveled >= distanceToTravel)
        {
            FindDirections();
        }
    }

    private List<Vector3> GenerateStartEnd()
    {
        GameObject walls = GameObject.Find("Walls");
        List<Transform> wallsParents = new List<Transform>();
        List<Vector3> startEndPos = new List<Vector3>();

        foreach (Transform child in walls.transform)
        {
            wallsParents.Add(child);
        }

        for (int i = 0; i < 2; i++)
        {
            wallsParents.Remove(wallsParents[Random.Range(0, wallsParents.Count)]);
        }

        var childsWall0 = wallsParents[0].GetComponentsInChildren<Transform>().ToList();
        var childsWall1 = wallsParents[1].GetComponentsInChildren<Transform>().ToList();
        childsWall0.RemoveAt(0);
        childsWall1.RemoveAt(0);

        start = childsWall0[Random.Range(0, childsWall0.Count)];
        player.position = start.position;
        end = childsWall1[Random.Range(0, childsWall1.Count)];
        end.tag = "End";
        startEndPos.Add(start.position);
        startEndPos.Add(end.position);

        start.GetComponent<Renderer>().material.color = Color.red;
        end.GetComponent<Renderer>().material.color = Color.blue;

        return startEndPos;
    }
}

In the method FindDirections i assign the player to be facing to the selected random direction:

player.forward = selectedDirection;

Then in the Update i'm moving the player to specific distance each time 1.5f And checking when the player traveled 1.5 distance call FindDirections again and over again. I checked with a break point it keep getting back to the FindDirections and getting a new random direction.

But in some cases when the player is walking to the left since it's random i saw it on the left side only so far didn't see it yet on the right side of the grid.

But when he is getting to the left in some cases he is keep moving by 1.5 out of the grid left wall out of the grid.

In the screenshot two cases where the player left the grid area on the left then he walk on this area and then back to the grid area.

It started when i started to move the player with the limit distance of 1.5 and the travel distance.

Not sure why it happen.

Body:
Your problem might be caused by floating-point precision.
This piece of code

 if (playerPosition.x > 0)

…evaluates true if playerPosition.x is a small value such as 0.000001.
You could avoid this by using small margin in comparison.

 const float margin = 0.001f;
 ...
 if (playerPosition.x - margin > 0f) // (pos.x - bounds.leftx) < margin

Better approach would be to use integers as grip positions.

Another thing is that you update player.position in Update() but use player.localPosition in FindDirections(). I’m not sure if this is intended.
(However, if the player transform has no parent, localPosition is same as position.)

EDIT: You could also force the player position to nearest multiple of 1.5f before setting a new direction:

if (m_distanceTraveled >= distanceToTravel)
{
// round x and z to nearest multiple of distanceToTravel
var tmpPos = player.position;
tmpPos.x = Mathf.Round(player.position.x / distanceToTravel) * distanceToTravel;
tmpPos.z = Mathf.Round(player.position.z / distanceToTravel) * distanceToTravel;
player.position = tmpPos;
FindDirections();
}


问:
Issue with returning object from a function in asp.net MVC
i am little confused about my code:

Here is some function from my controller:

```<code>  public void signIn(string userName, string userPass)
        {
            User user = new User();
            user.getUser(userName , userPass);

            if (user.userName != null)
            {
                Response.Redirect("/Home/Menu");
            }
            else
            {
                Response.Redirect("/Index/Index?Fail=" + "fail");
            }
        }
</code>```

the " user.getUser" suppose to return a User object.. here is the code from my Model directory:

```<code>public class User
{
    public ObjectId _id { get; set; }
    public string userName { get; set; }
    public string userPass { get; set; }

    public User getUser(string name , string pass)
    {
        var client = new MongoClient("mongodb://localhost:27017");
        var db = client.GetDatabase("testdb");
        var coll = db.GetCollection<User>("user");

        List<User> list = coll.Find(x => x.userName == name && x.userPass == pass).ToList<User>();

        User uObj = new User();
        uObj = list.FirstOrDefault();

        return uObj;
    }
}
</code>```

when i am debugging the code i can see the uJob object contain values. but when the function end and i return to the controller i see that the user object contain only null values, and the condition - "   if (user.userName != null)" is returning FALSE!.. instead of TRUE..

i would like to get some help. Thanks !

答:
if you replace

```<code>if (user.userName != null)
</code>```

with

```<code>if ( user.getUser(userName , userPass).userName != null)
</code>```

wil works for you.

Body:
i am little confused about my code:

Here is some function from my controller:

  public void signIn(string userName, string userPass)
        {
            User user = new User();
            user.getUser(userName , userPass);

            if (user.userName != null)
            {
                Response.Redirect("/Home/Menu");
            }
            else
            {
                Response.Redirect("/Index/Index?Fail=" + "fail");
            }
        }

the " user.getUser" suppose to return a User object.. here is the code from my Model directory:

public class User
{
    public ObjectId _id { get; set; }
    public string userName { get; set; }
    public string userPass { get; set; }

    public User getUser(string name , string pass)
    {
        var client = new MongoClient("mongodb://localhost:27017");
        var db = client.GetDatabase("testdb");
        var coll = db.GetCollection<User>("user");

        List<User> list = coll.Find(x => x.userName == name && x.userPass == pass).ToList<User>();

        User uObj = new User();
        uObj = list.FirstOrDefault();

        return uObj;
    }
}

when i am debugging the code i can see the uJob object contain values. but when the function end and i return to the controller i see that the user object contain only null values, and the condition - "   if (user.userName != null)" is returning FALSE!.. instead of TRUE..

i would like to get some help. Thanks !

Body:
if you replace

if (user.userName != null)

with

if ( user.getUser(userName , userPass).userName != null)

wil works for you.


问:
What can't be done in CSS yet?
A while ago I was trying to figure out a way of doing this without using a table layout:

```<code><table>
  <tr><td rowspan="2">Left column</td></tr>
  <tr><td>Right Top</td><td>Right bottom</td></tr>
</table>
</code>```

Eventually I gave up and decided that it's impossible to do without tables (okay, CSS 3 might be able to, but waiting another 5-10 years isn't practical).

Has anyone got more examples like this? (Or even better, can you show me I was wrong?)

答:
Another solution using the position property:

```<code><style type="text/css">
    .outer {
        position: relative;
        background-color: #EEE;
    }
    .left-column {
        position: absolute;
        top: 0;
        left: 0;
        width: 50%;
        height: 100%;
        background-color: #F88;
    }
    .right-top {
        margin-left: 50%;
        background-color: #8F8;
    }
    .right-bottom {
        margin-left: 50%;
        background-color: #88F;
    }
</style>

<div class="outer">
    <div class="left-column">Left column</div>
    <div class="right-top">Right top</div>
    <div class="right-bottom">Right bottom</div>
</div>
</code>```

Title: What can't be done in CSS yet?

Body:
A while ago I was trying to figure out a way of doing this without using a table layout:

Left column

Right Top	Right bottom

Eventually I gave up and decided that it's impossible to do without tables (okay, CSS 3 might be able to, but waiting another 5-10 years isn't practical).

Has anyone got more examples like this? (Or even better, can you show me I was wrong?)

Body:
Another solution using the position property:

<style type="text/css">
    .outer {
        position: relative;
        background-color: #EEE;
    }
    .left-column {
        position: absolute;
        top: 0;
        left: 0;
        width: 50%;
        height: 100%;
        background-color: #F88;
    }
    .right-top {
        margin-left: 50%;
        background-color: #8F8;
    }
    .right-bottom {
        margin-left: 50%;
        background-color: #88F;
    }
</style>

<div class="outer">
    <div class="left-column">Left column</div>
    <div class="right-top">Right top</div>
    <div class="right-bottom">Right bottom</div>
</div>

OwnerDisplayName: Gumbo


问:
Pinned view not saved in Dynamics CRM mobile client
Dynamics 365 online - We are facing one problem with the  Dynamics CRM mobile client. When a user pinned a view of an entity, it appears as required on that particular mobile device as and when user logins into the same device. But, when the user logs in again with the same credentials in a different device or opens the Dynamics CRM in Tablet mode in the browser, the pinned view gets removed from the "Home". It seems like Microsoft is managing it at the device level. We would like to manage it at the user level, like user's personal settings and that should be applicable wherever the same user logins anywhere on any devices. Please advise.

答:
User has to reconfigure the app to see the changes in effect.

Reconfiguring deletes all data and metadata from the cache, though you
  shouldn't rely on this as a security measure.

If you sign out of one organization and sign in to another, and then
  use the Reconfigure option on the organization you signed in to, your
  metadata will still remain for the organization you signed out of. To
  remove your metadata from the organization you signed out of, you’ll
  need to sign in to it and use the Reconfigure option there, as well.

Here's how to do it:

  Tap Dynamics 365 ellipsis (3 dots).

  Tap User
  Information.

  Tap Reconfigure.


问:
Implementation of a neural model on Tensor-flow
I am trying to implement a neural network model on Tensor flow but seems to be having problems with the shape of the placeholders. I'm new to TF, hence it could just be a simple misunderstanding. Here's my code and data sample:

```<code>_data=[[0.4,0.5,0.6,1],[0.7,0.8,0.9,0],....]
</code>```

The data comprises of arrays of 4 columns, the last column of each array is the label. I want to classify each array as label 0, label 1 or label 2.

```<code>import tensorflow as tf
import numpy as np

_data = datamatrix
X = tf.placeholder(tf.float32, [None, 3])
W = tf.Variable(tf.zeros([3, 1]))
b = tf.Variable(tf.zeros([3]))

init = tf.global_variables_initializer()
Y = tf.nn.softmax(tf.matmul(X, W) + b)

# placeholder for correct labels
Y_ = tf.placeholder(tf.float32, [None, 1])

# loss function
import time
start=time.time()

cross_entropy = -tf.reduce_sum(Y_ * tf.log(Y))

# % of correct answers found in batch
is_correct = tf.equal(tf.argmax(Y,1), tf.argmax(Y_,1))
accuracy = tf.reduce_mean(tf.cast(is_correct, tf.float32))

optimizer = tf.train.GradientDescentOptimizer(0.003)
train_step = optimizer.minimize(cross_entropy)

sess = tf.Session()
sess.run(init)
for i in range(1000):
    # load batch of images and correct answers
    batch_X, batch_Y = [x[:3] for x in _data[:2000]],[x[-1] for x in _data[:2000]]
    train_data={X: batch_X, Y_: batch_Y}

    # train
    sess.run(train_step, feed_dict=train_data)

# success ?
a,c = sess.run([accuracy, cross_entropy], feed_dict=train_data)
</code>```

I got the following error message after running my code:

```<code>ValueError: Cannot feed value of shape (2000,) for Tensor 'Placeholder_1:0', which has shape '(?, 1)'
</code>```

My desired output should be the performance of the model using cross-entropy; the accuracy value from the codeline below:

```<code>a,c = sess.run([accuracy, cross_entropy], feed_dict=train_data)
</code>```

I would also appreciate any suggestions on how to improve the model, or a model that is more suitable for my data.

答:
The shape of Placeholder_1:0 Y_, and input data batch_Y is mismatched as specified by the error message. Notice the 1-D vs 2-D array.

So you should either define 1-D place holder:

```<code>Y_ = tf.placeholder(tf.float32, [None])
</code>```

or prepare 2-D data:

```<code>    batch_X, batch_Y = [x[:3] for x in _data[:2000]],[x[-1:] for x in _data[:2000]]
</code>```

Body:
I am trying to implement a neural network model on Tensor flow but seems to be having problems with the shape of the placeholders. I'm new to TF, hence it could just be a simple misunderstanding. Here's my code and data sample:

_data=[[0.4,0.5,0.6,1],[0.7,0.8,0.9,0],....]

The data comprises of arrays of 4 columns, the last column of each array is the label. I want to classify each array as label 0, label 1 or label 2.

import tensorflow as tf
import numpy as np

_data = datamatrix
X = tf.placeholder(tf.float32, [None, 3])
W = tf.Variable(tf.zeros([3, 1]))
b = tf.Variable(tf.zeros([3]))

init = tf.global_variables_initializer()
Y = tf.nn.softmax(tf.matmul(X, W) + b)

# placeholder for correct labels
Y_ = tf.placeholder(tf.float32, [None, 1])

# loss function
import time
start=time.time()

cross_entropy = -tf.reduce_sum(Y_ * tf.log(Y))

# % of correct answers found in batch
is_correct = tf.equal(tf.argmax(Y,1), tf.argmax(Y_,1))
accuracy = tf.reduce_mean(tf.cast(is_correct, tf.float32))

optimizer = tf.train.GradientDescentOptimizer(0.003)
train_step = optimizer.minimize(cross_entropy)

sess = tf.Session()
sess.run(init)
for i in range(1000):
    # load batch of images and correct answers
    batch_X, batch_Y = [x[:3] for x in _data[:2000]],[x[-1] for x in _data[:2000]]
    train_data={X: batch_X, Y_: batch_Y}

    # train
    sess.run(train_step, feed_dict=train_data)

# success ?
a,c = sess.run([accuracy, cross_entropy], feed_dict=train_data)

I got the following error message after running my code:

ValueError: Cannot feed value of shape (2000,) for Tensor 'Placeholder_1:0', which has shape '(?, 1)'

My desired output should be the performance of the model using cross-entropy; the accuracy value from the codeline below:

a,c = sess.run([accuracy, cross_entropy], feed_dict=train_data)

I would also appreciate any suggestions on how to improve the model, or a model that is more suitable for my data.

Body:
The shape of Placeholder_1:0 Y_, and input data batch_Y is mismatched as specified by the error message. Notice the 1-D vs 2-D array.

So you should either define 1-D place holder:

Y_ = tf.placeholder(tf.float32, [None])

or prepare 2-D data:

    batch_X, batch_Y = [x[:3] for x in _data[:2000]],[x[-1:] for x in _data[:2000]]


问:
SQL choose column to update inside CASE condition
I have ArticlePhotos table and each Article can have N photos. I am writing a trigger which will reflect changes made in ArticlePhotos table to create a flat hierarhy inside Articles table for faster querying to avoid joins when listing several articles.

Is there a way to select column to update in some sort of CASE clause instead writing update clause for each desired type

```<code>DECLARE @FrontPagePhotoTypeId INT = 1;
DECLARE @MainArticlePhotoTypeId INT = 2;
DECLARE @FacebookPhotoType INT = 4;

-- all deleted photo records should be set as null in Articles table (flat hierarchy)

-- delete frontpage photo
UPDATE Articles
SET Articles.FrontPagePhoto = NULL <-- can this be written as a case by PhotoTypeId
FROM Articles
INNER JOIN deleted
ON Articles.id = deleted.ArticleId WHERE deleted.PhotoTypeId = @FrontPagePhotoTypeId

-- delete Main Article Photo
UPDATE Articles
SET Articles.MainArticlePhoto = NULL
FROM Articles
INNER JOIN deleted
ON Articles.id = deleted.ArticleId WHERE deleted.PhotoTypeId = @MainArticlePhotoTypeId

-- delete facebook
UPDATE Articles
SET Articles.FacebookPhoto = NULL
FROM Articles
INNER JOIN deleted
ON Articles.id = deleted.ArticleId WHERE deleted.PhotoTypeId = @FacebookPhotoType
</code>```

答:
The above query can be re-written as a single update as below</p>

```<code>DECLARE @FrontPagePhotoTypeId INT = 1;
DECLARE @MainArticlePhotoTypeId INT = 2;
DECLARE @FacebookPhotoType INT = 4;

UPDATE Articles
SET
    FrontPagePhoto = case when deleted.PhotoTypeId = @FrontPagePhotoTypeId
                                        then null
                                    else Articles.FrontPagePhoto end,
    MainArticlePhoto = case when deleted.PhotoTypeId = @MainArticlePhotoTypeId
                                        then null
                                    else Articles.MainArticlePhoto end,
    FacebookPhoto = case when deleted.PhotoTypeId = @FacebookPhotoType
                                        then null
                                    else Articles.FacebookPhoto end
FROM Articles
INNER JOIN deleted
ON Articles.id = deleted.ArticleId
</code>```

Body:
I have ArticlePhotos table and each Article can have N photos. I am writing a trigger which will reflect changes made in ArticlePhotos table to create a flat hierarhy inside Articles table for faster querying to avoid joins when listing several articles.

Is there a way to select column to update in some sort of CASE clause instead writing update clause for each desired type

DECLARE @FrontPagePhotoTypeId INT = 1;
DECLARE @MainArticlePhotoTypeId INT = 2;
DECLARE @FacebookPhotoType INT = 4;

-- all deleted photo records should be set as null in Articles table (flat hierarchy)

-- delete frontpage photo
UPDATE Articles
SET Articles.FrontPagePhoto = NULL <-- can this be written as a case by PhotoTypeId
FROM Articles
INNER JOIN deleted
ON Articles.id = deleted.ArticleId WHERE deleted.PhotoTypeId = @FrontPagePhotoTypeId

-- delete Main Article Photo
UPDATE Articles
SET Articles.MainArticlePhoto = NULL
FROM Articles
INNER JOIN deleted
ON Articles.id = deleted.ArticleId WHERE deleted.PhotoTypeId = @MainArticlePhotoTypeId

-- delete facebook
UPDATE Articles
SET Articles.FacebookPhoto = NULL
FROM Articles
INNER JOIN deleted
ON Articles.id = deleted.ArticleId WHERE deleted.PhotoTypeId = @FacebookPhotoType

Body:
The above query can be re-written as a single update as below

DECLARE @FrontPagePhotoTypeId INT = 1;
DECLARE @MainArticlePhotoTypeId INT = 2;
DECLARE @FacebookPhotoType INT = 4;

UPDATE Articles
SET
    FrontPagePhoto = case when deleted.PhotoTypeId = @FrontPagePhotoTypeId
                                        then null
                                    else Articles.FrontPagePhoto end,
    MainArticlePhoto = case when deleted.PhotoTypeId = @MainArticlePhotoTypeId
                                        then null
                                    else Articles.MainArticlePhoto end,
    FacebookPhoto = case when deleted.PhotoTypeId = @FacebookPhotoType
                                        then null
                                    else Articles.FacebookPhoto end
FROM Articles
INNER JOIN deleted
ON Articles.id = deleted.ArticleId


问:
Are variables declared in pthread's functions shared between threads?
I am new to C and pthreads. Here's an example (which probably won't compile as I wrote it now) but it shows what I want to know:

int i = 50;

```<code>void* myFunc (void* whatever) {
    int myLoop = 0;
    for (;;)
    {
        for (myLoop = 0; myLoop < i; myLoop++)
            do work blah;
    }
    pthread_exit(NULL);
}

int main (void) {
    pthread_t threadNo1, threadNo2, threadNo3;

    pthread_create(&threadNo1, NULL, myFunc, NULL);
    pthread_create(&threadNo2, NULL, myFunc, NULL);
    pthread_create(&threadNo3, NULL, myFunc, NULL);

    pthread_join(threadNo1, NULL);
    pthread_join(threadNo2, NULL);
    pthread_join(threadNo3, NULL);

    pthread_exit(NULL);
}
</code>```

Is int myLoop shared between the 3 threads?

Is the loop in myFunc running as thought on all 3 threads (as in iterating properly to 50 which is the value of int i), or are they fighting continuously over its value due to myLoop++? Is this because the variable int myLoop shares its memory value in all different threads?

I want myFunc to run on different threads given to different cores without them messing with each other while looping, meaning the loop iterates perfectly on all threads and they are ignorant of each other. Or is this not actually a problem and is indeed doing that?

答:
Is int myLoop shared between the 3 threads?

Threads have nothing to do with it. The same question could be asked about a single thread. Consider:

```<code>int myFunc(int *j)
{
    int q;
    // lots of code here
    myFunc (&q);
}
</code>```

Consider a single thread that calls myFunc and then myFunc calls itself. Do the two instances of myFunc share q or not? And the answer is -- both. Each invocation has its own q. But if the second call does *j = 2; it will change the value of the first invocation's q.

So each has its own, but they can share them if they wish since they have the same view of process memory.

Same with threads.

Body:
I am new to C and pthreads. Here's an example (which probably won't compile as I wrote it now) but it shows what I want to know:

int i = 50;

void* myFunc (void* whatever) {
    int myLoop = 0;
    for (;;)
    {
        for (myLoop = 0; myLoop < i; myLoop++)
            do work blah;
    }
    pthread_exit(NULL);
}

int main (void) {
    pthread_t threadNo1, threadNo2, threadNo3;

    pthread_create(&threadNo1, NULL, myFunc, NULL);
    pthread_create(&threadNo2, NULL, myFunc, NULL);
    pthread_create(&threadNo3, NULL, myFunc, NULL);

    pthread_join(threadNo1, NULL);
    pthread_join(threadNo2, NULL);
    pthread_join(threadNo3, NULL);

    pthread_exit(NULL);
}

Is int myLoop shared between the 3 threads?

Is the loop in myFunc running as thought on all 3 threads (as in iterating properly to 50 which is the value of int i), or are they fighting continuously over its value due to myLoop++? Is this because the variable int myLoop shares its memory value in all different threads?

I want myFunc to run on different threads given to different cores without them messing with each other while looping, meaning the loop iterates perfectly on all threads and they are ignorant of each other. Or is this not actually a problem and is indeed doing that?

Body:
Is int myLoop shared between the 3 threads?

Threads have nothing to do with it. The same question could be asked about a single thread. Consider:

int myFunc(int *j)
{
    int q;
    // lots of code here
    myFunc (&q);
}

Consider a single thread that calls myFunc and then myFunc calls itself. Do the two instances of myFunc share q or not? And the answer is -- both. Each invocation has its own q. But if the second call does *j = 2; it will change the value of the first invocation's q.

So each has its own, but they can share them if they wish since they have the same view of process memory.

Same with threads.


问:
How to call looped alias
how can i call all the column that the alias i've being looped? sounds weird right?

to make it understandable, here's my code:

```<code>    $begin = new DateTime( $start_date );
    $end = new DateTime( $end_date );
    $end = $end->modify( '+1 day' );

    $interval = new DateInterval('P1D');
    $daterange = new DatePeriod($begin, $interval ,$end);

    $date_array = array();
    $date_concat = array();

    foreach($daterange as $date){
        // $gc .= "GROUP_CONCAT(if(DATE(gen_access_control_log.created_at) = '".$date->format("Y-m-d")."', gen_access_control_log.created_at, NULL)) AS  'day".$date->format("Y-m-d")."',";

        $gc .= "CASE WHEN EXTRACT(DAY FROM gen_access_control_log.created_at) = '".$date->format("d")."' THEN 'P' ELSE 'A' END as 'days".$date->format('d')."',";

        $date_array[] = $date->format("M d");
        $date_concat[] = $date->format("Y-m-d");
    }

    $gc = rtrim($gc,',');

    // Fetch Students
    $students = DB::select(
        DB::raw("
            SELECT sys_user.*, sys_user_student.*, gen_access_control_log.*, sys_mf_grade.*, sys_mf_section.*,
            $gc
            FROM sys_user
            LEFT JOIN sys_user_student on sys_user.user_id = sys_user_student.user_id
            LEFT JOIN sys_mf_section on sys_user_student.section_id = sys_mf_section.section_id
            LEFT JOIN sys_mf_grade on sys_user_student.grade_id = sys_mf_grade.grade_id
            LEFT JOIN gen_access_control_log on sys_user_student.user_id = gen_access_control_log.user_id
            WHERE
            Date(gen_access_control_log.created_at) BETWEEN '$search_from' AND '$search_to'
            AND sys_mf_section.section_id = ".$section_name."
            AND sys_mf_grade.grade_id = ".$grade_name."
            AND gen_access_control_log.status = 'entrance'
            GROUP BY gen_access_control_log.user_id
        ")
    );
</code>```

as you can see, i set an alias of day".$date->format("d")."
my question is, how can i call it to a foreach loop

```<code>        foreach ($students as $key => $value) {
            $id = $value->identification_number;
            $fullname = $value->last_name.", ".$value->first_name;
            $gender = $value->gender;
        }
</code>```

is it possible to concatinate a table column?? something like this
$logs = $value->day.$date->format("d") ? if no, is there any other way or approach? Thanks guys!

答: Have you tried just your approach? If you would select out EXTRACT(DAY FROM gen_access_control_log.created_at) into a new alias extractedDay, then the alias to select out would be 'days' . $value->extractedDay, wouldn't it?

Title: How to call looped alias

Body:
how can i call all the column that the alias i've being looped? sounds weird right?

to make it understandable, here's my code:

    $begin = new DateTime( $start_date );
    $end = new DateTime( $end_date );
    $end = $end->modify( '+1 day' );

    $interval = new DateInterval('P1D');
    $daterange = new DatePeriod($begin, $interval ,$end);

    $date_array = array();
    $date_concat = array();

    foreach($daterange as $date){
        // $gc .= "GROUP_CONCAT(if(DATE(gen_access_control_log.created_at) = '".$date->format("Y-m-d")."', gen_access_control_log.created_at, NULL)) AS  'day".$date->format("Y-m-d")."',";

        $gc .= "CASE WHEN EXTRACT(DAY FROM gen_access_control_log.created_at) = '".$date->format("d")."' THEN 'P' ELSE 'A' END as 'days".$date->format('d')."',";

        $date_array[] = $date->format("M d");
        $date_concat[] = $date->format("Y-m-d");
    }

    $gc = rtrim($gc,',');

    // Fetch Students
    $students = DB::select(
        DB::raw("
            SELECT sys_user.*, sys_user_student.*, gen_access_control_log.*, sys_mf_grade.*, sys_mf_section.*,
            $gc
            FROM sys_user
            LEFT JOIN sys_user_student on sys_user.user_id = sys_user_student.user_id
            LEFT JOIN sys_mf_section on sys_user_student.section_id = sys_mf_section.section_id
            LEFT JOIN sys_mf_grade on sys_user_student.grade_id = sys_mf_grade.grade_id
            LEFT JOIN gen_access_control_log on sys_user_student.user_id = gen_access_control_log.user_id
            WHERE
            Date(gen_access_control_log.created_at) BETWEEN '$search_from' AND '$search_to'
            AND sys_mf_section.section_id = ".$section_name."
            AND sys_mf_grade.grade_id = ".$grade_name."
            AND gen_access_control_log.status = 'entrance'
            GROUP BY gen_access_control_log.user_id
        ")
    );

as you can see, i set an alias of day".$date->format("d")."
my question is, how can i call it to a foreach loop

        foreach ($students as $key => $value) {
            $id = $value->identification_number;
            $fullname = $value->last_name.", ".$value->first_name;
            $gender = $value->gender;
        }

is it possible to concatinate a table column?? something like this
$logs = $value->day.$date->format("d") ? if no, is there any other way or approach? Thanks guys!


问:
I'm creating an RSS reader and having trouble with feedburner feeds
I'm using the Google Feed API to get feeds and the results contain an link field which is great however a feedburner feed returns something to the effect of google.feedproxy.blahblahblah and I need the actual url for the html.  The google.feedproxy url will redirect.  Is there a way using Javascript for me to get the url that is being redirected to?  Or even just a more elegant way of getting the html url?

Any help is appreciated.

答: Make sure your Accept header is limited to the RSS and Atom MIME types. If by HTML URL, you mean the site for the feed, look for a <link rel="alternate"/> in the feed itself, as its href is the relevant site.


问:
borderRadius property of TextInput not working in react-native.
I want to use rounded TextInput in my react-native application but when I am setting  its borderRadius property its not working. Suggest me way to do that.</p>

```<code>    <TextInput  placeholder="Email" style={styles.textInput} />

    textInput:{

    borderColor:'black',
    backgroundColor:'#D3D3D3',
    width:300,
    borderWidth: 1,
    borderStyle: 'solid',
    fontSize:15,
    borderRadius: 25,

    }
</code>```

答: Try overflow:"hidden" on the TextInput that has borderRadius.

Body:
I want to use rounded TextInput in my react-native application but when I am setting  its borderRadius property its not working. Suggest me way to do that.

    <TextInput  placeholder="Email" style={styles.textInput} />

    textInput:{

    borderColor:'black',
    backgroundColor:'#D3D3D3',
    width:300,
    borderWidth: 1,
    borderStyle: 'solid',
    fontSize:15,
    borderRadius: 25,

    }


问:
MySQL connection made but query failing
Im trying to create a login page.
Connection is successful but query is not fetching the required result.
login page sends data through post method to action_page.php.

Action_page.php

```<code><?php
$servername = "localhost:3306";
$username = "root";
$password = "";
$dbname = "MyDB";

$con = mysqli_connect($servername, $username, $password, $dbname);

// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$uname = $_POST['uname'];
$pass = $_POST['psw'];
$sql = "SELECT * FROM Users WHERE uname=".$uname." AND pass=".$pass;
echo "<br/>$sql<br/>";

//$result = $con->query($sql);

echo var_dump($con->query($sql));

$con->close();
</code>```

?>

could someone please help.!

答:
```<code>You can use single quote for the inserted variable inside double quote :)

$sql = "SELECT * FROM Users WHERE uname='$uname' AND pass='$pass'";
</code>```

Title: MySQL connection made but query failing

Body:
Im trying to create a login page.
Connection is successful but query is not fetching the required result.
login page sends data through post method to action_page.php.

Action_page.php

<?php
$servername = "localhost:3306";
$username = "root";
$password = "";
$dbname = "MyDB";

$con = mysqli_connect($servername, $username, $password, $dbname);

// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$uname = $_POST['uname'];
$pass = $_POST['psw'];
$sql = "SELECT * FROM Users WHERE uname=".$uname." AND pass=".$pass;
echo "
$sql
";

//$result = $con->query($sql);

echo var_dump($con->query($sql));

$con->close();

?>

could someone please help.!


问:
Initializing array of std::vector in constructor init list
Usually when writing a constructor I try to initialize as many class members as possible in the member initialization list, including containers such as std::vector.

```<code>class MyClass
{
  protected:
  std::vector<int> myvector;

  public:
  MyClass() : myvector(500, -1) {}
}
</code>```

For technical reasons, I now need to split this into an array of vectors.

```<code>class MyClass
{
  protected:
  std::vector<int> myvector[3];

  public:
  MyClass() : myvector[0](500, -1), myvector[1](250, -1), myvector[2](250, -1) {}
}
</code>```

Turns out, I cannot initialize the array of vectors this way. What am I doing wrong? Or is this just not possible?

Of course I can still do this in the body of the ctor using assign, but I'd prefer to do it in the member init list.

答:
You should initialize the whole array, but not every element. The correct syntax to initialize the array should be</p>

```<code>MyClass() : myvector {std::vector<int>(500, -1), std::vector<int>(250, -1), std::vector<int>(250, -1)} {}
</code>```

Body:
Usually when writing a constructor I try to initialize as many class members as possible in the member initialization list, including containers such as std::vector.

class MyClass
{
  protected:
  std::vector<int> myvector;

  public:
  MyClass() : myvector(500, -1) {}
}

For technical reasons, I now need to split this into an array of vectors.

class MyClass
{
  protected:
  std::vector<int> myvector[3];

  public:
  MyClass() : myvector[0](500, -1), myvector[1](250, -1), myvector[2](250, -1) {}
}

Turns out, I cannot initialize the array of vectors this way. What am I doing wrong? Or is this just not possible?

Of course I can still do this in the body of the ctor using assign, but I'd prefer to do it in the member init list.

Body:
You should initialize the whole array, but not every element. The correct syntax to initialize the array should be

MyClass() : myvector {std::vector<int>(500, -1), std::vector<int>(250, -1), std::vector<int>(250, -1)} {}


问:
Using android vector Drawables on pre Lollipop crash
I'm using vector drawables in android prior to Lollipop and these are of some of my libraries and tool versions:

Android Studio : 2.0

Android Gradle Plugin : 2.0.0

Build Tools : 23.0.2

Android Support Library : 23.3.0

I added this property in my app level Build.Gradle

```<code>android {
  defaultConfig {
    vectorDrawables.useSupportLibrary = true
   }
}
</code>```

It is also worth mentioning that I use an extra drawable such as LayerDrawable(layer_list) as stated in Android official Blog (link here) for setting drawables for vector drawables outside of app:srcCompat

```<code><level-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/search"/>
</level-list>
</code>```

You’ll find directly referencing vector drawables outside of
  app:srcCompat will fail prior to Lollipop. However, AppCompat does
  support loading vector drawables when they are referenced in another
  drawable container such as a StateListDrawable, InsetDrawable,
  LayerDrawable, LevelListDrawable, and RotateDrawable. By using this
  indirection, you can use vector drawables in cases such as TextView’s
  android:drawableLeft attribute, which wouldn’t normally be able to
  support vector drawables.

When I'm using app:srcCompat everything works fine, but when I use:

```<code>android:background
android:drawableLeft
android:drawableRight
android:drawableTop
android:drawableBottom
</code>```

on ImageView, ImageButton, TextView or EditText prior to Lollipop, it throws an expection:

```<code>Caused by: android.content.res.Resources$NotFoundException: File res/drawable/search_toggle.xml from drawable resource ID #0x7f0200a9
</code>```

答:
For anyone who upgrade to android gradle 3.0 and above, there is no need to use AppCompatDelegate.setCompatVectorFromResourcesEnabled(true), or set vectorDrawables.useSupportLibrary = true (add this will cause problem) and use app:srcCompat, it just works.

Take me two days to figure this out, and have not find any related docs in google's docs...

ContentLicense: CC BY-SA 4.0

Body:
I'm using vector drawables in android prior to Lollipop and these are of some of my libraries and tool versions:

Android Studio : 2.0

Android Gradle Plugin : 2.0.0

Build Tools : 23.0.2

Android Support Library : 23.3.0

I added this property in my app level Build.Gradle

android {
  defaultConfig {
    vectorDrawables.useSupportLibrary = true
   }
}

It is also worth mentioning that I use an extra drawable such as LayerDrawable(layer_list) as stated in Android official Blog (link here) for setting drawables for vector drawables outside of app:srcCompat

<level-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/search"/>
</level-list>

You’ll find directly referencing vector drawables outside of
  app:srcCompat will fail prior to Lollipop. However, AppCompat does
  support loading vector drawables when they are referenced in another
  drawable container such as a StateListDrawable, InsetDrawable,
  LayerDrawable, LevelListDrawable, and RotateDrawable. By using this
  indirection, you can use vector drawables in cases such as TextView’s
  android:drawableLeft attribute, which wouldn’t normally be able to
  support vector drawables.

When I'm using app:srcCompat everything works fine, but when I use:

android:background
android:drawableLeft
android:drawableRight
android:drawableTop
android:drawableBottom

on ImageView, ImageButton, TextView or EditText prior to Lollipop, it throws an expection:

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/search_toggle.xml from drawable resource ID #0x7f0200a9


问:
How to properly Tar and gzip a Jupyter notebook and relevant csv files?
I have to send a Jupyter notebook with an analysis to a colleague. It was asked I tar and gzip the files. The notebook uses 3 csv data sets that are present in the same folder as the notebook.
I have never done this before and my background is mathematics not programming, so if this answer is obvious please forgive.

In the notebook I load all the datasets by reading them in from a folder on my computer (the same folder the notebook is in and that I will be tar balling). How can I tar the files so that my code runs smoothly in the notebook. Or do I have to edit the call on the data set in the notebook?

答:
Simply compress/zip the parent folder of the notebook and the 3 data files.

If the folder structure was like this:

```<code>- Parent folder
    - notebook
    - csv1
    - csv2
    - csv3
</code>```

You would want to simply compress/zip the "Parent folder" to achieve your question.

Please let me know if you have any more questions!

Body:
Simply compress/zip the parent folder of the notebook and the 3 data files.

If the folder structure was like this:

- Parent folder
    - notebook
    - csv1
    - csv2
    - csv3

You would want to simply compress/zip the "Parent folder" to achieve your question.

Please let me know if you have any more questions!


问:
how to add timestamp like a camcorder while recording video using GLES20
I want to display date/time while recording the video and it should be displayed when we replay the videos like we do it in CCTV video recordings. i can display shapes using GLES20  i want to use text inside video to display Timestamp i am using textureview along with Mediarecorder andorid when i run GLText() it displays nothing instead of text "hellooo" on the video.
  here is an example : </p>

```<code> private void drawBox() {
        GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
        GLES20.glScissor(0, 0, 100, 100);
        GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
        GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
    }

this code displays a box but i want to replace this with text and i am unable to find any solution ..

I tried this method but it didn't work

  public void GLText() {

//        Bitmap bitmap = Bitmap.createBitmap(64, 64, Bitmap.Config.ARGB_4444);
//        Canvas canvas = new Canvas(bitmap);
//        bitmap.eraseColor(0);
//
//        Paint paint = new Paint();
//        paint.setTextSize(18);
//        paint.setAntiAlias(true);
//        paint.setARGB(0xff, 0xff, 0xff, 0xff);
//        paint.setTextAlign(Paint.Align.LEFT);
//        paint.setTextScaleX(0.5f);
//        canvas.drawText("testGLText", 0.f, 15.f, paint);

        Bitmap bitmap = fromText("hellooo",50);
        GLES20.glEnable(GLES20.GL_SCISSOR_TEST);

        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glEnable(GLES20.GL_BLEND); // this, and the next line
        GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA); // and this were key! I'm still not completely sure as to what this is doing, but it works!
        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, bitmap, 0);

    }

 public Bitmap fromText(String text, int textSize) {
        Paint paint = new Paint();
        paint.setTextSize(textSize);
        paint.setColor(Color.WHITE);
        float baseline = -paint.ascent(); // ascent() is negative
        int width = (int) (paint.measureText(text) + 1.0f);
        int height = (int) (baseline + paint.descent() + 1.0f);
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        bitmap.setHasAlpha(true);
        Canvas canvas = new Canvas(bitmap);
        // canvas.drawColor(Color.argb(0, 255, 255, 255));
        canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
        canvas.drawText(text, 0, baseline, paint);
        return bitmap;
    }

My entire code is :

 if (showBox && (++mFrameCount & 0x04) == 0) {
            drawBox(); // here drawBox draws a box but i when i call GLText() it draws nothing
        }
    }

    /**
     * Draws a red box in the corner.
     */
    private void drawBox() {
        GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
        GLES20.glScissor(0, 0, 100, 100);
        GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
        GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
    }

    private void drawSquare() {
        GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
        GLES20.glScissor(200, 300, 900, 100);
        GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
        GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
    }

    public void GLText() {

//        Bitmap bitmap = Bitmap.createBitmap(64, 64, Bitmap.Config.ARGB_4444);
//        Canvas canvas = new Canvas(bitmap);
//        bitmap.eraseColor(0);
//
//        Paint paint = new Paint();
//        paint.setTextSize(18);
//        paint.setAntiAlias(true);
//        paint.setARGB(0xff, 0xff, 0xff, 0xff);
//        paint.setTextAlign(Paint.Align.LEFT);
//        paint.setTextScaleX(0.5f);
//        canvas.drawText("testGLText", 0.f, 15.f, paint);

        Bitmap bitmap = fromText("hellooo",50);
        GLES20.glEnable(GLES20.GL_SCISSOR_TEST);

        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glEnable(GLES20.GL_BLEND); // this, and the next line
        GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA); // and this were key! I'm still not completely sure as to what this is doing, but it works!
        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, bitmap, 0);

    }

    public Bitmap fromText(String text, int textSize) {
        Paint paint = new Paint();
        paint.setTextSize(textSize);
        paint.setColor(Color.WHITE);
        float baseline = -paint.ascent(); // ascent() is negative
        int width = (int) (paint.measureText(text) + 1.0f);
        int height = (int) (baseline + paint.descent() + 1.0f);
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        bitmap.setHasAlpha(true);
        Canvas canvas = new Canvas(bitmap);
        // canvas.drawColor(Color.argb(0, 255, 255, 255));
        canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
        canvas.drawText(text, 0, baseline, paint);
        return bitmap;
    }
</code>```

答:
Here I got an opensource library which works the similar way .. i can insert text inside a video and can do many other things.

https://github.com/INDExOS/media-for-mobile

Body:
I want to display date/time while recording the video and it should be displayed when we replay the videos like we do it in CCTV video recordings. i can display shapes using GLES20  i want to use text inside video to display Timestamp i am using textureview along with Mediarecorder andorid when i run GLText() it displays nothing instead of text "hellooo" on the video.
  here is an example :

 private void drawBox() {
        GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
        GLES20.glScissor(0, 0, 100, 100);
        GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
        GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
    }

this code displays a box but i want to replace this with text and i am unable to find any solution ..

I tried this method but it didn't work

  public void GLText() {

//        Bitmap bitmap = Bitmap.createBitmap(64, 64, Bitmap.Config.ARGB_4444);
//        Canvas canvas = new Canvas(bitmap);
//        bitmap.eraseColor(0);
//
//        Paint paint = new Paint();
//        paint.setTextSize(18);
//        paint.setAntiAlias(true);
//        paint.setARGB(0xff, 0xff, 0xff, 0xff);
//        paint.setTextAlign(Paint.Align.LEFT);
//        paint.setTextScaleX(0.5f);
//        canvas.drawText("testGLText", 0.f, 15.f, paint);

        Bitmap bitmap = fromText("hellooo",50);
        GLES20.glEnable(GLES20.GL_SCISSOR_TEST);

        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glEnable(GLES20.GL_BLEND); // this, and the next line
        GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA); // and this were key! I'm still not completely sure as to what this is doing, but it works!
        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, bitmap, 0);

    }

 public Bitmap fromText(String text, int textSize) {
        Paint paint = new Paint();
        paint.setTextSize(textSize);
        paint.setColor(Color.WHITE);
        float baseline = -paint.ascent(); // ascent() is negative
        int width = (int) (paint.measureText(text) + 1.0f);
        int height = (int) (baseline + paint.descent() + 1.0f);
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        bitmap.setHasAlpha(true);
        Canvas canvas = new Canvas(bitmap);
        // canvas.drawColor(Color.argb(0, 255, 255, 255));
        canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
        canvas.drawText(text, 0, baseline, paint);
        return bitmap;
    }

My entire code is :

 if (showBox && (++mFrameCount & 0x04) == 0) {
            drawBox(); // here drawBox draws a box but i when i call GLText() it draws nothing
        }
    }

    /**
     * Draws a red box in the corner.
     */
    private void drawBox() {
        GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
        GLES20.glScissor(0, 0, 100, 100);
        GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
        GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
    }

    private void drawSquare() {
        GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
        GLES20.glScissor(200, 300, 900, 100);
        GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
        GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
    }

    public void GLText() {

//        Bitmap bitmap = Bitmap.createBitmap(64, 64, Bitmap.Config.ARGB_4444);
//        Canvas canvas = new Canvas(bitmap);
//        bitmap.eraseColor(0);
//
//        Paint paint = new Paint();
//        paint.setTextSize(18);
//        paint.setAntiAlias(true);
//        paint.setARGB(0xff, 0xff, 0xff, 0xff);
//        paint.setTextAlign(Paint.Align.LEFT);
//        paint.setTextScaleX(0.5f);
//        canvas.drawText("testGLText", 0.f, 15.f, paint);

        Bitmap bitmap = fromText("hellooo",50);
        GLES20.glEnable(GLES20.GL_SCISSOR_TEST);

        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glEnable(GLES20.GL_BLEND); // this, and the next line
        GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA); // and this were key! I'm still not completely sure as to what this is doing, but it works!
        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, bitmap, 0);

    }

    public Bitmap fromText(String text, int textSize) {
        Paint paint = new Paint();
        paint.setTextSize(textSize);
        paint.setColor(Color.WHITE);
        float baseline = -paint.ascent(); // ascent() is negative
        int width = (int) (paint.measureText(text) + 1.0f);
        int height = (int) (baseline + paint.descent() + 1.0f);
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        bitmap.setHasAlpha(true);
        Canvas canvas = new Canvas(bitmap);
        // canvas.drawColor(Color.argb(0, 255, 255, 255));
        canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
        canvas.drawText(text, 0, baseline, paint);
        return bitmap;
    }