Q: Symfony3 - Validation of an embedded form I have an embedded form like this:
-> Parent (class)
|---> Attribute 1 (collection) : children (class) : required
.......|-----> Attribute 1 : child_name (string) : required
.......|-----> Attribute 2 : child_description (string) : required
I want, when I send the form:

*

*There is at least one parent object sent (I mean the children attribute contains at least one row of (child_name and child_description)

If the data received will be like this :

*

*parent[children][__name__][child_name]=value1&parent[children][__name__][child_description]=value2
Where name is the iteration in the ArrayCollection of the attribute children
So when we send two children in the form, we get this data:

*

*parent[children][0][child_name]=value1&parent[children][0][child_description]=value2&parent[children][1][child_name]=value3&parent[children][1][child_description]=value4
I want that:

*If the user will send only nothing (empty form), he gets an error that the atribute children is required.

*If the user will send only the child_name (or the child_description) value, he gets an error that the child_description (or the child_name) is also required. I mean if he doesn't event send the varaible child_name (or child_description) in the form like this:

*

*parent[children][__name__][child_name]=value1 (without the name and the value of the variable parent[children][__name__][child_description])
I tried to validate this form from the Entity But I got some problems.
In the Parent Entity class:
/**
 * Parent
 *
 * @ORM\Table(name="parent")
 * @ORM\Entity
 */
class Parent
{

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @var \Doctrine\Common\Collections\ArrayCollection
     *
     * @Assert\NotBlank(message="Error", groups={"Creation"})
     * @Assert\NotNull(message="Error", groups={"Creation"}))
     * @Assert\Count(
     *      min = 1,
     *      minMessage = "Error",
     *      groups={"Creation"}
     * )
     * @ORM\OneToMany(targetEntity="Children", mappedBy="parent", cascade={"ALL"}, orphanRemoval=true)
     */
    protected $children;

    public function __construct()
    {
        $this->children = new ArrayCollection();
    }

    /**
     * Add child
     *
     * @param Child $child
     * @return children
     */
    public function addChild(Child $child)
    {
        $this->children[] = $child;
        $child->setParent($this);
        return $this;
    }

    /**
     * Remove child
     *
     * @param Child $child
     */
    public function removeChild(Child $child)
    {
        $this->children->removeElement($child);
    }

    public function getChildren()
    {
        return $this->children;
    }

    /**
     * Get id.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }
}

Then, the Child Entity class:
/**
 * Child
 *
 * @ORM\Table(name="child")
 * @UniqueEntity(
 *     fields={"child_name","child_description"},
 *     message="already registred"
 * )
 */
class Child
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var Parent
     */
    private $parent;

        /**
         * @ORM\Column(name="child_name", type="string", length=255 )
         *
         * Assert\NotBlank(message="empty", groups={"Creation"})
         * Assert\NotNull(message="null", groups={"Creation"})
         * @Assert\Length(
         *     min=3,
         *     minMessage="too short",
         *     groups={"Creation"}
         * )
         * @Assert\Type(
         *     type="string",
         *     message="you need a string",
         *     groups={"Creation"}
         * )
         */
        private $child_name;

        /**
         * @ORM\Column(name="child_description", type="string", length=255 )
         *
         * Assert\NotBlank(message="empty", groups={"Creation"})
         * Assert\NotNull(message="null", groups={"Creation"})
         * @Assert\Length(
         *     min=3,
         *     minMessage="too short",
         *     groups={"Creation"}
         * )
         * @Assert\Type(
         *     type="string",
         *     message="you need a string",
         *     groups={"Creation"}
         * )
         */
        private $child_description;

    public function __construct()
    {}

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set childName
     *
     * @param string $childName
     *
     * @return Child
     */
    public function setChildName($childName)
    {
        $this->child_name = $childName;

        return $this;
    }

    /**
     * Get childName
     *
     * @return string
     */
    public function getChildName()
    {
        return $this->child_name;
    }

    /**
     * Set childDescription
     *
     * @param string $childDescription
     *
     * @return Child
     */
    public function setChildDescription($childDescription)
    {
        $this->child_description = $childDescription;

        return $this;
    }

    /**
     * Get childDescription
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->child_description ;
    }

In the Controller class:
public function postChildrenAction(Request $request)
{
    $result = new Parent();
    $em = $this->get('doctrine.orm.entity_manager');
    $form = $this->createForm(ParentType::class, $result, array(
            'validation_groups' => array('Creation', 'Default'),
    ));
    $form->submit($request->request->get($form->getName()));
    if ($form->isSubmitted() && $form->isValid()) {
        //persistance
    }
}

In the ParentType class :
class ParentType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('children', CollectionType::class,array(
                'entry_type' => ChildType::class,
                'required'=> true,
                'allow_add' => true,
                'allow_delete'  => true,
                'by_reference' => false,
                'constraints' => array(new Valid()), // __LINE_A__
                'entry_options' => array(
                        'validation_groups' => $options['validation_groups'],
                        'required'=> true,
                ),
        ));

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => 'Path\NameBundle\Entity\Parent',
            'csrf_protection' => false,
            'validation_groups' => array('Creation', 'Default'),
            'cascade_validation' => true,
            'error_bubbling' => false,
        ]);
    }
}

And finally the ChildType:
class ChildType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('child_name',TextType::class,array('required'=> true,'validation_groups'=>$options['validation_groups']));
        $builder->add('child_description',TextType::class,array('required'=> true,'validation_groups'=>$options['validation_groups']));
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => 'Path\NameBundle\Entity\Child',
            'csrf_protection' => false,
            'validation_groups' => array('Creation', 'Default'),
            'cascade_validation' => true,
            'error_bubbling' => false,
        ]);
    }
}

*The first problem is in the Parent Entity class: when I remove the Assert\Count() constraint from the children attribute, the validation will succeed. So why the constraints NotBlank and NotNull doesn't work ?

*If I comment the line 'constraints' => array(new Valid()) (__LINE_A__) in the ParentType, the constraint UniqueEntity of ChildType will not work. Why ?

*None of the 'required' => true options in the ParentType and ChildType worked. When I send only the child name without a description (or the inverse), I got an SQL error saying that there is a null value of the description.

*When the form is empty the validation will succeed but I need to get an error when some data is missing (for the child object or the parent object).

*The groups option from the Parent/Child Entity classes doesn't work if the form is sent with a missing variable even when I enable 'cascade_validation' => true.
This is too hard.
And to finish with this post, I want to know :

*The constraints that we define in the Entity classes aren't the ones that validates the form ? Because when I create the same constraints in validation.yml (using NotBlank with child_name and child_description) the validation works fine and fails if there is a missing variable/data.

Thank you even by answering me to one of these questions.


Q: Ordenar una tabla en el que el indice de orden sea un valor String Estoy realizando una pagina web en la que agrupa la información de un juego a cada jugador. Está información contiene el rango de la cuenta y los puntos, rango es Bronce, plata etc. Los datos los tengo en una tabla y quiero que se ordenen de mayor rango a menor pero no se como hacerlo.
https://imgur.com/a/m5OkiVd
(esto es como tengo la tabla ahora mismo pero no se ordenarlo.)
Añado el codigo del th :
    echo "";
                    if ($rank[0][tier] != Null ){
                            if ($rank[1][QUEUETYPE] == "RANKED_FLEX_SR" ){
                                $soloq=0;

                            }else{
                                $soloq=1;

                            }

                            echo " ".$summoner[name]." (Nivel  ".$summoner[summonerLevel].") · ".$rank[$soloq][tier]." ".$rank[$soloq][rank]." [".$rank[$soloq][leaguePoints]." LP] W:".$rank[$soloq][wins]." L:".$rank[$soloq][losses]."";

                    }else{
                    echo " ".$summoner[name]." (Nivel  ".$summoner[summonerLevel].") · UNRANKED";
                    }
                    echo "	";

A: Para reordenar arrays multidimensionales puedes usar esto:
<?php

    $users[] = array('name' => 'Sergio', 'age' => 22);
    $users[] = array('name' => 'Carlos', 'age' => 29);
    $users[] = array('name' => 'Iván', 'age' => 24);
    $users[] = array('name' => 'Jorge', 'age' => 21);
    $users[] = array('name' => 'Dani', 'age' => 25);
    $users[] = array('name' => 'Jose', 'age' => 27);
    $users[] = array('name' => 'David', 'age' => 19);
    $users[] = array('name' => 'Esteban', 'age' => 35);

    foreach ($users as $key => $row) {
        $aux[$key] = $row['age'];
    }

    array_multisort($aux, SORT_ASC, $users);

    foreach ($users as $key => $row) {
        echo $row['name'].' '.$row['age'].'
';
    }
 ?>

Fuente: https://www.jose-aguilar.com/blog/multidimensional-array-sort/
  PHP: https://www.php.net/manual/es/function.array-multisort.php

Luego lo pintas.


Q: Link one model more than once I have a function where a user can request a project. The request has 2 fields for other employees to be added.
It's got a field for a person who is responsible for the project (person_responsible) and the employee who is supposed to attend the opening meeting (person_attending).
What I want to know is, since both these fields (person_responsible and person_attending) will be pulling it's data from hr_employees table, how would I set this up in my Project-Model.
At the moment I have the one field set up like this:
public $belongsTo = array(
    'HrEmployee' => array(
        'className' => 'HrEmployee',
        'foreignKey' => 'responsible_person',
        'fields' => 'HrEmployee.employeename',
    )
);

How would I set up the other field?

A: What I do in this cases is to make two associations. Since cake allow to customize relations, you can have two relations to the same model with different names.
public $belongsTo = array(
    'ResponsibleEmployee' => array(
        'className' => 'HrEmployee',
        'foreignKey' => 'responsible_person',
        'fields' => 'HrEmployee.employeename',
    ),
    'AttendingEmployee' => array(
        'className' => 'HrEmployee',
        'foreignKey' => 'person_attending',
        'fields' => 'HrEmployee.employeename',
    )
);

Change the names to adjust your needs. Now, if your model is set as containable and you retrieve the Project model with those models in it, you'll get something like
array('Project' => array(/*data project*/),
      'ResponsibleEmployee' => array(/*name*/),
      'AttendingEmployee' => array(/*name*/)
)

(or another variation of that array depending on how the query was made).


Q: How can you numerically approximate the geodesic midpoint of 2 points on an ellipsoids? Assume we have an arbitrary ellipsoid:
$\frac{x^2}{a^2}+\frac{y^2}{b^2}+\frac{z^2}{c^2}=1$
Or on it's parametric form.
We have 2 arbitrary points on the ellipse $p_1, p_2$. And there is some geodesic line passing through both. There is a midpoint $p_{mid}$ as well.
The goal is to try to approximate this midpoint somehow with the information available.
We can easily calculate the gradient $\nabla E$ where $E$ is the ellipsoid. Now, this gradient points away from the origin of the ellipse. If there is a way to make it point towards $p_{mid}$ we could simply follow the gradient down by $\epsilon$ steps, and we will have found a good approximation of the midpoint.
But I do not know if there is a simple way to compute such an approximation.

