问:
Formatted toString()
I am beginner using the toString() method to return a formatted String. I am printing a deck of cards where each column is the different suit. Does anyone have any ideas? Here is the code I have:

```<code>public class DeckOfCards {
  public static void main(String[] args) {
    int[] deck = new int[52];
    //String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"};
    String[] suits = {"Clubs","Diamonds","Hearts","Spades"};
    //String[] ranks = {"Ace","King", "Queen", "Jack", "10", "9", "8", "7", "6", "5", "4", "3", "2"};
    String[] ranks = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King","Ace"};

    // Initialize cards
        for (int i = 0; i < deck.length; i++) {
            deck[i] = i;
        }

        // Shuffle the cards
        for (int i = 0; i < deck.length; i++) {
            int index = (int)(Math.random() * deck.length);
            int temp = deck[i];
            deck[i] = deck[index];
            deck[index] = temp;
        }

        // Display the all the cards
        for (int i = 0; i < 52; i++) {
            String suit = suits[deck[i] / 13];
            String rank = ranks[deck[i] % 13];
            System.out.println( rank + " of " + suit);
        }

        System.out.println("------------------------------");

        for(int i=0;i<deck.length;i++){
            for(int j=i;j<deck.length;j++){
                if(deck[j]==51-i){
                    int temp = deck[i];
                    deck[i] = deck[j];
                    deck[j] = temp;
                }
            }
        }

        // Display the all the cards
        for (int i = 0; i < 52; i++) {
            String suit = suits[deck[i] / 13];
            String rank = ranks[deck[i] % 13];
            System.out.printf( rank + " of " + suit + "\t");
        }

    }
  }
</code>```

The main area I believe will be in the toString() is here:

```<code>// Display the all the cards
        for (int i = 0; i < 52; i++) {
            String suit = suits[deck[i] / 13];
            String rank = ranks[deck[i] % 13];
            System.out.println( rank + " of " + suit);
        }
</code>```

How would I use this in the toString() method and also instantiate an object that can print this toString() method? Thank you for your time. So that it displays in order in a game of bridge I was thinking of an output like this:

```<code>Ace of Spades     Ace of Hearts     Ace of Diamonds     Ace of Clubs
...
// And so on until it reaches two of clubs
</code>```

Do any of these ways print it like such without one being extra spaced or if not what could be modified in the toString() to have it come out like that? Thank you for your time, again.

答:
if you want to instance a object, this is my solution:

Card.java

```<code>/*-***************************************************************************
 * Copyright (C) 2017  Miguel Fernandez Fernandez
 *
 * This is free software, licensed under the GNU General Public License v3.
 * See http://www.gnu.org/licenses/gpl.html for more information.
 ****************************************************************************/

public class Card {

    String suit;
    String rank;

    public Card(String suit, String rank) {
        this.suit = suit;
        this.rank = rank;
    }

    public String getSuit() {
        return suit;
    }

    public void setSuit(String suit) {
        this.suit = suit;
    }

    public String getRank() {
        return rank;
    }

    public void setRank(String rank) {
        this.rank = rank;
    }

    @Override
    public String toString() {
        return rank + "\t" + suit;
    }
}
</code>```

Main.java

```<code>/*-***************************************************************************
 * Copyright (C) 2017  Miguel Fernandez Fernandez
 *
 * This is free software, licensed under the GNU General Public License v3.
 * See http://www.gnu.org/licenses/gpl.html for more information.
 ****************************************************************************/

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    public static void main(String[] args) {

        List<Card> deck = new ArrayList<Card>(52);
        String[] suits = { "Clubs", "Diamonds", "Hearts", "Spades" };
        String[] ranks = { "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace" };

        // Initialize cards
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 13; j++) {
                deck.add(new Card(suits[i], ranks[j]));
            }
        }

        System.out.println("Cards: \n");

        // Print cards
        for (Card c : deck) {
            System.out.println(c.toString());
        }

        System.out.println("\n\nRandom cards...\n\n");

        // Shuffle the cards
        Collections.shuffle(deck);
        System.out.println("Cards: \n");

        // Display the all the cards
        for (Card c : deck) {
            System.out.println(c.toString());
        }
    }
}
</code>```

Thank you! :)

Title: Formatted toString()

Body:
I am beginner using the toString() method to return a formatted String. I am printing a deck of cards where each column is the different suit. Does anyone have any ideas? Here is the code I have:

public class DeckOfCards {
  public static void main(String[] args) {
    int[] deck = new int[52];
    //String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"};
    String[] suits = {"Clubs","Diamonds","Hearts","Spades"};
    //String[] ranks = {"Ace","King", "Queen", "Jack", "10", "9", "8", "7", "6", "5", "4", "3", "2"};
    String[] ranks = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King","Ace"};

    // Initialize cards
        for (int i = 0; i < deck.length; i++) {
            deck[i] = i;
        }

        // Shuffle the cards
        for (int i = 0; i < deck.length; i++) {
            int index = (int)(Math.random() * deck.length);
            int temp = deck[i];
            deck[i] = deck[index];
            deck[index] = temp;
        }

        // Display the all the cards
        for (int i = 0; i < 52; i++) {
            String suit = suits[deck[i] / 13];
            String rank = ranks[deck[i] % 13];
            System.out.println( rank + " of " + suit);
        }

        System.out.println("------------------------------");

        for(int i=0;i<deck.length;i++){
            for(int j=i;j<deck.length;j++){
                if(deck[j]==51-i){
                    int temp = deck[i];
                    deck[i] = deck[j];
                    deck[j] = temp;
                }
            }
        }

        // Display the all the cards
        for (int i = 0; i < 52; i++) {
            String suit = suits[deck[i] / 13];
            String rank = ranks[deck[i] % 13];
            System.out.printf( rank + " of " + suit + "\t");
        }

    }
  }

The main area I believe will be in the toString() is here:

// Display the all the cards
        for (int i = 0; i < 52; i++) {
            String suit = suits[deck[i] / 13];
            String rank = ranks[deck[i] % 13];
            System.out.println( rank + " of " + suit);
        }

How would I use this in the toString() method and also instantiate an object that can print this toString() method? Thank you for your time. So that it displays in order in a game of bridge I was thinking of an output like this:

Ace of Spades     Ace of Hearts     Ace of Diamonds     Ace of Clubs
...
// And so on until it reaches two of clubs

Do any of these ways print it like such without one being extra spaced or if not what could be modified in the toString() to have it come out like that? Thank you for your time, again.

Body:
if you want to instance a object, this is my solution:

Card.java

/*-***************************************************************************
 * Copyright (C) 2017  Miguel Fernandez Fernandez
 *
 * This is free software, licensed under the GNU General Public License v3.
 * See http://www.gnu.org/licenses/gpl.html for more information.
 ****************************************************************************/

public class Card {

    String suit;
    String rank;

    public Card(String suit, String rank) {
        this.suit = suit;
        this.rank = rank;
    }

    public String getSuit() {
        return suit;
    }

    public void setSuit(String suit) {
        this.suit = suit;
    }

    public String getRank() {
        return rank;
    }

    public void setRank(String rank) {
        this.rank = rank;
    }

    @Override
    public String toString() {
        return rank + "\t" + suit;
    }
}

Main.java

/*-***************************************************************************
 * Copyright (C) 2017  Miguel Fernandez Fernandez
 *
 * This is free software, licensed under the GNU General Public License v3.
 * See http://www.gnu.org/licenses/gpl.html for more information.
 ****************************************************************************/

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    public static void main(String[] args) {

        List<Card> deck = new ArrayList<Card>(52);
        String[] suits = { "Clubs", "Diamonds", "Hearts", "Spades" };
        String[] ranks = { "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace" };

        // Initialize cards
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 13; j++) {
                deck.add(new Card(suits[i], ranks[j]));
            }
        }

        System.out.println("Cards: \n");

        // Print cards
        for (Card c : deck) {
            System.out.println(c.toString());
        }

        System.out.println("\n\nRandom cards...\n\n");

        // Shuffle the cards
        Collections.shuffle(deck);
        System.out.println("Cards: \n");

        // Display the all the cards
        for (Card c : deck) {
            System.out.println(c.toString());
        }
    }
}

Thank you! :)


来源: stackexchange

问:
How do I get rid of the sidebar and toolbar when embedding a pdf in an html file?
Trying to embed a pdf on my website like so:

```<code><iframe src="filename.pdf" type='application/pdf' frameborder="0"></iframe>
</code>```

The website is a rails site, and currently I'm only running it on a local server.

The problem is that the pdfs render with a toolbar on top and a sidebar with my adobe creative cloud account information, as seen in the picture below (the actual content of the pdf displays in the white box under the toolbar and to the left of the sidebar)

How can I get the pdf to render alone, without the menu and sidebar?

答:
Searching more into stack, try that:

https://stackoverflow.com/a/2105095/7741129

For more detailed informations:

http://blogs.adobe.com/pdfdevjunkie/web_designers_guide

I think it's better use some kind of JS stuff just in case of cross-browser issues, like related into first link. Solutions like https://pdfobject.com/ it's helpful to get the job done. Look:

PDFObject 2.0 detects browser support for inline/embedded PDFs. (In
  case you were wondering, your browser supports embedded PDFs. You
  lucky dog, you!)

If you're working with dynamic HTML, such as a single-page web app,
  you may need to insert PDFs on-the-fly. However, PDF embedding is not
  supported by certain browsers. If you insert markup without first
  checking for PDF support, you could wind up with missing content or a
  broken UI.

The PDFObject utility helps you avoid these situations by detecting
  support for PDF embedding in the browser; if embedding is supported,
  the PDF is embedded. If embedding is NOT supported by the browser, the
  PDF will NOT be embedded.

By default, PDFObject 2.0 inserts a fallback link to the PDF when the
  browser does not support inline PDFs. This ensures your users always
  have access to your PDF, and is designed to help you write less code.
  The fallback link can be customized, or the option can be disabled if
  you prefer.

PDFObject 2.0 is npm-ready. Modern web apps use npm to manage packages
  and dependencies. PDFObject 2.0 is registered with Node Package
  Manager (npm) and can be loaded dynamically.

PDFObject also makes it easy to specify Adobe's proprietary "PDF Open
  Parameters". (Be warned these parameters are only supported by Adobe
  Reader, most PDF readers will ignore the parameters, including the
  built-in PDF readers in Chrome, Internet Explorer, and Safari. Read
  more below.)

ContentLicense: CC BY-SA 3.0

Body:
Trying to embed a pdf on my website like so:

The website is a rails site, and currently I'm only running it on a local server.

The problem is that the pdfs render with a toolbar on top and a sidebar with my adobe creative cloud account information, as seen in the picture below (the actual content of the pdf displays in the white box under the toolbar and to the left of the sidebar)

