text:
Q: PHP (PDO) file to send mail with multiple query i have this php code using which i want to send email to the user. Once the mail is sent, a pop-up will specify that the mail has been sent. However, as I type the basic structure of the mail body, i am getting error when i try to include the information in a table. below are the codes and the error:
PHP (to send email) (sendmail.php)
<?php
include_once "connect.php";
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);

$form=$_POST;
$accountnumber=$form['accountnumber'];
$trade=$form['tradetype'];
$metal=$form['metal'];
$amount=$form['amount'];
$date=$form['date'];

$stmt = $conn->prepare("SELECT * FROM Customers WHERE CustomerCode='$accountnumber'");
  while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {

$stmt1 = $conn->prepare("SELECT * FROM Contracts WHERE Trade='$trade' AND Metal='$metal' AND Amount='$amount' AND ExpiryDate='$date'");
  while ($row1 = $stmt1->fetch(PDO::FETCH_ASSOC)) {

 $to= $row['Email'];
 $subject= "Bullion Assets Management_Trade Order Confirmation - <?php print strftime('%d %B %Y');?>
 $body = "
;
 $body .="
";
 $body .=""Dear $row['Name']; "	"
 $body .="
";
 $body .="
";
 $body .=""Fixed Minimum $trade Price Pre-Order Confirmation"	";
 $body .="
";
 $body .="
";
 $body .=""1) Bullion Assets Management Pte Ltd confirms receipt and accepts your pre-order to $trade $amount of 9999 Pooled Allocated $metal Loco Singapore ("$metal") on $date London PM Fix at minimum fixed price at USD or higher."	";
 $body .="
";
 $body .="
";
 $body .=""2) This pre-order will enable a discount of USD $row1['DiscountPremium']; per oz ( notional value USD $row1[DiscountPremium'];*$amount ) upon your $metal purchase."	";
 $body .="
";
 $body .="
";
 $body .=""3) <<IMPORTANT>> - If the PM FIX on the above date is below USD $row1['Price']; per troy oz, you will still be obligated to buy at the minimum price of USD  $row1['Price']; per troy oz."	";
 $body .="
";
 $body .="
";
       if(isset($trade='Buy') {
 $body .=""4) A deposit of SGD 5000 will be required for your pre-order. This deposit will be used to offset the purchase amount upon your $metal purchase."	";
       } else {
 $body .=""4) No deposit is required for your pre-order."	";
       }
 $body .="
";
 $body .="
";
 $body .=""5) The pre-order minimum buying price and discount cannot be changed or cancelled upon signed confirmation of this order. You can however submit a new selling order at the PM Fix if you do not wish to proceed with your $metal purchase and collection."	";
 $body .="
";
 $body .="
";
 $body .=""6) Settlement and/or collection of $metal from Bullion Assets Management Pte Ltd is to be completed within 2 business days from $date."	";
 $body .="
";
 $body .="
";
 $body .=""This acknowledgement by you is subject to and constitutes a supplement to the Customer Agreement signed between you and Bullion Assets Management Pte Ltd."	";
 $body .="
";
 $body .="
";
});
});
$conn-->close();

        $headers = From: "ashwini@goldsilvercentral.com.sg";
        $headers .= 'MIME-Version: 1.0\r\n';
        $headers .= 'Content-Type: text/html; charset=\"iso-8859-1\"\n';
        $headers .= 'X-Priority: 1\r\n';
        $headers .= 'X-MSMail-Priority: High\n';
        $headers .= 'X-Mailer: PHP". phpversion() ."\r\n';

       mail($to, $subject, $body, $headers );
       echo "Your Order has been submitted";
 }
?>

Jquery for the above php file
 $('#confirm_btn').click(function() {

    var accountnumber = $('#accountnumber').val();
    var tradetype = $('input.tradetype:checked').val();
    var amount = $('#amount').val();
    var metal = $('input.metal:checked').val();
    var date = $('#date').val();

    $.ajax({
      type: "POST", /* METHOD TO USE TO PASS THE DATA */
      url: "sendorder.php", /* THE FILE WHERE YOU PROCESS THE SELECT QUERY */
      data: {"accountnumber": accountnumber, "tradetype": tradetype, "amount": amount, "metal": metal, "date":  date}, /* THE DATA WE WILL SUBMIT TO retrievepremordisc.php */
      success: function(data){
              successmessage = 'sucess';
      }
    });
  });

So the error i get is for the php file:
Parse error: syntax error, unexpected '>' in on line 20 ( $body = ";)
any suggestions as to the error?
also, how do i get the pop-up to appear? thank you in advance!

A: You have a number of errors in your code, mostly related to the way you are trying to concatenate your strings but also with how you are accessing variables and terminating your while loops. Here is your code cleaned up a bit. I cant test it on my end to make sure this will work as expected but it should at least get you on the right path.
PHP
include_once "connect.php";
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);

$accountnumber = isset($_POST['accountnumber']) ? $_POST['accountnumber'] : NULL;
$trade = isset($_POST['tradetype']) ? $_POST['tradetype'] : NULL;
$metal = isset($_POST['metal']) ? $_POST['metal'] : NULL;
$amount = isset($_POST['amount']) ? $_POST['amount'] : NULL;
$date = isset($_POST['date']) ? $_POST['date'] : NULL;
$stmt = $conn->prepare("SELECT * FROM Customers WHERE CustomerCode='$accountnumber'");
$failedEmails=0;
$sentEmails=0;
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    $stmt1 = $conn->prepare("SELECT * FROM Contracts WHERE Trade='$trade' AND Metal='$metal' AND Amount='$amount' AND ExpiryDate='$date'");
    while ($row1 = $stmt1->fetch(PDO::FETCH_ASSOC)) {
        $to = $row['Email']; // what are you trying to do here? are you attempting to send the email to serevral addresses at once?
        $subject = 'Bullion Assets Management_Trade Order Confirmation -' . strftime('%d %B %Y');

        if (isset($trade) && $trade == 'Buy') {
            $deposit = '4) A deposit of SGD 5000 will be required for your pre-order. This deposit will be used to offset the purchase amount upon your $metal purchase.	';
        } else {
            $deposit = '4) No deposit is required for your pre-order.	';
        }
        $body = '
' .
            '
Dear' . $row['Name'] . '
' .
            '
Fixed Minimum ' . $trade . ' Price Pre-Order Confirmation
' .
            '
1) Bullion Assets Management Pte Ltd confirms receipt and accepts your pre-order to $trade $amount of 9999 Pooled Allocated $metal Loco Singapore ("' . $metal . '") on $date London PM Fix at minimum fixed price at USD or higher.
' .
            '
2) This pre-order will enable a discount of USD ' . $row1['DiscountPremium'] . ' per oz ( notional value USD ' . $row1['DiscountPremium'] * $amount . ') upon your $metal purchase.
' .
            '
3) <<IMPORTANT>> - If the PM FIX on the above date is below USD ' . $row1['Price'] . ' per troy oz, you will still be obligated to buy at the minimum price of USD ' . $row1['Price'] . '  per troy oz.
' .
            '
' . $deposit . '
' .
            '
5) The pre-order minimum buying price and discount cannot be changed or cancelled upon signed confirmation of this order. You can however submit a new selling order at the PM Fix if you do not wish to proceed with your $metal purchase and collection.
' .
            '
"6) Settlement and/or collection of $metal from Bullion Assets Management Pte Ltd is to be completed within 2 business days from $date.
' .
            '
This acknowledgement by you is subject to and constitutes a supplement to the Customer Agreement signed between you and Bullion Assets Management Pte Ltd.
' .
            '
';

        $headers = 'From: ashwini@goldsilvercentral.com.sg';
        $headers .= 'MIME-Version: 1.0\r\n';
        $headers .= 'Content-Type: text/html; charset=\"iso-8859-1\"\n';
        $headers .= 'X-Priority: 1\r\n';
        $headers .= 'X-MSMail-Priority: High\n';
        $headers .= 'X-Mailer: PHP". phpversion() ."\r\n';

        mail($to, $subject, $body, $headers) ? $sentEmails++ : $failedEmails++;
    }
}

if ($failedEmails==0) echo json_encode(['success' => true, 'message' => 'Your Order has been submitted']);
else echo json_encode(['success' => false, 'message' => 'There was a problem submitting your order. Only '.$sentEmails.' of '.($sentEmails+$failedEmails).' emails were sent.']);
$conn-- > close();

jQuery
$('#confirm_btn').click(function () {
    var accountnumber = $('#accountnumber').val();
    var tradetype = $('input.tradetype:checked').val();
    var amount = $('#amount').val();
    var metal = $('input.metal:checked').val();
    var date = $('#date').val();

    $.ajax({
        type: "POST", /* METHOD TO USE TO PASS THE DATA */
        url: "sendorder.php", /* THE FILE WHERE YOU PROCESS THE SELECT QUERY */
        dataType: 'json',
        data: {
            "accountnumber": accountnumber,
            "tradetype": tradetype,
            "amount": amount,
            "metal": metal,
            "date": date
        }, /* THE DATA WE WILL SUBMIT TO retrievepremordisc.php */
        success: function (data) {
            if(data.success='true'){
                alert(data.message);
                // order was submitted
            }
            else{
                alert(data.message);
                // order was NOT submitted
            }
        },
        error: function (xhr, status, error) {
            console.log(xhr.responseText);
        }
    });
});


text:
Q: Sketch of Spivaks proof of the Inverse Function Theorem for Multivariable functions Below is the proof of the inverse function theorem for multivariable functions given in Spivaks "Calculus on Manifolds".  I have made a few interpretations regarding his reasoning and want to know if I have interpreted correctly.

*

*He spends the majority of the first part of the proof proving that $f$ is bijective, as this implies the existence of an inverse.

*The only time we use that $Df(a)=I$ is when we define $\mu=Df(a)$ and write $\mu^{-1}\big(f(x_1)-f(x)\big)=\mu^{-1}\big(\mu(x_1-x)+\phi(x_1-x)\big)$ $=$ $\mu^{-1}\big(\mu(x_1-x)\big)+\mu^{-1}\big(\phi(x_1-x)\big)$, since $\mu=I$ implies that $\mu^{-1}=\mu=I$ ,which gives that $\mu^{-1}$ is linear.  Besides that I don't see any other application of the property $Df(a)=I$ we established in the opening lines of the proof.

*$detf'(a)\neq 0$ is only used in the proof to guarantee that there exists a neighborhood around $f'(a)$ such that every element is non-zero; and then this implication is used to show that we must have $y^{i}-f^i(x)=0$, $\forall i$

Thanks in advance!

A: No, the main thing you've overlooked is that he uses $Df(a)=I$ in a crucial way when he considers $g(x)=f(x)-x$ to prove 4. (Intuitively, if $Df(a)=I$, then near $a$ the function $f$ is close to the identity function.) And, no, $\det Df(a)\ne 0$ is used to know that $Df(a)$ is invertible. That's what makes the whole proof get started.