A: First of all,
this is not an ellipse -
it is an ellipsoid.
Second,
by doing a search for
"geodesic of ellipsoid"
I found an excellent article
in Wikipedia:
https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid
In particular,
the section titled
"Geodesics on a triaxial ellipsoid"
describes the
solution discovered
by Jacobi
(an absolutely amazing
mathematician -
read his biography).
It involves elliptic integrals,
so your problem
probably can only by solved
numerically.
Your turn.


Q: why xpath cannot get the target element? I am quite new in scraping with xpath. I am trying to scrape product information on Target. I use selenium and xpath successfully get the price and name. But xpath cannot return any value when scraping for product sizeproduct size and sales locationsales location.
For example, for this url"https://www.target.com/p/pataday-once-daily-relief-extra-strength-drops-0-085-fl-oz/-/A-83775159?preselect=81887758#lnk=sametab", xpath for size is:
//*[@id="pageBodyContainer"]/div[1]/div[2]/div[2]/div/div[3]/div/div[1]/text()

xpath for sales location is:
//*[@id="pageBodyContainer"]/div[1]/div[2]/div[2]/div/div[1]/div[2]/span

I also try to get these two elements by using requests but it also did not work. Do anyone know why it happened? Any help appreciated. Thanks.
Following is my code:
    def job_function():
        urlList = ['https://www.target.com/p/pataday-once-daily-relief-extra-strength-drops-0-085-fl-oz/-/A-83775159?preselect=81887758#lnk=sametab',
        'https://www.target.com/p/kleenex-ultra-soft-facial-tissue/-/A-84780536?preselect=12964744#lnk=sametab',
        'https://www.target.com/p/claritin-24-hour-non-drowsy-allergy-relief-tablets-loratadine/-/A-80354268?preselect=14351285#lnk=sametab',
        'https://www.target.com/p/opti-free-pure-moist-rewetting-drops-0-4-fl-oz/-/A-14358641#lnk=sametab'
        ]

        def ScrapingTarget(url):
            AArray = []
            wait_imp = 10
            CO = webdriver.ChromeOptions()
            CO.add_experimental_option('useAutomationExtension', False)
            CO.add_argument('--ignore-certificate-errors')
            CO.add_argument('--start-maximized')
            wd = webdriver.Chrome(r'D:\chromedriver\chromedriver_win32new\chromedriver_win32 (2)\chromedriver.exe',
                                  options=CO)

            wd.get(url)
            wd.implicitly_wait(wait_imp)
            sleep(1)

            #start scraping
            name = wd.find_element(by=By.XPATH, value="//*[@id='pageBodyContainer']/div[1]/div[1]/h1/span").text
            sleep(0.5)
            price = wd.find_element(by=By.XPATH, value="//*[@id='pageBodyContainer']/div[1]/div[2]/div[2]/div/div[1]/div[1]/span").text
            sleep(0.5)
            try:
                size = wd.find_element(by=By.XPATH, value="//*[@id='pageBodyContainer']/div[1]/div[2]/div[2]/div/div[3]/div/div[1]/text()").text
            except:
                size = "none"
            sleep(0.5)
            try:
                sales location = wd.find_element(by=By.XPATH, value="//*[@id='pageBodyContainer']/div[1]/div[2]/div[2]/div/div[1]/div[2]/span").text
            except:
                sales location = "none"
            tz = pytz.timezone('Etc/GMT-0')
            GMT = datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")

            AArray.append([name, price, size, sales location, GMT])

            with open(
                    r'C:\Users\12987\PycharmProjects\python\Network\priceingAlgoriCoding\export_Target_dataframe.csv',
                    'a', newline="", encoding='utf-8') as f:
                writer = csv.writer(f)
                writer.writerows(AArray)

        with concurrent.futures.ThreadPoolExecutor(4) as executor:
            executor.map(ScrapingTarget, urlList)

    sched = BlockingScheduler()
    sched.add_job(job_function,'interval',seconds=60)
    sched.start()


Q: IOS image sizes for buttons I've read the human interface guidelines provided by apple.
Navigation Bar and Toolbar Icon Size:
Target size :
             72px × 72px (24pt × 24pt @3x)
             48px × 48px (24pt × 24pt @2x)
Max size:
             84px × 84px (28pt × 28pt @3x)
             56px × 56px (28pt × 28pt @2x)
Does this apply to regular buttons as well?
I have a few regular buttons with images inside them that are set to Max size (above) but I find its still to small.
Can I change the size to anything I see fit?

A: No. You can choose whatever size you want, just make sure the button or other elements are within safeAreaLayoutGuide.
Besides, the guidelines are just Guidelines , they guide you as to what might look most appropriate as per apple, but these are not necessarily restrictions that must be enforced.

A: They are guidelines not rules, go crazy with it.


Q: Which namespace (IBM.WMQ vs. IBM.WMQAX) should be used in the .NET library for IBM MQ WebSphere (amqmdnet.dll) I am writing an application that gets data from IBM WebSphere MQ.  IBM supplies a DLL with classes to interact with MQ.  However, there appear to be two main namespaces; IBM.WMQ and IBM.WMQAX.  The latter seems to be a newer addition, but the former appears to be what vague answers on various web sites suggest using for .NET applications.  I was hoping someone here might be able to enumerate the real differences and what advantages/disadvantages the classes in each namespace offer.

A: From this thread:

The IBM.WMQ is IBM's version of Neil Kolban's original work of
  converting the Java classes for MQ to classes for the .NET framework.
The IBM.WMQAX is IBM's COM component for accessing MQ (ActiveX)
If you're coding in .NET, use IBM.WMQ since it's managed code. If
  you're coding in VB6 or VC++ then use the ActiveX com component.
You could use the COM component from .NET using COM Interop, but that
  really would only make sense, IF, the classes for .NET were NOT
  available. Seeing that they are, use IBM.WMQ.

A: You need to use IBM.WMQ namespace for developing .NET applications to interact with IBM MQ Queue Manager. The other one, IBM.WMQAX namespace is for ActiveX applications.

A: This thread, linked in the answer by @stuartd contains some valuable information.  While the part in his quote seems partially incorrect, additional comments in the thread do a better job clarifying.  While I never used VB script or ActiveX, and thus don't quite follow the problem that the IBM.WMQAX namespace was looking to solve, I can ascertain from the discussion that the namespace should be avoided when writing a new .NET application from scratch.


Q: How to get array element containing '/' in the string array I have a string array which I have split based on the white space. Now, as per my requirements, I have to get the array element which contains '/' in its contents, but I am not able to get it. I don't understand how to achieve it.
Here is the code that I have tried:
 string[] arrdate = currentLine.Split(' ');

How do I get the array element consisting of a /?

A: Try this:
 string[] arrdate = currentLine.Split(' ');
 var dateItems = arrdate.Where(item => item.Contains("/")).ToArray()

A: foreach (string s in arrdate)
{
   if (s.contains("/"))
   {
       //do something with s like add it to an array or if you only look for one string assign it and break out of the loop.
   }
}

A: if you want to get only one item then try this
// split on the basis of white space
string[] arrdate = currentLine.Split(' ');

// now find out element with '/' using lambda
string item = arrdate.Where(item => item.Contains("/")).FirstOrDefault();

// if you don't want to use lambda then try for loop
string item;
for(int i = 0; i < arrdate.Length; i++)
{
if(arrdate[i].Contains("/"))
{
item = arrdate[i]
}
}

A: // split on the basis of white space
string[] arrdate = currentLine.Split(' ');

// now find out element with '/' using lambda
string item = arrdate.Where(item => item.Contains("/")).FirstOrDefault();

// if you don't want to use lambda then try for loop
string item;
for(int i = 0; i < arrdate.Length; i++)
{
if(arrdate[i].Contains("/"))
{
item = arrdate[i]
}
}


Q: how do i invoke 32 bit gdb installed on Centos 64 I have Centos7 and I see both 32 and 64 bit version of gdb are installed however /usr/bin/gdb is the 64bit version. How can I invoke 32bit gdb version since i need to debug application compiled with -m32 compiler option

A: The 64-bit GDB is perfectly capable of debugging both 64 and 32-bit programs. You don't need to invoke 32-bit GDB.


Q: bashtop and bpytop do not display properly in putty I have installed bashtop or bpytop (on a minimal CentOS install) but I just get a jumbled mess of colour blocks on the screen. I've made sure to do sudo yum upgrade and rebooted, but still garbled output. htop / mc work fine (I guess they use ncurses?). Can someone advise on what I could maybe look at to get bashtop / bpytop working? Maybe I'm missing some essential packages, or a Putty setting is required to get apps like these to render properly?


Q: Npm - fetch vs node-fetch? These package names are pretty confusing, they seem like they do the same thing yet 'fetch' looks to be abandoned yet not marked as deprecated (last commit 3 years ago). Judging from the download counts people are probably downloading 'fetch' when they should get the supported and maintained 'node-fetch' package.
If you're building a Reactjs app, is fetch already built in? If so, is it different than 'node-fetch'?
What is the suggested package npm users should use?
https://www.npmjs.com/package/fetch
https://www.npmjs.com/package/node-fetch

A: A bit of history
Fetch is a standard created in 2015 by the Web Hypertext Application Technology Working Group (WHATWG). It was meant to replace the old and cumbersome XMLHttpRequest as means for issuing web requests. As it was meant to replace XMLHttpRequest the standard was clearly targeted at browsers rather than Node runtime, however due to it's wide adoption and for cross compatibility reasons, it was decided that it should also be implemented in Node.
Nonetheless, it took Node team roughly 3 years to implement experimental fetch in Node v16. Although still experimental it is now enabled by default in Node v18.
Because it took Node dev team so long to implement the Fetch standard, the community took matter in their own hands and created the node-fetch package which implements the Fetch standard.
The fetch package that you have mentioned is just coincidentally named the same as the standard but it has nothing to do with it other than that they both aim to "fetch"/"request" resources from the web.
What should you use?
In the past browsers used XMLHttpRequest API and Node used its own http.request. We now have the opportunity to bring those two ecosystems closer still by having them both use the Fetch API. This increases code interoperability and even allows code sharing between the browser and Node in certain cases.
Now, there are other popular packages out there such as axios or requests that still don't use Fetch under the hood but rather continue using Node's http library. Not using Fetch reduces inter-compatibility and therefore I don't think you should keep using either of them unless they convert, which is unlikely in the near future.
Instead, you should consider using Node's native fetch or node-fetch package . Which one though? Well, my opinion is that the Node's fetch is still in early phases but given it has the support from the core Node team I would bet on that. I suppose node-fetch has a wider adoption of the Fetch standard but I think over time it will become redundant as the Node's native fetch becomes fully implemented.

A: Both does the same thing, only difference what i see is node-fetch is compatible API on Node.js runtime,
fetch is more specific to browser.


