问:
I outsourced some work and my project is now back from the Android Developer and he has changed the package name and now my Gradle won't work?
I have changed everything by refactoring my package name to the original name by refactoring my package name and also, again with Firebase Auth in terms of Facebook Login, Google Login, and Phone Login.

But I cannot seem to sync my Gradle as it shows these messages

Gradle project sync failed.  Basic functionality will not work
  properly.

Error: Could not find com.android.tools.build: gradle: 3.0 .0 - alpha5.
Searched in the following locations:
  file: /C:/Program
Files / Android / Android Studio / gradle / m2repository / com / android / tools / build / gradle / 3.0 .0 - alpha5 / gradle - 3.0 .0 - alpha5.pom
file: /C:/Program
Files / Android / Android Studio / gradle / m2repository / com / android / tools / build / gradle / 3.0 .0 - alpha5 / gradle - 3.0 .0 - alpha5.jar
https: //jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha5/gradle-3.0.0-alpha5.pom
  https: //jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha5/gradle-3.0.0-alpha5.jar
  Required by:
  project:```

Android 2.3.3

答:
in your top build.gradle you should add this

```<code>classpath 'com.android.tools.build:gradle:2.3.3'
</code>```

and remove line which contains alpha. That developer must be using canary builds of Android studio.

Body:
I have changed everything by refactoring my package name to the original name by refactoring my package name and also, again with Firebase Auth in terms of Facebook Login, Google Login, and Phone Login.

But I cannot seem to sync my Gradle as it shows these messages

Gradle project sync failed.  Basic functionality will not work
  properly.

Error: Could not find com.android.tools.build: gradle: 3.0 .0 - alpha5.
Searched in the following locations:
  file: /C:/Program
Files / Android / Android Studio / gradle / m2repository / com / android / tools / build / gradle / 3.0 .0 - alpha5 / gradle - 3.0 .0 - alpha5.pom
file: /C:/Program
Files / Android / Android Studio / gradle / m2repository / com / android / tools / build / gradle / 3.0 .0 - alpha5 / gradle - 3.0 .0 - alpha5.jar
https: //jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha5/gradle-3.0.0-alpha5.pom
  https: //jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha5/gradle-3.0.0-alpha5.jar
  Required by:
  project:

Android 2.3.3

Body:
in your top build.gradle you should add this

classpath 'com.android.tools.build:gradle:2.3.3'

and remove line which contains alpha. That developer must be using canary builds of Android studio.


来源: stackexchange

问:
How to use the signal QMovie::frameChanged(int frameNumber) to emit a signal?
I want to use the frameChanged(int) to emit a signal when the currentFrameNumber is equal to the frameCount, my QT version is 4.7.4

QObject::connect(movie,SIGNAL(frameChanged(int)),movie,SLOT(stop()));

QMovieChild.cpp:

```<code>class QMovieChild:public QMovie
{

signals:
void newSignal();
public slots:
    void onFrameChanged(int frameNumber){
        if(frameNumber == this->frameCount()-2)
            emit newSignal();
}
};
</code>```

Monster.cpp:

```<code>void Monster::Vanishment()
{
QMovieChild *movie = new QMovieChild();
movie->setFileName("./pikaqiu.gif");
QSize size = this->getLabelPointer()->size();
movie->setScaledSize(size);
this->getLabelPointer()->setMovie(movie);
QMovie::connect(movie,SIGNAL(newSignal()),movie,SLOT(deleteLater()));
QMovie::connect(movie,SIGNAL(frameChanged(int)),movie,SLOT(onFrameChanged(int)));
movie->start();
}
</code>```

答:
To create a signal the class should inherit from QObject, if the class you use is QWidget, it is also valid since it inherits from QObject.

```<code>#ifndef QMOVIECHILD_H
#define QMOVIECHILD_H

#include <QMovie>

class QMovieChild : public QMovie
{
    Q_OBJECT
public:
    QMovieChild(QObject * parent = 0):QMovie(parent){
        connect(this, SIGNAL(frameChanged(int)), this, SLOT(onFrameChanged(int)));
    }

signals:
    void newSignal();
private slots:
    void onFrameChanged(int frameNumber){
        if(frameNumber == frameCount()-1){
            emit newSignal();
            //stop();
        }
    }

};

#endif // QMOVIECHILD_H
</code>```

Use:

```<code>QMovieChild *movie = new QMovieChild;
movie->setFileName("./pikaqiu.gif");
QMovie::connect(movie,SIGNAL(newSignal()),movie,SLOT(deleteLater()));
QSize size = getLabelPointer()->size();
movie->setScaledSize(size);
getLabelPointer()->setMovie(movie);
movie->start();
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I want to use the frameChanged(int) to emit a signal when the currentFrameNumber is equal to the frameCount, my QT version is 4.7.4

QObject::connect(movie,SIGNAL(frameChanged(int)),movie,SLOT(stop()));

QMovieChild.cpp:

class QMovieChild:public QMovie
{

signals:
void newSignal();
public slots:
    void onFrameChanged(int frameNumber){
        if(frameNumber == this->frameCount()-2)
            emit newSignal();
}
};

Monster.cpp:

void Monster::Vanishment()
{
QMovieChild *movie = new QMovieChild();
movie->setFileName("./pikaqiu.gif");
QSize size = this->getLabelPointer()->size();
movie->setScaledSize(size);
this->getLabelPointer()->setMovie(movie);
QMovie::connect(movie,SIGNAL(newSignal()),movie,SLOT(deleteLater()));
QMovie::connect(movie,SIGNAL(frameChanged(int)),movie,SLOT(onFrameChanged(int)));
movie->start();
}

Body:
To create a signal the class should inherit from QObject, if the class you use is QWidget, it is also valid since it inherits from QObject.

#ifndef QMOVIECHILD_H
#define QMOVIECHILD_H

#include <QMovie>

class QMovieChild : public QMovie
{
    Q_OBJECT
public:
    QMovieChild(QObject * parent = 0):QMovie(parent){
        connect(this, SIGNAL(frameChanged(int)), this, SLOT(onFrameChanged(int)));
    }

signals:
    void newSignal();
private slots:
    void onFrameChanged(int frameNumber){
        if(frameNumber == frameCount()-1){
            emit newSignal();
            //stop();
        }
    }

};

#endif // QMOVIECHILD_H

Use:

QMovieChild *movie = new QMovieChild;
movie->setFileName("./pikaqiu.gif");
QMovie::connect(movie,SIGNAL(newSignal()),movie,SLOT(deleteLater()));
QSize size = getLabelPointer()->size();
movie->setScaledSize(size);
getLabelPointer()->setMovie(movie);
movie->start();

ContentLicense: CC BY-SA 3.0


问:
Export varbinary to file (image) from multiple rows
I have a MSSQL 2k8 database, in it I have a table of format below.

```<code>Employee Number   |   Segment   |   Data (varbinary(8000))
----------------------------------------------------------
111111            |     1       |    0x01234567...DEF
111111            |     2       |    0x01234567...DEF
111111            |     3       |    0x01234567...DEF
</code>```

The data (varbinary) column makes up a picture but unfortunately is split in multiple segments by a process I cannot control.

Is there a way to export this data via an SQL script/procedure to a file? I have seem some questions that answer for a varbinary(max) column but I can't for the life of me work out how to stitch these all together into one file.

Note: Some of the files have >500 segments but this procedure will not be occuring exceedingly regularly.

答:
If the picture can be reconstructed by simply concatenating all of the segments, then you could try execsql.py, which is a SQL script processor written in Python (by me).  It has a metacommand of this form:

```<code>EXPORT <table_or_view> TO <filename> AS RAW
</code>```

which will concatenate all columns and rows in the given table or view.

Body:
I have a MSSQL 2k8 database, in it I have a table of format below.

Employee Number   |   Segment   |   Data (varbinary(8000))
----------------------------------------------------------
111111            |     1       |    0x01234567...DEF
111111            |     2       |    0x01234567...DEF
111111            |     3       |    0x01234567...DEF

The data (varbinary) column makes up a picture but unfortunately is split in multiple segments by a process I cannot control.

Is there a way to export this data via an SQL script/procedure to a file? I have seem some questions that answer for a varbinary(max) column but I can't for the life of me work out how to stitch these all together into one file.

Note: Some of the files have >500 segments but this procedure will not be occuring exceedingly regularly.

Body:
If the picture can be reconstructed by simply concatenating all of the segments, then you could try execsql.py, which is a SQL script processor written in Python (by me).  It has a metacommand of this form:

EXPORT <table_or_view> TO <filename> AS RAW

which will concatenate all columns and rows in the given table or view.


问:
Error when installing dlib
I am trying to install dlib on a virtual environment on a mac.

When I run  ./compile_dlib_python_module.bat this is the error I get:

```<code>Scanning dependencies of target dlib_
[ 88%] Building CXX object CMakeFiles/dlib_.dir/src/dlib.cpp.o
[ 88%] Building CXX object CMakeFiles/dlib_.dir/src/matrix.cpp.o
[ 89%] Building CXX object CMakeFiles/dlib_.dir/src/vector.cpp.o
[ 90%] Building CXX object CMakeFiles/dlib_.dir/src/svm_c_trainer.cpp.o
[ 91%] Building CXX object CMakeFiles/dlib_.dir/src/svm_rank_trainer.cpp.o
[ 91%] Building CXX object CMakeFiles/dlib_.dir/src/decision_functions.cpp.o
[ 92%] Building CXX object CMakeFiles/dlib_.dir/src/other.cpp.o
[ 93%] Building CXX object CMakeFiles/dlib_.dir/src/basic.cpp.o
[ 94%] Building CXX object CMakeFiles/dlib_.dir/src/cca.cpp.o
[ 94%] Building CXX object CMakeFiles/dlib_.dir/src/sequence_segmenter.cpp.o
[ 95%] Building CXX object CMakeFiles/dlib_.dir/src/svm_struct.cpp.o
[ 96%] Building CXX object CMakeFiles/dlib_.dir/src/image.cpp.o
[ 97%] Building CXX object CMakeFiles/dlib_.dir/src/rectangles.cpp.o
[ 97%] Building CXX object CMakeFiles/dlib_.dir/src/object_detection.cpp.o
[ 98%] Building CXX object CMakeFiles/dlib_.dir/src/shape_predictor.cpp.o
[ 99%] Building CXX object CMakeFiles/dlib_.dir/src/correlation_tracker.cpp.o
make[2]: *** No rule to make target `/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib', needed by `dlib.so'.  Stop.
make[1]: *** [CMakeFiles/dlib_.dir/all] Error 2
make: *** [all] Error 2
</code>```

答:
Download the source code at the official website, then install:</p>

```<code>tar -jxvf XXXXX.bz2
python setup.py install
</code>```

Title: Error when installing dlib

Body:
I am trying to install dlib on a virtual environment on a mac.

When I run  ./compile_dlib_python_module.bat this is the error I get:

Scanning dependencies of target dlib_
[ 88%] Building CXX object CMakeFiles/dlib_.dir/src/dlib.cpp.o
[ 88%] Building CXX object CMakeFiles/dlib_.dir/src/matrix.cpp.o
[ 89%] Building CXX object CMakeFiles/dlib_.dir/src/vector.cpp.o
[ 90%] Building CXX object CMakeFiles/dlib_.dir/src/svm_c_trainer.cpp.o
[ 91%] Building CXX object CMakeFiles/dlib_.dir/src/svm_rank_trainer.cpp.o
[ 91%] Building CXX object CMakeFiles/dlib_.dir/src/decision_functions.cpp.o
[ 92%] Building CXX object CMakeFiles/dlib_.dir/src/other.cpp.o
[ 93%] Building CXX object CMakeFiles/dlib_.dir/src/basic.cpp.o
[ 94%] Building CXX object CMakeFiles/dlib_.dir/src/cca.cpp.o
[ 94%] Building CXX object CMakeFiles/dlib_.dir/src/sequence_segmenter.cpp.o
[ 95%] Building CXX object CMakeFiles/dlib_.dir/src/svm_struct.cpp.o
[ 96%] Building CXX object CMakeFiles/dlib_.dir/src/image.cpp.o
[ 97%] Building CXX object CMakeFiles/dlib_.dir/src/rectangles.cpp.o
[ 97%] Building CXX object CMakeFiles/dlib_.dir/src/object_detection.cpp.o
[ 98%] Building CXX object CMakeFiles/dlib_.dir/src/shape_predictor.cpp.o
[ 99%] Building CXX object CMakeFiles/dlib_.dir/src/correlation_tracker.cpp.o
make[2]: *** No rule to make target `/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib', needed by `dlib.so'.  Stop.
make[1]: *** [CMakeFiles/dlib_.dir/all] Error 2
make: *** [all] Error 2

