问:
Tensorflow : Improve a Tensorflow model on false predictions loaded from checkpoint
After training a network and out-putting a model, is it possible to feed single false predictions into the network after loading the first model from a checkpoint to help improve performance.

The current solutions I have tried so far have involved:

```<code>    with tf.Session() as sess:

        #Try new method...
        saver = tf.train.import_meta_graph('./model2.ckpt.meta')
        saver.restore(sess, './model2.ckpt')
        graph = tf.get_default_graph()

        x_1 = graph.get_tensor_by_name("x:0")
        y_1 = graph.get_tensor_by_name("y_:0")
        train_step = graph.get_tensor_by_name("train_step:0")

        trX = image
        trY = np.eye(10)[digit]

        sess.run(train_step, feed_dict={x: trX, y_: [trY],
                            keep_prob:0.5})

        new_saver = tf.train.Saver()
        new_saver.save(sess, "./model2.ckpt")
        sess.close()

        trX = image
        trY = np.eye(10)[digit]

        sess.run(train_step, feed_dict={x: trX, y_: [trY],
                            keep_prob:0.5})
</code>```

Or this solution:

```<code>    with tf.Session() as sess:

        saver = tf.train.Saver()
        saver.restore(sess, "./model2.ckpt")

        trX = image
        trY = np.eye(10)[digit]

        sess.run(train_step, feed_dict={x: trX, y_: [trY],
                            keep_prob:0.5})
</code>```

Both have resulted in the network loosing the ability to correctly predict a previously image, that was being predicted correctly.

答:
It turns out that the issue was with the training step, not the restoring of the weights. After loading the weights and running the training step the weights were showing NAN for every value. This issue was resolved by clipping the values in the cross entropy function.

The original cross entropy function was:
cross_entropy = -tf.reduce_sum(y_*tf.log(y_conv))

Which was changed into:
cross_entropy = -tf.reduce_sum(y_*tf.log(tf.clip_by_value(y_conv,1e-10,1.0)))

Body:
After training a network and out-putting a model, is it possible to feed single false predictions into the network after loading the first model from a checkpoint to help improve performance.

The current solutions I have tried so far have involved:

    with tf.Session() as sess:

        #Try new method...
        saver = tf.train.import_meta_graph('./model2.ckpt.meta')
        saver.restore(sess, './model2.ckpt')
        graph = tf.get_default_graph()

        x_1 = graph.get_tensor_by_name("x:0")
        y_1 = graph.get_tensor_by_name("y_:0")
        train_step = graph.get_tensor_by_name("train_step:0")

        trX = image
        trY = np.eye(10)[digit]

        sess.run(train_step, feed_dict={x: trX, y_: [trY],
                            keep_prob:0.5})

        new_saver = tf.train.Saver()
        new_saver.save(sess, "./model2.ckpt")
        sess.close()

        trX = image
        trY = np.eye(10)[digit]

        sess.run(train_step, feed_dict={x: trX, y_: [trY],
                            keep_prob:0.5})

Or this solution:

    with tf.Session() as sess:

        saver = tf.train.Saver()
        saver.restore(sess, "./model2.ckpt")

        trX = image
        trY = np.eye(10)[digit]

        sess.run(train_step, feed_dict={x: trX, y_: [trY],
                            keep_prob:0.5})

Both have resulted in the network loosing the ability to correctly predict a previously image, that was being predicted correctly.


来源: stackexchange

问:
MVC Model require true
Is there a way through data annotations to require that a boolean property be set to true?</p>

```<code>public class MyAwesomeObj{
    public bool ThisMustBeTrue{get;set;}
}
</code>```

答:
You could either create your own attribute or use the CustomValidationAttribute.

This is how you would use the CustomValidationAttribute:

```<code>[CustomValidation(typeof(BoolValidation), "ValidateBool")]
</code>```

where BoolValidation is defined as:

```<code>public class BoolValidation
{
  public static ValidationResult ValidateBool(bool boolToBeTrue)
  {
    if (boolToBeTrue)
    {
      return ValidationResult.Success;
    }
    else
    {
      return new ValidationResult(
          "Bool must be true.");
    }
  }
</code>```

ContentLicense: CC BY-SA 2.5

Title: MVC Model require true

Body:
Is there a way through data annotations to require that a boolean property be set to true?

public class MyAwesomeObj{
    public bool ThisMustBeTrue{get;set;}
}

Body:
You could either create your own attribute or use the CustomValidationAttribute.

This is how you would use the CustomValidationAttribute:

[CustomValidation(typeof(BoolValidation), "ValidateBool")]

where BoolValidation is defined as:

public class BoolValidation
{
  public static ValidationResult ValidateBool(bool boolToBeTrue)
  {
    if (boolToBeTrue)
    {
      return ValidationResult.Success;
    }
    else
    {
      return new ValidationResult(
          "Bool must be true.");
    }
  }


问:
How to make a drop shadow effect on a label in Swift?
I can't figure out how to code a drop shadow on a label. I have a score label that changes so just photoshopping text with shadows wont be possible. I need to code it so it automatically has a blurry shadow behind the text at all times. Can anyone come with some examples or help?

People saying this is a duplicate, the "duplicate" is about drop shadows on UIView, mine is about UILabel. It's not the same thing.

答:
You can write an extension and use it. Place the extension code outside of class ViewController.

I like subtle shadow.

```<code>extension UILabel {
    func textDropShadow() {
        self.layer.masksToBounds = false
        self.layer.shadowRadius = 2.0
        self.layer.shadowOpacity = 0.2
        self.layer.shadowOffset = CGSize(width: 1, height: 2)
    }

    static func createCustomLabel() -> UILabel {
        let label = UILabel()
        label.textDropShadow()
        return label
    }
}
</code>```

On your label simply call this method

```<code>myLabel.textDropShadow()
</code>```

ContentLicense: CC BY-SA 3.0

Body:
You can write an extension and use it. Place the extension code outside of class ViewController.

I like subtle shadow.

extension UILabel {
    func textDropShadow() {
        self.layer.masksToBounds = false
        self.layer.shadowRadius = 2.0
        self.layer.shadowOpacity = 0.2
        self.layer.shadowOffset = CGSize(width: 1, height: 2)
    }