A: Assuming $Df = I$ is only a simplification, and nothing deep there. Only invertibility matters here.
A crucial part/corollary of IFT is that an open set is mapped to an open set, and not a singular formation at $f(x_0)$. This is somewhat under-emphasized in this proof.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Send the file.getAbsolutePath() from JFileChooser as a parameter to another button I have a small problem with a Java app. I'm using a JFileChooser to open up a text file, display its content on a textzone, while keeping it ready for some other actions.
One of these actions are calling a method when pressing an 'analyse' button in my GUI. My problem is that it seems like I can't change the header of the action listeners on the JFrame class, in order to put the file.getAbsolutePath() as an out from the JFileChooser to the buttons action listener.
Below is the code I have. Basically I want the "test.txt" to be replaced with the file I open in the JFileChooser.
How do I solve this problem ?
  private void OuvrirActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    int returnVal = fileChooser.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fileChooser.getSelectedFile();
        try {
            // What to do with the file, e.g. display it in a TextArea
            textarea.read(new FileReader(file.getAbsolutePath()), null);
        } catch (IOException ex) {
            System.out.println("problem accessing file" + file.getAbsolutePath());
        }
    } else {
        System.out.println("File access cancelled by user.");
    }
}

private void FermerActionPerformed(java.awt.event.ActionEvent evt) {
    System.exit(0);         // TODO add your handling code here:
}

private void traiterActionPerformed(java.awt.event.ActionEvent evt) {
    Reader readme = new Reader();
    ArrayList<String[]> Noms = new ArrayList<String[]>();
    readme.file2string("test.txt", Noms);
    // TODO add your handling code here:
}

edit : I solved the issue. All I had to do was to use the fileChooser.getSelectedFile() everytime I needed to use the file elsewhere.

A: I solved the issue. All I had to do was to use the fileChooser.getSelectedFile() everytime I needed to use the file elsewhere.


text:
Q: I am getting error in below line. How can correct it? or have i implemented wrong way? I am making chat-server program. I want to check my currentUser is not null then it will work. but it gives me error.
error: invalid operands to binary != (have 'User {aka struct User}' and 'void *')
     if(currentUser != NULL)
i expect that "if condition" should be correct.

A: The error message clearly indicates what's wrong: currentUser is of type struct User, but in order to compare it to NULL, it should be a pointer type (i.e. struct User*).


text:
Q: Trouble getting revision number out of svn for spec file I'm working on a spec file where I want to use the revision number of the SVN repo as part of the version number.
If I use just:
%(svnversion -c %{sourcedir})

Then I get PackageName-1-209:299 where 299 is the revision number. So I am trying to crop out the "1-209" section as it's consistently there and doesn't change.
The line I'm having issues with is:
%(svnversion -c %{sourcedir} | sed 's/^1\-209://')

What I seem to get out from this is PackageName209:299 still.
Any help would be much appreciated!

A: You probably should try another regular expression:
%(svnversion -cn %{sourcedir} | sed -r 's/.+://')

However, note that svnversion may also add some letters in the end (M if there are local modifications, S - if it is the switched working copy). Do you need to check them - is up to you.
PS
There is a faster way to get the current revision (since svnrevision requests svn server to collect data) described here:
grep revision .svn/entries |  awk -F\" '{print $2}'

However, this will not work for svn since version 1.7.


text:
Q: Unity script only working on one gameobject This script in short changed the color of the gameobject it's attached to when the bullet goes through it.
`
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class targetHit : MonoBehaviour
{
    public Material oldMat;
    public Material newMat;
    Renderer rend;

    // Start is called before the first frame update
    void Start()
    {
        rend = GetComponent<Renderer>();
    }

    // Update is called once per frame
    void Update()
    {

    }

    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "bullet")
        {
            hitTarget();
        }
    }

    void hitTarget()
    {
        rend.material = newMat;
        StartCoroutine("waitThreeSeconds");
    }

    IEnumerator waitThreeSeconds()
    {
        yield return new WaitForSeconds(3);
        rend.material = oldMat;
    }
}

`
However it only works on the game object highlighted in the image attached.
Image

A: It may be because rend = GetComponent(); called in Start, if image not attached to Gameobejct, rend will be null. So without image component attached to the GameObject, this script will not work.

A: Assuming you assigned the material files in the inspector, instead of assigning the "rend" variable on start, try instead assigning it the same way, for all GameObjects that use the script. Please let me know if this does not work.


text:
Q: Trigger logout.html page on clicking Logout in angular Js I am working on logout functionality. On click of logout button which is kept in the navigation bar . I should open logout .html which contains a message saying that the user logged out now. I was able to achieve this but the navigation bar is still there . I am calling logout component using ui-sref.
Appreciate your help in guiding me to show just logout.html without the navigation bar.
import UiRouterModule = require('angular-ui-router');
import * as angular from 'angular';

const mod = angular.module('logout.routing', [
<any>UiRouterModule
]);

const moduleName = mod.name;

mod.config(($stateProvider) => {
$stateProvider
.state('logout', {
url: '/logout',
template: `<logout></logout>`
});
});

export { moduleName as LogoutRoutingModule };


text:
Q: Results of layers created with a custom CRS are loaded with a generated CRS in QGIS I have created a custom CRS for El Salvador using this parameters in a proj.4 string, based on this question:
+proj=lcc +lat_1=13.31666666666667 +lat_2=14.25 +lat_0=13.783333 +lon_0=-89 +x_0=500000 +y_0=295809.184 +k_0=0.99996704 +ellps=clrk66 +units=m +no_defs +towgs84=0,125,194,0,0,0,0 +wktext

I added +wktext to my string based on this answer. I set this CRS for my layers. I have also set the project CRS to this custom CRS. When I perform an operation using some tools, the result is loaded in the layers panel with a generated CRS. This is the generated CRS (sorry it's in spanish):

It's similar to the original, but without the +towgs84 and +wktext parameters.
It works when I save a shapefile or when I use some GDAL Tools that ask for a CRS. It doesn't work if I use some GDAL tools like GDAL Rasterize or some GRASS tools like r.surf.contour. Is there a way all the layers created with inputs with a custom CRS are loaded with this custom CRS?

A: Roundup answer from the comments:
It seems that datum shift and +wktext are arbitrary supported in GDAL and QGIS.
Take a screenshot in Web Mercator and warp it to your custom CRS:
gdalwarp -overwrite -dstnodata 0 -s_srs EPSG:3857 -t_srs "+proj=lcc +lat_1=13.31666666666667 +lat_2=14.25 +lat_0=13.783333 +lon_0=-89 +x_0=500000 +y_0=295809.184 +k_0=0.99996704 +ellps=clrk66 +units=m +no_defs +towgs84=0,125,194,0,0,0,0 +wktext" -of GTiff ElSalvador.png ElSalvadorNAD27.tif
gdalsrsinfo ElSalvadorNAD27.tif >out.txt

and you get:
PROJ.4 : '+proj=lcc +lat_1=13.31666666666667 +lat_2=14.25 +lat_0=13.783333 +lon_0=-89 +x_0=500000 +y_0=295809.184 +ellps=clrk66 +towgs84=0,125,194,0,0,0,0 +units=m +no_defs '

OGC WKT :
PROJCS["unnamed",
GEOGCS["Clarke 1866",
    DATUM["unknown",
        SPHEROID["clrk66",6378206.4,294.9786982138982],
        TOWGS84[0,125,194,0,0,0,0]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]],
PROJECTION["Lambert_Conformal_Conic_2SP"],
PARAMETER["standard_parallel_1",13.31666666666667],
PARAMETER["standard_parallel_2",14.25],
PARAMETER["latitude_of_origin",13.783333],
PARAMETER["central_meridian",-89],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",295809.184],
UNIT["metre",1,
    AUTHORITY["EPSG","9001"]]]

Datum shift is correctly implemented in Proj.4 string and WKT.
Take a vector file in WGS84, and convert it to the same CRS using ogr2ogr:
ogr2ogr -s_srs EPSG:4326 -t_srs "+proj=lcc +lat_1=13.31666666666667 +lat_2=14.25 +lat_0=13.783333 +lon_0=-89 +x_0=500000 +y_0=295809.184 +k_0=0.99996704 +ellps=clrk66 +units=m +no_defs +towgs84=0,125,194,0,0,0,0 +wktext" LimitesNAD27.shp dptoA_WGS_1984.shp
gdalsrsinfo LimitesNAD27.prj >>out.txt

outputs:
PROJ.4 : '+proj=lcc +lat_1=13.31666666666667 +lat_2=14.25 +lat_0=13.783333 +lon_0=-89 +x_0=500000 +y_0=295809.184 +ellps=clrk66 +units=m +no_defs '

OGC WKT :
PROJCS["Lambert_Conformal_Conic",
GEOGCS["GCS_Clarke 1866",
    DATUM["unknown",
        SPHEROID["clrk66",6378206.4,294.9786982]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]],
PROJECTION["Lambert_Conformal_Conic_2SP"],
PARAMETER["standard_parallel_1",13.31666666666667],
PARAMETER["standard_parallel_2",14.25],
PARAMETER["latitude_of_origin",13.783333],
PARAMETER["central_meridian",-89],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",295809.184],
UNIT["Meter",1]]

So the datum shift gets dropped. If you do the same in QGIS, a .qpj file is created, including the datum shift values. This is good inside QGIS, but not if you run external commands.
As a sidenote, you see that the scale factor gets dropped. According to http://geotiff.maptools.org/proj_list/lambert_conic_conformal_2sp.html, LCC 1SP with a scale factor is basically the same as LCC 2SP.
If you run gdalsrsinfo on the original LambertNAD27 files from http://www.cnr.gob.sv/geoportal-cnr/, you get:
PROJ.4 : '+proj=lcc +lat_1=13.31666666666667 +lat_2=14.25 +lat_0=13.783333 +lon_0=-89 +x_0=500000 +y_0=295809.184 +datum=NAD27 +units=m +no_defs '

which does not help at all, because datum=NAD27 redirects to the grid shift files for USA and Canada, ignoring Central American states that used NAD27 as well. EPSG favours Ocotepeque datum for El Salvador, which contradicts the shapefile CRS info.
So my best advice is to use the WGS84 data from http://www.cnr.gob.sv/geoportal-cnr/ , convert them to UTM 16N (EPSG:32616), and work on with that. You will have no datum shift problem, unless you need sub-meter accuracy.
BTW the 3-parms datum shift for NAD27 is not very accurate, and Ocotepeque possibly neither. El Salvador has now introduced SIRGAS2007 for sub-meter accuracy, but no transformation parameters from old to new data have yet been published.


text:
Q: Analysis method for Vegetation category change I have a data set showing vegetation change over a 100 year period. The data is categorical (ie. Conifer, Deciduous, Mixedwood, Grassland, Shrub, Open Canopy forest, non vegetated). Each cell in my data set represents a hectare. The data is discontinuous (I can only see 59% of the actual landscape, as some parts are hidden from view), and there is no data source to fill the holes.
I can account for all of the landscape change that is reversed succession (ie. anything that went from Coniferous to grassland) with ancillary data about known disturbances (fire, development, roads etc). I now want to understand what has driven the forward succession of some key transitions (ie. areas that were grassland in 1909 may now be Conifer, or Deciduous, etc). I have topographic data, solar insolation, natural subregions as predictors.
I am currently stuck trying to understand what analysis method I can use to model this relationship
(ie. For Vegetation = Grassland in 1909, and for Vegetation = more advanced than grassland in 2008, what are the driving forces and correlates).
I am seeking ideas for analysis methods...
 preferably ArcGIS, but I can dig into other software if necessary


text:
Q: Internal users can't access external website I know this question has been posed many times with slightly different scenarios. Here is the issue I'm running into:
Our local domain has three window server 2012 running active directory, dns, IIS, and SQL server.
Our internal domain is the same as our external website. We recently moved to a new host and internal users can't access our website via domain.com or www.domain.com
We have created a new www entry in our local dns that points to the IP address of the externally hosted website. But internal users are still redirected to the IIS homepage when trying to reach the domain.
There are several blank host A records point to the ips of our internal servers, so I created a new blank record pointing to the external IP address of our website and deleted the other blank a records. This fixed the problem for a while (users were able to access the external website), but then the other blank A records reappeared and users can no longer access the external website. Maybe one of the other servers on our network is acting as a backup DNS and repropagated the old blank A records that point to our local servers? How to fix? Thank you.

A: See: My public website name and AD domain name are the same. How can I get to my external website from inside my network?
The gist: It is specifically recommended by Microsoft that you do not make your AD Domain the same as your website. Your problem is one of the reasons why. Best recommendation is to change your AD Domain to something else.


text:
Q: jQuery .slideToggle not producing screen changes I am trying to get the #webdsn-drop div to appear when the #web is hovered over. I am using the .slideToggle jQuery but nothing happens when I scroll over it/ hover or click. I'm not sure where I've gone wrong. I also want the website to start with the webdsn-drop hidden.
The HTML is:
<!DOCTYPE html>

<link rel="stylesheet" type="text/css" href="main.css">

PORTFOLIO

    Logo Design
    Business Cards
    Posters & Flyers
    Website Design

WEBSITE DESIGN

The CSS is:
body {
    background-color: #383838;
}

/*--------------Navigation Bar------------*/

#navbar {
    width: 100%;
    background-color: #fcfcfc;
    overflow: auto;
    position: fixed;
    left: 0px;
    top: 0px;
    overflow: hidden;
    z-index: 10;

}

