问:
jQuery UI effects in Kynetx sidetab
I have successfully had a jQuery UI effect take place on a page using Kynetx's jQuery UI integration.

However, I am having trouble getting the effect to work from within a sidetab. Here are the rules for my application. I'm hoping someone can point out what I am missing:

```<code>global {
  css  <<
         #tester
         {
             margin-left: 10px;
             margin-top: 10px;
             width: 80px;
             height: 80px;
             background: green;
             position: relative;
         }
       >>;
 }

rule tab is active {
select when pageview ".*" setting ()

 pre {
        results = <<
           <div id='tester'></div>
            >>;
}
{
     sidetab() with pathToTabImage = "http://dl.dropbox.com/u/10762217/search-tab-images/tab2.png"
               and tabColor = "transparent"
               and topPos = "50px"
               and message = results
               and divCSS = {
                             "z-index": 10000,
                             "backgroundColor": "#ffffff",
                             "width": "200px",
                             "padding": "0px",
                             "imageHeight": "162px",
                             "imageWidth": "53px",
                             "-moz-border-radius": "5px"
                            };
              watch("#tester", "click");
           }

 }

 rule jeffect_on_click is active {
     select when web click "#tester"
        jquery_ui:effect("#tester","bounce","normal");

 }
}
</code>```

I made sure to include

```<code>use javascript resource jquery_ui_js
</code>```

in my meta tag.

答:
You aren't missing anything. Currently, the runtime, specifically the watch() action uses, .live() to register event handlers.  sidetab() eats all event handlers attached with .live(). sidetab() eats them because .live() actually works by attaching your click handler to the document object, and then watches for the event to bubble up. When it reaches the document, it checks to see if the event was registered from the element(s) matching your selector, if so, it fires your handler. sidetab() kills this by calling event.stopPropagation(), which stops the bubbling of the event, so it never reaches the document, so your handler will never fire.

You can fix this by registering your event handler with the jQuery utility function, .bind(). .bind() will only register the handler for elements that already exist, but as long as you take care that the elements inside of your sidetab exist before you call .bind(), you will be fine.

Something like this:

```<code>$K("#tester").bind("click", function() {
  $K(this).effect("bounce", { "times" : 3 }, 300);
});
</code>```

Let's put that in the context of an entire app, shall we?

To keep this example simple, we'll simply emit the javascript necessary to attach our handler and have the div bounce when clicked. This example is also available as a gist:

```<code>ruleset a369x111 {
    meta {
        name "Sidetab->Events"
            description <<
                Sidetab jQuery
            >>
            author "AKO"
            logging on

            use javascript resource jquery_ui_js

    }
    global {
        css  <<
            #tester {
                margin-left: 10px;
                margin-top: 10px;
                width: 80px;
                height: 80px;
                background: green;
                position: relative;
            }
        >>;
    }

    rule tab {
        select when pageview ".*"

            pre {
                results = <<
                    <div id="tester"></div>
                >>;
            }
        {
            sidetab() with pathToTabImage = "http://dl.dropbox.com/u/10762217/search-tab-images/tab2.png"
                and tabColor = "transparent"
                and topPos = "50px"
                and message = results
                and divCSS = {
                    "z-index": 10000,
                    "backgroundColor": "#ffffff",
                    "width": "200px",
                    "padding": "0px",
                    "imageHeight": "162px",
                    "imageWidth": "53px",
                    "-moz-border-radius": "5px"
                };
                emit <|
                    $K("#tester").bind("click", function() {
                        $K(this).effect("bounce", { "times" : 3 }, 300);
                    });
               |>;
        }

    }
}
</code>```

Title: jQuery UI effects in Kynetx sidetab

Body:
I have successfully had a jQuery UI effect take place on a page using Kynetx's jQuery UI integration.

However, I am having trouble getting the effect to work from within a sidetab. Here are the rules for my application. I'm hoping someone can point out what I am missing:

global {
  css  <<
         #tester
         {
             margin-left: 10px;
             margin-top: 10px;
             width: 80px;
             height: 80px;
             background: green;
             position: relative;
         }
       >>;
 }

rule tab is active {
select when pageview ".*" setting ()

 pre {
        results = <<

            >>;
}
{
     sidetab() with pathToTabImage = "http://dl.dropbox.com/u/10762217/search-tab-images/tab2.png"
               and tabColor = "transparent"
               and topPos = "50px"
               and message = results
               and divCSS = {
                             "z-index": 10000,
                             "backgroundColor": "#ffffff",
                             "width": "200px",
                             "padding": "0px",
                             "imageHeight": "162px",
                             "imageWidth": "53px",
                             "-moz-border-radius": "5px"
                            };
              watch("#tester", "click");
           }

 }

 rule jeffect_on_click is active {
     select when web click "#tester"
        jquery_ui:effect("#tester","bounce","normal");

 }
}

I made sure to include

use javascript resource jquery_ui_js

in my meta tag.

Body:
You aren't missing anything. Currently, the runtime, specifically the watch() action uses, .live() to register event handlers.  sidetab() eats all event handlers attached with .live(). sidetab() eats them because .live() actually works by attaching your click handler to the document object, and then watches for the event to bubble up. When it reaches the document, it checks to see if the event was registered from the element(s) matching your selector, if so, it fires your handler. sidetab() kills this by calling event.stopPropagation(), which stops the bubbling of the event, so it never reaches the document, so your handler will never fire.

You can fix this by registering your event handler with the jQuery utility function, .bind(). .bind() will only register the handler for elements that already exist, but as long as you take care that the elements inside of your sidetab exist before you call .bind(), you will be fine.

Something like this:

$K("#tester").bind("click", function() {
  $K(this).effect("bounce", { "times" : 3 }, 300);
});

Let's put that in the context of an entire app, shall we?

To keep this example simple, we'll simply emit the javascript necessary to attach our handler and have the div bounce when clicked. This example is also available as a gist:

ruleset a369x111 {
    meta {
        name "Sidetab->Events"
            description <<
                Sidetab jQuery
            >>
            author "AKO"
            logging on

            use javascript resource jquery_ui_js

    }
    global {
        css  <<
            #tester {
                margin-left: 10px;
                margin-top: 10px;
                width: 80px;
                height: 80px;
                background: green;
                position: relative;
            }
        >>;
    }

    rule tab {
        select when pageview ".*"

            pre {
                results = <<
                    <div id="tester"></div>
                >>;
            }
        {
            sidetab() with pathToTabImage = "http://dl.dropbox.com/u/10762217/search-tab-images/tab2.png"
                and tabColor = "transparent"
                and topPos = "50px"
                and message = results
                and divCSS = {
                    "z-index": 10000,
                    "backgroundColor": "#ffffff",
                    "width": "200px",
                    "padding": "0px",
                    "imageHeight": "162px",
                    "imageWidth": "53px",
                    "-moz-border-radius": "5px"
                };
                emit <|
                    $K("#tester").bind("click", function() {
                        $K(this).effect("bounce", { "times" : 3 }, 300);
                    });
               |>;
        }

    }
}


来源: stackexchange

问:
How to install srfi modules in local copy of guile
I have guile installed in /home/jcubic on shared hosting where I don't have root access and when I have this:

```<code>(use-modules (srfi srfi-1) (srfi srfi-26) (srfi srfi-43) (srfi srfi-60)
             (rnrs bytevectors) (ice-9 binary-ports) (srfi srfi-11))
</code>```

and when I run the script I've got error:

```<code> ERROR: no code for module (srfi srfi-43)
</code>```

how can I install this library to local guile instance?

答: Put it anywhere you like and add the directory to your load path, either by saying something like (add-to-load-path mydir), or by setting the environment variable GUILE_LOAD_PATH, which is probably more convenient.

ContentLicense: CC BY-SA 3.0

Body:
I have guile installed in /home/jcubic on shared hosting where I don't have root access and when I have this:

(use-modules (srfi srfi-1) (srfi srfi-26) (srfi srfi-43) (srfi srfi-60)
             (rnrs bytevectors) (ice-9 binary-ports) (srfi srfi-11))

and when I run the script I've got error:

 ERROR: no code for module (srfi srfi-43)

how can I install this library to local guile instance?


问:
Creating a Custom reporter block in Scratch
Quite simple, how do I create a hacked custom reporter block in Scratch?

I know I can make my own custom command block by editing the .json file, but I don't know how to create a custom reporter block. I believe that it is coming to Scratch 3.0, but I want to know how to make one by editing the .json file within the .sb2 file. Because I do not know how to use javascript, I don't know, but I believe in languages like C++, you can define a function that returns a value, like:

int function()
       //Function body
      return 0 //Gives the function a value of 0

Is it possible to do something like this is scratch?

People have asked me why I want to this. Imagine the main with having to calculate the factorial of a variable x every time you required to calculate statistical probabilities! You might as well make a function that assigns the result to a variable result and use that, but I cold only calculate one at once.

Thanks you to anybody that can help

答:
Item () of () is a Reporter block.  Custom reporter blocks are not currently possible, not even by editing JSON.

To create a custom block that takes a number as input, right-click on the block definition, edit, and add a number input.

EDIT:

Since custom reporter blocks are not possible, the only way is by using a variable to store the result.  Here the result is stored in f_result.  (rendered)

```<code>define f [input]
set (f_result) to ((((input)*(input))*(input))+((input)*(input)))

when GF clicked
f [2]
set [a v] to (f_result)
f [3]
set [b v] to (f_result)
set [c v] to ((a) + (b))
</code>```

See also custom block with return value.

Body:
Item () of () is a Reporter block.  Custom reporter blocks are not currently possible, not even by editing JSON.

To create a custom block that takes a number as input, right-click on the block definition, edit, and add a number input.

EDIT:

Since custom reporter blocks are not possible, the only way is by using a variable to store the result.  Here the result is stored in f_result.  (rendered)

define f [input]
set (f_result) to ((((input)*(input))*(input))+((input)*(input)))

when GF clicked
f [2]
set [a v] to (f_result)
f [3]
set [b v] to (f_result)
set [c v] to ((a) + (b))

See also custom block with return value.


问:
What is customer/service_head.tpl file in Xcart?
Am newbie in X cart.
How load customer/service_head.tpl in Xcart and not included,I can't saw that file in skin/customer folder.Is there any process to run that file display in x cart?Am So confused don't know what's wrong.

Please Give me Solution.

答:
The file is located here
./skin/common_files/customer/service_head.tpl

The file is loaded from the file like

skin/your_skin_name/customer/home.tpl:  {include file="customer/service_head.tpl"}

or from

skin/common_files/customer/home.tpl by default

Try our 'Webmaster mode' feature

https://demo.x-cart.com/demo_goldplus/admin/editor_mode.php

https://help.x-cart.com/index.php?title=X-Cart:Using_Webmaster_mode


