text:
Q: JAXB parse of Atom.xsd produces validation errors I am seeking to use JAXB to parse the Atom feed coming back from invoking Sharepoint 2010's REST service, and having the JAXB bind and compile happen on build in eclipse.  I downloaded a couple different versions of the atom xsd I found online (they differ only in some header attributes), including this one (http://www.kbcafe.com/rss/atom.xsd.xml) but am CONSISTENTLY getting the following errors regardless of which I use:
     [xjc] [WARNING] schema_reference.4: Failed to read schema document 'http://www.w3.org/2001/03/xml.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
     [xjc]   line 14 of file:/C:/rest_workspace/eDocs/src/gov/afms/edocs/rest/jaxb/schemas/AtomSchema2.xsd
     [xjc] [ERROR] src-resolve: Cannot resolve the name 'xml:base' to a(n) 'attribute declaration' component.
     [xjc]   line 292 of file:/C:/rest_workspace/eDocs/src/gov/afms/edocs/rest/jaxb/schemas/AtomSchema2.xsd
     [xjc] [ERROR] s4s-elt-must-match.1: The content of 'commonAttributes' must match (annotation?, ((attribute | attributeGroup)*, anyAttribute?)). A problem was found starting at: attribute.
     [xjc]   line 292 of file:/C:/rest_workspace/eDocs/src/gov/afms/edocs/rest/jaxb/schemas/AtomSchema2.xsd

I have seen some comments saying taht Java5 Xerces had some issues, but I echo out my java version from my ant script and am using 1.6.  The node at line 14 is:
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd" />

The node at line 292 is:
        <xs:attribute ref="xml:base" />

Note that eclipse is also flagging these things as errors.  For the warning, eclipse says "XSD: The location 'http://www.w3.org/2001/03/xml.xsd' has not been resolved", for the error line it says "XSD: Attribute reference 'http://www.w3.org/XML/1998/namespace#base' is unresolved".  It also errors on 293 which is similar to the above but pointing at lang instead of base.
It's wierd to me that the parser is trying to resolve the reference to the namespace document since that appears to be just an HTML doc explaining namespaces, NOT an XSD or DTD.  But this Atomschema2.xsd isn't something I made up, it was downloaded.
What am I supposed to be doing here?  Is there a better atom schema?  Should I modify the schema I downloaded to chage the references?  Some third thing?

A: The error is typically caused by the DTD DOCTYPE on top of the xml.xsd file; I never tried to figure it out with JAXB, but I can guarantee that if you download, fix the references, and remove the <!DOCTYPE...[]> from the xml.xsd file, JAXB will work out of the box with the schema you pointed at (I just tried it in NetBeans 7.1 with no issues). I guess a good question now is how to get JAXB's xjc to ignore the DTD...
UPDATE: -catalog in the command line might do it, please read this.


text:
Q: Why does my code shows headers already sent even if it is in if else condition? I have a very simple code which checks whether email address exists in the table or not. If it exists then alert Already Exists and redirect to another page and if it doesn't exist then insert into table. Inserting when the email address is not present in the table is happening properly and is getting redirected to the respected page but when the email is existing in the table then although it alerts that username exists, it shows headers already sent at error
My code is
<?php
    require_once('connection.php');
    $tbl_name="cust_contacts";
        $ccode=$_POST['ccode'];
        $name=$_POST['name'];
        $des=$_POST['desig'];
        $dep=$_POST['dep'];
        $phone=$_POST['phone'];
        $mobile=$_POST['mob'];
        $email=$_POST['email'];
        $check="select * from $tbl_name where email='$email'";
        $checkqry=mysql_query($check);
        if($checkqry['error'])
            die(mysql_error());
        $countcheck=mysql_num_rows($checkqry);
        if($countcheck==0)
        {
            $qry="insert into $tbl_name(cust_code,name,designation,department,phone,mobile,email) values('$ccode','$name','$des','$dep','$phone','$mobile','$email')";
            if (!mysql_query($qry))
            {
                die('Error: ' . mysql_error());
            }
            header("location:index.php?customername=$ccode#pop4");
        }
        else
        {
            echo '<script type="text/javascript">alert("User already exists. Try editing the user");</script>';
            header("location:index.php?customername=$ccode");
        }
    //$count=mysql_num_row($result);
    //if($count==1)
?>

A: If you want to show an alert message and redirect to another page, you can use JavaScript like this:
Befor (Your Original Code):
    echo '<script type="text/javascript">alert("User already exists. Try editing the user");</script>';
    header("location:index.php?customername=$ccode");

After:
 echo '<script type="text/javascript">';
 echo  'alert("User already exists. Try editing the user");';
 echo  'location.href = "index.php?customername=' . $ccode. '";';
 echo '</script>';

Hope this helps.

A: I had the same problem, and as far as i can see if the header() is use after some code then it throws an error, so maybe try removing the echo statement.
If that doesn't work, i used a function call. this the function:
function redirect($url) {
  if (!headers_sent()) {
      header('Location: '.$url);
      exit;
} else {
    echo '<script type="text/javascript">';
    echo 'window.location.href="'.$url.'";';
    echo '</script>';
    echo '<noscript>';
    echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
    echo '</noscript>'; exit;
}

}
And this is an example of the call:
if($mail->send()) {
        // redirect to thank you message.
        redirect( BASE_URL . "thanks/");
        exit;
    } else {
        $error_message = "There was a problem sending the email: " . $mail->ErrorInfo;
    }

Here i used it to redirect if an email was successful sent using PDO class, but it can used anywhere.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Error in creating dataframe: java.lang.RuntimeException: scala.Tuple2 is not a valid external type for schema of string I have created a schema with following code
val schema=  new StructType().add("city", StringType, true).add("female", IntegerType, true).add("male", IntegerType, true)

Created a RDD from
val data = spark.sparkContext.textFile("cities.txt")

Converted to RDD of Row to apply schema
    val cities = data.map(line => line.split(";")).map(row => Row.fromSeq(row.zip(schema.toSeq)))

 val citiesRDD = spark.sqlContext.createDataFrame(cities, schema)

This gives me an error
java.lang.RuntimeException: Error while encoding: java.lang.RuntimeException: scala.Tuple2 is not a valid external type for schema of string

A: You don't need a schema to create a Row, you need the schema when you create the DataFrame. You also need to introduce some logic how to convert your splitted line (which produces 3 strings) into integers:
here a minimal solution without exception-handling:
val data = sc.parallelize(Seq("Bern;10;12")) // mock for real data

val schema = new StructType().add("city", StringType, true).add("female", IntegerType, true).add("male", IntegerType, true)

val cities = data.map(line => {
val Array(city,female,male) = line.split(";")
  Row(
    city,
    female.toInt,
    male.toInt
  )
 }
)

val citiesDF = sqlContext.createDataFrame(cities, schema)

I normally use case-classes to create a dataframe, because spark can infer the schema from the case class:
// "schema" for dataframe, define outside of main method
case class MyRow(city:Option[String],female:Option[Int],male:Option[Int])

val data = sc.parallelize(Seq("Bern;10;12")) // mock for real data

import sqlContext.implicits._

val citiesDF = data.map(line => {
val Array(city,female,male) = line.split(";")
  MyRow(
    Some(city),
    Some(female.toInt),
    Some(male.toInt)
  )
}
).toDF()


text:
Q: How to set a field will be change by if statement in models for Django? I have a field in models that the True/False value will be affect by other field. May I know how to set it?
models.py:
class Product(models.Model):
  storage_amount = models.PositiveIntegerField()
  if storage_amount == 0 or None:
    out_of_storage_or_not = models.BooleanField(default=True)
  else:
    out_of_storage_or_not = models.BooleanField(default=False)

A:   class Product(models.Model):
    storage_amount = models.PositiveIntegerField()
    out_of_storage_or_not = models.BooleanField(default=False)

    def save(self,*args, **kwargs):
      if self.storage_amount==0 or None:
        self.out_of_storage_or_not=True
      super().save(*args, **kwargs)

A: Try this
class Product(models.Model):
    storage_amount = models.PositiveIntegerField()
    out_of_storage_or_not = models.BooleanField(default=False)

    def save(self, *args, **kwargs):
        self.out_of_storage_or_not = False if self.storage_amount else True
        super().save(*args, **kwargs)


text:
Q: Optimización de código Tengo una aplicación donde realizo un registro de usuario en una API, cuando un usuario se registra en mi página.
Mas adelante, si el usuario añade mas valores al registro o modifica alguno de los datos con los que se registró al principio, realizo un PUT en la API para actualizar estos nuevos datos.
Todas estas funcionalidades funcionan correctamente, pero me gustaría optimizar la clase que uso para conectarme en dicha API i hacer el POST i el PUT.
Actualmente tengo lo siguiente class, que la llamo des de la APP principal:
class connectSettings{

private $api_user = 'API_USER';
private $api_key = 'API_KEY';
private $resource = 'contact';

public function connectPUT($data_json, $contact){

    $ch = curl_init('https://'.$this->api_user.':'.$this->api_key.'@API_URL'.$contact);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);

    // Set HTTP Header for POST request
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/json',
            'Content-Length: ' . strlen($data_json))
    );

    // Submit the POST request
    $result = curl_exec($ch);

    // Close cURL session handle
    curl_close($ch);

}

public function connectPUSH($data_json){

    $ch = curl_init('https://'.$this->api_user.':'.$this->api_key.'API_URL'.$this->resource.'/');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);

    // Set HTTP Header for POST request
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/json',
            'Content-Length: ' . strlen($data_json))
    );

    // Submit the POST request
    $result = curl_exec($ch);

    // Close cURL session handle
    curl_close($ch);
}

}
La function connectPUT actualiza los datos y la connectPUSH los añade al registrarse el usuario.
Como se puede ver las dos functions son casi identicas. Solamente cambia la línea de la conexión en la URL.
$ch = curl_init('https://'.$this->api_user.':'.$this->api_key.'@API_URL'.$contact);

Y en el connectPUT añado una linea de mas:
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");

Quiero optimizar las dos funciones en una, para no repetir todo el código, pero no consigo hacerlo correctamente.
He pensado en crear una variable por cada linea que se vaya a repetir y luego llamarla en cada función pero estamos en las mismas, no optimizo nada.

A: Modifica tu función, agregando un parámetro, luego te quedara algo asi:
public function connectPUT($data_json, $contact, $update){

    if($update){
        $ch = curl_init('https://'.$this->api_user.':'.$this->api_key.'API_URL'.$this->resource.'/');
    }else{
        $ch = curl_init('https://'.$this->api_user.':'.$this->api_key.'@API_URL'.$contact);
    }

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_POST, true);

    if($update){
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    }

    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);

    // Set HTTP Header for POST request
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/json',
            'Content-Length: ' . strlen($data_json))
    );

    // Submit the POST request
    $result = curl_exec($ch);

    // Close cURL session handle
    curl_close($ch);

}

Se puede poner todo en el mismo bloque, pero lo he puesto separado para que se vea mejor.
Te paso a explicar tu duda.
En la clase principal tienes en alguna linea de codigo algo como: connectPUSH($data) ó connectPUT($data, $contacto), que es donde invocas a la funcion.
Pues estas lineas tienes que modificarlas y poner: connectPUT($data, $contacto, $update).
Ahora, si estas haciendo el registro, $contacto sera vacio (""), y update seria FALSE. Quedando asi: connectPUT($data, "", false)
En el otro caso quedaria asi: connectPUT($data, $contacto, true)
Si no quieres complicarte con otra variable, ($update), puedes hacer lo mismo que en el ejemplo de codigo, pero con el $contacto, es decir:
if ($contacto == ""){
  //...es nuevo registro
} else{
  //...es un update
}

Espero te sirva. Un saludo.