    static func createCustomLabel() -> UILabel {
        let label = UILabel()
        label.textDropShadow()
        return label
    }
}

On your label simply call this method

myLabel.textDropShadow()

ContentLicense: CC BY-SA 4.0


问:
Android N Preview dlopen() "has no section headers" Error
I compressed my Android APP's libs with UPX. When run at Android N Priview5 devices, there's an error : " dlopen failed: xxx.so has no section headers".

I find a changelog of Android Linker :
http://android-developers.blogspot.com/2016/06/android-changes-for-ndk-developers.html

It says "Each ELF file has additional information contained in the section headers. These headers must be present now, because the dynamic linker uses them for sanity checking. "

But after compressed whit UPX, the ELF's section headers is missing, how can I solve this problem.

ELF Header:

Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00

Class:                             ELF32

Data:                              2's complement, little endian

Version:                           1 (current)

OS/ABI:                            UNIX - System V

ABI Version:                       0

Type:                              DYN (Shared object file)

Machine:                           ARM

Version:                           0x1

Entry point address:               0x0

Start of program headers:          52 (bytes into file)

Start of section headers:          0 (bytes into file)

Flags:                             0x5000000, Version5 EABI

Size of this header:               52 (bytes)

Size of program headers:           32 (bytes)

Number of program headers:         7

Size of section headers:           0 (bytes)

Number of section headers:         0

Section header string table index: 0

答:
https://github.com/upx/upx/issues/65

you can add a parameter:

```<code>--android-shlib
</code>```

Body:
https://github.com/upx/upx/issues/65

you can add a parameter:

--android-shlib


问:
Codeigniter select join giving duplicate results
Hi everyone so I am having trouble of creating a query in codeigniter model which will give me this result. So far I have these tables on my database. and I'm trying using join and it's not working for me. It will just display duplicate songs and different publisher/writer. Here's my current query from my model.

```<code>public function get_songs_in_playlist($playlist_id)
{
    $this->db->select(
        "si.song_info_file_name,
        si.song_info_revised_file_name,
        a.artist_name,
        si.song_info_id as songinfoid,
        array_to_string(array_agg(c.composer_name),'/'),
        array_to_string(array_agg(p.publisher_name),'/'),
        array_to_string(array_agg(st.tag_name),',')"
    );
    $this->db->from('songs_in_playlist sp');
    $this->db->join('song_info si', 'sp.song_info_id = si.song_info_id', 'left');
    $this->db->join('original_artist a', 'si.artist_id = a.artist_id', 'left');
    $this->db->join('composer c', 'si.composer_id = c.composer_id', 'left');
    $this->db->join('publisher p', 'si.publisher_id = p.publisher_id', 'left');
    $this->db->join('song_info_tags sit', 'si.song_info_id = sit.song_info_id', 'left');
    $this->db->join('song_tags st', 'st.tag_id = sit.tag_id', 'left');
    $this->db->where('sp.playlist_id', $playlist_id);
    $this->db->group_by(array("si.song_info_id", "a.artist_name", "c.composer_name" , "p.publisher_name" ));

    $query = $this->db->get();

    return $query->result_array();

}
</code>```

Song Table

```<code>song_info_id   song_name
1              songA
</code>```

Publisher Table

```<code>publisher_id   publisher_name
1              publisherA
2              publisherB
</code>```

Writer Table

```<code>writer_id      writer_name     song_info_id    publisher_id
1              writerA         1               1
2              writerB         1               2
</code>```

Result should be:

```<code>Song Name      Writers                Publishers
SongA          writerA, writerB       publisherA, publisherB
</code>```

Current result from join:

```<code>Song Name      Writers                Publishers
SongA          writerA                publisherA
SongA          writerB                publisherB
</code>```

Results in array

```<code>Array (
    [0] => Array (
        [song_info_file_name] => Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [song_info_revised_file_name] => 1510657326_Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [status_artist_name] => Cartoon (feat. Daniel Levi)
        [songinfoid] => 133 [title] => On & On (feat. Daniel Levi)
        [array_to_string] =>
    )
    [1] => Array (
        [song_info_file_name] => Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [song_info_revised_file_name] => 1510657326_Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [status_artist_name] => American Authors
        [songinfoid] => 133
        [title] => On & On (feat. Daniel Levi)
        [array_to_string] =>
    )
    [2] => Array (
        [song_info_file_name] => 01-Reverie_(feat__King_Deco).mp3
        [song_info_revised_file_name] => 1510728747_01-Reverie_(feat__King_Deco).mp3
        [status_artist_name] => Illenium
        [songinfoid] => 136
        [title] => Reverie (feat. King Deco) [array_to_string] =>
        )
    [3] => Array (
        [song_info_file_name] => 01-Reverie_(feat__King_Deco).mp3
        [song_info_revised_file_name] => 1510728747_01-Reverie_(feat__King_Deco).mp3
        [status_artist_name] => Cartoon (feat. Daniel Levi)
        [songinfoid] => 136
        [title] => Reverie (feat. King Deco)
        [array_to_string] =>
    )
    [4] => Array (
        [song_info_file_name] => 01-Reverie_(feat__King_Deco).mp3
        [song_info_revised_file_name] => 1510728747_01-Reverie_(feat__King_Deco).mp3
        [status_artist_name] => American Authors
        [songinfoid] => 136
        [title] => Reverie (feat. King Deco)
        [array_to_string] =>
    )
    [5] => Array (
        [song_info_file_name] => Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [song_info_revised_file_name] => 1510657326_Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [status_artist_name] => Illenium
        [songinfoid] => 133
        [title] => On & On (feat. Daniel Levi)
        [array_to_string] =>
    )
    [6] => Array (
        [song_info_file_name] => American_Authors_-_Best_Day_Of_My_Life.mp3
        [song_info_revised_file_name] => 1510540526_American_Authors_-_Best_Day_Of_My_Life.mp3
        [status_artist_name] => Cartoon (feat. Daniel Levi)
        [songinfoid] => 134
        [title] => Best Day of My Life
        [array_to_string] => Mix, Half, Alternative, Mid
    )
    [7] => Array (
        [song_info_file_name] => American_Authors_-_Best_Day_Of_My_Life.mp3
        [song_info_revised_file_name] => 1510540526_American_Authors_-_Best_Day_Of_My_Life.mp3
        [status_artist_name] => American Authors
        [songinfoid] => 134
        [title] => Best Day of My Life [array_to_string] => Mix, Half, Alternative, Mid
    )
    [8] => Array (
        [song_info_file_name] => American_Authors_-_Best_Day_Of_My_Life.mp3
        [song_info_revised_file_name] => 1510540526_American_Authors_-_Best_Day_Of_My_Life.mp3
        [status_artist_name] => Illenium
        [songinfoid] => 134
        [title] => Best Day of My Life
        [array_to_string] => Mix, Mix, Half, Half, Alternative, Alternative, Mid, Mid
    )
)
</code>```

答:
Well after a few minutes of brain storming I found a way to be able to fix this one. Thank you for those who commented. btw sorry to tag mysql but I was using postgresql. here's my solution for future purposes.</p>

```<code> public function get_shareable_songs_playlist($playlist_id)
{
    $this->db->select("si.songinfoid,
    si.filename,
    si.revised_filename,
    si.title,

    array_to_string(
        ARRAY(
            select status_artist_name from status s where s.song_info_id = si.songinfoid
        ),

    '/'
    ) AS artist,

    array_to_string(
        ARRAY(
            select c.composer_name from composer c, song_composer sc where c.composer_id = sc.composer_id AND sc.song_info_id = si.songinfoid
        ),

    '/'
    ) AS composer,

    array_to_string(
        ARRAY(
            select p.publisher_name from publisher p, composer c, song_composer sc where p.publisher_id = c.publisher_id AND c.composer_id = sc.composer_id AND sc.song_info_id = si.songinfoid
        ),

    '/'
    ) AS publisher,

    array_to_string(
        ARRAY(
            select s.tag_name from song_tags s, song_info_tags sit where s.tag_id = sit.tag_id AND sit.song_info_id = si.songinfoid AND sit.info_tag_delete_flag = 0
        ),

    '/'
    ) AS tags,
    sp.playlist_id");
    $this->db->from("(SELECT song_info_id AS songinfoid, song_info_file_name AS filename, song_info_revised_file_name AS revised_filename, song_info_original_title AS title FROM song_info si GROUP BY song_info_id)si");
    $this->db->join('songs_in_playlist sp', 'sp.song_info_id = si.songinfoid');
    $this->db->join('playlist play', 'sp.playlist_id = play.playlist_id');
$this->db->where('sp.playlist_id', $playlist_id);
$this->db->where('play.playlist_share', 1);
$query = $this->db->get();

return $query->result_array();
}
</code>```

Body:
Hi everyone so I am having trouble of creating a query in codeigniter model which will give me this result. So far I have these tables on my database. and I'm trying using join and it's not working for me. It will just display duplicate songs and different publisher/writer. Here's my current query from my model.

public function get_songs_in_playlist($playlist_id)
{
    $this->db->select(
        "si.song_info_file_name,
        si.song_info_revised_file_name,
        a.artist_name,
        si.song_info_id as songinfoid,
        array_to_string(array_agg(c.composer_name),'/'),
        array_to_string(array_agg(p.publisher_name),'/'),
        array_to_string(array_agg(st.tag_name),',')"
    );
    $this->db->from('songs_in_playlist sp');
    $this->db->join('song_info si', 'sp.song_info_id = si.song_info_id', 'left');
    $this->db->join('original_artist a', 'si.artist_id = a.artist_id', 'left');
    $this->db->join('composer c', 'si.composer_id = c.composer_id', 'left');
    $this->db->join('publisher p', 'si.publisher_id = p.publisher_id', 'left');
    $this->db->join('song_info_tags sit', 'si.song_info_id = sit.song_info_id', 'left');
    $this->db->join('song_tags st', 'st.tag_id = sit.tag_id', 'left');
    $this->db->where('sp.playlist_id', $playlist_id);
    $this->db->group_by(array("si.song_info_id", "a.artist_name", "c.composer_name" , "p.publisher_name" ));

    $query = $this->db->get();

    return $query->result_array();

}

Song Table

song_info_id   song_name
1              songA

Publisher Table

publisher_id   publisher_name
1              publisherA
2              publisherB

Writer Table

writer_id      writer_name     song_info_id    publisher_id
1              writerA         1               1
2              writerB         1               2

Result should be:

Song Name      Writers                Publishers
SongA          writerA, writerB       publisherA, publisherB

Current result from join:

Song Name      Writers                Publishers
SongA          writerA                publisherA
SongA          writerB                publisherB

Results in array

Array (
    [0] => Array (
        [song_info_file_name] => Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [song_info_revised_file_name] => 1510657326_Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [status_artist_name] => Cartoon (feat. Daniel Levi)
        [songinfoid] => 133 [title] => On & On (feat. Daniel Levi)
        [array_to_string] =>
    )
    [1] => Array (
        [song_info_file_name] => Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [song_info_revised_file_name] => 1510657326_Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [status_artist_name] => American Authors
        [songinfoid] => 133
        [title] => On & On (feat. Daniel Levi)
        [array_to_string] =>
    )
    [2] => Array (
        [song_info_file_name] => 01-Reverie_(feat__King_Deco).mp3
        [song_info_revised_file_name] => 1510728747_01-Reverie_(feat__King_Deco).mp3
        [status_artist_name] => Illenium
        [songinfoid] => 136
        [title] => Reverie (feat. King Deco) [array_to_string] =>
        )
    [3] => Array (
        [song_info_file_name] => 01-Reverie_(feat__King_Deco).mp3
        [song_info_revised_file_name] => 1510728747_01-Reverie_(feat__King_Deco).mp3
        [status_artist_name] => Cartoon (feat. Daniel Levi)
        [songinfoid] => 136
        [title] => Reverie (feat. King Deco)
        [array_to_string] =>
    )
    [4] => Array (
        [song_info_file_name] => 01-Reverie_(feat__King_Deco).mp3
        [song_info_revised_file_name] => 1510728747_01-Reverie_(feat__King_Deco).mp3
        [status_artist_name] => American Authors
        [songinfoid] => 136
        [title] => Reverie (feat. King Deco)
        [array_to_string] =>
    )
    [5] => Array (
        [song_info_file_name] => Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [song_info_revised_file_name] => 1510657326_Cartoon_-_On_On_(ft__Daniel_Levi).mp3
        [status_artist_name] => Illenium
        [songinfoid] => 133
        [title] => On & On (feat. Daniel Levi)
        [array_to_string] =>
    )
    [6] => Array (
        [song_info_file_name] => American_Authors_-_Best_Day_Of_My_Life.mp3
        [song_info_revised_file_name] => 1510540526_American_Authors_-_Best_Day_Of_My_Life.mp3
        [status_artist_name] => Cartoon (feat. Daniel Levi)
        [songinfoid] => 134
        [title] => Best Day of My Life
        [array_to_string] => Mix, Half, Alternative, Mid
    )
    [7] => Array (
        [song_info_file_name] => American_Authors_-_Best_Day_Of_My_Life.mp3
        [song_info_revised_file_name] => 1510540526_American_Authors_-_Best_Day_Of_My_Life.mp3
        [status_artist_name] => American Authors
        [songinfoid] => 134
        [title] => Best Day of My Life [array_to_string] => Mix, Half, Alternative, Mid
    )
    [8] => Array (
        [song_info_file_name] => American_Authors_-_Best_Day_Of_My_Life.mp3
        [song_info_revised_file_name] => 1510540526_American_Authors_-_Best_Day_Of_My_Life.mp3
        [status_artist_name] => Illenium
        [songinfoid] => 134
        [title] => Best Day of My Life
        [array_to_string] => Mix, Mix, Half, Half, Alternative, Alternative, Mid, Mid
    )
)

Body:
Well after a few minutes of brain storming I found a way to be able to fix this one. Thank you for those who commented. btw sorry to tag mysql but I was using postgresql. here's my solution for future purposes.