Q: Javascript ternary operator -- what is the condition? I read a handful of SOF posts on ternary operators but I'm still confused with this example:
var str = "I want to count";
var counts = {};
var ch, index, len, count;

for (index = 0; index < str.length; ++index) {
    ch = str.charAt(index);
    count = counts[ch];
    counts[ch] = count ? count + 1 : 1; // TERNARY
}

I know the syntax is
condition ? expression1 : expression2
But I am trying to practice and break up the ternary into an if-else.
I don't know what the condition is supposed to be
counts[ch] = count // this isn't a condition, it's assigning a value...

A: The ternary
counts[ch] = count ? count + 1 : 1;

The condition in this expression is not counts[ch] = count but just count and is equivalent to
if (count){
    counts[ch] = count + 1;
}
else {
    counts[ch] = 1;
}

The right hand side of an assignment expression is always evaluated first and the counts[ch] is assigned the result of count ? count + 1 ? 1.

A: You're conflating the ternary with the assignment expression.
The code
counts[ch] = count ? count + 1 : 1;

can also be written as
counts[ch] = (count ? count + 1 : 1);
// but not (counts[ch] = count) ? count + 1 : 1
// that does something entirely different

And then, writing the matching if/else becomes pretty clear
if (count) {
   counts[ch] = count + 1;
} else {
   counts[ch] = 1;
}


Q: kali live usb not persistant I've been searching a lot but can't find the answer to my problem. I made a kali linux live boot flash drive. I am using an UEFI system so I made the drive boot-able using this tutorial
http://community.spiceworks.com/how_to/66948-uefi-kali-linux-live-usb-on-surface-pro
That was succesful in making the drive boot-able. When I boot the drive there are a couple of options for boot. One of them is a persistant mode. However, this mode doesn't work as persistant. None of the changes are saved. So I used this tutorial to try and add persistence.
http://docs.kali.org/downloading/kali-linux-live-usb-persistence
After I completed the tutorial I did not see any other boot options. My understanding is that this should add another mode to boot into. I also tried the original persistence mode and it still does not work. So my question is this... does anyone know how to add the new persistence to the boot menu? Or perhaps why my persistence isn't working?

A: Well after days of trying I finally got to the bottom of it. There is a line under the boot - persistent entry in the grub.cfg that needs to be changed.
linuxefi /live/vmlinuz boot=live noconfig=sudo username=root hostname=kali persistence
needs to be changed to
linuxefi /live/vmlinuz boot=live noconfig=sudo username=root hostname=kali persistence persistence-encryption=luks

Now I'm not sure why the non-encryted encryption won't work since the only difference is the persistence-encryption=luks But encrypted persistence is working like a charm


Q: My 3D racing game has some problems like wheels turning y axis and car not going anywhere My car's tires spin but the car doesn't move an inch and the wheels turn into y axis instead of left and right. Here is my code, i added rigidbody and boxcollider onto my car aswell maybe that's a problem causing the car not to move? (i made sure to put the collider above the wheels to make sure that they spin.)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CarController : MonoBehaviour
{
    private float horizontalInput;
    private float verticalInput;
    private float steerAngle;
    private bool isBreaking;

    public WheelCollider FrontLeftCollider;
    public WheelCollider FrontRightCollider;
    public WheelCollider BackLeftCollider;
    public WheelCollider BackRightCollider;
    public Transform FrontLeftTransform;
    public Transform FrontRightTransform;
    public Transform BackLeftTransform;
    public Transform BackRightTransform;

    public float maxSteeringAngle = 30f;
    public float motorForce = 50f;
    public float brakeForce = 0f;

    private void FixedUpdate()
    {
        GetInput();
        HandleMotor();
        HandleSteering();
        UpdateWheels();
    }

    private void GetInput()
    {
        horizontalInput = Input.GetAxis("Horizontal");
        verticalInput = Input.GetAxis("Vertical");
        isBreaking = Input.GetKey(KeyCode.Space);
    }

    private void HandleSteering()
    {
        steerAngle = maxSteeringAngle * horizontalInput;
        FrontLeftCollider.steerAngle = steerAngle;
        FrontRightCollider.steerAngle = steerAngle;
    }

    private void HandleMotor()
    {
        FrontLeftCollider.motorTorque = verticalInput * motorForce;
        FrontRightCollider.motorTorque = verticalInput * motorForce;

        brakeForce = isBreaking ? 3000f : 0f;
        FrontLeftCollider.brakeTorque = brakeForce;
        FrontRightCollider.brakeTorque = brakeForce;
        BackLeftCollider.brakeTorque = brakeForce;
        BackRightCollider.brakeTorque = brakeForce;
    }

    private void UpdateWheels()
    {
        UpdateWheelPos(FrontLeftCollider, FrontLeftTransform);
        UpdateWheelPos(FrontRightCollider, FrontRightTransform);
        UpdateWheelPos(BackLeftCollider, BackLeftTransform);
        UpdateWheelPos(BackRightCollider, BackRightTransform);
    }

    private void UpdateWheelPos(WheelCollider wheelCollider, Transform trans)
    {
        Vector3 pos;
        Quaternion rot;
        wheelCollider.GetWorldPose(out pos, out rot);
        trans.rotation = rot;
        trans.position = pos;
    }

}

If needed i can send screenshots of things please don't be shy to ask.
I haven't tried anything too afraid to make it worse

A: A rigidbody will not move until some kind of force is applied to it, or you use it's MovePosition method. Here is a link ... https://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html


Q: Embedded database in Java EE application Good day. I'm confused about storing the embedded database in a Java EE application. I've just resolved the problem with the .properties file which can be accessed via getResource method, but where should I put my database to support portability?

A: For portability, the appropriate way is to install the embedded database in the project directory & then specifying the relative path.
In general, you have to extract the content & specifying that path relative to the current directory as database url. Below are some examples.

*

*H2 Database - jdbc:h2:file:relative-database-path

*Apache Derby - By including required jars in classpath & configuring environment variable accordingly.

*HSQLDB - jdbc:hsqldb:file:relative-database-path


Q: Incorrect string value: '\xCC_a' for column when inserting I am attempting to run a sql query but get the following error:
Incorrect string value: '\xCC_a' for column

CSV File line that breaks mysql query:
Juan Gordon,GarcÃ_a,noman@gmail.com,,,,,,,,,,y,

SQL Error:

Error Number: 1366

Incorrect string value: '\xCC_a' for column 'last_name' at row 1

INSERT INTO `phppos_people` (`first_name`, `last_name`, `email`, `phone_number`, `address_1`, `address_2`, `city`, `state`, `zip`, `country`, `comments`) VALUES ('Juan Gordon', 'Garc�_a', 'noman@test.com', '', '', '', '', '', '', '', '')

Filename: /Library/WebServer/Documents/phppos/PHP-Point-Of-Sale/models/person.php

Line Number: 75

last_name is varchar(255) utf8_unicode_ci
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_unicode_ci';

Example CSV code

?>

last_name = GarcÌ_a

UPDATE: I just learned that when saving the file as a .csv in excel the encoding is: Westren (Mac OS Roman) with CR as line breaks.
I think that file encoding might cause the problem. But I need to support it.

A: The only Excel that exports to Mac OS Roman apparently is MS Excel for OSX. Unfortunately I don't have this so I can't check how to export with the correct character set
You now have two choices
a) Convert the CSV to UTF-8 using iconv for example
iconv -f MACROMAN -t UTF8 < yourfile.csv > yourfile-utf8.csv

b) Set the connection charset to the character set of the file before you import
SET NAMES macroman;

In codeigniter this would look like this
$this->db->simple_query('SET NAMES \'macroman\'');

After your import is done, don't forget to set it back
$this->db->simple_query('SET NAMES \'utf8\'');

Explanation:
If your connection charset is UTF-8, your database excepts UTF-8 encoded data. If you set the connection charset to macroman and the columns you write to are UTF-8, MySQL will automatically convert this for you.

From http://dev.mysql.com/doc/refman/5.5/en/charset-connection.html
SET NAMES 'charset_name' [COLLATE 'collation_name']
SET NAMES indicates what character set the client will use to send SQL statements to the  server. Thus, SET NAMES 'cp1251' tells the server, “future incoming messages from this  client are in character set cp1251.” It also specifies the character set that the server  should use for sending results back to the client. (For example, it indicates what character set to use for column values if you use a SELECT statement.)

On my freeBSD machine, MySQL has the macroman character set compiled in, I suppose you'll also have this.
mysql> SELECT * FROM information_schema.COLLATIONS WHERE CHARACTER_SET_NAME = 'macroman';
+---------------------+--------------------+----+------------+-------------+---------+
| COLLATION_NAME      | CHARACTER_SET_NAME | ID | IS_DEFAULT | IS_COMPILED | SORTLEN |
+---------------------+--------------------+----+------------+-------------+---------+
| macroman_general_ci | macroman           | 39 | Yes        | Yes         |       1 |
| macroman_bin        | macroman           | 53 |            | Yes         |       1 |
+---------------------+--------------------+----+------------+-------------+---------+

Also see http://dev.mysql.com/doc/refman/5.5/en/charset-charsets.html
Hope this helps


Q: If WPF Richtextbox Highlight word contains hyphen,thin line shown in the word? I am working in WPF RichTextBox.I have highlighted each word,using the below code.its works fine.But the word contains hyphen means,the highlighted word has some thin lines between the hyphen.
string SelectHighlightWord(RichTextBox rtb, int offset, int length)
{
    TextRange fullRange = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);
    fullRange.ClearAllProperties();
    TextPointer startSelect = fullRange.Start.GetPositionAtOffset(offset);
    TextPointer endSelect = startSelect.GetPositionAtOffset(length);
    TextRange textRange = rtb.Selection;
    textRange.Select(startSelect, endSelect);
    textRange.ApplyPropertyValue(TextElement.BackgroundProperty, new SolidColorBrush(m_backgroundColor));
    textRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(m_foregroundColor));
    FrameworkContentElement fce = (startSelect.Parent as FrameworkContentElement);
    if (fce != null)
    {
        fce.BringIntoView();
    }

    return rtb.Selection.Text;
}

Note : I have added images for better understanding.

A: Is your window setting TextOptions.TextFormattingMode on Ideal? If so, try setting Display.


Q: CSS add seperator after
*-Tag I'm tring to edit the Wordpress homepage of my friend.
He uses a free Template and want to add an seperator "|" after each of his menu items.
I tried it with this one.
#menu-mainmenu li + li:before {
    content: " | ";
    padding: 0 15px;
}

Format looks like this

...

...

...

...

The Pipes appear over the
*-Tag.

This is what I want to do

A: I had to make a lot of guesses here because you didn't include much code or explanation for what you are trying to achieve but I think I have managed to create the overall appearance of what you want.
I have created two ways that this works, one which should work for anyone and another which will work for everyone but work specifically in your case
Number one:

#menu-mainmenu li {
  position: relative;
  display: inline-block;
  float: left;
}