Body:
Download the source code at the official website, then install:

tar -jxvf XXXXX.bz2
python setup.py install


问:
Extra segment won't register color data in assembly
I am programming a game similar to breakout in assembly (tools:DosBOX, notepad++, tasm), and whilst creating the borders and platform in Graphics mode, I've stumbled upon 2 problems:

It seems as if the extra segment won't register the color information, as I can't get it right and when I try to pull it gives me a 0 which is black, as opposed to white which is 0Fh.

It's a slight problem which I tried to resolve, but for some reason, when when I try to paint the second and third border, a part of the 1st border turns black, you'll see it if you run the code. I wasn't able to determine why it happens and the debugger didn't show anything odd.

This is my current code, the main procedures that are involved in the creating of the borders, platform and movement of the platform are BorderPaint, PlatBuild and PlatMove

```<code>    IDEAL
    MODEL small
    STACK 100h
    DATASEG
    platLoc dw 63806
    speed1 dw 10
    speed2 dw 0FFFFh
    CODESEG
    ;procedure to paint borders-6 px white pixels
    proc BorderPaint
        push ax
        push bx
        push di
        push cx

    mov ax,0A000h ;accesses graphics mode video memory
    mov es,ax
    xor di,di

    ;first line-left vertical
    ;sets color white

    mov ax,0Fh
    mov cx,200 ;enters nested loop
    FirstLoop1:
    push cx
    mov cx,6
    SecondLoop1:
    mov [es:di],ax
    inc di
    loop SecondLoop1
    sub di,6
    add di,320
    pop cx
    loop FirstLoop1
    ;second line- up horizontal
    mov di,7
    mov cx,313
    FirstLoop2:
    push cx
    mov cx,6
    SecondLoop2:
    mov [es:di],ax
    add di,320
    loop SecondLoop2
    sub di,1920
    inc di
    pop cx
    loop FirstLoop2

    mov di,314
    mov cx,200
    FirstLoop3:
    push cx
    mov cx,6
    SecondLoop3:
    mov [es:di],ax
    inc di
    loop SecondLoop3
    sub di,6
    add di,320
    pop cx
    loop FirstLoop3

    ; xor di,di
    ; mov ax,0Fh
    ; mov cx,200
    ; FirstLoop4:
    ; push cx
    ; mov cx,6
    ; SecondLoop4:
    ; mov [es:di],ax
    ; inc di
    ; loop SecondLoop4
    ; sub di,6
    ; add di,320
    ; pop cx
    ; loop FirstLoop4

        pop cx
        pop di
        pop bx
        pop ax
    ret
    endp BorderPaint

    proc PlatBuild
    push di
    push cx
    push ax
        mov di,[platLoc]
        mov ax,5
        mov cx,40
        LoopPaint2:
        push cx
        mov cx,10
        LoopPaint1:
        mov [es:di],ax
        sub di,320
        loop LoopPaint1
        add di,320*10
        inc di
        pop cx
        loop LoopPaint2
    pop ax
    pop cx
    pop di
    ret
    endp PlatBuild

    Proc PlatErase
    push di
    push cx
    push ax
        mov di,[platLoc]
        mov ax,0
        mov cx,40
        LoopPaint4:
        push cx
        mov cx,10
        LoopPaint3:
        mov [es:di],ax
        sub di,320
        loop LoopPaint3
        add di,320*10
        inc di
        pop cx
        loop LoopPaint4
    pop ax
    pop cx
    pop di
    ret
    endp PlatErase

    Proc PlatMove
    push ax
    push cx
    push dx
    push di
        mov ax,0A000h
        mov es,ax
        call BorderPaint
        ;Input
        CheckPress1:
        mov ah,0h
        int 16h

        cmp al,'a'
        jne nxt11
        jmp MoveLeft1
         Nxt11:
        cmp al,'d'
        jne nxt12
        jmp MoveRight1
        Nxt12:
        cmp al,'q'
        jne CheckPress1
        jmp endproc1

        MoveLeft1:
        call Delay
        mov dx,[platLoc]
        add dx,8*320
        sub dx,1d
        mov di,dx
        mov ax,[es:di]
        cmp ax,0Fh
        jne move1
        jmp CheckPress1
        move1:
        call PlatErase
        dec [platLoc]
        call PlatBuild
        mov ah,1h
        int 16h
        je MoveLeft1
        jmp CheckPress1

        MoveRight1:
        call Delay
        mov dx,[platLoc]
        add dx,41

        mov di,dx
        mov ax,[es:di]
        cmp ax,0Fh
        jne move2
        jmp CheckPress1
        move2:
        call PlatErase
        inc [platLoc]
        call PlatBuild
        mov ah,1h
        int 16h
        je MoveRight1
        jmp CheckPress1
        EndProc1:
    pop di
    pop dx
    pop cx
    pop ax
        ret
        endp PlatMove
        proc Delay
    push cx
        mov cx, [speed2]
    LoopLong:
    push cx
        mov cx, [speed1]
      LoopShort:
        loop LoopShort
    pop cx
        loop LoopLong
    pop cx
    ret
    Endp Delay
    start:
        mov ax,@data
        mov ds,ax
        mov ax,13h
        int 10h
        call BorderPaint
        call PlatBuild
        mov ax, [es:63680]
        call PlatMove

    exit:
        mov ax,4c00h
        int 21h
    END startenter code here
</code>```

答:
mov [es:di],ax writes WORD (two bytes) into VRAM, ax = 0x000F, so you write at [es:di] value 0x0F, and at [es:di+1] value 0x00 (black).

```<code>    sub di,6
    add di,320
</code>```

This is blasphemy :/ ... add di,320-6 remains the intent visible on source level, but also shows less ignorance toward the machine, minimizing the amount of instructions used.

BTW, if you want to store 6 bytes with 0x0F value, you can also store three words of 0x0F0F value, saving half of VRAM accesses (which are expensive). So then

```<code>    mov di,<some VRAM address>
    mov cx,<number of lines>
    mov ax,0F0Fh  ; <color><color> (two pixels at same time)
Draw6PixelsLoop:
    mov [es:di],ax
    mov [es:di+2],ax
    mov [es:di+4],ax
    add di,320
    dec cx
    jnz Draw6PixelsLoop
</code>```

is more optimal hard-coded way how to draw 6 pixels (with only 3 VRAM writes) and move 1 line below.

not sure, what you mean, but probably one problem may be reading word (two pixels) from VRAM in PlatMove and then comparing them with 0Fh cmp ax,0Fh, i.e. two pixels "white + black" = 000Fh. So on the left side this will probably work well, but on the right side it will find such two pixels only at the end of the border (keep in mind after the last pixel on the right side the next byte is the first left pixel on next line, so if you have borders 6 pixels strong, the first white+black pixel is at next line where the left border ends).

Body:
I am programming a game similar to breakout in assembly (tools:DosBOX, notepad++, tasm), and whilst creating the borders and platform in Graphics mode, I've stumbled upon 2 problems:

It seems as if the extra segment won't register the color information, as I can't get it right and when I try to pull it gives me a 0 which is black, as opposed to white which is 0Fh.

It's a slight problem which I tried to resolve, but for some reason, when when I try to paint the second and third border, a part of the 1st border turns black, you'll see it if you run the code. I wasn't able to determine why it happens and the debugger didn't show anything odd.

This is my current code, the main procedures that are involved in the creating of the borders, platform and movement of the platform are BorderPaint, PlatBuild and PlatMove

    IDEAL
    MODEL small
    STACK 100h
    DATASEG
    platLoc dw 63806
    speed1 dw 10
    speed2 dw 0FFFFh
    CODESEG
    ;procedure to paint borders-6 px white pixels
    proc BorderPaint
        push ax
        push bx
        push di
        push cx

    mov ax,0A000h ;accesses graphics mode video memory
    mov es,ax
    xor di,di

    ;first line-left vertical
    ;sets color white

    mov ax,0Fh
    mov cx,200 ;enters nested loop
    FirstLoop1:
    push cx
    mov cx,6
    SecondLoop1:
    mov [es:di],ax
    inc di
    loop SecondLoop1
    sub di,6
    add di,320
    pop cx
    loop FirstLoop1
    ;second line- up horizontal
    mov di,7
    mov cx,313
    FirstLoop2:
    push cx
    mov cx,6
    SecondLoop2:
    mov [es:di],ax
    add di,320
    loop SecondLoop2
    sub di,1920
    inc di
    pop cx
    loop FirstLoop2

    mov di,314
    mov cx,200
    FirstLoop3:
    push cx
    mov cx,6
    SecondLoop3:
    mov [es:di],ax
    inc di
    loop SecondLoop3
    sub di,6
    add di,320
    pop cx
    loop FirstLoop3

    ; xor di,di
    ; mov ax,0Fh
    ; mov cx,200
    ; FirstLoop4:
    ; push cx
    ; mov cx,6
    ; SecondLoop4:
    ; mov [es:di],ax
    ; inc di
    ; loop SecondLoop4
    ; sub di,6
    ; add di,320
    ; pop cx
    ; loop FirstLoop4

        pop cx
        pop di
        pop bx
        pop ax
    ret
    endp BorderPaint

    proc PlatBuild
    push di
    push cx
    push ax
        mov di,[platLoc]
        mov ax,5
        mov cx,40
        LoopPaint2:
        push cx
        mov cx,10
        LoopPaint1:
        mov [es:di],ax
        sub di,320
        loop LoopPaint1
        add di,320*10
        inc di
        pop cx
        loop LoopPaint2
    pop ax
    pop cx
    pop di
    ret
    endp PlatBuild

    Proc PlatErase
    push di
    push cx
    push ax
        mov di,[platLoc]
        mov ax,0
        mov cx,40
        LoopPaint4:
        push cx
        mov cx,10
        LoopPaint3:
        mov [es:di],ax
        sub di,320
        loop LoopPaint3
        add di,320*10
        inc di
        pop cx
        loop LoopPaint4
    pop ax
    pop cx
    pop di
    ret
    endp PlatErase

    Proc PlatMove
    push ax
    push cx
    push dx
    push di
        mov ax,0A000h
        mov es,ax
        call BorderPaint
        ;Input
        CheckPress1:
        mov ah,0h
        int 16h

        cmp al,'a'
        jne nxt11
        jmp MoveLeft1
         Nxt11:
        cmp al,'d'
        jne nxt12
        jmp MoveRight1
        Nxt12:
        cmp al,'q'
        jne CheckPress1
        jmp endproc1

        MoveLeft1:
        call Delay
        mov dx,[platLoc]
        add dx,8*320
        sub dx,1d
        mov di,dx
        mov ax,[es:di]
        cmp ax,0Fh
        jne move1
        jmp CheckPress1
        move1:
        call PlatErase
        dec [platLoc]
        call PlatBuild
        mov ah,1h
        int 16h
        je MoveLeft1
        jmp CheckPress1

        MoveRight1:
        call Delay
        mov dx,[platLoc]
        add dx,41

        mov di,dx
        mov ax,[es:di]
        cmp ax,0Fh
        jne move2
        jmp CheckPress1
        move2:
        call PlatErase
        inc [platLoc]
        call PlatBuild
        mov ah,1h
        int 16h
        je MoveRight1
        jmp CheckPress1
        EndProc1:
    pop di
    pop dx
    pop cx
    pop ax
        ret
        endp PlatMove
        proc Delay
    push cx
        mov cx, [speed2]
    LoopLong:
    push cx
        mov cx, [speed1]
      LoopShort:
        loop LoopShort
    pop cx
        loop LoopLong
    pop cx
    ret
    Endp Delay
    start:
        mov ax,@data
        mov ds,ax
        mov ax,13h
        int 10h
        call BorderPaint
        call PlatBuild
        mov ax, [es:63680]
        call PlatMove

    exit:
        mov ax,4c00h
        int 21h
    END startenter code here