 public function get_shareable_songs_playlist($playlist_id)
{
    $this->db->select("si.songinfoid,
    si.filename,
    si.revised_filename,
    si.title,

    array_to_string(
        ARRAY(
            select status_artist_name from status s where s.song_info_id = si.songinfoid
        ),

    '/'
    ) AS artist,

    array_to_string(
        ARRAY(
            select c.composer_name from composer c, song_composer sc where c.composer_id = sc.composer_id AND sc.song_info_id = si.songinfoid
        ),

    '/'
    ) AS composer,

    array_to_string(
        ARRAY(
            select p.publisher_name from publisher p, composer c, song_composer sc where p.publisher_id = c.publisher_id AND c.composer_id = sc.composer_id AND sc.song_info_id = si.songinfoid
        ),

    '/'
    ) AS publisher,

    array_to_string(
        ARRAY(
            select s.tag_name from song_tags s, song_info_tags sit where s.tag_id = sit.tag_id AND sit.song_info_id = si.songinfoid AND sit.info_tag_delete_flag = 0
        ),

    '/'
    ) AS tags,
    sp.playlist_id");
    $this->db->from("(SELECT song_info_id AS songinfoid, song_info_file_name AS filename, song_info_revised_file_name AS revised_filename, song_info_original_title AS title FROM song_info si GROUP BY song_info_id)si");
    $this->db->join('songs_in_playlist sp', 'sp.song_info_id = si.songinfoid');
    $this->db->join('playlist play', 'sp.playlist_id = play.playlist_id');
$this->db->where('sp.playlist_id', $playlist_id);
$this->db->where('play.playlist_share', 1);
$query = $this->db->get();

return $query->result_array();
}


问:
Rxjava as event bus
I am trying to implement event processing in my app using Rxjava publishsubject.

Event bus will be shared between multiple activities, fragments and a service.

The service does my background processing work (runs every 30 secs).

Issues :

I would like that every event that has some flag set be saved in the DB. I would like to attach a generic listener for this. How can I achieve this? In which context should this run?

Service will read persisted events and process them if it deems necessary.

答:
Eventually we implemented and RxBus. We backed it up with an eventstore on local db. Then we ran a service which queries database for new events which are then loaded onto the bus. </p>

<p>We were looking for some product that does this by default. Could not find one. </p>

Title: Rxjava as event bus

Body:
Eventually we implemented and RxBus. We backed it up with an eventstore on local db. Then we ran a service which queries database for new events which are then loaded onto the bus.

We were looking for some product that does this by default. Could not find one.


问:
NotificationCompat.Builder deprecated in Android O
After upgrading my project to Android O

```<code>buildToolsVersion "26.0.1"
</code>```

Lint in Android Studio is showing a deprecated warning for the follow notification builder method:

```<code>new NotificationCompat.Builder(context)
</code>```

The problem is: Android Developers update their Documentation describing NotificationChannel to support notifications in Android O, and provide us with a snippet, yet with the same deprecated warning:

```<code>Notification notification = new Notification.Builder(MainActivity.this)
        .setContentTitle("New Message")
        .setContentText("You've received new messages.")
        .setSmallIcon(R.drawable.ic_notify_status)
        .setChannelId(CHANNEL_ID)
        .build();
</code>```

Notifications Overview

My question: Is there is any other solution for building notification, and still support Android O?

A solution I found is to pass the channel ID as a parameter in Notification.Builder constructor. But this solution is not exactly reusable.

```<code>new Notification.Builder(MainActivity.this, "channel_id")
</code>```

答:
Here is working code for all android versions as of API LEVEL 26+ with backward compatibility.

```<code> NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getContext(), "M_CH_ID");

        notificationBuilder.setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL)
                .setWhen(System.currentTimeMillis())
                .setSmallIcon(R.drawable.ic_launcher)
                .setTicker("Hearty365")
                .setPriority(Notification.PRIORITY_MAX) // this is deprecated in API 26 but you can still use for below 26. check below update for 26 API
                .setContentTitle("Default notification")
                .setContentText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
                .setContentInfo("Info");

NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, notificationBuilder.build());
</code>```

UPDATE for API 26 to set Max priority

```<code>    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    String NOTIFICATION_CHANNEL_ID = "my_channel_id_01";

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "My Notifications", NotificationManager.IMPORTANCE_MAX);

        // Configure the notification channel.
        notificationChannel.setDescription("Channel description");
        notificationChannel.enableLights(true);
        notificationChannel.setLightColor(Color.RED);
        notificationChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
        notificationChannel.enableVibration(true);
        notificationManager.createNotificationChannel(notificationChannel);
    }

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);

    notificationBuilder.setAutoCancel(true)
            .setDefaults(Notification.DEFAULT_ALL)
            .setWhen(System.currentTimeMillis())
            .setSmallIcon(R.drawable.ic_launcher)
            .setTicker("Hearty365")
       //     .setPriority(Notification.PRIORITY_MAX)
            .setContentTitle("Default notification")
            .setContentText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
            .setContentInfo("Info");

    notificationManager.notify(/*notification id*/1, notificationBuilder.build());
</code>```

Body:
After upgrading my project to Android O

buildToolsVersion "26.0.1"

Lint in Android Studio is showing a deprecated warning for the follow notification builder method:

new NotificationCompat.Builder(context)

The problem is: Android Developers update their Documentation describing NotificationChannel to support notifications in Android O, and provide us with a snippet, yet with the same deprecated warning:

Notification notification = new Notification.Builder(MainActivity.this)
        .setContentTitle("New Message")
        .setContentText("You've received new messages.")
        .setSmallIcon(R.drawable.ic_notify_status)
        .setChannelId(CHANNEL_ID)
        .build();

Notifications Overview

My question: Is there is any other solution for building notification, and still support Android O?

A solution I found is to pass the channel ID as a parameter in Notification.Builder constructor. But this solution is not exactly reusable.

new Notification.Builder(MainActivity.this, "channel_id")

Body:
Here is working code for all android versions as of API LEVEL 26+ with backward compatibility.

 NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getContext(), "M_CH_ID");

        notificationBuilder.setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL)
                .setWhen(System.currentTimeMillis())
                .setSmallIcon(R.drawable.ic_launcher)
                .setTicker("Hearty365")
                .setPriority(Notification.PRIORITY_MAX) // this is deprecated in API 26 but you can still use for below 26. check below update for 26 API
                .setContentTitle("Default notification")
                .setContentText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
                .setContentInfo("Info");

NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, notificationBuilder.build());

UPDATE for API 26 to set Max priority

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    String NOTIFICATION_CHANNEL_ID = "my_channel_id_01";

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "My Notifications", NotificationManager.IMPORTANCE_MAX);

        // Configure the notification channel.
        notificationChannel.setDescription("Channel description");
        notificationChannel.enableLights(true);
        notificationChannel.setLightColor(Color.RED);
        notificationChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
        notificationChannel.enableVibration(true);
        notificationManager.createNotificationChannel(notificationChannel);
    }

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);

    notificationBuilder.setAutoCancel(true)
            .setDefaults(Notification.DEFAULT_ALL)
            .setWhen(System.currentTimeMillis())
            .setSmallIcon(R.drawable.ic_launcher)
            .setTicker("Hearty365")
       //     .setPriority(Notification.PRIORITY_MAX)
            .setContentTitle("Default notification")
            .setContentText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
            .setContentInfo("Info");

    notificationManager.notify(/*notification id*/1, notificationBuilder.build());


问:
EWS: Appointment.Organizer sometimes empty
Exchange was updated from RTM to CU6
Since this update I do get Appointments without an organizer.

We do use a global user to insert the appointments. Before the organizer would be the user that is impersionated. Now it is null.

I do use Bind and in some cases (I think with older appointments) I do have an organizer.

Is there anything you could think of?
Is there any known error you know of?

答:
I had to add additionalProperties.Add(AppointmentSchema.Organizer);

It wasn't needet before. I do not know why now and why some of the Appointments have the Organizer filled whether the property is set or not and others don't, but since I set it it is allways filled again...


问:
removing certain objects from list of objects in c#
i have a list of objects </p>

```<code>    public int id { get; set; }
    public string device_code { get; set; }
    public string device_type { get; set; }
    public string authentication_token { get; set; }
    public string Status { get; set; }
</code>```

<p>while returning the list i want to remove "device_code" and "device_type" from the list and return the list only with "id","authentication_token" and "status".
How can I delete certain objects? </p>

答:
You must cast your object to another type that will contain only needed properties.
You can do this easy with linq:</p>

```<code>var result = yourCollection.Select(x => new YourTempClass(){property1=x.property1});
</code>```