#menu-mainmenu li:not(:first-child):after {
  content: " | ";
  position: relative;
  display: inline-block;
  float: left;
  margin: 0 15px;
}

HOME

ABOUT

...

...

Number two:

#menu-mainmenu li {
  position: relative;
  display: inline-block;
  float: left;
}

#menu-mainmenu li.line {
  margin: 0 15px;
}

HOME

|

ABOUT

|

...

|

...

A: I would use :after instead of :before

#menu-mainmenu li {
  display: inline-block;
}

#menu-mainmenu > li:after {
    content: " | ";
    padding: 0 15px;
}

#menu-mainmenu > li:last-child:after {
  content: "";
}

Link 1

Link 2

Link 3

Link 4

A: Using your CSS example , you'll need the follow:
#menu-mainmenu li{
   display:inline-block;
}

Run this snippet:

#menu-mainmenu li {
  display: inline-block;
}

#menu-mainmenu li + li:before {
    content: " | ";
    padding: 0 15px;
}

Item 1

Item 2

Item 3

Item 4

https://jsfiddle.net/6936pon8/1/

A: So, since you were unable to share the code, I had to simulate the error, and my guess was that the
 has a fixed width, so in the first example we have the possible error, please verify if that's your case. If it is, the second example will give you the asnwer.
Posible Error

#menu-mainmenu li {
  display: inline-block;
  width: 40px;
}

#menu-mainmenu li + li:before {
    content: " | ";
    padding: 0 15px;
}

hola

...

cómo

está

Fix

#menu-mainmenu li {
  display: inline-block;
  width: 50px;
  position: relative;
}

#menu-mainmenu li + li:before {
    content: " | ";
    position: absolute;
    left: -10px;
}

hola

.........

cómo

está

You can play around with absolute positioned elements as long as its parent is a relative element.
One more time, please submit as much code as you can so we can help you out, otherwise if nobody finds an answer it will be a waste of time.

A: #menu-mainmenu li:after {
    content: " | ";
    padding: 0 15px;
}

#menu-mainmenu li:last-child:after {
  content:"";
}

A:
Hey! check this out :)

* {
 margin: 0;
 padding: 0;
 box-sizing: border-box;
 -webkit-box-sizing : border-box;
        list-style-type : none;
}

#menu-mainmenu li {
       display: inline-block;
       padding: 5px 10px;
}

#menu-mainmenu li:after {
      content : " | ";
      display: inline-block;
      width : 10px;
      height : 30px;
      padding-left : 5px;
      margin-left : 10px;
      background-color: yellow;
      font-size : 25px;
}

first

second

third

forth


Q: importing converted data using pandas I have a csv file that looks like this:
patient_id  age_in_years    CENSUS_REGION   URBAN_RURAL_STATUS  YEAR    MONTH   DAY_NUMBER_IN_MONTH race
11511   7   Northeast   Urban   2011    6   20  Other
9882613 73  South   Urban   2011    7   25  Unknown
32190339    49  West    Urban   2011    8   13  Caucasian
...

I have converted the categorical data in this file (e.g., race, census region, urban/rural status, etc.) into binary vector objects using the following method:
def URSTATUS_to_numeric(a):
if a == 'Urban':
    return [1, 0, 0]
if a == 'Rural':
    return [0, 1, 0]
if a == 'NULL':
    return [0, 0, 1]

df['URSTATUS_num'] = df['URBAN_RURAL_STATUS'].apply(URSTATUS_to_numeric)

I want to use these vectors for linear regression analysis but I'm unable to call them using the following the code:
def import_data(file_name):
 df = pd.read_csv(file_name).drop_duplicates()
 X_parameter = []
 #Y_parameter = []
 for alpha in zip(df['age_in_years']):
       X_parameter.append([float(alpha)])
       #Y_parameter.append(float(beta))
 return X_parameter#, Y_parameter

X = import_data(filename)

Y = df['URSTATUS_num']

The error that I'm getting is this:
TypeError: float() argument must be a string or a number

A: If you're just iterating over that series to build a list of floats, you could instead use astype(float).
It seems like you have some values in that column, though, that cannot be converted to float. For the sake of troubleshooting, maybe just try
for alpha in zip(df['age_in_years']):
    try:
       X_parameter.append([float(alpha)])
    except:
       print alpha

You should be able to replace that whole function using
X = pd.read_csv(file_name).drop_duplicates()['age_in_years'].astype(float)


Q: Incorrect path to S3 flysystem adapter in Laravel 5 I'm having an issue with Laravel 5's filesystem when uploading files to an S3 bucket. The line that is running to the filesystem is:
Storage::disk('s3')->put($slug, $img);

It works as it should for:
Storage::disk('local')->put($slug, $img);

But when I change the disk to S3 it throws the following error:
Class 'League\Flysystem\AwsS3v3\AwsS3Adapter' not found

As per the L5 docs, I have the following requirement in my composer.json
"league/flysystem-aws-s3-v2": "~1.0"

which installed league's aws flysystem adapter under:
League\flysystem-aws-s3-v2\

I have tried updating the path in the fileSystemManager.php in the filesystem vendor folder to the aws flysystem installation path but it still doesn't work. I can't seem to find anyone else who has experienced this behaviour.
A fresh pair of eyes or a knowledgeable head who might know more about Laravel than I would be great. I really can't seem to the issue.
UPDATE
I did a fresh install of the aws flysystem and not I get the following:
ErrorException in Util.php line 250:
fstat() expects parameter 1 to be resource, object given

A: Ok so I fixed the initial issue by removing aws/aws-sdk-php : "^2.8.* that I had in my composer.json and ran a fresh 'composer require league/flysystem-aws-s3-v3 ~1.0'. This fixed the initial error in finding the S3 flysystem.
The second error fstat() expects parameter 1 to be resource, object given related to my attempt to pass an image object to the put method:
Storage::disk('s3')->put($slug, $img);

when it expects a string. This was fixed by stringifying the $img object
Storage::disk('s3')->put($slug, $img->__toString());

Hope this helps somebody else who might encounter this issue.


Q: CentOS 7 with KDE: Session bus not found While using git on my newly installed CentOS 7 with KDE, I get the following error:
ksshaskpass(15344)/kdeui (kdelibs): Session bus not found
To circumvent this problem try the following command (with Linux and bash)
export $(dbus-launch)
error: /usr/bin/ksshaskpass died of signal 6
error: unable to read askpass response from '/usr/bin/ksshaskpass'

However this does not interfere with the execution of the git commands. Any leads on why this might be happening?
UPDATE: I did go ahead and gave the export $(dbus-launch) command before running git clone again. Turns out this error was holding behind the launch of the KDE wallet with a somewhat buggy interface. Will try and report it to the right team.


Q: updating maradns with nsupdate I have configured Maradns as dns server on openwrt platform. Can i use nsupdate as ddns client to update the DNS Server. Is it possible of updating Maradns zones with nsupdate.

A: You could look at the maradns documentation. My reading of it is that no you cannot. However it does have something called fetchzone.


Q: Excel CountIF on date AND time I see lots of examples of how to work with times OR dates, but not a lot seems to be done with date AND time values.
I have the following data:

And would like the sum of some weights between specific date and times (shift patterns):
So

*

*I need all the weights between "17/07/2014 06:00" and "17/07/2014 14:00"

*I need all the weights between "17/07/2014 14:00" and "17/07/2014 22:00"

*I need all the weights between "17/07/2014 22:00" and "18/07/2014 06:00"

Yes, I can split the dates and times and deal with them separately, but there must be an easier way (it gets rather convoluted in the 3rd scenario)
By the way, the date to compare against will be calculated using "=DATE(YEAR(NOW()),MONTH(NOW()),DAY(NOW())-1)" for yesterdays date (stored in F11)
I have an entire page of different variations of attempts at this, which I wont post all of, but mainly:
 =SUMIFS(
   Last36Hours!$K$2:$K$10000,
   Last36Hours!$T$2:$T$10000,">=" &
      DATE(YEAR(F11),MONTH(F11),DAY(F11)) &
      TIME(6,0,0)
 )

should give me everything after yesterday 6am, but i get absolutely squat.

A: Very Close. Excel stores dates and times as days and fractions of days since 1/1/1900 or 1/1/1904. You need to ADD the time to the date, not concatenate.  And you can simplify getting the Date portion from F11. Try:
=SUMIFS(
   Last36Hours!$K$2:$K$10000,
   Last36Hours!$T$2:$T$10000,">=" &
     INT(F11)+ TIME(6,0,0))

You could also hard code yesterday at 6AM by replacing
DATE(YEAR(F11),MONTH(F11),DAY(F11)) & TIME(6,0,0)

with
TODAY()-0.75

which is the same as:
TODAY() - 1 + TIME(6,0,0)


Q: List to varargs with pre-difined size or without size What is the better way to convert List to varargs to call below 'builder( String... s )' method.
builder( stringList.toArray( new String[stringList.size()] ) );//with pre-difined array size

or
builder( stringList.toArray( new String[0] ) );//without predifined size

for example
void test() {

  List<String> stringList = new ArrayList<>();
  builder( stringList.toArray( new String[stringList.size()] ) );//call builder method with pre-difining array size
  builder( stringList.toArray( new String[0] ) );//call builder method with array size 0

}

void builder( String... s )
{

}

I faced this question in a review and I was suggested that builder( stringList.toArray( new String[0] ) ) is more efficient than
using builder( stringList.toArray( new String[stringList.size()] ) ).
Is there a significant difference between these two?
Thanks

A: To my understanding
stringList.toArray( new String[stringList.size()] ) )

is more efficient. The reason:
The argument is needed to have an actual type (String) for a generic List<String>, where the generic type parameter is erased at run-time.
The argument is used for the resulting array if its size matches the list size.
If the size is 0, the passed array is discarded.
So passing a correct array saves one object creation.
Of course list.size() is called extra. So it might be slower. I doubt it.

Correction
See Arrays of Wisdom of the Ancients.
A correct benchmark shows the inverse: new String[0] being faster.
I just overflew the very interesting analysis, and it seems:

*

*(an extra short lived new String[0] is irrelevant;)

*doing the array copying local in the toArray method allows a different, faster array copy;

*(and then there is the extra call to size.)

Mind, I did not sufficiently thorough read the article; it really is interesting.
Conclusion (counter-intuitively): new T[0] is faster.
Mind that:

*

*code checkers might still think differently and issue a warning;

*this is with warming up: till the hotspot JIT kicks in, it may be the other way around.

A: builder(stringList.toArray(new String[0])) is slightly less efficient since you create an empty array that will be discarded and never used after the method returns. toArray will have to create a new array in order to store the elements of the List.
On the other hand, builder(stringList.toArray(new String[stringList.size()])) passes an array of the required length to the toArray method, and therefore that method will use that array instead of creating a new array.

A: There is a difference and it's mainly outlined by the Alexey Shipilev. Long story short:

toArray(new T[0]) seems faster, safer, and contractually cleaner, and therefore should be the default choice now