#nav-container {
    max-width: 950px;
    min-width: 745px;
    margin: 0 auto;

}

#nav-container h1 {
    float: left;
    margin: 0 auto;
    padding-top: 10px;
    font-family: "calibri light";
    font-size: 25px;
    letter-spacing: 0.3em;
    margin-left: 5px;
    transition: color 0.3s ease;

}

#nav-container a {
    float: right;
    display: block;
    padding: 15px 15px;
    text-decoration: none;
    color: black;
    font-family: "calibri light", sans-serif;
    font-size: 18px;
    transition: background-color 0.5s ease;

}

#nav-container a:hover {
    background-color: #f4f4f4;
    transition: background-color 0.5s ease;
}

#nav-container a:active {
    background-color: #bfbfbf;
}

#nav-container h1:hover {
    color: #aaaaaa;
    transition: color 0.3s ease;
}

#border{
    width: 950px;
    margin: 0 auto;
}

#border h1{
    position: absolute;
    border: solid;
    border-color: white;
    border-width: 1px;
    display: inline;
    padding: 10px 20px;
    border-radius: 10px;
}

#webdsn-drop{
    background-color: #3f3f3f;
    margin-top: 50px;
    width: 100%;
    position: fixed;
    left: 0px;
    top: 0px;
    z-index: 9;
    font-family: 'calibri light';
    font-size: 12px;
    letter-spacing: 5px;
    height: 400px;
    color: white;

}

My jQuery is:
 $(document).ready(function(){
    $('#web').hover(function() {
  $('#webdsn-drop').slideDown();
}, function() {
  $('#webdsn-drop').slideUp();
});

});

A: Start #webdsn-drop with display:none so it's hidden when you first load the page:

WEBSITE DESIGN

Then, since you're using hover, I'd suggest explicitly using slideDown and slideUp to show and hide the div when you hover and unhover:
$('#web').hover(function() {
  $('#webdsn-drop').slideDown();
}, function() {
  $('#webdsn-drop').slideUp();
});

