问:
Print a file saved in C #
I'm trying to print in winform, it turns out that when I print the document, I get the blank sheet.
This is the code with which I try to print:

```<code>    private PrintDocument printDocument1 = new PrintDocument();
    private string stringToPrint;
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        ReadPrint();
        printDocument1.Print();
    }

    private void ReadPrint()
    {
        string docName = "ejemplo.pdf";
        string docPath = @"C:\dir1\";
        printDocument1.DocumentName = docName;
        using (FileStream stream = new FileStream(docPath + docName, FileMode.Open, FileAccess.Read))
        using (StreamReader reader = new StreamReader(stream))
        {
            stringToPrint = reader.ReadToEnd();
        }
    }

    private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
    {
        int charactersOnPage = 0;
        int linesPerPage = 0;

        e.Graphics.MeasureString(stringToPrint, this.Font,
            e.MarginBounds.Size, StringFormat.GenericTypographic,
            out charactersOnPage, out linesPerPage);

        e.Graphics.DrawString(stringToPrint, this.Font, Brushes.Black,
            e.MarginBounds, StringFormat.GenericTypographic);

        stringToPrint = stringToPrint.Substring(charactersOnPage);

        e.HasMorePages = (stringToPrint.Length > 0);
    }

    private void printButton_Click(object sender, EventArgs e)
    {
        LeerArchivo();
        printDocument1.Print();
    }
</code>```

I would like to know if there is a way to correct it or some other way to print the file?Or some example code?
regards

In stringToPrint:

答:
Are you sure that the stringToPrint is not empty or null ? I'm using the same thing and it works perfectly. You should try to add a print PrintPreviewDialog in case you want to check if the document to be print is not blank. Check your variables first.

```<code>e.Graphics.DrawString("SomeString", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(580, 510));

e.Graphics.DrawString("SomeString1", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(700, 510));
</code>```

for the parameter new Point() it is where your text appears via x and y coordinates.

Title: Print a file saved in C #

Body:
I'm trying to print in winform, it turns out that when I print the document, I get the blank sheet.
This is the code with which I try to print:

    private PrintDocument printDocument1 = new PrintDocument();
    private string stringToPrint;
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        ReadPrint();
        printDocument1.Print();
    }

    private void ReadPrint()
    {
        string docName = "ejemplo.pdf";
        string docPath = @"C:\dir1\";
        printDocument1.DocumentName = docName;
        using (FileStream stream = new FileStream(docPath + docName, FileMode.Open, FileAccess.Read))
        using (StreamReader reader = new StreamReader(stream))
        {
            stringToPrint = reader.ReadToEnd();
        }
    }

    private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
    {
        int charactersOnPage = 0;
        int linesPerPage = 0;

        e.Graphics.MeasureString(stringToPrint, this.Font,
            e.MarginBounds.Size, StringFormat.GenericTypographic,
            out charactersOnPage, out linesPerPage);

        e.Graphics.DrawString(stringToPrint, this.Font, Brushes.Black,
            e.MarginBounds, StringFormat.GenericTypographic);

        stringToPrint = stringToPrint.Substring(charactersOnPage);

        e.HasMorePages = (stringToPrint.Length > 0);
    }

    private void printButton_Click(object sender, EventArgs e)
    {
        LeerArchivo();
        printDocument1.Print();
    }

I would like to know if there is a way to correct it or some other way to print the file?Or some example code?
regards

In stringToPrint:

Body:
Are you sure that the stringToPrint is not empty or null ? I'm using the same thing and it works perfectly. You should try to add a print PrintPreviewDialog in case you want to check if the document to be print is not blank. Check your variables first.

e.Graphics.DrawString("SomeString", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(580, 510));

e.Graphics.DrawString("SomeString1", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(700, 510));

for the parameter new Point() it is where your text appears via x and y coordinates.


来源: stackexchange

问:
Oracle sql - what does (+) represent here
I understand that (+) can be used to represent an outer join in oracle sql.
What does the (+) in this code mean? </p>

```<code>where sysdate between start_date(+) and end_date(+)
</code>```

答:
It allows for an outer join to "survive" the where clause conditions. i.e. it also allows NULLs to be returned. e.g. below

```<code>select *
from from_table ft, outer_table ot
where sysdate between ot.start_date(+) and ot.end_date(+)
and ft.id = ot.ft_fk(+)
</code>```

an equivalent for that could be:

```<code>select *
from from_table ft
left join outer_table ot on ft.id = ot.ft_fk and sysdate between ot.start_date and ot.end_date
</code>```

or, an equivalent for that could be:

```<code>select *
from from_table ft
left join outer_table ot on ft.id = ot.ft_fk
where (sysdate between ot.start_date and ot.end_date OR ot.start_date IS NULL)
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I understand that (+) can be used to represent an outer join in oracle sql.
What does the (+) in this code mean?

where sysdate between start_date(+) and end_date(+)

Body:
It allows for an outer join to "survive" the where clause conditions. i.e. it also allows NULLs to be returned. e.g. below

select *
from from_table ft, outer_table ot
where sysdate between ot.start_date(+) and ot.end_date(+)
and ft.id = ot.ft_fk(+)

an equivalent for that could be:

select *
from from_table ft
left join outer_table ot on ft.id = ot.ft_fk and sysdate between ot.start_date and ot.end_date

or, an equivalent for that could be:

select *
from from_table ft
left join outer_table ot on ft.id = ot.ft_fk
where (sysdate between ot.start_date and ot.end_date OR ot.start_date IS NULL)


问:
c++ Linked List Stack Pop Function Crashing
I am having the worlds most difficult time understanding this linked list stack. I have been given a fixed ".h" file that I am not allowed to edit, and I am to write the push and pop functions. My pop function, however, is crashing the program and I am unsure why. My pop function is as follows:

```<code> int IntStack::pop(){
    int result = -1;
    if(isEmpty()){
        result = head->data; //program crashes here
        Node *temp;
        temp = head->next;
        delete head;
        head = temp;
    }
    return result;
}
</code>```

My nodes are the following;

```<code>struct Node{
     int data;
     Node* next;
};
</code>```

Any insight as to why this is crashing and how I can fix it would be appreciated. Also, I am not allowed to have a parameter in the function. Thank you

EDIT: I made the changes suggested to the function, and here is the rest of my code.

```<code> #include <iostream>
 #include <fstream>
 #include <string>
 #include "IntStack.h"

 using namespace std;

 bool ArePair(int first,char last){
     if(first == '(' && last == ')') return true;
     else if(first == '{' && last == '}') return true;
     else if(first == '[' && last==']') return true;
     return false;
 }

 int main(){
     string fileName;

     cout << "Hello, please enter a filename: ";
     cin >> fileName;

     ifstream inFile;

     inFile.open(fileName.c_str());

     while (!inFile){
         cerr << "ERROR: Cannot open " << fileName << ". Please re-enter.\n";
         cin >> fileName;
         inFile.open(fileName.c_str());
     }

     string current;
     IntStack iStack;
     int par; //parenthesis

     while(inFile){
        inFile >> current;

        for(int i=0;i<current.length();i++){
             if(current[i] == '('||current[i] == '{'||current[i] == '['){
                 par = current[i];
                 iStack.push(par);
                }
             else if(current[i] == ')'||current[i] == '}'||current[i] == ']'){
                 if(!iStack.isEmpty() || !ArePair(par,current[i])){
                     cout << "debug\n";
                 }
                 else{
                    iStack.pop();
                 }
             }
         }
     }

     inFile.close();

 }
</code>```

I think i may have an invalid pointer on the head of my pop function, but i am unsure. Or perhaps its my push function?

```<code> void IntStack::push(int data){
     assert(!isFull());
         Node *temp = new Node;
         temp->data = data;
         temp->next = NULL;
         temp = head;
 }
</code>```

答:
What are you trying to do in that code exactly? You could've just done int result = head->data; instead of the whole rigamarole with temp, which you just remove in the end. Also I reckon you never really remove head the way I suppose you want to.

I'm guessing this is what you were asking about:

```<code>int IntStack::pop(){
   int result = -1;             //Assume there is no element to pop
   if(!this->isEmpty()){        //if the stack is not empty,
        result = head->data;    //save the head's data in result
        Node *temp;             //make a temp node
        temp = head->next;      //point it to the node after the head
        delete head;            //remove the head
        head = temp;            //make the one after it the new head
    }
    return result;              //return the result
}
</code>```

EDIT:

You're missing the head node and the tail node in your code.
When you have the tail node, the push should look like this:

```<code> void IntStack::push(char data){
     if(!this->isFull()){
         Node *temp = new Node;
         temp->data = data;
         tail->next = temp;
         temp->next = NULL;
     }
 }
</code>```

ArePair has a loose return at the end you ought to regulate like this:

```<code> bool ArePair(int first, char last){
     if((first == '(' && last == ')') ||
        (first == '{' && last == '}') ||
        (first == '[' && last == ']'))
          return true;
     else return false;
 }