Body:
mov [es:di],ax writes WORD (two bytes) into VRAM, ax = 0x000F, so you write at [es:di] value 0x0F, and at [es:di+1] value 0x00 (black).

    sub di,6
    add di,320

This is blasphemy :/ ... add di,320-6 remains the intent visible on source level, but also shows less ignorance toward the machine, minimizing the amount of instructions used.

BTW, if you want to store 6 bytes with 0x0F value, you can also store three words of 0x0F0F value, saving half of VRAM accesses (which are expensive). So then

    mov di,<some VRAM address>
    mov cx,<number of lines>
    mov ax,0F0Fh  ; <color><color> (two pixels at same time)
Draw6PixelsLoop:
    mov [es:di],ax
    mov [es:di+2],ax
    mov [es:di+4],ax
    add di,320
    dec cx
    jnz Draw6PixelsLoop

is more optimal hard-coded way how to draw 6 pixels (with only 3 VRAM writes) and move 1 line below.

not sure, what you mean, but probably one problem may be reading word (two pixels) from VRAM in PlatMove and then comparing them with 0Fh cmp ax,0Fh, i.e. two pixels "white + black" = 000Fh. So on the left side this will probably work well, but on the right side it will find such two pixels only at the end of the border (keep in mind after the last pixel on the right side the next byte is the first left pixel on next line, so if you have borders 6 pixels strong, the first white+black pixel is at next line where the left border ends).


问:
Does throwing an Exception have to cause the program to terminate
Does throwing an Exception have to cause the program to terminate?

I think its no, I just want to make sure

答:
Only "Unhandled Exceptions" will cause your program to crash. To handle exceptions you use the following form</p>

```<code>try {
        // May Throw ApocalypseException
        functionThatMightBlowUpTheWorld();
    }
catch (ApocalypseException e){
         System.err.println("We accidentally almost blew up the world because: ");
         System.err.println(e.message);
}
</code>```

ContentLicense: CC BY-SA 2.5

Body:
Only "Unhandled Exceptions" will cause your program to crash. To handle exceptions you use the following form

try {
        // May Throw ApocalypseException
        functionThatMightBlowUpTheWorld();
    }
catch (ApocalypseException e){
         System.err.println("We accidentally almost blew up the world because: ");
         System.err.println(e.message);
}


问:
Pygame - Mixer system not initialized
I have been working on making a Pygame for my Social Studies class and I want to add new elements to this existing game. The problem is, when I load the old game, without making any significant changes, I get an error. It seems to have a couple of warnings as well that I have looked up but most of the threads are from years ago. My error is as follows:

```<code>Jordans-MacBook-Air:SS-Game Jordanxxi$ python ocean_cleaner.py
2017-05-26 12:23:15.729 Python[61184:1392206] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
May 26 12:23:15  Python[61184] <Error>: The function ‘SLSFlushWindow’ is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance. Please use `SLSFlushWindowContentRegion' instead.
Traceback (most recent call last):
  File "ocean_cleaner.py", line 30, in <module>
    hit = pygame.mixer.Sound("resources/audio/pop.wav")
pygame.error: mixer system not initialized
</code>```

My code, as of now, is as follows:

```<code>#Import statements
import pygame, sys
import pygame.mixer
import time
from pygame.locals import *

#Pygame function to load the game and screen size
pygame.init()
screen = pygame.display.set_mode((700,500))

#Images needed in game
background = pygame.image.load("resources/images/background.png")
slick = pygame.image.load("resources/images/slick.png")
slick_med = pygame.image.load("resources/images/slick_med.png")
slick_sml = pygame.image.load("resources/images/slick_sml.png")
diver = pygame.image.load("resources/images/diver_gun.png")
diver1 = pygame.image.load("resources/images/diver_gun1.png")
spray_right = pygame.image.load("resources/images/spray_right.png")
spray_left = pygame.image.load("resources/images/spray_left.png")
win_screen = pygame.image.load("resources/images/win_screen.png")
lose_screen = pygame.image.load("resources/images/lose_screen.png")
red_bar = pygame.image.load("resources/images/red_bar.png")
green_bar2 = pygame.image.load("resources/images/green_bar2.png")
green_bar4 = pygame.image.load("resources/images/green_bar4.png")
air_bar = pygame.image.load("resources/images/air_bar.png")
spray_bar = pygame.image.load("resources/images/spray_bar.png")

#Sounds
hit = pygame.mixer.Sound("resources/audio/pop.wav")
hit.set_volume(0.5)
wash = pygame.mixer.Sound("resources/audio/spray.wav")
wash.set_volume(0.4)
pygame.mixer.music.load('resources/audio/tune_1.wav')
pygame.mixer.music.play(-1, 0.0)
pygame.mixer.music.set_volume(0.25)

#The Variables
player = diver
spray = spray_right
spray_off_set = 0
pop=False
pop_index=0
player_x = 250
player_y = 100
background_x = 0
background_y = 0
move_x = 0
move_y = 0
keys=[False,False,False,False,False]
slick_large=[[slick,300,250],[slick,1000,650],[slick,1400,1050]]
slick_medium =[]
slick_small = []
clean_up = 12
life = True
sprays = 30

main_loop = 1
while main_loop:

    pygame.display.set_caption('Greek Mythology Quiz')

    #How the charater moves when certain keys are clicked
    #---------------------------------------------------#
    #Move Right
    if keys[0]==True and move_x <5:
        move_x+= 1
        player = diver1
        spray = spray_left
        spray_off_set = -200
    #Move Left
    if keys[1]==True and move_x >-1310:
        move_x-= 1
        player = diver
        spray = spray_right
        spray_off_set = 0
    #Move Up
    if keys[2]==True and move_y <10:
        move_y+= 1
    #Move Down
    if keys[3]==True and move_y >-1010:
        move_y-= 1

    #Check for collisions
    spray_rect=pygame.Rect(spray.get_rect())
    spray_rect.left=(350+spray_off_set)
    spray_rect.top=100

    player_rect=pygame.Rect(player.get_rect())
    player_rect.left= player_x
    player_rect.top= player_y

    for i in range(len(slick_large)):
        slick_rect=pygame.Rect(slick.get_rect())
        slick_rect.left=((slick_large[i][1])+move_x)
        slick_rect.top=(slick_large[i][2]+move_y)
        if spray_rect.colliderect(slick_rect) and keys[4] == True:
            pop=True
            pop_index=i
        if player_rect.colliderect(slick_rect):
            life = False
    #When pop sound is called, volume depends on object size
    if pop==True:
        hit.play()
        slick_medium.append([slick_med,(slick_large[pop_index][1]+75),(slick_large[pop_index][2]-50)])
        slick_medium.append([slick_med,(slick_large[pop_index][1]+150),(slick_large[pop_index][2]+50)])
        slick_large.pop(pop_index)
        pop=False

    #Collision redirect physics
    for i in range(len(slick_medium)):
        slick_rect=pygame.Rect(slick_med.get_rect())
        slick_rect.left=((slick_medium[i][1])+move_x)
        slick_rect.top=(slick_medium[i][2]+move_y)
        if spray_rect.colliderect(slick_rect) and keys[4] == True:
            pop=True
            pop_index=i
        if player_rect.colliderect(slick_rect):
            life = False
    if pop==True:
        hit.play()
        slick_small.append([slick_sml,(slick_medium[pop_index][1]-75),(slick_medium[pop_index][2]-75)])
        slick_small.append([slick_sml,(slick_medium[pop_index][1]-150),(slick_medium[pop_index][2]-50)])
        slick_medium.pop(pop_index)
        pop=False

    for i in range(len(slick_small)):
        slick_rect=pygame.Rect(slick_sml.get_rect())
        slick_rect.left=((slick_small[i][1])+move_x)
        slick_rect.top=(slick_small[i][2]+move_y)
        if spray_rect.colliderect(slick_rect) and keys[4] == True:
            pop=True
            pop_index=i
        if player_rect.colliderect(slick_rect):
            life = False
    if pop==True:
        hit.play()
        slick_small.pop(pop_index)
        clean_up -=1
        pop=False

    #Background scrolling
    screen.fill(0)

    screen.blit(background,((background_x+move_x),(background_y+move_y)))
    screen.blit(player,(player_x,player_y))

    if keys[4]==True:
        wash.play()
        screen.blit(spray,((350+spray_off_set),100))
    else:
        wash.stop()

    for i in range( len(slick_large)):
        screen.blit(slick_large[i][0],((slick_large[i][1]+move_x),(slick_large[i][2]+move_y)))

    for i in range( len(slick_medium)):
        screen.blit(slick_medium[i][0],((slick_medium[i][1]+move_x),(slick_medium[i][2]+move_y)))

    for i in range( len(slick_small)):
        screen.blit(slick_small[i][0],((slick_small[i][1]+move_x),(slick_small[i][2]+move_y)))

    time_remaining = int((60-(pygame.time.get_ticks()/1000)))
    screen.blit(air_bar,(8,8))
    screen.blit(red_bar,(10,10))
    for i in range(time_remaining):
        screen.blit(green_bar2,(10+(i*2),10))

    screen.blit(spray_bar,(570,8))
    screen.blit(red_bar,(572,10))
    for i in range(sprays):
        screen.blit(green_bar4,(572+(i*4),10))

    if clean_up == 0:
        screen.blit(win_screen,(0,0))
        main_loop = 0
    if life == False or sprays == 0 or time_remaining == 0:
        screen.blit(lose_screen,(0,0))
        main_loop = 0

    pygame.display.flip()

    for event in pygame.event.get():
        if event.type==pygame.QUIT:
            pygame.quit()
            exit(0)
        #Event checkers - Check to see if certain keys are pressed
        if event.type == pygame.KEYDOWN:
            if event.key==K_LEFT:
                keys[0]=True
            elif event.key==K_RIGHT:
                keys[1]=True
            elif event.key==K_UP:
                keys[2]=True
            elif event.key==K_DOWN:
                keys[3]=True
            elif event.key==K_SPACE:
                keys[4]=True
        #Check to see when certain keys are released
        if event.type == pygame.KEYUP:
            if event.key==K_LEFT:
                keys[0]=False
            elif event.key==K_RIGHT:
                keys[1]=False
            elif event.key==K_UP:
                keys[2]=False
            elif event.key==K_DOWN:
                keys[3]=False
            elif event.key==K_SPACE:
                keys[4]=False
                sprays -= 1