问:
Application Trigger from Background Task in uwp
I am trying to signal application trigger from a background task.
If the app is in foreground, the trigger works but after the app is suspended, the the background task is signals the application trigger. but the code in application trigger does not hit.

Background trigger is a 15 min time trigger.

Any suggestions.

答:
This is the designed behavior. The purpose of the ApplicationTrigger is to trigger background activity while the app is in the foreground. This activity can continue to run in the background after the foreground app goes away, but it can only be initiated from an app that has foreground rights.

Thanks,

Stefan Wick - Windows Developer Platform


问:
Change the size of a JTextField inside a JBorderLayout
When I use the code below it doesn't alter the size at all, it still fills the area in the grid.</p>

```<code>JPanel displayPanel = new JPanel(new GridLayout(4, 2));

JTextField titleText = new JTextField("title");

displayPanel.add(titleText);

titleText.setSize(200, 24);
</code>```

答:
Try to play with

```<code>setMinSize()
setMaxSize()
setPreferredSize()
</code>```

These method are used by layout when it decide what should be the size of current element. The layout manager calls setSize() and actually overrides your values.

ContentLicense: CC BY-SA 2.5

Body:
When I use the code below it doesn't alter the size at all, it still fills the area in the grid.

JPanel displayPanel = new JPanel(new GridLayout(4, 2));

JTextField titleText = new JTextField("title");

displayPanel.add(titleText);

titleText.setSize(200, 24);

Body:
Try to play with

setMinSize()
setMaxSize()
setPreferredSize()

These method are used by layout when it decide what should be the size of current element. The layout manager calls setSize() and actually overrides your values.


问:
How to change width of underline in css
I have a cell in a table like this:

```<code><td><b>Grand Total</b></td>
</code>```

I need to give it a line under the text "Grand Total". I used text-decoration: underline;. It worked well, but I need to change the color and thickness of the underline. I used text-decoration-color: red; to add color but it doesn't work. How can I solve this problem?

答:
You cannot modify the width of underline tag. Instead go for Border-bottom approach and change it's properties as required.

.underline {
  border-bottom: 5px solid red;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table>
  <tr>
    <td><b class="underline">Grand Total</b></td>
  </tr>
</table></code>```

Title: How to change width of underline in css

Body:
I have a cell in a table like this:

Grand Total

I need to give it a line under the text "Grand Total". I used text-decoration: underline;. It worked well, but I need to change the color and thickness of the underline. I used text-decoration-color: red; to add color but it doesn't work. How can I solve this problem?

Body:
You cannot modify the width of underline tag. Instead go for Border-bottom approach and change it's properties as required.

.underline {
  border-bottom: 5px solid red;
}

<table>
  <tr>
    <td><b class="underline">Grand Total</b></td>
  </tr>
</table>


问:
How to add horizontal scroll view below a listview
How to put a horizontal scrollview below a listview? I have a listview and below it a horizontal scroll view with a bunch of radio buttons. This is my code:

```<code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/radioGroup">
    </ListView>

    <RadioGroup
        android:id="@+id/radioGroup"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true">

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:checked="true"
            android:gravity="center"
            android:padding="5dp"
            android:text="/>

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:padding="5dp"
            android:text="A-"/>

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:padding="5dp"
            android:text="B+"/>

        <RadioButton
            android:id="@+id/bNegative"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:padding="5dp"
            android:text="/>

    </RadioGroup>

</RelativeLayout>
</code>```

I need to be able to scroll the listview as normal i.e. vertically and the horizontal scroll view horizontally. Right now i can't scroll the listview but can scroll the horizontal scroll view. Please help me out

答:
use recyclerview to scroll both horizontal and vertical according to your requirement by setting orientation of recyclerview

to scroll vertical set orientation

```<code> android:orientation="vertical "
</code>```

and scroll horizontal set orientation

```<code> android:orientation="horizontal"
</code>```

Body:
How to put a horizontal scrollview below a listview? I have a listview and below it a horizontal scroll view with a bunch of radio buttons. This is my code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/radioGroup">
    </ListView>

    <RadioGroup
        android:id="@+id/radioGroup"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true">

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:checked="true"
            android:gravity="center"
            android:padding="5dp"
            android:text="/>

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:padding="5dp"
            android:text="A-"/>

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:padding="5dp"
            android:text="B+"/>

        <RadioButton
            android:id="@+id/bNegative"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:padding="5dp"
            android:text="/>

    </RadioGroup>

</RelativeLayout>

I need to be able to scroll the listview as normal i.e. vertically and the horizontal scroll view horizontally. Right now i can't scroll the listview but can scroll the horizontal scroll view. Please help me out

Body:
use recyclerview to scroll both horizontal and vertical according to your requirement by setting orientation of recyclerview

to scroll vertical set orientation

 android:orientation="vertical "

and scroll horizontal set orientation

 android:orientation="horizontal"


问:
Multiple Slave SPI on ESP8266 - PN532 and ILI9341
Im trying to interface ESP12-E module with ILI9341 display 320*240 And PN532 RFID reader on the same SPI bus. I have assigned SS Pins on different GPIO.

Im unable to Communicate with both. Display works perfectly in any conditions. But once i communicate with ILI9341 , the PN532 stops working and it will not respond until i restart the device even if i reinitialize it.

Any Help would be highly Appreciated
My Code :

```<code>#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#include <UTFT.h>
UTFT lcd(ILI9341_S5P,15,D1,D3);

// If using the breakout with SPI, define the pins for SPI communication.
#define PN532_SS   (D4)
#define PN532_SCK  (D5)
#define PN532_MOSI (D7)
#define PN532_MISO (D6)

// If using the breakout or shield with I2C, define just the pins connected
// to the IRQ and reset lines.  Use the values below (2, 3) for the shield!
#define PN532_IRQ   (2)
#define PN532_RESET (3)  // Not connected by default on the NFC Shield

// Uncomment just _one_ line below depending on how your breakout or shield
// is connected to the Arduino:

// Use this line for a breakout with a SPI connection:
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);

// Use this line for a breakout with a hardware SPI connection.  Note that
// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
// hardware SPI SCK, MOSI, and MISO pins.  On an Arduino Uno these are
// SCK = 13, MOSI = 11, MISO = 12.  The SS line can be any digital IO pin.
//Adafruit_PN532 nfc(PN532_SS);

// Or use this line for a breakout or shield with an I2C connection:
//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
extern uint8_t BigFont[];

void setup(void) {
  Serial.begin(115200);
  Serial.println("Hello!");
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }

  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
  lcd.InitLCD();
    lcd.setColor ( 0, 0, 0 );
    lcd.fillRect(1,1,319,239);
    lcd.setColor ( 255, 255, 255 );
    lcd.fillRect(100,100,220,140);
  lcd.setFont ( BigFont );
  lcd.print(String("Scanning"),0,0);
  // Set the max number of retry attempts to read from a card
  // This prevents us from waiting forever for a card, which is
  // the default behaviour of the PN532.
  nfc.setPassiveActivationRetries(0xFF);

  // configure board to read RFID tags
  nfc.SAMConfig();

  Serial.println("Waiting for an ISO14443A card");
}

void loop(void) {
  boolean success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
  uint8_t uidLength;                // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

  // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
  // 'uid' will be populated with the UID, and uidLength will indicate
  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength,25);

  if (success) {
    Serial.println("Found a card!");
    Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
    Serial.print("UID Value: ");
    for (uint8_t i=0; i < uidLength; i++)
    {
      Serial.print(" 0x");Serial.print(uid[i], HEX);
    }
    Serial.println("");
    // Wait 1 second before continuing
    delay(1000);
  }
  else
  {
    // PN532 probably timed out waiting for a card
    //Serial.println("Timed out waiting for a card");
  }
}
</code>```

答:
Thanks for the help.
Im not a big fan of bitbanging SPI.
I have tried several ways and tried re-initializing, etc.
Finally, i got it solved.

I dont know why, but when i re-initialize spi hardware after reading card, Both of the module works perfectly.

The code i added just after reading card:

```<code>    lcd._hw_special_init();
</code>```

like:

```<code>    success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength,0);
    if (success) {
    lcd._hw_special_init();
    //Do the rest
    }
</code>```

Body:
Im trying to interface ESP12-E module with ILI9341 display 320*240 And PN532 RFID reader on the same SPI bus. I have assigned SS Pins on different GPIO.

Im unable to Communicate with both. Display works perfectly in any conditions. But once i communicate with ILI9341 , the PN532 stops working and it will not respond until i restart the device even if i reinitialize it.

Any Help would be highly Appreciated
My Code :

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#include <UTFT.h>
UTFT lcd(ILI9341_S5P,15,D1,D3);

// If using the breakout with SPI, define the pins for SPI communication.
#define PN532_SS   (D4)
#define PN532_SCK  (D5)
#define PN532_MOSI (D7)
#define PN532_MISO (D6)

// If using the breakout or shield with I2C, define just the pins connected
// to the IRQ and reset lines.  Use the values below (2, 3) for the shield!
#define PN532_IRQ   (2)
#define PN532_RESET (3)  // Not connected by default on the NFC Shield

// Uncomment just _one_ line below depending on how your breakout or shield
// is connected to the Arduino:

// Use this line for a breakout with a SPI connection:
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);

// Use this line for a breakout with a hardware SPI connection.  Note that
// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
// hardware SPI SCK, MOSI, and MISO pins.  On an Arduino Uno these are
// SCK = 13, MOSI = 11, MISO = 12.  The SS line can be any digital IO pin.
//Adafruit_PN532 nfc(PN532_SS);

// Or use this line for a breakout or shield with an I2C connection:
//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
extern uint8_t BigFont[];

void setup(void) {
  Serial.begin(115200);
  Serial.println("Hello!");
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }

  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
  lcd.InitLCD();
    lcd.setColor ( 0, 0, 0 );
    lcd.fillRect(1,1,319,239);
    lcd.setColor ( 255, 255, 255 );
    lcd.fillRect(100,100,220,140);
  lcd.setFont ( BigFont );
  lcd.print(String("Scanning"),0,0);
  // Set the max number of retry attempts to read from a card
  // This prevents us from waiting forever for a card, which is
  // the default behaviour of the PN532.
  nfc.setPassiveActivationRetries(0xFF);

  // configure board to read RFID tags
  nfc.SAMConfig();

  Serial.println("Waiting for an ISO14443A card");
}

void loop(void) {
  boolean success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
  uint8_t uidLength;                // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

  // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
  // 'uid' will be populated with the UID, and uidLength will indicate
  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength,25);

  if (success) {
    Serial.println("Found a card!");
    Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
    Serial.print("UID Value: ");
    for (uint8_t i=0; i < uidLength; i++)
    {
      Serial.print(" 0x");Serial.print(uid[i], HEX);
    }
    Serial.println("");
    // Wait 1 second before continuing
    delay(1000);
  }
  else
  {
    // PN532 probably timed out waiting for a card
    //Serial.println("Timed out waiting for a card");
  }
}

Body:
Thanks for the help.
Im not a big fan of bitbanging SPI.
I have tried several ways and tried re-initializing, etc.
Finally, i got it solved.

I dont know why, but when i re-initialize spi hardware after reading card, Both of the module works perfectly.

The code i added just after reading card:

    lcd._hw_special_init();

like:

    success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength,0);
    if (success) {
    lcd._hw_special_init();
    //Do the rest
    }


问:
Why protected members can be overridden by public members in TypeScript?
I am new to Typescript, and I tried to played around a little with TypeScript in this playground. I noticed that in TypeScript, a protected member in base class can be overridden by public members:

```<code>class Base {
    protected name: string = '!'
}