A: I thought that c.toArray(new String[c.size()])) is more efficient, because we define here an array with required size.
BUT!!
IntelliJ IDEA has Collection.toArray() inspection, which is on by default. This is description:

There are two styles to convert a collection to an array: either using
  a pre-sized array (like c.toArray(new String[c.size()])) or using an
  empty array (like c.toArray(new String[0]).
In older Java versions
  using pre-sized array was recommended, as the reflection call which is
  necessary to create an array of proper size was quite slow. However
  since late updates of OpenJDK 6 this call was intrinsified, making the
  performance of the empty array version the same and sometimes even
  better, compared to the pre-sized version. Also passing pre-sized
  array is dangerous for a concurrent or synchronized collection as a
  data race is possible between the size and toArray call which may
  result in extra nulls at the end of the array, if the collection was
  concurrently shrunk during the operation.
This inspection allows to follow the uniform style: either using an
  empty array (which is recommended in modern Java) or using a pre-sized
  array (which might be faster in older Java versions or non-HotSpot
  based JVMs).

So it seems, that after JDK6, we should use c.toArray(new String[0]). My personal opinion, is that it doesn't matter what aporoach to use this time. Only if profiler says that this is a bottle neck, then we should worry about it.


Q: Console Application - How to access the properties in JSON? I need to access the json properties so that I will be able to filter the result based on registers devices (either AEVL2020 or AEVL2021) but, I can't figure out how to access it. It seems like the RootObject can't access anything. I'm doing this for about 2 days now, so I need help.
Here is my json:
{
"registers":{
        "AEVL2020":[
            {
                "user_id": "1",
                "employee_id": "12",
                "name": "Juan Dela Cruz",
                "privilege": "0"
            },
            {
                "user_id": "2",
                "employee_id": "32",
                "name": "Pedro Dela Cruz",
                "privilege": "0"
            }
        ],
        "AEVL2021":[
            {
                "user_id": "1",
                "employee_id": "29",
                "name": "Maria Del Mundo",
                "privilege": "0"
            },
            {
                "user_id": "2",
                "employee_id": "222",
                "name": "Jay Del Mundo",
                "privilege": "0"
            }
        ]
    }
}

my C#:
static void Main(string[] args)
{
    using (StreamReader r = new StreamReader("C:\\Users\\Admin\\source\\repos\\Practice1\\Practice1\\company1.json"))
    {
        string json = r.ReadToEnd();
        var root = JsonConvert.DeserializeObject<RootObject>(json);

        // This is where the error, I can't access either AEVL2020 or AEVL2021
        foreach (var p in root.AEVL2020 || root.AEVL2021)
        {
            Console.WriteLine(p.user_id + p.name + p.employee_id + p.privilege);
        }
    }
}

public class AEVL2020
{
    public string user_id { get; set; }
    public string employee_id { get; set; }
    public string name { get; set; }
    public string privilege { get; set; }
}

public class AEVL2021
{
    public string user_id { get; set; }
    public string employee_id { get; set; }
    public string name { get; set; }
    public string privilege { get; set; }
}

public class Registers
{
    public List<AEVL2020> AEVL2020 { get; set; }
    public List<AEVL2021> AEVL2021 { get; set; }
}

public class RootObject
{
    public Registers registers { get; set; }
}

A: You can define single AEVL class for both AEVL2020  and AEVL2020  as follow:
public class AEVL
{
    public string user_id { get; set; }
    public string employee_id { get; set; }
    public string name { get; set; }
    public string privilege { get; set; }
}

public class Registers
{
    public List<AEVL> AEVL2020 { get; set; }
    public List<AEVL> AEVL2021 { get; set; }
}

Then your code would be like this and you can get items based on given string:
var aevlProp = root.registers.GetType().GetProperty("AEVL2020");
var values = (aevlProp.GetValue(root.registers, null) as List<AEVL>);

foreach (var p in values)
{
    Console.WriteLine(p.user_id + p.name + p.employee_id + p.privilege);
}

Output for  GetProperty("AEVL2020");
1Juan Dela Cruz120
2Pedro Dela Cruz320

Output for  GetProperty("AEVL2021");
1Maria Del Mundo290
2Jay Del Mundo2220

A: Something like this i guess
Given
public class SomeObject
{
   public string user_id { get; set; }
   public string employee_id { get; set; }
   public string name { get; set; }
   public string privilege { get; set; }
}

public class RootObject
{
   public Dictionary<string, List<SomeObject>> registers { get; set; }
}

Usage
var input = "{\r\n\"registers\":{\r\n        \"AEVL2020\":[\r\n            {\r\n                \"user_id\": \"1\",\r\n                \"employee_id\": \"12\",\r\n                \"name\": \"Juan Dela Cruz\",\r\n                \"privilege\": \"0\"\r\n            },\r\n            {\r\n                \"user_id\": \"2\",\r\n                \"employee_id\": \"32\",\r\n                \"name\": \"Pedro Dela Cruz\",\r\n                \"privilege\": \"0\"\r\n            }\r\n        ],\r\n        \"AEVL2021\":[\r\n            {\r\n                \"user_id\": \"1\",\r\n                \"employee_id\": \"29\",\r\n                \"name\": \"Maria Del Mundo\",\r\n                \"privilege\": \"0\"\r\n            },\r\n            {\r\n                \"user_id\": \"2\",\r\n                \"employee_id\": \"222\",\r\n                \"name\": \"Jay Del Mundo\",\r\n                \"privilege\": \"0\"\r\n            }\r\n        ]\r\n    }\r\n}";

var r= JsonConvert.DeserializeObject<RootObject>(input);

// choose the name you want here
var values = r.registers["<Name>"];

foreach (var p in values )
  Console.WriteLine(p.user_id + p.name + p.employee_id + p.privilege);


Q: How to best create web-based Leads and Opportunities We want to put a link on our internal company web site to allow users to submit referrals to possible new Accounts and/or new opportunities for already existing accounts.
I'm probably just going to use an out of the box Web-to-Lead approach for the new Accounts. But I think I will need to use a separate link to produce Opportunity records for referral to already existing accounts. The other link would present the employee with a web form which would in turn create the Opportunity.
Is this the proper approach ? Should I somehow just be using the Web-to-Lead approach even for already existing accounts ? That doesn't seem proper, but I'm just wondering if that's what some people do - and then through back-end programming they turn that Lead into an Opportunity instead....?
Thank you for any feedback you can provide.

A: Yes, any time there's a potential for a sale, it is originally a Lead. Once the Lead is Qualified, it becomes an Opportunity (a potential sale). Leads merge in to existing Account and Contact records upon conversion (based on Account Name and Contact Name). This is the intended flow, and is probably the easiest way to manage your sales cycle.


Q: BizTalk | Issue with Logical Existence functoid | source node doesn’t exist, still need output in the target I have a requirement to populate the output field in the destination schema though the source field does not exist in the input XML. If it does not exist, I have different logic to populate the target field. I tried using the 'Logical Existence' functoid but it is not giving me the desired output.


Q: error when try to boot: http://tau.rghost.ru/49221058/image.png
I don't understand what should I write here

A: If you have tried to install Ubuntu and it is not starting and you are seeing this screen then you need to just reinstall it again. It is not seeing your hard drive or the boot sector. I wrote this answer for someone who had boot troubles. it may be a help to you to read it: Error partitioning hard drive during installation of Ubuntu12.04.3 LTS


Q: Interthread communication between producer and consumer threads? I am trying to learn inter thread communication where I am using BlockingQueue.
I have written a producer which generate TaskId and insert it into BlockingQueue.
Now I have 2 consumers threads (name "1" and "0"). If taskId is odd, it is consumed by Thread "1" else "2".
@Override
    public void run() {
        while (true) {

                while (queue.peek() != null && !name.equals(String.valueOf(queue.peek().intValue() % 2 ))) {

                try {
                    System.out.println(name + ",consumed," + queue.take());
                } catch (InterruptedException e) {
                    e.printStackTrace();

                }
            }
        }
    }

How can i make that check also here?

A: One way I am thinking, there could be other better ways also:
@Override
    public void run() {
        String name = Thread.currentThread().getName();
        while (true) {

            while (queue.peek() == null) {
                //some sleep time
            }

            synchronized (lock) {
                while (queue.peek() != null && !name.equals(String.valueOf(queue.peek().intValue() % 2 ))) {
                    try {
                        lock.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                if(queue.peek() != null) {
                    try {
                        System.out.println(name + ",consumed," + queue.take());
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                lock.notify();
            }
        }
    }

Another Way: To have anotherLock that will be notified by producer thread whenever element is added to queue.
@Override
    public void run() {
        String name = Thread.currentThread().getName();
        while (true) {

            synchronized (anotherLock) {
                while (queue.peek() == null) {
                    anotherLock.wait();
                }
            }

            synchronized (lock) {
                while (queue.peek() != null && !name.equals(String.valueOf(queue.peek().intValue() % 2 ))) {
                    try {
                        lock.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                if(queue.peek() != null) {
                    try {
                        System.out.println(name + ",consumed," + queue.take());
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                lock.notify();
            }
        }
    }


Q: Charm Down PicturesService not working I'm still having problems getting the Charm Down PicturesService to work.
(I already posted a question regarding the issue).
Now I created a very simple test application and updated the build.gradle file with the latest library versions.
However, the PicturesService is still working very unreliable.  Selecting a picture sometimes works, sometimes it doesn't. Taking a picture seems to be working even more unreliable.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {   classpath 'org.javafxports:jfxmobile-plugin:1.3.5'}
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.gluonapplication.GluonApplication'

dependencies {
    compile 'com.gluonhq:charm:4.3.4'
    compile 'org.javafxports:jfxdvk:8.60.9'
    compileNoRetrolambda 'com.airhacks:afterburner.mfx:1.6.2'
}

jfxmobile {
    downConfig {
        version = '3.3.0'
        plugins 'display', 'lifecycle', 'statusbar', 'storage', 'pictures'
    }
    android {
        manifest = 'src/android/AndroidManifest.xml'
        compileSdkVersion = '23'

        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'license/LICENSE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/NOTICE.txt'
        }
    }
}

The necessary permissions are added to the AndroidManifest:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

MobileApplication:
public class GluonApplication extends MobileApplication {

    @Override
    public void init() {

        addViewFactory(HOME_VIEW, () ->
            {

                PicturesService pictureService = Services.get(PicturesService.class)
                                                         .orElseThrow(() -> new IllegalStateException("Failed to get PictureService"));

                Button btnLoadImage = new Button("load image");
                btnLoadImage.setOnAction(e -> pictureService.loadImageFromGallery().ifPresent(i -> imv.setImage(i)));

                CheckBox chkSavePicture = new CheckBox("save picture");

                Button btnTakePhoto = new Button("take photo");
                btnTakePhoto.setOnAction(e -> pictureService.takePhoto(chkSavePicture.isSelected()).ifPresent(i -> imv.setImage(i)));

                ImageView imv= new ImageView();
                imv.setFitHeight(300);
                imv.setFitWidth(300);

                VBox content = new VBox(16, btnLoadImage, btnTakePhoto, chkSavePicture, imv);
                content.setAlignment(Pos.CENTER);

                return new View(content);
            });
    }
}

Tested on a Huawei P9 lite, Android 6.0
Logcat take photo succeeded:
05-13 16:08:49.200: V/FXActivity(18796): onActivityResult with requestCode 2 and resultCode = -1 and intent = null
05-13 16:08:50.180: V/FXActivity(18796): onRestart
05-13 16:08:50.187: V/FXActivity(18796): onStart
05-13 16:08:50.187: V/FXActivity(18796): onResume
05-13 16:08:50.196: V/FXEntity(18796): Surface created.
05-13 16:08:50.198: V/FXActivity native(18796): [JVDBG] SURFACE created native android window at 0xe7c9b208, surface = 0xffac4e60
05-13 16:08:50.202: D/mali_winsys(18796): new_window_surface returns 0x3000
05-13 16:08:50.202: I/GLASS(18796): Native code is notified that surface has changed (repaintall)!
05-13 16:08:50.203: V/FXEntity(18796): Called Surface changed [1080, 1740], format 4
05-13 16:08:50.203: V/FXActivity native(18796): [JVDBG] SURFACE created native android window at 0xe7c9b208, surface = 0xffac4e40
05-13 16:08:50.204: I/GLASS(18796): Native code is notified that surface has changed with size provided (repaintall)!
05-13 16:08:50.204: V/FXEntity(18796): Called Surface redraw needed
05-13 16:08:50.205: V/FXEntity(18796): Redraw...
05-13 16:08:50.205: I/GLASS(18796): Call surfaceRedrawNeeded
05-13 16:08:50.205: I/GLASS(18796): Native code is notified that surface needs to be redrawn (repaintall)!
05-13 16:08:50.205: V/FXEntity(18796): Wait a while before doing this again...
05-13 16:08:50.230: I/System.out(18796): PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_20
05-13 16:08:50.310: I/System.out(18796): PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_28
05-13 16:08:50.408: V/FXEntity(18796): Redraw again...
05-13 16:08:50.408: I/GLASS(18796): Call surfaceRedrawNeeded
05-13 16:08:50.408: I/GLASS(18796): Native code is notified that surface needs to be redrawn (repaintall)!
05-13 16:08:50.416: I/OpenGLRenderer(18796): Initialized EGL, version 1.4
05-13 16:08:50.419: D/mali_winsys(18796): new_window_surface returns 0x3000

Logcat take photo failed:
    05-13 22:18:38.264: I/art(9381): Late-enabling -Xcheck:jni
    05-13 22:18:38.299: D/ActivityThread(9381): ActivityThread,attachApplication
    05-13 16:07:13.229: D/HwCust(18033): Create obj success use class android.content.res.HwCustHwResourcesImpl
    05-13 16:07:13.393: I/MultiDex(18033): VM with version 2.1.0 has multidex support
    05-13 16:07:13.393: I/MultiDex(18033): install
    05-13 16:07:13.393: I/MultiDex(18033): VM has multidex support, MultiDex support library is disabled.
    05-13 16:07:13.429: V/FXActivity(18033): Initializing JavaFX Platform, using 8.60.9-SNAPSHOT
    05-13 16:07:13.438: V/FXActivity native(18033): Loading JavaFXDalvik library
    05-13 16:07:13.452: V/HwPolicyFactory(18033): : success to get AllImpl object and return....
    05-13 16:07:13.474: I/HwCust(18033): Constructor found for class android.app.HwCustHwWallpaperManagerImpl
    05-13 16:07:13.474: D/HwCust(18033): Create obj success use class android.app.HwCustHwWallpaperManagerImpl
    05-13 16:07:13.475: V/ActivityThread(18033): ActivityThread,callActivityOnCreate
    05-13 16:07:13.482: I/System.out(18033): usetextureview = false, useswipekeyboard = false
    05-13 16:07:13.484: I/HwSecImmHelper(18033): mSecurityInputMethodService is null
    05-13 16:07:13.485: V/FXActivity(18033): onCreate called, using 8.60.9-SNAPSHOT
    05-13 16:07:13.486: V/FXActivity native(18033): Notification queue instance created.
    05-13 16:07:13.486: V/FXActivity native(18033): Notification queue started
    05-13 16:07:13.498: V/HwWidgetFactory(18033): : successes to get AllImpl object and return....
    05-13 16:07:13.542: V/FXActivity native(18033): appDataDir: /data/user/0/com.gluonapplication
    05-13 16:07:13.543: V/FXActivity(18033): onStart
    05-13 16:07:13.544: D/ActivityThread(18033): add activity client record, r= ActivityRecord{a0b6377 token=android.os.BinderProxy@a432176 {com.gluonapplication/javafxports.android.FXActivity}} token= android.os.BinderProxy@a432176
    05-13 16:07:13.544: V/FXActivity(18033): onActivityResult with requestCode 2 and resultCode = -1 and intent = null
    05-13 16:07:13.544: V/FXActivity(18033): onResume
    05-13 16:07:13.566: D/OpenGLRenderer(18033): Use EGL_SWAP_BEHAVIOR_PRESERVED: false
    05-13 16:07:13.638: I/OpenGLRenderer(18033): Initialized EGL, version 1.4
    05-13 16:07:13.655: D/mali_winsys(18033): new_window_surface returns 0x3000
    05-13 16:07:13.665: V/FXEntity(18033): Surface created.
    05-13 16:07:13.666: V/FXActivity native(18033): [JVDBG] SURFACE created native android window at 0xe7c99d08, surface = 0xffac4f30
    05-13 16:07:13.816: I/System.out(18033): user.locale=de-DE
    05-13 16:07:13.816: I/System.out(18033): javax.xml.stream.XMLEventFactory=com.sun.xml.stream.events.ZephyrEvent...
    05-13 16:07:13.816: I/System.out(18033): prism.text=native
    05-13 16:07:13.816: I/System.out(18033): java.vendor.url=http://www.android.com/
    05-13 16:07:13.816: I/System.out(18033): java.ext.dirs=
    05-13 16:07:13.816: I/System.out(18033): line.separator=
    05-13 16:07:13.816: I/System.out(18033): file.encoding=UTF-8
    05-13 16:07:13.816: I/System.out(18033): java.runtime.version=0.9
    05-13 16:07:13.816: I/System.out(18033): prism.dirtyopts=true
    05-13 16:07:13.816: I/System.out(18033): user.name=root
    05-13 16:07:13.816: I/System.out(18033): java.compiler=
    05-13 16:07:13.816: I/System.out(18033): android.icu.unicode.version=7.0
    05-13 16:07:13.816: I/System.out(18033): javax.xml.stream.XMLOutputFactory=com.sun.xml.stream.ZephyrWriterFactory
    05-13 16:07:13.816: I/System.out(18033): prism.debugfonts=true
    05-13 16:07:13.816: I/System.out(18033): com.sun.javafx.gestures.rotate=true
    05-13 16:07:13.816: I/System.out(18033): java.version=0
    05-13 16:07:13.816: I/System.out(18033): android.icu.library.version=55.1
    05-13 16:07:13.816: I/System.out(18033): use.egl=true
    05-13 16:07:13.816: I/System.out(18033): embedded=monocle
    05-13 16:07:13.816: I/System.out(18033): com.sun.javafx.gestures.scroll=true
    05-13 16:07:13.816: I/System.out(18033): prism.lcdtext=false
    05-13 16:07:13.816: I/System.out(18033): os.arch=armv7l
    05-13 16:07:13.816: I/System.out(18033): java.io.tmpdir=/data/user/0/com.gluonapplication/cache
    05-13 16:07:13.816: I/System.out(18033): glass.platform=Monocle
    05-13 16:07:13.816: I/System.out(18033): android.zlib.version=1.2.8
    05-13 16:07:13.816: I/System.out(18033): user.language=de
    05-13 16:07:13.816: I/System.out(18033): java.vm.version=2.1.0
    05-13 16:07:13.816: I/System.out(18033): com.sun.javafx.isEmbedded=true
    05-13 16:07:13.816: I/System.out(18033): javax.xml.stream.XMLInputFactory=com.sun.xml.stream.ZephyrParserFactory
    05-13 16:07:13.816: I/System.out(18033): prism.glDepthSize=16
    05-13 16:07:13.816: I/System.out(18033): path.separator=:
    05-13 16:07:13.816: I/System.out(18033): java.runtime.name=Android Runtime
    05-13 16:07:13.816: I/System.out(18033): java.specification.version=0.9
    05-13 16:07:13.816: I/System.out(18033): user.dir=/
    05-13 16:07:13.816: I/System.out(18033): prism.maxTextureSize=2048
    05-13 16:07:13.816: I/System.out(18033): java.vm.specification.vendor=The Android Project
    05-13 16:07:13.816: I/System.out(18033): com.sun.javafx.gestures.zoom=true
    05-13 16:07:13.816: I/System.out(18033): java.vm.name=Dalvik
    05-13 16:07:13.816: I/System.out(18033): monocle.platform=Android
    05-13 16:07:13.816: I/System.out(18033): log.lens=FINEST
    05-13 16:07:13.816: I/System.out(18033): java.vm.specification.version=0.9
    05-13 16:07:13.816: I/System.out(18033): user.home=
    05-13 16:07:13.816: I/System.out(18033): java.specification.name=Dalvik Core Library
    05-13 16:07:13.816: I/System.out(18033): file.separator=/
    05-13 16:07:13.816: I/System.out(18033): java.library.path=/vendor/lib:/system/lib
    05-13 16:07:13.816: I/System.out(18033): user.variant=
    05-13 16:07:13.816: I/System.out(18033): os.version=3.10.90-g033208c
    05-13 16:07:13.816: I/System.out(18033): java.boot.class.path=/system/framework/core-libart.jar:/sy...
    05-13 16:07:13.816: I/System.out(18033): DALVIK.prism.verbose=true
    05-13 16:07:13.816: I/System.out(18033): java.vm.specification.name=Dalvik Virtual Machine Specification
    05-13 16:07:13.816: I/System.out(18033): javafx.platform=android
    05-13 16:07:13.816: I/System.out(18033): glass.lens=eglfb
    05-13 16:07:13.816: I/System.out(18033): os.name=Linux
    05-13 16:07:13.816: I/System.out(18033): user.region=DE
    05-13 16:07:13.816: I/System.out(18033): java.class.path=.
    05-13 16:07:13.816: I/System.out(18033): android.icu.impl.ICUBinary.dataPath=/data/misc/zoneinfo/current/icu:/syst...
    05-13 16:07:13.816: I/System.out(18033): prism.verbose=true
    05-13 16:07:13.816: I/System.out(18033): prism.vsync=false
    05-13 16:07:13.816: I/System.out(18033): java.specification.vendor=The Android Project
    05-13 16:07:13.816: I/System.out(18033): java.vm.vendor=The Android Project
    05-13 16:07:13.816: I/System.out(18033): prism.allowhidpi=true
    05-13 16:07:13.816: I/System.out(18033): java.vendor=The Android Project
    05-13 16:07:13.816: I/System.out(18033): http.agent=Dalvik/2.1.0 (Linux; U; Android 6.0; ...
    05-13 16:07:13.816: I/System.out(18033): android.icu.cldr.version=27.0.1
    05-13 16:07:13.816: I/System.out(18033): android.openssl.version=BoringSSL
    05-13 16:07:13.817: I/System.out(18033): java.home=/system
    05-13 16:07:13.817: I/System.out(18033): java.vm.vendor.url=http://www.android.com/
    05-13 16:07:13.817: I/System.out(18033): java.class.version=50.0
    05-13 16:07:13.817: V/DalvikLauncher(18033): Launch JavaFX application on DALVIK vm.
    05-13 16:07:13.848: V/DalvikLauncher(18033): We have JavaFX on our current (base) classpath, registered exit listener
    05-13 16:07:13.854: V/DalvikLauncher(18033): application class: [class com.gluonapplication.GluonApplication]
    05-13 16:07:13.854: V/DalvikLauncher(18033): preloader class: [null]
    05-13 16:07:13.854: V/DalvikLauncher(18033): javafx application class: [class javafx.application.Application]
    05-13 16:07:13.854: V/DalvikLauncher(18033): javafx launcher class: [class com.sun.javafx.application.LauncherImpl]
    05-13 16:07:13.854: V/DalvikLauncher(18033): launch application method: [public static void com.sun.javafx.application.LauncherImpl.launchApplication(java.lang.Class,java.lang.Class,java.lang.String[])]
    05-13 16:07:13.871: V/FXEntity(18033): Called Surface changed [1080, 1740], format 4
    05-13 16:07:13.871: V/FXActivity native(18033): [JVDBG] SURFACE created native android window at 0xe7c99d08, surface = 0xffac4f10
    05-13 16:07:13.871: V/FXEntity(18033): Called Surface redraw needed
    05-13 16:07:13.878: V/FXEntity(18033): Called Surface redraw needed
    05-13 16:07:13.993: I/System.out(18033): Prism pipeline init order: es2
    05-13 16:07:13.993: I/System.out(18033): Using native-based Pisces rasterizer
    05-13 16:07:13.993: I/System.out(18033): Using dirty region optimizations
    05-13 16:07:13.993: I/System.out(18033): Using system sized mask for primitives
    05-13 16:07:13.993: I/System.out(18033): Not forcing power of 2 sizes for textures
    05-13 16:07:13.993: I/System.out(18033): Using hardware CLAMP_TO_ZERO mode
    05-13 16:07:13.993: I/System.out(18033): Opting in for HiDPI pixel scaling
    05-13 16:07:14.000: I/System.out(18033): Prism pipeline name = com.sun.prism.es2.ES2Pipeline
    05-13 16:07:14.010: I/System.out(18033): Loading ES2 native library ... prism_es2_monocle
    05-13 16:07:14.023: I/System.out(18033):    succeeded.
    05-13 16:07:14.023: I/System.out(18033): GLFactory using com.sun.prism.es2.MonocleGLFactory
    05-13 16:07:14.054: I/GLASS(18033): I have to Call dlopen libGLESv2.so
    05-13 16:07:14.055: I/GLASS(18033): handle = 0xf76fcd04
    05-13 16:07:14.055: I/GLASS(18033): I have to Call dlopen libEGL.so
    05-13 16:07:14.056: I/GLASS(18033): handle = 0xf76fc9c4
    05-13 16:07:14.057: I/GLASS(18033): Binding to libactivity.so
    05-13 16:07:14.058: I/GLASS(18033): GetNativeWindow = 0xf3762da1, getDensitiy = 0xf3762dad
    05-13 16:07:14.058: V/FXEntity(18033): notify_glassHasStarted called in FXActivity. register device now.
    05-13 16:07:14.079: D/mali_winsys(18033): new_window_surface returns 0x3000
    05-13 16:07:14.089: I/System.out(18033): (X) Got class = class com.sun.prism.es2.ES2Pipeline
    05-13 16:07:14.104: I/System.out(18033): Initialized prism pipeline: com.sun.prism.es2.ES2Pipeline
    05-13 16:07:14.127: I/DENSITY(18033): GETDENSITY, answer = 3.000000
    05-13 16:07:14.185: I/System.out(18033): Maximum supported texture size: 8192
    05-13 16:07:14.186: I/System.out(18033): Maximum texture size clamped to 2048
    05-13 16:07:14.186: I/System.out(18033): Non power of two texture support = true
    05-13 16:07:14.186: I/System.out(18033): Maximum number of vertex attributes = 16
    05-13 16:07:14.186: I/System.out(18033): Maximum number of uniform vertex components = 4096
    05-13 16:07:14.186: I/System.out(18033): Maximum number of uniform fragment components = 4096
    05-13 16:07:14.186: I/System.out(18033): Maximum number of varying components = 60
    05-13 16:07:14.186: I/System.out(18033): Maximum number of texture units usable in a vertex shader = 16
    05-13 16:07:14.186: I/System.out(18033): Maximum number of texture units usable in a fragment shader = 16
    05-13 16:07:14.190: I/System.out(18033): Graphics Vendor: ARM
    05-13 16:07:14.191: I/System.out(18033):        Renderer: Mali-T830
    05-13 16:07:14.192: I/System.out(18033):         Version: OpenGL ES 3.1 v1.r8p0-01dev0.bbfc5a14ef62ccdf784a9fff6af72acd
    05-13 16:07:14.216: I/System.out(18033): register device done
    05-13 16:07:14.227: W/System.err(18033):  vsync: false vpipe: true
    05-13 16:07:14.227: I/System.out(18033): [MON] Create device
    05-13 16:07:14.230: I/System.out(18033): [MON] Create device done, add done
    05-13 16:07:14.414: W/System.err(18033): Loading FontFactory com.sun.javafx.font.freetype.FTFactory
    05-13 16:07:14.414: W/System.err(18033): Subpixel: enabled
    05-13 16:07:14.434: W/System.err(18033): Freetype2 Loaded (version 2.5.0)
    05-13 16:07:14.434: W/System.err(18033): LCD support Enabled
    05-13 16:07:14.444: W/art(18033): Before Android 4.1, method void com.sun.javafx.scene.transform.TransformUtils$ImmutableTransform.ensureCanTransform2DPoint() would have incorrectly overridden the package-private method in javafx.scene.transform.Transform
    05-13 16:07:14.630: W/System.err(18033): Temp file created: /data/user/0/com.gluonapplication/cache/+JXF415078203.tmp
    05-13 16:07:14.643: W/System.err(18033): Temp file created: /data/user/0/com.gluonapplication/cache/+JXF1552782793.tmp
    05-13 16:07:14.650: W/System.err(18033): Temp file created: /data/user/0/com.gluonapplication/cache/+JXF-728135178.tmp
    05-13 16:07:14.657: W/System.err(18033): Temp file created: /data/user/0/com.gluonapplication/cache/+JXF-646868817.tmp
    05-13 16:07:14.828: W/art(18033): Before Android 4.1, method double javafx.scene.text.TextFlow.computeChildPrefAreaHeight(javafx.scene.Node, javafx.geometry.Insets) would have incorrectly overridden the package-private method in javafx.scene.layout.Region
    05-13 16:07:14.828: W/art(18033): Before Android 4.1, method double javafx.scene.text.TextFlow.computeChildPrefAreaWidth(javafx.scene.Node, javafx.geometry.Insets) would have incorrectly overridden the package-private method in javafx.scene.layout.Region
    05-13 16:07:15.067: I/System.out(18033): max rectangle texture cell size = 62
    05-13 16:07:15.084: I/System.out(18033): wrap rectangle texture = 2 x 2
    05-13 16:07:15.087: I/System.out(18033): ES2ResourceFactory: Prism - createStockShader: AlphaTexture_Color.frag
    05-13 16:07:15.106: I/System.out(18033): ES2ResourceFactory: Prism - createStockShader: Texture_Color.frag
    05-13 16:07:15.122: I/System.out(18033): PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_20
    05-13 16:07:15.133: I/System.out(18033): ES2ResourceFactory: Prism - createStockShader: Solid_TextureRGB.frag
    05-13 16:07:15.150: I/System.out(18033): ES2ResourceFactory: Prism - createStockShader: FillRoundRect_Color.frag
    05-13 16:07:15.154: I/System.out(18033): Loading Prism common native library ...
    05-13 16:07:15.163: I/System.out(18033):    succeeded.
    05-13 16:07:15.177: I/System.out(18033): PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_28


Q: "Error calling Driver#connect" using Hibernate This is my cfg.xml file:

    <!-- Database connection settings -->
    <property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
    <property name="connection.url">jdbc:sqlserver://localhost:1433;DatabaseName=hiber;</property>
    <property name="connection.username">Costi-PC\Costi</property>
    <property name="connection.password"></property>

    <!-- JDBC connection pool (use the built-in) -->
    <property name="connection.pool_size">1</property>

    <!-- SQL dialect -->
    <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

    <!-- Disable the second-level cache -->
    <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>

    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">true</property>

    <!-- Drop and re-create the database schema on startup -->
    <property name="hbm2ddl.auto">create</property>

    <!-- Names the annotated entity class -->
    <mapping class="model.User" />

User class and Main class:
@Entity
    public class User {

        @Id
        private int userId;
        private String userName;

        public int getUserId() {..}
        public void setUserId(int userId) {..}
        public String getUserName() {..}
        public void setUserName(String userName) {..}

    }

    public class Main {

        public static void main(String[] args) {
           User user = new User();
           user.setUserId(1);
           user.setUserName("Costi");

           AnnotationConfiguration configuration = new AnnotationConfiguration();
           configuration.configure();

           SessionFactory sessionFactory = configuration.buildSessionFactory();

           Session session = sessionFactory.openSession();
           session.beginTransaction();
           session.save(user);
           session.getTransaction().commit();
           session.close();

           sessionFactory.close();

}

When I run the program i get this error:
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
    at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:132)
    at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator$1$1.convert(BasicConnectionCreator.java:118)
    at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:140)
    at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:58)
    at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:75)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:106)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
    at main.Main.main(Main.java:23)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
    at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:241)
    at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2243)
    at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:491)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1309)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
    at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:55)
    ... 14 more