Working fiddle: https://jsfiddle.net/n0qne6gx/1/
(Sorry, Stack Overflow snippets appear to be broken at the moment, so I can't share the working code inline.)


text:
Q: PhantomJS and Unicode Block 'Private Use Area' PhantomJS has an issues with unicode private blocks. I didn't found any references about it.
The test is very simple just render this test page and you will get the results.
Has anyone a resolution for this?

A: The Private Use Area is one of the blocks allocated for private use codepoints,  often called "private use characters", though this is really misleading. The Unicode FAQ says: "Private-use characters are code points whose interpretation is not specified by a character encoding standard and whose use and interpretation may be determined by private agreement among cooperating users."
Thus, a private use codepoint has no meaning unless one is assigned, by an agreement between interested partied. You should not expect it to be rendered in any useful way. Programs typically render them using some generic glyph, or no glyph, or e.g. a box containing the code number.
However, fonts may have glyphs representing characters (typically, characters not yet encoded in Unicode). This is completely font-dependent, though the idea is that such allocating reflects some private agreement on the use of private use code points.


text:
Q: ASP.NET DropDown List position is lost when user typing pauses One of my end-users just reported an odd problem in an ASP.NET 2.0 application, which I've confirmed, but which seems rather odd to me.  I have a DropDownList control on my web form, which displays several dozen different items.  The easiest method for them to navigate the list is by typing the first several letters of the item they want to select.  No problem, and we're all familiar with this approach.
The issue arises when they pause typing, wait a second or so (to consult a document for a serial number, for example), and then resume typing the next letters of their target selection.  As soon as they resume typing, the position they had in the list is ignored, and the cursor moves to the value which begins with the new sequence of characters they have keyed in.  For example, if they are trying to select a value of "PREAMBLE", and they type the letters PRE, the first item containing "PRE" is highlighted.  However, if they pause for a moment, then continue with "AMBL", the list jumps back to the beginning, and the first list item containing "AMBL" is highlighted.  Since the users are typing serial numbers in one of the dropdowns, this habit of pausing for a moment is completely natural, but it also causes them some frustration, as they have to type in a longer string of characters without stopping.
I've tested this on Chrome and Internet Explorer and Firefox, so I conclude it isn't browser specific.  Is there a time paramater I can adjust on the dropdown list, to allow for a longer pause?  Is there a way to disable the behavior I've described here?  I can duplicate the behavior on a list with as few as seven items.  On a list of seven items, it isn't a problem, but on a list with a hundred items, it gets to be a hassle.
Any insight in to this would be most appreciate, as would any suggestions on how to avoid it from happening, especially if I can disable it on a control by control basis.  Thanks in advance!

A: what you are witnessing is the normal behavior of any dropdown..
till you keep typing it works as an auto complete.. but as soon as you stop it starts to search again in the list of item it comtains
if you wanna just keep the current state of the also.. then look for solutions like Jquery AutoComplete present here and it will keep the state and will give due importance to all the characters typed the problem that you might face with it is that it is applied on a textbox but then it would be easier for users to type all the way and look for hints simultaneously


text:
Q: Solving probability problem with given information that doesn't add up I hope you all are doing okay.
I have a quick question regarding a probability problem that I've been struggling to solve.
This is what we were given $$\Pr(A^c) = 2\Pr(A)\\ \Pr(A|B^c)=.2 \\ 2\Pr(B|A) = .2 $$
So I've started working on it.  First, trying to find $\Pr(A)$: $$1-\Pr(A) = 2\Pr(A) \\ 1 = 3\Pr(A) \\ \frac{1}{3} = \Pr(A)$$.
Then, trying to find $Pr(A\cap B)$: $$\Pr(B|A)=.1 \\ \frac{\Pr (A \cap B)}{\Pr(A)} = .1 \\ \Pr(A \cap B) = \frac{1}{30}$$
I only need $\Pr(B)$ now. Let's use infromation from $2\Pr(B|A)$: $$2\Pr(B|A) = .2 \\ 2[1-\Pr(B^c|A)] = .2 \\ 1-\Pr(B^c|A) = .1 \\ 1- \frac{\Pr(B^c \cap A)}{\Pr(A)} = .1 \\ 1 - \frac{\Pr(B^c \cap A}{\frac{1}{3}} = .1 \\ \Pr(B^c \cap A) = .3$$
Thus,  since $\Pr(A|B^c)=.2$, and $\Pr(A|B^c) = \frac{\Pr(A \cap B^c)}{\Pr(B^c)}$, we observe: $$ .2 = \frac{.3}{\Pr(B^c)} \\ \Pr(B^c) = \frac{.3}{.2} = 1.5$$
Which isn't right at all.  I can't really figure out what I'm doing wrong here and I would absolutely appreciate your help.

A: Your calculations are correct. The problem is that the conditions are inconsistent, leading to a nonsensical result.
Another way to compute $P(B^c)$ is to rearrange the second two conditions:
$$
P(A\cap B^c) = .2 P(B^c)
$$
$$
P(B\cap A) = .1 P(A)
$$
Add the two equations, using $P(A) = P(A\cap B) + P(A\cap B^c)$:
$$
P(A) = .2 P(B^c) + .1 P(A)
$$
Given $P(A)=\frac13$, we solve for $P(B^c)$ and obtain $1.5$ again.

A: You may indeed obtain absurd results while using valid reasoning but inconsistent facts.
These facts are inconsistent.

Let us take $\Pr(A^\complement)=2\Pr(A)$ and $2\Pr(B\mid A)=0.2$ as given, and derive $\Pr(A\mid B^\complement)$ to compare.
We have $\Pr(A)=1/3$ as you obtained, $\Pr(B\mid A)=1/10$ as is clear, and so $\Pr(A\cap B)=1/30$ by definition: $\Pr(A\cap B)=\Pr(A)\Pr(B\mid A)$
Likewise by definition, $\Pr (B\mid A)=\Pr(A\cap B)\div\Pr(B)$.
Therefore: $~\Pr(B)~{=\Pr(A\cap B)\div\Pr(B\mid A)\\=\tfrac 1{30}\div\tfrac 1{10}\\=\tfrac 13}\\\Pr(B^\complement)=\tfrac 23$

By Law of Total Probability: $\Pr(A\cap B^\complement)~{=\Pr(A)-\Pr(A\cap B)\\=\tfrac 13-\tfrac 1{30}\\=\tfrac{3}{10}}$

Therefore $\Pr(A\mid B^\complement)~{=\dfrac{3/10}{2/3}\\=1/20\\=0.05}$
Not $0.2$ as claimed.  Therefore the three facts, which you were provided, are inconsistent.

You will obtain different results for $\Pr(B^\complement)$ depending on which two of the three 'facts' you choose to derive it.


text:
Q: how to null a variable of type float My code is working if my float variable is set to 0, but I want  my code to work if my  variable is null.  How could I do that?  Here is a code snippet I wrote:
float oikonomia= (float)((float)new Float(vprosvasis7.getText().toString()));

                         if(oikonomia==0){

I have tied if(oikonomia==null) or if(oikonomia=null) but it is not working.
P.S.: Another way would be to initially set oikonomia=0; and, if the users change it, go to my if session.  This is not working either.
Float oikonomia = Float.valueOf(vprosvasis7.getText().toString());
                     if(oikonomia.toString() == " "){

float oikonomia= (float)((float)new Float(vprosvasis7.getText().toString()));
                  oikonomia=0;
                         if(oikonomia==0){

that way is not working too:
Float oikonomia = Float.valueOf(vprosvasis7.getText().toString());

                         if(oikonomia.toString() == " "){

A: Floats and floats are not the same thing.  The "float" type in Java is a primitive type that cannot be null.

A: If you want a nullable float, then try Float instead of float
Float oikonomia= new Float(vprosvasis7.getText().toString());

But it will never be null that way as in your example...
EDIT: Aaaah, I'm starting to understand what your problem is. You really don't know what vprosvasis7 contains, and whether it is correctly initialised as a number. So try this, then:
Float oikonomia = null;

try {
  oikonomia = new Float(vprosvasis7.getText().toString());
}
catch (Exception ignore) {
  // We're ignoring potential exceptions for the example.
  // Cleaner solutions would treat NumberFormatException
  // and NullPointerExceptions here
}

// This happens when we had an exception before
if (oikonomia == null) {
  // [...]
}

// This happens when the above float was correctly parsed
else {
  // [...]
}

Of course there are lots of ways to simplify the above and write cleaner code. But I think this should about explain how you should correctly and safely parse a String into a float without running into any Exceptions...

A: You should probably be doing something like this
Float oikonomia = Float.valueOf(vprosvasis7.getText().toString());
You're going to get a NumberFormatException if you try to parse a string that doesn't translate into a valid number.  So you could simply wrap this statement in a try catch block and handle the error properly.
Hope that helps.

A: try this:
Float oikonomia = null;
try{
  oikonomia = Float.valueOf(vprosvasis7.getText().toString());
}catch(numberFormatException e){
  // logging goes here
}

Now the value is NULL in case of an illegal (non float) string.


text:
Q: How to use Action Script file in iOS I have a page curl code in Action Script and i want to use that code in my app which is developed using Xcode(Objective c). Can any one tell whether it is possible or not. If possible then please tell me how to do.
The action script code follows
package
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.DisplayObject;
    import flash.display.GradientType;
    import flash.display.PixelSnapping;
    import flash.display.Sprite;
    import flash.geom.Matrix;
    import flash.geom.Point;
    import flash.geom.Rectangle;

    import asData.clsGlobalConstants;
    import com.DaveLibrary.clsSupport;
    import com.cupcake.Utils;

    public class clsPageTurn extends Sprite
    {
        private var cMain:clsMain;
        private var gc:clsGlobalConstants;

        private var flipDirection:int;
        private var pageWidth:Number;
        private var pageHeight:Number;
        private var pageWidthHeight:Number;
        private var pivotY:Number;

        private var NextPageLeft:BitmapData;
        private var NextPageRight:BitmapData;

        private var StationaryPage:Sprite;
        private var StationaryPageMask:Sprite;
        private var StationaryPageBitmap:Bitmap;

        private var StationaryShadow:Sprite;
        private var StationaryShadowMask:Sprite;

        private var FlippingPage:Sprite;
        private var FlippingPageBitmap:Bitmap;
        private var FlippingPageMask:Sprite;
        private var FlippingPageBorder:Sprite;

        private var FlippingPageShadow:Sprite;

        private var OutsideShadow:Sprite;
        private var OutsideShadowMask:Sprite;

        private var LeftRect:Rectangle;
        private var RightRect:Rectangle;
        private var LeftPoint:Point;
        private var RightPoint:Point;

        private var StaticLeftRect:Rectangle;
        private var StaticRightRect:Rectangle;
        private var StaticLeftPoint:Point;
        private var StaticRightPoint:Point;

        public var percentage:Number;
        public var useShadows:Boolean = false;

        public function clsPageTurn(Main:clsMain, FlipDirection:int, pWidth:Number = 1366, pHeight:Number = 768, xOffset:Number = -171)
        {
            // constructor code
            cMain = Main;
            gc = cMain.gc;

            this.x = xOffset;

            percentage = 0; // tracks the last percentage that was drawn.

            StationaryPage = new Sprite();
            StationaryPage.x = xOffset;
            this.addChild(StationaryPage);

            StationaryPageBitmap = new Bitmap();
            StationaryPageBitmap.pixelSnapping = PixelSnapping.ALWAYS;
            StationaryPage.addChild(StationaryPageBitmap);

            StationaryPageMask = new Sprite();
            StationaryPageMask.x = xOffset;
            this.addChild(StationaryPageMask);

            useShadows = !clsMain.isSlow;
            if ( useShadows )
            {
                StationaryShadow = new Sprite();
                StationaryShadow.x = xOffset;
                this.addChild(StationaryShadow);

                OutsideShadow = new Sprite();
                OutsideShadow.x = xOffset;
                this.addChild(OutsideShadow);

                OutsideShadowMask = new Sprite();
                OutsideShadowMask.x = xOffset;
                this.addChild(OutsideShadowMask);
            }

            FlippingPage = new Sprite();
            FlippingPage.x = xOffset;
            this.addChild(FlippingPage);

            FlippingPageBitmap = new Bitmap();
            FlippingPageBitmap.pixelSnapping = PixelSnapping.ALWAYS;
            FlippingPage.addChild(FlippingPageBitmap);

            if ( useShadows )
            {
                FlippingPageBorder = new Sprite();
                FlippingPage.addChild(FlippingPageBorder);
            }

            FlippingPageMask = new Sprite();
            FlippingPageMask.x = xOffset;
            this.addChild(FlippingPageMask);

            if ( useShadows )
            {
                FlippingPageShadow = new Sprite();
                FlippingPage.addChild(FlippingPageShadow);
            }

            // set the page width and height and other variables for this page flip object.
            pageWidth = pWidth / 2; // the width is the width of one of our half pages, not the full screen width.
            pageHeight = pHeight;
            pageWidthHeight = pageWidth + pageHeight;
            pivotY = (pageHeight/2) + pageWidth;

            // rect and points for copying the halves.
            LeftRect = new Rectangle(xOffset, 0, pageWidth, pageHeight);
            RightRect = new Rectangle(pageWidth + xOffset, 0, pageWidth, pageHeight);
            LeftPoint = new Point(xOffset,0);
            RightPoint = new Point(pageWidth + xOffset, 0);

            StaticLeftRect = new Rectangle(0, 0, pageWidth, pageHeight);
            StaticRightRect = new Rectangle(pageWidth, 0, pageWidth, pageHeight);
            StaticLeftPoint = new Point(0,0);
            StaticRightPoint = new Point(pageWidth, 0);

            flipDirection = FlipDirection;

            // create our page halves.
            NextPageLeft = new BitmapData(pageWidth, pageHeight, true, 0);
            NextPageRight = new BitmapData(pageWidth, pageHeight, true, 0);

            if(flipDirection > 0) {
                StationaryPageBitmap.bitmapData = NextPageRight;
                FlippingPageBitmap.bitmapData = NextPageLeft;
            } else {
                StationaryPageBitmap.bitmapData = NextPageLeft;
                FlippingPageBitmap.bitmapData = NextPageRight;
            }

            // disable the mouse for this sprite so it doesn't trap events.
            this.mouseEnabled = false;
            this.mouseChildren = false;
        }

        public function destroy():void
        {
            this.graphics.clear();

            if(this.parent != null) {
                if(this.parent.contains(this)) {
                    this.parent.removeChild(this);
                }
            }

            if(NextPageLeft != null) NextPageLeft.dispose();
            NextPageLeft = null;

            if(NextPageRight != null) NextPageRight.dispose();
            NextPageRight = null;

            if(StationaryPage != null) {
                while(StationaryPage.numChildren < 0) {
                    StationaryPage.removeChildAt(0);
                }
            }
            StationaryPage = null;

            if(StationaryPageMask != null) StationaryPageMask.graphics.clear();
            StationaryPageMask = null;

            if(StationaryShadow != null) StationaryShadow.graphics.clear();
            StationaryShadow = null;

            if(StationaryShadowMask != null) StationaryShadowMask.graphics.clear();
            StationaryShadowMask = null;

            if(OutsideShadow != null) {
                while(OutsideShadow.numChildren < 0) {
                    OutsideShadow.removeChildAt(0);
                }
            }
            OutsideShadow = null;

            if(OutsideShadowMask != null) OutsideShadowMask.graphics.clear();
            OutsideShadowMask = null;

            if(FlippingPage != null) {
                while(FlippingPage.numChildren > 0) {
                    FlippingPage.removeChildAt(0);
                }
            }
            FlippingPage = null;

            if(FlippingPageMask != null) FlippingPageMask.graphics.clear();
            FlippingPageMask = null;

            if(FlippingPageShadow != null) FlippingPageShadow.graphics.clear();
            FlippingPageShadow = null;

            if(FlippingPageBitmap != null) {
                if(FlippingPageBitmap.bitmapData != null) FlippingPageBitmap.bitmapData.dispose();
            }
            FlippingPageBitmap = null;

            gc = null;
            cMain = null;
        }

        public function Initialize( NextPage:BitmapData ):void
        {
            NextPageLeft.copyPixels(NextPage, StaticLeftRect, StaticLeftPoint);
            NextPageRight.copyPixels(NextPage, StaticRightRect, StaticLeftPoint);
            StationaryPageBitmap.smoothing = useShadows;
            FlippingPageBitmap.smoothing = useShadows;

            redraw(0);
        }

        public function InitializeDO( NextPage:DisplayObject ):void
        {
            var rect:Rectangle = NextPage.scrollRect;
            NextPage.scrollRect = LeftRect;
            NextPageLeft.draw( NextPage );
            NextPage.scrollRect = RightRect;
            NextPageRight.draw( NextPage );
            NextPage.scrollRect = rect;
            StationaryPageBitmap.smoothing = useShadows;
            FlippingPageBitmap.smoothing = useShadows;

            redraw(0);
        }

        public function InitializeHelperObjects():void
        {
            var bmData:BitmapData;
            var m:Matrix;
            var colors:Array;
            var alphas:Array;
            var ratios:Array;
            var maxLength:Number = Math.sqrt((pageWidth * pageWidth)+(pageWidthHeight * pageWidthHeight));
            var matrix:Matrix = new Matrix();

            StationaryPageBitmap.x = ((flipDirection * pageWidth) / 2) - (pageWidth / 2);
            StationaryPageBitmap.y = -pivotY - (pageHeight/2);

            StationaryPage.x = pageWidth;
            StationaryPage.y = pivotY + (pageHeight / 2);

            StationaryPageMask.graphics.clear();
            StationaryPageMask.graphics.beginFill(0x00FF00,1);
            StationaryPageMask.graphics.drawRect(((flipDirection > 0) ? 0 : -pageWidth)  , (-pivotY) - (pageWidthHeight / 2), pageWidth, pageWidthHeight);
            StationaryPageMask.graphics.endFill();
            StationaryPageMask.transform.matrix = new Matrix(1,0,0,1,pageWidth, pivotY + (pageHeight / 2));

            colors = [gc.pageTurn_InsideShadow_Color, gc.pageTurn_InsideShadow_Color,gc.pageTurn_InsideShadow_Color,gc.pageTurn_InsideShadow_Color,gc.pageTurn_InsideShadow_Color];
            alphas = [0,0,gc.pageTurn_InsideShadow_Stationary_Max,0,0];
            ratios = [0,85,125,170,255];
            matrix = new Matrix();

            if ( useShadows )
            {
                StationaryShadow.graphics.clear();
                StationaryShadow.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
                StationaryShadow.graphics.drawRect(((flipDirection > 0) ? 0 : -pageWidth), (-pivotY) - (pageWidthHeight / 2), pageWidth, pageWidthHeight);
                StationaryShadow.graphics.endFill();
                StationaryShadow.transform.matrix = new Matrix(1,0,0,1,pageWidth, pivotY + (pageHeight / 2));
            }

            FlippingPageBitmap.x = ((-flipDirection * pageWidth) / 2) - (pageWidth / 2);
            FlippingPageBitmap.y = (-pivotY) - (pageHeight / 2);
            FlippingPage.transform.matrix = new Matrix(1,0,0,1,pageWidth, pivotY + (pageHeight / 2));

            maxLength = Math.sqrt((pageWidth * pageWidth)+(pageWidthHeight * pageWidthHeight));
            colors = [gc.pageTurn_InsideShadow_Color,gc.pageTurn_InsideShadow_Color,gc.pageTurn_InsideShadow_Color,gc.pageTurn_InsideShadow_Color];
            alphas = [0, gc.pageTurn_InsideShadow_Flipping_Max, gc.pageTurn_InsideShadow_Flipping_Max, 0];
            ratios = [0, 100, 150, 255];
            matrix = new Matrix();
            matrix.createGradientBox( pageWidth, FlippingPageBitmap.height, 0, 0, 0);

            if ( useShadows )
            {
                FlippingPageShadow.graphics.clear();
                FlippingPageShadow.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
                FlippingPageShadow.graphics.drawRect(0, 0, FlippingPageBitmap.width, FlippingPageBitmap.height);
                FlippingPageShadow.graphics.endFill();
                FlippingPageShadow.transform.matrix = new Matrix(1,0,0,1,FlippingPageBitmap.x, FlippingPageBitmap.y);
            }

            FlippingPageMask.graphics.clear();
            FlippingPageMask.graphics.beginFill(0xFF0000,1);
            FlippingPageMask.graphics.drawRect(((-flipDirection * pageWidthHeight) / 2) - (pageWidthHeight/2), (-pivotY) - (pageWidthHeight / 2), pageWidthHeight, pageWidthHeight*2);
            FlippingPageMask.graphics.endFill();
            FlippingPageMask.transform.matrix = new Matrix(1,0,0,1,pageWidth, pivotY + (pageHeight / 2));

            if ( useShadows )
            {
                OutsideShadow.graphics.clear();
                OutsideShadow.graphics.beginFill(0x000000,cMain.gc.pageTurn_OutsideShadow_Alpha);
                OutsideShadow.graphics.drawRect(FlippingPageBitmap.x, FlippingPageBitmap.y, FlippingPageBitmap.width, FlippingPageBitmap.height);
                OutsideShadow.graphics.endFill();
                OutsideShadow.transform.matrix = new Matrix(1,0,0,1,pageWidth, pivotY + (pageHeight / 2));

                OutsideShadowMask.graphics.clear();
                OutsideShadowMask.graphics.beginFill(0x0000FF,1);
                OutsideShadowMask.graphics.drawRect(((-flipDirection * pageWidthHeight) / 2) - (pageWidthHeight/2), (-pivotY) - (pageWidthHeight / 2), pageWidthHeight, pageWidthHeight*2);
                OutsideShadowMask.graphics.endFill();
                OutsideShadowMask.transform.matrix = new Matrix(1,0,0,1,pageWidth, pivotY + (pageHeight / 2));

                FlippingPageBorder.x = FlippingPageBitmap.x;
                FlippingPageBorder.y = FlippingPageBitmap.y;
                FlippingPageBorder.width = pageWidth;
                FlippingPageBorder.height = pageHeight;

                FlippingPageBorder.graphics.clear();
                FlippingPageBorder.graphics.beginFill(0x000001, 1);
                FlippingPageBorder.graphics.drawRect(0,0,gc.pageTurn_Border_Size, pageHeight);
                FlippingPageBorder.graphics.endFill();
                FlippingPageBorder.graphics.beginFill(0x000001, 1);
                FlippingPageBorder.graphics.drawRect(gc.pageTurn_Border_Size,0,pageWidth-(gc.pageTurn_Border_Size*2), gc.pageTurn_Border_Size);
                FlippingPageBorder.graphics.endFill();
                FlippingPageBorder.graphics.beginFill(0x000001, 1);
                FlippingPageBorder.graphics.drawRect(gc.pageTurn_Border_Size,pageHeight - gc.pageTurn_Border_Size,pageWidth - (gc.pageTurn_Border_Size*2), gc.pageTurn_Border_Size);
                FlippingPageBorder.graphics.endFill();
                FlippingPageBorder.graphics.beginFill(0x000001, 1);
                FlippingPageBorder.graphics.drawRect(pageWidth - gc.pageTurn_Border_Size,0,gc.pageTurn_Border_Size, pageHeight);
                FlippingPageBorder.graphics.endFill();
                FlippingPageBorder.visible = true;
            }

            StationaryPage.mask = StationaryPageMask;
            FlippingPage.mask = FlippingPageMask;
            if ( useShadows ) OutsideShadow.mask = OutsideShadowMask;
        }

        public function redraw(Percentage:Number):void
        {
            percentage = Utils.Clamp( Percentage, 0, 1 );

            var rot:Number = flipDirection * 45 * Percentage;

            rotateSprite(FlippingPage, (flipDirection * 90) - rot * 2);

            if ( useShadows )
            {
                FlippingPageShadow.alpha = 0;
                StationaryShadow.alpha = clsSupport.GetBezier2DPercentage(0,0,1,1,Percentage);
                FlippingPageBorder.alpha =  gc.pageTurn_Border_Alpha * (1 - percentage);
                rotateSprite(OutsideShadow, ((flipDirection * 90) - rot * 2) + (clsSupport.GetBezier2DPercentage(gc.pageTurn_OutsideShadow_OffsetStart, gc.pageTurn_OutsideShadow_OffsetEnd, gc.pageTurn_OutsideShadow_LeadIn, gc.pageTurn_OutsideShadow_LeadOut, Percentage) * -flipDirection));
                rotateSprite(StationaryShadow, (flipDirection * 45) - rot );
                rotateSprite(OutsideShadowMask, (flipDirection * 45) - rot);
            }

            rotateSprite(StationaryPageMask, (flipDirection * 45) - rot );
            rotateSprite(FlippingPageMask, (flipDirection * 45) - rot);

            if(Percentage == 0 && useShadows)
            {
                FlippingPageBorder.x = FlippingPageBitmap.x;
                FlippingPageBorder.y = FlippingPageBitmap.y;
                FlippingPageBorder.width = FlippingPageBitmap.bitmapData.width;
                FlippingPageBorder.height = FlippingPageBitmap.bitmapData.height;
            }
        }

        private function rotateSprite(spr:Sprite, degress:Number):void
        {
            var m:Matrix;
            var x:Number;
            var y:Number;
            x = spr.x;
            y = spr.y;
            m = spr.transform.matrix;
            m.a = 1;
            m.b = 0;
            m.c = 0;
            m.d = 1;
            m.rotate(clsSupport.ToRadians(degress));
            m.tx = x;
            m.ty = y;
            spr.transform.matrix = m;
        }
    }
}

Can anyone tell me how to do this. Any help will be appreciated.

A: Impossible. if you want to use it in objective-c, must directly porting. Note that the page curl effect is built into iOS. To use the code on the iPhone using Air for iOS development.

A: Use a UIPageViewController to have this curl effect. Set the transitionStyle to UIPageViewControllerTransitionStylePageCurl or use the init-method – initWithTransitionStyle:navigationOrientation:options: .
Create instances of all the viewController you want use in put them into an array. This array is first argument of the setViewControllers:direction:animated:completion: method.


text:
Q: Add Second Set of Tabs to .NET MAUI app with Shell I want to add a second set of tabs on a page that is accessed through tabs defined in AppShell in my .NET MAUI app. According to the documentation, TabbedPage is not compatible with .NET MAUI apps that use AppShell. How do I achieve this -- preferably with standard XAML and not through a third party solution.
Here's the look I want:

As mentioned, I define my tabs in AppShell like this:
<FlyoutItem Title="Home" Icon="home.png">
   <Tab Title="Tiger" Icon="tiger.png">
      <ShellContent Route="Tiger" ContentTemplate="{DataTemplate local: Tiger}" />
   </Tab>
   <Tab Title="Giraffe" Icon="giraffe.png">
       <ShellContent Route="Giraffe" ContentTemplate="{DataTemplate local: Giraffe}" />
   </Tab>
   <Tab Title="Moose" Icon="moose.png">
       <ShellContent Route="Moose" ContentTemplate="{DataTemplate local: Moose}" />
   </Tab>
   <Tab Title="Elephant" Icon="elephant.png">
       <ShellContent Route="Elephant" ContentTemplate="{DataTemplate local: Elephant}" />
   </Tab>
</FlyoutItem>

A: If I understand your question correctly, you just need to add additional <ShellContent> elements inside your <Tab> definitions as described in the docs:
<FlyoutItem Title="Home" Icon="home.png">
   <Tab Title="Tiger" Icon="tiger.png">
      <ShellContent Route="Tiger" ContentTemplate="{DataTemplate local: Tiger}" />
      <ShellContent Route="Tiger2" ContentTemplate="{DataTemplate local: Tiger2}" />
      <ShellContent Route="Tiger3" ContentTemplate="{DataTemplate local: Tiger3}" />
   </Tab>
   <Tab Title="Giraffe" Icon="giraffe.png">
       <ShellContent Route="Giraffe" ContentTemplate="{DataTemplate local: Giraffe}" />
   </Tab>
   <Tab Title="Moose" Icon="moose.png">
       <ShellContent Route="Moose" ContentTemplate="{DataTemplate local: Moose}" />
   </Tab>
   <Tab Title="Elephant" Icon="elephant.png">
       <ShellContent Route="Elephant" ContentTemplate="{DataTemplate local: Elephant}" />
   </Tab>
</FlyoutItem>

I don't know if this works together with the <FlyoutItem>, though.

A: You can not.
You can use this auto wrapping, and get confused all you want.
But in the end, it all gets to the point, where your TabBar (that is Shell Item), contains Tabs (that are Shell Sections) and those contain a list of Shell Contents.
You can navigate between Items, and the Shell itself will provide means to navigate between Sections and Contents.
But those are not tabs.


text:
Q: Unable to use searchbar to filter tableview I am trying to filter tableview with search bar. I have written all necessary methods.
My code is as below:
What is wrong with it?? Please help me, i could not find the solution.
There should be something  that I am missing
@implementation ApothekeViewController
@synthesize  tableView,searchBar,mapView,eczaneler,eczanelerTemp,locationManager,searchDispController,filteredListContent,isFiltered,tableViewController;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
    tableViewController = [[UITableViewController alloc] init];
    tableViewController.tableView.delegate = self;
    tableViewController.tableView.dataSource = self;
    [tableViewController.tableView reloadData];
    tableViewController.tableView.frame = CGRectMake(0,66 ,320.0, 768.0);

    // tableView = [[UITableView alloc]init];
    //tableView.frame = CGRectMake(0,66 ,320.0, 768.0);
    //tableView.delegate = self;
    //tableView.dataSource = self;

    [self.view addSubview:tableViewController.tableView];

    searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    searchBar.placeholder = @"Arama" ;
    searchBar.delegate = self;

    UISearchDisplayController *searchCon = [[UISearchDisplayController alloc]
                                            initWithSearchBar:searchBar
                                            contentsController:tableViewController];
    self.searchDispController = searchCon;

    searchDispController.delegate = self;
    searchDispController.searchResultsDataSource = self;
    searchDispController.searchResultsDelegate = self;

    //searchBar.showsCancelButton = YES;

    tableViewController.tableView.tableHeaderView = searchBar;

    NSDate *now = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init ] ;
    [formatter setDateFormat:@"dd MMMM yyyy, EEEE"];
    [formatter setTimeZone:[NSTimeZone timeZoneWithName:@"Australia/Sydney"]];

    NSString *strSelectedDate= [formatter stringFromDate:now];

    UINavigationBar *naviBarObj = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 1024, 55)];

    UILabel *date = [[UILabel alloc] initWithFrame:CGRectMake(760,25,400,30)];
    date.text = strSelectedDate;
    date.textColor = [UIColor whiteColor];
    [date setFont:[UIFont fontWithName:@"Arial" size:25]];
    [naviBarObj addSubview:date];
    [date setBackgroundColor:[UIColor clearColor]];
    naviBarObj.topItem.titleView = date;

    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(60,5,400,50)];
    title.text = @"En Yakın Eczane";
    title.textColor = [UIColor whiteColor];
    [title setFont:[UIFont fontWithName:@"Arial" size:40]];
    [naviBarObj addSubview:title];
    [title setBackgroundColor:[UIColor clearColor]];
    naviBarObj.topItem.titleView = title;

    UIBarButtonItem *btnCancel = [[UIBarButtonItem alloc]
                                  initWithTitle:@"Cancel"
                                  style:UIBarButtonItemStyleBordered
                                  target:self
                                  action:@selector(cancel_Clicked:)];

    naviBarObj.topItem.leftBarButtonItem = btnCancel;

    [self.view addSubview:naviBarObj];

}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];