text:
Q: Can an IGBT overcurrent damage the driver? We are using an hex IGBT module (datasheet: http://www.microsemi.com/document-portal/doc_view/7751-aptgt150ta60pg-rev2-pdf) which is driven by two separate IGBT drivers, the 2SC0108T2D0-07 (datasheet http://www.igbt.cn/UserFiles/CONCEPT/2SC0108T2Dx_Manual.pdf), using two channels on one, one channel on the other module to drive the "bottom" three IGBTs in the module as a DC-DC converter.
During some testing, we had set the current limit too high for the module, and something stopped working. During the de-bug stages, we took the unit apart and discovered that the drivers both had faults. After replacing both drivers, the faults went away, and we could run the circuit to check the IGBTs themselves.
By putting a voltage across each IGBT in turn, we checked that there was no current flowing when the IGBT was stopped, and then that current was flowing when the IGBT was activated again. By this method it looks like all the IGBTs are fully working.
The question is then: how did an over current event knock out both of the IGBT drivers, yet not damage the IGBTs themselves?


text:
Q: No SharePoint 2013 WorkFlow in the list Goal:
Use SharePoint 2013:s workflow in my custom list
Problem:
In the picture below it only has SharePoint 2010 Workflow only.
What method should I do in order to find out why I don't have SharePoint 2013 workflow?

A: Ensure that you have fully installed and configured workflow for SP2013: http://technet.microsoft.com/en-us/library/jj658588.aspx
http://technet.microsoft.com/en-us/library/jj193478.aspx
That should make the "SharePoint 2013 Workflow" Platform Type appear in SPD2013.


text:
Q: Leaflet map remains present when modal is active. Why? I'm working on a web app using Leaflet.js to create a map, Vue.js to manage the app, and Bulma for CSS.
Bulma has a "modal" element, that should appear in front of everything else when its class is set to is-active. I have this working, except the map does not fade into the background like the rest of the page.
I don't know much about modals. Does anyone have any idea why the map would remain visible while everything else fades? Thanks!!

A: Without seeing this in action I can only guess. But most likely the modal, the dark overlay behind the modal, and the map all have their css position set to absolute or relative and a number assigned to their css z-index.
The z-index of the map is likely higher than that of the modal or the background overlay, causing it to appear in front. The solution, if this is the case is to modify the z-index values to get them in the right order.


text:
Q: Regex for two words in ASP.NET? Basically I'm trying to code a regex that will accept two words and nothing else, the words can contain any letters, but not numbers.
I've currently got:
^[a-zA-Z+#-.0-9]/s^[a-zA-Z+#-.0-9]$

Although I know for sure this is wrong because it isn't allowing two words separated by a space, it also currently allows numbers.
Does anybody know what Regex code I need to get this working?

A: This should do the trick! :)
//Allow letters and numbers
^\w+\s\w+$

//Allow only letters
^[a-zA-Z]+\s+[a-zA-Z]+$

A: While something using the \w shorthand character class might work for you, you specifically wrote can contain any letters, but not numbers, so you'd have to use:
^[a-zA-Z]+\s+[a-zA-Z]+$

Your expression allows numbers (and + and any of these characters: #$%&*()-',.) because you included all of these characters in your character class [a-zA-Z+#-.0-9], which means lowercase and uppercase letters, + sign, any ASCII characters from # to . (which includes $%&*()-',), and any numbers 0-9.
The shorthand character class \w allows letters, numbers, and underscore (_)
I might recommend running through a short tutorial on regex before deciding its the solution for you...

A: How about something like:
^\w+\s+\w+$


text:
Q: Assignment doesn't work Lua (corona SDK) local car={};
local car_mt = { __index=car };
function car.new(_x, _y,_color,_animation_index)
    local ncar=
    {
        x=_x or 0;
        y=_y or 0;
        color=_color or 0x005500;

        print(_animation_index,animation_index);
        animation_index=(_animation_index or 1);
        print((_animation_index or 1),animation_index);
    }
    return setmetatable(ncar,car_mt);
end
return car;

The output is

nil nil
1 nil

_color and _animation_index are not defined when car.new is called:
local pcar=require("car")
...
function scene:enterScene( event )
    local group = self.view
    physics.start();
    local car1=pcar.new(200,200);

end

Why hasn't the animation_index value changed after assignment?
UPD:
I can't assgn to variables with names like rranimation_index too.
        rranimation_index=(_animation_index or 1);

        rranimation_index=5;
        print((_animation_index or 1),rranimation_index);

is:

1 nil

It's not likely to be caused by already used global variables names.

A: All the variables were nils before end of table creation. Solved by working with vars after it:
local car={};
local car_mt = { __index=car };
local C=require("_const");
function car.new(_x, _y,_color,_animation_index)
    local ncar=
    {
        x=_x or 0;
        y=_y or 0;
        color=_color or 0x005500;
        animation_index=(_animation_index or 1);
        img;
        frames=0;
    }
    function ncar:setup()
        self.img=display.newImageRect((C.CARS_DIR..C.ANIMATIONS_CARS[self.animation_index]) or C.EMPTY_IMAGE,50,120,true);
    end
    ncar:setup();
    return setmetatable(ncar,car_mt);
end
return car;


text:
Q: WIX Uninstall an EXE Package I am working on a wix installer that Installs WebView2. I have this working. However, when I uninstall WebView2 is left on my system. How do I remove the WebView2 when the uninstaller is ran?
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" >
    <Bundle Name="Build.Bootstrap.Installer" Version="1.0.0.0" Manufacturer="Company Name" UpgradeCode="GUID">
        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense"/>
        <Chain>
            <ExePackage Id="InvokeBootstrapper" Name="Install WebView2 Runtime" Cache="no" Compressed="no"
PerMachine="yes" Vital="yes" SourceFile="MicrosoftEdgeWebview2Setup.exe"
InstallCommand=" /silent /install" InstallCondition="NOT (REMOVE OR WVRTInstalled)" />

            <!-- TODO: Define the list of chained packages. -->
            <!-- <MsiPackage SourceFile="path\to\your.msi" /> -->
        </Chain>
    </Bundle>
</Wix>


text:
Q: When the same user ID is trying to log in on multiple devices, how do I kill the session on the other device? Asp.net Identity What I want to do is to limit a user ID to only being able to log in to one device at a time. For example, user ID "abc" logs in to their computer. User ID "abc" now tries to log in from their phone. What I want to happen is to kill the session on their computer.
I'm using Asp.net mvc and identity membership. I've an idea to create a table logins. save userId , current session or claim id and when someone logs in delete all sessions according to the userId, except current.
Can someone provide actual code how to implement such functionality?

A: The main role of SecurityStamp is to allow this functionality. Change it, and all of the signed in devices will be effectively signed out.
For more information, you can read What is ASP.NET Identity's IUserSecurityStampStore<TUser> interface?


text:
Q: Automatically logout when user deletes Android Authenticator account from settings I have developed an app that uses the Android Authenticator API (AccountManager), so I can add or delete accounts via the settings screen.
If I log out from my application, I can programatically delete the account and return the user to the AccountAuthenticatorActivity. However, if the user deletes the account manually from the settings screen, I would like that my app (which is running) detected this condition and automatically logged out when re-opened.
I have thought in overwriting the onResume method in each activity (or extend from a new Activity class) and ask the Authenticator with getAuthTokenByFeatures, so when the app is resumed it would ask the user to login if the account was removed. Yet I'm new to Android and don't know if this is a good approach.

A: Ok, I have discovered the addOnAccountsUpdatedListener method in the AccountManager class.
Using that, I answer my own question. In the onCreate method of the main activity of my app:
    accountsListener = new OnAccountsUpdateListener() {
        @Override
        public void onAccountsUpdated(Account[] accounts) {
            Account[] myAccounts = mAccountManager.getAccountsByType(AccountGeneral.ACCOUNT_TYPE);
            if (myAccounts.length == 0) {
                // The account has been deleted
                Intent i = new Intent(mContext, PromptLoginActivity.class);
                startActivity(i);
                finish();
            }
            return;
        }
    };

    mAccountManager.addOnAccountsUpdatedListener(accountsListener, null, true);


text:
Q: Can I insert my code to my coded interface using Win32? I have a C program and I am supposed to add an interface to it. Can I insert my code to my coded interface using Win32?
Example: Here is my code to convert binary into octal.
void biTodec(){

    long long n;
    int dec = 0, i = 0, rem;
    printf("Enter a binary number: ");
    scanf("%lld", &n);
    while (n != 0) {
        rem = n % 10;
        n /= 10;
        dec += rem * pow(2, i);
        ++i;
    }
    printf("%lld in binary = %d in decimal", n, dec);
    return 0;
}

Now, I want my button in my API when clicked to perform the conversion. Here is my Win32 design
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include <stdlib.h>

LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM,LPARAM);

void AddMenus(HWND);
void AddControls(HWND);

HMENU hMenu;

int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hPrevInst, LPSTR args, int ncmdshow){

    WNDCLASSW kim = {0};
    kim.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
    kim.hCursor = LoadCursor(NULL, IDC_ARROW);
    kim.hInstance = hinst;
    kim.lpszClassName = L"myWindowClass";
    kim.lpfnWndProc = WindowProcedure;

    if(!RegisterClassW(&kim))
        return -1;

    CreateWindowW(L"myWindowClass",L"Number System Converter",
      WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 500, 500,
      NULL,NULL,NULL,NULL);
    MSG msg={0};
    while(GetMessage(&msg, NULL,NULL, NULL)){
        TranslateMessage(&msg);
        DispatchMessage(&msg);

    }
    return 0;
}

LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){

    switch(msg){

        case WM_COMMAND:

        switch(wp){
        case 1:
            MessageBoxA(hWnd, "This project was made by bla bla for
        seven (7) days. He had no any prior idea on interface so he spent
      the 6 out of 7 days just for researching. Copyright 2021", "About
      the
      project", NULL);

            break;
        case 2:
            MessageBeep(MB_OK);
            break;
        case 3:
            PostQuitMessage(0);
            break;
        case 4:
            MessageBeep(MB_OK);
            break;
        case 5:
            MessageBeep(MB_OK);
            break;
        }
    case WM_CREATE:
        AddMenus(hWnd);
        AddControls(hWnd);
        break;

    case WM_DESTROY:
        PostQuitMessage(0);
        break;

    default:
        return DefWindowProcW(hWnd,msg,wp,lp);

    }
}
void AddMenus(HWND hWnd){
    hMenu = CreateMenu();
    HMENU hFileMenu = CreateMenu();
    HMENU hSubMenu = CreatePopupMenu();

    AppendMenu(hSubMenu,MF_STRING, 4, "File");
    AppendMenu(hSubMenu,MF_STRING, 5, "Folder");
    AppendMenu(hSubMenu, MF_SEPARATOR, NULL, NULL);

    AppendMenu(hFileMenu,MF_POPUP,(UINT_PTR)hSubMenu, "Open");
    AppendMenu(hFileMenu,MF_STRING, 2, "Save");
    AppendMenu(hFileMenu, MF_SEPARATOR, NULL, NULL);
    AppendMenu(hFileMenu,MF_STRING, 3, "Exit");

    AppendMenu(hMenu, MF_POPUP ,(UINT_PTR)hFileMenu, "Options");
    AppendMenu(hMenu, MF_POPUP ,1, "Help");

    SetMenu(hWnd, hMenu);
}

void AddControls(HWND hWnd){
    CreateWindowW(L"Static",L"Choose the number system to be converted",
      WS_VISIBLE|WS_CHILD,100, 30, 300, 20, hWnd, NULL, NULL, NULL );

    CreateWindowW(L"Edit", L"", WS_VISIBLE|WS_BORDER| WS_CHILD, 60, 80, 120, 30, hWnd, NULL, NULL,NULL);
    CreateWindowW(L"Button", L"Generate", WS_VISIBLE|WS_BORDER|WS_CHILD,
    200, 80, 80, 20, hWnd, NULL, NULL, NULL);
    CreateWindowW(L"Edit", L"", WS_VISIBLE|WS_BORDER| WS_CHILD, 300, 80,
    120, 30, hWnd, NULL, NULL,NULL);

    CreateWindowW(L"Button", L"Binary",
      WS_VISIBLE|WS_BORDER|WS_CHILD|BS_RADIOBUTTON|WS_TABSTOP, 60, 150,
      120, 20, hWnd,NULL , NULL, NULL);
    CreateWindowW(L"Button", L"Decimal",
     WS_VISIBLE|WS_BORDER|WS_CHILD|BS_RADIOBUTTON|WS_TABSTOP, 60, 180,
     120, 20, hWnd,NULL , NULL, NULL);
    CreateWindowW(L"Button", L"Octal",
     WS_VISIBLE|WS_BORDER|WS_CHILD|BS_RADIOBUTTON|WS_TABSTOP, 60, 210,
     120, 20, hWnd, NULL, NULL, NULL);
    CreateWindowW(L"Button", L"Hexadecimal",
      WS_VISIBLE|WS_BORDER|WS_CHILD|BS_RADIOBUTTON|WS_TABSTOP,60, 240,
     120, 20, hWnd, NULL, NULL, NULL);

       CreateWindowW(L"Button", L"Binary",
      WS_VISIBLE|WS_BORDER|WS_CHILD|BS_RADIOBUTTON|WS_TABSTOP, 300, 150,
      120, 20, hWnd,NULL , NULL, NULL);
    CreateWindowW(L"Button", L"Decimal",
      WS_VISIBLE|WS_BORDER|WS_CHILD|BS_RADIOBUTTON|WS_TABSTOP, 300, 180,
      120, 20, hWnd,NULL , NULL, NULL);
    CreateWindowW(L"Button", L"Octal",
       WS_VISIBLE|WS_BORDER|WS_CHILD|BS_RADIOBUTTON|WS_TABSTOP, 300, 210,
     120, 20, hWnd, NULL, NULL, NULL);
    CreateWindowW(L"Button", L"Hexadecimal",
       WS_VISIBLE|WS_BORDER|WS_CHILD|BS_RADIOBUTTON | WS_TABSTOP, 300,
      240, 120, 20, hWnd,NULL, NULL, NULL);

}

Is it possible to insert my code to the API or not? If not, can you suggest what I have to learn to create a user interface in my program?

A: I have fixed your code and plugged your conversion function. I have not added more conversion - you'll do it yourself with my example - nor have I added enhancements.
To fix the Windows API part, note that I have:
Saved all HWND for the controls to be able to get/set values.
Used BS_AUTORADIOBUTTON and WS_GROUP so that radio button works as usual.
Used identifiers for all controls to be able to check which operation was requested.
Fixed various warnings using appropriate casts.
#include <stdio.h>
#include <wchar.h>
#include <windows.h>
#include <windowsx.h>
#include <stdlib.h>
#include <math.h>

#define ID_CONV_SRC_BINARY       0x100
#define ID_CONV_SRC_OCTAL        0x101
#define ID_CONV_SRC_DECIMAL      0x102
#define ID_CONV_SRC_HEXADECIMAL  0x103
#define ID_CONV_DST_BINARY       0x200
#define ID_CONV_DST_OCTAL        0x201
#define ID_CONV_DST_DECIMAL      0x202
#define ID_CONV_DST_HEXADECIMAL  0x203
#define ID_GENERATE              0x300

int srcConvert = 0;
int dstConvert = 0;

LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);

void AddMenus(HWND);
void AddControls(HWND);

HMENU hMenu;
HWND hNum, hOut;
HWND hWndInEdit;
HWND hWndOutEdit;
HWND hWndSrcBinary;
HWND hWndSrcOctal;
HWND hWndSrcDecimal;
HWND hWndSrcHexadecimal;
HWND hWndDstBinary;
HWND hWndDstOctal;
HWND hWndDstDecimal;
HWND hWndDstHexadecimal;

void biTodec(
    wchar_t * const inBuf,
    wchar_t * const outBuf,
    size_t outBufSize)
{
    long long n;
    int dec = 0, i = 0, rem;
    if (swscanf(inBuf, L"%lld", &n) == 1) {
        while (n != 0) {
            rem = n % 10;
            n /= 10;
            dec += rem * (1 << i);//pow(2, i);
            ++i;
        }
    }
    swprintf(outBuf, outBufSize, L"%d", dec);
}

int WINAPI WinMain(
    _In_ HINSTANCE hinst,
    _In_opt_ HINSTANCE hPrevInstance,
    _In_ LPSTR lpCmdLine,
    _In_ int nShowCmd)
{
    WNDCLASSW kim = { 0 };
    kim.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
    kim.hCursor = LoadCursor(NULL, IDC_ARROW);
    kim.hInstance = hinst;
    kim.lpszClassName = L"myWindowClass";
    kim.lpfnWndProc = WindowProcedure;

    if (!RegisterClassW(&kim))
        return -1;

    HWND hWnd = CreateWindowW(L"myWindowClass", L"Number System Converter", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
        100, 100, 500, 500, NULL, NULL, NULL, NULL);
    MSG msg = { 0 };
    while (GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return (int)msg.wParam;
}

void Generate(HWND hWnd)
{
    wchar_t inBuf[30];
    wchar_t outBuf[30];

    if (Button_GetCheck(hWndSrcBinary))
        srcConvert = ID_CONV_SRC_BINARY;
    else if (Button_GetCheck(hWndSrcDecimal))
        srcConvert = ID_CONV_SRC_DECIMAL;
    else if (Button_GetCheck(hWndSrcOctal))
        srcConvert = ID_CONV_SRC_OCTAL;
    else if (Button_GetCheck(hWndSrcHexadecimal))
        srcConvert = ID_CONV_SRC_HEXADECIMAL;
    else
        srcConvert = 0;

    if (Button_GetCheck(hWndDstBinary))
        dstConvert = ID_CONV_DST_BINARY;
    else if (Button_GetCheck(hWndDstDecimal))
        dstConvert = ID_CONV_DST_DECIMAL;
    else if (Button_GetCheck(hWndDstOctal))
        dstConvert = ID_CONV_DST_OCTAL;
    else if (Button_GetCheck(hWndDstHexadecimal))
        dstConvert = ID_CONV_DST_HEXADECIMAL;
    else
        dstConvert = 0;

    GetWindowText(hWndInEdit, inBuf, sizeof(inBuf) / sizeof(inBuf[0]));
    if ((srcConvert & 0xFF) == (dstConvert & 0xFF))
        wcscpy(outBuf, inBuf);
    else if ((srcConvert == ID_CONV_SRC_BINARY) && (dstConvert == ID_CONV_DST_DECIMAL))
        biTodec(inBuf, outBuf, sizeof(outBuf));
    else {
        MessageBox(hWnd, L"Not implemented yet", L"Warning", MB_OK);
        outBuf[0] = 0;
    }
    SetWindowText(hWndOutEdit, outBuf);
}

LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
    switch (msg) {
    case WM_COMMAND:
        switch (wp) {
        case ID_CONV_SRC_BINARY:
        case ID_CONV_SRC_DECIMAL:
        case ID_CONV_SRC_HEXADECIMAL:
        case ID_CONV_SRC_OCTAL:
        case ID_CONV_DST_BINARY:
        case ID_CONV_DST_DECIMAL:
        case ID_CONV_DST_HEXADECIMAL:
        case ID_CONV_DST_OCTAL:
        case ID_GENERATE:
            Generate(hWnd);
            break;
        case 1:
            MessageBox(hWnd, L"Copyright 2021", L"About the project", MB_OK);
            break;
        case 2:
            MessageBeep(MB_OK);
            break;
        case 3:
            PostQuitMessage(0);
            break;
        case 4:
            MessageBeep(MB_OK);
            break;
        case 5:
            MessageBeep(MB_OK);
            break;
        }
        break;
    case WM_CREATE:
        AddMenus(hWnd);
        AddControls(hWnd);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProcW(hWnd, msg, wp, lp);
    }
    return 0;
}

void AddMenus(HWND hWnd) {
    hMenu = CreateMenu();
    HMENU hFileMenu = CreateMenu();
    HMENU hSubMenu = CreatePopupMenu();

    AppendMenu(hSubMenu, MF_STRING, 4, L"File");
    AppendMenu(hSubMenu, MF_STRING, 5, L"Folder");
    AppendMenu(hSubMenu, MF_SEPARATOR, 0, NULL);

    AppendMenu(hFileMenu, MF_POPUP, (UINT_PTR)hSubMenu, L"Open");
    AppendMenu(hFileMenu, MF_STRING, 2, L"Save");
    AppendMenu(hFileMenu, MF_SEPARATOR, 0, NULL);
    AppendMenu(hFileMenu, MF_STRING, 3, L"Exit");

    AppendMenu(hMenu, MF_POPUP, (UINT_PTR)hFileMenu, L"Options");
    AppendMenu(hMenu, MF_POPUP, 1, L"Help");

    SetMenu(hWnd, hMenu);
}

void AddControls(HWND hWnd) {
    CreateWindowW(L"Static", L"Choose the number system to be converted",
        WS_VISIBLE | WS_CHILD, 100,
        30, 300, 20, hWnd, NULL, NULL, NULL);

    hWndInEdit = CreateWindowW(L"Edit", L"", WS_VISIBLE | WS_BORDER | WS_CHILD, 60, 80, 120, 30, hWnd, NULL,
        NULL, NULL);
    CreateWindowW(L"Button", L"Generate", WS_VISIBLE | WS_BORDER | WS_CHILD, 200, 80, 80, 20, hWnd,
        (HMENU)ID_GENERATE,
        0, NULL);
    hWndOutEdit = CreateWindowW(L"Edit", L"", WS_VISIBLE | WS_BORDER | WS_CHILD, 300, 80, 120, 30, hWnd, NULL,
        NULL, NULL);

    hWndSrcBinary = CreateWindowW(L"Button", L"Binary", WS_VISIBLE | WS_BORDER | WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,
        60, 150, 120, 20, hWnd, (HMENU)ID_CONV_SRC_BINARY, NULL, NULL);
    hWndSrcDecimal = CreateWindowW(L"Button", L"Decimal", WS_VISIBLE | WS_BORDER | WS_CHILD | BS_AUTORADIOBUTTON,
        60, 180, 120, 20, hWnd, (HMENU)ID_CONV_SRC_DECIMAL, NULL, NULL);
    hWndSrcOctal = CreateWindowW(L"Button", L"Octal", WS_VISIBLE | WS_BORDER | WS_CHILD | BS_AUTORADIOBUTTON,
        60, 210, 120, 20, hWnd, (HMENU)ID_CONV_SRC_OCTAL, NULL, NULL);
    hWndSrcHexadecimal = CreateWindowW(L"Button", L"Hexadecimal", WS_VISIBLE | WS_BORDER | WS_CHILD | BS_AUTORADIOBUTTON,
        60, 240, 120, 20, hWnd, (HMENU)ID_CONV_SRC_HEXADECIMAL, NULL, NULL);

    hWndDstBinary = CreateWindowW(L"Button", L"Binary", WS_VISIBLE | WS_BORDER | WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,
        300, 150, 120, 20, hWnd, (HMENU)ID_CONV_DST_BINARY, NULL, NULL);
    hWndDstDecimal = CreateWindowW(L"Button", L"Decimal", WS_VISIBLE | WS_BORDER | WS_CHILD | BS_AUTORADIOBUTTON, ,
        300, 180, 120, 20, hWnd, (HMENU)ID_CONV_DST_DECIMAL, NULL, NULL);
    hWndDstOctal = CreateWindowW(L"Button", L"Octal", WS_VISIBLE | WS_BORDER | WS_CHILD | BS_AUTORADIOBUTTON,
        300, 210, 120, 20, hWnd, (HMENU)ID_CONV_DST_OCTAL, NULL, NULL);
    hWndDstHexadecimal = CreateWindowW(L"Button", L"Hexadecimal", WS_VISIBLE | WS_BORDER | WS_CHILD | BS_AUTORADIOBUTTON,
        300, 240, 120, 20, hWnd, (HMENU)ID_CONV_DST_HEXADECIMAL, NULL, NULL);

}