I'm using sql server 2008.
I tried different types of cfg configuration  but none seems to work.
I believe the problem is from connection.url. I tried to change the port (1433) but nothing.
Can anyone tell what's the problem ?

A: I have Faced Same issue just i have changed the Version on mysql  server connector than works fine
    <!-- commented as it was not make to connect
       <dependency>
          <groupId>mysql</groupId>
          <artifactId>mysql-connector-java</artifactId>
          <version>5.1.34</version>
       </dependency>
   -->

added latest version of mysql connector
   <!-- added latest version of mysql connector -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.18</version>
            </dependency>

A: I know this post is almost 2 years old, but for me the questions gave me, for me, the right answer. And because people with the same question are getting this post from Google. I thought, lets add my story.
Same thing, same problem. And for me the answer was that SQL Server didn't accept connections from the outside. The tcp/ip network client configuration is standard disabled.
So it was for me a hint in the right direction.

A: I changed the version of MySql like,
From 5.1.8
<dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.8</version>
    </dependency>

To 8.0.19
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.19</version>
    </dependency>

It works for me.
Thank you.

A: Use This with all Permission of DB
 <property name="hibernate.connection.url">jdbc:mysql://ip:3306/dbname</property><property name="hibernate.connection.username">*******</property>
     <property name="hibernate.connection.password">*******</property>