</code>```

I think you'll find this more useful since you know the rest of your code yourself, and there are some basic constructs to cover here.
https://www.codementor.io/codementorteam/a-comprehensive-guide-to-implementation-of-singly-linked-list-using-c_plus_plus-ondlm5azr

Body:
I am having the worlds most difficult time understanding this linked list stack. I have been given a fixed ".h" file that I am not allowed to edit, and I am to write the push and pop functions. My pop function, however, is crashing the program and I am unsure why. My pop function is as follows:

 int IntStack::pop(){
    int result = -1;
    if(isEmpty()){
        result = head->data; //program crashes here
        Node *temp;
        temp = head->next;
        delete head;
        head = temp;
    }
    return result;
}

My nodes are the following;

struct Node{
     int data;
     Node* next;
};

Any insight as to why this is crashing and how I can fix it would be appreciated. Also, I am not allowed to have a parameter in the function. Thank you

EDIT: I made the changes suggested to the function, and here is the rest of my code.

 #include <iostream>
 #include <fstream>
 #include <string>
 #include "IntStack.h"

 using namespace std;

 bool ArePair(int first,char last){
     if(first == '(' && last == ')') return true;
     else if(first == '{' && last == '}') return true;
     else if(first == '[' && last==']') return true;
     return false;
 }

 int main(){
     string fileName;

     cout << "Hello, please enter a filename: ";
     cin >> fileName;

     ifstream inFile;

     inFile.open(fileName.c_str());

     while (!inFile){
         cerr << "ERROR: Cannot open " << fileName << ". Please re-enter.\n";
         cin >> fileName;
         inFile.open(fileName.c_str());
     }

     string current;
     IntStack iStack;
     int par; //parenthesis

     while(inFile){
        inFile >> current;

        for(int i=0;i<current.length();i++){
             if(current[i] == '('||current[i] == '{'||current[i] == '['){
                 par = current[i];
                 iStack.push(par);
                }
             else if(current[i] == ')'||current[i] == '}'||current[i] == ']'){
                 if(!iStack.isEmpty() || !ArePair(par,current[i])){
                     cout << "debug\n";
                 }
                 else{
                    iStack.pop();
                 }
             }
         }
     }

     inFile.close();

 }

I think i may have an invalid pointer on the head of my pop function, but i am unsure. Or perhaps its my push function?

 void IntStack::push(int data){
     assert(!isFull());
         Node *temp = new Node;
         temp->data = data;
         temp->next = NULL;
         temp = head;
 }

Body:
What are you trying to do in that code exactly? You could've just done int result = head->data; instead of the whole rigamarole with temp, which you just remove in the end. Also I reckon you never really remove head the way I suppose you want to.

I'm guessing this is what you were asking about:

int IntStack::pop(){
   int result = -1;             //Assume there is no element to pop
   if(!this->isEmpty()){        //if the stack is not empty,
        result = head->data;    //save the head's data in result
        Node *temp;             //make a temp node
        temp = head->next;      //point it to the node after the head
        delete head;            //remove the head
        head = temp;            //make the one after it the new head
    }
    return result;              //return the result
}

EDIT:

You're missing the head node and the tail node in your code.
When you have the tail node, the push should look like this:

 void IntStack::push(char data){
     if(!this->isFull()){
         Node *temp = new Node;
         temp->data = data;
         tail->next = temp;
         temp->next = NULL;
     }
 }

ArePair has a loose return at the end you ought to regulate like this:

 bool ArePair(int first, char last){
     if((first == '(' && last == ')') ||
        (first == '{' && last == '}') ||
        (first == '[' && last == ']'))
          return true;
     else return false;
 }

I think you'll find this more useful since you know the rest of your code yourself, and there are some basic constructs to cover here.
https://www.codementor.io/codementorteam/a-comprehensive-guide-to-implementation-of-singly-linked-list-using-c_plus_plus-ondlm5azr


问:
Capturing the finished installing event for ActiveX
At the moment I have a custom ActiveX plugin that drops down the usual yellow bar with the install button if the user doesn't have it. When they finish installing, however, I need the page to automatically refresh. Is there a way to detect that the plugin has been successfully installed that isn't constantly polling for the plugin's presence. That is to say, not doing this:

```<code>function checkForPlugin() {
    try {
            control = new ActiveXObject('Object.One');
            //refresh
    } catch (e) {
            setTimeout("checkForPlugin()" ,2000);
    }
}
</code>```

This doesn't seem terribly professional and I'm curious if there is a better approach I could be taking. Come to think of it...I'm not exactly sure how I'd refresh there anyway, does anyone have insight on that as well? Thanks.

Update -- I have it working using the above method and even solved the refresh issue. I'm really not thrilled with this as an implementation though. It just feels wrong to leave the browser sitting there constantly polling in the background until it gets what it wants. It's not terrible I guess but I wish there was a more clean approach. Does anyone have any ideas?

答: You could have your control fire an event and listen for it.</p>

ContentLicense: CC BY-SA 2.5

Body:
At the moment I have a custom ActiveX plugin that drops down the usual yellow bar with the install button if the user doesn't have it. When they finish installing, however, I need the page to automatically refresh. Is there a way to detect that the plugin has been successfully installed that isn't constantly polling for the plugin's presence. That is to say, not doing this:

function checkForPlugin() {
    try {
            control = new ActiveXObject('Object.One');
            //refresh
    } catch (e) {
            setTimeout("checkForPlugin()" ,2000);
    }
}

This doesn't seem terribly professional and I'm curious if there is a better approach I could be taking. Come to think of it...I'm not exactly sure how I'd refresh there anyway, does anyone have insight on that as well? Thanks.

Update -- I have it working using the above method and even solved the refresh issue. I'm really not thrilled with this as an implementation though. It just feels wrong to leave the browser sitting there constantly polling in the background until it gets what it wants. It's not terrible I guess but I wish there was a more clean approach. Does anyone have any ideas?


问:
duplicate view of debugger window on Visual Studio
I would like to have 2 instance of the "machine code" view on the Visual Studio debugger

Someone can help me ?

thanks

答:
Not find the better answer, it just opens one "Machine Code/Disassembly" window if we debug one app just with one VS instance in default. If we want to get two windows, we often debug projects using two VS instance.

I help you submit a feature request to the product team:

https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/32528791-duplicate-view-of-debugger-window-on-visual-studio

If possible, you could add your comment and vote this user voice.


问:
Running two threads in same time ( multithreading?)
I'm trying to get two threads to work in same time.
Let me explain with code:

Main Class that runs both threads

```<code>public static void main(String[] args) {
    abThread.move(5);
    cdThread.move(5);
}
</code>```

Thread 1:

```<code>static void move(int i) {
    int min = 0;
    int max = 100;

    while (i > 0) {
        int a = ThreadLocalRandom.current().nextInt(min, max + 1);
        //  try {
        //      Thread.sleep(100);
        //  } catch (Exception e) {
        //  }

        if ((a % 2) == 1) {
            System.out.println("a");
            i -= 1;
            continue;
        } else {
            System.out.println("b");
            i -= 1;
            continue;
        }
    }
}
</code>```

Thread 2:

```<code>static void move(int i) {
    int min = 0;
    int max = 100;

    while (i > 0) {
        int a = ThreadLocalRandom.current().nextInt(min, max + 1);
        //  try {
        //      Thread.sleep(100);
        //  } catch (Exception e) {
        //  }

        if ((a % 2) == 1) {
            System.out.println("c");
            i -= 1;
            continue;
        } else {
            System.out.println("d");
            i -= 1;
            continue;
        }
    }
}
</code>```

Im getting random a/b x 5 and after 5 of them im getting random (c/d) x5

My goal is to get a/b,c/d,a/b,c/d... and so on

Any help or redirection to some way-would greatly appreciate it!

Edit: Notice i tryed with try sleep but it just postpones how long before next a/b after a/b. Only way i could do it a/b,c/b would be

```<code>    abThread.move(1);
    cdThread.move(1);
    abThread.move(1);