mapView = [[MKMapView alloc] initWithFrame:CGRectMake(320, 66, 704, 705)];

mapView.delegate = self;

[self.view addSubview:mapView];

mapView.showsUserLocation = YES;

eczanelerTemp = [[NSMutableArray alloc]init];

self.eczaneler = [[NSMutableArray alloc] init];

Eczane *eczane1 = [[Eczane alloc] init];

eczane1.customerName = @"Duyarlı Eczanesi";

eczane1.customerID = @"mohammed@gmail.com";

eczane1.longitude = @"29.0312";
eczane1.latitude =  @"41.109817";

Eczane *eczane2 = [[Eczane alloc] init];

eczane2.customerName = @"Azim Eczanesi Azim";

eczane2.customerID = @"azim@gmail.com";

eczane2.longitude = @"30.0312";
eczane2.latitude =  @"41.109817";

[self.eczaneler addObject:eczane1];

[self.eczaneler addObject:eczane2];

Eczane *eczane3 = [[Eczane alloc] init];

eczane3.customerName = @"Optik Eczanesi";

eczane3.customerID = @"optik@gmail.com";

eczane3.longitude = @"29.0352";
eczane3.latitude =  @"40.109817";

[self.eczaneler addObject:eczane3];

for(int i=0; i<[eczaneler count];i++)
{

    Eczane *temp = [self.eczaneler objectAtIndex:i];

    CLLocationCoordinate2D coordinate;
    coordinate.longitude = [temp.longitude floatValue];
    coordinate.latitude = [temp.latitude floatValue];

    CustomAnnotation *point = [[CustomAnnotation alloc] init];
    point.coordinate = coordinate;

    [self.mapView addAnnotation:point];

}

}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{
self.mapView.delegate = self;

[self.mapView setShowsUserLocation:YES];

return YES;

}