There are plenty room for enhancements. I made the minimum to answer your question. Open more questions if you need more help.


text:
Q: How to query a database with an array in the where clause in PHP? Hi guys I am trying to select all the users in my database with an array of USER ID. I am coding in PHP and this is my code so far but I get an error saying I am trying to use an array.
$relative = $this->db->select('user_id, fname, surname')->get_where('user_view_view', array('user_id'=>$mytest))->result_array();

My array of user ids is called:
$mytest

What am I doing wrong?

A: try something like that
$query = $this->db
    ->select('user_id, fname, surname')
    ->from("user_view_view")
    ->where_in("user_id",$myTest)
    ->get();

$relative = $query->result_array();

the reason why it won't work is because get_where doesn't accept an array as field_value
you should get an error with the message "Array to string conversion"


text:
Q: Button in navigation bar How do I add a button to navigation bar that appears only in a particular view controller? And also how to add different buttons to different view controller that is embedded in navigation controller.

A: You don't have to add buttons to navigation bar, rather you could add bar button items. If you want you can customise bar button item to meet your requirements like setting a custom image as suggested by @Pushpendra.
Programatically:
Your View Controller is responsible for providing bar button item(s) for it's navigation bar. Create bar button items inside each of your view controller's viewDidLoad() or in init() if you have overridden it.
Storyboards:
It's pretty handy to drag n drop bar button items from storyboard editor and have the outlets setup so that you can change the behaviour later.
If you are precisely looking to control the behaviour, then you can add or remove a bar button as and when needed depending on your conditional requirements.
class FooViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        /// Assuming this view controller presented/pushed with navigation controller
        let buttonItem = UIBarButtonItem(barButtonSystemItem: .save, target: self, action: #selector(FooViewController.buttonItemAction(sender:)))
        self.navigationItem.leftBarButtonItem = buttonItem
    }

    @IBAction func buttonItemAction(sender: UIBarButtonItem)    {
        /// some action
    }
}

class BarViewController: UIViewController {
    var buttonItem: UIBarButtonItem?
    var showButtonItem = false

    override func viewDidLoad() {
        super.viewDidLoad()

        /// Assuming this view controller presented/pushed with navigation controller
        buttonItem = UIBarButtonItem(barButtonSystemItem: .bookmarks, target: self, action: #selector(BarViewController.buttonItemAction(sender:)))
        self.navigationItem.leftBarButtonItem = buttonItem
    }

    @IBAction func buttonItemAction(sender: UIBarButtonItem)    {
        /// some action
    }

    @IBAction func toggleButtonItem(sender: UIButton)   {
        self.navigationItem.rightBarButtonItem = (self.showButtonItem == true) ? self.buttonItem : nil
    }
}

If this is what you are not looking for then update your question along with the code that you have tried.

A: try this :-
 extension UIViewController {
func addButton(img:String){
    let imgIcon = UIImage(named: img)

 let btn = UIBarButtonItem(image: imgIcon, style: .plain, target:
  self, action: #selector(self.btnAction))
   // if you want  to set right button then add right bar button item
    self.navigationItem.leftBarButtonItem = btn
  }

   func btnAction(){
   }

func removeButton() {
    self.navigationItem.leftBarButtonItem = nil

}

      }

when you want to add button
  in viewDidLoad :-
  self.addButton(img:"imageName")

also if you want to perform separate action on all view controller then
  call this on controller
     override func btnAction() {
      }

to remove :-
   self.removeButton()

if you want to add different button on different controller add the button in viewDidLoad and remove in viewWillDisappear

A: Drag a bar button item in your navigation bar for the specific view controller in your storyboard

A: The best solution is
Create Viewcontroller inherit from UIViewController or UITableViewController and write a method for setupNavigationButton or buttonText or
(Better to add an action method on a super controller also)
eg:
-(void) setupNavigationButton {
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"button1" style:UIBarButtonItemStylePlain target:self action:@selector(buttonActin:)];
}

and call this method on viewDidLoad on the created controller
Next when you create your own controller add this viewcontroler as your parent view controller. So it will automatically add that view.
(You want to write an action on your controller)
Using above method, it saves only one line. But you can save more lines. Let's assume you want to change only text and action on that button.
If it is only you need to change text, write a method to return button text
(Following line for your baseviewcontroller)
-(NSString *) rightButtonText {
  return @"";
}

and add following codes for baseviewcontroller
-(void)setNavigationControler {
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:[self rightButtonText] style:UIBarButtonItemStylePlain target:self action:@selector(buttonActin:)];
}

and call it on baseviewcontroller
Now your every view controller, you need to override rightButtonText and create selector method and do that action.
Assume you don't need to add that button for some viewcontroler. Then you have a few options
1) Remove baseviewcotroler inheritance from your viewcontroller
2) After call supper viewDidload add following code
 self.navigationItem.rightBarButtonItem =

3) Override setNavigationControler method on your controller with the blank method body.
-(void)setNavigationControler {}


text:
Q: Installing IIS using Azure Management Libraries and DSC extension handler I'm looking at the the new Azure Management Libraries example and specifically the example creating a VMSS with Linux and Apache here.
I wonder what would be the alternative to create a Windows Server 2016 VMSS with IIS? Assuming the DSC script is at hand, like the one referenced by Windows VMSS and Desired State Configuration with Azure Resource Manager templates.
Maybe there is a way (I have not found) a Window Server (2016 Core) image with IIS to somehow use an ARM template for this part?
<edit: It appears if the Windows Core 2016 images either are recent

*

*Very recent or

*Perhaps available.

Either way it looks like at least there isn't an image with (and nothing but) IIS preinstalled.


text:
Q: jquery shorttag issue

if I have a standard start/end tag, then jquery is fine

Testing

output
I m here
Testing

if I have shorttag

it only displays
I m here

how could configure the jquery to support shorttag ?

A: Short tags are closed. They are not meant to hold content or child elements. It's a self closing tag.
What you're trying to do is invalid.
Just stick to tags that open and close if you want child content and short tags if you don't need to add any child content to the HTML tag.


text:
Q: Symfony Panther - Rollback db transaction in functional test I want to rollback all queries made inside the symfony/panther test.
With the normal WebTestCase i can achieve that by
protected function setUp()
{
    parent::setUp();
    $this->client = static::createClient();
    $this->client->disableReboot();
    $this->connection = $this->client->getContainer()->get('doctrine')->getConnection();
    $this->connection->beginTransaction();
    $this->connection->setAutoCommit(false);
}
protected function tearDown()
{
    parent::tearDown();
    if ($this->connection->isTransactionActive()) {
        $this->connection->rollback();
    }
}

How to achieve the same with Panther since there is no $client->disableReboot() method?


text:
Q: Cannot change istance in a queryset/dropdownlist, with no errors I am currently developing an app to manage apartments. One requirement is to be able to handle payment from tenants by utilizing his room/security deposit. For this case, the involve models will be as follows (minimum setup):
'''
class Billing(models.Model):
    bill_batch = models.ForeignKey(BillBatch, on_delete=models.PROTECT)
    reservation = models.ForeignKey(
        'tenants.Reservation', on_delete=models.PROTECT)
    rental = models.DecimalField(max_digits=9, decimal_places=2, default=0)
    electricity = models.DecimalField(max_digits=9, decimal_places=2, default=0)
    water = models.DecimalField(max_digits=9, decimal_places=2, default=0)

class SecurityDeposit(models.Model):
    payments = models.ForeignKey(Payment, on_delete=models.PROTECT)
    reservations = models.ForeignKey(
        'tenants.Reservation', on_delete=models.PROTECT)
    deposit_date = models.DateField(default=date.today,
                                verbose_name='Date deposited')
    deposited_amount = models.DecimalField(max_digits=9, decimal_places=2,
                                       default=0, verbose_name='Amount deposited')

class ConsumeDeposit(models.Model):
    billings = models.ForeignKey(
        'billings.Billing', on_delete=models.PROTECT)
    security_deposits = models.ForeignKey(
        SecurityDeposit, on_delete=models.PROTECT)
    pay_date = models.DateField()
    allocated_amount = models.DecimalField(
        max_digits=9, decimal_places=2, default=0)

'''
In my code,
'''
class ConsumeDepositEditMixin(object):

    def dispatch(self, request, *args, **kwargs):

        self.security_deposit = get_object_or_404(
           SecurityDeposit, id=self.kwargs['deposit_id'])

        # the qs must contain only billings exclusive to the reservation
        # by which the deposit is allocated for; that is, deposit can't be consumed
        # by other room reservations of the same tenant
        self.billing_qs = Billing.objects.filter(
           reservation=self.security_deposit.reservations)

        # TODO: need fix, can't change billing item
    return super().dispatch(request, *args, **kwargs)

    def get_form(self, form_class=None):
        form = super().get_form(form_class=None)
        form.fields['security_deposits'].widget = forms.HiddenInput()
        form.fields['billings'].queryset = self.billing_qs
        return form

'''
In the tests I made, I have 2 billings available, say Billing-July and Billing-August for a reservation, say Reservation-1. The problem is, when I tried to change the billing instance, the saving process will finish without error but when I open back the ConsumeDeposit form, the change was not saved. I tried to remove the filter in the self.billings_qs, and it worked just fine.
I also tried to change the queryset to this,
'''
reservations = Reservation.objects.filter(id=self.security_deposit.reservations_id)

self.billing_qs = Billing.objects.filter(
        reservation_id__in=Subquery(reservations.values('id')))

'''
But the same result. What corrections should I make in order to make this work?


text:
Q: Output after Triangulation (MATLAB) isn't accurate I am using MATLAB- CVST to perform Stereo Camera Calibration. From 28 images (6 X 7 corners), stereoParams are obtained (stereoParams.MeanReprojectionError = 0.3168).
Next, I took took a checkerboard stereo pair (CB_I1 & CB_I2).
To CB_I1 I applied the following functions:

*

*undistortImage

*detectCheckerboardPoints

*generateCheckerboardPoints

*extrinsics: This gives me Translation vector (T) and Rotation Matrix (R)

Next, To both CB_I1 & CB_I2, I apply the following functions:

*

*undistortImage

*detectCheckerboardPoints

*triangulate: this gives me worldPoints

*Inverse Translation and Rotation Transform

This is my code:
CB_I1_undist = undistortImage(CB_I1, stereoParams.CameraParameters1);
CB_I2_undist = undistortImage(CB_I2, stereoParams.CameraParameters2);

[imagePoints1, ~] = detectCheckerboardPoints(CB_I1_undist);
[imagePoints, ~] = detectCheckerboardPoints(CB_I2_undist);

worldPoints = triangulate(imagePoints1,imagePoints,stereoParams);