end = 1
while end:
    #Exit function
    for event in pygame.event.get():
        if event.type==pygame.QUIT:
            pygame.quit()
            exit(0)
</code>```

Any help? Thanks in advance.

Update - I was running the game through terminal instead of Idle. I still get an error but it is a little bit different. Anyone know how to fix this?

```<code>Traceback (most recent call last):
  File "/Users/Jordanxxi/Desktop/Game/ocean_cleaner.py", line 29, in <module>
    hit = pygame.mixer.Sound("resources/audio/pop.wav")
error: mixer system not initialized
</code>```

答:
I believe you have to do:

```<code>pygame.mixer.init()
</code>```

Check the documentation for mixer (this is always a good idea to do first when you have a problem!): http://www.pygame.org/docs/ref/mixer.html

Title: Pygame - Mixer system not initialized

Body:
I have been working on making a Pygame for my Social Studies class and I want to add new elements to this existing game. The problem is, when I load the old game, without making any significant changes, I get an error. It seems to have a couple of warnings as well that I have looked up but most of the threads are from years ago. My error is as follows:

Jordans-MacBook-Air:SS-Game Jordanxxi$ python ocean_cleaner.py
2017-05-26 12:23:15.729 Python[61184:1392206] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
May 26 12:23:15  Python[61184] <Error>: The function ‘SLSFlushWindow’ is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance. Please use `SLSFlushWindowContentRegion' instead.
Traceback (most recent call last):
  File "ocean_cleaner.py", line 30, in <module>
    hit = pygame.mixer.Sound("resources/audio/pop.wav")
pygame.error: mixer system not initialized

My code, as of now, is as follows:

#Import statements
import pygame, sys
import pygame.mixer
import time
from pygame.locals import *

#Pygame function to load the game and screen size
pygame.init()
screen = pygame.display.set_mode((700,500))

#Images needed in game
background = pygame.image.load("resources/images/background.png")
slick = pygame.image.load("resources/images/slick.png")
slick_med = pygame.image.load("resources/images/slick_med.png")
slick_sml = pygame.image.load("resources/images/slick_sml.png")
diver = pygame.image.load("resources/images/diver_gun.png")
diver1 = pygame.image.load("resources/images/diver_gun1.png")
spray_right = pygame.image.load("resources/images/spray_right.png")
spray_left = pygame.image.load("resources/images/spray_left.png")
win_screen = pygame.image.load("resources/images/win_screen.png")
lose_screen = pygame.image.load("resources/images/lose_screen.png")
red_bar = pygame.image.load("resources/images/red_bar.png")
green_bar2 = pygame.image.load("resources/images/green_bar2.png")
green_bar4 = pygame.image.load("resources/images/green_bar4.png")
air_bar = pygame.image.load("resources/images/air_bar.png")
spray_bar = pygame.image.load("resources/images/spray_bar.png")

#Sounds
hit = pygame.mixer.Sound("resources/audio/pop.wav")
hit.set_volume(0.5)
wash = pygame.mixer.Sound("resources/audio/spray.wav")
wash.set_volume(0.4)
pygame.mixer.music.load('resources/audio/tune_1.wav')
pygame.mixer.music.play(-1, 0.0)
pygame.mixer.music.set_volume(0.25)

#The Variables
player = diver
spray = spray_right
spray_off_set = 0
pop=False
pop_index=0
player_x = 250
player_y = 100
background_x = 0
background_y = 0
move_x = 0
move_y = 0
keys=[False,False,False,False,False]
slick_large=[[slick,300,250],[slick,1000,650],[slick,1400,1050]]
slick_medium =[]
slick_small = []
clean_up = 12
life = True
sprays = 30

main_loop = 1
while main_loop:

    pygame.display.set_caption('Greek Mythology Quiz')

    #How the charater moves when certain keys are clicked
    #---------------------------------------------------#
    #Move Right
    if keys[0]==True and move_x <5:
        move_x+= 1
        player = diver1
        spray = spray_left
        spray_off_set = -200
    #Move Left
    if keys[1]==True and move_x >-1310:
        move_x-= 1
        player = diver
        spray = spray_right
        spray_off_set = 0
    #Move Up
    if keys[2]==True and move_y <10:
        move_y+= 1
    #Move Down
    if keys[3]==True and move_y >-1010:
        move_y-= 1

    #Check for collisions
    spray_rect=pygame.Rect(spray.get_rect())
    spray_rect.left=(350+spray_off_set)
    spray_rect.top=100

    player_rect=pygame.Rect(player.get_rect())
    player_rect.left= player_x
    player_rect.top= player_y

    for i in range(len(slick_large)):
        slick_rect=pygame.Rect(slick.get_rect())
        slick_rect.left=((slick_large[i][1])+move_x)
        slick_rect.top=(slick_large[i][2]+move_y)
        if spray_rect.colliderect(slick_rect) and keys[4] == True:
            pop=True
            pop_index=i
        if player_rect.colliderect(slick_rect):
            life = False
    #When pop sound is called, volume depends on object size
    if pop==True:
        hit.play()
        slick_medium.append([slick_med,(slick_large[pop_index][1]+75),(slick_large[pop_index][2]-50)])
        slick_medium.append([slick_med,(slick_large[pop_index][1]+150),(slick_large[pop_index][2]+50)])
        slick_large.pop(pop_index)
        pop=False

    #Collision redirect physics
    for i in range(len(slick_medium)):
        slick_rect=pygame.Rect(slick_med.get_rect())
        slick_rect.left=((slick_medium[i][1])+move_x)
        slick_rect.top=(slick_medium[i][2]+move_y)
        if spray_rect.colliderect(slick_rect) and keys[4] == True:
            pop=True
            pop_index=i
        if player_rect.colliderect(slick_rect):
            life = False
    if pop==True:
        hit.play()
        slick_small.append([slick_sml,(slick_medium[pop_index][1]-75),(slick_medium[pop_index][2]-75)])
        slick_small.append([slick_sml,(slick_medium[pop_index][1]-150),(slick_medium[pop_index][2]-50)])
        slick_medium.pop(pop_index)
        pop=False

    for i in range(len(slick_small)):
        slick_rect=pygame.Rect(slick_sml.get_rect())
        slick_rect.left=((slick_small[i][1])+move_x)
        slick_rect.top=(slick_small[i][2]+move_y)
        if spray_rect.colliderect(slick_rect) and keys[4] == True:
            pop=True
            pop_index=i
        if player_rect.colliderect(slick_rect):
            life = False
    if pop==True:
        hit.play()
        slick_small.pop(pop_index)
        clean_up -=1
        pop=False

    #Background scrolling
    screen.fill(0)

    screen.blit(background,((background_x+move_x),(background_y+move_y)))
    screen.blit(player,(player_x,player_y))

    if keys[4]==True:
        wash.play()
        screen.blit(spray,((350+spray_off_set),100))
    else:
        wash.stop()

    for i in range( len(slick_large)):
        screen.blit(slick_large[i][0],((slick_large[i][1]+move_x),(slick_large[i][2]+move_y)))

    for i in range( len(slick_medium)):
        screen.blit(slick_medium[i][0],((slick_medium[i][1]+move_x),(slick_medium[i][2]+move_y)))

    for i in range( len(slick_small)):
        screen.blit(slick_small[i][0],((slick_small[i][1]+move_x),(slick_small[i][2]+move_y)))

    time_remaining = int((60-(pygame.time.get_ticks()/1000)))
    screen.blit(air_bar,(8,8))
    screen.blit(red_bar,(10,10))
    for i in range(time_remaining):
        screen.blit(green_bar2,(10+(i*2),10))

    screen.blit(spray_bar,(570,8))
    screen.blit(red_bar,(572,10))
    for i in range(sprays):
        screen.blit(green_bar4,(572+(i*4),10))

    if clean_up == 0:
        screen.blit(win_screen,(0,0))
        main_loop = 0
    if life == False or sprays == 0 or time_remaining == 0:
        screen.blit(lose_screen,(0,0))
        main_loop = 0

    pygame.display.flip()

    for event in pygame.event.get():
        if event.type==pygame.QUIT:
            pygame.quit()
            exit(0)
        #Event checkers - Check to see if certain keys are pressed
        if event.type == pygame.KEYDOWN:
            if event.key==K_LEFT:
                keys[0]=True
            elif event.key==K_RIGHT:
                keys[1]=True
            elif event.key==K_UP:
                keys[2]=True
            elif event.key==K_DOWN:
                keys[3]=True
            elif event.key==K_SPACE:
                keys[4]=True
        #Check to see when certain keys are released
        if event.type == pygame.KEYUP:
            if event.key==K_LEFT:
                keys[0]=False
            elif event.key==K_RIGHT:
                keys[1]=False
            elif event.key==K_UP:
                keys[2]=False
            elif event.key==K_DOWN:
                keys[3]=False
            elif event.key==K_SPACE:
                keys[4]=False
                sprays -= 1

end = 1
while end:
    #Exit function
    for event in pygame.event.get():
        if event.type==pygame.QUIT:
            pygame.quit()
            exit(0)

Any help? Thanks in advance.

Update - I was running the game through terminal instead of Idle. I still get an error but it is a little bit different. Anyone know how to fix this?

Traceback (most recent call last):
  File "/Users/Jordanxxi/Desktop/Game/ocean_cleaner.py", line 29, in <module>
    hit = pygame.mixer.Sound("resources/audio/pop.wav")
error: mixer system not initialized

Body:
I believe you have to do:

pygame.mixer.init()

Check the documentation for mixer (this is always a good idea to do first when you have a problem!): http://www.pygame.org/docs/ref/mixer.html


问:
not able to download vcard on iphone Chrome
I am having some trouble downloading vcard on iphone chrome.
I making an API call from the href which returns a .vcf file to download the vcard, it is working fine on desktop (IE/Chorme/Firefox..) and working fine on iphone safari and samsung chrome,
but when i tried to download on a chrom iphone it is throwing an exception as shown in the image

Using

API bound to href is something like GET: http://.../rest/v1/profiles/00d5a2fb-ab56-a555-a5d5-0050569257ef/vcard

code to return the vcards .vcf file is something like

var vCard = BuildVCard(profile, profileUrl);
vCard returns a Vcard

return new FileActionResult(
                new StringContent(vCard.ToString()),
                "text/vcard",
                CreateVCardFileName(profile));

and CreateVCardFileName returns a string.Format("{0}.vcf", fileName);

the entities on fiddler headers shows something like
Content-Disposition: attachment; filename=Uma.vcf
Content-Type: text/vcard

Is this something related to IOS- Chrome thing, do I need to add anything to download the vcard like any specific mime-types.

Appreciate your help and time.

答:
I tried using this on a site. Routing to a "Please open in safari" page did work. Getting the .vcf file to download on chrome mobile by linking to the .vcf file like in the demo did not, it only brought me to a blank external page or gave me a fail like yours above.

When I put the exact live demo on my server the download to ANY phone button still did not work as the original live demo. It is my opinion that the different PHP versions the sites a running on are causing this but I could be very wrong.

How to add a contact to the iPhone's Address Book from a Web Page?


问:
how to load old config.inc.php into setup
Recently I updated from phpmyadmin 4.5.3.1 to 4.7.2 on my LAMP server. In previous versions we could copy the config.inc.php file to the config directory and load it into setup to make changes. With 4.7.2 there is a new restriction that the config.inc.php file may not exist in the phpmyadmin root directory while running setup.