- (MKAnnotationView *)mapView:(MKMapView *)mapView2 viewForAnnotation:(id   <MKAnnotation>)annotation
{

if ([annotation isKindOfClass:[MKUserLocation class]])
{
    return nil;
}
else if ([annotation isKindOfClass:[CustomAnnotation class]])
{
    static NSString * const identifier = @"MyCustomAnnotation";

    MKAnnotationView* annotationView = [mapView2 dequeueReusableAnnotationViewWithIdentifier:identifier];

    if (annotationView)
    {
        annotationView.annotation = annotation;
    }
    else
    {
        annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
                                                      reuseIdentifier:identifier];
    }

    // set annotationView properties

    UIImageView * ecz = [[UIImageView alloc]init];

    ecz.frame = CGRectMake(0, 0, 65, 49);

    ecz.image = [UIImage imageNamed:@"indicator.png"];

    UIImageView * vstd = [[UIImageView alloc]init];

    vstd.frame = CGRectMake(33, 10, 24, 22);

    vstd.image = [UIImage imageNamed:@"indicator_ziyaret_gri"];

    UIImageView * nbox = [[UIImageView alloc]init];

    nbox.frame = CGRectMake(48, -6, 22, 22);

    nbox.image = [UIImage imageNamed:@"numara_kutusu"];

    [annotationView addSubview:ecz];

    [annotationView addSubview:vstd];

    UILabel *index = [[UILabel alloc] initWithFrame:CGRectMake(5,4,15,15)];
  //  index.text =[NSString stringWithFormat:@"%d", iterator ];
    index.textColor = [UIColor whiteColor];
    [index setFont:[UIFont fontWithName:@"Arial-BoldMT" size:18]];
    [nbox addSubview:index];
    [index setBackgroundColor:[UIColor clearColor]];

    [annotationView addSubview:nbox];

    //annotationView. = [UIImage imageNamed:@"indicator.png"];
    annotationView.canShowCallout = YES;

    return annotationView;
}

return nil;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (self.tableViewController.tableView == self.searchDisplayController.searchResultsTableView) {

    return [filteredListContent count];

} else {
    return [eczaneler count];

}
}
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 110;
}

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {

 NSLog(@"cellForRowAtIndexPath");

 static NSString *CellIdentifier = @"EczaneCell";

 EczaneCell *cell = (EczaneCell *) [self.tableViewController.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

 if (cell == nil) {
     cell = [[[EczaneCell alloc] initWithFrame:CGRectZero] autorelease];
 }

 Eczane *eczane = [[Eczane alloc]init];

 if (self.tableViewController.tableView == self.searchDisplayController.searchResultsTableView) {
     eczane = [self.filteredListContent objectAtIndex:[indexPath row]];
 } else {
     eczane = [self.eczaneler objectAtIndex:[indexPath row]];
 }

 cell.circleIndex.text        = [NSString stringWithFormat:@"%d", ([indexPath row]+1)];
 cell.cellName.text           = eczane.customerName;

 return cell;

 }

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//EczaneCell *cell = [tableView cellForRowAtIndexPath:indexPath];

Eczane *eczane = [self.eczaneler objectAtIndex:[indexPath row]];

CLLocationCoordinate2D coordinate;
    coordinate.longitude = [eczane.longitude floatValue];
    coordinate.latitude = [eczane.latitude floatValue];

MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coordinate, 2000, 2000);

[mapView setRegion:region animated:YES];

}

#pragma mark -
#pragma mark UISearchDisplayController Delegate Methods

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
[filteredListContent removeAllObjects];

for (Eczane *eczObj in eczaneler)
{

    NSComparisonResult result = [eczObj.customerName compare:searchString options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchString length])];
    if (result == NSOrderedSame)
    {
        [self.filteredListContent addObject:eczObj];
    }
}

[self.searchDispController.searchResultsTableView reloadData];

//[self.tableViewController.tableView reloadData];

//[self.tableViewController.tableView] = [self.searchDispController.searchResultsTableView ];

[self.tableViewController.tableView reloadData];

[searchDispController.searchResultsTableView setFrame:CGRectMake(0, 44, 320, [filteredListContent count]*(searchDispController.searchResultsTableView.rowHeight))];

return YES;
}

@end

A: Your problem is probably:
contentsController:tableViewController

Because you have 'stolen' the table view from the controller and made yourself the delegate and data source so the search controller will be trying to gather source information using a broken controller.
Make self the contents controller.
Your next problem is:
if (self.tableViewController.tableView == self.searchDisplayController.searchResultsTableView) {

Again, because you broke that controller (you should fix that, why are you creating a table view controller and then stealing its view?). Change it to:
if (tableView == self.searchDisplayController.searchResultsTableView) {


text:
Q: How to add multiple TextView s for a LinearLayout by Java Code ( in Android ) Here is my code. In the resulting screen it shows only the first TextView. Not the second one. Im kind of new to Android and please give a help.
public class Details extends Activity {
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);

        TextView label = new TextView(this);
        label.setText("Moves");
        label.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        label.setTextSize(20);

        TextView label2 = new TextView(this);
        label2.setText("Time");
        label2.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        label2.setTextSize(20);

        LinearLayout ll = new LinearLayout(this);
        ll.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
        ll.setOrientation(LinearLayout.VERTICAL);

        ll.addView(label);
        ll.addView(label2);

        setContentView(ll);
    }
}

A: You forgot to tell the LinearLayout how to stack its children (Orientation). Without that it won't stack them at all and will ONLY display the first item (I believe).
http://developer.android.com/reference/android/widget/LinearLayout.html#setOrientation(int)


text:
Q: SvelteKit SSR - how to block server-side render until data has been fetched? I am using SvelteKit and, for SEO reasons, I would like to use full SSR and to ensure that all data is fetched and rendered server-side before being delivered to the browser. In other words, all calls to the back-end API should have completed before the initial page response is delivered.
However, it is unclear to me from the documentation how to achieve this. (I may have missed something.)
I have tried the following, but this just delivers a completely empty body:

{#await promise then character}

Your character

    Name is {character.name}

{/await}

Does anyone know how to block server-side render using SvelteKit until data has been fetched?

A: You need to export a load function: https://kit.svelte.dev/docs#loading

A: As noted above, the answer is to export a load function (as described here), but just to add a working example of this:

Your character:

Name is {character.name}

Hair color is {character.hair_color}


text:
Q: How to manage setOnClickListener on a array of buttons I have a dynamic array of buttons and I would like to know how to handle the onclick on every button?
Thanks

A: I don't see a need to create a new OnClickListener for each button -- all the buttons could share a single listener.
private OnClickListener myListener = new OnClickListener() {
  public void onClick(View v) {
    Object tag = v.getTag();
    // Do something depending on the value of the tag
  }
};

...

for (int i=0; i < btns.length; ++i) {
  btns[i].setOnClickListener(myListener);
  btns[i].setTag(some_identifying_information);
}

Of course, you could create a unique OnClickListener for each button, and take advantage this way:
for (int i=0; i < btns.length; ++i) {
  final Button btn = btns[i];
  btn.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
      // do something depending on the value of btn, which you're allowed
      // to reference here because it was declared final above.
    }
  });
}

A: The same way you would on a single button...
Set an on click listener, if you have an Array it would look something like this:
btns[0].setOnClickListener(new OnClickListener() {
    public void onClick(View v){
        //do something
    }
});

btns[1].setOnClickListener(new OnClickListener() {
    public void onClick(View v){
        //do something
    }
});
//etc.

If you want all of them to do the same thing you could use a for loop to loop over the array like this:
for(int i = 0; i< btns.length; i++){
    btns[i].setOnClickListener(new OnClickListener() {
        public void onClick(View v){
            //do something
        }
    });
}

I don't know exactly what you are doing but if you have an Array of Buttons it is likely that you should probably be using an Adapter with a ListView or something instead of how every you are doing it now.

A: Without seeing some code or more of an explanation, it's hard to really answer your question, but here are some tips:
Before we get to the listeners, we have to make sure that each of the dynamically created buttons knows how to respond to a click event.  You can use the setTag method on a button to attach an arbitrary Object to it.  This Object will represent how the Button acts when clicked.  You can just use Integers as this Object (perhaps some constant values) or if each button needs some unique data, create a class that maintains both how the button needs to act when clicked AND the data you need (or at least a reference to it).
Then, you can initialize one single listener that handles all of your button clicks.  In the onClick method of this listener place a conditional that branches to handle all of your click cases.  Set this listener on all of your dynamic buttons as you create them.  At the start of your onClick, get the Tag from the View parameter of the onClick method (this view will be the button that was clicked), and use that to decide which branch of the conditional to take.
Hope this helps.  If you make your question more specific, we'll be able to offer some more detailed assistance.