class Derived extends Base{
    public name: string = '?'
}
</code>```

On the one hand, this makes sense to me since the Liskov Substitution Principle still holds: base class has stricter requirements than derived class. But on the other hand, I noticed that private member cannot be overridden by protected or public one, which seems inconsistent to me:

```<code>class Base {
    private name: string = '!'
}

class Derived extends Base{
    public name: string = '?'  // ERROR!
}
</code>```

Thus I wonder:

Is my observation an intended behavior or a bug in Typescript?

If it's intended, why this inconsistency exists? Why not TypeScript requires all overriding members having the same accessibility as members in base class? Or allowing all derived members with higher accessibility overriding members in base class?

答:
This is the intended behavior.

You can make a protected field public because protected allows a derived class to read and write a field. The derived class can choose to use its ability to read and write the field to allow others to read and write the field. There's no point making you write something like this:

```<code>class Foo {
  protected someField;
}

class Bar extends Foo {
  public get someFieldButPublic() {
    return this.someField;
  }
  public set someFieldButPublic(value) {
    this.someField = value;
  }
}
</code>```

if all you wanted to do was make someField public.

You can't make a private field protected or public because you don't have read or write access to that field. It's private; if the base class wanted you to have access to the field, they would have made it protected, after all.

Body:
I am new to Typescript, and I tried to played around a little with TypeScript in this playground. I noticed that in TypeScript, a protected member in base class can be overridden by public members:

class Base {
    protected name: string = '!'
}

class Derived extends Base{
    public name: string = '?'
}

On the one hand, this makes sense to me since the Liskov Substitution Principle still holds: base class has stricter requirements than derived class. But on the other hand, I noticed that private member cannot be overridden by protected or public one, which seems inconsistent to me:

class Base {
    private name: string = '!'
}

class Derived extends Base{
    public name: string = '?'  // ERROR!
}

Thus I wonder:

Is my observation an intended behavior or a bug in Typescript?

If it's intended, why this inconsistency exists? Why not TypeScript requires all overriding members having the same accessibility as members in base class? Or allowing all derived members with higher accessibility overriding members in base class?

Body:
This is the intended behavior.

You can make a protected field public because protected allows a derived class to read and write a field. The derived class can choose to use its ability to read and write the field to allow others to read and write the field. There's no point making you write something like this:

class Foo {
  protected someField;
}

class Bar extends Foo {
  public get someFieldButPublic() {
    return this.someField;
  }
  public set someFieldButPublic(value) {
    this.someField = value;
  }
}

if all you wanted to do was make someField public.

You can't make a private field protected or public because you don't have read or write access to that field. It's private; if the base class wanted you to have access to the field, they would have made it protected, after all.


问:
Elasticsearch 5.2: Mapping Issue with date field

I'm having a problem with properly mapping my timestamps. If I define it in default mapping I get a mapping parser error when importing the data.
When i did this manually for certain types it worked.

Why is this not working as default mapping?

```<code>PUT database
{
  "mappings": {
       "_default_": {
         "properties": {
            "Timestamp":{
              "type":"date",
              "format":"strict_date_hour_minute_second_fraction"

    }
  }}}
}
</code>```

答: My own fault my Timestamp doesnt have the fraction, seems when I did it manually I used strict_date_hour_minute_second instead.</p>

Body:
I'm having a problem with properly mapping my timestamps. If I define it in default mapping I get a mapping parser error when importing the data.
When i did this manually for certain types it worked.

Why is this not working as default mapping?

PUT database
{
  "mappings": {
       "_default_": {
         "properties": {
            "Timestamp":{
              "type":"date",
              "format":"strict_date_hour_minute_second_fraction"

    }
  }}}
}


问:
How do I upgrade python 2.7.8 to 2.7.9 in Anaconda without conflicting other components in its environment?
After successful installation of Anaconda on Windows 7 I realized the default Python version is 2.7.8. However I need 2.7.9. So how do I upgrade?</p>

答: Install newest version of Anaconda from their website. This will upgrade your Anaconda and python as well. Also, uninstall the previous version of Anaconda.</p>


问:
how to split string into double and string
I want to get  value from the following list box and separate the value into two double and int, and also a value from the combo box after getting these values i have to change these values into double and do some calculation on it and display the result in a message box. but it only display zero not whole value any solution pleas.

```<code>private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    double Value;
    string[] value = listBox1.Text.Split('-');
    value[1] = value[1].Trim('$');
    double.TryParse(value[1] , out Value);
    double Cmbo;
    string cmboValue = comboBox1.Text;
    double.TryParse(cmboValue , out Cmbo);
    double final1 = Value * Cmbo;
    string final = final1.ToString();
    MessageBox.Show(final);

}
</code>```

答:
I don't know why you are splitting based on "-", why don't you use "$" and get your values:

```<code>string res = "Full dicorative-$50.00";
string splitString = res.Split('$')[1];
double Value;
Double.TryParse(splitString, out Value);
double Cmbo;
double.TryParse("50.00", out Cmbo);
double final1 = Value * Cmbo;
string final = final1.ToString();
</code>```

It works perfectly.

Body:
I want to get  value from the following list box and separate the value into two double and int, and also a value from the combo box after getting these values i have to change these values into double and do some calculation on it and display the result in a message box. but it only display zero not whole value any solution pleas.

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    double Value;
    string[] value = listBox1.Text.Split('-');
    value[1] = value[1].Trim('$');
    double.TryParse(value[1] , out Value);
    double Cmbo;
    string cmboValue = comboBox1.Text;
    double.TryParse(cmboValue , out Cmbo);
    double final1 = Value * Cmbo;
    string final = final1.ToString();
    MessageBox.Show(final);

}

Body:
I don't know why you are splitting based on "-", why don't you use "$" and get your values:

string res = "Full dicorative-$50.00";
string splitString = res.Split('$')[1];
double Value;
Double.TryParse(splitString, out Value);
double Cmbo;
double.TryParse("50.00", out Cmbo);
double final1 = Value * Cmbo;
string final = final1.ToString();

It works perfectly.


问:
Vb.net Webbrowser Dock at bottom with Textbox Dock at top
In the window, I add a textbox and a Webbrowser Control.

How do I achieved the following picture?

On runtime when I increase the window size, it becomes like this. How to let the webbrowser dock the entire window without occupying the textbox.

答: I solved it by adding a panel for the textbox then dock it at top then dock inside it the textbox. Then dock the webbrowser at the bottom. Thanks.</p>


答:
You should give class or id to your specific line, like:

HTML:

```<code><td><b id="total">Grand Total</b></td>
</code>```

CSS:

```<code>#total {
  border-bottom: 1px solid red;
  padding: 0 0 4px;
}
</code>```

Title: How to change width of underline in css

Body:
You should give class or id to your specific line, like:

HTML:

<td><b id="total">Grand Total</b></td>

CSS:

#total {
  border-bottom: 1px solid red;
  padding: 0 0 4px;
}


问:
Is it safe to store only userId using SetAuthCookie() in ASP.NET
I was wondering if it was safe to store only UserId (primary key in the database) in the cookie using FormsAuthentication.SetAuthCookie() and saving it as a persisting cookie?

I've seen a lot of example where people save usernames but this(userId) could be a one or two digit number which would I guess make it even easier to obtain.
So my question is should I do it? If not, why and would it be a lot better if I simply saved the username? (which could again be a short name)

答:
It is not safe if you store that value unencrypted and then read that value back from the cookie and use it to authenticate the user's identity on subsequent requests (using the username this way would also be insecure).

It is not safe because it is trivial to change the value in the cookie and then users could subsume the identity of another user.

It is safe, however, if you store the User Id in the FormsAuthenticationTicket.UserData and encrypt the ticket.


问:
After login to captive portal,user can access router page and also ssh to router in openwrt
I am having TP-Link WR841Nv11 router and I upgrade it to openwrt for using captive portal. I am using coova-chilli for captive portal. I setup router with 2 ssid's one is for private use and other it will ask to login through captive portal for external users.

Everything is working fine, but the issue is after login through captive portal user can access the routers webpage and also able to ssh. I want to stop users to access router page and ssh as well.

答:
I found answer for my own question. Hopefully, this will be useful for
someone in the future. I made new network interface. Do cahnges in following files.

In /etc/config/network

```<code>config interface 'youfi'
    option ifname 'eth2'
    option force_link '1'
    option type 'bridge'
    option proto 'static'
    option ipaddr '10.0.0.1'
    option netmask '255.255.255.0'
    option isolate '1'
</code>```

In /etc/config/dhcp

```<code>config dhcp 'youfi'
    option interface 'youfi'
    option start '50'
    option limit '200'
    option leasetime '1h'
</code>```

In /etc/config/firewall

```<code>config zone
    option name 'youfi'
    option forward 'REJECT'
    option output 'ACCEPT'
    option network 'youfi'
    option input 'REJECT'

config forwarding
    option dest 'wan'
    option src 'youfi'

config rule
    option target 'ACCEPT'
    option proto 'tcp udp'
    option dest_port '53'
    option name 'youfi DNS'
    option src 'youfi'

config rule
    option enabled '1'
    option target 'ACCEPT'
    option name 'youfi DHCP'
    option src 'youfi'
    option proto 'udp'
    option dest_port '67-68'
</code>```

In /etc/config/wireless

```<code>config wifi-iface
    option device 'radio0'
    option network 'youfi'
    option mode 'ap'
    option encryption 'none'
    option ssid 'abcxyz'