A: Try going to the command line and see if sqlserver is indeed listening to that port. On windows this would be the command:
netstat -nao | findstr 1433

Then see if the PID is Sql Server as expected in the windows (Ctr+Alt+Delete) process list.
If the server is running, try to connect to it using a SQL client GUI, see here for examples.  When you can connect to the database from an external client successfully, try again from the Java program.
Try to see also if your local firewall settings to see if the firewall is the cause for the error, although by default firewalls do not block  localhost - have a look at this answer.

A: Check you Sid in

hibernate.cfg.xml file

For Oracle Express Edition:
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>

For Oracle Enterprise Edition:
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>

A: the error is due to AnnotationConfiguration and making session by it.
you can try this solution:
@Autowired
SessionFactory sessionFactory;
Session session = sessionFactory.getCurrentSession();
session.saveOrUpdate(ce);

A: I also face same problem due to some dependency issue. i solve my problem to change sql depenedency which is compatible to my current version of sql server in pom.xml file.

A: I had a same error when migrating from jTDS1.2.8 to mssql-jdbc and for me it helped removing the port number and specifying the named instance in the connection URL within hibernate.cfg.xml
From:
<property name="hibernate.connection.url">jdbc:sqlserver://MYHOSTNAME:1433;databaseName=mydbname;instanceName=MYINSTANCENAME;</property>