text:
Q: JSF navigating to named anchor I have a JSF2 form which is not near the top of the page, the form has a named anchor in the heading:

Contact Us

The form consists of user-side validation, for example:
<f:validateLength for="message" minimum="10"/>
<f:validateRegex for="email" pattern="#{regex['email']}" />

When the validation fails, the user is redirected to the top of the page, however the error messages are shown in the form. When the form passes validation, the request is processed in the ManagedBean and a success message is shown in the form, I am returning the string:
public String sendMessage () {
    // process request ...

    return "#contact_form";
}

This code results in the warning:
WARNING: JSF1090: Navigation case not resolved for component j_idt83.

*

*I would prefer for the validation to fail and redirect to the named anchor.

*I would prefer for successful processing of the form to redirect to the named anchor.

Footnote: This form is inserted by a ui:include statement on every page of the site, I do not necessarily know the url that the form is on.

A: I don;t think you can return a fragment as a navigation outcome, at least not without writing a custom NavigationHandler class. (see this SO answer, particularly the comments on the accepted answer)
In our application we got round this using a bit of jquery in our master page template that in the document.ready() function selects any element that has an id that ends with "scroll_to_anchor" and if found, sets the window location to the first element that has that id. I'm not able to access my codebase right now but I remember it was quite straightforward and if you're interested in my solution I can post the code tomorrow when I'm in the office.


text:
Q: Feasible to use a laptop as a Digital Media Receiver/Extender? Since the price of many dedicated hardware Digital Media Extenders is only slightly lower than that of a cheap laptop, is there any reason you couldn't use a laptop as a Digital Media Extender?
I'm looking for specific reasons that might make this unworkable.  For instance, would the small screen/low-power video card of the laptop prevent the movie from playing well on the TV?

A: I know several people that do this. It isn't so much that it's a laptop or not. It's all about the specific components:

*

*Does the video card have hardware acceleration for the video formats you want to play? If so, CPU probably isn't an issue.

*If not using acceleration on the graphics card, is the CPU fast enough?

*If you're recording on the laptop, is the hard drive fast enough? a 5400RPM laptop drive might not be able to record and do other things without dropping some frames.

*If you're recording, what is the capture device? It probably has to be a USB or network encoder.


text:
Q: Does the prestige of a gym automatically degrade over time? 5 days ago I became a member of a level 10 gym which had 52,000 prestige. The prestige remained at 52,000 until 2 days ago when it fell to exactly 50,000 (still 10 pokemon. ok). Last night, the prestige fell to exactly 49,500 (now with 9 pokemon. ok).
That each degradation happened in units of 500 surely means pokemon are getting kicked-out, but why? Is it the passage of time that is kicking out pokemon automatically?
note (1):
During the 5 minutes it took to write this, gym prestige fell to exactly 49,000, BUT there are still 9 pokemon! What the heck? How did the gym lose 500 but not lose a pokemon?
note (final):
20-min has just passed, and now I see fighting at the gym. My gym mates are counter-attacking and have pushed prestige back up to 48,978. So, the "attack" was in units of 500 and the counter-attack was in units of 1. In essence, that is my question.

A: Training works with variable xp.
Fighting gyms always costs a multiple of 500 prestige. I've seen up to 2500 prestige reductions. This is based on the amount of pokemon you beat and if the attacker won the entire battle series.
Beating a single pokemon and having all your pokemon faint vs the second one results in 500 prestige reduction.


text:
Q: Any difference in " 'value' == typeof X " VS " typeof X == 'value' " Is there any difference (compiler/interpreter/juju wise, etc) between the two versions of checking the result of the typeof operator?
I am asking because I see the first version a lot of times, as if it followed a concept, while version two is way more readable and better describes my intention: primarily I am interested in the type of a variable and not a string being equal with something.
UPDATE:
while it's not part of the original question it worth noting that x == y is never a good practice when you are about to check equality. One should always use the === operator for that.

A: Update
There is no difference in terms of functionality but it seems that in JavaScript, you get an error in either way (which is good, thanks to JS):
Invalid left-hand side in assignment

So it seems to be just a habit of developers from other programming languages. For example in PHP if you did:
if ($var = 'foo')

PHP will silently assign foo as value to $var but with following:
if ('foo' = $var)

It will throw an error.

I am asking because I see the first version a lot of times

There is no difference in what they do. However first version will throw an error if you happen to write:
'value' = typeof X

Notice = instead of == or ===
This is generally good practice, people from other languages have habit of doing it that way in JavaScript also.

A: There will be no difference, as the equivalence operation will return the same thing, regardless of which way round it is.


text:
Q: I have a function defined on integer-radian inputs from the unit circle in the complex plane. Is it discontinuous? Recently, some colleagues and I had need to consider the following function defined on a part of the complex plane
 $$f:(e^{in},e^{im})\quad\mapsto\quad e^{inm},$$
where $n$ and $m$ are non-negative integers. Because these are integer radian angles, it follows that the numbers of the form $e^{in}$ are dense on the unit circle, and we only consider the function $f$ on input of the form $e^{in}$ for $n\in\mathbb{N}$.
Notice that the function $f$ is continuous in each coordinate separately, since if one fixes the first input value at $e^{in}$, then $f(e^{in},z)$ agrees with $z^n$ for $z$ in its domain, and similarly $f(z,e^{im})=z^m$, when $m$ is fixed, and in each case these are continuous unary functions.
But I believe that the function $f$ is likely discontinuous as a binary function on its domain.
Can you prove it?

A: Alex Wilkie sent me the following argument by email, and I post it transcribed here with his permission.

Transcription.
Let $$2\leq N_0 < N_1 <\cdot$$ and $$1\leq k_0 < k_1 <\cdots$$ be
  strictly increasing sequences of integers, and $$t_0, t_1, \ldots$$
  a sequence of real numbers with
   $$(\ast)\qquad 2\pi k_j-N_j = \frac{t_j}{N_{j-1}}$$
  and
   $$(\ast\ast) \qquad \frac{\pi}{2} \leq |t_j| \leq \pi.$$
  Such sequences are easy to construct using Dirichlet's theorem
  (and, of course, the fact that $\pi$ is irrational).
Then, by $(\ast)$, we have
   $$e^{iN_j}=e^{i(2\pi
k_j-\frac{t_j}{N_{j-1}})}\to 1\quad\text{ as }\quad j\to\infty$$ and
  so also
   $$e^{iN_{j-1}}\to 1\quad\text{ as }\quad j\to \infty.$$
  Hence, $f(e^{iN_j},e^{iN_{j-1}})\to f(1,1)=1$, if $f$ were
  continuous.
However, $$f(e^{iN_j},e^{iN_{j-1}})=e^{iN_jN_{j-1}}=e^{i(2\pi
k_jN_{j-1}-t_j)}=e^{-it_j},$$ which converges to a point (if it
  converges at all) in the left half-plane. $\Box$
In fact, only a very weak form of Dirichlet's theorem is needed:
  just that $|N\pi - M|$ can be made arbitrarily small for integers
  $M$, $N$.


text:
Q: multibranchPipelineJob job DSL: how to enable Discover branches and Suppress automatic SCM triggering How to enable in a Jenkins job DSL for a multibranch pipeline the behavior Discover Benches and the Property strategy Suppress automatic SCM triggering?

A: It can be done like this:
multibranchPipelineJob('job name') {
    branchSources {
        branchSource {
            source {
                git {
                    remote('https://<repo address>.git')
                    credentialsId('credential id')
                }
            }
            strategy {
                defaultBranchPropertyStrategy {
                    props {
                        noTriggerBranchProperty()
                    }
                }
            }
        }
    }
    configure {
        def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
        traits << 'jenkins.plugins.git.traits.BranchDiscoveryTrait' {}
    }
    triggers {
        periodic(2) // Trigger every 2 min.
    }
    orphanedItemStrategy { discardOldItems { numToKeep(-1) } }
}

A: Just to extend the accepted answer: you don't necessary need that tricky traits << ... syntax to add branch (or tags) discovery. Instead you may use traits { } section (see docs).
multibranchPipelineJob 'job name', {
    branchSources {
        branchSource {
            source {
                git {
                    id 'job name'
                    remote 'git@<repo-url>.git'
                    credentialsId 'git-creds-id'

                    traits {
                        gitBranchDiscovery()
                        gitTagDiscovery() // if you need tag discovery
                    }
                }
            }
            strategy {
                defaultBranchPropertyStrategy {
                    props {
                        noTriggerBranchProperty()
                    }
                }
            }
        }
    }
}


text:
Q: SQL Create Table [Default] Can I specify DEFAULT to get the exact value of a column?
I am creating a Serial table, with range, some has From and To and some are just singular.
Therefore I have two columns: [Serial_Fr] & [Serial_To]
If I insert Serial_Fr only, I want to populate Serial_To = Serial_Fr.
How do I do that? Or should I use triggers and just set default = '', in doing this I think it will cause a strain when I have millions of serials.

A: Create a View which is
CREATE VIEW MyView AS
SELECT
  Serial_Fr,
  Serial_To =  COALESCE(Serial_To,Serial_Fr)
FROM MyTable

Or this could be done in a Stored Procedure
But what is wrong with leaving some of the entries in Serial_To as NULL ?

Edit
ISNULL is T-sql : COALESCE is 92 standard sql. There is a good discussion of the subtle differences between these functions HERE ON SO
Martin Smith also refers to an article which has this interesting example that illustrates a difference:
DECLARE @test VARCHAR(2)
DECLARE @first VARCHAR(4)
DECLARE @second VARCHAR(4)

SELECT @first = ISNULL(@test, 'test')
SELECT @second = COALESCE(@test, 'test')

PRINT @first
PRINT @second