</code>```

In /etc/config/chilli

Change in this line do br-lan to br-youfi

```<code>option dhcpif           br-lan
</code>```

to

```<code>option dhcpif           br-youfi
</code>```

and then

```<code>/etc/init.d/chilli stop
/etc/init.d/chilli start
</code>```

It is working as I want.

Body:
I found answer for my own question. Hopefully, this will be useful for
someone in the future. I made new network interface. Do cahnges in following files.

In /etc/config/network

config interface 'youfi'
    option ifname 'eth2'
    option force_link '1'
    option type 'bridge'
    option proto 'static'
    option ipaddr '10.0.0.1'
    option netmask '255.255.255.0'
    option isolate '1'

In /etc/config/dhcp

config dhcp 'youfi'
    option interface 'youfi'
    option start '50'
    option limit '200'
    option leasetime '1h'

In /etc/config/firewall

config zone
    option name 'youfi'
    option forward 'REJECT'
    option output 'ACCEPT'
    option network 'youfi'
    option input 'REJECT'

config forwarding
    option dest 'wan'
    option src 'youfi'

config rule
    option target 'ACCEPT'
    option proto 'tcp udp'
    option dest_port '53'
    option name 'youfi DNS'
    option src 'youfi'

config rule
    option enabled '1'
    option target 'ACCEPT'
    option name 'youfi DHCP'
    option src 'youfi'
    option proto 'udp'
    option dest_port '67-68'

In /etc/config/wireless

config wifi-iface
    option device 'radio0'
    option network 'youfi'
    option mode 'ap'
    option encryption 'none'
    option ssid 'abcxyz'

In /etc/config/chilli

Change in this line do br-lan to br-youfi

option dhcpif           br-lan

to

option dhcpif           br-youfi

and then

/etc/init.d/chilli stop
/etc/init.d/chilli start

It is working as I want.


问:
libgdx dialog how to properly display 3 lines and a button
In a libgdx dialog I want to display three text lines, with a button to quit the dialog at the bottom.

The following code would print all text in 1 line, followed by the button at the bottom:

```<code>    Dialog dialog = new Dialog("Stats", skin);
    dialog.text("First line");
    dialog.text("Second line");
    dialog.text("Third line");
    dialog.button("Done");

    dialog.show(stage);
</code>```

If I use table followed by a button like the following, the button would be shown at the left side not the bottom.

```<code>    Table table = new Table(skin);
    table.add(new Label("First line", skin));
    table.row();
    table.add(new Label("Second line", skin));
    table.row();
    table.add(new Label("Third line", skin));

    Dialog dialog = new Dialog("Stats", skin);
    dialog.add(table);
    dialog.button("Done");
    dialog.show(stage);
</code>```

If I put a button inside the table the dialog can't be clicked close.

答:
If you want to do it by table. Try

```<code>dialog.getContentTable().add(table);
</code>```

If you want a text dialog. Follow this

```<code>Label text = new Label("first line\nsecond line\nthird line \n",skin,labelStyle);
text.setWrap(true);
</code>```

Body:
In a libgdx dialog I want to display three text lines, with a button to quit the dialog at the bottom.

The following code would print all text in 1 line, followed by the button at the bottom:

    Dialog dialog = new Dialog("Stats", skin);
    dialog.text("First line");
    dialog.text("Second line");
    dialog.text("Third line");
    dialog.button("Done");

    dialog.show(stage);

If I use table followed by a button like the following, the button would be shown at the left side not the bottom.

    Table table = new Table(skin);
    table.add(new Label("First line", skin));
    table.row();
    table.add(new Label("Second line", skin));
    table.row();
    table.add(new Label("Third line", skin));

    Dialog dialog = new Dialog("Stats", skin);
    dialog.add(table);
    dialog.button("Done");
    dialog.show(stage);

If I put a button inside the table the dialog can't be clicked close.

Body:
If you want to do it by table. Try

dialog.getContentTable().add(table);

If you want a text dialog. Follow this

Label text = new Label("first line\nsecond line\nthird line \n",skin,labelStyle);
text.setWrap(true);


问:
remove some elements if no children
i need to remove some elements if no children...

this will work...

```<code>$$('*').each(function() {
    ($$(this).text().trim() === '') && $$(this).remove()
});
</code>```

but it will look for all elements... i need to limit to some elements.. so i made this..

```<code>elements.forEach(element => {
    $$(element).each(function() {
        ($$(this).text().trim() === '') && $$(this).remove()
    });
})
</code>```

but it doesn't work..

答:
Remove all empty tags from current document

```<code>$("*:empty").remove();
</code>```

Title: remove some elements if no children

Body:
i need to remove some elements if no children...

this will work...

$$('*').each(function() {
    ($$(this).text().trim() === '') && $$(this).remove()
});

but it will look for all elements... i need to limit to some elements.. so i made this..

elements.forEach(element => {
    $$(element).each(function() {
        ($$(this).text().trim() === '') && $$(this).remove()
    });
})

but it doesn't work..

Body:
Remove all empty tags from current document

$("*:empty").remove();


答:
Use pseudo elements like :before and :after to control the length of the underline as well

td {
  position: relative;
}

td:after {
  content: '';
  position: absolute;
  width: 100%;
  display: block;
  height: 5px;
  background-color: red;
  bottom: -5px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table>
  <tbody>
    <tr>
      <td><b>Grand Total</b></td>
    </tr>
  </tbody>
</table></code>```

Title: How to change width of underline in css

Body:
I have a cell in a table like this:

Grand Total

I need to give it a line under the text "Grand Total". I used text-decoration: underline;. It worked well, but I need to change the color and thickness of the underline. I used text-decoration-color: red; to add color but it doesn't work. How can I solve this problem?

Body:
Use pseudo elements like :before and :after to control the length of the underline as well

td {
  position: relative;
}

td:after {
  content: '';
  position: absolute;
  width: 100%;
  display: block;
  height: 5px;
  background-color: red;
  bottom: -5px;
}

<table>
  <tbody>
    <tr>
      <td><b>Grand Total</b></td>
    </tr>
  </tbody>
</table>


答:
From here

td {
  color: red;
  text-decoration: underline;
}