The docs on https://docs.phpmyadmin.net/en/latest/setup.html#setup "Using setup script" do not mention a "config directory" at all. I tried copying the config.inc.php file into a config dir with proper permissions, setup does not seem to recognize it. It seems that setup is now only usable from a blank configuration, so every parameter has to be manually entered from a previous configuration every time you want to use setup to build a config file or even make a single change.

So, how do you load previous configuration settings into setup?

答:
Unfortunately, this functionality was removed starting with version 4.6.6.

You can mostly just copy the config.inc.php over directly without needing to make any modifications (generally, new configuration directives are noted in the release notes). I know it's not the same as being able to edit it directly, but you shouldn't need to make too many modifications once your config.inc.php is established.

You could make a feature request asking for this to be brought back.


问:
How can I reinstall an MSI when a new build is released?
I already installed the setup in my PC. Then I made some changes in my code and built the MSI with new one. Now when I tried to install the application I am getting an error as "Another version of the product is already installed please remove the older one".

Instead of displaying this warning, I would like to re-install it. Is this possible?

答:
You are getting that message because your PackageCode has changed but your ProductCode hasn't.  To install the newer version you'll need to run msiexec /i foo.msi REINSTALL=ALL REINSTALLMODE=vomus.  Tools like InstallShield can generate a setup.exe to detect this state and handle it for you.

But I'd like to address a broader concern that I have.  You need to understand thoroughly Windows Installer Servicing Strategies. You need to choose what type of upgrades and patches you want to support and test it before you go into production.  Additionally you are playing with fire by installing on your own machine without the knowledge needed to mitigate the risks.  This is what virtual machine snapshots are for.


问:
How to take R.string value instead of hardcoded value, if it's a class field?
For instance I want to take this

```<code>public class SomeClass {
    public static final String GREET_STRING = "Hello!";
    //...
</code>```

and change it to something like:

```<code>public class SomeClass {
    public static final String GREET_STRING = getString(R.string.greet_string);
    //...
</code>```

Can this be done or do I need some kind of Context instantiation to get the resources for the string loading?

答:
There are two ways access the string inside the class which is not extending Activity or Fragment.

Pass Context or Activity to class constructor

```<code>public class SomeClass {
    private Context context;
    public SomeClass(Context context) {
        this.context = context;
    }
    public static final String GREET_STRING = context.getString(R.string.greet_string);
}
</code>```

The second way is if you don`t want to pass context to class. You need to create an instance of the Application and static function get instance.

```<code>public class App extends Application {
        private static App instance = null;
        @Override
        public void onCreate() {
            super.onCreate();
            instance = this;
        }
        public static App getInstance() {
            // Return the instance
            return instance;
        }
}

public class SomeClass {
        public static final String GREET_STRING = App.getInstance().getString(R.string.greet_string);
    }
</code>```

Body:
For instance I want to take this

public class SomeClass {
    public static final String GREET_STRING = "Hello!";
    //...

and change it to something like:

public class SomeClass {
    public static final String GREET_STRING = getString(R.string.greet_string);
    //...

Can this be done or do I need some kind of Context instantiation to get the resources for the string loading?

Body:
There are two ways access the string inside the class which is not extending Activity or Fragment.

Pass Context or Activity to class constructor

public class SomeClass {
    private Context context;
    public SomeClass(Context context) {
        this.context = context;
    }
    public static final String GREET_STRING = context.getString(R.string.greet_string);
}

The second way is if you don`t want to pass context to class. You need to create an instance of the Application and static function get instance.

public class App extends Application {
        private static App instance = null;
        @Override
        public void onCreate() {
            super.onCreate();
            instance = this;
        }
        public static App getInstance() {
            // Return the instance
            return instance;
        }
}

public class SomeClass {
        public static final String GREET_STRING = App.getInstance().getString(R.string.greet_string);
    }


问:
Firebase Admin SDK: NoSuchMethodError for setCredential()
My application uses the Firebase Admin SDK for Java (recently upgraded from the Firebase Server SDK). It has worked correctly while testing on the local environment, however after deploying it to Google App Engine from Eclipse, the logs are showing this error:

```<code>com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backend method
java.lang.NoSuchMethodError: com.google.firebase.FirebaseOptions$Builder.setCredential(Lcom/google/firebase/auth/FirebaseCredential;)Lcom/google/firebase/FirebaseOptions$Builder;
</code>```

Can anyone advise? I have checked pom.xml on the server and I can see that the firebase-admin SDK dependency was uploaded successfully:

```<code><dependency>
    <groupId>com.google.firebase</groupId>
    <artifactId>firebase-admin</artifactId>
    <version>5.2.0</version>
</dependency>
</code>```

答:
You may have to upgrade Firebase version to 4.1.0 or later. com.google.firebase.FirebaseOptions$Builder.setCredential() has been introduced since version 4.1.0.

```<code><dependency>
    <groupId>com.google.firebase</groupId>
    <artifactId>firebase-admin</artifactId>
    <version>4.1.0</version>
</dependency>
</code>```

Body:
My application uses the Firebase Admin SDK for Java (recently upgraded from the Firebase Server SDK). It has worked correctly while testing on the local environment, however after deploying it to Google App Engine from Eclipse, the logs are showing this error:

com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backend method
java.lang.NoSuchMethodError: com.google.firebase.FirebaseOptions$Builder.setCredential(Lcom/google/firebase/auth/FirebaseCredential;)Lcom/google/firebase/FirebaseOptions$Builder;

Can anyone advise? I have checked pom.xml on the server and I can see that the firebase-admin SDK dependency was uploaded successfully:

<dependency>
    <groupId>com.google.firebase</groupId>
    <artifactId>firebase-admin</artifactId>
    <version>5.2.0</version>
</dependency>

Body:
You may have to upgrade Firebase version to 4.1.0 or later. com.google.firebase.FirebaseOptions$Builder.setCredential() has been introduced since version 4.1.0.

<dependency>
    <groupId>com.google.firebase</groupId>
    <artifactId>firebase-admin</artifactId>
    <version>4.1.0</version>
</dependency>


问:
ionic2 background image not showing
I want set background image in pages of ionic2,

```<code>  <style type="text/css">
    ion-content {
      background: url(../../img/background.jpg) no-repeat center center fixed;
    }
  </style>
  <ion-content  padding>
      <h2>Welcome to Ionic!</h2>
  </ion-content>
</code>```

but it not showing in the device.
why?

答:
Add to your css for the ion-content:

```<code>  background-size: cover;
  background-color: transparent;
</code>```

Title: ionic2 background image not showing

Body:
I want set background image in pages of ionic2,

  <ion-content  padding>

Welcome to Ionic!

  </ion-content>

but it not showing in the device.
why?

Body:
Add to your css for the ion-content:

  background-size: cover;
  background-color: transparent;


问:
How to work with abstract type members in Scala
I'm running into issues with the following code (heavily simplified). Looks like the problem may be with the way I use abstract type members. I would appreciate someone pointing out and explaining what I'm doing wrong here. Compiler error at the bottom.
I'm using Scala version 2.12.

```<code>trait DataType {
    type A

    def convert(value: String): A
    def convertToString(value: A): String
}

case object IntType extends DataType {
    type A = Int

    def convert(value: String): A = value.toInt
    def convertToString(value: A): String = value.toString
}

trait Codec[T <: DataType] {
    val dtype: T

    def encode(data: Array[String]): Array[T#A]
    def decode(data: Array[T#A]): Array[String]
}

class CodecImp[T <: DataType](val dtype: T)(implicit tag: ClassTag[T#A]) extends Codec[T] {
    def encode(data: Array[String]): Array[T#A] = {
        Array[T#A](dtype.convert(data(0)))
    }

    def decode(data: Array[T#A]): Array[String] = {
        Array[String](dtype.convertToString(data(0)))
    }
}

val cod = new CodecImp(IntType)
val encoded = cod.encode(Array("1", "2", "3")) // expecting: Array[IntType.A]
val decoded = cod.decode(encoded) // expecting: Array[String]
</code>```

Compiler error.

```<code>Error:(30, 50) type mismatch;
 found   : T#A
 required: CodecImp.this.dtype.A
        Array[String](dtype.convertToString(data(0)))
                 ^
</code>```

答:
This is caused by dtype.convertToString(data(0)) this method is wanting a variable with type: dtype#A, this type is decided by the variable dtype, but data type is Array[T#A], so this caused type mismatch, it's can't resolve in Scala, Since we can't state our method, like: def decode(data: Array[dType.A])... that's compiler expected.

And You can solve this by generics type agains type alias, like:

```<code>trait DataType[T] {
  def convert(value: String): T
  def convertToString(value: T): String
}

case object IntType extends DataType[Int] {

  def convert(value: String): Int = value.toInt
  def convertToString(value: Int): String = value.toString
}

class CodecImp[B](val dtype: DataType[B])(implicit tag: ClassTag[B]) {
  def encode(data: Array[String]): Array[B] = {
    Array[B](dtype.convert(data(0)))
  }

  def decode(data: Array[B]): Array[String] = {
    Array[String](dtype.convertToString(data(0)))
  }
}
</code>```

Body:
I'm running into issues with the following code (heavily simplified). Looks like the problem may be with the way I use abstract type members. I would appreciate someone pointing out and explaining what I'm doing wrong here. Compiler error at the bottom.
I'm using Scala version 2.12.

trait DataType {
    type A

    def convert(value: String): A
    def convertToString(value: A): String
}

case object IntType extends DataType {
    type A = Int

    def convert(value: String): A = value.toInt
    def convertToString(value: A): String = value.toString
}

trait Codec[T <: DataType] {
    val dtype: T