text:
Q: Proof of Dirac Delta's sifting property A common way to characterize the dirac delta function $\delta$ is by the following two properties:
$$1)\ \delta(x) = 0\ \ \text{for}\ \ x \neq 0$$
$$2)\ \int_{-\infty}^{\infty}\delta(x)\ dx = 1$$
I have seen a proof of the sifting property for the delta function from these two properties as follows:
Starting with
$$\int_{-\infty}^{\infty}\delta(x-t)f(x)\ dx$$
for some "sufficiently smooth" function $f$, since $\delta(x - t) = 0$ for $x \neq t$ we can restrict the integral to some epsilon interval around $t$
$$\int_{-\infty}^{\infty}\delta(x-t)f(x)\ dx = \int_{t-\epsilon}^{t+\epsilon}\delta(x-t)f(x)\ dx$$
On this infinitesimal interval, $f$ is "approximately constant" and so we can remove it from the integral
$$\int_{t-\epsilon}^{t+\epsilon}\delta(x-t)f(x)\ dx = f(t)\int_{t-\epsilon}^{t+\epsilon}\delta(x-t)\ dx = f(t)$$
This proof seems a little too hand wavy for me. The points I find problematic are in quotations. What is meant by "sufficiently smooth" in this case? Is continuous enough? Also, how exactly is the extraction of the function from the integral done rigorously, without just assuming that it is "approximately constant"? I have seen this proof done with non-standard analysis and I understand that the delta function is by nature a rather "hand wavy" object so that a rigorous proof using these two properties may not even exist. Still I ask if anyone can perhaps make the above proof rigorous or offer a new proof without appealing to non-standard analysis.
(I'm not too sure what tags to include for this question. If anyone could retag for me that'd be much appreciated

A: Theory of Distributions by J. Ian Richards and Heekyung Youn gives rigorous proofs of things like this without need for functional analysis, topology, or measure theory.
Definitely the proof you give is extremely "hand-wavy".  In particular, the two defining properties you give cannot be taken literally if one conceives of a function as something where you put in a number $x$ and get out a number $f(x)$.  To take those two properties is intuitive but very very "hand-wavy".

A: Well, as you mention, no truely rigorous treatment can be given with such a description of the Delta Dirac function - no such function actually satisfies those requirements. Thus, I won't take too much effort to make the below too precise.
Where it says "sufficiently smooth", it doesn't actually need anything there at all! Whatever $f$ is, as long as it is finite almost everywhere, the product with that delta function will be $0$ away from a neighbourhood of $t$, so you can restrict the integral like that.
For the extraction of $f$, being continuous in a closed neighbourood of $x=t$ is enough. If $f$ is continuous through $ [ t-\epsilon, t+ \epsilon ] $ then by the Extreme value theorem it attains a maximum and minimum in that interval, call them $ M $ and $m$ respectively.
Then since $ m \leq f(x) \leq M$ is that range, $$ m=\int^{t+\epsilon}_{t-\epsilon} m \delta(x-t) \, dx \leq \int^{t+\epsilon}_{t-\epsilon} f(x) \delta(x-t) \,dx \leq \int^{t+\epsilon}_{t-\epsilon} M \delta(x-t) \, dx = M.$$
Now as $\epsilon \to 0$, both $m$ and $M$ go to $f(t)$ as $f$ is continuous so by the Squeeze theorem, $$ \int^{t+\epsilon}_{t-\epsilon} f(x) \delta(x-t) \, dx  \to f(t) $$ as $\epsilon \to 0$.

A:
The simplest possible nascent delta function is a rectangular pulse:
$$
\delta_h(x) =
\begin{cases}
0 & |x|\geq h \\
1/2h & -h\leq x \leq h
\end{cases}.
$$

For a continuous function $f,$ the sifting property of $\delta_h(x)$
is very easily proven.
$$
  \int_{-h}^h \delta_h(x) f(x) \,dx =
  \left.\frac{F(x)}{2h}\right|_{-h}^{h} = \frac{F(h) - F(-h)}{2h}
$$
where $F$ is the antiderivative of $f.$  Since $f$ is continuous, its
antiderivative is continuously differentiable and the limit of $(F(h)-F(-h))/2h$ as $h\rightarrow 0$ is $f(0).$

It is true that no function has the two properties listed in the
question.  But there are infinitely many families of continuous functions
$\delta_h(x)$ that are positive on
$(-h,h)$ and 0 everywhere else with integral equal to 1 for
all $h.$  These functions satisfy property (2) for all $h$ and
property (1) in the limit $h\rightarrow 0.$

It is very easy to prove that
these nascent delta functions satisfy the sifting
property in the limit $h\rightarrow 0.$  The exact same squeeze
argument from
the proof in the answer above applies since the integral of
$\delta_h(x)$ over $[-h,h]$ is 1 for every $h.$

Both the rectangular pulse and hat function are examples of this type of
nascent delta function.
A smooth example of this type of nascent delta function is the mollifier
$$
\frac{K}{h}\exp\left( \frac{-1}{1 - x^2/h^2} \right)
$$
where $K$ is the constant that makes the integral 1 for $h=1$ (and also
all other values of $h.$)


text:
Q: Minimum value of $2^{2x}+6\cdot 2^x +18$
Minimum value of $$2^{2x}+6\cdot 2^x +18.$$

It looks like the quadratic equation $$t^2+6t+18=(t+3)^2+9.$$
So the minimum is $9$ if we complete the square, but there is no such $x$ which will give us $2^x=-3$.
So the answer should be $18$ as $2^x>0$ for all $x$! Am I correct?

A: Write:
$$2^{2x}+6\cdot 2^x +18=(2^x+3)^2+9$$
And see that the minimum happens when $2^x \rightarrow 0$ once $2^x >0$.
So in this case we have infimum (not minimum) and it is $18$.

A: The function
$$f(x)=2^{2x}+6\cdot 2^x +18$$
is strictly increasing on $\mathbb{R}$: if $x_1>x_2$ then
$$f(x_1)-f(x_2)=(4^{x_1}-4^{x_2})+6\cdot(2^{x_1}-2^{x_2})>0.$$
Therefore the greatest lower bound is
$$\inf_{x\in\mathbb{R}}f(x)=\lim_{x\to -\infty}f(x)=18.$$
Note that $f$ does not attain the value $18$ so you can not say that $18$ is the minimum value.

A: Yes you are. However the value is not a minimum but an infimum because this value is taken after
$$\lim_{x\to-\infty}2^{2x}+6\cdot 2^x +18=18$$ (for all negative real $x$ you have
$2^{2x}+6\cdot 2^x +18\gt18$)


text:
Q: GPU problem for CUDA 11.0 and cuDNN 8.0.2 I have the CUDA 11.0 and cuDNN 8.0.2, which are the recommended setup
I have tensorflow-gpu 2.3 and keras 2.4
However the GPUs are not used and I don't know why.
by giving the following command lines
sess = tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None)
print("GPU available? ", sess)
built = tf.test.is_built_with_cuda()
print("tf is built with CUDA? ", built)
gpus = tf.config.list_physical_devices('GPU')
cpus = tf.config.list_physical_devices('CPU')
print("Num GPUs used: ", len(gpus))
print("Num CPUs used: ", len(cpus))
print(tf.sysconfig.get_build_info())

The output is the following:
GPU available?  False
tf is built with CUDA?  True
Num GPUs used:  0
Num CPUs used:  1
{'cuda_version': '10.1', 'cudnn_version': '7', 'cuda_compute_capabilities': ['sm_35', 'sm_37', 'sm_52', 'sm_60', 'sm_61', 'compute_70'], 'cpu_compiler': '/usr/bin/gcc-5', 'is_rocm_build': False, 'is_cuda_build': True}

it comes with the following error:
 W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory
 I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
 I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
 I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
 I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
 I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
 I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7
 W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.

A: As stated in Tensorflow documentation. The software requirements are as follows.
Nvidia gpu drivers - 418.x or higher
Cuda - 10.1 (TensorFlow >= 2.1.0)
cuDNN - 7.6

See Link
You must have a python version between 3.5 - 3.8.
Along with that you need Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019.
You can download that here. Link
Check the full system requirements here Link
Don't forget to add cuda and cudnn in your system path. See Link

A: This solution clears the issue completely in my case even my system is set up with CUDA 10.2. Tensorflow probably requires something from CUDA 10.1, I guess.
conda install cudatoolkit=10.1

Check https://github.com/tensorflow/tensorflow/issues/38578#issuecomment-710104168


text:
Q: Hexadecimal Floating-Point,roundIng I try the following example:
printf("%9.1a",4488.09); //Only one digits has to be printed after digital point

The binary representation of 4488.09  == 1 0001 1000 1000.0001011100001010001111010111000010100011110101
should become 0x1.1p+12or 0x1.2p+12 ?
I cant undrstand if the round operation (while printing) has to be performed for the binary representation or for the 1.18+13 representation?And if it should perform  ceil() - the 8 is exactly in the middle of the hexadecimal range...

A: Binary can always be converted to decimal without a loss, unless you restrict the number of decimal digits to a too small number. If the mantissa value is something like 1.188170A3D70A4 and you restrict printf() to only 1 fractional digit, you should get 1.2 printed for the mantissa. If you restrict it to 2 fractional digits, you should get 1.19. If 3, then 1.188. If 4, then 1.1881. And so on.

A: yeah, when you printf() a 9.1 number, you're going to get rounding.
if you don't want rounding, you could , zero out the lower bits.
your error seems to be thinking that rounding will occur for part of the number, but not the whole number.
also here in tennessee, we don't use the word, mantissa.  But we do use the "fractional part"


text:
Q: How can I configure persistence.xml to point to MongoDB My project uses Morphia to map my Java entities to MongoDB. What I want to achieve is to create a persistence.xml and configure it so that I will not have to configure properties from source code. How can I achieve this ?

A: Morphia doesn't use persistence.xml.  You'll have to use the annotations.


text:
Q: Chromium DevTools Protocol - deleteCookies Пытаюсь использовать Chromium DevTools protocol, точнее метод Network.deleteCookies: https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-clearBrowserCookies
И вроде, как в описание к методу написано, что параметры url, domain and path - это опциональные параметры, то есть использовать их или нет - это по желанию.
Но, когда я вызываю этот метод:
{"id":3,"method":"Network.deleteCookies","params":{"name":"name_cookie"}}

То приходит ошибка:
{"code":-32602,"message":"At least one of the url and domain needs to be specified"}

Почему так ? ПОдскажите пожалуйста.


text:
Q: set-up and tear-down method for multiple test modules I have a number of tests, scattered among different test modules and classes. I need to start up/tear down a docker container before/after running the tests, but neither setUpClass() nor setUpModule() seems appropriate. How do I specify set-up and tear-down methods for multiple modules?

A: Create a base class for all your tests with in which you place your common setUpClass and tearDownClass methods:
class MyTestCase(unittest.TestCase):
    def setUpClass(self):
        ...set up docker stuff...

    def tearDownClass(self):
        ...tear down docker stuff...

Now have all of your test classes inherit from that base class:
from mymodule.mytestcase import MyTestCase

class TestMyNiftyFeature(MyTestCase):
    def test_feature(self):
        ...test things here...

This will run the setup/teardown methods before and after each class, which is generally what you want because you want your tests to be self-contained so that you can run tests in one file without running tests in another.


text:
Q: There is no space left on the device sudo df -h
udev            982M     0  982M   0% /dev
tmpfs           200M  5.3M  195M   3% /run
/dev/vda2        40G  5.2G   33G  14% /
tmpfs          1000M     0 1000M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs          1000M     0 1000M   0% /sys/fs/cgroup
tmpfs           200M     0  200M   0% /run/user/0

sudo df -i
Filesystem      Inodes   IUsed  IFree IUse% Mounted on
udev            251350     413 250937    1% /dev
tmpfs           255984     937 255047    1% /run
/dev/vda2      2595840 2595840      0  100% /
tmpfs           255984       1 255983    1% /dev/shm
tmpfs           255984       6 255978    1% /run/lock
tmpfs           255984      16 255968    1% /sys/fs/cgroup
tmpfs           255984       4 255980    1% /run/user/0

I have no clue what's wrong here, why im getting no space left ?

A: You are not out of space. You still have 33G free space but zero free inodes. You have used all available inodes on your root partition / as shown in the output of df -i.
Filesystem      Inodes   IUsed  IFree IUse% Mounted on
/dev/vda2      2595840 2595840      0  100% /

With zero free inodes, no new files can be created and some system or applications functionality will be limited.

An inode (index node) is a data structure found in many Unix/Linux file
systems. Each inode stores all the information about a file system
object (file, device node, socket, pipe, etc.), except data content
and file name.

To fix it:
Find which directories use the most inodes by running this command:
sudo du --inodes /

Then delete some files that you do not need or move them to a USB drive.
This will free some inodes and make it possible to utilize the available free space.

Notice:
To output only directories with a certain minimum number of inodes, use the command like so:
sudo du --inodes / | grep -P "^\d{4,}"

This will only output directories with four digits number of inodes and more so 1000 and more will be printed.
You can change 4to for example 5 to print only directories with 10000 inodes and more and so on.