Body:
i have a list of objects

    public int id { get; set; }
    public string device_code { get; set; }
    public string device_type { get; set; }
    public string authentication_token { get; set; }
    public string Status { get; set; }

while returning the list i want to remove "device_code" and "device_type" from the list and return the list only with "id","authentication_token" and "status".
How can I delete certain objects?

Body:
You must cast your object to another type that will contain only needed properties.
You can do this easy with linq:

var result = yourCollection.Select(x => new YourTempClass(){property1=x.property1});


问:
How to hide unity multiplayer connection info.?
I am trying to develop a unity multiplayer game. I want to hide information of port like other games.I post image You can chack it. I want to change stop button to quit but not How.?

Any one can help me, tell me How to do this like other games, What shoudl I do.
Should I need to change scene after connection success(all player connected).?

答:
The information displayed on your screen come from the NetworkManagerHUD.

In order to hide these information, you have to set showGUI boolean to false.

In order to do so, either uncheck it from the inspector or use the following line of code once your players are connected :

```<code>NetworkManagerHUD hud = FindObjectOfType<NetworkManagerHUD>();
if( hud != null )
    hud.showGUI = false;
</code>```

Body:
The information displayed on your screen come from the NetworkManagerHUD.

In order to hide these information, you have to set showGUI boolean to false.

In order to do so, either uncheck it from the inspector or use the following line of code once your players are connected :

NetworkManagerHUD hud = FindObjectOfType<NetworkManagerHUD>();
if( hud != null )
    hud.showGUI = false;


问:
What would be the appropriate HTTP method to rename a resource in RESTful APIs
Will we use PUT or POST when the identity of resource itself is changing from oldname to newname in the web service?

答: Typically POST is used to create a resource. Since you're not creating a resource better option seems to be PUT but... PUT request are idempotent - it means more or less - repeatable in terms of outcome, further reading might be found here. Also PUT needs to contain the whole resource. Thus, maybe PATCH is the right choice?


问:
Docker Login for AWS ECR failing with "Cannot connect to the Docker deamon..."
I'm having trouble getting started with ECR because the login command generated by

```<code>aws ecr get-login
</code>```

returns:

```<code> Warning: '-e' is deprecated, it will be removed soon. See usage.
 Cannot connect to the Docker daemon. Is the docker daemon running on this host?
</code>```

Unfortunately, the documentation for ECR doesn't acknowledge this as possible issue. Has anyone here experienced this before and if so what did you do to fix it? For reference I've setup AWS CLI with an IAM user that has policies for full EC2/ECR permissions attached. I've also created a permissions statement on the ECR registry that allows my IAM user full rights.

答:
As i updgraded Docker to version 17.06.2-ce, this deprecation notice moved to be an error :

```<code>unknown shorthand flag: 'e' in -e
See 'docker login --help'.
</code>```

The cause is the "aws ecr get-login" command returing an invalid parameter ("-e none"). Before this docker version, it was a warning / depreciation error, now docker failed with a return code of 125.

To prevent this, I log on ECR with this command :

```<code>$> $(aws ecr get-login | sed -e "s/-e none//g")
</code>```

Body:
I'm having trouble getting started with ECR because the login command generated by

aws ecr get-login

returns:

 Warning: '-e' is deprecated, it will be removed soon. See usage.
 Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Unfortunately, the documentation for ECR doesn't acknowledge this as possible issue. Has anyone here experienced this before and if so what did you do to fix it? For reference I've setup AWS CLI with an IAM user that has policies for full EC2/ECR permissions attached. I've also created a permissions statement on the ECR registry that allows my IAM user full rights.

Body:
As i updgraded Docker to version 17.06.2-ce, this deprecation notice moved to be an error :

unknown shorthand flag: 'e' in -e
See 'docker login --help'.

The cause is the "aws ecr get-login" command returing an invalid parameter ("-e none"). Before this docker version, it was a warning / depreciation error, now docker failed with a return code of 125.

To prevent this, I log on ECR with this command :

$> $(aws ecr get-login | sed -e "s/-e none//g")


答:
Another method, which makes the four directions symetric :

```<code>rm = m[::-1].T                            # (j,-i) to (x,y)
green = np.where(rm==2)                   # the costly operation
centers = np.vstack(green).T

rm[green] = 0
res = []

for x,y in centers:
    for s in (-1,1):                      # rear/front
        for t in range(2) :               # vertical/horizontal
            v = *_,save = rm[x,y::s]
            v[-1] = 1                     # sentinel
            res.append(y + s*v.argmax())  # find the first 1
            v[-1] = save
            x,y,rm = y,x,rm.T             # turn

rm[green] = 2

coordinates = np.array(res).reshape(-1,4)
corners = coordinates.take([[1,2],[3,2],[1,0],[3,0]],axis=1)
</code>```

This avoids to deal with the included/excluded behavior of Python slices, and manages borders with a sentinel system.

```<code>print(centers);print(corners)

[[ 0  0]
 [ 7 12]
 [16 27]
 [29 21]
 [34  7]]
-----------
[[[ 0  6]
  [ 2  6]
  [ 0  0]
  [ 2  0]]

 [[ 3 14]
  [ 9 14]
  [ 3  7]
  [ 9  7]]

 [[12 31]
  [23 31]
  [12 24]
  [23 24]]

 [[25 22]
  [32 22]
  [25 15]
  [32 15]]

 [[33 13]
  [35 13]
  [33  0]
  [35  0]]]
</code>```

Title: Get coordinates of squares in numpy matrix

Body:
Given the following numpy matrix

import numpy as np
np_matrix = np.array([[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,1,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0]
                    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0]
                    ,[0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
                    ,[0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1]
                    ,[0,0,0,1,0,0,0,2,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]
                    ,[0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]
                    ,[0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]
                    ,[0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]
                    ,[0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]
                    ,[0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,0]
                    ,[1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]
                    ,[0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]
                    ,[0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]
                    ,[0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]
                    ,[0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]
                    ,[0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]
                    ,[2,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]])

print(np_matrix)
print(np_matrix.shape)

which can be represented as an image.

Here are a few assumptions about the input matrix:

The matrix shape can vary. It is not a fixed size.

The number of squares varies from matrix to matrix. But there is always at least one square in the matrix.

For each green dot there is a square around it and squares have a single dot inside them. The dot inside the square is marked with number 2

Squares are sequential on the X axis and square's borders never overlap the borders of other squares. Squares borders are marked with number 1

The white space is marked with number 0

I have two questions. In the most efficient way how can i get an array with the coordinates of all the green dots? And how can i get an array with all the corners for the squares around a green dot?

Here is the result i am looking after for this example:

green_dots_coordinates = [
    [0,0],  # dot 1 with coordinates x1, y1 inside square 1
    [7,12], # dot 2 with coordinates x2, y2 inside square 2
    [16,27],# dot 3 with coordinates x3, y3 inside square 3
    [29,21],# dot 4 with coordinates x4, y4 inside square 4
    [34,7], # dot 5 with coordinates x5, y5 inside square 5
]

sqaures_corners_coordinates = [
    #square nr 1
    [
        [0,6], # x1, y1
        [2,6], # x2, y2
        [0,0], # x3, y3
        [2,0], # x4, y4
    ],

    #square nr 2
    [
        [3,14], # x1, y1
        [9,14], # x2, y2
        [3,7], # x3, y3
        [9,7], # x4, y4
    ],

    #square nr 3
    [
        [12,31], # x1, y1
        [23,31], # x2, y2
        [12,24], # x3, y3
        [23,24], # x4, y4
    ],

    #square nr 4
    [
        [25,22], # x1, y1
        [32,22], # x2, y2
        [25,15], # x3, y3
        [32,15], # x4, y4
    ]

    ,#square nr 5
    [
        [33,13], # x1, y1
        [35,13], # x2, y2
        [33,0], # x3, y3
        [35,0], # x4, y4
    ],

]

Body:
Another method, which makes the four directions symetric :

rm = m[::-1].T                            # (j,-i) to (x,y)
green = np.where(rm==2)                   # the costly operation
centers = np.vstack(green).T

rm[green] = 0
res = []

for x,y in centers:
    for s in (-1,1):                      # rear/front
        for t in range(2) :               # vertical/horizontal
            v = *_,save = rm[x,y::s]
            v[-1] = 1                     # sentinel
            res.append(y + s*v.argmax())  # find the first 1
            v[-1] = save
            x,y,rm = y,x,rm.T             # turn

rm[green] = 2

coordinates = np.array(res).reshape(-1,4)
corners = coordinates.take([[1,2],[3,2],[1,0],[3,0]],axis=1)

This avoids to deal with the included/excluded behavior of Python slices, and manages borders with a sentinel system.

print(centers);print(corners)

[[ 0  0]
 [ 7 12]
 [16 27]
 [29 21]
 [34  7]]
-----------
[[[ 0  6]
  [ 2  6]
  [ 0  0]
  [ 2  0]]

 [[ 3 14]
  [ 9 14]
  [ 3  7]
  [ 9  7]]

 [[12 31]
  [23 31]
  [12 24]
  [23 24]]

 [[25 22]
  [32 22]
  [25 15]
  [32 15]]

 [[33 13]
  [35 13]
  [33  0]
  [35  0]]]


问:
Visual Studio 2017 - PreBuild event command line (build another project)
I have a solution with multiple projects.

When I build project 'Foo', I need it to build also project 'SimplePluginFramework' before Foo.

It also needs to build 'SimplePluginFramework' in Release mode, even if Foo is built in debug mode.

I tried adding this to Foo's Pre-build event command line but it's existing with code 9009 and Bar doesn't get built...