Translated_pnts = zeros(size(worldPoints));
Translated_pnts(:,1) = worldPoints(:,1) - T(1);
Translated_pnts(:,2) = worldPoints(:,2) - T(2);
Translated_pnts(:,3) = worldPoints(:,3) - T(3);
Rotated_pnts = Translated_pnts * (R');

Transformed_points = Rotated_pnts;

Ultimately, Transformed_points looks like this:

and so on....for 42 points.
How do I interpret this? I expect Transformed_points to be:

since each square size is 40mm.

*

*Primarily, is this an error?

*What is the cause? Is it because of the high reprojection error? (if so, how can it be minimised?)

*How can I reduce this as much as possible?

*I want this as close as possible to the ideal value.  What are the different ways by which I can improve my algorithm's accuracy?

Let me know if you need any other information.

A: You say you have a mean re-projection error of 0.3~.
If I calculate the distance between your first and second point:
sqrt((-0.2006+0.1993)^2+(-1.2843-39.1922)^2+(3.0466-2.0656)^2)
ans >>
      40.4884

Well thats what you expect right? Its not 100% accurate of course.
Also,look again at your points. They are exactly where you expect them to be. Instead of 120 you have 120.06. Instead of 160, you have 159.94.
you are missing the points by around 0.3 millimeters. 0.3 MILIMETERS.
Take a ruler and try to measure 0.3 millimeters!!

*

*Thats 4 time a human hair!

*Its more or less the minimum distance the human eye can distinguish!

*3 times the with of paper!

*0.6 times the size OF A BACTERIA! (amoeba Proteus)

WOW, I think thats a quite good error to have, dont you?
Anyway, you can decrease that error using more calibration images, but yeah, I'd say you are doing a good job already.
A good way of measuring the error so it has more meaning is to calculate the pixel error, not the real physical error. If you divide the error by the length of a pixel, you can know how many pixels of error you have. You will see that most likely in your case you are having sub-pixel accuracy (pixel error < 1). This is very good because it means that your error is smaller than what you can measure, so, in some sense (not really, but yeah) you are breaking the Shanon principle! Good job

Source of random data: http://www.wolframalpha.com/input/?i=300+micrometres

A: To Ander's answer I would just like to add that you should be sure to measure the square size very precisely, using a caliper. If you can get sub-millimeter accuracy on that, that will have an effect on your reconstruction accuracy. Also, please be sure not to use lossy compression on your images, i. e. no jpeg. Jpeg artifacts will also decrease your accuracy.


text:
Q: How to search data from multiple endpoints in NServiceBus? I'm currently trying to figure the best solution for following problem using NServiceBus: I have GUI that user can use to search different things, but information about those things is spread in multiple services/databases. Lets say for example that user is searching for list of parks in a city, but each district of this city keeps only info of their parks in their own database (which they expose by web-services). I need NServiceBus to send message to each endpoint(district) what info user needs, wait for response, and then when it gets it from all endpoints (and only then) send it back to user(GUI). User is only interested in full information so Bus needs to know if every endpoint have send its response or not (it also needs to be in real time so Bus will assume that endpoint is offline and will send failure message if it will take too much time). Endpoints can change at any time so code needs to be easy to maintain. Best option will be that adding/removing endpoints can be done without changes in code.
Here are my thoughts about possible solution:

*

*Publish/subscribe pattern lets me easily send message to multiple endpoints and add/remove endpoints at will by subscribing/unsubscribing without changing code of publisher. Problem: By definition publisher doesn't know how many subscribers are there (and what they are), so waiting for all of the subscribers to responds become difficult, if not impossible.

*Request/response pattern lets me easily tell endpoints that i want answer and I will know if endpoint responded yet. Problem: Every time I need to add/remove new endpoint I need to change code of the sender. Also scalability may be a problem.
My question: Is there any way to combine those patterns? Or am I looking at this problem wrong way? Is there even a way that I can achieve all I want?

A: I think you are indeed looking at the problem the wrong way.
It sounds like you want to query multiple services and aggregate the information for presentation in the UI.  Generally speaking, a bus is not a good choice for straight querying.  A bus is great for sending commands to a specific endpoint, and for publishing state changes as they happen.
If you are performing a query against an endpoint, your best bet would be to model and expose a query (via something like WebAPI).


text:
Q: How to find the type of an img file so it can be mounted I have a .img file and I want to see what's inside of it. I tried mounting it, but I don't know what filesystem type it is. Is there a way to detect what it is so I can mount it? I'm using Ubuntu.
Essentially the command I think I need to do to browse it is:
mount -t <FS TYPE HERE> myimage.img /path/to/mount/dir/

A: mount itself has an autodetection option, -t auto, you can always try that.
To check the type of some file, I usually find file to be a pretty good tool, perhaps file -k if you want to be sure it does not stop at the first match.
If file fails to give you any useful information, you will have to look at the file yourself and try to find some clue (say, for example, by looking at hexdump -C). Some file types will have the file type name or some type-specific code at the beginning. That's what file relies on to detect many of the filetypes.


text:
Q: Explain proof of sum equivalence I need to prove:
$$\sum_{k=1}^n k{n \choose k} 2^{k-1} = n3^{n-1}$$
I have the answer, but I can't understand how can I get from step 1 to step 2?!
Step 1: $$(1+x)^n = \sum_{k=0}^n {n \choose k} x^k $$
Step 2: $$n(1+x)^{n-1} = \sum_{k=1}^n k{n \choose k} x^{k-1} $$
Step 3: $$x=2$$ gives $$\sum_{k=1}^n k{n \choose k} 2^{k-1} = n3^{n-1}$$
I feel this is simple, but can't figure it out.. I tried substitute $$n = n-1$$ and I get strange results...

A: We have $$(1+x)^n = \sum_{k=0}^n {n \choose k} x^k $$.
By the uniqueness of the derivative:
$$\frac{\mathrm{d}}{\mathrm{d}x}(1+x)^n = \frac{\mathrm{d}}{\mathrm{d}x}\left(\sum_{k=0}^n {n \choose k} x^k\right) $$
Assuming that the derivative of a sum is the sum of the derivatives we have:
$$n(1+x)^{n-1} = \sum_{k=0}^n k{n \choose k} x^{k-1}$$
$x=2$ yields your result.
The proof that "derivative of a sum is the sum of a derivatives" is some analysis-y work that I'm assuming is not required for a simple exercise here. You may want to look it up, however, it is rather interesting.

A: An alternative approach avoids differentiation:
$$\sum_{k=1}^n k \binom{n}{k} 2^{k-1}
= \sum_{k=1}^n k \frac{n}{k}\binom{n-1}{k-1} 2^{k-1}
= n \sum_{k=1}^n \binom{n-1}{k-1} 2^{k-1}
= n (1+2)^{n-1}
= n 3^{n-1}$$


text:
Q: Creating string with varaibles using asp.net mvc I am new to mvc and maybe to some of my question will seem naive.
I have this code in view Index.chtml page:

I need to create in src attribute of the frame element string that has two varaibles session and weblayout but, it seems I am doing it's wrong.
And value of the session and weblayout will not generated and will be like this:
/mapserver201x/mapviewernet/ajaxviewer.aspx?SESSION= + session + &weblayout= + weblayout

and I need it to be like this:
if value of session is:654276345234GSAKJD333,
and value of weblayout is: Library://Exercise/WebCast/Hello.weblayout

the result should be:
    /mapserver201x/mapviewernet/ajaxviewer.aspx?SESSION=654276345234GSAKJD333
&weblayout=Library://Exercise/WebCast/Hello.weblayout

Any idea how to implement it?

A: <frame src="/mapserver201x/mapviewernew/ajaxviewer.aspx?session=@ViewData["sessionId"]&weblayout=@ViewData["webLayout"]" />

All you've done in your example is assigned the value of those ViewData keys to JavaScript variables which won't work as you have expected.
You would definitely benefit from an introduction to MVC to get the basics.
Also, trying typing your code into your question instead of using an image, it makes it easier to apply an answer using your original code.


text:
Q: Excel - Take Average of Monthly Data I have a historical data set for commodity pricing. Throughout the data set, the data starts inputting prices on specific days, rather than the average of the entire month. In order to keep the flow of having only the average pricing for the months.
In the best case scenario, I would use an Averageif function, however, the data for each month doesn't display a consistent amount of days.
How can I automate this the process: If the month is the same as the previous row and different than the next row, calculate the average of the ^ rows until you hit the next month.
Here's a simple display of what I mean:
]1

A: You can use a pivot table to get the output you want. It will also be neatly organized instead of having your averages mixed in with a mostly blank column. Photo below shows the set-up/output of a pivot table generated with random data.