    def encode(data: Array[String]): Array[T#A]
    def decode(data: Array[T#A]): Array[String]
}

class CodecImp[T <: DataType](val dtype: T)(implicit tag: ClassTag[T#A]) extends Codec[T] {
    def encode(data: Array[String]): Array[T#A] = {
        Array[T#A](dtype.convert(data(0)))
    }

    def decode(data: Array[T#A]): Array[String] = {
        Array[String](dtype.convertToString(data(0)))
    }
}

val cod = new CodecImp(IntType)
val encoded = cod.encode(Array("1", "2", "3")) // expecting: Array[IntType.A]
val decoded = cod.decode(encoded) // expecting: Array[String]

Compiler error.

Error:(30, 50) type mismatch;
 found   : T#A
 required: CodecImp.this.dtype.A
        Array[String](dtype.convertToString(data(0)))
                 ^

Body:
This is caused by dtype.convertToString(data(0)) this method is wanting a variable with type: dtype#A, this type is decided by the variable dtype, but data type is Array[T#A], so this caused type mismatch, it's can't resolve in Scala, Since we can't state our method, like: def decode(data: Array[dType.A])... that's compiler expected.

And You can solve this by generics type agains type alias, like:

trait DataType[T] {
  def convert(value: String): T
  def convertToString(value: T): String
}

case object IntType extends DataType[Int] {

  def convert(value: String): Int = value.toInt
  def convertToString(value: Int): String = value.toString
}

class CodecImp[B](val dtype: DataType[B])(implicit tag: ClassTag[B]) {
  def encode(data: Array[String]): Array[B] = {
    Array[B](dtype.convert(data(0)))
  }

  def decode(data: Array[B]): Array[String] = {
    Array[String](dtype.convertToString(data(0)))
  }
}


问:
Unable to change camera position when using VRControls
I have the following code:

```<code>...
camera = new THREE.PerspectiveCamera(75, screenRatio, 1, 10000 );
camera.position.z = -10; // position.set(0, 0, -10) also not working.
controls = new THREE.VRControls( camera );
effect = new THREE.VREffect( renderer );
effect.setSize( window.innerWidth, window.innerHeight );
...
</code>```

VRControls are working in sync with the accelerometer, but I can't change the cameras position. It seems stuck in the origin point (0,0,0). It was working just fine before applying VRControls and VREffect.

答: I think the camera is now the object. You can try object.position.set() instead.

Body:
I have the following code:

...
camera = new THREE.PerspectiveCamera(75, screenRatio, 1, 10000 );
camera.position.z = -10; // position.set(0, 0, -10) also not working.
controls = new THREE.VRControls( camera );
effect = new THREE.VREffect( renderer );
effect.setSize( window.innerWidth, window.innerHeight );
...

VRControls are working in sync with the accelerometer, but I can't change the cameras position. It seems stuck in the origin point (0,0,0). It was working just fine before applying VRControls and VREffect.


问:
table view is not loading data
I am running the following code, and have a UITableView nested within a UIViewController.  The code should be using a nib to populate the rows, but for some reason nothing shows up when the UITableView loads.  Below is the following class associated with the UIViewController that has an embedded tableview.  Does anyone know why this may not be loading?

Code I have tried:

```<code>import UIKit
import Firebase

class Today: UIViewController, UITableViewDelegate, UITableViewDataSource  {

    var anArray: [String] = ["a", "b", "c"]

    @IBOutlet weak var myTableView: UITableView!
    override func viewDidLoad() {

        let nib = UINib.init(nibName: "ScheduleCellTableViewCell", bundle: nil)

        self.myTableView.registerNib(nib, forCellReuseIdentifier: "cell")

        self.myTableView.reloadData() //<<<<<<<<<<<<< RELOADS TABLEVIEW

    }//viewDidLoad() ends here

    public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        //return the count of the number of groups
        return anArray.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! ScheduleCellTableViewCell

        let val = indexPath.row

        cell.testLabel.text = anArray[val]

        return cell
    }

    public func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return 160.0
    }
}
</code>```

答:
The issue could be in ScheduleCellTableViewCell, you have not set the CellIdentifier to be "cell".

Btw, I don't think self.myTableView.reloadData() is needed in viewDidLoad().

Title: table view is not loading data

Body:
I am running the following code, and have a UITableView nested within a UIViewController.  The code should be using a nib to populate the rows, but for some reason nothing shows up when the UITableView loads.  Below is the following class associated with the UIViewController that has an embedded tableview.  Does anyone know why this may not be loading?

Code I have tried:

import UIKit
import Firebase

class Today: UIViewController, UITableViewDelegate, UITableViewDataSource  {

    var anArray: [String] = ["a", "b", "c"]

    @IBOutlet weak var myTableView: UITableView!
    override func viewDidLoad() {

        let nib = UINib.init(nibName: "ScheduleCellTableViewCell", bundle: nil)

        self.myTableView.registerNib(nib, forCellReuseIdentifier: "cell")

        self.myTableView.reloadData() //<<<<<<<<<<<<< RELOADS TABLEVIEW

    }//viewDidLoad() ends here

    public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        //return the count of the number of groups
        return anArray.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! ScheduleCellTableViewCell

        let val = indexPath.row

        cell.testLabel.text = anArray[val]

        return cell
    }

    public func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return 160.0
    }
}


问:
Very basic objective-c question-how do I make different views share information?
So, basically, I have four different views that are switched via a tab bar at the bottom of the screen. I have a view controller set up for each one, and they all work fine. The only problem is that I have no idea how to share information between the different views-for example, I have an IBAction on one that takes the output of a UISegmentedControl and stores the selection as an integer (1,2,3,4). The problem is, I don't know how to access that integer from the first view controller (the one that actually does stuff with that information). I'm sure this is a very basic problem but my google-fu doesn't seem to be working here. Thanks!</p>

答:
You could have your views expose their variables to the UITabBarController. The UITabBarController can have methods that these views can call to see these variables.

Or, you could have your views directly set the values of variables in the UITabBarController. Not recommended (though a lot less typing :)

Just did a quick search on Google, btw, and came across this: Accessing parent view controller (custom) properties. Looks like there's sample code to be had there. :)

Hope this helps!


问:
How to download all files from a specific Sourceforge project?
After spending about an hour downloading almost every Msys package from sourceforge I'm wondering whether there is a more clever way to do this. Is it possible to use wget for this purpose?   </p>

答:
I've used this script successfully:

https://github.com/SpiritQuaddicted/sourceforge-file-download

For your use run:

```<code>sourceforge-file-downloader.sh msys
</code>```

It should download all the pages first then find the actual links in the pages and download the final files.

From the project description:

Allows you to download all of a sourceforge project's files. Downloads to the current directory into a directory named like the project. Pass the project's name as first argument, eg ./sourceforge-file-download.sh inkscape to download all of http://sourceforge.net/projects/inkscape/files/

Just in case the repo ever gets removed I'll post it here since it's short enough:

```<code>#!/bin/sh

project=$1
echo "Downloading $project's files"

# download all the pages on which direct download links are
# be nice, sleep a second
wget -w 1 -np -m -A download http://sourceforge.net/projects/$project/files/

# extract those links
grep -Rh direct-download sourceforge.net/ | grep -Eo '".*" ' | sed 's/"//g' > urllist

# remove temporary files, unless you want to keep them for some reason
rm -r sourceforge.net/

# download each of the extracted URLs, put into $projectname/
while read url; do wget --content-disposition -x -nH --cut-dirs=1 "${url}"; done < urllist

rm urllist
</code>```

Body:
I've used this script successfully:

https://github.com/SpiritQuaddicted/sourceforge-file-download

For your use run:

sourceforge-file-downloader.sh msys

It should download all the pages first then find the actual links in the pages and download the final files.

From the project description:

Allows you to download all of a sourceforge project's files. Downloads to the current directory into a directory named like the project. Pass the project's name as first argument, eg ./sourceforge-file-download.sh inkscape to download all of http://sourceforge.net/projects/inkscape/files/

Just in case the repo ever gets removed I'll post it here since it's short enough:

#!/bin/sh

project=$1
echo "Downloading $project's files"

# download all the pages on which direct download links are
# be nice, sleep a second
wget -w 1 -np -m -A download http://sourceforge.net/projects/$project/files/

# extract those links
grep -Rh direct-download sourceforge.net/ | grep -Eo '".*" ' | sed 's/"//g' > urllist

# remove temporary files, unless you want to keep them for some reason
rm -r sourceforge.net/

# download each of the extracted URLs, put into $projectname/
while read url; do wget --content-disposition -x -nH --cut-dirs=1 "${url}"; done < urllist

rm urllist


答:
Make sure your UITableview delegate and datasource assign properly from storyboard if not then assign them into your viewDidLoad function

```<code>override func viewDidLoad() {

        let nib = UINib.init(nibName: "ScheduleCellTableViewCell", bundle: nil)

        self.myTableView.registerNib(nib, forCellReuseIdentifier: "cell")
        self.myTableView.delegate = self
        self.myTableView.dataSource = self
        self.myTableView.reloadData() // <<<<<< RELOADS TABLEVIEW

    }
</code>```

Title: table view is not loading data

Body:
Make sure your UITableview delegate and datasource assign properly from storyboard if not then assign them into your viewDidLoad function

override func viewDidLoad() {

        let nib = UINib.init(nibName: "ScheduleCellTableViewCell", bundle: nil)

        self.myTableView.registerNib(nib, forCellReuseIdentifier: "cell")
        self.myTableView.delegate = self
        self.myTableView.dataSource = self
        self.myTableView.reloadData() // <<<<<< RELOADS TABLEVIEW

    }


问:
matlab tall arrays with for loop inplementation
I'm working with binary data in large files (30GB+).
I have implemented fileDatastore with a custom read function.

```<code>fds = fileDatastore(location,'ReadFcn',@readFile);
</code>```

The readFile function reads in the binary data into an array a byte at a time.
I then create a tall array from the fileDatastore.

```<code>data = tall(fds);
</code>```

This all seems to be working fine. Now I would like to search through the tall array for a byte pattern (ex. 25 followed by 30).  Something like...

```<code>for i=1:size(data)
    if data(i) == 25 && data(i+1) == 30
        disp('do something')
    end
end
</code>```

This does not seem to be possible.  I end up with a 'conversion to logical from tall is not possible' error.  How can I solve this problem?

答:
The issue is that you cannot use tall logicals as conditions in loop statements. This is why the error is "Conversion to logical from tall is not possible." So since data(i) == 25 returns a tall logical, you just need to use gather to turn that into an in-memory logical. Try this instead (since it's probably more efficient to gather these at the same time):

```<code>[a,b] = gather(data(i)==25,data(i+1)==30);
if a && b
    disp('do something')
end
</code>```

Source:
  http://www.mathworks.com/help/matlab/import_export/deferred-evaluation-of-tall-arrays.html

"For example, you cannot control if or while loop statements using a tall logical array, but once the array is evaluated with gather it
  becomes an in-memory logical value that you can use in these
  contexts."

Body:
I'm working with binary data in large files (30GB+).
I have implemented fileDatastore with a custom read function.

fds = fileDatastore(location,'ReadFcn',@readFile);

The readFile function reads in the binary data into an array a byte at a time.
I then create a tall array from the fileDatastore.

data = tall(fds);

This all seems to be working fine. Now I would like to search through the tall array for a byte pattern (ex. 25 followed by 30).  Something like...

for i=1:size(data)
    if data(i) == 25 && data(i+1) == 30
        disp('do something')
    end
end

This does not seem to be possible.  I end up with a 'conversion to logical from tall is not possible' error.  How can I solve this problem?

Body:
The issue is that you cannot use tall logicals as conditions in loop statements. This is why the error is "Conversion to logical from tall is not possible." So since data(i) == 25 returns a tall logical, you just need to use gather to turn that into an in-memory logical. Try this instead (since it's probably more efficient to gather these at the same time):

[a,b] = gather(data(i)==25,data(i+1)==30);
if a && b
    disp('do something')
end

Source:
  http://www.mathworks.com/help/matlab/import_export/deferred-evaluation-of-tall-arrays.html

"For example, you cannot control if or while loop statements using a tall logical array, but once the array is evaluated with gather it
  becomes an in-memory logical value that you can use in these
  contexts."


问:
how to compile Java for Spark?
I would like to compile Java file to jar. I want it to be runnable by Spark. I did try to compile normally but it have an error like this.

```<code>java.lang.NoClassDefFoundError: JavaWordCount (wrong name: org/apache/spark/examples/JavaWordCount)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.spark.util.Utils$.classForName(Utils.scala:229)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:700)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
</code>```

This is how I compile Java.

```<code>javac -classpath spark-sql_2.11-2.1.1.jar:spark-core_2.11-2.1.1.jar:scala-compiler-2.11.8.jar:scala-library-2.11.8.jar JavaWordCount.java
</code>```

And this is how I make jar file

```<code>jar cvf JavaWordCount.jar JavaWordCount*.class
</code>```

However doing like this came up with an error above when I tried to spark-submit.

```<code>spark-submit --class JavaWordCount JavaWordCount.jar README.md
</code>```

I also did try to change class into org.apache.spark.examples.JavaWordCount but it's still give me the same error.

Where did I go wrong? Any suggestion?
PS I use an example JavaWordCount in Spark folder.

答: I solved the problem only need to javac with all spark jar files(only the one that needed) and when use jar cvf with spark jar files again which I didn't do it when I posted the question.

Title: how to compile Java for Spark?

Body:
I would like to compile Java file to jar. I want it to be runnable by Spark. I did try to compile normally but it have an error like this.

java.lang.NoClassDefFoundError: JavaWordCount (wrong name: org/apache/spark/examples/JavaWordCount)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.spark.util.Utils$.classForName(Utils.scala:229)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:700)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

This is how I compile Java.

javac -classpath spark-sql_2.11-2.1.1.jar:spark-core_2.11-2.1.1.jar:scala-compiler-2.11.8.jar:scala-library-2.11.8.jar JavaWordCount.java

And this is how I make jar file

jar cvf JavaWordCount.jar JavaWordCount*.class

However doing like this came up with an error above when I tried to spark-submit.

spark-submit --class JavaWordCount JavaWordCount.jar README.md

I also did try to change class into org.apache.spark.examples.JavaWordCount but it's still give me the same error.

Where did I go wrong? Any suggestion?
PS I use an example JavaWordCount in Spark folder.


问:
fatal error: Could not create a path to the bundle
I've been trying to make a CocoaPod that includes a .xib for two full days, to no avail. I have a standalone Xcode project for my framework with the following .podspec:

```<code>Pod::Spec.new do |s|
  s.name         = "OrderStatusTable"
  s.version      = "1.2.0"
  s.platform = :ios
  s.ios.deployment_target = '9.0'
  s.summary      = "Order Status UITableView framework."
  s.description  = "A UITableView framework with custom view."
  s.homepage     = "https://github.com/myname/OrderStatusTableView"
  s.license = { :type => "MIT", :file => "LICENSE" }
  s.author = { "My Name" => "My Email" }
  s.platform     = :ios, "9.0"
  s.source       = { :git => "https://github.com/myname/OrderStatusTableView.git", :tag => "1.2.0" }

  s.source_files = "OrderStatusTable/**/*.{h,m,swift}"

  s.resource_bundles = {
    'OrderStatusTable' => [
        'Pod/**/*.xib'
    ]
  }

end
</code>```

In my sample project, I'm adding pod 'OrderStatusTable', :git => 'https://github.com/myname/OrderStatusTableView.git', :tag => ‘1.2.0’ to my Podfile. My .xib file is included in a Resources folder within the pod in the example project, but I keep getting this error: fatal error: Could not create a path to the bundle: file /Users/myname/Desktop/appname/OrderStatusTableDemo/Pods/OrderStatusTable/OrderStatusTable/OrderStatusTable.swift, line 40

It's a UITableView framework and I'm trying to register a custom UITableViewCell nib with a cell reuse identifier, like this:

```<code>    public class OrderStatusTable: UITableView {

    public override func awakeFromNib() {

        delegate = self
        dataSource = self

        let podBundle = NSBundle(forClass: self.classForCoder)

        if let bundleURL = podBundle.URLForResource("OrderStatusTable", withExtension: "bundle") {

            if let bundle = NSBundle(URL: bundleURL) {

                let cellNib = UINib(nibName: "OrderStatusTableViewCell", bundle: bundle)

                registerNib(cellNib, forCellReuseIdentifier: "OrderStatusTableViewCell")

            } else {

                assertionFailure("Could not load the bundle")

            }

        } else {

            assertionFailure("Could not create a path to the bundle")
            // This keeps getting called
        }
}
</code>```

So I'm not sure if I have the wrong bundle URLForResource or what? This isn't very well documented online. Can someone please advise? Thanks!

答:
In here you need to add this into your pod spec.

```<code> s.resources = "YourProjectName/*.xib"
 s.resource_bundles = {
   'YourProjectName' => [
       'Pod/**/*.xib'
   ]
 }
</code>```

For this particular question,

```<code>s.resources = "OrderStatusTable/*.xib"
 s.resource_bundles = {
   'OrderStatusTable' => [
       'Pod/**/*.xib'
   ]
 }
</code>```

Then there is an error in your code.

Don't use

```<code> let podBundle = Bundle(for: self.classForCoder)
</code>```

Instead of this one use like this:-

```<code>let podBundle = Bundle(for:YourClassName.self)
</code>```

For this question, it should be

```<code> let podBundle = Bundle(OrderStatusTable.self)
</code>```

Body:
I've been trying to make a CocoaPod that includes a .xib for two full days, to no avail. I have a standalone Xcode project for my framework with the following .podspec:

Pod::Spec.new do |s|
  s.name         = "OrderStatusTable"
  s.version      = "1.2.0"
  s.platform = :ios
  s.ios.deployment_target = '9.0'
  s.summary      = "Order Status UITableView framework."
  s.description  = "A UITableView framework with custom view."
  s.homepage     = "https://github.com/myname/OrderStatusTableView"
  s.license = { :type => "MIT", :file => "LICENSE" }
  s.author = { "My Name" => "My Email" }
  s.platform     = :ios, "9.0"
  s.source       = { :git => "https://github.com/myname/OrderStatusTableView.git", :tag => "1.2.0" }

  s.source_files = "OrderStatusTable/**/*.{h,m,swift}"

  s.resource_bundles = {
    'OrderStatusTable' => [
        'Pod/**/*.xib'
    ]
  }

end

In my sample project, I'm adding pod 'OrderStatusTable', :git => 'https://github.com/myname/OrderStatusTableView.git', :tag => ‘1.2.0’ to my Podfile. My .xib file is included in a Resources folder within the pod in the example project, but I keep getting this error: fatal error: Could not create a path to the bundle: file /Users/myname/Desktop/appname/OrderStatusTableDemo/Pods/OrderStatusTable/OrderStatusTable/OrderStatusTable.swift, line 40

It's a UITableView framework and I'm trying to register a custom UITableViewCell nib with a cell reuse identifier, like this:

    public class OrderStatusTable: UITableView {

    public override func awakeFromNib() {

        delegate = self
        dataSource = self

        let podBundle = NSBundle(forClass: self.classForCoder)

        if let bundleURL = podBundle.URLForResource("OrderStatusTable", withExtension: "bundle") {

            if let bundle = NSBundle(URL: bundleURL) {

                let cellNib = UINib(nibName: "OrderStatusTableViewCell", bundle: bundle)

                registerNib(cellNib, forCellReuseIdentifier: "OrderStatusTableViewCell")

            } else {

                assertionFailure("Could not load the bundle")

            }

        } else {

            assertionFailure("Could not create a path to the bundle")
            // This keeps getting called
        }
}

So I'm not sure if I have the wrong bundle URLForResource or what? This isn't very well documented online. Can someone please advise? Thanks!

Body:
In here you need to add this into your pod spec.

 s.resources = "YourProjectName/*.xib"
 s.resource_bundles = {
   'YourProjectName' => [
       'Pod/**/*.xib'
   ]
 }

For this particular question,

s.resources = "OrderStatusTable/*.xib"
 s.resource_bundles = {
   'OrderStatusTable' => [
       'Pod/**/*.xib'
   ]
 }

Then there is an error in your code.

Don't use

 let podBundle = Bundle(for: self.classForCoder)

Instead of this one use like this:-

let podBundle = Bundle(for:YourClassName.self)

For this question, it should be

 let podBundle = Bundle(OrderStatusTable.self)


问:
checking for an array in an multidimensional array (pref-jQuery)
I've got a multi-dimensional array, and I'm trying to check if it holds another array.
I'm using jQuery.inArray function at the moment (I was trying Array.prototype but kept getting errors, never used that before).

I am trying to ensure that my parent array doesn't add the same child array twice

```
if(jQuery.inArray(new Array(step[0],step[1],r2),unavailArray)==-1){
    alert(jQuery.inArray(new Array(step[0],step[1],r2),unavailArray));

    unavailArray.push(new Array(step[0],step[1],r2));
  }

```

I've also tried

```
jQuery.inArray("[step[0],step[1],r2]",unavailArray)==-1
```

and

```
jQuery.inArray([step[0],step[1],r2],unavailArray)==-1
```

they all return -1, and when I look at the array, I have

```
[[630,690,09],[3180,3220,2],[3180,3220,2]]
```

so clearly something isn't working.

答:
I believe you're issue is that you keep adding new Array() for the arrays instead of giving them a variable name to point back to, hence they're never really the same even though they may have the same exact content as each other.

For this to work as you wish you need to assign new Array([step[0],step[1],r2]) to a variable and check that variable instead of new Array()

```<code>var blah = new Array(step[0],step[1],r2);

// this will add the array to unavailArray
if(jQuery.inArray(blah,unavailArray)==-1){
    alert(jQuery.inArray(blah,unavailArray));

    unavailArray.push(blah);
  }else{
    alert('found so was not added');
}

// Try again and it wont, instead firing off the alert message
if(jQuery.inArray(blah,unavailArray)==-1){
    alert(jQuery.inArray(blah,unavailArray));

    unavailArray.push(blah);
  }else{
    alert('found so was not added');
}
</code>```

Here is a link to a JSFiddle I made to illustrate this: Live Example

Body:
I've got a multi-dimensional array, and I'm trying to check if it holds another array.
I'm using jQuery.inArray function at the moment (I was trying Array.prototype but kept getting errors, never used that before).

I am trying to ensure that my parent array doesn't add the same child array twice

if(jQuery.inArray(new Array(step[0],step[1],r2),unavailArray)==-1){
    alert(jQuery.inArray(new Array(step[0],step[1],r2),unavailArray));

    unavailArray.push(new Array(step[0],step[1],r2));
  }

I've also tried

jQuery.inArray("[step[0],step[1],r2]",unavailArray)==-1

and

jQuery.inArray([step[0],step[1],r2],unavailArray)==-1

they all return -1, and when I look at the array, I have

[[630,690,09],[3180,3220,2],[3180,3220,2]]

so clearly something isn't working.

Body:
I believe you're issue is that you keep adding new Array() for the arrays instead of giving them a variable name to point back to, hence they're never really the same even though they may have the same exact content as each other.

For this to work as you wish you need to assign new Array([step[0],step[1],r2]) to a variable and check that variable instead of new Array()

var blah = new Array(step[0],step[1],r2);

// this will add the array to unavailArray
if(jQuery.inArray(blah,unavailArray)==-1){
    alert(jQuery.inArray(blah,unavailArray));

    unavailArray.push(blah);
  }else{
    alert('found so was not added');
}

// Try again and it wont, instead firing off the alert message
if(jQuery.inArray(blah,unavailArray)==-1){
    alert(jQuery.inArray(blah,unavailArray));

    unavailArray.push(blah);
  }else{
    alert('found so was not added');
}

Here is a link to a JSFiddle I made to illustrate this: Live Example


问:
Deploy TestAgent fails with unhandled exception
The Deploy test agent task in TFS release definition fails with the below exception:

Unhandled Exception:
  System.Management.Automation.PSInvalidOperationException: The
  WriteObject and WriteError methods cannot be called from outside the
  overrides of the BeginProcessing, ProcessRecord, and EndProcessing
  methods, and they can only be called from within the same thread.
  Validate that the cmdlet makes these calls correctly, or contact
  Microsoft Customer Support Services. 2017-06-16T08:49:49.9634068Z

  at
  System.Management.Automation.MshCommandRuntime.ThrowIfWriteNotPermitted(Boolean
  needsToWriteToPipeline) 2017-06-16T08:49:49.9634068Z    at
  System.Management.Automation.MshCommandRuntime.WriteHelper_ShouldWrite(ActionPreference
  preference, ContinueStatus lastContinueStatus)
  2017-06-16T08:49:49.9634068Z    at
  System.Management.Automation.MshCommandRuntime.WriteWarning(WarningRecord
  record, Boolean overrideInquire) 2017-06-16T08:49:49.9634068Z    at
  System.Management.Automation.Cmdlet.WriteWarning(String text)
  2017-06-16T08:49:49.9634068Z    at
  Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.Logger.WriteWarning(String
  message) 2017-06-16T08:49:49.9634068Z    at
  Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.TestAgentDownloader.wc_DownloadFileCompleted(Object
  sender, AsyncCompletedEventArgs e) 2017-06-16T08:49:49.9634068Z    at
  System.Net.WebClient.OnDownloadFileCompleted(AsyncCompletedEventArgs
  e) 2017-06-16T08:49:49.9634068Z    at
  System.Threading.ExecutionContext.RunInternal(ExecutionContext
  executionContext, ContextCallback callback, Object state, Boolean
  preserveSyncCtx) 2017-06-16T08:49:49.9634068Z    at
  System.Threading.ExecutionContext.Run(ExecutionContext
  executionContext, ContextCallback callback, Object state, Boolean
  preserveSyncCtx) 2017-06-16T08:49:49.9634068Z    at
  System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
  2017-06-16T08:49:49.9634068Z    at
  System.Threading.ThreadPoolWorkQueue.Dispatch()
  2017-06-16T08:49:55.4477257Z ##[error]PowerShell script completed with
  255 errors.

The task executes successfully if the Update test agent check box is not checked.
 Solution mentioned here https://github.com/Microsoft/vsts-tasks/issues/2964 and https://social.msdn.microsoft.com/Forums/sqlserver/en-US/dae4c62d-cd23-40ad-83cf-2555d37c0bb9/test-agent-deployment-failing?forum=tfsbuild does not seems to work either

答: The issue was resolved by downloading the testagent exe and copying the same to a share folder that has access to the build agents. This is configured under the advanced section and provide the share path under Test Agent Location.


问:
How to make ng-bind-html angularjs code
i have to pass html code by angullar js data

```<code> this.items = [
  {
    'title': 'Angular',
    'icon': 'angular',
    'description': " <ul><li>Coffee</li><li>Tea</li><li>Milk</li></ul>A powerful Javascript framework for building single page apps. Angular is open source, and maintained by Google.",
    'color': '#E63135'
  },
  {
    'title': 'CSS3',
    'icon': 'css3',
    'description': '<ul><li>Coffee</li><li>Tea</li><li>Milk</li></ul>  The latest version of cascading stylesheets - the styling language of the web!',
    'color': '#0CA9EA'
  },
  {
    'title': 'HTML5',
    'icon': 'html5',
    'description': 'The latest version of the web\'s markup language.',
    'color': '#F46529'
  },]
</code>```

bu in the view html

{{item.description}}

not working

ng-bind-html="item.description"

not working

答:
Use the filter with $sce.trustAsHtml

```<code> myApp.filter('trustHtml',function($sce){
  return function(html){
    return $sce.trustAsHtml(html)
  }
})
</code>```

DEMO

var myApp=angular.module('myApp',[]);
 myApp.controller('thecontroller',function(){

  this.items = [
  {
    'title': 'Angular',
    'icon': 'angular',
    'description': "

Coffee

Tea

Milk

A powerful Javascript framework for building single page apps. Angular is open source, and maintained by Google.",
    'color': '#E63135'
  },
  {
    'title': 'CSS3',
    'icon': 'css3',
    'description': '

Coffee

Tea

Milk

  The latest version of cascading stylesheets - the styling language of the web!',
    'color': '#0CA9EA'
  },
  {
    'title': 'HTML5',
    'icon': 'html5',
    'description': 'The latest version of the web\'s markup language.',
    'color': '#F46529'
  }];

});
 myApp.filter('trustHtml',function($sce){
  return function(html){
    return $sce.trustAsHtml(html)
  }
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
    <html>
        <head>
          <title>ng-Messages Service</title>
          <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>
            <script src='https://code.angularjs.org/1.5.0-rc.0/angular.min.js'></script>
        </head>
        <body ng-app="myApp">
            <div ng-controller='thecontroller as vm'>
                <div ng-repeat="item in vm.items ">
                 <div ng-bind-html="item.description |  trustHtml"></div>
                </div>
            </div>
        </body>
    </html></code>```

Title: How to make ng-bind-html angularjs code

Body:
i have to pass html code by angullar js data

 this.items = [
  {
    'title': 'Angular',
    'icon': 'angular',
    'description': "

Coffee

Tea

Milk

A powerful Javascript framework for building single page apps. Angular is open source, and maintained by Google.",
    'color': '#E63135'
  },
  {
    'title': 'CSS3',
    'icon': 'css3',
    'description': '

Coffee

Tea

Milk

  The latest version of cascading stylesheets - the styling language of the web!',
    'color': '#0CA9EA'
  },
  {
    'title': 'HTML5',
    'icon': 'html5',
    'description': 'The latest version of the web\'s markup language.',
    'color': '#F46529'
  },]

bu in the view html

{{item.description}}

not working

ng-bind-html="item.description"

not working

Body:
Use the filter with $sce.trustAsHtml

 myApp.filter('trustHtml',function($sce){
  return function(html){
    return $sce.trustAsHtml(html)
  }
})

DEMO

var myApp=angular.module('myApp',[]);
 myApp.controller('thecontroller',function(){

  this.items = [
  {
    'title': 'Angular',
    'icon': 'angular',
    'description': " <ul><li>Coffee</li><li>Tea</li><li>Milk</li></ul>A powerful Javascript framework for building single page apps. Angular is open source, and maintained by Google.",
    'color': '#E63135'
  },
  {
    'title': 'CSS3',
    'icon': 'css3',
    'description': '<ul><li>Coffee</li><li>Tea</li><li>Milk</li></ul>  The latest version of cascading stylesheets - the styling language of the web!',
    'color': '#0CA9EA'
  },
  {
    'title': 'HTML5',
    'icon': 'html5',
    'description': 'The latest version of the web\'s markup language.',
    'color': '#F46529'
  }];

});
 myApp.filter('trustHtml',function($sce){
  return function(html){
    return $sce.trustAsHtml(html)
  }
})

<!DOCTYPE html>
    <html>
        <head>
          <title>ng-Messages Service</title>
          <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>
            <script src='https://code.angularjs.org/1.5.0-rc.0/angular.min.js'></script>
        </head>
        <body ng-app="myApp">
            <div ng-controller='thecontroller as vm'>
                <div ng-repeat="item in vm.items ">
                 <div ng-bind-html="item.description |  trustHtml"></div>
                </div>
            </div>
        </body>
    </html>


问:
How can I retrieve rows in a text file
I started programing in language C, and I have some problems with reading text files. Let me explain.

I have one file text which is organized like this :

```<code>Tony
12.23
John
09.45
Tayris
03.99
</code>```

I would like to retrieve all notes less than ten and display them, but I can't...

Does anybody could help me?

Thanks a lot.

答:
Check out the fgets function. It will return until (and including) the end of string character (you can strip it from the destination string if you want).

http://people.cs.uchicago.edu/~iancooke/osstuff/ccc.html offers an example:

Here's a more complicated example.
  Readline() uses fgets() to read up to
  MAX_LINE - 1 characters into the
  buffer 'in'. It strips preceding
  whitespace and returns a pointer to
  the first non-whitespace character.

```<code> char *Readline(char *in) {
   char *cptr;

   if (cptr = fgets(in, MAX_LINE, stdin)) {
     /* kill preceding whitespace but leave \n
        so we're guaranteed to have something*/
     while(*cptr == ' ' || *cptr == '\t') {
       cptr++;
     }
     return cptr;
    } else {
     return 0;
   }
 }
</code>```

That should be enough I think.

Title: How can I retrieve rows in a text file

Body:
I started programing in language C, and I have some problems with reading text files. Let me explain.

I have one file text which is organized like this :

Tony
12.23
John
09.45
Tayris
03.99

I would like to retrieve all notes less than ten and display them, but I can't...

Does anybody could help me?

Thanks a lot.

Body:
Check out the fgets function. It will return until (and including) the end of string character (you can strip it from the destination string if you want).

http://people.cs.uchicago.edu/~iancooke/osstuff/ccc.html offers an example:

Here's a more complicated example.
  Readline() uses fgets() to read up to
  MAX_LINE - 1 characters into the
  buffer 'in'. It strips preceding
  whitespace and returns a pointer to
  the first non-whitespace character.

 char *Readline(char *in) {
   char *cptr;

   if (cptr = fgets(in, MAX_LINE, stdin)) {
     /* kill preceding whitespace but leave \n
        so we're guaranteed to have something*/
     while(*cptr == ' ' || *cptr == '\t') {
       cptr++;
     }
     return cptr;
    } else {
     return 0;
   }
 }

That should be enough I think.


答:
"By default, the resulting HTML content will be sanitized using the $sanitize service. To utilize this functionality, ensure that $sanitize is available"
 In order to use ngSanitize in your module's dependencies, you need to include "angular-sanitize.js" in your application.

You may also bypass sanitization for values you know are safe. To do so, bind to an explicitly trusted value via $sce.trustAsHtml. See the example under Strict Contextual Escaping (SCE).

https://docs.angularjs.org/api/ng/directive/ngBindHtml

https://docs.angularjs.org/api/ng/service/$sce#show-me-an-example-using-sce-

Title: How to make ng-bind-html angularjs code


问:
Advanced search with "urn:schemas:httpmail:datereceived" using OR and AND
I'm trying to do an advanced search in Outlook. I use python and win32com to do it.

My query ignores my date filter.

```<code>"urn:schemas:mailheader:subject" like '%draft%' OR
"urn:schemas:mailheader:subject" ci_phrasematch 'draft' OR
"urn:schemas:httpmail:textdescription" like '%draft%' OR
"urn:schemas:httpmail:textdescription" ci_phrasematch 'draft' AND
"urn:schemas:httpmail:datereceived"  > '01.06.2017 12:00 AM'
</code>```

答:
your query may be working exactly as instructed

i think that you may need to add brackets into your logic statement

your query checks the date only when

```<code>("urn:schemas:httpmail:textdescription" ci_phrasematch 'draft') = TRUE
</code>```

you most likely want this :

```<code>    (   ("urn:schemas:mailheader:subject"       like           '%draft%')
     OR ("urn:schemas:mailheader:subject"       ci_phrasematch 'draft'  )
     OR ("urn:schemas:httpmail:textdescription" like           '%draft%')
     OR ("urn:schemas:httpmail:textdescription" ci_phrasematch 'draft'  )
    )
AND ("urn:schemas:httpmail:datereceived"  > '01.06.2017 12:00 AM')
</code>```

Body:
I'm trying to do an advanced search in Outlook. I use python and win32com to do it.

My query ignores my date filter.

"urn:schemas:mailheader:subject" like '%draft%' OR
"urn:schemas:mailheader:subject" ci_phrasematch 'draft' OR
"urn:schemas:httpmail:textdescription" like '%draft%' OR
"urn:schemas:httpmail:textdescription" ci_phrasematch 'draft' AND
"urn:schemas:httpmail:datereceived"  > '01.06.2017 12:00 AM'

Body:
your query may be working exactly as instructed

i think that you may need to add brackets into your logic statement

your query checks the date only when

("urn:schemas:httpmail:textdescription" ci_phrasematch 'draft') = TRUE

you most likely want this :

    (   ("urn:schemas:mailheader:subject"       like           '%draft%')
     OR ("urn:schemas:mailheader:subject"       ci_phrasematch 'draft'  )
     OR ("urn:schemas:httpmail:textdescription" like           '%draft%')
     OR ("urn:schemas:httpmail:textdescription" ci_phrasematch 'draft'  )
    )
AND ("urn:schemas:httpmail:datereceived"  > '01.06.2017 12:00 AM')