```<code> $(MSBuildBinPath)\MSBuild.exe "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" /t:build /p:Configuration=Release
</code>```

How can I make the build of one project trigger the build of a different project before the build?

I've tried adding a reference to that project but it still doesn't build it.

Error:

```<code>    1>Target "PreBuildEvent" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" from project "L:\SL1-(SentiLAN)-SentiLAN v1 - Current System\SentilanCore\SentiLAN Agent\SentilanV1\AgentServiceTpl\SentilanService\SentilanService.csproj" (target "CoreBuild" depends on it):
1>Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>Task "Exec"
1>  "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" /t:build /p:Configuration=release
1>  Microsoft (R) Build Engine version 15.3.409.57025 for .NET Framework
1>  Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>  Build started 15/11/2017 09:47:32.
1>  Project "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" on node 1 (build target(s)).
1>  GenerateTargetFrameworkMonikerAttribute:
1>  Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>  CoreCompile:
1>  Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
1>  _CopyAppConfigFile:
1>  Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
1>  CopyFilesToOutputDirectory:
1>    SimplePluginFramework -> L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\lib\net35\SimplePluginFramework.dll
1>  Done Building Project "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" (build target(s)).
1>
1>  Build succeeded.
1>      0 Warning(s)
1>      0 Error(s)
1>
1>  Time Elapsed 00:00:00.22
</code>```

Project Dependencies:

答:
Use Project | Project Dependencies to define that Foo depends on SimplePluginFramework.

Use solution configuration (right click on solution and select properties) to define that in solution level Debug configuration Foo's debug build is used but SimplePluginFramework's release build is used.

Body:
I have a solution with multiple projects.

When I build project 'Foo', I need it to build also project 'SimplePluginFramework' before Foo.

It also needs to build 'SimplePluginFramework' in Release mode, even if Foo is built in debug mode.

I tried adding this to Foo's Pre-build event command line but it's existing with code 9009 and Bar doesn't get built...

 $(MSBuildBinPath)\MSBuild.exe "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" /t:build /p:Configuration=Release

How can I make the build of one project trigger the build of a different project before the build?

I've tried adding a reference to that project but it still doesn't build it.

Error:

    1>Target "PreBuildEvent" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" from project "L:\SL1-(SentiLAN)-SentiLAN v1 - Current System\SentilanCore\SentiLAN Agent\SentilanV1\AgentServiceTpl\SentilanService\SentilanService.csproj" (target "CoreBuild" depends on it):
1>Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>Task "Exec"
1>  "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" /t:build /p:Configuration=release
1>  Microsoft (R) Build Engine version 15.3.409.57025 for .NET Framework
1>  Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>  Build started 15/11/2017 09:47:32.
1>  Project "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" on node 1 (build target(s)).
1>  GenerateTargetFrameworkMonikerAttribute:
1>  Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>  CoreCompile:
1>  Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
1>  _CopyAppConfigFile:
1>  Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
1>  CopyFilesToOutputDirectory:
1>    SimplePluginFramework -> L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\lib\net35\SimplePluginFramework.dll
1>  Done Building Project "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" (build target(s)).
1>
1>  Build succeeded.
1>      0 Warning(s)
1>      0 Error(s)
1>
1>  Time Elapsed 00:00:00.22

Project Dependencies:


答:
You seem to not want to remove objects, but properties of the objects.

```<code>public class ClassWithAllProperties
{
    public int id { get; set; }
    public string device_code { get; set; }
    public string device_type { get; set; }
    public string authentication_token { get; set; }
    public string Status { get; set; }
}

var allInstances = new List<ClassWithAllProperties>();

// populate list

var allInstancesButNotAllProperties = allInstances.Select(x => new { id = x.id, authentication_token = x.authentication_token, Status = x.Status }).ToList();
</code>```

Now this list contains only the properties you want. However it obviously also does not contain instances of ClassWithAllProperties. It contains so-called anonymous classes. Classes the compiler builds in the background for you, based on your description in the new.

Title: removing certain objects from list of objects in c#

Body:
You seem to not want to remove objects, but properties of the objects.

public class ClassWithAllProperties
{
    public int id { get; set; }
    public string device_code { get; set; }
    public string device_type { get; set; }
    public string authentication_token { get; set; }
    public string Status { get; set; }
}

var allInstances = new List<ClassWithAllProperties>();

// populate list

var allInstancesButNotAllProperties = allInstances.Select(x => new { id = x.id, authentication_token = x.authentication_token, Status = x.Status }).ToList();

Now this list contains only the properties you want. However it obviously also does not contain instances of ClassWithAllProperties. It contains so-called anonymous classes. Classes the compiler builds in the background for you, based on your description in the new.


问:
CoordinatorLayout and toolbar and TabLayout sometimes cannot work move right and left scroll
I make the collapse toolbar activity use the CoordinatorLayout.

1. main_activity

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinatorLayout"
    android:background="@android:color/white"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="75dp"
            android:background="?attr/colorPrimary"
            android:paddingLeft="@dimen/layout_margin"
            android:theme="@style/ThemeToolbar"
            app:layout_scrollFlags="scroll|enterAlways"
            app:layout_collapseMode="pin"/>
        <android.support.design.widget.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabTextColor="@color/text_space"
            app:tabSelectedTextColor="@android:color/white"
            app:tabIndicatorColor="@android:color/white"
            app:tabIndicatorHeight="2dp"/>
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.widget.SwipeRefreshLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/swipe_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <android.support.v4.view.ViewPager
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </android.support.v4.widget.SwipeRefreshLayout>
    <android.support.design.widget.FloatingActionButton
        android:visibility="gone"
        android:id="@+id/fabButton_menu"
        android:src="@drawable/plus"
        app:fabSize="normal"
        app:backgroundTint="@color/color_family"
        app:borderWidth="0dp"
        style="@style/FabStyle_Normal"/>
</android.support.design.widget.CoordinatorLayout>
</code>```

2. code

```<code>pagerAdapter = new PagerAdapter(getSupportFragmentManager());
pagerAdapter.addFragment(new TabFragment_Home(), "T1");
pagerAdapter.addFragment(new TabFragment_Pharm(),"T2");
pagerAdapter.addFragment(new TabFragment_Family(), "T3");
pagerAdapter.addFragment(new TabFragment_Board(), "T4");