A: For a solution without pivot tables, you can use the following formula :
=AVERAGEIFS($B$1:$B$30;$A$1:$A$30;">="&(A1-DAY(A1)+1);$A$1:$A$30;"<="&EOMONTH(A1;0))
The above example is from cell C1, and can be copied down the entire list. The dates are in $A$1:$A$30 and the values in $B$1:$B$30. The first conditions test on the first day of the month (calculated as A1-DAY(A1)+1),and the second condition as last day of the month (calculated as EOMONTH(A1;0)
This will obviously put the average value of the month on each row, but will also work if your data is not sorted on date. If this is the case, and you only want to display one number per month in the column (as in your own example), you can add an additional IF statement wrapped around the formula:
=IF(EOMONTH(A2;0)=EOMONTH(A1;0);"";AVERAGEIFS($B$1:$B$30;$A$1:$A$30;">="&(A1-DAY(A1)+1);$A$1:$A$30;"<="&EOMONTH(A1;0)))
So it will display empty in all cells, except where the month changes.


text:
Q: Win 7: Changing Desktop Background Colour (but not image) I'm on Windows 7. I have a problem with my desktop background - I use the Community Showcase: Natural Landscapes 2 theme. Very nice it is too.
However, the shape of the images on my 4:3 second monitor leaves black bars above and below the image (TIL these black bars are called "mattes"), like so:

Windows 7 allows transparency on window borders (as well as the Start Menu and Taskbar). I like this feature, so I've enabled it. However, when I'm using (for example) Excel on my second monitor, the black bars combined with the windows border transparency makes it tricky to read the filename (especially given I use a privacy screen).

What I'd like to do is change my desktop background colour from black to something a bit lighter so there's more contrast between filename text and background.
What I've tried
I could turn transparency off, but that would also turn it off on the taskbar and start menu. I like the transparency, so would like to avoid this. Neither changing the colour tone of the transparent effect, or increasing the intensity of the transparency colour makes a difference.
I've tried searching for tips on how to change the desktop settings in Windows 7 but they all want to tell me how to change the background image, not the actual desktop canvas colour.
In the days of Windows XP and earlier, I'd go into Display Properties and just set the background colour. In Windows 7 this option seems to have gone.
Any ideas?

A: After trawling through control panel for quite a while, I finally stumbled on the answer - my old friend Display Properties from XP hasn't been completely retired after all. It's just been well hidden. To find it:

*

*Right-click the desktop and select Personalize

*At the bottom of the screen, select Window Color

*Click Advanced appearance settings...

*Change Desktop Color 1

Changing to an intermediate grey seems to do the trick - I can now read filenames in Excel.

And the background on its own doesn't look too terrible (although obviously not as good as black).


text:
Q: Python Bottle Image part 2 im unsure, if im not understanding the bottle tutorial correctly but this code:
from bottle import static_file

@route('/images/<filename:re:.*\.png>')
def send_image(filename):
    return static_file(filename, root='/path/to/image/files', mimetype='image/png')

is supposed to look through the folder for that image name without having to add .png to the name, right?
so if i have a file named python.png
i would type into the browser .../python, and this should get me the image, right?
because im not getting the image but i do get it when i add .png to it

A: Well, answering the question you asked in the comment...
@route('/images/:filename')
def send_image(filename):
    return static_file(filename + '.png', root='/path/to/image/files', mimetype='image/png')


text:
Q: Get NSCFDictionary sub key values I am parsing JSON data and I get  a JSON tree like

2015-10-13 15:29:10.563 JsonProject[29154:1434114] requestReply: (
          {
          DNumb = 512421421;
          DTempData = "";
          DUUID = 12;
          Id = 1;
      },
          {
          DTempData = "";
          Id = 2;
      },

As you can see here sub key values, I got values under NSCFDictionary data, but i don't know how to parse them.  I am new on objective-c and came from .net, is there way to parse these values?

A: Following is your reponse ;
equestReply: (
    {
      DNumb = 512421421; DTempData = ""; DUUID = 12; Id = 1;
     },
     { DTempData = ""; Id = 2;
    })

So you can get values as follows ;
NSMutableArray* dict = [yourResponseObject  ObjectForKey:"equestReply"];
NSString* = [[dict objectAtIndex:index] valueForKey:"DNumb"];
NSString* = [[dict objectAtIndex:index] valueForKey:"DTempData"];
NSString* = [[dict objectAtIndex:index] valueForKey:"DUUID"];

A: First you need to convert your JSON data into an NSArray:
NSError *jsonError;
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&jsonError];

then you can access each value using its key like this:
NSDictionary *jsonItemDic = jsonArray[0];
NSString *dTempData = [jsonItemDic objectForkey@"DTempData"];

P.S.: The sample data you have sent is incomplete, it seems though that your JSON is an Array of dictionaries. My Answer relies on this theory.
Update:
From the screenshots I have seen, you data is stored inside a root dictionary. That means your object's root is a dictionary with a key called GetVerifiedDevices and the value of an array of dictionaries. You can access the devices array like this:
NSArray *devices = [your_json_object objectForKey:@"GetVerifiedDevices"];

and then query your devices like this:
for(NSDictionary *deviceDic in devices){
  NSString *dTempData = [deviceDic objectForkey@"DTempData"];
//And others like above
}

Cheers. M.


text:
Q: If $ \frac{1}{4} \leq x^2 + y^2 \leq 1$, then is it true that $0 \leq \left|-(x^2+y^2)-1\right|\leq \frac{3}{4}$? If $ \frac{1}{4} \leq x^2 + y^2 \leq 1$, $x$, $y \in \mathbb{R}$, then are the following lines true?
$$ -1 \leq -(x^2 + y^2) \leq -\frac{1}{4} \quad \quad (1)$$
$$ \Rightarrow -2 \leq -(x^2 + y^2) - 1 \leq -\frac{5}{4} \quad \quad (2) $$
$$\Rightarrow  -2 \leq -(x^2 + y^2) - 1 < \frac{3}{4} \quad \quad (3)$$
$$\Rightarrow 0 \leq \left|-(x^2+y^2)-1\right| <\frac{3}{4} \quad \quad (4)$$
I am most concerned with inequalities (3) and (4). Since $\frac{-5}{4} < \frac{3}{4}$, I obtained (3). Furthermore, $|-(x^2 + y^2) -1| \geq 0$ since it is an absolute value. Hence, the (4).
Are these justifications valid?

A: Inequality (1) is correct; you have reflected your given inequality across the origin.
Inequality (2) is correct; you have shifted (1) in the negative direction.
When working with inequalities, it is unusual to throw away information. This is what you have done by writing (3), although it is correct.
(2) is preferable to (3) for you, in particular, because it shows that $-(x^2+y^2)-1$ is a negative number. I would move from (2) to (3b) by another reflection across the origin:
$$ \frac{5}{4}  \leq -(-(x^2 + y^2) - 1) \leq 2, \quad \quad \quad \quad \quad (3b)$$
$$ \frac{5}{4}  \leq (x^2 + y^2) + 1 \leq 2. \quad\quad  \quad \,\,\,\quad \quad \quad \quad (4b)$$
Your error in moving from the true (3) to the wrong (4) is of this form:
$$ a < b \quad \implies \quad |a| < b.$$
Of course the part of (4) claiming that $|a| \geq 0$ for any $a$ is correct.

A: We have that
$$\left|-(x^2+y^2)-1\right|=x^2+y^2+1>0$$
and
$$\frac{1}{4} \leq x^2 + y^2 \leq 1 \iff \frac{5}{4} \leq x^2 + y^2 +1\leq 2$$
but
$$0 \leq \left|-(x^2+y^2)-1\right|\leq \frac{3}{4} \iff 0 \leq x^2+y^2+1\leq \frac{3}{4}<\frac 5 4$$
Note that in your derivation from $(3)$ to $(4)$ we have
$$-2 \leq -(x^2 + y^2) - 1 < \frac{3}{4} \implies 0 \leq \left|-(x^2+y^2)-1\right|\leq 2$$


text:
Q: Date conversion issue in ios I have an issue of converting time into 24 hours from 12 hours. For this I did all the required things and followed mostly all the stack overflow answers but it didn't help me. What exactly I need to do is I have a NSString object having time (not date) in 12 hours like 6:00 pm and I need to change this in 24 hours (18:00). Here is what I did for this :
NSString* dateString = startTime;
NSDateFormatter* fmt = [NSDateFormatter new];
[fmt setDateFormat:@"HH:mm"];
NSDate* date = [fmt dateFromString:dateString];

But it returns me nil date. What can be missing here?
Update :
One more thing,12 hours time gives me correct result but 'am' and 'pm' are small letters so is there any procedure to have these in capital letters.

A: NSString* dateString = @"6:00 pm";
NSDateFormatter* dateFormat = [NSDateFormatter new];
[dateFormat setDateFormat:@"h:mm a"];
NSDate* date = [dateFormat dateFromString:dateString];
[dateFormat setDateFormat:@"H:mm"];
return [dateFormat stringFromDate: date];


text:
Q: Interesting D.E turns into Geometric Limit and Cyclic Group. Me and a friend Observed some very odd behavior of a matrix when trying to solve an ODE
Consider first the 3x3 system where a,b are parameters in the Reals and fine the general solution.
$A=\begin{pmatrix} a & 0 & b \\ 0 & b & 0 \\ -b & 0 & a\end{pmatrix}$
Now a common method would be to just throw in some $\lambda$'s and take a determinant.
An odd choice that may work well is to write $e^{At}$ where A is a matrix now im not all that well versed in this method so please bare with the expansion.
first we split the matrix into
$\begin{pmatrix} a & 0 & 0 \\ 0 & b & 0 \\ 0 & 0 & a\end{pmatrix} + b\begin{pmatrix} 0 & 0 & 1 \\ 0 & 0 & 0 \\ -1 & 0 & 0\end{pmatrix}$ one of the rules of this expansion is that if call the first matrix here $C_{1}$ and the second $C_{2}$ is that $C_{2}$$C_{1}$=$C_{1}$$C_{2}$ this actually work's out for us which was exciting at the time but lets take a closer look at $C_{2}$.
$C_{2}=\begin{pmatrix} 0 & 0 & 1 \\ 0 & 0 & 0 \\ -1 & 0 & 0\end{pmatrix}$ the other basic idea of thsi formula is that $(C_{1})^{n}$= O
where $O=\begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0\end{pmatrix}$
Much to our dismay this never happens oddly you can actually define a infinite sequence here where the sum $(C_{1}^{2k})/2k!$ and $(C_{1}^{2k-1})/(2k-1)!$ and the function actually generates sin and cos's taylor expansion.
The other more interesting thing for me was that ( perhaps for the first time in my life i spotted an idea from set theory that wasn't completely engineered) you can treat $C_{1}$ as generator ie $<C_{1}>=G$ and you get a cyclic group G.
Now for my actually question/s
First Can you solve this ODE using set theory and what this means and explain it to me?
2) can someone construct an isomorphism from this group to anther group with labels that i can look up and go look at what that group means.
3) what is the identity?
I am very bad at anything and everything math but most of all set theory ( click on my profile if you don't believe me) i think if i could look at this with my understanding of the solution to this ODE it would give me a nice new light to look at groups with.


text:
Q: Worklight adapter authentication using different authenticator This is a generalization of my scenario:
the user of a client app, when challenged for security, could choice to authenticate using more than one method, each one different as parameters (and backend systems to be called, in a more complex scenario).
for example:
- choice A using (id, pwd)
- choice B using (name, cellnum, token)
- choice C using (platenumber)
I'm thinking about a possible first solution where define different "submitAuthentication"-like backend procedures, each one with different signature,  that the client calls based on the user's choice.
A possible second solution (really I don't like), to have a single "submitAuthentication"-like backend procedure where first parameters determines the kind of the choice, and following parameters will be mapped on the expected ones.
Is there some guidelines in order to realize that?
thanks.

A: There are multiple ways to accomplish utilizing multiple inputs for authentication. I would suggest looking over the authentication presentations and accompanying samples provided by Worklight:
Authentication Concepts:
http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/08_01_Authentication_concepts.pdf
Form Based Authentication:
http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/08_02_Form_based_authentication.pdf
Adapter Based Authentication:
http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/08_03_Adapter_based_authentication.pdf
Custom Authenticator and Login Module:
http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/08_04_Custom_Authenticator_and_Login_Module.pdf
As I  stated looking at your above scenario you could take many routes to accomplish this. I would say your decisions would mostly be based around what design the login would have on the client side. You could have something as simple as having the user choose what kind of login credentials they want to use and have the different situations handled in your challenge handler.


text:
Q: How to press ENTER with AutoItX on Java I'm trying to build automation script with Selenium(Java) + AutoItX.
In my script I want to press the ENTER key, this is my code:
AutoItX x = new AutoItX();
    Thread.sleep(3000);
    x.send("{ENTER}");

but it doesn't work.. any idea why?

A: You have to use below code.
x.controlSend(windowTitle, "", mainOutlookClass, "{ENTER}");

WindowTitle = Window Name
mainOutlookClass = Class name of that window, which you can find from AutoIT.


text:
Q: store reference variable in c++ I have been struggling hard to find the difference between the following two pieces of code.
This ...
int z=10;
int y=&z;

... is invalid whereas the following does not throw any error:
int& foo()
{
    int z=10;
    return z;
}
main()
{
    int y=foo();
    cout<<y;
    return 0;
}

When I tried to run the program it returned y=10.
My question is:
If y can store the reference of another variable using foo(), why not directly using y=&z?

A:  int y=&z;

The ampersand above does not indicate y is a reference, instead you're applying the address of operator to z, meaning you're taking its address.
 int& y=z;

Here y is a reference to z.

In your second example you have undefined behavior because the function foo() returns a reference to a variable that is local to the function. The storage for z within foo() will cease to exist when the function returns, and then accessing it via the returned reference is undefined behavior.

A: If you want to create reference variable do
int z=10;
int& y=z;
//int y = &z; this is not correct.

A: y store values, not references, because y is defined int y instead of int& y. Because of this foo( ) returns a reference, but y stores the value of the reference... that is 10.
Next code will fail:
int& foo()
{
    int z=10;
    return z;
}
main()
{
    int& y = foo(); // <-- now y is a reference
    cout<<y;        // <-- at this point z does not exists
    return 0;
}

A: The problem is with this code:
int& foo()
{
    int z=10;
    return z;
}

z is an internal variable whose scope is with-in foo function. As soon as function body ends, z is no more in the memory. But we have passed the reference of internal variable to the outer world (which is out of its scope).

A: int z=10; // create integer z and set it to the value 10.
int y=&z; // create integer y and set it to the address of z

The code above doesn't have anything to do with references....
int &y = z; // create a reference (y) to integer z

Is more like what you want.

A: In C++, a reference variable is similar to an alias (as-if having different name for accessing the same variable). As such,
int z=10;
int &y=z; // y is a reference variable, and shares same space of z
y++; // this makes z++ effectively, i.e. z becomes 11

and
int y = &z; // your example is wrong, as rvalue is int * and lvalue is int

Now, when you have,
int& foo()
{
    int z=10;
    return z;
}
main()
{
    int y=foo();
    cout<<y;
    return 0;
}

This is dangerous, as you are returning reference of a local variable (z) which is going to be destroyed upon returning from foo.
This should have been used like returning a value (instead of reference), as local variables go out of scope upon return from function. Thus, correct usage is:
int foo() // return by value
{
    int z=10;
    return z;
}
main()
{
    int y=foo();
    cout<<y;
    return 0;
}

Hope this helps.
Advise is that never ever return reference of a local variable.

A: When you use the function, you're simply indicating that the function doesn't push the value on the stack, it instead returns the value by reference.  Somewhat pointless for a simple int, but more useful if you're returning a struct or class.
In the y=&z case, you're attempting to set an int equal to an address.


text:
Q: When is JSF's  body evaluated/executed? We have an Oracle ADF Faces 11.1.1.5 application which integrates Oracle SiteStudio regions through Oracle's OpenWCM tags (e.g. <wcm:placeholder>). As far as these tags are JSP tags (but not JSF components) they must be put inside <f:verbatim> tag in JSF pages:
...
<f:verbatim>
  <wcm:placeholder name="content"/>
</f:verbatim>
...

Unfortunately, we realized that <f:verbatim>'s body is evaluated/executed at each request (even at postback requests and at PPR requests that have nothing to do with this section of the page) and this causes regeneration of the corresponding SiteStudio region unnecessarily, which is a huge overhead.
Could anybody explain when <f:verbatim>'s body is evaluated/executed? How could we workaround this problem?


text:
Q: Is an object a data structure? I know things like arrays, linked lists, etc are data structures...but what about objects?
Like say if I create an object say employee and it stores and keeps track of the employees name, salary, phone number...etc etc.

A: It's a question of semantics really, and I expect it could be argued either way.
When you create an object, you are telling a compiler, or an interpreter to store a group of information together. Usually the interpreter/compiler, will use some type of data structure to store that information (Python uses a hash table for example).
I might call that data structure the object if I pointed it out in a hex dump, but that's just because saying 'the bytes that represents the object' is a bit inconvenient.
You could (and maybe someone has) write a compiler that stores many objects in one data structure. In that case there would be no one to one mapping between object and data structure. So for that reason - I'm going to say no, an object is not a data structure, but it is normally stored in one.

A: Interestingly, before the OOP paradigm  came into vogue, languages like C used struct's (structures).  Which, in C is simply a contiguous block of virtual memory with named offsets (members).  Although that does get more complex with things like unions, etc.
But essentially a structure, as @James pointed out, is exactly that - some collection or grouping of related things together in a way a programmer (or mad scientist) feels is logical.
In the modern programming lexicon, with languages such as Java, C#, etc - your Objects usually represent one real-world thing, such as a Customer, Order, < inset over-used object example here>, etc.  While your data-structures (usually collections in the libraries of the languages I mentioned) represent the containment of multiple "Objects".
Strictly speaking, however (and just to confuse everyone), the data structures in languages like Java and C# are objects!  (i.e. they are referenced passed around, can have methods called on them, etc.)
In a more classical (and perhaps more CS derived) sense, "data structures" are collections of behaviours (typically algorithms) that are used to manage the memory that stores data, while "objects" are that data.


text:
Q: Conflict in Eclipse Feature installation when one of the plugins already exists in the Eclipse instance I have developed an Eclipse Feature Project, and I am using the open-source css validation plugin org.w3c.css in my feature. This plugin is also used by the Aptana Studio eclipse tool. If a user who has Aptana Studio installed in their Eclipse instance also wants to install my feature, a conflict results. Here's the jist:
Cannot complete the install because of a conflicting dependency.
...
    Only one of the following can be installed at once:
        W3C CSS Validator 1.0.0.20110712 (org.w3c.css 1.0.0.20110712)
        CSS Validator 3.0.0.1303365277 (org.w3c.css 3.0.0.1303365277)

What I would like to have happen is the when my feature is being installed, if the org.w3c.css plugin is already installed, it doesn't break the installation. Ideally it would just pick the latest version and use that one, but any way that the installation can complete successfully would be great.
Here's the plugin declaration in my feature.xml, in case its of value:
   <plugin
         id="org.w3c.css"
         download-size="0"
         install-size="0"
         version="0.0.0"
         unpack="false"/>


text:
Q: How to install ffmpeg on CentOS 6 I have been trying to install ffmpeg for 2 days now and had no luck. I have tried countless videos on youtube, step by steps on google with no luck. Any help would be great.
I have a Centos 6 server.
Yes I am using root ssh in terminal on mac.
Commands I tried are:

*

*wget http://mirror.ffmpeginstaller.com/old/scripts/ffmpeg8/ffmpeginstaller.8.0. tar.gz

*tar -xvzf ffmpeginstaller.8.0.tar.gz

*cd ffmpeginstaller.8.0

*./install.sh

A: Static build
Easiest method is to download a recent version that is already compiled.

*

*Download a static build of ffmpeg from https://www.johnvansickle.com/ffmpeg/

*Extract the archive file you just downloaded from the above site

*(optional) Copy or move the ffmpeg file into /usr/local/bin
Compile
If you prefer to make a custom build you can compile. See FFmpeg Wiki: Compile FFmpeg on CentOS.


text:
Q: Python: Multiple HTTP requests at the same time I am looking to set up an HTTP server which takes in some input and then the application needs to send multiple HTTP requests at the same time (to another server). What is the best approach for this?
If I use the Twisted framework, do I still need to use threading?

A: You don't need to worry about threading or thread safety yourself.  Most of the time spent doing HTTP requests is waiting for a response, at which time Python can run other code in parallel safely.  Use some of the libraries and built-in functionality Python has to manage concurrent I/O waits.
You could use gevent.  Twisted has similar functionality but may be more complex to learn to use.  There's also the multiprocessing.dummy functionality built-in to Python.
If you go with something other than Twisted, you can and should use the requests library to do HTTP client stuff in conjunction with the above -- you may need to use grequests, which is a green-threaded variant, to do non-blocking I/O.

A: If you use the Twisted networking engine, you do not need to use threading.  Just issue the requests and wait for the responses by adding callbacks that will execute as they're available.
For a nice easy way to make HTTP requests using Twisted, you might want to consider Treq, a requests-inspired convenience layer for Twisted's HTTP client.

A: Either Threading or Twisted can do this.
ie. If you use twisted, you won't need to use Threading.
Keep in mind that some servers have a limit on the number of connections they will allow from a single IP address.


text:
Q: Group Concat in mysql statement I've got a table called delitems with some colums.
Within my SELECT statement I want to use a GROUP_CONCAT:
 +-------------------------------+-------+--------+--------+-----+
 | COLOR                         | tOTAL | Ptotal | Amount | qty |
 +-------------------------------+-------+--------+--------+-----+
 | BLUE - W = 55,BLUE - W/O = 93 |   148 |    375 |  55500 |   2 |
 +-------------------------------+-------+--------+--------+-----+
 mysql>select GROUP_CONCAT(color,' = ',qty) as COLOR, SUM(qTY) AS tOTAL, suM(p_cost)  as Ptotal, SUM(qty)*SUM(p_cost) as Amount,count(*) qty from delitems where status='3' Group By cont_no;

Everything works fine except the Amount column. The total amount is wrong! Here the correct value:
+-----------------+-------+--------+--------+-----+
| COLOR           | tOTAL | Ptotal | Amount | qty |
+-----------------+-------+--------+--------+-----+
| BLUE - W = 55   |    55 |    125 |   6875 |   1 |
| BLUE - W/O = 93 |    93 |    250 |  23250 |   1 |
+-----------------+-------+--------+--------+-----+
mysql>select GROUP_CONCAT(color,' = ',qty) as COLOR, SUM(qTY) AS tOTAL, suM(p_cost) as Ptotal, SUM(qty)*SUM(p_cost) as Amount,count(*) qty from delitems where status='3' Group By color;

I only want to display it in one line with the correct total amount
Please help.

A: Should be you need sum(a*b) not sum(a)*sum(b)
select
   GROUP_CONCAT(color,' = ',qty) as COLOR
 , SUM(qTY) AS tOTAL
 , suM(p_cost)  as Ptotal
 , SUM(qty*(p_cost) as Amount, count(*) qty
from delitems
where status='3' Group By cont_no;


text:
Q: Include jsp file from another jsp file I deployed a small project on a server (on a shared hosting) and I have a problem there, it cannot see the included file.
So, I have the file:
public_html/test/index.jsp:
that has the code:
<jsp:include page="/WEB-INF/jsps/aaa.jsp"></jsp:include>

and another file: public_html/WEB-INF/jsps/aaa.jsp
And if i access index.jsp like:
www.mydomain.com/test/index.jsp
I get the error:
HTTP Status 500 - javax.servlet.ServletException: File "/WEB-INF/jsps/aaa.jsp" not found

The problem is that I cannot include a file from a different directory!
In the localhost environment, where I developed the project I don't have this problem, but on the server I have it.
Do you know why is this happening? How can I fix it?

A: just try the following code:
<jsp:include page="../WEB-INF/jsps/aaa.jsp"/>

instead of the one you wrote with end tag. <jsp:xxx .. should not have an end tag.. Generally I would suggest you avoid saving your jsp files inside WEB-INF since it's not a good practice (first time I see). and as I suggested earlier you can always mention the whole url as:
<jsp:include page="http://www.domain.com/public_html/WEB-INF/jsps/aaa.jsp"/>

I hope it works for you this time.


text:
Q: calculate tangent Its been a while since classes in trigonometry, I am calculating the height of rockets.  I know that the formula is (distance from base) * Tangent(angle of rocket height).  The trick is I will not be in a place where there will be a calculator.  How can I do this manually?

A: Similar triangles.  Point a stick at the apogee of the rocket.  The ratio of the height of the tip of the stick to the base distance along a level is the same as the ration of the height of the apogee to the level base distance of the apogee.  Then it is a matter of a multiplication and a division which you should be able to do without a calculator.
It was a school exercise a long time ago to measure the heights of trees this way.  It is also the basis of surveying.
Hope this helps.
Ced


text:
Q: Connection to Postgresql database failing I'm trying to connect to my localhost Postgresql database and I'm getting an error:

Connection to database... failed

No other message provided.
I'm using using pgAdmin3 connecting to Postgresql 10.1
I've been connecting to this database using the same user (and password) and another user via my app successfully all the while but it just failed to connect to the database now. No users seems to be able to connect to the database
Edit: after further checks I noticed Postgresql is not listening on the port 5432.
I've checked the postgresql.conf file and it looks fine
   listen_addresses = '*', port = 5432
I'm kind of new to Postgresql. Sorry if it's something obvious I'm missing out. Still looking for how to start postgresql or make it listen on the port.


text:
Q: CRM Dynamics How to trigger a process when a member is added to a list entity I have 3 entities like Member, List and ListMember. Member and List have many-to-many relationship, as a Member can be added to multiple Lists and naturally a list have multiple Members added to itself. I'm trying to keep the related records of Members and List in the ListMember entity. That is, when a Member is added to a List, then there must be a record created in ListMember entity with the Member and List.
My first question is, is there any automated way to do this, that is, can I define ListMember entity as a many-to-many relationship keeper or something like that?
Second question is, if there isn't such a way, how can I trigger a process which creates records with the Member and List in the ListMember entity each time a Member is added into a List, and how can I reach data from both List and the Member in the process?
For more info about the problem, here is my previous question which reduced the situation into this triggering thing:
CRM Dynamics How to set short list - long list relationship

A: You have 2 basic options when it comes to creating a M:M relationship in CRM:

*

*Add the relationship and defining it as M:M will create your ListMemeber Entity for you, and adding a List to a member, or a member to a list will be populated in the ListMember Entity.

*Roll your own Entity that basically does the same thing.  You can also auto-populate fields on the form by looking up the regardingojectid
regObj = Xrm.Page.getAttribute("regardingobjectid").getValue();
The regardingobjectid will return the referencing entity that you came from when creating a new entity.  This will allow you to populate the side of the relationship that you came from, so the user just has to select the other entity.
It sounds like you want option 1, so I won't go anymore in-depth on Option 2.


text:
Q: Form validation causing wrong input in database from form field I'm using a javascript that validates a form by radio buttons being checked, depending on which button is checked I want a value for that button submitted to MySQL but when I select a button it submits the button name to MySQL. changing the name of the button causes the script to stop working. How can I change the script so it allows the button value to post to MySQL instead of the button name?
jsFiddle
function ValidateForm(form) {
ErrorText = "";
if ((form.job_status[0].checked === false) && (form.job_status[1].checked === false)) {
    alert("Before you can get a signature you must mark a selection.\n Is the work completed or do you need to return?");
    return false;
}
if (ErrorText = "") {
    form.submit();
}

}

A: job_status[0] ,job_status[1] means with name job_status two radio buttons exist.
If you change one of the radio buttons name either of job_status[0] job_status[1]  one will exist.So you are getting exception
Instead of doing all that process by default select a radio button.That solves all your problems.I updated the link
see here


text:
Q: heroku cannot find module bcrypt-as-promised? app works in localhost but when I am trying to deploy in heroku, it gets uploaded but app crashes when visited. why did heroku not install bcrypt-as-promised? These are my package.json scripts:
"scripts": {
    "prestart": "babel -d ./build ./server ",
    "start": "node ./build/",
    "bundle": "webpack --config ./webpack.prod.config.js --progress --colors",
    "build": "relay-compiler --src ./js/ --schema ./server/schema.graphql",
    "update-schema": "babel-node ./scripts/updateSchema.js"
  },

and this is my error on heroku logs -t:
Starting process with command `node ./build/`
2017-09-26T04:03:12.946916+00:00 app[web.1]: module.js:471
2017-09-26T04:03:12.946928+00:00 app[web.1]:     ^
2017-09-26T04:03:12.946928+00:00 app[web.1]:
2017-09-26T04:03:12.946927+00:00 app[web.1]:     throw err;
2017-09-26T04:03:12.946929+00:00 app[web.1]: Error: Cannot find module 'bcrypt-as-promised'

this is my first time using bcrypt-as-promised and I am so confused. is it different on other module? what makes it not installed in heroku?


text:
Q: 555 Maximum Duration of Output One more short question on 555. I am required to say what is the maximum possible duration of the output pulse (or signal). I looked it up online (including the datasheet for 555), but found no such parameter. What does it depend on and what is that maximum value (if it exists)?
Thanks!

A: In theory you can generate pulses that last minutes , even hours! But you have to accurately measure the values of resistors and capacitors that you use in your project with NE555. To understand what it depends on, you should understand the working of NE555 as astable oscillator. There is a capacitor charging and discharging, and the period depends on how long does it take to reach a particular value of voltage. If you take a large capacitor and a big resistor, it could take hours.

A: long enough that a CD4060 is a better solution.
Depending on which version of the 555 you choose in excess of about half an hour, but above about 60 seconds a CD4060 starts looking pretty good.


text:
Q: My function echos only "array" I'm trying to create visual composer extension that displays all the child pages.
Somehow it only displays "Array".
Any ideas?
function childpages_func( $childpages = '' ){
      $childpages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc&parent='.$post->ID);
        foreach($childpages as $child){
            "

                ID).' title='.$child->post_title.'>
                    ID)).' title='.$child->post_title.'>

";
        }
        return $childpages;
    }

    /* Display Child Pages */
    function vc_doo_clip_child_pages_func( $atts ) {
     extract( shortcode_atts( array(
            'cp_header' => 'cp_header'
        ), $atts ) );
         $end_content = '
'.$cp_header.'
'.childpages_func().'';

            return $end_content;
    }