How can I get the pdf to render alone, without the menu and sidebar?


问:
Get data by id wordpress

Problem

I have two different plugin tables and I want to get their value by sql. Problem is id where I cannot find connection which I can retrieve data.

Table 1 (bdt_mappress_posts)

postid = 2 and mapid = 3

Table 2 (bdt_mappress_maps)

mapid = 3 and obj = json

```<code><? $postid = get_the_ID();
$results = $GLOBALS['wpdb']->get_results( 'SELECT obj FROM bdt_mappress_maps INNER JOIN bdt_mappress_posts WHERE bdt_mappress_maps.mapid = bdt_mappress_posts AND   bdt_mappress_posts.postid ='.$postid); print_r($results);
 ?>
</code>```

$postid returns me id of the post. The sql returns me empty value, I know sql but not so strong. If someone can help me or give related post which I can find answer. Thanks beforehand!

答:
assuming that the two table are related  by mapid for both of the tables  you should use a join with on condition </p>

```<code>$results = $GLOBALS['wpdb']->get_results( 'SELECT mapid
           FROM bdt_mappress_maps
           INNER JOIN bdt_mappress_posts
              on (bdt_mappress_maps.mapid = bdt_mappress_posts
                   AND   bdt_mappress_posts.id ='.$postid));
</code>```

Title: Get data by id wordpress

Body:
Problem

I have two different plugin tables and I want to get their value by sql. Problem is id where I cannot find connection which I can retrieve data.

Table 1 (bdt_mappress_posts)

postid = 2 and mapid = 3

Table 2 (bdt_mappress_maps)

mapid = 3 and obj = json

<? $postid = get_the_ID();
$results = $GLOBALS['wpdb']->get_results( 'SELECT obj FROM bdt_mappress_maps INNER JOIN bdt_mappress_posts WHERE bdt_mappress_maps.mapid = bdt_mappress_posts AND   bdt_mappress_posts.postid ='.$postid); print_r($results);
 ?>

$postid returns me id of the post. The sql returns me empty value, I know sql but not so strong. If someone can help me or give related post which I can find answer. Thanks beforehand!

Body:
assuming that the two table are related  by mapid for both of the tables  you should use a join with on condition