viewPager.setOffscreenPageLimit(4);
viewPager.setAdapter(pagerAdapter);
tabLayout.setupWithViewPager(viewPager, false);
</code>```

This code is very simple and basic code.
I have one question the scroll action please see the image below.

Question: why cannot scroll move right? this is bug or my mistake? please let me know. thanks

答:
Add this line: app:layout_behavior="@string/appbar_scrolling_view_behavior" in tablayout</p>

```<code><android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_scrollFlags="scroll|enterAlways"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</code>```

Body:
I make the collapse toolbar activity use the CoordinatorLayout.

1. main_activity

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinatorLayout"
    android:background="@android:color/white"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="75dp"
            android:background="?attr/colorPrimary"
            android:paddingLeft="@dimen/layout_margin"
            android:theme="@style/ThemeToolbar"
            app:layout_scrollFlags="scroll|enterAlways"
            app:layout_collapseMode="pin"/>
        <android.support.design.widget.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabTextColor="@color/text_space"
            app:tabSelectedTextColor="@android:color/white"
            app:tabIndicatorColor="@android:color/white"
            app:tabIndicatorHeight="2dp"/>
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.widget.SwipeRefreshLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/swipe_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <android.support.v4.view.ViewPager
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </android.support.v4.widget.SwipeRefreshLayout>
    <android.support.design.widget.FloatingActionButton
        android:visibility="gone"
        android:id="@+id/fabButton_menu"
        android:src="@drawable/plus"
        app:fabSize="normal"
        app:backgroundTint="@color/color_family"
        app:borderWidth="0dp"
        style="@style/FabStyle_Normal"/>
</android.support.design.widget.CoordinatorLayout>

2. code

pagerAdapter = new PagerAdapter(getSupportFragmentManager());
pagerAdapter.addFragment(new TabFragment_Home(), "T1");
pagerAdapter.addFragment(new TabFragment_Pharm(),"T2");
pagerAdapter.addFragment(new TabFragment_Family(), "T3");
pagerAdapter.addFragment(new TabFragment_Board(), "T4");

viewPager.setOffscreenPageLimit(4);
viewPager.setAdapter(pagerAdapter);
tabLayout.setupWithViewPager(viewPager, false);

This code is very simple and basic code.
I have one question the scroll action please see the image below.

Question: why cannot scroll move right? this is bug or my mistake? please let me know. thanks

Body:
Add this line: app:layout_behavior="@string/appbar_scrolling_view_behavior" in tablayout

<android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_scrollFlags="scroll|enterAlways"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>


问:
What TFS 2017 build task applies web.config transforms during TFS builds?
Some original info was changed to make the post more focused on the real issue after it was found.

These are some of the details of the current environment. I listed these only because questions were raised in other posts to determine what was and was not working in the current environment:

```<code>Upon check-in TFS 2017 successfully builds a web project on the build agent.
A VS 2017 publish profile can manually transform the project properly
The build machine artifact location includes both the transform and profile files
</code>```

The artifact location is shown below:

I have researched this in depth on Microsoft's VS site, SO and other forums, but there are so many different answers, many of them for older versions, I have been unable to piece this together.  As a result I have several sub-questions.

1) Can transforms be engaged in both Builds and Releases?. I read that transforms are applied during the publish process, not the build process, and that made me wonder if it is even possible to do this during a Build. But then when I was exploring releases, I saw all the same tasks usable in a Build, which suggests I can publish with a transform in either Build or Release.  Is that correct?

2) Does TFS 2017 require a lot of special handling to engage a transform file?  Some of the posts instructed the editing of the .proj file. I wanted to get a confirmation before doing that kind of detailed manipulation, especially given the improvements in TFS 2017.

The following information is the state of the current build definition named "confPanner-CI".  The shaded PS script was successfully used to upload to the hosting location to test the whole process, but that is not adequate for the task at hand which requires transforms to be applied:

The full MSBuild Arguments which also created a temp location for the powershell script are:

```<code>/p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=c:\ConfPlnrWeb
</code>```

If I were to add a task for publishing I saw the Publish Build Artifacts task:

But none of the settings as shown below seem to relate to transforms:

The bottom line question is: How do I configure the build so the web project upload has the proper web transform applied?

Update:  The following added after the answer below led to at least one place where VS transforms can be applied during a build, and presumably also a release.

Inside the MSBuild Build solution task set the Configuration as shown below:

答:
Publish Build Artifacts task is used to publish the related artifacts ( The “a” working directory contains the artifacts (also known as the “drop”) that are uploaded at the end of the build) to Visual Studio Team Services/TFS or a file share.

Usually it should be a package and be used in a deploy task such as Deploy: WinRM - IIS Web App Deployment or Azure App Service Deployment to achieved the deployment.

1) Can transforms be engaged in both Builds and Releases?

Yes, you could also do this in a build pipeline with the useage of build deploy task. You need to add the task after the publish build artifacts task.

2) Does TFS 2017 require a lot of special handling to engage a transform file?

update

The BuildConfiguration variable is different in TFS 2017, it's inside
  the MSBuild task! Transforms are now applied according
  to the MSBuild task Configuration setting.

Edit the  .proj file is a method to do the transform. If you don't need to change the transform, it will auto do it during the build.You could also use some 3-rd party task/extension for extra transform such as: XDT Transform

Usually we separate the build and release for the deployment, cause it's easy to configure multiple  environments and easy to debug issue. You definitely could do this only in build but with a bloated process. You could refer this tutorial: Build and Deploy Azure Web Apps using Team Foundation Server/Services vNext Builds.

For a separate build and release solution, you could take a look at this blog: Using web.config transforms and Release Manager – TFS 2017/Team Services edition

Body:
Some original info was changed to make the post more focused on the real issue after it was found.

These are some of the details of the current environment. I listed these only because questions were raised in other posts to determine what was and was not working in the current environment:

Upon check-in TFS 2017 successfully builds a web project on the build agent.
A VS 2017 publish profile can manually transform the project properly
The build machine artifact location includes both the transform and profile files

The artifact location is shown below:

I have researched this in depth on Microsoft's VS site, SO and other forums, but there are so many different answers, many of them for older versions, I have been unable to piece this together.  As a result I have several sub-questions.

1) Can transforms be engaged in both Builds and Releases?. I read that transforms are applied during the publish process, not the build process, and that made me wonder if it is even possible to do this during a Build. But then when I was exploring releases, I saw all the same tasks usable in a Build, which suggests I can publish with a transform in either Build or Release.  Is that correct?

2) Does TFS 2017 require a lot of special handling to engage a transform file?  Some of the posts instructed the editing of the .proj file. I wanted to get a confirmation before doing that kind of detailed manipulation, especially given the improvements in TFS 2017.

The following information is the state of the current build definition named "confPanner-CI".  The shaded PS script was successfully used to upload to the hosting location to test the whole process, but that is not adequate for the task at hand which requires transforms to be applied:

The full MSBuild Arguments which also created a temp location for the powershell script are:

/p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=c:\ConfPlnrWeb

If I were to add a task for publishing I saw the Publish Build Artifacts task:

But none of the settings as shown below seem to relate to transforms:

The bottom line question is: How do I configure the build so the web project upload has the proper web transform applied?

Update:  The following added after the answer below led to at least one place where VS transforms can be applied during a build, and presumably also a release.

Inside the MSBuild Build solution task set the Configuration as shown below:


问:
Banner alignment in vbulletin using css?
I have a site where sponsors pay to have their own section with a banner.

However, since updating to the latest vbulletin version 4.1, i am having problems getting the homepage to look right with the banners.

If you look at the homepage of http://www.r32oc.com you will notice that the banners are being manipulated by the text title of the section they are within. Ideally i would like to get the banner to stick to the far right of that box or directly underneath the section title.

The code for the forumdisplay page is this:

```<code>    <!-- vBSponsors -->
<vb:if condition="$foruminfo['sponsor_enabled'] == 1 AND $vboptions['sponsor_global_enable_sponsorship'] == 1">
{vb:raw vboptions.sponsor_global_default_text}
<a href="vB.Sponsors/link.php?f={vb:raw foruminfo.forumid}" title="{vb:raw foruminfo.sponsor_name}" target="_blank">
<vb:if condition="$foruminfo['sponsor_banner_enabled'] == 1 AND $vboptions['sponsor_global_enable_banners'] == 1">
<vb:if condition="!empty($foruminfo['sponsor_banner_big'])">
<vb:if condition="$vboptions['sponsor_global_enable_big_banners'] == 1">
<img src="{vb:raw foruminfo.sponsor_banner_big}" border="0" align="right" />
<vb:else />
<img src="{vb:raw foruminfo.sponsor_banner}" border="0" align="right" />
</vb:if>
<vb:else />
{vb:raw foruminfo.sponsor_name}
</vb:if> </vb:if> </a> </vb:if>
<!-- / vBSponsors -->
</code>```

If anyone can helpy me with this, i would appreciate it.

答:
On line 364 of the source there is a div beneath the #breadcrumb div that has the following inline style:

```<code><div style="width:728px; margin:0 auto; padding-bottom:1em">
</code>```

To change it to align left you would change margin:0 auto; to just margin:0;.  To align right you would change it to margin:0 0 0 85px;.

I am not familiar with vbulletin so I can't tell you where this div styling is located, however if you do a search for the #breadcrumb div then you are likely to find it.

Body:
I have a site where sponsors pay to have their own section with a banner.

However, since updating to the latest vbulletin version 4.1, i am having problems getting the homepage to look right with the banners.

If you look at the homepage of http://www.r32oc.com you will notice that the banners are being manipulated by the text title of the section they are within. Ideally i would like to get the banner to stick to the far right of that box or directly underneath the section title.

The code for the forumdisplay page is this:

<vb:if condition="$foruminfo['sponsor_enabled'] == 1 AND $vboptions['sponsor_global_enable_sponsorship'] == 1">
{vb:raw vboptions.sponsor_global_default_text}

<vb:if condition="$foruminfo['sponsor_banner_enabled'] == 1 AND $vboptions['sponsor_global_enable_banners'] == 1">
<vb:if condition="!empty($foruminfo['sponsor_banner_big'])">
<vb:if condition="$vboptions['sponsor_global_enable_big_banners'] == 1">

<vb:else />

</vb:if>
<vb:else />
{vb:raw foruminfo.sponsor_name}
</vb:if> </vb:if>  </vb:if>

If anyone can helpy me with this, i would appreciate it.

Body:
On line 364 of the source there is a div beneath the #breadcrumb div that has the following inline style:

<div style="width:728px; margin:0 auto; padding-bottom:1em">

To change it to align left you would change margin:0 auto; to just margin:0;.  To align right you would change it to margin:0 0 0 85px;.

I am not familiar with vbulletin so I can't tell you where this div styling is located, however if you do a search for the #breadcrumb div then you are likely to find it.


问:
Create copy button in popup
I have a discount coupon code popup like in the picture I attached.

My question is, how do I create a copy function on the "Copy this coupon code" button? So when the user clicks the "Copy this coupon code" then the 123 coupon code will be copied.
I follow this way but it does not work for popups
https://www.w3schools.com/howto/howto_js_copy_clipboard.asp

There is an error message: copyText.select () is not function

答:
Let me clear the example

```<code> <!-- The text field -->
 <input type="text" value="Hello World" id="myInput">

 <!-- The button used to copy the text -->
 <button onclick="myFunction()">Copy text</button>