To:
  <property name="hibernate.connection.url">jdbc:sqlserver://MYHOSTNAME;instanceName=MYINSTANCENAME;databaseName=mydbname;</property>

Reference: https://learn.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-2017
When using Named and Multiple SQL Server Instances, to use a JDBC URL property, do the following:
jdbc:sqlserver://localhost;instanceName=instance1;integratedSecurity=true;<more properties as required>;

A: if you are using a virtual server or server that is not updated the time zone should update it.
SQL CONSOLE:
SET GLOBAL time_zone = '+3:00';

A: Wrong username or a password in a config hibernate file "hibernate.cfg.xml"

A: Please make sure that the database with which you are trying to connect has already been created in the database with the same name.

A: If you're using Hibernate 4, try switching to Hibernate 5.
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.4.10.Final</version>
</dependency>

This helped me resolve the error.


Q: Preloading entities with EF4 I have a bunch of classificators which will be used quite often. I wan't to preload those entities when my program starts so that I wouldn't have to do it later when any object references them.
How can this be done in EF4?

A: There's a long-ish walkthrough here:
How to Cache Entity Framework Reference Data
But profile first. Writing good projections may be faster than materializing entire entities with cached references. Even loading single referenced objects is quite fast. Don't "optimize" stuff which isn't slow.


Q: Redirecting requests over 8443 to 443 One of our applications was previously configured to serve SSL from tomcat over port 8443. We're migrating this application to a new environment and switching to using nginx to handle SSL termination rather than tomcat (which will operate over 8080). I would like the ability for folks to be able to connect to the new environment over 8443 but get redirected to 443 (to support anyone's old bookmarks or links).
Currently have rulesets to redirect 80 to 443, and a full ssl_certificate set defined for listening on 443, but no luck trying a variety of methods to listen on 8443 and redirect to itself over 443.
Any suggestions?

A: Just define a separate server for port 8443, and do a redirect from there.  You'd obviously still have to have a proper certificate for your 8443 server, too.
server {
  listen 8443 ssl;
  server_name example.com;
  ssl_...;
  return 301 https://example.com$request_uri;
}


Q: Python hashlib: TypeError: object supporting the buffer API required I am writing a client/server program for class which allows the client to send messages to the server using a variety of different encryption techniques.  Right now, I'm in the middle of implementing symmetric encryption, and the server is throwing me an error when I attempt to hash the public key that it receives from the client during the initial key distribution.  I am not very familiar with these libraries so I'm not quite sure what the cause of this error is.
My server code:
from Crypto.Random import *
from Crypto.PublicKey import RSA
import hashlib

import socket

s = socket.socket()
host = socket.gethostname()
port = 12345
s.bind((host, port))

c = None
addr = None

s.listen(5)
while True:
   c, addr = s.accept()
   print ('Got connection from', addr)
   break
c.send('You have connected to the server.\nPlease select one of the following communication options by entering the corresponding number.\n1. Public Key Encryption\n2. Symmetric Key Encryption\n3. Digital Signature\n4. Hash'.encode('ascii'))
#receive user option, this will get used in code I add in later
option = c.recv(1024).decode()
#receive and process the public key
pKey = RSA.importKey(c.recv(2048).decode())
#receive the original digest
digest = c.recv(2048).decode()
#hash the received key
hash_object = hashlib.sha1(pKey)
newDigest = hash_object.hexdigest()

if newDigest == digest:
    print("Success")
else:
    print("Failure")

My client code:
from Crypto import Random
from Crypto.PublicKey import RSA
import hashlib
import socket

s = socket.socket()
host = socket.gethostname()
port = 12345
inLoop = True

s.connect((host, port))
print(s.recv(1024).decode())
while(True):
    option = input("Select an option: ")
    print(option)
    s.send(option.encode())
    if (option == '1'):
        #Begin handshake
        random = Random.new().read
        key = RSA.generate(1024,random)
        pKey = key.publickey().exportKey()
        hash_object = hashlib.sha1(pKey)
        hex_digest = hash_object.hexdigest()
        #send public key
        s.send(pKey)
        #send digest
        s.send(hex_digest.encode())

    elif(option == 2):
        while(inLoop == True):
            ""
    elif(option == 3):
        while(inLoop == True):
            ""
    elif(option == 4):
        while(inLoop == True):
            ""
    else:
        print("Please enter a valid option.")

s.close()

Right now a great deal of this is unfinished, but the specific problem I am having is that the client creates a public RSA key, and hashes it, and sends the public key and the hex_digest to the server.  The server receives the public key and decodes it into a string, and then turns it into an RSA key, but hashlib gives me an error once I attempt to hash the key.  When the server reaches the line hash_object = hashlib.sha1(pKey), I receive an error: TypeError: object supporting the buffer API required
I am not sure what this means; I've done a lot of research.  I do not know how to fix this, but for some reason the server will not hash the key.

A: I'm an idiot.  I was doing hash_object = hashlib.sha1(pKey), but pKey is an RSA key, not a string, so I needed to do hash_object = hashlib.sha1(pKey.exportKey()) instead.


Q: Asp.Net Core Web APi and Azure AD auth I have to create a web app with these kinds of requirements:

*

*SPA (Angular 9)

*SPA call to Web API (Asp.net core 3.1)

*I have to use the Azure AD for
the authentication (I created the tenant)

*I have to use Microsoft Graph API

I read different guides and studied the examples at the link
azure ad auth samples
but they do not cover my requirements.
I read this guide a web api that calls a web api that use a desktop application but after changing the code i receive the 401 unouthorized error.
Can anyone help me?
P.S. : Due unsuitable examples, i currently no have exutable code
Thanks a lot

A: You can check the MSAL For Angular document for how to authenticate user and acquire access token  . And this code sample is for Angular 9 .
If you want to directly call Microsfot Graph in Angular application , you can directly acquire Microsoft Graph's scopes as the document show , MSAL will help acquiring access token for Microsoft Graph . If you want to call Microsoft Graph from web api application , propagate the delegated user identity and permissions , you can use OAuth 2.0 On-Behalf-Of flow and follow the code sample as your shown , and use fiddler or developer tools to trace the requests and troubleshoot the 401 problem .


Q: When to use lib.es2015.d.ts vs @types/core-js? It seems lib.es2015.d.ts that ships with the Typescript compiler conflicts with the @types/core-js package if they are both being referenced.
This post indicates that the solution is either:

*

*Change es6 to es5 in compilerOptions's lib property. This way TypeScript won’t include ES6 type definitions.

*Remove core-js from node_modules. This way TypeScript will use only its internal ES6 type definitions.

What I don't understand is why does @types/core-js then even exist, and when is it useful, since the compiler already ships with these definitions?


Q: How do EDMFunction work? We had a developer who attempted to filter on a numeric ID property using a string:
var student = (from s in dbStudents
        where s.StudentId.ToString() == "2"
        select s).FirstOrDefault();

This won't work, as ToString() cannot be translated into SQL by the EF Provider.
One solution was provided works, but I honestly am unclear about why it works:
[EdmFunction("SqlServer", "STR")]
public static string ConvertToString(double? number)
{
   return number.HasValue ? number.ToString() : null;
}

And the query now looks like:
var student = (from s in Students
        where ConvertToString((double) s.LanguageId).Trim() == "2"
        select s).FirstOrDefault();

My understanding is this query should be building up an expression tree, but it appears that we have a CLR method being executed in the middle? I had thought that we could only use methods where the provider understood how it could be translated into SQL.
The SQL looks right, can anyone tell me how we got from:
return number.HasValue ? number.ToString() : null;

to
SELECT TOP (1)
[Extent1].[StudentId] AS [StudentId],
[Extent1].[Name] AS [Name]
FROM [dbo].[Student] AS [Extent1]
WHERE N'2' = (LTRIM(RTRIM(STR( CAST( [Extent1].[StudentId] AS float)))))

A: The Entity Framework uses only the information in the attribute to convert the method call to SQL. The implementation is not used in this case.

A: The EdmFunction attribute calls the specified method in SQL. The implementation you have in C# will be ignored. So in your case STR method is called at SQL end.
You can have your method as:
[EdmFunction("SqlServer", "STR")]
public static string ConvertToString(double? number)
{
   throw new NotSupportedException("Direct calls not supported");
}

and still it would work.
See: EDM and Store functions exposed in LINQ

How it works
When a method with the EdmFunction attribute is detected within a LINQ
  query expression, its treatment is identical to that of a function
  within an Entity-SQL query. Overload resolution is performed with
  respect to the EDM types (not CLR types) of the function arguments.
  Ambiguous overloads, missing functions or lack of overloads result in
  an exception. In addition, the return type of the method must be
  validated. If the CLR return type does not have an implicit cast to
  the appropriate EDM type, the translation will fail.

As a side note, you can also use SqlFunctions.StringConvert like:
var student = (from s in Students
        where  SqlFunctions.StringConvert((double) s.LanguageId)).Trim() == "2"
        select s).FirstOrDefault();