Any help will be greatly appreciated ;)
Thanks!

A: You shouldn't return childpages, you should add variable $ret=""; and in each cycle append
foreach(...){
   $ret.="<div...";
}

and return it
In general you should always return a string(or number) in such functions


text:
Q: Caddy server stop working with error "Stopped background certificate maintenance " I am facing an issue with CaddyServer. It stop working. I find a message " Stopped background certificate maintenance "
I run npm run build command in a nuxt2 project. then caddy automatically down.
How:
My Package.json code below:
{
  "name": "uihut",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "export": "nuxt export",
    "serve": "nuxt serve"
  },
  "dependencies": {
    "@nuxtjs/axios": "^5.11.0",
    "@nuxtjs/robots": "^2.5.0",
    "@nuxtjs/sitemap": "^2.4.0",
    "file-saver": "^2.0.5",
    "hooper": "^0.3.4",
    "lodash": "^4.17.20",
    "moment": "^2.29.1",
    "nuxt": "^2.13.0",
    "slugify": "^1.5.0",
    "v-wow": "^1.2.1",
    "view-design": "^4.5.0",
    "vue-clickaway": "^2.2.2",
    "vue-lazyload": "^1.3.3",
    "vue-masonry-wall": "^0.3.2",
    "vue-sweetalert2": "^5.0.5",
    "vue-typed-js": "^0.1.2"
  },
  "devDependencies": {
    "@nuxt/postcss8": "^1.1.3",
    "@nuxtjs/google-analytics": "^2.4.0",
    "@nuxtjs/pwa": "^3.3.5",
    "autoprefixer": "10.4.5",
    "node": "^16.0.0",
    "postcss": "^8.4.21",
    "sass": "^1.55.0",
    "sass-loader": "^10.1.1",
    "tailwindcss": "^3.2.7"
  }
}