</code>```

......

Thanks

答:
If you really want to experiment with threads, not only print characters alternately, you could try something like this:

First of all, implement Runnable that holds code to be run by threads:

```<code>class Task implements Runnable {
    //c1 and c2 are characters to print (a,b and c,d for example)
    private final String c1, c2;
    //semaphore guarantees the order of threads execution
    private final Semaphore sync;
    private int i;

    Task(int i, String c1, String c2, Semaphore sync) {
        this.i = i;
        this.c1 = c1;
        this.c2 = c2;
        this.sync = sync;
    }
    @Override
    public void run() {
        try {
            int min = 0;
            int max = 100;
            while (i > 0) {
                sync.acquire();
                int a = ThreadLocalRandom.current().nextInt(min, max + 1);
                if ((a % 2) == 1) {
                    System.out.println(c1);
                    i -= 1;
                } else {
                    System.out.println(c2);
                    i -= 1;
                }
                sync.release();
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
</code>```

Then create Semaphore:

```<code>Semaphore sync = new Semaphore(0, true);
</code>```

Create two threads and run them:

```<code>Thread t1 = new Thread(new Task(10, "a", "b", sync));
Thread t2 = new Thread(new Task(10, "c", "d", sync));

t1.start();
t2.start();
</code>```

And finally release semaphore so that one of the threads waiting on it can proceed:

```<code>sync.release();
</code>```

Body:
I'm trying to get two threads to work in same time.
Let me explain with code:

Main Class that runs both threads

public static void main(String[] args) {
    abThread.move(5);
    cdThread.move(5);
}

Thread 1:

static void move(int i) {
    int min = 0;
    int max = 100;

    while (i > 0) {
        int a = ThreadLocalRandom.current().nextInt(min, max + 1);
        //  try {
        //      Thread.sleep(100);
        //  } catch (Exception e) {
        //  }

        if ((a % 2) == 1) {
            System.out.println("a");
            i -= 1;
            continue;
        } else {
            System.out.println("b");
            i -= 1;
            continue;
        }
    }
}

Thread 2:

static void move(int i) {
    int min = 0;
    int max = 100;

    while (i > 0) {
        int a = ThreadLocalRandom.current().nextInt(min, max + 1);
        //  try {
        //      Thread.sleep(100);
        //  } catch (Exception e) {
        //  }

        if ((a % 2) == 1) {
            System.out.println("c");
            i -= 1;
            continue;
        } else {
            System.out.println("d");
            i -= 1;
            continue;
        }
    }
}

Im getting random a/b x 5 and after 5 of them im getting random (c/d) x5

My goal is to get a/b,c/d,a/b,c/d... and so on

Any help or redirection to some way-would greatly appreciate it!

Edit: Notice i tryed with try sleep but it just postpones how long before next a/b after a/b. Only way i could do it a/b,c/b would be

    abThread.move(1);
    cdThread.move(1);
    abThread.move(1);

......

Thanks

Body:
If you really want to experiment with threads, not only print characters alternately, you could try something like this:

First of all, implement Runnable that holds code to be run by threads:

class Task implements Runnable {
    //c1 and c2 are characters to print (a,b and c,d for example)
    private final String c1, c2;
    //semaphore guarantees the order of threads execution
    private final Semaphore sync;
    private int i;

    Task(int i, String c1, String c2, Semaphore sync) {
        this.i = i;
        this.c1 = c1;
        this.c2 = c2;
        this.sync = sync;
    }
    @Override
    public void run() {
        try {
            int min = 0;
            int max = 100;
            while (i > 0) {
                sync.acquire();
                int a = ThreadLocalRandom.current().nextInt(min, max + 1);
                if ((a % 2) == 1) {
                    System.out.println(c1);
                    i -= 1;
                } else {
                    System.out.println(c2);
                    i -= 1;
                }
                sync.release();
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}

Then create Semaphore:

Semaphore sync = new Semaphore(0, true);

Create two threads and run them:

Thread t1 = new Thread(new Task(10, "a", "b", sync));
Thread t2 = new Thread(new Task(10, "c", "d", sync));

t1.start();
t2.start();

And finally release semaphore so that one of the threads waiting on it can proceed:

sync.release();


问:
Call cv::VideoCapture constructor conditionally
I want to call the cv::VideoCapture constructor conditionally. If argc == 2, then the user has specified a video file and I want to load that. Otherwise use the default camera.

```<code>#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;

int main(int argc, char* argv[])
{
    VideoCapture cap(argc == 2 ? argv[1] : 0);

    return 0;
}
</code>```

I compile and run it

```<code>$ g++ -g -Wall -o main main.cpp `pkg-config opencv --cflags --libs`
$ ./main
</code>```

But sadly it doesn't seem to work and I get

```<code>OpenCV: Couldn't read movie file ""
</code>```

The ternary operator returns a string in one case and an integer in another. I reckon this won't work because of some idiosyncrasy of C++ constructors I'm not aware of.

What's the cleanest way to do what I want? Can I do it without using new so that I don't have to free memory myself at the end of the program?

答:
Expression A ? B : C has a return type of B and C must be implicitly convertible to B. Some compilers will not compile (best behavior), some will. In your case, B = char * and C = int. I believe 0 is interpreted as pointer to address 0 or NULL whose byte equal '\0' i.e. null-termination character that marks the end of a C-style string hence the empty string.

If you insist on a one-liner, then:

```<code>std::unique_ptr<VideoCapture> capture = (argc == 2 ? std::make_unique<VideoCapture>(argv[1]) : std::make_unique<VideoCapture>(0));
</code>```

Body:
I want to call the cv::VideoCapture constructor conditionally. If argc == 2, then the user has specified a video file and I want to load that. Otherwise use the default camera.

#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;

int main(int argc, char* argv[])
{
    VideoCapture cap(argc == 2 ? argv[1] : 0);

    return 0;
}

I compile and run it

$ g++ -g -Wall -o main main.cpp `pkg-config opencv --cflags --libs`
$ ./main

But sadly it doesn't seem to work and I get

OpenCV: Couldn't read movie file ""

The ternary operator returns a string in one case and an integer in another. I reckon this won't work because of some idiosyncrasy of C++ constructors I'm not aware of.

What's the cleanest way to do what I want? Can I do it without using new so that I don't have to free memory myself at the end of the program?

Body:
Expression A ? B : C has a return type of B and C must be implicitly convertible to B. Some compilers will not compile (best behavior), some will. In your case, B = char * and C = int. I believe 0 is interpreted as pointer to address 0 or NULL whose byte equal '\0' i.e. null-termination character that marks the end of a C-style string hence the empty string.

If you insist on a one-liner, then:

std::unique_ptr<VideoCapture> capture = (argc == 2 ? std::make_unique<VideoCapture>(argv[1]) : std::make_unique<VideoCapture>(0));


问:
Not able to resize objects <HREF> + Media Query CSS
I am having problems with resizing some buttons in my page because when you resize the page for the screen of a mobile phone and you try to click on them <href "1.htm">, they will do not do anything.

I know that it is a problem of the media query but I do not how to solve it.

index.html:

```<code><!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">

    <title>DaZPlayer</title>
        <link rel="stylesheet" type="text/css" href="index_files/styles.css">
      <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script>
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
      <link rel="stylesheet" href="index_files/menu.css">

  </head>
  <body>
    <a href="1"><img class="portada" src="index_files/DaZ-Player_v2.jpg"></a>

    <link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
  <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">

  <nav class="nav">
    <input class="chk-nav" type="checkbox" id="btn-navbar" />
    <label for="btn-navbar"><i class="fa fa-bars"></i></label>

    <ul class="navbar">
      <li><a href="#" class="casa"><i class="fa fa-home"></i>Inicio</a></li>
      <li>
        <!--- SI QUIERES PONER UNA FLECHA DEBES PONER  CLASS lbl-nav --->
          <label for="btn-subnav1">
            <i class="fa fa-play-circle"></i>Canales
          </label>
          <input class="chk-nav" type="checkbox" id="btn-subnav1"/>

          <!--- ESTO ES POR SÍ QUIERES PONER MÁS COSAS ADENTRO DE UNA

          <ul class="sub-nav">
            <li><a href="#">Excel básico</a></li>
            <li><a href="#">Diseño web</a></li>
            <li><a href="#">Computación básica</a></li>
            <li><a href="#">Fundamentos de programación</a></li>
          </ul>
          --->

      </li>
      <li>
          <label class="" for="btn-subnav2">
               <i class="fa fa-info-circle"></i>Nosotros
          </label>
          <input class="chk-nav" type="checkbox" id="btn-subnav2" />

          <!--- ESTO ES POR SÍ QUIERES PONER MÁS COSAS ADENTRO DE UNA

          <ul class="sub-nav">
            <li><a href="#">Excel básico</a></li>
            <li><a href="#">Diseño web</a></li>
            <li><a href="#">Computación básica</a></li>
            <li><a href="#">Fundamentos de programación</a></li>
          </ul> --->
      </li>
      <li><a href="#" class="casa"><i class="fa fa-envelope"></i>Contáctenos</a></li>
    </ul>
  </nav>

  <!--- Ya Por fin Comenzamoz y salimos del Menu --->
  <h1 class="titulo_1">Canales de TV en Vivo</h1>
  <div id="contenedor1">
    <br>
    <a href="1" class="conexion"><img alt="" class="canales" src="img_canales/cnn.png"></a>
    <a href="2" class="conexion"><img alt="" class="canales" src="img_canales/rt1.png"></a>
    <a href="3" class="conexion"><img alt="" class="canales_mas_ancho" src="img_canales/todo_noticias.png"></a>
    <a href="4" class="conexion"><img alt="" class="canales_mas_ancho" src="img_canales/tlx_arg.png"></a>
  </div>

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

menu.css:

```<code>/*_________________________________________________________________

                      $RESET
____________________________________________________________________*/
*, *:before, *:after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/*_________________________________________________________________

                      $ESTILOS GENERALES
____________________________________________________________________*/
ul {
  list-style-type: none;
}

.casa, label {
  display: block;
  font-size: 1.25rem;
  text-decoration: none;
  color: #E5E5E5;
  padding: 1rem 1rem 1rem 3rem;
  cursor: pointer;
  -webkit-transition: all .3s ease;
  transition: all .3s ease;
  border-left: 4px solid rgba(255, 255, 255, 0);
}
.casa:hover, label:hover {
  color: #FFB503;
  border-left: 4px solid #049CF3;
}

.chk-nav {
  display: none;
}

/*_________________________________________________________________

                      $NAV <nav class"nav"></nav>
____________________________________________________________________*/
.nav {
  width: 100%;
  position: absolute;
  z-index: 10;
}

/*_________________________________________________________________

                      $NAVBAR <ul class"nav-bar"></ul>
____________________________________________________________________*/
.navbar {
  width: 50%;
}
.navbar .sub-nav {
  display: block;
}

.sub-nav .casa {
  padding-left: 2rem;
  font-size: 1rem;
}

.navbar > li {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
}

/*_________________________________________________________________

$ESTILOS PARA MODIFICAR EL LABEL SECUNDARIO DEL SUBMENU
____________________________________________________________________*/
.navbar .fa {
  position: absolute;
  left: 1rem;
}

/* 25BC es la flecha */
.lbl-nav:after {
  content: "\25BC";
  font-size: 1rem;
  position: absolute;
  width: 100%;
  text-align: right;
  left: 0;
  padding-right: .75rem;
  line-height: 1.5rem;
}

/*_________________________________________________________________

$ESTILOS PARA MODIFICAR EL LABEL PRINCIPAL O ICONO DE HAMBURGUESA
____________________________________________________________________*/
label[for="btn-navbar"] {
  padding: .5rem 1rem .5rem 1rem;
  font-size: 2rem;
  text-align: left;
  color: #049CF3;
  background-color: #252525;
}
label[for="btn-navbar"]:hover {
  color: #E5E5E5;
  border-left: 4px solid transparent;
}

/*_________________________________________________________________

$ESTILOS PARA ESCONDER LA LISTA PRINCIPAL DEL MENU
____________________________________________________________________*/
.navbar {
  margin-left: -100%;
  height: 100vh;
  -webkit-transition: all .5s ease;
  transition: all .5s ease;
  background-color: #252525;
}

.chk-nav:checked ~ .navbar {
  margin-left: 0;
}

/*_________________________________________________________________

$ESTILOS PARA ESCONDER LOS SUBMENUS
____________________________________________________________________*/
.navbar .sub-nav {
  display: none;
}

.chk-nav:checked ~ .sub-nav {
  display: block;
}

/****************_________________________________________________________________*******************

                                $ESTILOS PARA DESKTOP MEDIAQUERYS
****************____________________________________________________________________*****************/
@media all and (min-width: 49rem) {
  .casa, label {
    display: block;
    padding: 1rem 1.25rem;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
  }

           /*_________________________________________________________________

            $ESTILOS PARA NAVBAR
          ____________________________________________________________________*/
  .navbar {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: table;
    table-layout: fixed;
    margin: auto;
  }

  .navbar > li {
    display: table-cell;
  }

  .chk-nav:checked ~ .navbar {
    margin: auto;
  }

          /*_________________________________________________________________

            $ESTILOS PARA ESCONDER EL ICONO DE HAMBURGUESA
          ____________________________________________________________________*/
  label[for="btn-navbar"] {
    display: none;
  }

          /*_________________________________________________________________

          $ESTILOS PARA el SUBMENU
          ____________________________________________________________________*/
  .navbar .sub-nav {
    display: none;
  }

  .navbar > ul > li {
    position: relative;
  }

  .chk-nav:checked ~ .sub-nav {
    display: block;
  }

  .navbar .sub-nav {
    width: 100%;
    background-color: #222;
    position: absolute;
  }

  .sub-nav .casa {
    font-size: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
  }

          /*_________________________________________________________________

                  $ESTILOS PARA LOS ICONOS
            ____________________________________________________________________*/
  .navbar .fa {
    position: static;
    padding-right: .3rem;
  }

  .lbl-nav:after {
    top: 0;
    height: 100%;
    line-height: 3.5rem;
  }

        /*_________________________________________________________________

                  $ESTILOS PARA EL MENU PRINCIPAL
         ____________________________________________________________________*/

         /* BORDES*/

  .navbar > li {
    position: relative;
    border-top: 4px solid #049CF3;
  }

  .navbar > li > .casa:hover, label:hover {
    border-left: 4px solid transparent;
  }
}
</code>```

styles.css:

```<code>    #contenedor1 {
        margin-top: 30px;
        margin-right: 40px;
        margin-bottom: 20px;
        margin-left: 70px;
    }

@media all and (max-width: 450px){
  .portada{
      width:100%;
  }
}

h1.titulo_1 {
  text-align: center;
    font-size: 60px;
    color: black;
    margin-top: 100px;
    margin-right: 40px;
    margin-bottom: 10px;
    margin-left: 40px;
    }

/* CUANDO LA PANTALLA ES MENOR A 1000px PASARA ESTO*/
@media all and (max-width: 1000px){
    .canales{
            width: 155px;
            height: 90px;
    }
}

/* CUANDO LA PANTALLA ES MENOR A 500px PASARA ESTO*/
@media all and (max-width: 300px){
    .canales{
        width: 140px;
        height: 70px;
        display:block;
        margin:auto;
    }
}

/* PARA QUE NO APAREZCAEL TAMAÑO ORIGINAL CUANDO YA ESTA EXTENDIDA LA VENTANA
DEL NAVEGADOR, COLOCAS UN TAMAÑO ESTABLECIDO, EN MI CASO 160px*/
 .canales{
     width: 170px;
     height: 100px;
     margin-bottom: 25px;
     margin-left: 10px;
     border-radius: 20px;
     -webkit-border-radius: 20px;
     -moz-border-radius: 20px;
     -o-border-radius: 20px;
     -ms-border-radius: 20px;
 }

 .canales_mas_ancho{
    width: 170px;
    height: 100px;
    margin-bottom: 25px;
    margin-left: 10px;
    border-radius: 20px;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    -o-border-radius: 20px;
    -ms-border-radius: 20px;
 }

 /* CUANDO LA PANTALLA ES MENOR A 1000px PASARA ESTO*/
 @media all and (max-width: 1000px){
    .canales_mas_ancho{
            width: 155px;
            height: 90px;
    }
 }

 /* CUANDO LA PANTALLA ES MENOR A 500px PASARA ESTO*/
 @media all and (max-width: 300px){
 .canales_mas_ancho{
        width: 140px;
        height: 70px;
        display:block;
        margin:auto;
    }
 }
</code>```

答:
See if this helps you:
https://s.codepen.io/panchroma/debug/EbJdjM/jVMpogKwympk

This pen is the same HTML and CSS that you posted except that in the CSS for the .nav block, starting at line 46, I set a height for the .nav element.

```<code>.nav {
  width: 100%;
  position: absolute;
  z-index: 10;
  height: 55px !important;
  background-color: pink;
}
</code>```

What seemed to be happening with your code is that on mobile viewports, .nav covered the entire window, and therefore you couldn't access the links because they are 'under' the fullscreen nav element. To confirm this, comment out line 50 which is limiting the height of .nav

Good luck!

Body:
I am having problems with resizing some buttons in my page because when you resize the page for the screen of a mobile phone and you try to click on them <href "1.htm">, they will do not do anything.

I know that it is a problem of the media query but I do not how to solve it.

index.html:

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">

    <title>DaZPlayer</title>
        <link rel="stylesheet" type="text/css" href="index_files/styles.css">

      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
      <link rel="stylesheet" href="index_files/menu.css">

    <link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
  <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">

    <input class="chk-nav" type="checkbox" id="btn-navbar" />

Inicio

            Canales

          <input class="chk-nav" type="checkbox" id="btn-subnav1"/>

               Nosotros

          <input class="chk-nav" type="checkbox" id="btn-subnav2" />

Contáctenos

Canales de TV en Vivo

menu.css:

/*_________________________________________________________________

                      $RESET
____________________________________________________________________*/
*, *:before, *:after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/*_________________________________________________________________

                      $ESTILOS GENERALES
____________________________________________________________________*/
ul {
  list-style-type: none;
}

.casa, label {
  display: block;
  font-size: 1.25rem;
  text-decoration: none;
  color: #E5E5E5;
  padding: 1rem 1rem 1rem 3rem;
  cursor: pointer;
  -webkit-transition: all .3s ease;
  transition: all .3s ease;
  border-left: 4px solid rgba(255, 255, 255, 0);
}
.casa:hover, label:hover {
  color: #FFB503;
  border-left: 4px solid #049CF3;
}

.chk-nav {
  display: none;
}

/*_________________________________________________________________

                      $NAV
____________________________________________________________________*/
.nav {
  width: 100%;
  position: absolute;
  z-index: 10;
}

/*_________________________________________________________________

                      $NAVBAR

____________________________________________________________________*/
.navbar {
  width: 50%;
}
.navbar .sub-nav {
  display: block;
}

.sub-nav .casa {
  padding-left: 2rem;
  font-size: 1rem;
}

.navbar > li {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
}

/*_________________________________________________________________

$ESTILOS PARA MODIFICAR EL LABEL SECUNDARIO DEL SUBMENU
____________________________________________________________________*/
.navbar .fa {
  position: absolute;
  left: 1rem;
}

/* 25BC es la flecha */
.lbl-nav:after {
  content: "\25BC";
  font-size: 1rem;
  position: absolute;
  width: 100%;
  text-align: right;
  left: 0;
  padding-right: .75rem;
  line-height: 1.5rem;
}

/*_________________________________________________________________

$ESTILOS PARA MODIFICAR EL LABEL PRINCIPAL O ICONO DE HAMBURGUESA
____________________________________________________________________*/
label[for="btn-navbar"] {
  padding: .5rem 1rem .5rem 1rem;
  font-size: 2rem;
  text-align: left;
  color: #049CF3;
  background-color: #252525;
}
label[for="btn-navbar"]:hover {
  color: #E5E5E5;
  border-left: 4px solid transparent;
}

/*_________________________________________________________________

$ESTILOS PARA ESCONDER LA LISTA PRINCIPAL DEL MENU
____________________________________________________________________*/
.navbar {
  margin-left: -100%;
  height: 100vh;
  -webkit-transition: all .5s ease;
  transition: all .5s ease;
  background-color: #252525;
}

.chk-nav:checked ~ .navbar {
  margin-left: 0;
}

/*_________________________________________________________________

$ESTILOS PARA ESCONDER LOS SUBMENUS
____________________________________________________________________*/
.navbar .sub-nav {
  display: none;
}

.chk-nav:checked ~ .sub-nav {
  display: block;
}

/****************_________________________________________________________________*******************

                                $ESTILOS PARA DESKTOP MEDIAQUERYS
****************____________________________________________________________________*****************/
@media all and (min-width: 49rem) {
  .casa, label {
    display: block;
    padding: 1rem 1.25rem;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
  }

           /*_________________________________________________________________

            $ESTILOS PARA NAVBAR
          ____________________________________________________________________*/
  .navbar {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: table;
    table-layout: fixed;
    margin: auto;
  }

  .navbar > li {
    display: table-cell;
  }

  .chk-nav:checked ~ .navbar {
    margin: auto;
  }

          /*_________________________________________________________________

            $ESTILOS PARA ESCONDER EL ICONO DE HAMBURGUESA
          ____________________________________________________________________*/
  label[for="btn-navbar"] {
    display: none;
  }

          /*_________________________________________________________________

          $ESTILOS PARA el SUBMENU
          ____________________________________________________________________*/
  .navbar .sub-nav {
    display: none;
  }

  .navbar > ul > li {
    position: relative;
  }

  .chk-nav:checked ~ .sub-nav {
    display: block;
  }

  .navbar .sub-nav {
    width: 100%;
    background-color: #222;
    position: absolute;
  }

  .sub-nav .casa {
    font-size: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
  }

          /*_________________________________________________________________

                  $ESTILOS PARA LOS ICONOS
            ____________________________________________________________________*/
  .navbar .fa {
    position: static;
    padding-right: .3rem;
  }

  .lbl-nav:after {
    top: 0;
    height: 100%;
    line-height: 3.5rem;
  }

        /*_________________________________________________________________

                  $ESTILOS PARA EL MENU PRINCIPAL
         ____________________________________________________________________*/

         /* BORDES*/

  .navbar > li {
    position: relative;
    border-top: 4px solid #049CF3;
  }

  .navbar > li > .casa:hover, label:hover {
    border-left: 4px solid transparent;
  }
}

styles.css:

    #contenedor1 {
        margin-top: 30px;
        margin-right: 40px;
        margin-bottom: 20px;
        margin-left: 70px;
    }

@media all and (max-width: 450px){
  .portada{
      width:100%;
  }
}

h1.titulo_1 {
  text-align: center;
    font-size: 60px;
    color: black;
    margin-top: 100px;
    margin-right: 40px;
    margin-bottom: 10px;
    margin-left: 40px;
    }

/* CUANDO LA PANTALLA ES MENOR A 1000px PASARA ESTO*/
@media all and (max-width: 1000px){
    .canales{
            width: 155px;
            height: 90px;
    }
}

/* CUANDO LA PANTALLA ES MENOR A 500px PASARA ESTO*/
@media all and (max-width: 300px){
    .canales{
        width: 140px;
        height: 70px;
        display:block;
        margin:auto;
    }
}

/* PARA QUE NO APAREZCAEL TAMAÑO ORIGINAL CUANDO YA ESTA EXTENDIDA LA VENTANA
DEL NAVEGADOR, COLOCAS UN TAMAÑO ESTABLECIDO, EN MI CASO 160px*/
 .canales{
     width: 170px;
     height: 100px;
     margin-bottom: 25px;
     margin-left: 10px;
     border-radius: 20px;
     -webkit-border-radius: 20px;
     -moz-border-radius: 20px;
     -o-border-radius: 20px;
     -ms-border-radius: 20px;
 }

 .canales_mas_ancho{
    width: 170px;
    height: 100px;
    margin-bottom: 25px;
    margin-left: 10px;
    border-radius: 20px;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    -o-border-radius: 20px;
    -ms-border-radius: 20px;
 }

 /* CUANDO LA PANTALLA ES MENOR A 1000px PASARA ESTO*/
 @media all and (max-width: 1000px){
    .canales_mas_ancho{
            width: 155px;
            height: 90px;
    }
 }

 /* CUANDO LA PANTALLA ES MENOR A 500px PASARA ESTO*/
 @media all and (max-width: 300px){
 .canales_mas_ancho{
        width: 140px;
        height: 70px;
        display:block;
        margin:auto;
    }
 }

Body:
See if this helps you:
https://s.codepen.io/panchroma/debug/EbJdjM/jVMpogKwympk

This pen is the same HTML and CSS that you posted except that in the CSS for the .nav block, starting at line 46, I set a height for the .nav element.

.nav {
  width: 100%;
  position: absolute;
  z-index: 10;
  height: 55px !important;
  background-color: pink;
}

What seemed to be happening with your code is that on mobile viewports, .nav covered the entire window, and therefore you couldn't access the links because they are 'under' the fullscreen nav element. To confirm this, comment out line 50 which is limiting the height of .nav

Good luck!


问:
script for copying a column to another column of different table
SQL command not properly ended - error is showing while I run below code. I want to copy all values  from Process column of table T_DOC to Process column of T_CHARACTERISTICS. Now Process column in T_CHARACTERISTICS is NULL.  (Except this column all other columns of T_CHARACTERISTICS is having values)  Thanks in advance

```<code>UPDATE T_CHARACTERISTICS
SET T_CHARACTERISTICS.PROCESS = T_DOC.PROCESS
FROM T_CHARACTERISTICS
JOIN  T_DOC ON T_CHARACTERISTICS.ID = T_DOC.ID
</code>```

答:
Oracle does not support update joins, but we can use a correlated subquery instead:</p>

```<code>UPDATE T_CHARACTERISTICS t1
SET PROCESS = (SELECT t2.PROCESS FROM T_DOC t2 WHERE t2.ID = t1.ID);
</code>```

Body:
SQL command not properly ended - error is showing while I run below code. I want to copy all values  from Process column of table T_DOC to Process column of T_CHARACTERISTICS. Now Process column in T_CHARACTERISTICS is NULL.  (Except this column all other columns of T_CHARACTERISTICS is having values)  Thanks in advance

UPDATE T_CHARACTERISTICS
SET T_CHARACTERISTICS.PROCESS = T_DOC.PROCESS
FROM T_CHARACTERISTICS
JOIN  T_DOC ON T_CHARACTERISTICS.ID = T_DOC.ID

Body:
Oracle does not support update joins, but we can use a correlated subquery instead:

UPDATE T_CHARACTERISTICS t1
SET PROCESS = (SELECT t2.PROCESS FROM T_DOC t2 WHERE t2.ID = t1.ID);


问:
Alter table script in SQL Server database project
My Requirement is to create delta scripts for an existing project, so we will be making lot of changes and create more tables in it.

We have Dev, QA, Stage and Production environments. I want to do the changes only in dev environment and rest of the environments have to be taken care by Dacpac automatically using VSTS. All the scripts have to be re-runnable except the seed data.

I am able to add a table, but unable to add an alter table statement in database project in build mode. I don't want to import full database. Can the Dacpac not accept alter statements?

Since I have to check if exists for post deployment script, I don't want use alter statement there. How can I achieve this?

答:
I think you may have miss understood what the SQL Server database project is/does. The project it self uses SQL scripts to build an in memory model of what your database looks like. This model then compiles down to a DACPAC which contains meta data that describes what the database should look like. When you deploy the DACPAC, this generates a change script that will transform the database into a state that matches the model described in the DACPAC.

The reason your ALTER TABLE doesn't work is due to there being no table to alter. The project isn't a database and it doesn't know how to represent in memory your ALTER statements. If you include it in a pre or post deploy script, the model will ignore this. It will, as you found out, mess with the deployments to the other environments.

The ideal way to deploy your database to your dev environment is using VSTS via CI/CD practices with the DACPAC. I'm not sure why you don't want to use a DACPAC to deploy to your dev environment, but if this is a hard fast rule, then you can use schema compare in Visual Studio's SSDT to copy your changes locally to the target database.

ContentLicense: CC BY-SA 4.0


答:
This is not proper Oracle syntax.  Here is one method:</p>

```<code>UPDATE T_CHARACTERISTICS c
    SET PROCESS = (SELECT d.PROCESS
                   FROM T_DOC d
                   WHERE c.ID = d.ID
                  )
    WHERE EXISTS (SELECT 1
                  FROM T_DOC d
                  WHERE c.ID = d.ID
                 );
</code>```

Title: script for copying a column to another column of different table

Body:
This is not proper Oracle syntax.  Here is one method:

UPDATE T_CHARACTERISTICS c
    SET PROCESS = (SELECT d.PROCESS
                   FROM T_DOC d
                   WHERE c.ID = d.ID
                  )
    WHERE EXISTS (SELECT 1
                  FROM T_DOC d
                  WHERE c.ID = d.ID
                 );


问:
Press a Button in React Native Elements UI Toolkit to go to a web URL
i'm new in this, and i try to make a social media button using

```<code>import { SocialIcon } from 'react-native-elements';
</code>```

and using

```<code><SocialIcon type='facebook'/>
</code>```

but how send the URL in the OnPress( ). ?

答:
Via Linking in React Native:

To start the corresponding activity for a link (web URL, email,
  contact etc.), call:

```<code>Linking.openURL(url).catch(err => console.error('An error occurred', err));
</code>```

You can swap the url for the real URL, wrap it in a very specific handler passed into your SocialIcon component's onPress prop, or (and this is much more React-y), you can create a reusable component, i.e.:

class SocialButton extends Component {
  static propTypes = {
    url: PropTypes.string.isRequired,
    type: PropTypes.string.isRequired,
  };

  handleClick = () => {
    Linking.openURL(this.props.url).catch(err => console.error("An error occurred", err));
  };

  render() {
    return <SocialIcon type={this.props.type} url={this.props.url} onPress={this.handleClick} />;
  }
}
```

<p>and use it the following way:</p>

<pre class="lang-js prettyprint-override"><code><SocialButton type="facebook" url="https://www.facebook.com/wonderloveapp/" />
</code>```

Body:
i'm new in this, and i try to make a social media button using

import { SocialIcon } from 'react-native-elements';

and using

<SocialIcon type='facebook'/>

but how send the URL in the OnPress( ). ?

Body:
Via Linking in React Native:

To start the corresponding activity for a link (web URL, email,
  contact etc.), call:

Linking.openURL(url).catch(err => console.error('An error occurred', err));

You can swap the url for the real URL, wrap it in a very specific handler passed into your SocialIcon component's onPress prop, or (and this is much more React-y), you can create a reusable component, i.e.:

class SocialButton extends Component {
  static propTypes = {
    url: PropTypes.string.isRequired,
    type: PropTypes.string.isRequired,
  };

  handleClick = () => {
    Linking.openURL(this.props.url).catch(err => console.error("An error occurred", err));
  };

  render() {
    return <SocialIcon type={this.props.type} url={this.props.url} onPress={this.handleClick} />;
  }
}

and use it the following way:

<SocialButton type="facebook" url="https://www.facebook.com/wonderloveapp/" />


问:
Is there a postgres command to list/drop all materialized views?
I am creating multiple views in my code and each time the code is run, I would like to drop all the materialized views generated thus far. Is there any command that will list all the materialized views for Postgres or drop all of them?</p>

答:
This would be easier if you want to get a full list with the DROP statement in front of each view:</p>

```<code>SELECT 'DROP MATERIALIZED VIEW ' || relname || ';'
FROM   pg_class
WHERE  relkind = 'm';
</code>```

Body:
This would be easier if you want to get a full list with the DROP statement in front of each view:

SELECT 'DROP MATERIALIZED VIEW ' || relname || ';'
FROM   pg_class
WHERE  relkind = 'm';


问:
count number of days in a month in SAS
I am looking to get number of days in a month in SAS. The date format I have is yyyymm (e.g.201701) and I would like to record the number of days in a month. The data is recurring on a monthly basis (201701,201702...etc). I have tried to use the Day function along with EOMONTH , however the SAS picks up the SAS date for 201701. I am new to SAS coding and any help would be appreciated.</p>

答:
SAS date values are numeric type with a value that is the number of days since 1-January-1960.

You need to first understand what type of value your date representing variable is.
Is it:

character type with digit letters at the meaning place Y Y Y Y M M

numeric type with date encoded as value 100 * year + month

If EOMONTH is character, you will need to convert it to a SAS date value that includes a day.  For 'month' values that day is usually set to 1.  For example:

```<code>data _null_;
  myDateString = '201701';
  * note the ||'01' that makes myDate be the first of the month;
  myDate = input (trim(myDateString)||'01', yymmdd8.);
  format myDate yymmd.;
  put myDate=;
  put myDate= 12.; * Show in LOG the date as number of days from reference;
run;
----- LOG -----
myDate=2017-01
myDate=20820
</code>```

Sometimes you will get date representing data which is numeric and encoded to appear like YYYYMM when viewed.  These values also would need to be converted to a SAS date value. For example:

```<code>data have;
  myDateNumber = 201701;
  * note the , 1 that makes myDate be the first of the month;
  myDate = mdy ( mod(myDateNumber,100), 1, myDateNumber / 100);
  format myDate yymmd.;
  put myDate=;
  put myDate= 12.; * What date value is 'unformatted' is the number of days from reference;
run;
----- LOG -----
myDate=2017-01
myDate=20820
</code>```

There are other ways to convert a character or numeric representation of a date to a SAS date value.  Just be careful to understand that when you are viewing a variable in SAS, you need to know the variable type and the format being applied by the viewer.

Once you have a SAS date value, you can compute the number of days in the month of the date using SAS interval functions INTCK and INTNX.

```<code>days_in_month = intck ('days', /* how many days between next two args */
  intnx('month', mydate, 0),  /* advance mydate to first of month */
  intnx('month', mydate, 1)   /* advance mydate to first of next month */
);
</code>```

This formula will work regardless of the day of the month of the date value.

Title: count number of days in a month in SAS

Body:
SAS date values are numeric type with a value that is the number of days since 1-January-1960.

You need to first understand what type of value your date representing variable is.
Is it:

character type with digit letters at the meaning place Y Y Y Y M M

numeric type with date encoded as value 100 * year + month

If EOMONTH is character, you will need to convert it to a SAS date value that includes a day.  For 'month' values that day is usually set to 1.  For example:

data _null_;
  myDateString = '201701';
  * note the ||'01' that makes myDate be the first of the month;
  myDate = input (trim(myDateString)||'01', yymmdd8.);
  format myDate yymmd.;
  put myDate=;
  put myDate= 12.; * Show in LOG the date as number of days from reference;
run;
----- LOG -----
myDate=2017-01
myDate=20820

Sometimes you will get date representing data which is numeric and encoded to appear like YYYYMM when viewed.  These values also would need to be converted to a SAS date value. For example:

data have;
  myDateNumber = 201701;
  * note the , 1 that makes myDate be the first of the month;
  myDate = mdy ( mod(myDateNumber,100), 1, myDateNumber / 100);
  format myDate yymmd.;
  put myDate=;
  put myDate= 12.; * What date value is 'unformatted' is the number of days from reference;
run;
----- LOG -----
myDate=2017-01
myDate=20820

There are other ways to convert a character or numeric representation of a date to a SAS date value.  Just be careful to understand that when you are viewing a variable in SAS, you need to know the variable type and the format being applied by the viewer.

Once you have a SAS date value, you can compute the number of days in the month of the date using SAS interval functions INTCK and INTNX.

days_in_month = intck ('days', /* how many days between next two args */
  intnx('month', mydate, 0),  /* advance mydate to first of month */
  intnx('month', mydate, 1)   /* advance mydate to first of next month */
);

This formula will work regardless of the day of the month of the date value.


问:
Giving an array of indexes, how to push items from one array to another depending on the indexes that are specified?
I am trying to push items from one Array to another depending on the order that is supplied. Essentially i have a 2d array with a name and a price :

```<code>var myArray = [['Apples',22],['Orange',55],['Berry',23]];
</code>```

Another array with the order it should be in :

```<code>var myOrder = [0,2,1];
</code>```

My resulting array would look like this :

```<code>var finalArray = [['Apples',22],['Berry',23],['Orange',55]]
</code>```

My initial thought process was to loop through myArray and loop through myOrder , store the object temporary at a specified index in myOrder then push to final array. I think i am over thinking it a bit, i made several attempts but with no luck whatsoever. Any help would be greatly appreciated!

答:
```<code>function reorder(arr, order) {
  return order.map(function(i) {
    return arr[i];
  });
}

var myArray = [['Apples',22],['Orange',55],['Berry',23]];
var myOrder = [0,2,1];
reorder(myArray, myOrder); // => [["Apples",22],["Berry",23],["Orange",55]]
</code>```

Body:
I am trying to push items from one Array to another depending on the order that is supplied. Essentially i have a 2d array with a name and a price :

var myArray = [['Apples',22],['Orange',55],['Berry',23]];

Another array with the order it should be in :

var myOrder = [0,2,1];

My resulting array would look like this :

var finalArray = [['Apples',22],['Berry',23],['Orange',55]]

My initial thought process was to loop through myArray and loop through myOrder , store the object temporary at a specified index in myOrder then push to final array. I think i am over thinking it a bit, i made several attempts but with no luck whatsoever. Any help would be greatly appreciated!


问:
JavaScript code with If Statements
I have been working on a text based game for personal use to get better at JavaScript. With this game, the user answers the questions that is written (like a story/choice game). This is my code...

```<code><!DOCTYPE HTML>
<html>

<head>
<!--<script type="text/javascript" src="gamescript.js"></script>-->

<style>
body {
  font-family: Calibri, sans-serif;
}

#mspace {
  padding: 10px 20px;
  background: #ff0;
}

.hideThis {
  display: none;
}

button {
  margin: 10px;
}

</style>

<script>

function myFunction(){
    var door = document.getElementById("myInput").value;
    if (door == "Door 1" || door == "door 1"){
        document.getElementById("door").innerHTML = "You have entered" + door;
    }else if (door == "Door 2" || door == "door 2"){
        document.getElementById("door").innerHTML = "You have entered" + door;
    }else{
        document.getElementById("door").innerHTML = "You must enter a door!"
    }
}

function myFunction2(){
    var choice1 = document.getElementById("myInput2").value;
    if (choice1 == "enter passageway" || choice1 == "passageway"){
        document.getElementById("choice1").innerHTML = "You entered the" + choice1;
     }else if (choice1 == "continue searching"){
        document.getElementById("choice1").innerHTML = "You " + choice1;
    }else{
        document.getElementById("choice1").innerHTML = "You must choose an option!"
    }
}

// JS for BOSS level
// starting variable for the boss
var stamina = 10;

// starting message
var msg = "A huge, threatening monster wants to fight you! What do you do?";
// run a function that is below
document.getElementById("mspace")

// click a button to execute a function
// NOTE: no parentheses after the function name in these cases
window.onload = function(){
    document.getElementById("fight").onclick = fightResponse;
    document.getElementById("run").onclick = runResponse;
}

function runResponse() {
  if (stamina > 8) {
    msg = "The monster swings his long arm and -- GAME OVER!";
    hideButtons();
  } else if (stamina > 3) {
    msg = "Well, that's one way to end a fight ...";
    hideButtons();
  } else {
    msg = "Keep fighting! The monster is almost dead!";
  }
  writeMessage();
}

function fightResponse() {
  if (stamina > 8) {
    msg = "The monster is strong! It resists your attack!";
  } else if (stamina > 5) {
    msg = "With a loud screech, the monster stands firm.";
  } else if (stamina > 3) {
    msg = "Your attack seems to be having an effect! The monster stumbles!";
  } else if (stamina > 0) {
    msg = "This monster is about to fall! It staggers and reels!";
  } else {
    msg = "With a final swing! The monster has been defeated! You have triumphed!";
    hideButtons();
  }
  // create new random number from 0 to 5
  var damage = Math.floor(Math.random() * 6);
  // subtract it from stamina
  stamina -= damage;
  writeMessage();
}

function hideButtons() {
  // changes the class on the div - see the CSS pane
  document.getElementById("game").className = "hideThis";
}

window.onload = function writeMessage() {
  // write message into the yellow paragraph
  document.getElementById("mspace").innerHTML = msg;
}

</script>
</head>

<body>

<p id ="door"> Which door do you wish to enter? Door 1 or Door 2? </p>

<input id="myInput" type="text">

<button onclick="myFunction()">Enter</button>

<!---- Question 1 ---->
<p id ="choice1">Behind Door 1 is an empty room. Whilst searching the room for clues, you see a hidden passageway. Do you wish to enter the passageway or continue searching?</p>

<input id="myInput2" type="text">

<button onclick="myFunction2()">Enter</button>

<!---- Boss ---->
<h1>Fight the Monster!</h1>

<p id="mspace"></p>

<div id="game">

  <button id="fight">Fight</button>
  <button id="run">Run</button>

</div>

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

When the questions appear, although it does what I want it to, I wanted it so that when the user enters either "Door 1" or "Door 2" for the first question, the 2nd question to appear after it. In my code, it's like a list of questions with text box underneath. It doesn't look nice and I don't know how to change it.

For the "Final Boss" code, It doesn't seem to be working and i don't know why. I have checked the F12 developer tool and no errors are showing.

All the help is appreciated and thank you!

答:
Because browsers generally process code (HTML, CSS, or Javascript) from the top down, window.onloadis used to ensure that a function is executed after the entire page has been loaded which helps avoid reference errors. However, in your code, window.onload is assigned multiple times, which means that only the last assignment will get executed. You can remedy this by consolidating all of your onload functionality into one 'parent' function, or by something like this which allows you to append functions to the onload event (more information can be found here):

```<code>function addLoadEvent(func)
{
      var oldonload = window.onload;
      if (typeof window.onload != 'function') {
        window.onload = func;
      } else {
        window.onload = function() {
          if (oldonload) {
            oldonload();
          }
          func();
        }
      }
}
addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
addLoadEvent(function() {
      /* more code to run on page load */
    });
</code>```

When it comes to displaying the questions sequentially, as suggested by @KKK you may want to look into the visibility attribute and set it accordingly. But if you want more dynamic functionality, then you will want to use document.getElementById() and its related functions to edit, append, and remove elements on the page. This should be a good starting point.

As an aside, be careful when putting multiple conditions in if statements. Your code should function fine due to Operator Precedence, but proper use of parentheses can ensure that it functions as intended while improving code readability.

Title: JavaScript code with If Statements

Body:
I have been working on a text based game for personal use to get better at JavaScript. With this game, the user answers the questions that is written (like a story/choice game). This is my code...

<!DOCTYPE HTML>

 Which door do you wish to enter? Door 1 or Door 2?

<input id="myInput" type="text">

<button onclick="myFunction()">Enter</button>

Behind Door 1 is an empty room. Whilst searching the room for clues, you see a hidden passageway. Do you wish to enter the passageway or continue searching?

<input id="myInput2" type="text">

<button onclick="myFunction2()">Enter</button>

Fight the Monster!

  <button id="fight">Fight</button>
  <button id="run">Run</button>

When the questions appear, although it does what I want it to, I wanted it so that when the user enters either "Door 1" or "Door 2" for the first question, the 2nd question to appear after it. In my code, it's like a list of questions with text box underneath. It doesn't look nice and I don't know how to change it.

For the "Final Boss" code, It doesn't seem to be working and i don't know why. I have checked the F12 developer tool and no errors are showing.

All the help is appreciated and thank you!

Body:
Because browsers generally process code (HTML, CSS, or Javascript) from the top down, window.onloadis used to ensure that a function is executed after the entire page has been loaded which helps avoid reference errors. However, in your code, window.onload is assigned multiple times, which means that only the last assignment will get executed. You can remedy this by consolidating all of your onload functionality into one 'parent' function, or by something like this which allows you to append functions to the onload event (more information can be found here):

function addLoadEvent(func)
{
      var oldonload = window.onload;
      if (typeof window.onload != 'function') {
        window.onload = func;
      } else {
        window.onload = function() {
          if (oldonload) {
            oldonload();
          }
          func();
        }
      }
}
addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
addLoadEvent(function() {
      /* more code to run on page load */
    });

When it comes to displaying the questions sequentially, as suggested by @KKK you may want to look into the visibility attribute and set it accordingly. But if you want more dynamic functionality, then you will want to use document.getElementById() and its related functions to edit, append, and remove elements on the page. This should be a good starting point.

As an aside, be careful when putting multiple conditions in if statements. Your code should function fine due to Operator Precedence, but proper use of parentheses can ensure that it functions as intended while improving code readability.


问:
How to recalculate normals?
I'm trying to write a simple shader that moves all verts with a sin wave.

```<code>v.vertex.y += sin(_Time.y * _Speed + v.vertex.x * _Amount * v.vertex.z) * _Distance;
</code>```

The problem is that after moving them, the normals are wrong, thus there are no real time shadows. I've searched a lot and found that I need to recalculate the normals using fake neighbours. None of the implementations were for Unity Shaderlab, so I can't just copy and paste them, and my knowledge of shader code is pretty basic so I can't translate what I found to what I need.

Can anyone help me with what and how to recalculate normals after moving a vertex?

答:
Having not done this myself, I did a little googly and found this shader, used to invert the normals. It does this by tweaking the vertex information:

```<code>    void vert(inout appdata_full v) {
        v.normal.xyz = v.normal * -1;
    }
</code>```

You should be able to tweak your shader to recompute the normal direction based off the other alterations and update it in a similar manner.

Title: How to recalculate normals?

Body:
I'm trying to write a simple shader that moves all verts with a sin wave.

v.vertex.y += sin(_Time.y * _Speed + v.vertex.x * _Amount * v.vertex.z) * _Distance;

The problem is that after moving them, the normals are wrong, thus there are no real time shadows. I've searched a lot and found that I need to recalculate the normals using fake neighbours. None of the implementations were for Unity Shaderlab, so I can't just copy and paste them, and my knowledge of shader code is pretty basic so I can't translate what I found to what I need.

Can anyone help me with what and how to recalculate normals after moving a vertex?

Body:
Having not done this myself, I did a little googly and found this shader, used to invert the normals. It does this by tweaking the vertex information:

    void vert(inout appdata_full v) {
        v.normal.xyz = v.normal * -1;
    }

You should be able to tweak your shader to recompute the normal direction based off the other alterations and update it in a similar manner.


问:
Is there a way I can log when python "requests-cache" hits the cache?
I'm using https://requests-cache.readthedocs.io/en/latest/index.html and I want to know when the cache is hit vs. the web. </p>

答:
According to the source code, there should be a .from_cache flag set on the response object:

```<code>In [1]: import requests

In [2]: import requests_cache

In [3]: requests_cache.install_cache('demo_cache')

In [4]: requests.get("https://stackoverflow.com").from_cache
Out[4]: False

In [5]: requests.get("https://stackoverflow.com").from_cache
Out[5]: True
</code>```

Body:
According to the source code, there should be a .from_cache flag set on the response object:

In [1]: import requests

In [2]: import requests_cache

In [3]: requests_cache.install_cache('demo_cache')

In [4]: requests.get("https://stackoverflow.com").from_cache
Out[4]: False

In [5]: requests.get("https://stackoverflow.com").from_cache
Out[5]: True


问:
Which parameters are local in a binary tree recursion?
```<code>import java.util.*;

    public static void main(String[] args) {

        TreeNode root = new TreeNode(8);
        root.left = new TreeNode(7);
        root.right = new TreeNode(6);
        root.left.left = new TreeNode(5);
        root.right.right = new TreeNode(4);
        List<Integer> list = postorderTraversal(root);
        System.out.println(list);
    }

    public static List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> list = new ArrayList<Integer>();
        list = helper(root, list);
        return list;
    }

    private static List<Integer> helper(TreeNode node, List<Integer> list){
        if (node != null) {
            helper(node.left, list);
            helper(node.right, list);
            list.add(node.val);
        }
        return list;
    }
}
</code>```

In this question, I don't understand why I don't have to do list = helper(node.left, list); Why is list global here and when I'm changing my root it's local and I have to do root.left = recurse(root.left) ?

答:
This is because of how pointers work in java.
When you pass list in as a parameter to a function, you aren't passing in the object itself, you're passing in its memory address on your computer. This memory address is called a pointer and is useful because it lets you avoid expensively duplicating objects.

You don't normally notice this because java typically hides the fact that it's using pointers at all. For instance, when you do list.add(...), it works like you're using an ordinary object and calling add() on it because java automatically substitutes the object for the pointer.

So list is kind of like a global variable, because even though the pointer is copied every time you pass it into something, it still references the same section of memory. Changing that section of memory will affect what every other pointer to that spot sees, so you get changes that other functions can see.

Body:
import java.util.*;

    public static void main(String[] args) {

        TreeNode root = new TreeNode(8);
        root.left = new TreeNode(7);
        root.right = new TreeNode(6);
        root.left.left = new TreeNode(5);
        root.right.right = new TreeNode(4);
        List<Integer> list = postorderTraversal(root);
        System.out.println(list);
    }

    public static List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> list = new ArrayList<Integer>();
        list = helper(root, list);
        return list;
    }

    private static List<Integer> helper(TreeNode node, List<Integer> list){
        if (node != null) {
            helper(node.left, list);
            helper(node.right, list);
            list.add(node.val);
        }
        return list;
    }
}

In this question, I don't understand why I don't have to do list = helper(node.left, list); Why is list global here and when I'm changing my root it's local and I have to do root.left = recurse(root.left) ?


问:
Is there a way to install the scipy special module without the rest of scipy?
I'm writing some Python numerical code and would like to use some functions from the special module. So far, my code only depends on numpy, which I've found very easy to install in a variety of Python environments. Installing scipy, on the other hand, has generally been an exercise in frustration.  Is there a way to get just the special module?

Note, I see now that there is a downloadable scipy package for the Mac, but that hasn't always been the case

答: If you already have the right version of Numpy installed then you could try to just take the source for the special module, stick it in a directory somewhere, add it to your PYTHONPATH, and see if it works.  It all depends on its dependencies.  If it has dependencies beyond Numpy, then you'll have to install those, and if those have dependencies...</p>

OwnerDisplayName: Nick

LastEditorDisplayName: Jeff Bauer

OwnerDisplayName: Erik Engbrecht


问:
Python- Remove all words that contain other words in a list
I have a list populated with words from a dictionary.  I want to find a way to remove all words, only considering root words that form at the beginning of the target word.

For example, the word "rodeo" would be removed from the list because it contains the English-valid word "rode."  "Typewriter" would be removed because it contains the English-valid word "type."  However, the word "snicker" is still valid even if it contains the word "nick" because "nick" is in the middle and not at the beginning of the word.

I was thinking something like this:

```<code> for line in wordlist:
        if line.find(...) --
</code>```

but I want that "if" statement to then run through every single word in the list checking to see if its found and, if so, remove itself from the list so that only root words remain.  Do I have to create a copy of wordlist to traverse?

答:
You should use the built-in  lambda function for this. I think it'll make your life a lot easier

```<code>words = ['rode', 'nick'] # this is the list of all the words that you have.
                         # I'm using 'rode' and 'nick' as they're in your example
listOfWordsToTry = ['rodeo', 'snicker']
def validate(w):
    for word in words:
        if w.startswith(word):
            return False
    return True

wordsThatDontStartWithValidEnglishWords = \
    filter(lambda x : validate(x), listOfWordsToTry)
</code>```

This should work for your purposes, unless I misunderstand your question.

Hope this helps

Body:
I have a list populated with words from a dictionary.  I want to find a way to remove all words, only considering root words that form at the beginning of the target word.

For example, the word "rodeo" would be removed from the list because it contains the English-valid word "rode."  "Typewriter" would be removed because it contains the English-valid word "type."  However, the word "snicker" is still valid even if it contains the word "nick" because "nick" is in the middle and not at the beginning of the word.

I was thinking something like this:

 for line in wordlist:
        if line.find(...) --

but I want that "if" statement to then run through every single word in the list checking to see if its found and, if so, remove itself from the list so that only root words remain.  Do I have to create a copy of wordlist to traverse?

Body:
You should use the built-in  lambda function for this. I think it'll make your life a lot easier

words = ['rode', 'nick'] # this is the list of all the words that you have.
                         # I'm using 'rode' and 'nick' as they're in your example
listOfWordsToTry = ['rodeo', 'snicker']
def validate(w):
    for word in words:
        if w.startswith(word):
            return False
    return True

wordsThatDontStartWithValidEnglishWords = \
    filter(lambda x : validate(x), listOfWordsToTry)

This should work for your purposes, unless I misunderstand your question.

Hope this helps


问:
How to Pass parameters to PowerShell script while building from VSTS
I am running the below PowerShell Script to deploy csv file data into Azure table storage. But The below parameters are different for different environment in the azure.Suppose the below script can be deployed to any environment but the below parameters will be varied as per the environment.So I want to pass the below parameters to the script while running from the PowerShell task in VSTS.How to accomplish task.Please help me out on this.So

```<code>**$subscriptionName = "Tech Enabled Solutions"
$resourceGroupName = "abc"
$storageAccountName = "defghi"
$location = "North Central US, South Central US"
$StorageAccountKey = "12345678"**
</code>```

PowerShell Script:

```<code>   function Add-Entity()
{
 [CmdletBinding()]

 param
 (
 $table,
 [string] $partitionKey,
 [string] $RowKey,
 [string] $Label_Usage,
 [string] $Label_Value,
 [string] $Usage_Location,
 [string] $subscriptionName,
 [string] $resourceGroupName,
 [string] $storageAccountName,
 [string] $location,
 [string] $StorageAccountKey
)

 $entity = New-Object -TypeName Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity -ArgumentList $partitionKey, $rowKey
 $entity.Properties.Add("Label_Value",$Label_Value)
 $entity.Properties.Add("Label_Usage",$Label_Usage)
 $entity.Properties.Add("Usage_Location",$Usage_Location)
 $result = $table.CloudTable.Execute([Microsoft.WindowsAzure.Storage.Table.TableOperation]::InsertOrReplace($entity))
}
$tableName = "sampletable"

# Get a storage context
$ctx = New-AzureStorageContext $StorageAccountName $StorageAccountKey

# Get a reference to the table
$table = Get-AzureStorageTable -Name $tableName -Context $ctx -ErrorAction Ignore
$csv = Import-CSV "d:\a\1\s\DeploymentScripts\sampletable.csv"

ForEach ($line in $csv)
{
 Add-Entity -Table $table -partitionKey $line.partitionkey -rowKey $line.RowKey -Label_Usage $line.Label_Usage -Label_Value $line.Label_Value -Usage_Location $line.Usage_Location

}
</code>```

答:
Some parameters are not used in your script, such as $subscriptionName, $resourceGroupName, you can check whether they are needed.

Refer to this code to add parameters:

```<code>param(
[string] $subscriptionName,
 [string] $resourceGroupName,
 [string] $storageAccountName,
 [string] $location,
 [string] $StorageAccountKey
)
function Add-Entity()
{
 [CmdletBinding()]

 param
 (
 $table,
 [string] $partitionKey,
 [string] $RowKey,
 [string] $Label_Usage,
 [string] $Label_Value,
 [string] $Usage_Location
)

 $entity = New-Object -TypeName Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity -ArgumentList $partitionKey, $rowKey
 $entity.Properties.Add("Label_Value",$Label_Value)
 $entity.Properties.Add("Label_Usage",$Label_Usage)
 $entity.Properties.Add("Usage_Location",$Usage_Location)
 $result = $table.CloudTable.Execute([Microsoft.WindowsAzure.Storage.Table.TableOperation]::InsertOrReplace($entity))
}
$tableName = "sampletable"

# Get a storage context
$ctx = New-AzureStorageContext $storageAccountName $StorageAccountKey

# Get a reference to the table
$table = Get-AzureStorageTable -Name $tableName -Context $ctx -ErrorAction Ignore
$csv = Import-CSV "d:\a\1\s\DeploymentScripts\sampletable.csv"

ForEach ($line in $csv)
{
 Add-Entity -Table $table -partitionKey $line.partitionkey -rowKey $line.RowKey -Label_Usage $line.Label_Usage -Label_Value $line.Label_Value -Usage_Location $line.Usage_Location

}
</code>```

Specify the parameters' value in PowerShell task (Arguments input box)

```<code>-subscriptionName "Tech Enabled Solutions" -resourceGroupName "abc" -storageAccountName "defghi" -location "North Central US, South Central US" -StorageAccountKey "12345678"
</code>```

Body:
I am running the below PowerShell Script to deploy csv file data into Azure table storage. But The below parameters are different for different environment in the azure.Suppose the below script can be deployed to any environment but the below parameters will be varied as per the environment.So I want to pass the below parameters to the script while running from the PowerShell task in VSTS.How to accomplish task.Please help me out on this.So

**$subscriptionName = "Tech Enabled Solutions"
$resourceGroupName = "abc"
$storageAccountName = "defghi"
$location = "North Central US, South Central US"
$StorageAccountKey = "12345678"**

PowerShell Script:

   function Add-Entity()
{
 [CmdletBinding()]

 param
 (
 $table,
 [string] $partitionKey,
 [string] $RowKey,
 [string] $Label_Usage,
 [string] $Label_Value,
 [string] $Usage_Location,
 [string] $subscriptionName,
 [string] $resourceGroupName,
 [string] $storageAccountName,
 [string] $location,
 [string] $StorageAccountKey
)

 $entity = New-Object -TypeName Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity -ArgumentList $partitionKey, $rowKey
 $entity.Properties.Add("Label_Value",$Label_Value)
 $entity.Properties.Add("Label_Usage",$Label_Usage)
 $entity.Properties.Add("Usage_Location",$Usage_Location)
 $result = $table.CloudTable.Execute([Microsoft.WindowsAzure.Storage.Table.TableOperation]::InsertOrReplace($entity))
}
$tableName = "sampletable"

# Get a storage context
$ctx = New-AzureStorageContext $StorageAccountName $StorageAccountKey

# Get a reference to the table
$table = Get-AzureStorageTable -Name $tableName -Context $ctx -ErrorAction Ignore
$csv = Import-CSV "d:\a\1\s\DeploymentScripts\sampletable.csv"

ForEach ($line in $csv)
{
 Add-Entity -Table $table -partitionKey $line.partitionkey -rowKey $line.RowKey -Label_Usage $line.Label_Usage -Label_Value $line.Label_Value -Usage_Location $line.Usage_Location

}

Body:
Some parameters are not used in your script, such as $subscriptionName, $resourceGroupName, you can check whether they are needed.

Refer to this code to add parameters:

param(
[string] $subscriptionName,
 [string] $resourceGroupName,
 [string] $storageAccountName,
 [string] $location,
 [string] $StorageAccountKey
)
function Add-Entity()
{
 [CmdletBinding()]

 param
 (
 $table,
 [string] $partitionKey,
 [string] $RowKey,
 [string] $Label_Usage,
 [string] $Label_Value,
 [string] $Usage_Location
)

 $entity = New-Object -TypeName Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity -ArgumentList $partitionKey, $rowKey
 $entity.Properties.Add("Label_Value",$Label_Value)
 $entity.Properties.Add("Label_Usage",$Label_Usage)
 $entity.Properties.Add("Usage_Location",$Usage_Location)
 $result = $table.CloudTable.Execute([Microsoft.WindowsAzure.Storage.Table.TableOperation]::InsertOrReplace($entity))
}
$tableName = "sampletable"

# Get a storage context
$ctx = New-AzureStorageContext $storageAccountName $StorageAccountKey

# Get a reference to the table
$table = Get-AzureStorageTable -Name $tableName -Context $ctx -ErrorAction Ignore
$csv = Import-CSV "d:\a\1\s\DeploymentScripts\sampletable.csv"

ForEach ($line in $csv)
{
 Add-Entity -Table $table -partitionKey $line.partitionkey -rowKey $line.RowKey -Label_Usage $line.Label_Usage -Label_Value $line.Label_Value -Usage_Location $line.Usage_Location

}

Specify the parameters' value in PowerShell task (Arguments input box)

-subscriptionName "Tech Enabled Solutions" -resourceGroupName "abc" -storageAccountName "defghi" -location "North Central US, South Central US" -StorageAccountKey "12345678"


答:
This is a simple map() that doesn't require anything else

var myArray = [['Apples',22],['Orange',55],['Berry',23]];
var myOrder = [0,2,1];

let final = myOrder.map(i =>  myArray[i])

console.log(final)```

Title: Giving an array of indexes, how to push items from one array to another depending on the indexes that are specified?


问:
Set up identifying a user for Appcues in a ReactJS project
I am trying to set up Appcues in a ReactJS project and the documentation states to add the following to identify the current user:

```<code>  Appcues.identify({UNIQUE_USER_ID}, { // Unique identifier for current user
    name: "John Doe",   // Current user's name
    email: "john.doe@example.com", // Current user's email
    created_at: 1234567890,    // Unix timestamp of user signup date
  });
</code>```

However, this throws the error that:

'Appcues' is not defined

This error makes sense to me since the object, Appcues, is referenced but not imported or created.

Attempt to fix:

Since Appcues is imported from a script, I tried accessing Appcues through the window, but it results in my demo not being loaded when I go to my project in the browser:

```<code>  window.Appcues.identify({UNIQUE_USER_ID}, { // Unique identifier for current user
    name: "John Doe",   // Current user's name
    email: "john.doe@example.com", // Current user's email
    created_at: 1234567890,    // Unix timestamp of user signup date
  });
</code>```

Does anyone understand how to set up identifying a user for Appcues in a ReactJS project?

答:
Create a recursive function that checks to see if window.Appcues is null; then, either set up the identity of the user (if not null) or load the Appcues script and then recursively call itself (the function).

Identify User

```<code>function identifyUser(userID, name, email, createdAt) {
  // if window.Appcues is not undefined or null..
  if (window.Appcues != undefined && window.Appcues != null) {
    // set up the identity of the user
    window.Appcues.identify(userID, { // Unique identifier for current user
      name: name,   // Current user's name
      email: email, // Current user's email
      created_at: createdAt,    // Unix timestamp of user signup date
    });
  // else...
  } else {
    // load the script for Appcues
    newScript("//fast.appcues.com/30716.js").then(function() {
      // then recursively call identifyUser to initialize the identity of the user
      identifyUser(userID, name, email, createdAt);
    // catch any error and print to the console
    }.bind(this)).catch(function(error) {
      console.log('identifyUser: error on loading script');
    });
  }
}
</code>```

Dynamically load script when needed

```<code>function newScript(src) {
  // create a promise for the newScript
  return new Promise(function(resolve, reject){
    // create an html script element
    var script = document.createElement('script');
    // set the source of the script element
    script.src = src;
    // set a listener when the script element finishes loading the script
    script.addEventListener('load', function () {
      // resolve if the script element loads
      resolve();
    }.bind(this));
    // set a listener when the script element faces any errors while loading
    script.addEventListener('error', function (e) {
      // reject if the script element has an error while loading the script
      reject(e);
    }.bind(this));
    // append the script element to the body
    document.body.appendChild(script);
  }.bind(this))
};
</code>```

Cheers!

Body:
I am trying to set up Appcues in a ReactJS project and the documentation states to add the following to identify the current user:

  Appcues.identify({UNIQUE_USER_ID}, { // Unique identifier for current user
    name: "John Doe",   // Current user's name
    email: "john.doe@example.com", // Current user's email
    created_at: 1234567890,    // Unix timestamp of user signup date
  });

However, this throws the error that:

'Appcues' is not defined

This error makes sense to me since the object, Appcues, is referenced but not imported or created.

Attempt to fix:

Since Appcues is imported from a script, I tried accessing Appcues through the window, but it results in my demo not being loaded when I go to my project in the browser:

  window.Appcues.identify({UNIQUE_USER_ID}, { // Unique identifier for current user
    name: "John Doe",   // Current user's name
    email: "john.doe@example.com", // Current user's email
    created_at: 1234567890,    // Unix timestamp of user signup date
  });

Does anyone understand how to set up identifying a user for Appcues in a ReactJS project?

Body:
Create a recursive function that checks to see if window.Appcues is null; then, either set up the identity of the user (if not null) or load the Appcues script and then recursively call itself (the function).

Identify User

function identifyUser(userID, name, email, createdAt) {
  // if window.Appcues is not undefined or null..
  if (window.Appcues != undefined && window.Appcues != null) {
    // set up the identity of the user
    window.Appcues.identify(userID, { // Unique identifier for current user
      name: name,   // Current user's name
      email: email, // Current user's email
      created_at: createdAt,    // Unix timestamp of user signup date
    });
  // else...
  } else {
    // load the script for Appcues
    newScript("//fast.appcues.com/30716.js").then(function() {
      // then recursively call identifyUser to initialize the identity of the user
      identifyUser(userID, name, email, createdAt);
    // catch any error and print to the console
    }.bind(this)).catch(function(error) {
      console.log('identifyUser: error on loading script');
    });
  }
}

Dynamically load script when needed

function newScript(src) {
  // create a promise for the newScript
  return new Promise(function(resolve, reject){
    // create an html script element
    var script = document.createElement('script');
    // set the source of the script element
    script.src = src;
    // set a listener when the script element finishes loading the script
    script.addEventListener('load', function () {
      // resolve if the script element loads
      resolve();
    }.bind(this));
    // set a listener when the script element faces any errors while loading
    script.addEventListener('error', function (e) {
      // reject if the script element has an error while loading the script
      reject(e);
    }.bind(this));
    // append the script element to the body
    document.body.appendChild(script);
  }.bind(this))
};

Cheers!


问:
Is there a way to deliver push notifications in iOS 11 during Guided Access?
Our iPad app relies on silent push notifications to trigger certain events, and is used by many of our users in Guided Access mode. This has worked well until iOS 11 which now seems to block delivery of push notifications while Guided Access is enabled.

I've tried a variety of different payloads according to the Apple documentation here (such as content-available, alert, sound, badge etc.), but I can't get anything to be delivered while Guided Access is enabled. This isn't necessarily a bug, but may in fact be the new intended behaviour.

Is there a way I can configure a notification so that it is delivered during guided access?

For what it's worth I raised a Technical Support Incident for this issue with Apple, who promptly refunded my ticket and asked me to report a bug instead. There has been no feedback from the bug report yet.

答:
If your app is in the foreground, you can create your own push system using c/s mode BSD socket to reach your goal.
There are good sample like xmppframework on the iOS side and openfire on the server side.</p>