span {
  color: black;
  text-decoration: none;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table>
  <tr>
    <td><b><span>Grand Total</span></b></td>
  </tr>
</table></code>```

Title: How to change width of underline in css

Body:
From here

td {
  color: red;
  text-decoration: underline;
}

span {
  color: black;
  text-decoration: none;
}

<table>
  <tr>
    <td><b><span>Grand Total</span></b></td>
  </tr>
</table>


问:
BufferedOutputStream not throwing I/O exception
While working on BufferedOutputStream found it does not throw an IOException when we wrote on it after closing the stream.

To verify my result, i checked FileOutputStream found it is throwing IOException once we try to write on it after closing it.

```<code>public class Test {
    public static void main(String[] args) {
        try {
            // Created a byte[] barry1 barry2
            byte[] barry1 = { '1', '3' };
            byte[] barray2 = { '2', '4' };
            OutputStream os = new BufferedOutputStream(
                  new FileOutputStream("abc.txt", false));
            // Writing to stream
            os.write(barry1);
            os.close();
            os.write(barray2); // this suceeds - bug

            os = new FileOutputStream("abc.txt", true);
             //Writing to stream
            os.write(barry1);
            os.close();
            os.write(barray2); // crashes here, correct.
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
</code>```

Could some one help me on this, Why this behavior is different ?

答: Because BufferedOutputStream writes bytes to its internal byte buffer, then when invoked writes to the underlying ouput stream, so if call flush after the os.write(c);, it will throw the exception, but here you try to write to the file stream directly after it was closed, hence the exception, no surprise here

Body:
While working on BufferedOutputStream found it does not throw an IOException when we wrote on it after closing the stream.

To verify my result, i checked FileOutputStream found it is throwing IOException once we try to write on it after closing it.

public class Test {
    public static void main(String[] args) {
        try {
            // Created a byte[] barry1 barry2
            byte[] barry1 = { '1', '3' };
            byte[] barray2 = { '2', '4' };
            OutputStream os = new BufferedOutputStream(
                  new FileOutputStream("abc.txt", false));
            // Writing to stream
            os.write(barry1);
            os.close();
            os.write(barray2); // this suceeds - bug

            os = new FileOutputStream("abc.txt", true);
             //Writing to stream
            os.write(barry1);
            os.close();
            os.write(barray2); // crashes here, correct.
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Could some one help me on this, Why this behavior is different ?


问:
How do I use multiple Kynetx apps in a single phone call with Twilio?
I want to be able to use multiple Kynetx apps (rulesets) in a single phone call. Say the first app is a phone menu, and the second app provides the functionality for the menu option. How do I redirect from one to the other?</p>

答:
When you use a twilio:redirect() or twill:gather_start() action, the url you provide is a relative URL.

All twilio webhooks provided by Kynetx have the full URL of http://webhooks.kynetxapps.net/t/appid/eventname

If you pass in a URL relative to this, it will resolve relative to this. Example:

With a base URL of http://webhooks.kynetxapps.net/t/myappid/callstart the action twilio:redirect("sayhello") will resolve to http://webhooks.kynetxapps.net/t/myappid/sayhello

This will send in a new event to the same application.

If you want to switch apps, you can either provide the full URL, including the new appid, or use a relative URL like the following:

With a base URL: http://webhooks.kynetxapps.net/t/myappid/callstart the action twilio:redirect("../newappid/sayhello") resolves to: http://webhooks.kynetxapps.net/t/newappid/sayhello

Here is an example app which uses a different app for a menu choice.

```<code>ruleset firstappid {
  meta {
    name "Phone Menu App"
    description <<
      Provides the Phone Menu
    >>
    author "Sam Curren"
    logging off
  }
  dispatch {}
  global {}

  rule menu {
    select when twilio givemenu
    {
      twill:gather_start("../secondappid/menuchoice") with numDigits = 1;
        twilio:say("Press 1 to speak do whatever.");
      twilio:gather_stop();
    }
  }

}
</code>```

And the app which receives the menu choice.

```<code>ruleset secondappid {
  meta {
    name "Phone Menu Option"
    description <<
      Provides the menu functionality
    >>
    author "Sam Curren"
    logging off
  }
  dispatch {}
  global {}

  rule speak {
    select when twilio menuchoice Digits "1"
    {
      twilio:say("This is what you get when you press 1.");
      twilio:hangup();
    }
  }
}
</code>```

By using the action twilio:redirect('../firstappid/givemenu') instead of twilio:hangup(), this rule could redirect back to the first app.

Body:
When you use a twilio:redirect() or twill:gather_start() action, the url you provide is a relative URL.

All twilio webhooks provided by Kynetx have the full URL of http://webhooks.kynetxapps.net/t/appid/eventname

If you pass in a URL relative to this, it will resolve relative to this. Example:

With a base URL of http://webhooks.kynetxapps.net/t/myappid/callstart the action twilio:redirect("sayhello") will resolve to http://webhooks.kynetxapps.net/t/myappid/sayhello

This will send in a new event to the same application.

If you want to switch apps, you can either provide the full URL, including the new appid, or use a relative URL like the following:

With a base URL: http://webhooks.kynetxapps.net/t/myappid/callstart the action twilio:redirect("../newappid/sayhello") resolves to: http://webhooks.kynetxapps.net/t/newappid/sayhello

Here is an example app which uses a different app for a menu choice.

ruleset firstappid {
  meta {
    name "Phone Menu App"
    description <<
      Provides the Phone Menu
    >>
    author "Sam Curren"
    logging off
  }
  dispatch {}
  global {}

  rule menu {
    select when twilio givemenu
    {
      twill:gather_start("../secondappid/menuchoice") with numDigits = 1;
        twilio:say("Press 1 to speak do whatever.");
      twilio:gather_stop();
    }
  }

}

And the app which receives the menu choice.

ruleset secondappid {
  meta {
    name "Phone Menu Option"
    description <<
      Provides the menu functionality
    >>
    author "Sam Curren"
    logging off
  }
  dispatch {}
  global {}

  rule speak {
    select when twilio menuchoice Digits "1"
    {
      twilio:say("This is what you get when you press 1.");
      twilio:hangup();
    }
  }
}

By using the action twilio:redirect('../firstappid/givemenu') instead of twilio:hangup(), this rule could redirect back to the first app.


问:
How to match crypted password in php while login?
I am using PHP crypt(). Here I saved my password using crypt().

In login, I want to match my password with the input password and logged in password, but in crypt its everytime creating random string with the same password.

below is my login code.

$user_name=$_REQUEST['username'];
$salt = "";
echo  $password=crypt($_REQUEST['password'], $salt);

$query ="select username , password from users where username = '".$user_name."'";
$result = mysqli_query($con , $query);
$row = mysqli_fetch_assoc($result);

echo "```";print_r($row);exit;
</code>```

login out put

$1$oIllNdlE$y23rdM6qp4sv/P/bgfUE7/     //user input

Array
(
    [username] => sradha
    [password] => $1$dI1IgbiD$NsfWU0fOHOzNEFbd7Vrx.0  //from data base
)
```

<p>here my password is 123, for same 123 it's generating two different results.</p>

<p>below is the code I am inserting to DB, while sign in:</p>

<pre class="lang-html prettyprint-override"><code>user_name=$_REQUEST['username'];
$salt = "";
$password=crypt($_REQUEST['password'], $salt);
mysqli_query($con , "INSERT INTO users (username , password) VALUES ('sradha' , '".$password."')");
</code>```

any suggestion, how to match the password using crypt?

答:
Crypt function returns the different data every time.
You can use hash_equal function to compare the encrypted strings.</p>

Body:
I am using PHP crypt(). Here I saved my password using crypt().

In login, I want to match my password with the input password and logged in password, but in crypt its everytime creating random string with the same password.

below is my login code.

$user_name=$_REQUEST['username'];
$salt = "";
echo  $password=crypt($_REQUEST['password'], $salt);

$query ="select username , password from users where username = '".$user_name."'";
$result = mysqli_query($con , $query);
$row = mysqli_fetch_assoc($result);

echo "
";print_r($row);exit;

login out put

$1$oIllNdlE$y23rdM6qp4sv/P/bgfUE7/     //user input

Array
(
    [username] => sradha
    [password] => $1$dI1IgbiD$NsfWU0fOHOzNEFbd7Vrx.0  //from data base
)

here my password is 123, for same 123 it's generating two different results.

below is the code I am inserting to DB, while sign in:

user_name=$_REQUEST['username'];
$salt = "";
$password=crypt($_REQUEST['password'], $salt);
mysqli_query($con , "INSERT INTO users (username , password) VALUES ('sradha' , '".$password."')");

any suggestion, how to match the password using crypt?


问:
Oracle SQL Practice
So I'm super stuck on a practice problem I'm on while reading through my book. This is the requirement:

List the zip code, name and phone number of instructors who teach students that live in same zipcode as the instructor.

And this is the expected results:
FIRST_NAME LAST_NAME PHONE

Nina Schorin 2125551212

Todd Smythe 2125551212

(2 Rows)

This is the code I have so far and I return two results just not the correct results. Any help would be much appreciated.
I added an Image of the Tables and queries that I'm working with.

```<code>    SELECT DISTINCT S.first_name, S.last_name, S.PHONE
    FROM STUDENT S, ENROLLMENT E, section SE, INSTRUCTOR I
    WHERE S.STUDENT_ID = E.STUDENT_ID
    AND E.SECTION_ID = SE.SECTION_ID
    AND SE.INSTRUCTOR_ID = I.INSTRUCTOR_ID
    AND S.ZIP = I.ZIP
    GROUP BY S.FIRST_NAME, S.LAST_NAME, S.PHONE
    MINUS
    SELECT DISTINCT I.first_name, I.last_name, I.PHONE
    FROM STUDENT S, ENROLLMENT E, section SE, INSTRUCTOR I
    WHERE S.STUDENT_ID = E.STUDENT_ID
    AND E.SECTION_ID = SE.SECTION_ID
    AND SE.INSTRUCTOR_ID = I.INSTRUCTOR_ID
    AND S.ZIP = I.ZIP
    GROUP BY I.FIRST_NAME, I.LAST_NAME, I.PHONE;
</code>```

TABLES AND RESULTS

答:
Here's a link for you, this'll make you understand better way: SQL INNER JOIN

And here's what you should code:

```<code>select INSTRUCTOR.FIRST_NAME, INSTRUCTOR.LAST_NAME, INSTRUCTOR.PHONE, STUDENT.FIRST_NAME, STUDENT.LAST_NAME
from INSTRUCTOR inner join STUDENT on INSTRUCTOR.ZIP = STUDENT.ZIP
</code>```

I put it Student's first name and last name so you have a better idea to who that instructor teaches.

Title: Oracle SQL Practice

Body:
So I'm super stuck on a practice problem I'm on while reading through my book. This is the requirement:

List the zip code, name and phone number of instructors who teach students that live in same zipcode as the instructor.

And this is the expected results:
FIRST_NAME LAST_NAME PHONE

Nina Schorin 2125551212

Todd Smythe 2125551212

(2 Rows)

This is the code I have so far and I return two results just not the correct results. Any help would be much appreciated.
I added an Image of the Tables and queries that I'm working with.

    SELECT DISTINCT S.first_name, S.last_name, S.PHONE
    FROM STUDENT S, ENROLLMENT E, section SE, INSTRUCTOR I
    WHERE S.STUDENT_ID = E.STUDENT_ID
    AND E.SECTION_ID = SE.SECTION_ID
    AND SE.INSTRUCTOR_ID = I.INSTRUCTOR_ID
    AND S.ZIP = I.ZIP
    GROUP BY S.FIRST_NAME, S.LAST_NAME, S.PHONE
    MINUS
    SELECT DISTINCT I.first_name, I.last_name, I.PHONE
    FROM STUDENT S, ENROLLMENT E, section SE, INSTRUCTOR I
    WHERE S.STUDENT_ID = E.STUDENT_ID
    AND E.SECTION_ID = SE.SECTION_ID
    AND SE.INSTRUCTOR_ID = I.INSTRUCTOR_ID
    AND S.ZIP = I.ZIP
    GROUP BY I.FIRST_NAME, I.LAST_NAME, I.PHONE;

TABLES AND RESULTS

Body:
Here's a link for you, this'll make you understand better way: SQL INNER JOIN

And here's what you should code:

select INSTRUCTOR.FIRST_NAME, INSTRUCTOR.LAST_NAME, INSTRUCTOR.PHONE, STUDENT.FIRST_NAME, STUDENT.LAST_NAME
from INSTRUCTOR inner join STUDENT on INSTRUCTOR.ZIP = STUDENT.ZIP

I put it Student's first name and last name so you have a better idea to who that instructor teaches.


问:
Transition to route's action from Ember object
I am fairly new to ember. I have an existing Ember App and i need to implement a functionality in it. I have a Ember Object as below

```<code>`import Ember from 'ember'`

CallService = Ember.Object.extend

 ... other code here

 _updateConnectedLeadId: (->
    console.log "Do i get here??"

    **pass the route action here**

  ).observes('some_other_here')
`export default CallService`
</code>```

Unfortunately, i couldn't put the whole code here.

My route looks like

```<code>ApplicationRoute = Ember.Route.extend
  actions:
    showLead: ->
      console.log data
      console.log "did i get here?"
      @transitionTo('dashboard')

`export default ApplicationRoute`
</code>```

I tried using @send('showLead'), @sendAction('showLead') in my method but no luck.

My main intention is to make a transition once the console.log "Do i get here??" is displayed. I am not sure if i am on the right way here.

I also tried using @transitionTo('dashboard') and @transitionToRote('dashboard') directly but it throws me errors.

I have been stuck for a day on this now and i am clueless.

I'll be grateful for any guidance and help. Thanks

答:
You have the problem that you are trying to trigger a route action or trigger a transition from within an Ember.Object, named call service. The code you create is unclear about where your custom object is being created; where the observer is triggered due to a change to object's property update, and so on.

Nevertheless, I tried to provide a working example for you. If you open the twiddle, you will see that I created a my-object instance within index.js route and pass it as model to my-component. When you click the button within my-component.hbs. The my-object instances dummyVariable is toggled and the observer within my-object executes. The tricky part here is that I passed index route itself as ownerRoute property to my-object instance; so that I can trigger the index route's dummyAction from within my-object.js with

```<code>ownerRoute.send('dummyAction');
</code>```

so that related action executes and transition to my-route is performed. Although, I believe this might solve your question; I am not quite happy about the design. I do not think, it is a good way for Ember.Objects to know about routes, actions, controllers, etc. I believe the proper way is observing object's relevant properties from within this constructs and perform necessary actions by their own. Moreover, you might consider creating a service instead of an object and inject the service directly to your route instead of creating an instance of your class extending Ember.Object. If you have to extend from Ember.Object you can just inject relevant route, controller, etc to the instances of that particular object class by using an instance-initializer if you need.

Anyway, please take a look at the twiddle and ask more if you need to. I will be happy to help if I can.

Body:
I am fairly new to ember. I have an existing Ember App and i need to implement a functionality in it. I have a Ember Object as below

`import Ember from 'ember'`

CallService = Ember.Object.extend

 ... other code here

 _updateConnectedLeadId: (->
    console.log "Do i get here??"

    **pass the route action here**

  ).observes('some_other_here')
`export default CallService`

Unfortunately, i couldn't put the whole code here.

My route looks like

ApplicationRoute = Ember.Route.extend
  actions:
    showLead: ->
      console.log data
      console.log "did i get here?"
      @transitionTo('dashboard')

`export default ApplicationRoute`

I tried using @send('showLead'), @sendAction('showLead') in my method but no luck.

My main intention is to make a transition once the console.log "Do i get here??" is displayed. I am not sure if i am on the right way here.

I also tried using @transitionTo('dashboard') and @transitionToRote('dashboard') directly but it throws me errors.

I have been stuck for a day on this now and i am clueless.

I'll be grateful for any guidance and help. Thanks

Body:
You have the problem that you are trying to trigger a route action or trigger a transition from within an Ember.Object, named call service. The code you create is unclear about where your custom object is being created; where the observer is triggered due to a change to object's property update, and so on.

Nevertheless, I tried to provide a working example for you. If you open the twiddle, you will see that I created a my-object instance within index.js route and pass it as model to my-component. When you click the button within my-component.hbs. The my-object instances dummyVariable is toggled and the observer within my-object executes. The tricky part here is that I passed index route itself as ownerRoute property to my-object instance; so that I can trigger the index route's dummyAction from within my-object.js with

ownerRoute.send('dummyAction');

so that related action executes and transition to my-route is performed. Although, I believe this might solve your question; I am not quite happy about the design. I do not think, it is a good way for Ember.Objects to know about routes, actions, controllers, etc. I believe the proper way is observing object's relevant properties from within this constructs and perform necessary actions by their own. Moreover, you might consider creating a service instead of an object and inject the service directly to your route instead of creating an instance of your class extending Ember.Object. If you have to extend from Ember.Object you can just inject relevant route, controller, etc to the instances of that particular object class by using an instance-initializer if you need.

Anyway, please take a look at the twiddle and ask more if you need to. I will be happy to help if I can.


问:
python mysql unsupported format character '''
I'm getting an error replacing the %s to a date string.

```<code>import datetime

now = datetime.datetime.now()

day_minus_one = now + datetime.timedelta(days=-1)
new_date = day_minus_one.strftime('%Y%m%d')

db = MySQLdb.connect(host='127.0.0.1', user='root', passwd='', db='daily_report')
cur = db.cursor()

sql = "select date, stp_dpc, count(*), concat(round(avg(status = 'Success') * 100), '%') as Success from daily where status not in ('data1', 'data2', 'data3') and date = %s group by date, stp_dpc"

cur.execute(sql, new_date)
rows = cur.fetchall()
</code>```

If i replace the equals to a literal string = '20170327' it does work perfectly.

```<code>cur.execute("select date, stp_dpc, count(*), concat(round(avg(status = 'Success') * 100), '%') as Success from daily where status not in ('data1', 'data2', 'data3') and date = '20170310' group by date, stp_dpc")
rows = cur.fetchall()
</code>```

答: How about ...and date = '{}' group by date, stp_dpc".format(new_date)</p>

Body:
I'm getting an error replacing the %s to a date string.

import datetime

now = datetime.datetime.now()

day_minus_one = now + datetime.timedelta(days=-1)
new_date = day_minus_one.strftime('%Y%m%d')

db = MySQLdb.connect(host='127.0.0.1', user='root', passwd='', db='daily_report')
cur = db.cursor()

sql = "select date, stp_dpc, count(*), concat(round(avg(status = 'Success') * 100), '%') as Success from daily where status not in ('data1', 'data2', 'data3') and date = %s group by date, stp_dpc"

cur.execute(sql, new_date)
rows = cur.fetchall()

If i replace the equals to a literal string = '20170327' it does work perfectly.

cur.execute("select date, stp_dpc, count(*), concat(round(avg(status = 'Success') * 100), '%') as Success from daily where status not in ('data1', 'data2', 'data3') and date = '20170310' group by date, stp_dpc")
rows = cur.fetchall()


问:
Query-string in ASP.NET in Visual Studio 2015 for debugging?
How do you add a query-string to a specific page in ASP.NET in Visual Studio 2015 for debugging?

I want to run certain pages with a query-string with test values.

I know this is going to be simple but I can not work out to do it.

答:
Try adding the query string parameter to the project's start page property. Select project in Solution Explorer, right-click on Properties. Under the Web tab, you can append the parameter in the Specific Page text box.

Similar question here.


问:
Stacking images on top of each other in a centered, responsive div
I have the following code. It is set up so that the images are responsive (scale with the window size) and positioned centrally, both horizontally and vertically. It was working fine until I wanted to add several images stacked on top of each other to play as a slideshow (fade-in, fade-out). I had to position the img tags "absolute". And it obviously collapsed the parent divs. Basically I want an alternative method to stack images on top of each other without using absolute positioning. </p>

```<code><div class="container">

            <div class="main-picture-wrapper">
                 <div class="main-picture">
                      <img id="front" src="img/VR-front.png" class="">
                      <img id="side" src="img/VR-side.png" class="">

                 </div>
             </div>
  </div>

 .container {
  height:100%;
  text-align: center;
  font:0/0 a;
    }

 .container:before {
  content: ' ';
  display: inline-block;
  vertical-align: middle;
  height: 100%;
}

.main-picture-wrapper {
    margin-top: 70px;
    display: inline-block;
    vertical-align: middle;
    font-size: 16px/1;
    width:70%;
    left:0;
}

.main-picture {
 width:100%;
 position: relative;
 text-align: center;
}

.main-picture img {
    position: absolute;
    width:100%;
    top: 0;
    left: 0;

}
</code>```

答:
As k185 suggested, flexbox is the way, along with absolute positioning. As today it's compatible with most of browsers.

Keeping your markup and style, a good starting point could be something like this:

```<code>html, body {
  height: 100%;
}

.main-picture {
  ...
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-picture img {
  position: absolute;
}
</code>```

https://jsbin.com/sinayiloge/edit?html,css,output

Body:
I have the following code. It is set up so that the images are responsive (scale with the window size) and positioned centrally, both horizontally and vertically. It was working fine until I wanted to add several images stacked on top of each other to play as a slideshow (fade-in, fade-out). I had to position the img tags "absolute". And it obviously collapsed the parent divs. Basically I want an alternative method to stack images on top of each other without using absolute positioning.

 .container {
  height:100%;
  text-align: center;
  font:0/0 a;
    }

 .container:before {
  content: ' ';
  display: inline-block;
  vertical-align: middle;
  height: 100%;
}

.main-picture-wrapper {
    margin-top: 70px;
    display: inline-block;
    vertical-align: middle;
    font-size: 16px/1;
    width:70%;
    left:0;
}

.main-picture {
 width:100%;
 position: relative;
 text-align: center;
}

.main-picture img {
    position: absolute;
    width:100%;
    top: 0;
    left: 0;

}

Body:
As k185 suggested, flexbox is the way, along with absolute positioning. As today it's compatible with most of browsers.

Keeping your markup and style, a good starting point could be something like this:

html, body {
  height: 100%;
}

.main-picture {
  ...
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-picture img {
  position: absolute;
}

https://jsbin.com/sinayiloge/edit?html,css,output


问:
R drop and element from a nested list using laply
I have nested list, the elements in the list are strings. So the structure is ...

```<code>> lapply(DVHlimits, function(x) laply (x, function(x) laply(x, function(x) length(x))))
[[1]]
      1 2 3 4 5 6 7 8
 [1,] 1 1 1 1 1 1 1 1
 [2,] 1 1 1 1 1 1 1 1
 [3,] 1 1 1 1 1 1 1 1
 [4,] 1 1 1 1 1 1 1 1
 [5,] 1 1 1 1 1 1 1 1

 [[2]]
      1 2 3 4 5 6 7
 [1,] 1 1 1 1 1 1 1
 [2,] 1 1 1 1 1 1 1
 [3,] 1 1 1 1 1 1 1
 [4,] 1 1 1 1 1 1 1

[[3]]
     1 2 3 4 5 6 7
[1,] 1 1 1 1 1 1 1
[2,] 1 1 1 1 1 1 1
</code>```

etc ......

What I want to do is drop the 8th element from each of sublists (where there is an 8th element) Can anyone tell me how to remove them?

Thank you

答:
Thanks for your suggestions, this is the solution that I came up with.

```<code># Create a function which can be used with lapply
cleanColls <- function(x) {
  x <- x[c(-1, -8)]
}

DVHlimits <- lapply(DVHlimits, function(x) lapply( x, function(x) cleanColls(x)))
</code>```

As you can probably figure out I have also dropped the first element of each sublist. The end result is each sublist has now only 6 elements, they are now all the same length which is what I wanted to achieve.

Body:
I have nested list, the elements in the list are strings. So the structure is ...

> lapply(DVHlimits, function(x) laply (x, function(x) laply(x, function(x) length(x))))
[[1]]
      1 2 3 4 5 6 7 8
 [1,] 1 1 1 1 1 1 1 1
 [2,] 1 1 1 1 1 1 1 1
 [3,] 1 1 1 1 1 1 1 1
 [4,] 1 1 1 1 1 1 1 1
 [5,] 1 1 1 1 1 1 1 1

 [[2]]
      1 2 3 4 5 6 7
 [1,] 1 1 1 1 1 1 1
 [2,] 1 1 1 1 1 1 1
 [3,] 1 1 1 1 1 1 1
 [4,] 1 1 1 1 1 1 1

[[3]]
     1 2 3 4 5 6 7
[1,] 1 1 1 1 1 1 1
[2,] 1 1 1 1 1 1 1

etc ......

What I want to do is drop the 8th element from each of sublists (where there is an 8th element) Can anyone tell me how to remove them?

Thank you

Body:
Thanks for your suggestions, this is the solution that I came up with.

# Create a function which can be used with lapply
cleanColls <- function(x) {
  x <- x[c(-1, -8)]
}

DVHlimits <- lapply(DVHlimits, function(x) lapply( x, function(x) cleanColls(x)))

As you can probably figure out I have also dropped the first element of each sublist. The end result is each sublist has now only 6 elements, they are now all the same length which is what I wanted to achieve.


问:
angular2 - infinite loop when i call method from a Angular 2 class inside template
I have a problem when i call a method from component in the template by interpolation: {{get_method()}}. The method runs, but in infinite loop I don't know why. Any help please ??

the code of method is like this :

```<code>get_name() {
  console.log("bonjour");
}
</code>```

and I call it in my template like this :

```<code>{{get_name()}}
</code>```

and this is the result :

答:
In your component </p>

```<code>getName:string;
ngOnInit() {
   this.get_name();
}
get_name() {
    console.log("bonjour");
    this.getName = "bonjour";
}
</code>```

<p>And in your view file </p>

```<code>{{getName}}
</code>```

Body:
I have a problem when i call a method from component in the template by interpolation: {{get_method()}}. The method runs, but in infinite loop I don't know why. Any help please ??

the code of method is like this :

get_name() {
  console.log("bonjour");
}

and I call it in my template like this :

{{get_name()}}

and this is the result :

Body:
In your component

getName:string;
ngOnInit() {
   this.get_name();
}
get_name() {
    console.log("bonjour");
    this.getName = "bonjour";
}

And in your view file

{{getName}}


问:
Phantomjs proxy ajax request
Is there a way to proxy ajax requests to another server in phanomjs?

I'm using webpack server for development with proxyng '/api/**' requests to my local backend server http://myserver.dev. For prependering I use phantomjs but it return 404 for my ajax requests.

If I making ajax manually to http://myserver.dev/api/** then it works perfectly, but i wannna keep my services clean if it's possible.

答:
I found the answer. It is possible with onResourceRequested callback.</p>

```<code>page.onResourceRequested = function (requestData, request) {
  if (/^http:\/\/localhost:8000\/api/i.test(requestData.url)) {
    request.changeUrl(
        requestData.url.replace('http://localhost:8000', 'http://myserver.dev')
    );
  }
}
</code>```

Title: Phantomjs proxy ajax request

Body:
I found the answer. It is possible with onResourceRequested callback.

page.onResourceRequested = function (requestData, request) {
  if (/^http:\/\/localhost:8000\/api/i.test(requestData.url)) {
    request.changeUrl(
        requestData.url.replace('http://localhost:8000', 'http://myserver.dev')
    );
  }
}


问:
Group array data on one column and sum data from another column to form a flat associative array
I have my array data as shown below:

```<code>$array = [
    ['name' => 'Bank BRI', 'amount' => 0],
    ['name' => 'Bank BRI', 'amount' => 0],
    ['name' => 'Bank BCA', 'amount' => 1412341234],
    ['name' => 'Bank CIMB Niaga', 'amount' => 532532552],
    ['name' => 'Bank BRI', 'amount' => 34534534],
    ['name' => 'Bank CIMB Niaga', 'amount' => 453425243],
    ['name' => 'Bank BRI', 'amount' => 0],
    ['name' => 'Bank BNI', 'amount' => 124124],
    ['name' => 'Bank CIMB Niaga', 'amount' => 352345623],
    ['name' => 'Bank BCA', 'amount' => 23432423],
    ['name' => 'Bank Mandiri', 'amount' => 0],
    ['name' => 'Bank BCA', 'amount' => 0],
    ['name' => 'Bank BCA', 'amount' => 0],
    ['name' => 'Bank Permata', 'amount' => 352352353],
];
</code>```

How to sum 'amount' based on same 'bank name'.

My result should show grouped names and their summed amount:

```<code>array (
  'Bank BRI' => 34534534,
  'Bank BCA' => 1435773657,
  'Bank CIMB Niaga' => 1338303418,
  'Bank BNI' => 124124,
  'Bank Mandiri' => 0,
  'Bank Permata' => 352352353,
)
</code>```

答:
I would rather add </p>

```<code>$bankTotals = array();
foreach($amountsArray as $amount)
{
 if(isset($bankTotals[$amount['name']]))
    $bankTotals[$amount['name']] += $amount['amount'];
 else
    $bankTotals[$amount['name']] = $amount['amount'];
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have my array data as shown below:

$array = [
    ['name' => 'Bank BRI', 'amount' => 0],
    ['name' => 'Bank BRI', 'amount' => 0],
    ['name' => 'Bank BCA', 'amount' => 1412341234],
    ['name' => 'Bank CIMB Niaga', 'amount' => 532532552],
    ['name' => 'Bank BRI', 'amount' => 34534534],
    ['name' => 'Bank CIMB Niaga', 'amount' => 453425243],
    ['name' => 'Bank BRI', 'amount' => 0],
    ['name' => 'Bank BNI', 'amount' => 124124],
    ['name' => 'Bank CIMB Niaga', 'amount' => 352345623],
    ['name' => 'Bank BCA', 'amount' => 23432423],
    ['name' => 'Bank Mandiri', 'amount' => 0],
    ['name' => 'Bank BCA', 'amount' => 0],
    ['name' => 'Bank BCA', 'amount' => 0],
    ['name' => 'Bank Permata', 'amount' => 352352353],
];

How to sum 'amount' based on same 'bank name'.

My result should show grouped names and their summed amount:

array (
  'Bank BRI' => 34534534,
  'Bank BCA' => 1435773657,
  'Bank CIMB Niaga' => 1338303418,
  'Bank BNI' => 124124,
  'Bank Mandiri' => 0,
  'Bank Permata' => 352352353,
)

Body:
I would rather add

$bankTotals = array();
foreach($amountsArray as $amount)
{
 if(isset($bankTotals[$amount['name']]))
    $bankTotals[$amount['name']] += $amount['amount'];
 else
    $bankTotals[$amount['name']] = $amount['amount'];
}


问:
left join not getting expected data - returns inaccurate result
I am facing issue when trying retrieve some fields from table using left join.

Table 1 has - column reportno, slno, and desc
Table 2 has - Column report no, slno and parameters

Now i would like to retrieve all values from table1 for specific report no and and corresponding  parameters from table2. My expected result is shown below.
that means it should get all row for matching repno from table 1 and also get paramaters by matching repno and slno

/*table2 data*/
repno   slno  parameter
M100001 2     TypeRating
M100001 1     Type&Rating```
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>select
qc_item_list.i_rep_no,
qc_item_list.slno,
qc_item_list.ITEM_DESC,
qc_insp.parameters
from qc_item_list
left join qc_insp
on qc_item_list.I_REP_NO = qc_insp.I_REP_NO
WHERE qc_item_list.i_rep_no = 'M100001'
ORDER BY qc_item_list.slno</code>```

答:
Here is basic example of left join.

https://www.w3schools.com/sql/sql_join_left.asp

You must share both tables data and your expected output , than you can get help to fix your SQL.

Body:
I am facing issue when trying retrieve some fields from table using left join.

Table 1 has - column reportno, slno, and desc
Table 2 has - Column report no, slno and parameters

Now i would like to retrieve all values from table1 for specific report no and and corresponding  parameters from table2. My expected result is shown below.
that means it should get all row for matching repno from table 1 and also get paramaters by matching repno and slno

/*table2 data*/
repno   slno  parameter
M100001 2     TypeRating
M100001 1     Type&Rating

select
qc_item_list.i_rep_no,
qc_item_list.slno,
qc_item_list.ITEM_DESC,
qc_insp.parameters
from qc_item_list
left join qc_insp
on qc_item_list.I_REP_NO = qc_insp.I_REP_NO
WHERE qc_item_list.i_rep_no = 'M100001'
ORDER BY qc_item_list.slno


问:
ng2-file-upload 500 internal server issue
I have installed this ng2-file-upload package but i am having some problems while upload a image its showing me the following error in console

OPTIONS http://localhost:3000/api/ 500 (Internal Server Error)

XMLHttpRequest cannot load http://localhost:3000/api/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 500.

my api server.js file code is

```<code>var express = require('express');
var multer = require('multer');
var fs = require('fs');
var app = express();

var DIR = './uploads/';

var upload = multer({dest: DIR});

app.use(function (req, res, next) {
 res.setHeader("Access-Control-Allow-Methods",
    "POST, PUT, OPTIONS,   DELETE, GET");
    header('Access-Control-Allow-Origin: http://localhost:4200');

    header('Access-Control-Allow-Methods: GET, POST, PATCH,
    PUT, DELETE, OPTIONS');

    header('Access-Control-Allow-Headers: Origin, Content-Type');
    next();
});

 app.get('/api', function (req, res) {
  res.end('file catcher example');
 });

app.post('/api', function (req, res) {
 upload(req, res, function (err) {
    if (err) {
      return res.end(err.toString());
    }
    res.end('File is uploaded');
   });
});

var PORT = process.env.PORT || 3000;

app.listen(PORT, function () {
 console.log('Working on port ' + PORT);
});
</code>```

AdminComponent.ts code

```<code> import { FileSelectDirective, FileDropDirective, FileUploader,
 Headers  } from 'ng2-file-upload/ng2-file-upload';

 const URL = 'http://localhost:3000/api/';

@Component({
  selector  : 'app-admin',
  templateUrl   : './admin.component.html',
  styleUrls : ['./admin.component.css']
})
</code>```

答:
Replace this:

```<code>app.use(function (req, res, next) {
 res.setHeader("Access-Control-Allow-Methods",
    "POST, PUT, OPTIONS,   DELETE, GET");
    header('Access-Control-Allow-Origin: http://localhost:4200');

    header('Access-Control-Allow-Methods: GET, POST, PATCH,
    PUT, DELETE, OPTIONS');

    header('Access-Control-Allow-Headers: Origin, Content-Type');
    next();
});
</code>```

with

```<code>app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", 'http://localhost:4200');
    res.header("Access-Control-Allow-Credentials", true);
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
    res.header("Access-Control-Allow-Headers", 'Origin,X-Requested-With,Content-Type,Accept,content-type,application/json');
    next();
  });
</code>```

Body:
I have installed this ng2-file-upload package but i am having some problems while upload a image its showing me the following error in console

OPTIONS http://localhost:3000/api/ 500 (Internal Server Error)

XMLHttpRequest cannot load http://localhost:3000/api/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 500.

my api server.js file code is

var express = require('express');
var multer = require('multer');
var fs = require('fs');
var app = express();

var DIR = './uploads/';

var upload = multer({dest: DIR});

app.use(function (req, res, next) {
 res.setHeader("Access-Control-Allow-Methods",
    "POST, PUT, OPTIONS,   DELETE, GET");
    header('Access-Control-Allow-Origin: http://localhost:4200');

    header('Access-Control-Allow-Methods: GET, POST, PATCH,
    PUT, DELETE, OPTIONS');

    header('Access-Control-Allow-Headers: Origin, Content-Type');
    next();
});

 app.get('/api', function (req, res) {
  res.end('file catcher example');
 });

app.post('/api', function (req, res) {
 upload(req, res, function (err) {
    if (err) {
      return res.end(err.toString());
    }
    res.end('File is uploaded');
   });
});

var PORT = process.env.PORT || 3000;

app.listen(PORT, function () {
 console.log('Working on port ' + PORT);
});

AdminComponent.ts code

 import { FileSelectDirective, FileDropDirective, FileUploader,
 Headers  } from 'ng2-file-upload/ng2-file-upload';

 const URL = 'http://localhost:3000/api/';

@Component({
  selector  : 'app-admin',
  templateUrl   : './admin.component.html',
  styleUrls : ['./admin.component.css']
})

Body:
Replace this:

app.use(function (req, res, next) {
 res.setHeader("Access-Control-Allow-Methods",
    "POST, PUT, OPTIONS,   DELETE, GET");
    header('Access-Control-Allow-Origin: http://localhost:4200');

    header('Access-Control-Allow-Methods: GET, POST, PATCH,
    PUT, DELETE, OPTIONS');

    header('Access-Control-Allow-Headers: Origin, Content-Type');
    next();
});

with

app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", 'http://localhost:4200');
    res.header("Access-Control-Allow-Credentials", true);
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
    res.header("Access-Control-Allow-Headers", 'Origin,X-Requested-With,Content-Type,Accept,content-type,application/json');
    next();
  });


问:
Eclipse: "Update SVN cache" hangs and locks up
Every time I start eclipse, the program begins doing this "Update SVN cache" thing but it will sit at 0% forever. I cannot perform any operations (such as checking out my projects, building them, or even running them) until this operation is completed (which never happens). Also, whenever I try to type anything in the editor, the whole program freezes and I have to kill the process.

I have been searching google for the answer to this problem for days and have yet to come up with an answer. Has anyone else had a similar problem and found a solution?

I'd like to add that I've tried re installing eclipse, all its plugins, and the jdk from scratch. Nothing seems to be working.

答:
In my case I realized that a tortoise SVN explorer related windows was somewhere open. It probably locked the cache and eclipse was waiting for the unlock.

Not a direct answer to the question, but this might help for somebody making a similar mistake.


问:
How can i set double height to Imageview programmatically?
Image view takes int value programmatically but in some time height calculate in double so any one have suggestion which one procedure. I searched but did not get exact solution

Here is my code:

```<code>//--------calculate width and height
        int final_width;
        double final_height;
        final_width  = width - 40;
        final_height = ((final_width) * (0.75));
        Log.e("final height",""+final_height);
        imageView.getLayoutParams().width  = Utility.pxToDp(final_width,mContext);
        imageView.getLayoutParams().height = Utility.pxToDp(final_height,mContext);
</code>```

答:
The maximum range of int varies from 2147483647
-2147483648. So int is enough, you don't need a double. Otherwise you can typecast your value to int.

```<code>int intVal = (int) Math.floor(val);
</code>```

where value of val=some float.

Body:
Image view takes int value programmatically but in some time height calculate in double so any one have suggestion which one procedure. I searched but did not get exact solution

Here is my code:

//--------calculate width and height
        int final_width;
        double final_height;
        final_width  = width - 40;
        final_height = ((final_width) * (0.75));
        Log.e("final height",""+final_height);
        imageView.getLayoutParams().width  = Utility.pxToDp(final_width,mContext);
        imageView.getLayoutParams().height = Utility.pxToDp(final_height,mContext);

Body:
The maximum range of int varies from 2147483647
-2147483648. So int is enough, you don't need a double. Otherwise you can typecast your value to int.

int intVal = (int) Math.floor(val);

where value of val=some float.


问:
Custom Validator firing but it does not update the ValidationSummary
Hi I am working on a custom form field validator, it seems like the custom validator is working by not allowing it to continue to the next page, but it doesn't update the Validation Summary nor does it display the asterisk and the labels that i've made visable. I also have other validators like RequiredFieldValidator on the same field. My ValidationGroup is set, as is the Text and IsValid. I even wrote and set a dummy client side validation method in javascript as some workarounds suggests.

here is the validation summary code in asp.net

```<code><asp:ValidationSummary ID="ValidatorSummary" runat="server" ValidationGroup="Step2" />
</code>```

here is the custom validator and the required field one

```<code><asp:CustomValidator ID="AddressVerification" runat="server" ErrorMessage="Please enter a valid address." Display="Dynamic" ValidationGroup="Step2" OnServerValidate="AddressVerification_ServerValidate" ClientValidationFunction="CustomValidatorDummy" Text="*" Enabled="true" EnableClientScript="true"></asp:CustomValidator>
<asp:RequiredFieldValidator ID="RFValidatorHomeAddress" runat="server" ErrorMessage="Please enter home address." Text="*" Display="Dynamic" ValidationGroup="Step2" ControlToValidate="txtHomeAddress"></asp:RequiredFieldValidator>
</code>```

here is the custom validation method in the code behind

```<code>protected void AddressVerification_ServerValidate(object sender, ServerValidateEventArgs e)
{
//lets just say it doesn't validate and sets the IsValid to false
lblUspsValidatorResHomeCity.Visible = true;
lblUspsValidatorResHomeState.Visible = true;
lblUspsValidatorResHomeZip.Visible = true;
e.IsValid = false;
}
</code>```

please advise, thanks.

EDIT:
Answered - as bitxwise mentioned. the validation summary should be placed inside an update panel as well. Thanks!

Like so:

```<code><asp:UpdatePanel ID="UpdatePanelValidationSummaryHome" ChildrenAsTriggers="false" UpdateMode="Conditional"
runat="server">
<ContentTemplate>
    <asp:ValidationSummary ID="AddressHomeValidationSummary" runat="server" ValidationGroup="AddressHomeValidationGroup"
        CssClass="errors" />
</ContentTemplate>
</code>```

and then calling the update:

```<code>UpdatePanelValidationSummaryHome.Update();
</code>```

答:
You seem to be missing ControlToValidate in your declaration of CustomValidator.

EDIT

If your CustomValidator aggregates multiple controls, then try this:

ASPX

```<code><asp:TextBox ID="txtMyTextBox" runat="server" />
<asp:CustomValidator ID="AddressVerification" runat="server"
    Display="Dynamic"
    ErrorMessage="Please enter a valid address."
    OnServerValidate="AddressVerification_ServerValidate"
    Text="*"
    ValidationGroup="Step2" />
<asp:RequiredFieldValidator ID="rfvAddress" runat="server"
    ControlToValidate="txtMyTextBox"
    Display="Dynamic"
    ErrorMessage="Please enter an address"
    Text="*"
    ValidationGroup="Step2" />
...
<asp:ValidationSummary ID="ValidatorSummary" runat="server"
    ValidationGroup="Step2" />
...
<asp:Button ID="btnCheckAddresses" runat="server"
    CausesValidation="true"
    Text="Check Addresses"
    ValidationGroup="Step2" />
</code>```

CS

```<code>protected void AddressVerification_ServerValidate(object source, ServerValidateEventArgs args) {
    args.IsValid = !string.IsNullOrEmpty(txtMyTextBox.Text) && !txtMyTextBox.Text.Contains(' ');
}
</code>```

Note that the validation group of the control invoking the post back has CausesValidation="true" and has the same ValidationGroup as the validators.

EDIT 2

If your postback control was in the UpdatePanel but the ValidationSummary was not, then the partial postback would not have refreshed the ValidationSummary. Once you removed the postback control from the UpdatePanel, I imagine it would then generate a full postback, which would refresh your ValidationSummary.

I don't know what else is in your UpdatePanel, but many people report having issues with their validators being in UpdatePanel's.

Check out MSDN,

When you use the ValidationSummary
  control inside an UpdatePanel control,
  make sure that the validator control
  and the control it is associated with
  are in the same panel. For more
  information about using the
  UpdatePanel control for partial-page
  updates, see Partial-Page Rendering
  Overview.

as well as this MSDN blog.

Body:
Hi I am working on a custom form field validator, it seems like the custom validator is working by not allowing it to continue to the next page, but it doesn't update the Validation Summary nor does it display the asterisk and the labels that i've made visable. I also have other validators like RequiredFieldValidator on the same field. My ValidationGroup is set, as is the Text and IsValid. I even wrote and set a dummy client side validation method in javascript as some workarounds suggests.

here is the validation summary code in asp.net

<asp:ValidationSummary ID="ValidatorSummary" runat="server" ValidationGroup="Step2" />

here is the custom validator and the required field one

<asp:CustomValidator ID="AddressVerification" runat="server" ErrorMessage="Please enter a valid address." Display="Dynamic" ValidationGroup="Step2" OnServerValidate="AddressVerification_ServerValidate" ClientValidationFunction="CustomValidatorDummy" Text="*" Enabled="true" EnableClientScript="true"></asp:CustomValidator>
<asp:RequiredFieldValidator ID="RFValidatorHomeAddress" runat="server" ErrorMessage="Please enter home address." Text="*" Display="Dynamic" ValidationGroup="Step2" ControlToValidate="txtHomeAddress"></asp:RequiredFieldValidator>

here is the custom validation method in the code behind

protected void AddressVerification_ServerValidate(object sender, ServerValidateEventArgs e)
{
//lets just say it doesn't validate and sets the IsValid to false
lblUspsValidatorResHomeCity.Visible = true;
lblUspsValidatorResHomeState.Visible = true;
lblUspsValidatorResHomeZip.Visible = true;
e.IsValid = false;
}

please advise, thanks.

EDIT:
Answered - as bitxwise mentioned. the validation summary should be placed inside an update panel as well. Thanks!

Like so:

<asp:UpdatePanel ID="UpdatePanelValidationSummaryHome" ChildrenAsTriggers="false" UpdateMode="Conditional"
runat="server">
<ContentTemplate>
    <asp:ValidationSummary ID="AddressHomeValidationSummary" runat="server" ValidationGroup="AddressHomeValidationGroup"
        CssClass="errors" />
</ContentTemplate>

and then calling the update:

UpdatePanelValidationSummaryHome.Update();

Body:
You seem to be missing ControlToValidate in your declaration of CustomValidator.

EDIT

If your CustomValidator aggregates multiple controls, then try this:

ASPX

<asp:TextBox ID="txtMyTextBox" runat="server" />
<asp:CustomValidator ID="AddressVerification" runat="server"
    Display="Dynamic"
    ErrorMessage="Please enter a valid address."
    OnServerValidate="AddressVerification_ServerValidate"
    Text="*"
    ValidationGroup="Step2" />
<asp:RequiredFieldValidator ID="rfvAddress" runat="server"
    ControlToValidate="txtMyTextBox"
    Display="Dynamic"
    ErrorMessage="Please enter an address"
    Text="*"
    ValidationGroup="Step2" />
...
<asp:ValidationSummary ID="ValidatorSummary" runat="server"
    ValidationGroup="Step2" />
...
<asp:Button ID="btnCheckAddresses" runat="server"
    CausesValidation="true"
    Text="Check Addresses"
    ValidationGroup="Step2" />

CS

protected void AddressVerification_ServerValidate(object source, ServerValidateEventArgs args) {
    args.IsValid = !string.IsNullOrEmpty(txtMyTextBox.Text) && !txtMyTextBox.Text.Contains(' ');
}

Note that the validation group of the control invoking the post back has CausesValidation="true" and has the same ValidationGroup as the validators.

EDIT 2

If your postback control was in the UpdatePanel but the ValidationSummary was not, then the partial postback would not have refreshed the ValidationSummary. Once you removed the postback control from the UpdatePanel, I imagine it would then generate a full postback, which would refresh your ValidationSummary.

I don't know what else is in your UpdatePanel, but many people report having issues with their validators being in UpdatePanel's.

Check out MSDN,

When you use the ValidationSummary
  control inside an UpdatePanel control,
  make sure that the validator control
  and the control it is associated with
  are in the same panel. For more
  information about using the
  UpdatePanel control for partial-page
  updates, see Partial-Page Rendering
  Overview.

as well as this MSDN blog.