$results = $GLOBALS['wpdb']->get_results( 'SELECT mapid
           FROM bdt_mappress_maps
           INNER JOIN bdt_mappress_posts
              on (bdt_mappress_maps.mapid = bdt_mappress_posts
                   AND   bdt_mappress_posts.id ='.$postid));


问:
Racket type annotations in for/list using in-query (DB calls)
I'm trying to read data from a database in typed Racket and convert it to a list of structures. The code below is the untyped version that works perfectly. This is the smallest bit I can make that demonstrates the problem.

```<code>#lang racket

(require db)

(define dbc (sqlite3-connect #:database "dmdb.sqlite3" #:mode 'read/write))

(struct player (name size str dex con base-hp current-hp base-ac attack) #:mutable)

(define get-players
  (lambda (c)
    (for/list
        ([(n s str dex con bhp chp bac attack)
            (in-query c "select * from players")])
      (player n s str dex con bhp chp bac attack))))
</code>```

The typed version of the procedure is as shown below:

```<code>#lang type/racket
(require typed/db)

(: get-players (-> Connection (Listof player)))
(define get-players
  (lambda (c)
    (for/list
        ([(n s str dex con bhp chp bac attack)
            (in-query c "select * from players")])
      (player n s str dex con bhp chp bac attack))))
</code>```

When I try to compile it in typed Racket I receive some strange error messages:

```<code>Type Checker: Expression should produce 9 values, but produces 1 values of
types SQL-Datum in: (for/list (((n s str dex con bhp chp bac attack
(in-query c "select * from players"))) (player n s str dex con bhp chp bac
attack))
</code>```

Again, the code works perfectly as long as it is not typed.

答:
With some help from Leif Andersen I found an answer. Below is the smallest bit of code I could create that allowed me to test my solution. It involves using query-rows instead of in-query to extract the data and then manipulating the resulting list of vectors.

```<code>#lang typed/racket
(require typed/db/base typed/db/sqlite3)

; for testing - cut and paste into interactions window
(define dbc (sqlite3-connect #:database "dmdb.sqlite3" #:mode 'read/write))

(struct player ([name : String] [size : String]
                [str : Integer] [dex : Integer] [con : Integer] [base-hp : Integer]
                [current-hp : Integer]
                [base-ac : Integer] [attack : Integer]) #:mutable )

(define lv (query-rows dbc "select * from players"))

(define ll : (Listof (Listof SQL-Datum))
    (for/list ((v lv))
      (vector->list v)))

(: lv->ll (-> (Listof (Vectorof SQL-Datum)) (Listof (Listof SQL-Datum))))
(define lv->ll
  (lambda (llv)
    (for/list ((v llv))
      (vector->list v))))

(: list->player (-> (Listof SQL-Datum) player))
(define list->player
  (lambda (a)
    (player (cast (list-ref a 0) String)
            (cast (list-ref a 1) String)
            (cast (list-ref a 2) Integer)
            (cast (list-ref a 3) Integer)
            (cast (list-ref a 4) Integer)
            (cast (list-ref a 5) Integer)
            (cast (list-ref a 6) Integer)
            (cast (list-ref a 7) Integer)
            (cast (list-ref a 8) Integer))))

(: list->playerlist (-> (Listof (Listof SQL-Datum)) (Listof player)))
(define list->playerlist
  (lambda (l)
    (for/list ((p l))
      (list->player p))))

(: listvectors->playerlist (-> (Listof (Vectorof SQL-Datum)) (Listof player)))
(define listvectors->playerlist
  (lambda (l)
    (list->playerlist (lv->ll l))))

(disconnect dbc)
</code>```

I know that casts are considered ugly in some circles, but I needed to force the data types and I'm trusting that no-one is going to screw with the database once the program's out there. If they mess up their DB, it's their own problem, I guess.

Body:
I'm trying to read data from a database in typed Racket and convert it to a list of structures. The code below is the untyped version that works perfectly. This is the smallest bit I can make that demonstrates the problem.

#lang racket

(require db)

(define dbc (sqlite3-connect #:database "dmdb.sqlite3" #:mode 'read/write))

(struct player (name size str dex con base-hp current-hp base-ac attack) #:mutable)

(define get-players
  (lambda (c)
    (for/list
        ([(n s str dex con bhp chp bac attack)
            (in-query c "select * from players")])
      (player n s str dex con bhp chp bac attack))))

The typed version of the procedure is as shown below:

#lang type/racket
(require typed/db)

(: get-players (-> Connection (Listof player)))
(define get-players
  (lambda (c)
    (for/list
        ([(n s str dex con bhp chp bac attack)
            (in-query c "select * from players")])
      (player n s str dex con bhp chp bac attack))))

When I try to compile it in typed Racket I receive some strange error messages:

Type Checker: Expression should produce 9 values, but produces 1 values of
types SQL-Datum in: (for/list (((n s str dex con bhp chp bac attack
(in-query c "select * from players"))) (player n s str dex con bhp chp bac
attack))

Again, the code works perfectly as long as it is not typed.

Body:
With some help from Leif Andersen I found an answer. Below is the smallest bit of code I could create that allowed me to test my solution. It involves using query-rows instead of in-query to extract the data and then manipulating the resulting list of vectors.

#lang typed/racket
(require typed/db/base typed/db/sqlite3)

; for testing - cut and paste into interactions window
(define dbc (sqlite3-connect #:database "dmdb.sqlite3" #:mode 'read/write))

(struct player ([name : String] [size : String]
                [str : Integer] [dex : Integer] [con : Integer] [base-hp : Integer]
                [current-hp : Integer]
                [base-ac : Integer] [attack : Integer]) #:mutable )

(define lv (query-rows dbc "select * from players"))

(define ll : (Listof (Listof SQL-Datum))
    (for/list ((v lv))
      (vector->list v)))

(: lv->ll (-> (Listof (Vectorof SQL-Datum)) (Listof (Listof SQL-Datum))))
(define lv->ll
  (lambda (llv)
    (for/list ((v llv))
      (vector->list v))))

(: list->player (-> (Listof SQL-Datum) player))
(define list->player
  (lambda (a)
    (player (cast (list-ref a 0) String)
            (cast (list-ref a 1) String)
            (cast (list-ref a 2) Integer)
            (cast (list-ref a 3) Integer)
            (cast (list-ref a 4) Integer)
            (cast (list-ref a 5) Integer)
            (cast (list-ref a 6) Integer)
            (cast (list-ref a 7) Integer)
            (cast (list-ref a 8) Integer))))

(: list->playerlist (-> (Listof (Listof SQL-Datum)) (Listof player)))
(define list->playerlist
  (lambda (l)
    (for/list ((p l))
      (list->player p))))

(: listvectors->playerlist (-> (Listof (Vectorof SQL-Datum)) (Listof player)))
(define listvectors->playerlist
  (lambda (l)
    (list->playerlist (lv->ll l))))

(disconnect dbc)

I know that casts are considered ugly in some circles, but I needed to force the data types and I'm trusting that no-one is going to screw with the database once the program's out there. If they mess up their DB, it's their own problem, I guess.


问:
Parsing JSON Name Pair in C#
Using C# to parse JSON URL I am facing some issues. As you know JSON data is written as name/value pairs. now in URL JSON I have  these data:

```<code>{
   "currentVersion":10.41,
   "serviceDescription":"There are some text here",
   "hasVersionedData":true,
   "supportsDisconnectedEditing":false,
   "syncEnabled":false,
   "supportedQueryFormats":"JSON",
   "maxRecordCount":1000
 }
</code>```

and I want to only print out the name part of the JSON data using this code

```<code>using (var wc = new WebClient())
{
    string json = wc.DownloadString("http://xxxxxxxxx?f=pjson");
    try
    {
        dynamic data = Json.Decode(json);
        for (int i = 0; i <= data.Length - 1; i++)
        {
            Console.WriteLine(data[0]);
        }

    }
    catch (Exception e)
    {

    }
}
</code>```

but this is  not printing any thing on the console! can you please let me know what I am doing wrong?

答:
Use Newtonsoft JSON:</p>

```<code>JObject jsonObject = JObject.Parse(json);
foreach(var jsonItem in jsonObject)
{
    Console.WriteLine(jsonItem.Key);
}
Console.ReadKey();
</code>```

Title: Parsing JSON Name Pair in C#

Body:
Using C# to parse JSON URL I am facing some issues. As you know JSON data is written as name/value pairs. now in URL JSON I have  these data:

{
   "currentVersion":10.41,
   "serviceDescription":"There are some text here",
   "hasVersionedData":true,
   "supportsDisconnectedEditing":false,
   "syncEnabled":false,
   "supportedQueryFormats":"JSON",
   "maxRecordCount":1000
 }

and I want to only print out the name part of the JSON data using this code

using (var wc = new WebClient())
{
    string json = wc.DownloadString("http://xxxxxxxxx?f=pjson");
    try
    {
        dynamic data = Json.Decode(json);
        for (int i = 0; i <= data.Length - 1; i++)
        {
            Console.WriteLine(data[0]);
        }

    }
    catch (Exception e)
    {

    }
}

but this is  not printing any thing on the console! can you please let me know what I am doing wrong?

Body:
Use Newtonsoft JSON:

JObject jsonObject = JObject.Parse(json);
foreach(var jsonItem in jsonObject)
{
    Console.WriteLine(jsonItem.Key);
}
Console.ReadKey();


问:
Python - How to improve performance of subsetting tuple key dictionaries through for loop?
I have two dictionaries with tuple keys. I subsetted each dictionary into 3 small dictionaries and then applied the prediction model to each dictionary. See below,

```<code># Subset dictionaries from df_dict140 and df_dict150
# df_dict140 has 456 rows and df_dict150 has 415
# I subsetted the them by 200
dic1 = {k: df_dic[k] for k in df_dict140[:200]}
dic2 = {k: df_dic[k] for k in df_dict140[200:400]}
dic3 = {k: df_dic[k] for k in df_dict140[400:456]}

dic4 = {k: df_dic[k] for k in df_dict150[:200]}
dic5 = {k: df_dic[k] for k in df_dict150[200:400]}
dic6 = {k: df_dic[k] for k in df_dict150[400:415]}
</code>```

Applied the model to each dictionary,

```<code>def predictionModel(pred_dict):
    prediction = {}
    for (key1, key2), value in pred_dict.items():
        m = Prophet().fit(value)
        future = m.make_future_dataframe(periods = 365)
        forecast = m.predict(future)
        prediction[key2] = forecast[['ds','yhat']].tail()
    return prediction
</code>```

Prediction results,

```<code>prediction1 = predictionModel(dic1)
prediction2 = predictionModel(dic2)
prediction3 = predictionModel(dic3)
prediction4 = predictionModel(dic4)
prediction5 = predictionModel(dic5)
prediction6 = predictionModel(dic6)
</code>```

Is it possible to write a function or for loop to do the above work so that no need to subset the dictionaries twice and can get the results by once.

答:
```<code># Note that Python will let you index beyond the end of lists without issue
smaller_dicts = [{k: df_dic[k] for k in dfd[200*i:200*(i+1)]}
                 for dfd in [df_dict140, df_dict150]
                 for i in range(3)]

predictions = [predictionModel(sd) for sd in smaller_dicts]
</code>```

Body:
I have two dictionaries with tuple keys. I subsetted each dictionary into 3 small dictionaries and then applied the prediction model to each dictionary. See below,

# Subset dictionaries from df_dict140 and df_dict150
# df_dict140 has 456 rows and df_dict150 has 415
# I subsetted the them by 200
dic1 = {k: df_dic[k] for k in df_dict140[:200]}
dic2 = {k: df_dic[k] for k in df_dict140[200:400]}
dic3 = {k: df_dic[k] for k in df_dict140[400:456]}

dic4 = {k: df_dic[k] for k in df_dict150[:200]}
dic5 = {k: df_dic[k] for k in df_dict150[200:400]}
dic6 = {k: df_dic[k] for k in df_dict150[400:415]}

Applied the model to each dictionary,

def predictionModel(pred_dict):
    prediction = {}
    for (key1, key2), value in pred_dict.items():
        m = Prophet().fit(value)
        future = m.make_future_dataframe(periods = 365)
        forecast = m.predict(future)
        prediction[key2] = forecast[['ds','yhat']].tail()
    return prediction

Prediction results,

prediction1 = predictionModel(dic1)
prediction2 = predictionModel(dic2)
prediction3 = predictionModel(dic3)
prediction4 = predictionModel(dic4)
prediction5 = predictionModel(dic5)
prediction6 = predictionModel(dic6)

Is it possible to write a function or for loop to do the above work so that no need to subset the dictionaries twice and can get the results by once.


问:
SQL Azure - Importing CSV file that resides in a blob
I have read this SO question but mine is quite specific to the "import" of CSV and not how to access the blob to get the CSV out

Which is the best way?

1) CSV Stored in the Blob - use a worker role, read the CSV from the blob, parse data and update database

2) Is SQL BulkCopy/BulkInsert an option. The challenge here is that it should not have any on-premise involvement. All within Azure: blob->SQL DAtabase.

3) Will Azure Automation help? Are there PS scripts/workflows that help in such bulk update of CSV data to Azure SQL DB? I haven't found any though

Are there other options that help import blob CSV data to SQL DB without having to write custom code?

Appreciate any thoughts...

答: I know this question is two years old, but for those just now searching on the topic, I'd like to mention that the new Azure Feature Pack for SSIS makes this an easy task in SSIS.  In VS Data Tools, after installing the Azure Feature pack, you would open an empty SSIS project and 1) Create an Azure Storage Connection Manager, then 2) Add a Data Flow Task, then open the Data Flow task and 3) Add a Blob Source tool to connect to the CSV, and then 4) using Destination Assistant connect to the SQL Table where the data is going. You can then execute this as a one-time load interactively inside the VS Data Tools IDE, or publish it to the SQL Server instance and create a recurring job.</p>


问:
How to join datatables of a dataset?
I have a dataset which have four datatables.

Table[0] contains columns such as: storedProcedure,DLLMethod,BLLMethod

Table[1] contains columns such as: DLLMethod,BLLMethod

Table[2] contains columns such as: UCName,BLLMethod

Table[3] contains columns such as: UCName,Function,Module

Table[4] contains columns such as: StoredProcedure,Function,Module

I want to join first four tables such that final table must contain StoredProcedure,Function and Module.Can anyone Please help me with C# coding?

答:
LINQ to DataSet

```<code>dim query = from a in table1 join b in table2 on a.table2ID = b.ID select a,b
</code>```

this can grow on many more tables by adding more joins

```<code>var query = from a in table1 join b in table2 on a.table2ID = b.ID select a,b;
</code>```

ContentLicense: CC BY-SA 2.5

Title: How to join datatables of a dataset?

Body:
LINQ to DataSet

dim query = from a in table1 join b in table2 on a.table2ID = b.ID select a,b

this can grow on many more tables by adding more joins

var query = from a in table1 join b in table2 on a.table2ID = b.ID select a,b;


问:
Delete Action methods of Web API did not get trigger
I have a web api controller in my project, as follows

```<code>public class EmployeeController : ApiController
{
    static readonly IEmployeeRepository repository = new EmployeeRepository();
    // GET api/<controller>
    [HttpGet]
    public object Get()
    {
        var queryString = HttpContext.Current.Request.QueryString;
        var data = repository.GetAll().ToList();
        return new { Items = data, Count = data.Count() };
    }

    public Employee GetEmployee(int id)
    {
        Employee emp = repository.Get(id);
        if (emp == null)
        {
            throw new HttpResponseException(HttpStatusCode.NotFound);
        }
        return emp;
    }

    // POST api/<controller>
    public HttpResponseMessage PostEmployee(Employee emp)
    {
        emp = repository.Add(emp);
        var response = Request.CreateResponse<Employee>(HttpStatusCode.Created, emp);

        string uri = Url.Link("Employee", new { id = emp.EmployeeID });
        response.Headers.Location = new Uri(uri);
        return response;
    }
     [HttpPut]
    // PUT api/<controller>
    public void PutEmployee(Employee emp)
    {

        if (!repository.Update(emp))
        {
            throw new HttpResponseException(HttpStatusCode.NotFound);
        }

    }
    [HttpDelete]
     public void DeleteEmployee(int id)
    {
        Employee emp = repository.Get(id);
        if (emp == null)
        {
            throw new HttpResponseException(HttpStatusCode.NotFound);
        }

        repository.Remove(id);
    }
}
</code>```

For me, get and post method getting triggered correctly

But, Delete Method is not getting triggered.

and my Webapicongif.cs

```<code>    public static void Register(HttpConfiguration config)
    {
        config.MapHttpAttributeRoutes();

        config.Routes.MapHttpRoute(
            name: "Employee",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
        //config.EnableQuerySupport();
    }
</code>```

and the global.cs file as follows

```<code>    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

        GlobalConfiguration.Configure(WebApiConfig.Register);

        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);

    }
</code>```

once i did the delete to the Employee

```<code>General:

Request URL:http://localhost:63187/api/Employee/2
Request Method:DELETE
Status Code:404 Not Found
Remote Address:[::1]:63187
</code>```

Response Headers

```<code>   Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS
Cache-Control:no-cache
Content-Length:204
Content-Type:application/json; charset=utf-8
Date:Thu, 30 Mar 2017 12:00:21 GMT
Expires:-1
Pragma:no-cache
Server:Microsoft-IIS/10.0
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
X-SourceFiles:=?UTF-8?B?RDpcU2FtcGxlXE1WQ1xEYXRhTWFuYWdlclxBZGFwdG9yc1xTYW1wbGVcYXBpXEVtcGxveWVlXDI=?=
</code>```

Request Headers

```<code>Accept:*/*
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:1
Content-Type:application/json; charset=UTF-8
DataServiceVersion:2.0
Host:localhost:63187
MaxDataServiceVersion:2.0
Origin:http://localhost:63187
Referer:http://localhost:63187/CRUDRemote/Remove
User-Agent:Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
X-Requested-With:XMLHttpRequest
</code>```

Request Payload

```<code>2
</code>```

my ajax request will as below

```<code>beforeSend:function (),
contentType:"application/json; charset=utf-8",
data:"2",
error:function (e),
success:function (),
type:"DELETE",
url:"/api/Employee/2",
</code>```

Where i committing my mistake

答:
For me adding the following in web.config worked all the time.By default delete is not allowed when using WebAPI on remote server.</p>

```<code>   <system.webServer>
    <modules>
    <remove name="WebDAVModule"/>
    </modules>
    <handlers>
    <remove name="WebDAV" />
    <remove name="ExtensionlessUrl-Integrated-4.0" />
    <add name="ExtensionlessUrl-Integrated-4.0"
    path="*."
    verb="GET,HEAD,POST,DEBUG,DELETE,PUT"
    type="System.Web.Handlers.TransferRequestHandler"
    preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    </system.webServer>
</code>```

Body:
I have a web api controller in my project, as follows

public class EmployeeController : ApiController
{
    static readonly IEmployeeRepository repository = new EmployeeRepository();
    // GET api/<controller>
    [HttpGet]
    public object Get()
    {
        var queryString = HttpContext.Current.Request.QueryString;
        var data = repository.GetAll().ToList();
        return new { Items = data, Count = data.Count() };
    }

    public Employee GetEmployee(int id)
    {
        Employee emp = repository.Get(id);
        if (emp == null)
        {
            throw new HttpResponseException(HttpStatusCode.NotFound);
        }
        return emp;
    }

    // POST api/<controller>
    public HttpResponseMessage PostEmployee(Employee emp)
    {
        emp = repository.Add(emp);
        var response = Request.CreateResponse<Employee>(HttpStatusCode.Created, emp);

        string uri = Url.Link("Employee", new { id = emp.EmployeeID });
        response.Headers.Location = new Uri(uri);
        return response;
    }
     [HttpPut]
    // PUT api/<controller>
    public void PutEmployee(Employee emp)
    {

        if (!repository.Update(emp))
        {
            throw new HttpResponseException(HttpStatusCode.NotFound);
        }

    }
    [HttpDelete]
     public void DeleteEmployee(int id)
    {
        Employee emp = repository.Get(id);
        if (emp == null)
        {
            throw new HttpResponseException(HttpStatusCode.NotFound);
        }

        repository.Remove(id);
    }
}

For me, get and post method getting triggered correctly

But, Delete Method is not getting triggered.

and my Webapicongif.cs

    public static void Register(HttpConfiguration config)
    {
        config.MapHttpAttributeRoutes();

        config.Routes.MapHttpRoute(
            name: "Employee",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
        //config.EnableQuerySupport();
    }

and the global.cs file as follows

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

        GlobalConfiguration.Configure(WebApiConfig.Register);

        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);

    }

once i did the delete to the Employee

General:

Request URL:http://localhost:63187/api/Employee/2
Request Method:DELETE
Status Code:404 Not Found
Remote Address:[::1]:63187

Response Headers

   Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS
Cache-Control:no-cache
Content-Length:204
Content-Type:application/json; charset=utf-8
Date:Thu, 30 Mar 2017 12:00:21 GMT
Expires:-1
Pragma:no-cache
Server:Microsoft-IIS/10.0
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
X-SourceFiles:=?UTF-8?B?RDpcU2FtcGxlXE1WQ1xEYXRhTWFuYWdlclxBZGFwdG9yc1xTYW1wbGVcYXBpXEVtcGxveWVlXDI=?=

Request Headers

Accept:*/*
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:1
Content-Type:application/json; charset=UTF-8
DataServiceVersion:2.0
Host:localhost:63187
MaxDataServiceVersion:2.0
Origin:http://localhost:63187
Referer:http://localhost:63187/CRUDRemote/Remove
User-Agent:Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
X-Requested-With:XMLHttpRequest

Request Payload

2

my ajax request will as below

beforeSend:function (),
contentType:"application/json; charset=utf-8",
data:"2",
error:function (e),
success:function (),
type:"DELETE",
url:"/api/Employee/2",

Where i committing my mistake

Body:
For me adding the following in web.config worked all the time.By default delete is not allowed when using WebAPI on remote server.

   <system.webServer>
    <modules>
    <remove name="WebDAVModule"/>
    </modules>
    <handlers>
    <remove name="WebDAV" />
    <remove name="ExtensionlessUrl-Integrated-4.0" />
    <add name="ExtensionlessUrl-Integrated-4.0"
    path="*."
    verb="GET,HEAD,POST,DEBUG,DELETE,PUT"
    type="System.Web.Handlers.TransferRequestHandler"
    preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    </system.webServer>


问:
Check if one of the values from both lists are present in the string in ruby
I have two arrays with logins and file extensions:
logins = ['bob', 'mark', 'joe']
extensions = ['.doc', '.xls']

I need to check if one of the values from both lists are present in the string (string is like str = "aaa bob test.txt test text"), and if yes do some work.

How to correctly perform this checking in Ruby.

Now I'm perform this with several loop and if statements.

答:
You could also use Regexp.union :

```<code>str = 'aaa bob test.xls test text'
logins     = Regexp.union(['bob', 'mark', 'joe'])
extensions = Regexp.union(['.doc', '.xls'])
str =~ logins && str =~ extensions
# => 12
</code>```

It returns either nil if one of both didn't match or an integer if both matched.

As an alternative, with Ruby 2.4 :

```<code>str.match?(logins) && str.match?(extensions)
</code>```

which would return a boolean.

Body:
You could also use Regexp.union :

str = 'aaa bob test.xls test text'
logins     = Regexp.union(['bob', 'mark', 'joe'])
extensions = Regexp.union(['.doc', '.xls'])
str =~ logins && str =~ extensions
# => 12

It returns either nil if one of both didn't match or an integer if both matched.

As an alternative, with Ruby 2.4 :

str.match?(logins) && str.match?(extensions)

which would return a boolean.


问:
Using variable 'i' outside of its function
Okay, I was playing around javascript.  I wanted to create a webpage with a "change background" button that cycled between different colors.  So I wrote it like this (script tag starts out of view)

```<code> var bgcolors = ["pink", "beige", "wheat", "white", "brown"];

        var i = 0;

        function cyclebg(){

            document.body.style.backgroundColor = bgcolors[i];

            i++;

            if (i > (bgcolors.length - 1))
            {
                i = 0;
            }

        }

        //other ideas:
        //-say color next to button
    </script>
    <br>
    <br>
    <button type="button"  style="background-color:red; border-color: red;" OnClick="cyclebg()">Change Background Color</button>
</code>```

That worked just fine.  Then I decided to make an edition, and have the name of the color displayed right next to the button.  So I added...

```<code><script>document.write(bgcolors[i]);

    </script>
</code>```

However, "pink" is always written.  It seems like this "document.write" script is only capable of reading what "i" is outside the function.  Why is this?  Aren't all variables global in javaSCRIPT?  How can I get it to read what "i" is inside the function, so it displays the name of the color being used in the background?

答:
Adding an element to target when the button is clicked would be the easiest way of doing what you are trying to accomplish.

HTML

```<code><button type="button"  style="background-color:red; border-color: red;" OnClick="cyclebg()">Change Background Color</button><span id="color-name"></span>
</code>```

JS

```<code>var bgcolors = ["pink", "beige", "wheat", "white", "brown"];

var i = 0;

function cyclebg(){
    document.body.style.backgroundColor = bgcolors[i];
    document.getElementById("color-name").innerHTML = bgcolors[i]
    i++;
    if (i > (bgcolors.length - 1))
       {
           i = 0;
       }
}
</code>```

https://jsfiddle.net/rt7t1fws/

Body:
Okay, I was playing around javascript.  I wanted to create a webpage with a "change background" button that cycled between different colors.  So I wrote it like this (script tag starts out of view)

 var bgcolors = ["pink", "beige", "wheat", "white", "brown"];

        var i = 0;

        function cyclebg(){

            document.body.style.backgroundColor = bgcolors[i];

            i++;

            if (i > (bgcolors.length - 1))
            {
                i = 0;
            }

        }

        //other ideas:
        //-say color next to button
    </script>

    <button type="button"  style="background-color:red; border-color: red;" OnClick="cyclebg()">Change Background Color</button>

That worked just fine.  Then I decided to make an edition, and have the name of the color displayed right next to the button.  So I added...

However, "pink" is always written.  It seems like this "document.write" script is only capable of reading what "i" is outside the function.  Why is this?  Aren't all variables global in javaSCRIPT?  How can I get it to read what "i" is inside the function, so it displays the name of the color being used in the background?

Body:
Adding an element to target when the button is clicked would be the easiest way of doing what you are trying to accomplish.

HTML

<button type="button"  style="background-color:red; border-color: red;" OnClick="cyclebg()">Change Background Color</button><span id="color-name"></span>

JS

var bgcolors = ["pink", "beige", "wheat", "white", "brown"];

var i = 0;

function cyclebg(){
    document.body.style.backgroundColor = bgcolors[i];
    document.getElementById("color-name").innerHTML = bgcolors[i]
    i++;
    if (i > (bgcolors.length - 1))
       {
           i = 0;
       }
}

https://jsfiddle.net/rt7t1fws/


问:
Implicit conversion in wrapper class
I have confusion in Number Wrapper Class in Java.

These two assignments look symmetric - a char is assigned to Integer, and an int is assigned to Character. However, the first assignment

```<code>Integer i = 'a';
</code>```

gives Compilation Error, while the second assignment

```<code>Character ch2 = 97;
</code>```

is allowed. Why?

答:
The rules for boxing conversions can be found in the Java Language Spec, chapter 5.1.7

Boxing conversion converts expressions of primitive type to corresponding expressions of reference type. Specifically, the following nine conversions are called the boxing conversions:

... followed by a list of valid conversions from primitive types to reference types.

The point is: in any case, a conversion must take place.

If you had

```<code>int a = '97'
</code>```

that is fine; as that is a widening conversion (sectin 5.12 in the JLS). But that case

```<code>Integer i = '97'
</code>```

isn't listed as "valid" conversion for Auto-boxing. In other words: the JLS doesn't allow for it; and this the compiler doesn't do it either.
...

Title: Implicit conversion in wrapper class

Body:
I have confusion in Number Wrapper Class in Java.

These two assignments look symmetric - a char is assigned to Integer, and an int is assigned to Character. However, the first assignment

Integer i = 'a';

gives Compilation Error, while the second assignment

Character ch2 = 97;

is allowed. Why?

Body:
The rules for boxing conversions can be found in the Java Language Spec, chapter 5.1.7

Boxing conversion converts expressions of primitive type to corresponding expressions of reference type. Specifically, the following nine conversions are called the boxing conversions:

... followed by a list of valid conversions from primitive types to reference types.

The point is: in any case, a conversion must take place.

If you had

int a = '97'

that is fine; as that is a widening conversion (sectin 5.12 in the JLS). But that case

Integer i = '97'

isn't listed as "valid" conversion for Auto-boxing. In other words: the JLS doesn't allow for it; and this the compiler doesn't do it either.
...


问:
Unable to extract object values in Typescript
I have been trying to convert a JavaScript web form to Typescript, and have been unable to work out how to deal with the following (which works in JavaScript):

```<code>let fieldValues = JSON.parse(cookieData);

let keys = Object.keys(fieldValues);

let values = Object.values(fieldValues);
</code>```

Visual Studio tells me:

Error TS2339  Property 'values' does not exist on type
  'ObjectConstructor'.

What can I do?

答:
If Object.values is not supported (which today is often the case), you can just map over your keys:

let cookieData = '{"key":"value"}'

let fieldValues = JSON.parse(cookieData)

let keys = Object.keys(fieldValues)

let values = keys.map(k => fieldValues[k])

console.log(keys) //=> ['key']
console.log(values) //=> ['value']```

Body:
I have been trying to convert a JavaScript web form to Typescript, and have been unable to work out how to deal with the following (which works in JavaScript):

let fieldValues = JSON.parse(cookieData);

let keys = Object.keys(fieldValues);

let values = Object.values(fieldValues);

Visual Studio tells me:

Error TS2339  Property 'values' does not exist on type
  'ObjectConstructor'.

What can I do?


问:
PHP array search
I'm trying to add some quick and simple search functionality to a site. The site has an XML file with all their stores, and I want to create a search box to search for the closest store to the user by town or postcode.

I have put all the data into an array, but as far as I can tell, there is no way to 'search' an array (NOT array_search) to retrieve results like using a MySQL LIKE query.

Surely there must be a way? Using MySQL isn't an option in this case.

答: You can try *array_filter()* with an user defined callback.</p>

Title: PHP array search


问:
How can I make both columns same height in Bootstrap?
I have 2 columns in bootstrap side-by-side, col-md-4 and col-md-8 but one is taller than the other.

How can I shrink the taller one to match the height of the smaller column?

The css class listing-top is using flex box.

DEMO https://jsfiddle.net/halnex/3dw85L1r/1/

HTML

```<code><section class="listing listing-top with-feature">
    <div class="col-md-4">
        <article class="tease top-latest tease-" data-post-id="1069327">

            <a class="overlay" href="#"></a>
            <div class="tag"></div>
            <figure style="background-image:url('http://i.imgur.com/WDCTb5S.jpg');">
                <div></div>
            </figure>
            <header>
                <h2><a href="#">Galaxy S8 face recognition already defeated with a simple picture</a></h2>
                <p class="excerpt">Face unlock feature once again defeated with anything resembling owner's face. </p>

                <p class="byline" itemprop="author creator" itemscope="" itemtype="#">
                    <a itemprop="url" href="#"><span itemprop="name">Author</span></a>
                    –  <time class="date" data-time="1490974219" datetime="2017-03-31T15:30:19+00:00">3/31/2017, 6:30 PM</time>
                </p>

            </header>
            <footer>
                <aside class="comments-hotness ">
                    <a title="25 posters participating" class="comment-count icon-comment-bubble-up" href="#">
                        <span class="comment-count-number">31</span>
                    </a>    </aside>

            </footer>
        </article>
    </div>

    <div class="col-md-8">
        <article class="tease top-latest tease-" data-post-id="1069327">

            <a class="overlay" href="#"></a>
            <div class="tag"></div>
            <figure style="background-image:url('http://i.imgur.com/WDCTb5S.jpg');">
                <div></div>
            </figure>
            <header>
                <h2><a href="#">Galaxy S8 face recognition already defeated with a simple picture</a></h2>
                <p class="excerpt">Face unlock feature once again defeated with anything resembling owner's face. </p>

                <p class="byline" itemprop="author creator" itemscope="" itemtype="#">
                    <a itemprop="url" href="#"><span itemprop="name">Author</span></a>
                    –  <time class="date" data-time="1490974219" datetime="2017-03-31T15:30:19+00:00">3/31/2017, 6:30 PM</time>
                </p>

            </header>
            <footer>
                <aside class="comments-hotness ">
                    <a title="25 posters participating" class="comment-count icon-comment-bubble-up" href="#">
                        <span class="comment-count-number">31</span>
                    </a>    </aside>

            </footer>
        </article>
    </div>
</section>
</code>```

CSS

```<code>.listing-top {
    -js-display: flex;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-flow: row wrap;
    flex-flow: row wrap;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
}
.listing-top.with-feature article.top-latest {
    margin-bottom: 20px;
    position: relative;
    cursor: pointer;
    cursor: hand;
    display: block;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-flow: none;
    flex-flow: none;
}
.listing-top.with-feature article.top-latest .overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 14;
}
.listing-top.with-feature article.top-latest .tag {
    -js-display: flex;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-flow: row nowrap;
    flex-flow: row nowrap;
}
.listing-top.with-feature article.top-latest .tag {
    pointer-events: none;
    position: absolute;
    height: 36px;
    z-index: 15;
    background-color: #fff;
    color: #000;
    text-transform: uppercase;
    font-size: 20px;
    font-family: economica;
    top: 15px;
    left: 0;
    display: none;
}
.listing-top.with-feature article .tag {
    pointer-events: none;
    position: absolute;
    height: 36px;
    z-index: 15;
    background-color: #fff;
    color: #000;
    text-transform: uppercase;
    font-size: 20px;
    font-family: economica;
    top: 15px;
    left: 0;
    display: none;
}
.listing-top.with-feature article.top-latest figure {
    width: 100%;
    height: 0;
    padding-bottom: 55.55556%;
}
.listing-top.with-feature article.top-latest figure {
    -webkit-transition: all .17s;
    transition: all .17s;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: top;
    background-color: #f0f1f2;
    background-blend-mode: multiply;
    margin: 0;
}
.listing-top.with-feature article figure {
    width: 100%;
    height: 0;
    padding-bottom: 55.55556%;
}
.listing-top.with-feature article figure {
    -webkit-transition: all .17s;
    transition: all .17s;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: top;
    background-color: #f0f1f2;
    background-blend-mode: multiply;
    margin: 0;
}
figure {
    margin: 1em 40px;
}
article, aside, details, figcaption, figure, footer, header, main, menu, nav, section, summary {
    display: block;
}
.listing-top.with-feature article.top-latest header {
    background: -webkit-linear-gradient(top,#fff 15px,hsla(210,7%,95%,0));
    background: linear-gradient(180deg,#fff 15px,hsla(210,7%,95%,0));
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff",endColorstr="#00f0f1f2",GradientType=0);
    margin: 15px;
    margin-top: -15px;
    padding: 15px;
    border-bottom: none;
    position: relative;
}
.listing-top.with-feature article header {
    background: -webkit-linear-gradient(top,#fff 15px,hsla(210,7%,95%,0));
    background: linear-gradient(180deg,#fff 15px,hsla(210,7%,95%,0));
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff",endColorstr="#00f0f1f2",GradientType=0);
    margin: 15px;
    margin-top: -15px;
    padding: 15px;
    border-bottom: none;
    position: relative;
}
.listing-top.with-feature article.top-latest footer {
    width: 100%;
    margin-top: -25px;
    bottom: -10px;
}
.listing-top.with-feature article.top-latest footer {
    position: absolute;
    z-index: 15;
}
.listing-top.with-feature article.top-latest:after {
    content: "";
    position: absolute;
    bottom: 0;
    height: 30px;
    width: 100%;
    border: 15px solid #ccc;
    border-top: none;
}
.listing-top.with-feature article:after {
    content: "";
    position: absolute;
    bottom: 0;
    height: 30px;
    width: 100%;
    border: 15px solid #ccc;
    border-top: none;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count {
    background-size: cover;
    width: 34px;
    height: 34px;
    display: block;
    margin: 0 auto;
    text-align: center;
    background-position: 50%;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count .comment-count-number {
    padding: 0;
    margin: 0;
    line-height: 34px;
    font-size: 18px;
    color: #fff;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count {
    font-family: economica;
    color: #fff;
    background-repeat: no-repeat;
    display: block;
    background-image: url('../img/comments.svg');
}
@media (min-width: 1000px) {
    .listing-top.with-feature article.top-latest .tag:before {
        top: 11px;
        height: 14px;
        width: 18px;
        background-image: url('../img/arrow.svg');
    }
}
.listing-top.with-feature article.top-latest .tag:before {
    background-image: url('../img/arrows.svg');
    height: 9px;
    width: 18px;
    top: 13px;
    right: 10px;
}
.listing-top.with-feature article.top-latest .tag:before {
    content: "";
    position: absolute;
    background-repeat: no-repeat;
    background-size: cover;
}
.listing-top.with-feature article .tag:before {
    content: "";
    position: absolute;
    background-repeat: no-repeat;
    background-size: cover;
}
.listing-top.with-feature article.top-latest .tag:after {
    content: "Latest stories";
    margin-left: 10px;
    margin-right: 36px;
}
.listing-top.with-feature article.top-latest .tag:after {
    content: "";
    -ms-flex-item-align: center;
    -ms-grid-row-align: center;
    align-self: center;
}
.listing-top.with-feature article .tag:after {
    content: "";
    -ms-flex-item-align: center;
    -ms-grid-row-align: center;
    align-self: center;
}
</code>```

答:
.listing-top {
    -js-display: flex;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-flow: row wrap;
    flex-flow: row wrap;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
}
.listing-top.with-feature article.top-latest {
    margin-bottom: 20px;
    position: relative;
    cursor: pointer;
    cursor: hand;
    display: block;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-flow: none;
    flex-flow: none;
}
.listing-top.with-feature article.top-latest .overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 14;
}
.listing-top.with-feature article.top-latest .tag {
    -js-display: flex;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-flow: row nowrap;
    flex-flow: row nowrap;
}
.listing-top.with-feature article.top-latest .tag {
    pointer-events: none;
    position: absolute;
    height: 36px;
    z-index: 15;
    background-color: #fff;
    color: #000;
    text-transform: uppercase;
    font-size: 20px;
    font-family: economica;
    top: 15px;
    left: 0;
    display: none;
}
.listing-top.with-feature article .tag {
    pointer-events: none;
    position: absolute;
    height: 36px;
    z-index: 15;
    background-color: #fff;
    color: #000;
    text-transform: uppercase;
    font-size: 20px;
    font-family: economica;
    top: 15px;
    left: 0;
    display: none;
}
.listing-top.with-feature article.top-latest figure {
    width: 100%;
    height: 0;
    padding-bottom: 55.55556%;
}
.listing-top.with-feature article.top-latest figure {
    -webkit-transition: all .17s;
    transition: all .17s;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: top;
    background-color: #f0f1f2;
    background-blend-mode: multiply;
    margin: 0;
}
.listing-top.with-feature article figure {
    width: 100%;
    height: 0;
    padding-bottom: 55.55556%;
}
.listing-top.with-feature article figure {
    -webkit-transition: all .17s;
    transition: all .17s;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: top;
    background-color: #f0f1f2;
    background-blend-mode: multiply;
    margin: 0;
}
figure {
    margin: 1em 40px;
}
article, aside, details, figcaption, figure, footer, header, main, menu, nav, section, summary {
    display: block;
}
.listing-top.with-feature article.top-latest header {
    background: -webkit-linear-gradient(top,#fff 15px,hsla(210,7%,95%,0));
    background: linear-gradient(180deg,#fff 15px,hsla(210,7%,95%,0));
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff",endColorstr="#00f0f1f2",GradientType=0);
    margin: 15px;
    margin-top: -15px;
    padding: 15px;
    border-bottom: none;
    position: relative;
}
.listing-top.with-feature article header {
    background: -webkit-linear-gradient(top,#fff 15px,hsla(210,7%,95%,0));
    background: linear-gradient(180deg,#fff 15px,hsla(210,7%,95%,0));
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff",endColorstr="#00f0f1f2",GradientType=0);
    margin: 15px;
    margin-top: -15px;
    padding: 15px;
    border-bottom: none;
    position: relative;
}
.listing-top.with-feature article.top-latest footer {
    width: 100%;
    margin-top: -25px;
    bottom: -10px;
}
.listing-top.with-feature article.top-latest footer {
    position: absolute;
    z-index: 15;
}
.listing-top.with-feature article.top-latest:after {
    content: "";
    position: absolute;
    bottom: 0;
    height: 30px;
    width: 100%;
    border: 15px solid #ccc;
    border-top: none;
}
.listing-top.with-feature article:after {
    content: "";
    position: absolute;
    bottom: 0;
    height: 30px;
    width: 100%;
    border: 15px solid #ccc;
    border-top: none;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count {
    background-size: cover;
    width: 34px;
    height: 34px;
    display: block;
    margin: 0 auto;
    text-align: center;
    background-position: 50%;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count .comment-count-number {
    padding: 0;
    margin: 0;
    line-height: 34px;
    font-size: 18px;
    color: #fff;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count {
    font-family: economica;
    color: #fff;
    background-repeat: no-repeat;
    display: block;
    background-image: url('../img/comments.svg');
}
@media (min-width: 1000px) {
    .listing-top.with-feature article.top-latest .tag:before {
        top: 11px;
        height: 14px;
        width: 18px;
        background-image: url('../img/arrow.svg');
    }
}
.listing-top.with-feature article.top-latest .tag:before {
    background-image: url('../img/arrows.svg');
    height: 9px;
    width: 18px;
    top: 13px;
    right: 10px;
}
.listing-top.with-feature article.top-latest .tag:before {
    content: "";
    position: absolute;
    background-repeat: no-repeat;
    background-size: cover;
}
.listing-top.with-feature article .tag:before {
    content: "";
    position: absolute;
    background-repeat: no-repeat;
    background-size: cover;
}
.listing-top.with-feature article.top-latest .tag:after {
    content: "Latest stories";
    margin-left: 10px;
    margin-right: 36px;
}
.listing-top.with-feature article.top-latest .tag:after {
    content: "";
    -ms-flex-item-align: center;
    -ms-grid-row-align: center;
    align-self: center;
}
.listing-top.with-feature article .tag:after {
    content: "";
    -ms-flex-item-align: center;
    -ms-grid-row-align: center;
    align-self: center;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.cohttps://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.cssm/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<section class="listing listing-top with-feature">
        <div class="col-sm-6 form-group">
            <article class="tease top-latest tease-" data-post-id="1069327">

                <div class="tag"></div>
                <figure style="background-image:url('http://i.imgur.com/WDCTb5S.jpg');">
                    <div></div>
                </figure>
                <header>
                    <h2>Galaxy S8 face recognition already defeated with a simple picture</h2>
                    <p class="excerpt">Face unlock feature once again defeated with anything resembling owner's face. </p>

                    <p class="byline" itemprop="author creator" itemscope="" itemtype="#">
                        <span itemprop="name">Author</span>
                        –  <time class="date" data-time="1490974219" datetime="2017-03-31T15:30:19+00:00">3/31/2017, 6:30 PM</time>
                    </p>

                </header>
                <footer>
                    <aside class="comments-hotness ">

                            <span class="comment-count-number">31</span>
                         </aside>

                </footer>
            </article>
        </div>

        <div class="col-sm-6">
            <article class="tease top-latest tease-" data-post-id="1069327">

                <div class="tag"></div>
                <figure style="background-image:url('http://i.imgur.com/WDCTb5S.jpg');">
                    <div></div>
                </figure>
                <header>
                    <h2>Galaxy S8 face recognition already defeated with a simple picture</h2>
                    <p class="excerpt">Face unlock feature once again defeated with anything resembling owner's face. </p>

                    <p class="byline" itemprop="author creator" itemscope="" itemtype="#">
                        <span itemprop="name">Author</span>
                        –  <time class="date" data-time="1490974219" datetime="2017-03-31T15:30:19+00:00">3/31/2017, 6:30 PM</time>
                    </p>

                </header>
                <footer>
                    <aside class="comments-hotness ">

                            <span class="comment-count-number">31</span>
                         </aside>

                </footer>
            </article>
        </div>
    </section></code>```

If you want block height same then we will achieve it while using Jquery.

Take div height $(selector).innerHeight();

Give that height to required div then both div blocks will acheive same height.

Body:
I have 2 columns in bootstrap side-by-side, col-md-4 and col-md-8 but one is taller than the other.

How can I shrink the taller one to match the height of the smaller column?

The css class listing-top is using flex box.

DEMO https://jsfiddle.net/halnex/3dw85L1r/1/

HTML

Galaxy S8 face recognition already defeated with a simple picture

Face unlock feature once again defeated with anything resembling owner's face.

                    Author
                    –  <time class="date" data-time="1490974219" datetime="2017-03-31T15:30:19+00:00">3/31/2017, 6:30 PM</time>

                        31

Galaxy S8 face recognition already defeated with a simple picture

Face unlock feature once again defeated with anything resembling owner's face.

                    Author
                    –  <time class="date" data-time="1490974219" datetime="2017-03-31T15:30:19+00:00">3/31/2017, 6:30 PM</time>

                        31

CSS

.listing-top {
    -js-display: flex;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-flow: row wrap;
    flex-flow: row wrap;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
}
.listing-top.with-feature article.top-latest {
    margin-bottom: 20px;
    position: relative;
    cursor: pointer;
    cursor: hand;
    display: block;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-flow: none;
    flex-flow: none;
}
.listing-top.with-feature article.top-latest .overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 14;
}
.listing-top.with-feature article.top-latest .tag {
    -js-display: flex;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-flow: row nowrap;
    flex-flow: row nowrap;
}
.listing-top.with-feature article.top-latest .tag {
    pointer-events: none;
    position: absolute;
    height: 36px;
    z-index: 15;
    background-color: #fff;
    color: #000;
    text-transform: uppercase;
    font-size: 20px;
    font-family: economica;
    top: 15px;
    left: 0;
    display: none;
}
.listing-top.with-feature article .tag {
    pointer-events: none;
    position: absolute;
    height: 36px;
    z-index: 15;
    background-color: #fff;
    color: #000;
    text-transform: uppercase;
    font-size: 20px;
    font-family: economica;
    top: 15px;
    left: 0;
    display: none;
}
.listing-top.with-feature article.top-latest figure {
    width: 100%;
    height: 0;
    padding-bottom: 55.55556%;
}
.listing-top.with-feature article.top-latest figure {
    -webkit-transition: all .17s;
    transition: all .17s;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: top;
    background-color: #f0f1f2;
    background-blend-mode: multiply;
    margin: 0;
}
.listing-top.with-feature article figure {
    width: 100%;
    height: 0;
    padding-bottom: 55.55556%;
}
.listing-top.with-feature article figure {
    -webkit-transition: all .17s;
    transition: all .17s;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: top;
    background-color: #f0f1f2;
    background-blend-mode: multiply;
    margin: 0;
}
figure {
    margin: 1em 40px;
}
article, aside, details, figcaption, figure, footer, header, main, menu, nav, section, summary {
    display: block;
}
.listing-top.with-feature article.top-latest header {
    background: -webkit-linear-gradient(top,#fff 15px,hsla(210,7%,95%,0));
    background: linear-gradient(180deg,#fff 15px,hsla(210,7%,95%,0));
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff",endColorstr="#00f0f1f2",GradientType=0);
    margin: 15px;
    margin-top: -15px;
    padding: 15px;
    border-bottom: none;
    position: relative;
}
.listing-top.with-feature article header {
    background: -webkit-linear-gradient(top,#fff 15px,hsla(210,7%,95%,0));
    background: linear-gradient(180deg,#fff 15px,hsla(210,7%,95%,0));
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff",endColorstr="#00f0f1f2",GradientType=0);
    margin: 15px;
    margin-top: -15px;
    padding: 15px;
    border-bottom: none;
    position: relative;
}
.listing-top.with-feature article.top-latest footer {
    width: 100%;
    margin-top: -25px;
    bottom: -10px;
}
.listing-top.with-feature article.top-latest footer {
    position: absolute;
    z-index: 15;
}
.listing-top.with-feature article.top-latest:after {
    content: "";
    position: absolute;
    bottom: 0;
    height: 30px;
    width: 100%;
    border: 15px solid #ccc;
    border-top: none;
}
.listing-top.with-feature article:after {
    content: "";
    position: absolute;
    bottom: 0;
    height: 30px;
    width: 100%;
    border: 15px solid #ccc;
    border-top: none;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count {
    background-size: cover;
    width: 34px;
    height: 34px;
    display: block;
    margin: 0 auto;
    text-align: center;
    background-position: 50%;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count .comment-count-number {
    padding: 0;
    margin: 0;
    line-height: 34px;
    font-size: 18px;
    color: #fff;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count {
    font-family: economica;
    color: #fff;
    background-repeat: no-repeat;
    display: block;
    background-image: url('../img/comments.svg');
}
@media (min-width: 1000px) {
    .listing-top.with-feature article.top-latest .tag:before {
        top: 11px;
        height: 14px;
        width: 18px;
        background-image: url('../img/arrow.svg');
    }
}
.listing-top.with-feature article.top-latest .tag:before {
    background-image: url('../img/arrows.svg');
    height: 9px;
    width: 18px;
    top: 13px;
    right: 10px;
}
.listing-top.with-feature article.top-latest .tag:before {
    content: "";
    position: absolute;
    background-repeat: no-repeat;
    background-size: cover;
}
.listing-top.with-feature article .tag:before {
    content: "";
    position: absolute;
    background-repeat: no-repeat;
    background-size: cover;
}
.listing-top.with-feature article.top-latest .tag:after {
    content: "Latest stories";
    margin-left: 10px;
    margin-right: 36px;
}
.listing-top.with-feature article.top-latest .tag:after {
    content: "";
    -ms-flex-item-align: center;
    -ms-grid-row-align: center;
    align-self: center;
}
.listing-top.with-feature article .tag:after {
    content: "";
    -ms-flex-item-align: center;
    -ms-grid-row-align: center;
    align-self: center;
}

Body:
.listing-top {
    -js-display: flex;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-flow: row wrap;
    flex-flow: row wrap;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
}
.listing-top.with-feature article.top-latest {
    margin-bottom: 20px;
    position: relative;
    cursor: pointer;
    cursor: hand;
    display: block;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-flow: none;
    flex-flow: none;
}
.listing-top.with-feature article.top-latest .overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 14;
}
.listing-top.with-feature article.top-latest .tag {
    -js-display: flex;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-flow: row nowrap;
    flex-flow: row nowrap;
}
.listing-top.with-feature article.top-latest .tag {
    pointer-events: none;
    position: absolute;
    height: 36px;
    z-index: 15;
    background-color: #fff;
    color: #000;
    text-transform: uppercase;
    font-size: 20px;
    font-family: economica;
    top: 15px;
    left: 0;
    display: none;
}
.listing-top.with-feature article .tag {
    pointer-events: none;
    position: absolute;
    height: 36px;
    z-index: 15;
    background-color: #fff;
    color: #000;
    text-transform: uppercase;
    font-size: 20px;
    font-family: economica;
    top: 15px;
    left: 0;
    display: none;
}
.listing-top.with-feature article.top-latest figure {
    width: 100%;
    height: 0;
    padding-bottom: 55.55556%;
}
.listing-top.with-feature article.top-latest figure {
    -webkit-transition: all .17s;
    transition: all .17s;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: top;
    background-color: #f0f1f2;
    background-blend-mode: multiply;
    margin: 0;
}
.listing-top.with-feature article figure {
    width: 100%;
    height: 0;
    padding-bottom: 55.55556%;
}
.listing-top.with-feature article figure {
    -webkit-transition: all .17s;
    transition: all .17s;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: top;
    background-color: #f0f1f2;
    background-blend-mode: multiply;
    margin: 0;
}
figure {
    margin: 1em 40px;
}
article, aside, details, figcaption, figure, footer, header, main, menu, nav, section, summary {
    display: block;
}
.listing-top.with-feature article.top-latest header {
    background: -webkit-linear-gradient(top,#fff 15px,hsla(210,7%,95%,0));
    background: linear-gradient(180deg,#fff 15px,hsla(210,7%,95%,0));
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff",endColorstr="#00f0f1f2",GradientType=0);
    margin: 15px;
    margin-top: -15px;
    padding: 15px;
    border-bottom: none;
    position: relative;
}
.listing-top.with-feature article header {
    background: -webkit-linear-gradient(top,#fff 15px,hsla(210,7%,95%,0));
    background: linear-gradient(180deg,#fff 15px,hsla(210,7%,95%,0));
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff",endColorstr="#00f0f1f2",GradientType=0);
    margin: 15px;
    margin-top: -15px;
    padding: 15px;
    border-bottom: none;
    position: relative;
}
.listing-top.with-feature article.top-latest footer {
    width: 100%;
    margin-top: -25px;
    bottom: -10px;
}
.listing-top.with-feature article.top-latest footer {
    position: absolute;
    z-index: 15;
}
.listing-top.with-feature article.top-latest:after {
    content: "";
    position: absolute;
    bottom: 0;
    height: 30px;
    width: 100%;
    border: 15px solid #ccc;
    border-top: none;
}
.listing-top.with-feature article:after {
    content: "";
    position: absolute;
    bottom: 0;
    height: 30px;
    width: 100%;
    border: 15px solid #ccc;
    border-top: none;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count {
    background-size: cover;
    width: 34px;
    height: 34px;
    display: block;
    margin: 0 auto;
    text-align: center;
    background-position: 50%;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count .comment-count-number {
    padding: 0;
    margin: 0;
    line-height: 34px;
    font-size: 18px;
    color: #fff;
}
.listing-top.with-feature article.top-latest footer .comments-hotness .comment-count {
    font-family: economica;
    color: #fff;
    background-repeat: no-repeat;
    display: block;
    background-image: url('../img/comments.svg');
}
@media (min-width: 1000px) {
    .listing-top.with-feature article.top-latest .tag:before {
        top: 11px;
        height: 14px;
        width: 18px;
        background-image: url('../img/arrow.svg');
    }
}
.listing-top.with-feature article.top-latest .tag:before {
    background-image: url('../img/arrows.svg');
    height: 9px;
    width: 18px;
    top: 13px;
    right: 10px;
}
.listing-top.with-feature article.top-latest .tag:before {
    content: "";
    position: absolute;
    background-repeat: no-repeat;
    background-size: cover;
}
.listing-top.with-feature article .tag:before {
    content: "";
    position: absolute;
    background-repeat: no-repeat;
    background-size: cover;
}
.listing-top.with-feature article.top-latest .tag:after {
    content: "Latest stories";
    margin-left: 10px;
    margin-right: 36px;
}
.listing-top.with-feature article.top-latest .tag:after {
    content: "";
    -ms-flex-item-align: center;
    -ms-grid-row-align: center;
    align-self: center;
}
.listing-top.with-feature article .tag:after {
    content: "";
    -ms-flex-item-align: center;
    -ms-grid-row-align: center;
    align-self: center;
}

<link href="https://maxcdn.bootstrapcdn.cohttps://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.cssm/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<section class="listing listing-top with-feature">
        <div class="col-sm-6 form-group">
            <article class="tease top-latest tease-" data-post-id="1069327">

                <a class="overlay" href="#"></a>
                <div class="tag"></div>
                <figure style="background-image:url('http://i.imgur.com/WDCTb5S.jpg');">
                    <div></div>
                </figure>
                <header>
                    <h2><a href="#">Galaxy S8 face recognition already defeated with a simple picture</a></h2>
                    <p class="excerpt">Face unlock feature once again defeated with anything resembling owner's face. </p>

                    <p class="byline" itemprop="author creator" itemscope="" itemtype="#">
                        <a itemprop="url" href="#"><span itemprop="name">Author</span></a>
                        –  <time class="date" data-time="1490974219" datetime="2017-03-31T15:30:19+00:00">3/31/2017, 6:30 PM</time>
                    </p>

                </header>
                <footer>
                    <aside class="comments-hotness ">
                        <a title="25 posters participating" class="comment-count icon-comment-bubble-up" href="#">
                            <span class="comment-count-number">31</span>
                        </a> </aside>

                </footer>
            </article>
        </div>

        <div class="col-sm-6">
            <article class="tease top-latest tease-" data-post-id="1069327">

                <a class="overlay" href="#"></a>
                <div class="tag"></div>
                <figure style="background-image:url('http://i.imgur.com/WDCTb5S.jpg');">
                    <div></div>
                </figure>
                <header>
                    <h2><a href="#">Galaxy S8 face recognition already defeated with a simple picture</a></h2>
                    <p class="excerpt">Face unlock feature once again defeated with anything resembling owner's face. </p>

                    <p class="byline" itemprop="author creator" itemscope="" itemtype="#">
                        <a itemprop="url" href="#"><span itemprop="name">Author</span></a>
                        –  <time class="date" data-time="1490974219" datetime="2017-03-31T15:30:19+00:00">3/31/2017, 6:30 PM</time>
                    </p>

                </header>
                <footer>
                    <aside class="comments-hotness ">
                        <a title="25 posters participating" class="comment-count icon-comment-bubble-up" href="#">
                            <span class="comment-count-number">31</span>
                        </a> </aside>

                </footer>
            </article>
        </div>
    </section>

If you want block height same then we will achieve it while using Jquery.

Take div height $(selector).innerHeight();

Give that height to required div then both div blocks will acheive same height.


问:
AngularFire2 - using access token from Google Auth for Google APIs
Google Authentication through AngularFire2 returns the Firebase access token, but not the Google access token for use on Google APIs.  What's the proper way to get the access token from the AngularFire2 auth?

Angular: 2.4.9

Firebase: 3.5.2

AngularFire: 2.0.0-beta.8

Here's a plunkr:

http://plnkr.co/edit/qIbtcp?p=preview

You'll notice in the constructor:

```<code>constructor(af: AngularFire, public auth$: AngularFireAuth, public http:Http) {

      auth$.subscribe((state: FirebaseAuthState) => {
        if(state){
          this.signedIn = true
        }
    });

    firebase.auth()
      .getRedirectResult()
      .then((result) => {
        console.log('result', result);
        if (result.credential) {
          // This gives you a Google Access Token.
          var token = result.credential.accessToken;
          console.log('token',token)
          this.getPeople(token)
          .subscribe(
            people => console.log('people',people),
            error =>  console.log(error));
        }
        var user = result.user;
      })
      .catch(err => console.log(err));
  }
</code>```

Where I call firebase.auth() is where I try to get the Google Access Token.  However on first login, I get this error:

```<code>{
error: {
code: 403,
message: "Request had insufficient authentication scopes.",
status: "PERMISSION_DENIED"
}
}
</code>```

I know this shouldn't happen because I tried the same setup with strictly Firebase (no AngularFire2), in this example:

https://embed.plnkr.co/zxOfRZ1PDDb7ee5qzIKW/

So is there an issue with sharing auth tokens between AngularFire and just Firebase?  Does anyone have an example of this working?

答:
Found a similar issue on StackOverflow:

Using Firebase Auth to access the Google Calendar API

I ended up using the same approach, it seems that you need to manually use the Google API's Javascript client, and use that credential to sign in with Firebase.

Body:
Google Authentication through AngularFire2 returns the Firebase access token, but not the Google access token for use on Google APIs.  What's the proper way to get the access token from the AngularFire2 auth?

Angular: 2.4.9

Firebase: 3.5.2

AngularFire: 2.0.0-beta.8

Here's a plunkr:

http://plnkr.co/edit/qIbtcp?p=preview

You'll notice in the constructor:

constructor(af: AngularFire, public auth$: AngularFireAuth, public http:Http) {

      auth$.subscribe((state: FirebaseAuthState) => {
        if(state){
          this.signedIn = true
        }
    });

    firebase.auth()
      .getRedirectResult()
      .then((result) => {
        console.log('result', result);
        if (result.credential) {
          // This gives you a Google Access Token.
          var token = result.credential.accessToken;
          console.log('token',token)
          this.getPeople(token)
          .subscribe(
            people => console.log('people',people),
            error =>  console.log(error));
        }
        var user = result.user;
      })
      .catch(err => console.log(err));
  }

Where I call firebase.auth() is where I try to get the Google Access Token.  However on first login, I get this error:

{
error: {
code: 403,
message: "Request had insufficient authentication scopes.",
status: "PERMISSION_DENIED"
}
}

I know this shouldn't happen because I tried the same setup with strictly Firebase (no AngularFire2), in this example:

https://embed.plnkr.co/zxOfRZ1PDDb7ee5qzIKW/

So is there an issue with sharing auth tokens between AngularFire and just Firebase?  Does anyone have an example of this working?


问:
how to debug python click cli application?
I have built a cli application using the click library in python. There is no documentation on how to debug commands. </p>

<p>Without click, its easy to just debug python files in IDE, but when we use click, the commands need to be run through console_scripts setup in setup.py. </p>

答:
This is not well documented, but you can call your command functions directly, and thus can run the code in a debugger:

Sample Code:

```<code>import click

@click.command()
@click.option('--my_arg', default=1, help='a number')
def my_command(my_arg):
    click.echo("my_arg='%d'" % my_arg)

if __name__ == '__main__':
    my_command(['--my_arg', '3'])
</code>```

Result:

```<code>my_arg='3'
</code>```

Body:
I have built a cli application using the click library in python. There is no documentation on how to debug commands.

Without click, its easy to just debug python files in IDE, but when we use click, the commands need to be run through console_scripts setup in setup.py.

Body:
This is not well documented, but you can call your command functions directly, and thus can run the code in a debugger:

Sample Code:

import click

@click.command()
@click.option('--my_arg', default=1, help='a number')
def my_command(my_arg):
    click.echo("my_arg='%d'" % my_arg)

if __name__ == '__main__':
    my_command(['--my_arg', '3'])

Result:

my_arg='3'


问:
How at other way transfer the message from one PHP page to other?
I just transfer the message from page1.php to page2.php like this:

page1.php:

```<code>header('Location: admin.php?message=1');
</code>```

page2.php:

```<code>if (isset($_GET["message"]))
echo "Login fail, please try again.";
</code>```

How at other way transfer the message from one PHP page to other and what is the best way?

答:
This is a good enough approach, the other is using sessions:
The contents of page1.php:

```<code>session_start();
$_SESSION['message'] = "Login fail, please try again.";
header('Location: admin.php');
</code>```

The contents of page2.php would be something like:

```<code>session_start();
if (isset($_SESSION["message"]))
{
    echo $_SESSION['message'];
    unset($_SESSION['message']);
}
</code>```

Body:
I just transfer the message from page1.php to page2.php like this:

page1.php:

header('Location: admin.php?message=1');

page2.php:

if (isset($_GET["message"]))
echo "Login fail, please try again.";

How at other way transfer the message from one PHP page to other and what is the best way?

Body:
This is a good enough approach, the other is using sessions:
The contents of page1.php:

session_start();
$_SESSION['message'] = "Login fail, please try again.";
header('Location: admin.php');

The contents of page2.php would be something like:

session_start();
if (isset($_SESSION["message"]))
{
    echo $_SESSION['message'];
    unset($_SESSION['message']);
}


答:
Integer i = 'a' just wraps int i ='a'.  Since 'a' is not an int it throws an error.

Likewise, Character ch2 = 97 wraps char ch2 = 97.  However, 97 is an valid char!  It represents the character "a".  Example:

```<code>System.out.println((char) 97); //Output: a
</code>```

Title: Implicit conversion in wrapper class

Body:
Integer i = 'a' just wraps int i ='a'.  Since 'a' is not an int it throws an error.

Likewise, Character ch2 = 97 wraps char ch2 = 97.  However, 97 is an valid char!  It represents the character "a".  Example:

System.out.println((char) 97); //Output: a


问:
can't find an easy way to display ion-radio icon to the left
In the ion-icon directive, the icon for the selected item is displayed at the right by defualt, there is an easy way to displayed at the left instead? thank you</p>

```<code> <ion-list>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'A'">Bogotá</ion-radio>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'B'">Cali</ion-radio>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'C'">Medellin</ion-radio>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'D'">Bucaramanga</ion-radio>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'E'">Cartagena</ion-radio>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'F'">San Andres</ion-radio>
</ion-list>
</code>```

答:
I ended up using this:</p>

```<code><ion-radio ng-model="model" ng-repeat="item in items" ng-value="item.value" ng-click="select(item)" name="{{name}}">
                <i class="icon {{item.icon}}"></i>
                <span>{{item.label}}</span>
                <p ng-if="item.desc">{{item.desc}}</p>
            </ion-radio>
</code>```

Body:
In the ion-icon directive, the icon for the selected item is displayed at the right by defualt, there is an easy way to displayed at the left instead? thank you

 <ion-list>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'A'">Bogotá</ion-radio>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'B'">Cali</ion-radio>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'C'">Medellin</ion-radio>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'D'">Bucaramanga</ion-radio>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'E'">Cartagena</ion-radio>
        <ion-radio ng-model="choice" icon="icon ion-android-pin" ng-value="'F'">San Andres</ion-radio>
</ion-list>

Body:
I ended up using this:

<ion-radio ng-model="model" ng-repeat="item in items" ng-value="item.value" ng-click="select(item)" name="{{name}}">
                <i class="icon {{item.icon}}"></i>
                <span>{{item.label}}</span>
                <p ng-if="item.desc">{{item.desc}}</p>
            </ion-radio>


问:
Win 10 bash shell and highlighting of the directories in console
I implemented bash shell into my windows 10 as "Bash on Ubuntu on Windows".

And now I just want to remove the highlight from folders in console.

Additionally I use bashIt library to change design of my console but I don't know how to change that hightlight :(

答:
I find an answer and if somebody need it there is solution.

You need to add this :

```<code>export LS_COLORS=$LS_COLORS:'ow=1;34:';
</code>```

into your .bashrc file

More information here :
http://www.bigsoft.co.uk/blog/index.php/2008/04/11/configuring-ls_colors

or here :
https://askubuntu.com/questions/466198/how-do-i-change-the-color-for-directories-with-ls-in-the-console

ContentLicense: CC BY-SA 4.0

Body:
I find an answer and if somebody need it there is solution.

You need to add this :

export LS_COLORS=$LS_COLORS:'ow=1;34:';

into your .bashrc file

More information here :
http://www.bigsoft.co.uk/blog/index.php/2008/04/11/configuring-ls_colors

or here :
https://askubuntu.com/questions/466198/how-do-i-change-the-color-for-directories-with-ls-in-the-console


问:
Add new colors along with custom theme colors angular2 material
how to add new colors in Angular 2 material.

Its specified in the ng2-material docs: color: "primary"|"accent"|"warn" are accepted i want to add something like "progressbarcolor" other than the colors defined in my custom theme for angular2 material.

For eg :

```<code> <md-progress-bar color="progressbarcolor">    </md-progress-bar>
</code>```

答:
You have two options:

Custom theme

recommended

create your own custom theme with custom colors with this guide

Override the style

possible, not recommended but sometimes used for example when placing white loader inside a colored button.

<md-progress-bar class="custom-color"></md-progress-bar>

/deep/ md-progress-circle.custom-color path {
   stroke: $progress-circle-custom-color;
 }

the /deep/ keyword ignores the shadow DOM so be careful using it, it is also deprecated but not yet removed

you can place the code in your global style file and therefore not use the deep keyword

Body:
how to add new colors in Angular 2 material.

Its specified in the ng2-material docs: color: "primary"|"accent"|"warn" are accepted i want to add something like "progressbarcolor" other than the colors defined in my custom theme for angular2 material.

For eg :

 <md-progress-bar color="progressbarcolor">    </md-progress-bar>


问:
how to prepare transactional dataset for association rule mining in RapidMiner?
I have a dataset like this:

```<code>abelia,fl,nc
esculentus,ct,dc,fl,il,ky,la,md,mi,ms,nc,sc,va,pr,vi
abelmoschus moschatus,hi,pr*
</code>```

dataset link:

My dataset haven't any attribute declaration. I want apply association rules on my dataset. I want to be like this dataset.

```<code>plant   fl  nc  ct  dc  .....
abelia  1   1   0   0
.....
</code>```

答:
I did my work with this python script:</p>

```<code>import csv

abbrs = ['states', 'ab', 'ak', 'ar', 'az', 'ca', 'co', 'ct',
     'de', 'dc', 'of', 'fl', 'ga', 'hi', 'id', 'il', 'in',
     'ia', 'ks', 'ky', 'la', 'me', 'md', 'ma', 'mi', 'mn',
     'ms', 'mo', 'mt', 'ne', 'nv', 'nh', 'nj', 'nm', 'ny',
     'nc', 'nd', 'oh', 'ok', 'or', 'pa', 'pr', 'ri', 'sc',
     'sd', 'tn', 'tx', 'ut', 'vt', 'va', 'vi', 'wa', 'wv',
     'wi', 'wy', 'al', 'bc', 'mb', 'nb', 'lb', 'nf', 'nt',
     'ns', 'nu', 'on', 'qc', 'sk', 'yt']

with open("plants.data.txt", encoding = "ISO-8859-1") as f1, open("plants.data.csv", "a") as f2:
csv_f2 = csv.writer(f2, delimiter=',')
csv_f2.writerow(abbrs)
csv_f1 = csv.reader(f1)
for row in csv_f1:
    new_row = [row[0]]
    for abbr in abbrs:
        if abbr in row:
            new_row.append(1)
        else:
            new_row.append(0)
    csv_f2.writerow(new_row)
</code>```

Body:
I have a dataset like this:

abelia,fl,nc
esculentus,ct,dc,fl,il,ky,la,md,mi,ms,nc,sc,va,pr,vi
abelmoschus moschatus,hi,pr*

dataset link:

My dataset haven't any attribute declaration. I want apply association rules on my dataset. I want to be like this dataset.

plant   fl  nc  ct  dc  .....
abelia  1   1   0   0
.....

Body:
I did my work with this python script:

import csv

abbrs = ['states', 'ab', 'ak', 'ar', 'az', 'ca', 'co', 'ct',
     'de', 'dc', 'of', 'fl', 'ga', 'hi', 'id', 'il', 'in',
     'ia', 'ks', 'ky', 'la', 'me', 'md', 'ma', 'mi', 'mn',
     'ms', 'mo', 'mt', 'ne', 'nv', 'nh', 'nj', 'nm', 'ny',
     'nc', 'nd', 'oh', 'ok', 'or', 'pa', 'pr', 'ri', 'sc',
     'sd', 'tn', 'tx', 'ut', 'vt', 'va', 'vi', 'wa', 'wv',
     'wi', 'wy', 'al', 'bc', 'mb', 'nb', 'lb', 'nf', 'nt',
     'ns', 'nu', 'on', 'qc', 'sk', 'yt']

with open("plants.data.txt", encoding = "ISO-8859-1") as f1, open("plants.data.csv", "a") as f2:
csv_f2 = csv.writer(f2, delimiter=',')
csv_f2.writerow(abbrs)
csv_f1 = csv.reader(f1)
for row in csv_f1:
    new_row = [row[0]]
    for abbr in abbrs:
        if abbr in row:
            new_row.append(1)
        else:
            new_row.append(0)
    csv_f2.writerow(new_row)