</code>```

Now see in the text field id is given i.e myInput and now the function as below

```<code><script type="text/javascript">
function myFunction() {
var copyText = document.getElementById("myInput");
copyText.select();
document.execCommand("Copy");
alert("Copied the text: " + copyText.value);
}
</code>```

Now in function first we get the input text by that id(myInput) and then applied the rest functionality accordingly. Please check in your code that have you used correct id?

Thanks

Title: Create copy button in popup

Body:
Let me clear the example

 <!-- The text field -->
 <input type="text" value="Hello World" id="myInput">

 <!-- The button used to copy the text -->
 <button onclick="myFunction()">Copy text</button>

Now see in the text field id is given i.e myInput and now the function as below

<script type="text/javascript">
function myFunction() {
var copyText = document.getElementById("myInput");
copyText.select();
document.execCommand("Copy");
alert("Copied the text: " + copyText.value);
}

Now in function first we get the input text by that id(myInput) and then applied the rest functionality accordingly. Please check in your code that have you used correct id?

Thanks


问:
How to write SQL query into code-igniter formate
How to write below SQL query in to code-igniter </p>

```<code>SELECT
    `pm`.`id`,
    `pm`.`region`,
    `pm`.`port_name`,
    `pm`.`country`,
    `tbl_port_annual_throughput`.`YEAR`,
    `tbl_port_annual_throughput`.`TOTAL_THROUGHPUT`,
    `tbl_port_annual_throughput`.`status`
    FROM (`tbl_port_annual_throughput`)
    JOIN `port_master` pm
      ON `pm`.`id` = `tbl_port_annual_throughput`.`PORT_ID`
    WHERE `pm`.`country` = "100@Kenya"
    AND (
        (`tbl_port_annual_throughput`.`YEAR` =  '2014' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
        OR (`tbl_port_annual_throughput`.`YEAR` =  '2015' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
        OR (`tbl_port_annual_throughput`.`YEAR` =  '2016' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
    )
</code>```

答:
Try this:</p>

```<code>$or_where= "(`tbl_port_annual_throughput`.`YEAR` =  '2014' AND `tbl_port_annual_throughput`.`status` =  'Confirmed') OR (`tbl_port_annual_throughput`.`YEAR` =  '2015' AND `tbl_port_annual_throughput`.`status` =  'Confirmed') OR (`tbl_port_annual_throughput`.`YEAR` =  '2016' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')";

            $this->db->select('pm.id, pm.region,pm.port_name,pm.country,tbl_port_annual_throughput.YEAR,tbl_port_annual_throughput.TOTAL_THROUGHPUT,tbl_port_annual_throughput.status');
            $this->db->join('port_master as pm','pm.id = tbl_port_annual_throughput.PORT_ID');
            $this->db->where('pm.country','100@Kenya');
            $this->db->where($or_where);
            return $this->db->get('tbl_port_annual_throughput')->result();
</code>```

Body:
How to write below SQL query in to code-igniter

SELECT
    `pm`.`id`,
    `pm`.`region`,
    `pm`.`port_name`,
    `pm`.`country`,
    `tbl_port_annual_throughput`.`YEAR`,
    `tbl_port_annual_throughput`.`TOTAL_THROUGHPUT`,
    `tbl_port_annual_throughput`.`status`
    FROM (`tbl_port_annual_throughput`)
    JOIN `port_master` pm
      ON `pm`.`id` = `tbl_port_annual_throughput`.`PORT_ID`
    WHERE `pm`.`country` = "100@Kenya"
    AND (
        (`tbl_port_annual_throughput`.`YEAR` =  '2014' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
        OR (`tbl_port_annual_throughput`.`YEAR` =  '2015' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
        OR (`tbl_port_annual_throughput`.`YEAR` =  '2016' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')
    )

Body:
Try this:

$or_where= "(`tbl_port_annual_throughput`.`YEAR` =  '2014' AND `tbl_port_annual_throughput`.`status` =  'Confirmed') OR (`tbl_port_annual_throughput`.`YEAR` =  '2015' AND `tbl_port_annual_throughput`.`status` =  'Confirmed') OR (`tbl_port_annual_throughput`.`YEAR` =  '2016' AND `tbl_port_annual_throughput`.`status` =  'Confirmed')";

            $this->db->select('pm.id, pm.region,pm.port_name,pm.country,tbl_port_annual_throughput.YEAR,tbl_port_annual_throughput.TOTAL_THROUGHPUT,tbl_port_annual_throughput.status');
            $this->db->join('port_master as pm','pm.id = tbl_port_annual_throughput.PORT_ID');
            $this->db->where('pm.country','100@Kenya');
            $this->db->where($or_where);
            return $this->db->get('tbl_port_annual_throughput')->result();


问:
Angular 2 Consuming JSON
I am learning angular 2 and looking for a code which can help in consuming JSON and showing that on UI. Please pass me a piece of code which i can use to consume JSON and show it on UI.

Thanks in advance!

答:
if you want to show object of your array like...

TypeScript:

```<code>new1 = any[] = [{name:'Name1'},{name:'Name2'}];
</code>```

Then you should be use in angular 2 using *ngFor

```<code><ul><li *ngFor="let employee of new1">{{employee.name}}</li></ul>
</code>```

You get result like that

Name1

Name2

Title: Angular 2 Consuming JSON

Body:
if you want to show object of your array like...

TypeScript:

new1 = any[] = [{name:'Name1'},{name:'Name2'}];

Then you should be use in angular 2 using *ngFor

<ul><li *ngFor="let employee of new1">{{employee.name}}</li></ul>

You get result like that

Name1

Name2


问:
The term 'Add-migration' is not recognized - VS2017 and EntityFrameworkCore
I am posting this question just in case the solution I found would help someone else out. While working in Visual Studio 2017 rc4 each time I tried to run the Add-Migration command in the Package Manager console I get the following error:

The term 'Add-migration' is not recognized...

答: I reinstalled package Microsoft.EntityFrameworkCore.Tools and issue got fixed for me.</p>


问:
Locally Unique?
I am trying to get straight the unique and key elements for XML Schema,
especially with regards to the selector and field elements within.

I'm unclear about selectors and fields, and I need to get this straight.

Suppose I had an XML file with companies listed within functional groups.
I have an element within each group with a unique field (to reference
each particular group).

I want to create a unique field within each company listing within
each group that would be unique only within that particular group.

Would this be correct?:

```<code>    <xs:unique id="company_group_refs" name="company_group_refs">
        <xs:selector xpath="root/all_companies/company_group"/>
        <xs:field xpath="company_group_ref"/>
    </xs:unique>

    <xs:unique id="company_refs" name="company_refs">
        <xs:selector xpath="root/all_companies/company_group"/>
        <xs:field xpath="company/company_ref"/>
    </xs:unique>
</code>```

If so, could I condense the above to this?:

```<code>    <xs:unique id="company_refs" name="company_refs">
        <xs:selector xpath="root/all_companies/company_group"/>
        <xs:field xpath="company_group_ref"/>
        <xs:field xpath="company/company_ref"/>
    </xs:unique>
</code>```

To reference any company name in particular, I want to be able to
give an XPath expression like this:

root/all_companies/company_group[company_group_ref=x1]/company[company_ref=x2]/name

Where: x1 = the unique reference for the company group.

and:   x2 = the unique reference for the company within that group.

What follows is an XML file excerpt that exemplifies this scenario:

```<code><all_companies>

    <company_group>
        <company_group_name>Cleaning</company_group_name>
        <company_group_ref>1</company_group_ref>
        <company>
            <name>Ajax</name>
            <company_ref>1</company_ref>
        </company>
        <company>
            <name>Bloomburg</name>
            <company_ref>2</company_ref>
        </company>
        <company>
            <name>Morris</name>
            <company_ref>3</company_ref>
        </company>
    </company_group>

    <company_group>
        <company_group_name>Electrical</company_group_name>
        <company_group_ref>2</company_group_ref>
        <company>
            <name>Armstrong</name>
            <company_ref>1</company_ref>
        </company>
        <company>
            <name>Bloomburg</name>
            <company_ref>2</company_ref>
        </company>
        <company>
            <name>Zap Electrical</name>
            <company_ref>3</company_ref>
        </company>
        <company>
            <name>Morris</name>
            <company_ref>4</company_ref>
        </company>
    </company_group>

</all_companies>
</code>```

THANKS!!!

答:
Your constraint to require uniqueness of group_refs is correct. The constraint to make company_refs unique within a group should read like this

```<code><xs:element name="company_group">
  <xs:unique name="company_unique_within_group">
    <xs:selector xpath="company">
    <xs:field xpath="company_ref">
  </xs:unique>
  ...
</xs:element>
</code>```

Read that as "within a company_group" "select all company" and require that "company_ref is unique among them".

Your company_ref constraint says: "globally" "for all company_groups" require that "company/company_ref is unique".

Your condensed constraint expresses something entirely different: "globally" "for all company_groups" require that "the combination of company_group_ref and company/company_ref" is unique". Given that there are actually multiple company_refs per group, the latter two are nonsensical.

Title: Locally Unique?

Body:
I am trying to get straight the unique and key elements for XML Schema,
especially with regards to the selector and field elements within.

I'm unclear about selectors and fields, and I need to get this straight.

Suppose I had an XML file with companies listed within functional groups.
I have an element within each group with a unique field (to reference
each particular group).

I want to create a unique field within each company listing within
each group that would be unique only within that particular group.

Would this be correct?:

    <xs:unique id="company_group_refs" name="company_group_refs">
        <xs:selector xpath="root/all_companies/company_group"/>
        <xs:field xpath="company_group_ref"/>
    </xs:unique>

    <xs:unique id="company_refs" name="company_refs">
        <xs:selector xpath="root/all_companies/company_group"/>
        <xs:field xpath="company/company_ref"/>
    </xs:unique>

If so, could I condense the above to this?:

    <xs:unique id="company_refs" name="company_refs">
        <xs:selector xpath="root/all_companies/company_group"/>
        <xs:field xpath="company_group_ref"/>
        <xs:field xpath="company/company_ref"/>
    </xs:unique>

To reference any company name in particular, I want to be able to
give an XPath expression like this:

root/all_companies/company_group[company_group_ref=x1]/company[company_ref=x2]/name

Where: x1 = the unique reference for the company group.

and:   x2 = the unique reference for the company within that group.

What follows is an XML file excerpt that exemplifies this scenario:

<all_companies>

    <company_group>
        <company_group_name>Cleaning</company_group_name>
        <company_group_ref>1</company_group_ref>
        <company>
            <name>Ajax</name>
            <company_ref>1</company_ref>
        </company>
        <company>
            <name>Bloomburg</name>
            <company_ref>2</company_ref>
        </company>
        <company>
            <name>Morris</name>
            <company_ref>3</company_ref>
        </company>
    </company_group>

    <company_group>
        <company_group_name>Electrical</company_group_name>
        <company_group_ref>2</company_group_ref>
        <company>
            <name>Armstrong</name>
            <company_ref>1</company_ref>
        </company>
        <company>
            <name>Bloomburg</name>
            <company_ref>2</company_ref>
        </company>
        <company>
            <name>Zap Electrical</name>
            <company_ref>3</company_ref>
        </company>
        <company>
            <name>Morris</name>
            <company_ref>4</company_ref>
        </company>
    </company_group>

</all_companies>

THANKS!!!

Body:
Your constraint to require uniqueness of group_refs is correct. The constraint to make company_refs unique within a group should read like this

<xs:element name="company_group">
  <xs:unique name="company_unique_within_group">
    <xs:selector xpath="company">
    <xs:field xpath="company_ref">
  </xs:unique>
  ...
</xs:element>

Read that as "within a company_group" "select all company" and require that "company_ref is unique among them".

Your company_ref constraint says: "globally" "for all company_groups" require that "company/company_ref is unique".

Your condensed constraint expresses something entirely different: "globally" "for all company_groups" require that "the combination of company_group_ref and company/company_ref" is unique". Given that there are actually multiple company_refs per group, the latter two are nonsensical.


问:
Underline two letters separately
Is there a way to have non-continuous underline? I want the underline stop and restart (and see that visually) where I closed and reopened the  tags..

W. Raven, “al-Washshaʾ”```

答:
The simplest option would be to style the underlines to have a small amount of padding on their right.

u { padding-right: 2px; }```
<pre class="snippet-code-html lang-html prettyprint-override"><code>W. Raven, “al-Wa<u>sh</u><u>sh</u>aʾ”</code>```

Alternatively, if you want to be smarter with it and only apply it to two consecutive underlines. This finds any underline that directly follows another, and adds padding to it's left.

u + u{
  padding-left: 2px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>W. Raven, “al-Wa<u>sh</u><u>sh</u>aʾ”</code>```

Title: Underline two letters separately

Body:
The simplest option would be to style the underlines to have a small amount of padding on their right.

u { padding-right: 2px; }

W. Raven, “al-Wa<u>sh</u><u>sh</u>aʾ”

Alternatively, if you want to be smarter with it and only apply it to two consecutive underlines. This finds any underline that directly follows another, and adds padding to it's left.

u + u{
  padding-left: 2px;
}

W. Raven, “al-Wa<u>sh</u><u>sh</u>aʾ”


问:
Ionic App convert JSON to array
I'm pretty new to both Ionic and Angular so please excuse if this question doesn't make much sense.

Platform : Ionic 3.

I have a provider : rest.ts as follows

```<code>getLights() {
  return new Promise(resolve => {
    this.http.get(this.apiUrl+'/lights').subscribe(data => {
      resolve(data);
    }, err => {
      console.log(err);
    });
  });
}
</code>```

This returns the following data (sensitive info removed)

```<code>{
    "1": {
        "state": {
            "on": false,
            "bri": 98,
            "alert": "none",
            "reachable": true
        },
        "swupdate": {
            "state": "noupdates",
            "lastinstall": null
        },
        "type": "Dimmable light",
        "name": "Lion",
        "modelid": "LWB010",
        "manufacturername": "Philips",
    },
    "2": {
        "state": {
            "on": true,
            "bri": 100,
            "alert": "none",
            "reachable": true
        },
        "swupdate": {
            "state": "noupdates",
            "lastinstall": null
        },
        "type": "Dimmable light",
        "name": "Brutus",
        "modelid": "LWB010",
        "manufacturername": "Philips",
    },
    "3": {
        "state": {
            "on": true,
            "bri": 254,
            "hue": 8418,
            "sat": 140,
            "effect": "none",
            "xy": [
                0.4573,
                0.41
            ],
            "ct": 366,
            "alert": "none",
            "colormode": "ct",
            "reachable": true
        },
        "swupdate": {
            "state": "noupdates",
            "lastinstall": null
        },
        "type": "Extended color light",
        "name": "Hue lightstrip plus 1",
        "modelid": "LST002",
        "manufacturername": "Philips"
    }
}
</code>```

An ionic page 'list' made up of : list.ts

```<code>export class ListPage {

  lights: any;
  icons: string[];

  constructor(public navCtrl: NavController,
              public navParams: NavParams,
              public restProvider: RestProvider) {

    this.getLights();
  }

  getLights() {
    this.restProvider.getLights()
    .then(data => {
      this.lights = data;
      console.log(this.lights);
    });
  }

}
</code>```

and list.html :

```<code><ion-content>
  <ion-list inset>
    <ion-item *ngFor="let light of lights">
      <h2>{{light.name}}</h2>
      <p>{{light.type}}</p>
    </ion-item>
  </ion-list>
</ion-content>
</code>```

Although the console log statement displays the JSON correctly, I can't iterate it using ngFor in list.html due to the following error.

Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

I realise I need to convert the JSON into a javascript array, but not sure where or how to do this.  Any pointers would be very much appreciated.

答:
Thank you for the response above. Very helpful, but unfortunately I couldn't get any of it to work as I expected ... down to my inexperience likely.

I'm still unable to get round the issue of the JSON containing numbers as keys and being able to iterate over the lights....

However, I was able to cast the response of one light (altering my API call to get light '1') :

```<code>{
"state": {
   "on": false,
   "bri": 98,
   "alert": "none",
   "reachable": true
},
"swupdate": {
  "state": "noupdates",
  "lastinstall": null
},
"type": "Dimmable light",
"name": "Lion",
"modelid": "LWB010",
"manufacturername": "Philips",
}
</code>```

using interfaces :

```<code>export interface State {

  on: boolean;
  bri: number;
  alert: string;
  reachable: boolean;
}

export interface Swupdate {
  state: string;
  lastinstall?: any;
}

export interface Light {
  state: State;
  swupdate: Swupdate;
  type: string;
  name: string;
  modelid: string;
  manufacturername: string;
  uniqueid: string;
  swversion: string;
  swconfigid: string;
  productid: string;
}
</code>```

Then using the HttpClient call to cast the object as follows :

```<code>this.http.get<Light>(this.apiUrl+'/lights/1').subscribe(data => {
        console.log(data.state.bri);
})
</code>```

If anyone can detail the structure of an interface that might successfully cast a list of lights where the key is a number, that would be ideal ...

Title: Ionic App convert JSON to array

Body:
I'm pretty new to both Ionic and Angular so please excuse if this question doesn't make much sense.

Platform : Ionic 3.

I have a provider : rest.ts as follows

getLights() {
  return new Promise(resolve => {
    this.http.get(this.apiUrl+'/lights').subscribe(data => {
      resolve(data);
    }, err => {
      console.log(err);
    });
  });
}

This returns the following data (sensitive info removed)

{
    "1": {
        "state": {
            "on": false,
            "bri": 98,
            "alert": "none",
            "reachable": true
        },
        "swupdate": {
            "state": "noupdates",
            "lastinstall": null
        },
        "type": "Dimmable light",
        "name": "Lion",
        "modelid": "LWB010",
        "manufacturername": "Philips",
    },
    "2": {
        "state": {
            "on": true,
            "bri": 100,
            "alert": "none",
            "reachable": true
        },
        "swupdate": {
            "state": "noupdates",
            "lastinstall": null
        },
        "type": "Dimmable light",
        "name": "Brutus",
        "modelid": "LWB010",
        "manufacturername": "Philips",
    },
    "3": {
        "state": {
            "on": true,
            "bri": 254,
            "hue": 8418,
            "sat": 140,
            "effect": "none",
            "xy": [
                0.4573,
                0.41
            ],
            "ct": 366,
            "alert": "none",
            "colormode": "ct",
            "reachable": true
        },
        "swupdate": {
            "state": "noupdates",
            "lastinstall": null
        },
        "type": "Extended color light",
        "name": "Hue lightstrip plus 1",
        "modelid": "LST002",
        "manufacturername": "Philips"
    }
}

An ionic page 'list' made up of : list.ts

export class ListPage {

  lights: any;
  icons: string[];

  constructor(public navCtrl: NavController,
              public navParams: NavParams,
              public restProvider: RestProvider) {

    this.getLights();
  }

  getLights() {
    this.restProvider.getLights()
    .then(data => {
      this.lights = data;
      console.log(this.lights);
    });
  }

}

and list.html :

<ion-content>
  <ion-list inset>
    <ion-item *ngFor="let light of lights">

{{light.name}}

{{light.type}}

    </ion-item>
  </ion-list>
</ion-content>

Although the console log statement displays the JSON correctly, I can't iterate it using ngFor in list.html due to the following error.

Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

I realise I need to convert the JSON into a javascript array, but not sure where or how to do this.  Any pointers would be very much appreciated.

Body:
Thank you for the response above. Very helpful, but unfortunately I couldn't get any of it to work as I expected ... down to my inexperience likely.

I'm still unable to get round the issue of the JSON containing numbers as keys and being able to iterate over the lights....

However, I was able to cast the response of one light (altering my API call to get light '1') :

{
"state": {
   "on": false,
   "bri": 98,
   "alert": "none",
   "reachable": true
},
"swupdate": {
  "state": "noupdates",
  "lastinstall": null
},
"type": "Dimmable light",
"name": "Lion",
"modelid": "LWB010",
"manufacturername": "Philips",
}

using interfaces :

export interface State {

  on: boolean;
  bri: number;
  alert: string;
  reachable: boolean;
}

export interface Swupdate {
  state: string;
  lastinstall?: any;
}

export interface Light {
  state: State;
  swupdate: Swupdate;
  type: string;
  name: string;
  modelid: string;
  manufacturername: string;
  uniqueid: string;
  swversion: string;
  swconfigid: string;
  productid: string;
}

Then using the HttpClient call to cast the object as follows :

this.http.get<Light>(this.apiUrl+'/lights/1').subscribe(data => {
        console.log(data.state.bri);
})

If anyone can detail the structure of an interface that might successfully cast a list of lights where the key is a number, that would be ideal ...