Caddy error:
Feb 06 17:58:57 staging-server caddy[58600]: {"level":"info","ts":1675706337.0468912,"logger":"http.acme_client","msg":"validations succeeded; finalizing order","order":"https://acme-v02.api.letsencrypt.org/acme/order/952014366/163268940>
Feb 06 17:58:57 staging-server caddy[58600]: {"level":"info","ts":1675706337.7899773,"logger":"http.acme_client","msg":"successfully downloaded available certificate chains","count":2,"first_url":"https://acme-v02.api.letsencrypt.org/acm>
Feb 06 17:58:57 staging-server caddy[58600]: {"level":"info","ts":1675706337.7907612,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"utm.besnik.net"}
Feb 06 17:58:57 staging-server caddy[58600]: {"level":"info","ts":1675706337.790849,"logger":"tls.obtain","msg":"releasing lock","identifier":"utm.besnik.net"}
Feb 06 17:59:02 staging-server caddy[58600]: {"level":"info","ts":1675706342.5809731,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/stop","remote_ip":"127.0.0.1","remote_port":"39336","heade>
Feb 06 17:59:02 staging-server caddy[58600]: {"level":"warn","ts":1675706342.5811977,"logger":"admin.api","msg":"exiting; byeee!! "}
Feb 06 17:59:02 staging-server caddy[58600]: {"level":"info","ts":1675706342.5815964,"logger":"tls.cache.maintenance","msg":"stopped background certificate maintenance","cache":"0xc0001e1730"}
Feb 06 17:59:02 staging-server caddy[58600]: {"level":"info","ts":1675706342.581959,"logger":"admin","msg":"stopped previous server","address":"localhost:2019"}
Feb 06 17:59:02 staging-server caddy[58600]: {"level":"info","ts":1675706342.5819852,"logger":"admin.api","msg":"shutdown complete","exit_code":0}
Feb 06 17:59:02 staging-server systemd[1]: caddy.service: Deactivated successfully.

A: Just stop daemon Service:
sudo systemctl stop caddy.service
Then Disable :
sudo systemctl disable caddy.service
Then Enable:
sudo systemctl enable caddy.service
Reload all daemon:
sudo systemctl daemon-reload
After that caddy will work.


text:
Q: diazo replaces  tags with  I'm having problems with diazo for plone.
I have <esi:include> tags in my page templates but when I use diazo, all those tags are replaced by <include> even if I use mode="raw" or not.
I've found a ungly workaround:
<xsl:template css:match="include">
    <xsl:text disable-output-escaping="yes"><esi:include src="</xsl:text>
    <xsl:value-of select="@src" />
    <xsl:text disable-output-escaping="yes">"></esi:include></xsl:text>
</xsl:template>

But the <include> tags are not replaced by <esi:include when the html is put with mode="raw".
Any idea?
Thank you very much.

A: If you want bare XSL to be processed in raw mode, you'll need to add method="raw" to your xsl:template tag. You may need to have two versions of your template tag, one for method="raw" and one for default (no method attribute).
Templates in XSL only match if their method matches. If there's no method in the apply specified in the apply template tag, then the method is "default".
When you indicate 'mode="raw"' in Diazo, it puts method="raw" in the apply template call, which skips most post processing, including any XSL templates for which you don't specify method="raw".


text:
Q: Really Confused on a surface area integral can't seem to finish the integral off. Basically the question asks to compute $\int \int_{S} ( x^{2}+y^{2}) dA$ where S is the portion of the sphere  $x^{2}  + y^{2}+  z^{2}= 4$ and $z \in [1,2]$ we start with a chnage of variables
$x=x  $
$y=y$
$ z= 2 \cdot(4-(x^{2}  + y^{2}))^{1/2}$
$Det(u,v)= \begin{bmatrix}
i & j& k \\
1 & 0 & \frac {-x}{(4-(x^{2}  + y^{2}))^{1/2}} \\
0 & 1 & \frac {-y}{(4-(x^{2}  + y^{2}))^{1/2}} \\
\end{bmatrix}=(\frac {x}{(4-(x^{2}  + y^{2}))^{1/2}})i + (\frac {y}{(4-(x^{2}  + y^{2}))^{1/2}})j + k$
$dA=(\frac {x^{2}+y^{2}}{(4-(x^{2}  + y^{2}))} +1)^{1/2}$
$\int \int_{S} (\frac {(x^{2}+y^{2})^{3}}{(4-(x^{2}  + y^{2}))}+(x^{2}+y^{2})^{2})^{1/2}$
Projecting when z=1 and z=2 we have $x^{2}  + y^{2}= 4-1$ $\to r= 0,(3)^{1/2}$
going to polar we have:
$(\frac {r^{6}}{(4-r^{2})}+r^{4})^{1/2}rdrd\theta=(\frac {4r^{4}}{(4-r^{2})})^{1/2}rdrd\theta$
my problem is $2\int^{2\pi}_{0} \int^{(3)^{1/2}}_{0} (\frac {4r^{4}}{(4-r^{2})})^{1/2}rdrd\theta$ there is no nice way i can think of to integrate this. it can also be written as:
$2\int^{2\pi}_{0} \int^{(3)^{1/2}}_{0} \frac {2r^{2}}{((4-r^{2}))^{1/2}}rdrd\theta$

A: It seems that spherical coordinates are more appropriate for calculating  $\iint\limits_{S} ( x^{2}+y^{2}) dA$.
In the last integral
$$
2\int^{2\pi}_{0} \int^{(3)^{1/2}}_{0} \frac {2r^{2}}{((4-r^{2}))^{1/2}}rdrd\theta=
{4\pi}\int^{(3)^{1/2}}_{0} \frac {2r^{2}}{((4-r^{2}))^{1/2}}r\,dr$$
you can make the substitution $r=2\sin{t}.$

A: Sometimes cylindrical coordinates is at least as easy when there is axial symmetry.  The integral to be evaluated becomes
$$2 \pi \int_1^2 dz \, r(z)^3 \sqrt{1+\left ( \frac{d r}{dz} \right)^2} $$
where $r(z) = \sqrt{4 - z^2}$ and $r$ is the distance from the axis to the sphere.  This reduces to, upon evaluation of the terms in the integrand
$$4 \pi \int_1^2 dz \: (4-z^2) = \frac{20 \pi}{3}$$

A: Although the sine substitution probably is the easiest method, here's another one:
If the integrand is a fraction with a square root in the denominator, see if you can write the integrand as the derivative of the square root times another function to pave the way for an integration by parts:
$I = \int \frac{r^3}{\sqrt{4-r^2}}\, \mathrm{d}r = \int -r^2 \frac{-r}{\sqrt{4-r^2}}\, \mathrm{d}r  $
$\: = -r^2 \sqrt{4-r^2} + 2 \int r \sqrt{4-r^2}\, \mathrm{d}r$
$\: = -r^2 \sqrt{4-r^2} - \frac{2}{3} (4-x^2)^{\frac{3}{2}}$


text:
Q: How to simulate/test AJAX exception handler? I have a PrototypeJS AJAX request like this (third party code):
new Ajax.Request(url,
{
    method: 'get',
    onException: function(transport, e)
    {
        //...
    },
    onComplete: function(transport)
    {
        //...
    }
});

and want to test the behavior of onException. I have control over the server side, so I can change the response. But simply returning a 500 status does not do the trick, it is still handled by onComplete.
So what possibilities do I have to trigger the onException handler?

A: onException is only fired when there was an exception while dispatching other callbacks, see here, in Ajax response callbacks. So I'm not sure there is a way to test it.
EDIT:
I read (in french, didn't find anything in english) that if you make a cross-domain request it fires the vent.