text:
Q: Performance: create collection from scratch or iterate and add missing? (Java) A quick question: which is preferable, either performance-wise or programming-wise:
Situation:
You have a table in a database which contains information about an object, for example:
Table Car which has columns Id (PK), Brand, Colour.
You have a program that displays information about the cars in your database. You can select a Brand and it shows you all the cars from that brand. A call to the database is performed to get this information. Every car that is displayed is made into an Object Car in your program, with the corresponding attributes, and added to the Collection CarCollection (ArrayList). Next time you need information about a specific Car, the program first checks if the Car is in the collection. If this is not the case, a call to the database is done.
So you end up with a Collection of Cars. Now I want to display all the Cars I have in my database. They may all be in the CarCollection already, but that is not certain.
What is preferable:

*

*Use a query to select all Cars, clear the contents of the existing CarCollection and fill the collection from scratch

*Use a query to select all Cars, iterate through the CarCollection and the database result and add those that are missing

*Use a query that only selects the Cars not in the collection and add those

Extra note: Collection.contains() yields only false, it does not recognize the objects on the list as the same that are in the collection (even if this is the case).
Another extra note: The idea behind the collection was to minimalize calls to the database. If an object is already in the collection, a database call is no longer needed.
Suggestions for a completely different approach are of course also welcome.

A:
Collection.contains() yields only false

Then you probably need to override equals and hashcode on your objects.

The idea behind the collection was to minimalize calls to the database

Let's assume that your objects have an id, why not call a
SELECT ... FROM ... WHERE id NOT IN (<the list of ids that you already have>)

?

A: You need to be more clear on phrasing the requirement. It is easy to find the missing object.
First point here is how to define the object. Means how uniquely you will identify the objects. Then define equals() and hashcode() methods are implemented.
public class Entity{
     private int id;
     ......
     .......

     public boolean equals(Object obj){
        if(!(obj instanceof Entity)){
           return false;
        }
        EntityObj eobj = (Entity)obj;

        return (id==eobj.id);

     }

     public int hashcode(){
        return id; //Any hashing function is fine
     }

}

Once you have object defined. You just need to fetch all the elements from Database and compare with the collection elements and find the missing.
Collection needs to be used for searching depends on your requirement. If it is List interface you need to iterate them is time consuming.  For any searching it is better to use hashing function for fast Search.


text:
Q: Qt 5.6 VS 2015 Add-in asks to specify default version My story starts same as here Qt 5.6 VS 2015 problem

I have installed this
http://download.qt.io/development_releases/qt/5.6/5.6.0-beta/qt-opensource-windows-x86-msvc2015-5.6.0-beta.exe.mirrorlist
And tried it using this extension on VS
https://visualstudiogallery.msdn.microsoft.com/c89ff880-8509-47a4-a262-e4fa07168408

I've faced the same problem as described in that question. And the answer solved my problem as well.
But now I have another error. I've searched on the net but couldn't find anything related to. By now, QT path in Qt Add-in is set. Every time I click 'Open .pro project' it tells me
The following error occurred:
The default Qt version does not support Visual Studio 2015.
In order to import .pro files specify a Qt version >=5.2 as default.

So, the question is how to specify a Qt version. Probably it's one line in a config file, but in which one?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Wordpress pages theme/layout I'd like to know whether I could have different layout and content for each page?
For example, I have 4 pages, and I have 4 completely different layout design, do I need to make 4 themes then apply to different pages or something else?
Moreover,   can I have different posts show on different page?
like post no.1/or tag [google] goes to page 1, post no.5/tag[orange] goes to page 3?
I'd like to learn how to structure this idea.
Many thanks

A: make the diffrent template for different pages  to show the  different  design on  every page
for  making template   create normal php file  and at the top of file  add the  code for every template  by replacing template  name
<?php
/*
Template Name:About Us

 */

  ?>

By this  you get different template  for about us  put you code desing that  you want to show for  this page  and from that  back end select the  template  from rignt hand side option and save  that page .
And to show different post on different pages  you need to create category after that  where you want to call the post for page call the  category   code for  that
<?php Query_post('cat=3&showposts');
      while(have_posts()): the_post();
           the_title();
       endwhile; wp_reset_query(); ?> every time  on different page you just chage the category id   (cat)


text:
Q: One server and Multi client chat box in UDP I'm trying to design a chat application using UDP networking in java.
Here is my server:
package ChatBox;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Server implements Runnable {

public Hashtable<String, InetAddress> table;
public Hashtable<String, Integer> tab;
DatagramSocket sock = new DatagramSocket(5050);
DatagramPacket pack;
private String str[];
int Port;

Server(String str[]) throws SocketException, UnsupportedEncodingException, IOException {
    this.str = str;
    String Sname = str[2];
    System.out.println(Sname);
    byte[] data = new byte[1000];
    pack = new DatagramPacket(data, data.length);
    sock.receive(pack);
    String s = new String(data, "UTF-8");
    String s1 = s.replaceAll("\n", " ");
    StringTokenizer st = new StringTokenizer(s1, " ");
    int f1 = 0, f2 = 0, f3 = 0;
    String sender;

    while (st.hasMoreTokens()) {
        String s2 = st.nextToken();
        if (s2.equals("Via:")) {
            if (st.nextToken().equals(Sname)) {
                f1 = 1;
            }
        } else if (s2.equals("To:")) {
            if (st.nextToken().equals(Sname)) {
                f2 = 1;
            }
        }
        else if(s2.equals("From:"))
        {
            sender = st.nextToken();
            table.put(sender, pack.getAddress());
        }
        else if (s2.equals("Port:")) {
            Port = Integer.parseInt(st.nextToken());
            if (tab.get(Port) != null) {
                f3 = 1;
            }
        }
    }
    if ((f1 == 1) && (f2 == 1) && (f3 == 1)) {
        new Thread(this).start();
    } else {
        if (f1 == 0) {
            System.out.println("Warning: Server name mismatch. Message dropped.");
        }
        if (f2 == 0) {
            System.out.println("Warning: Server name mismatch. Message dropped.");
        }
        if (f3 == 0) {
            System.out.println("Warning: Unknown recipient. Message dropped.");
        }
    }
}

public void run() {
    while (true) {
        try {
            String s;
            String namefind;
            String name = null;
            byte[] data = new byte[1000];
            DatagramPacket receivePack = new DatagramPacket(data, data.length);
            sock.receive(receivePack);
            System.out.println(new String(receivePack.getData()));
            s = new String(data, "UTF-8");
            String s1 = s.replaceAll("\n", " ");
            StringTokenizer st = new StringTokenizer(s1, " ");
            while (st.hasMoreTokens()) {
                namefind=st.nextToken();
                if (namefind.equals("Body:")) {
                    namefind = st.nextToken();
                    StringTokenizer namefind2 = new StringTokenizer(namefind, "$");
                    name = namefind2.nextToken();
                    tab.put(name, Port);
                }
            }
            sendPackToClient(receivePack,name);

        } catch (Exception e) {
            System.out.println(e);
        }
    }
}
public void sendPackToClient(DatagramPacket receivePack,String name) throws IOException {
    byte[] data = receivePack.getData();
    String s = new String(data, "UTF-8");
    InetAddress add = table.get(name);
    DatagramPacket dp = new DatagramPacket(s.getBytes("UTF-8"), s.getBytes("UTF-8").length, add, Port);
    sock.send(dp);
}

public static void main(String[] args) throws SocketException, IOException {
    try {
        String str[]={"java", "Server ","NetworkingAssignmentServer"};
        new Server(str);
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
    }
}
}

And here is my Client:
package ChatBox;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Client {

Thread send;
Thread accept;
DatagramPacket pack;
DatagramSocket sock;
private String str[];
String name, sname;
int listeningPort;
InetAddress server_ip;
String message, sender;

public Client(String s[]) throws UnsupportedEncodingException, IOException {
    this.str = s;
    name = str[2];
    System.out.println(name);
    listeningPort = Integer.parseInt(str[3]);
    server_ip = InetAddress.getByName("127.0.0.1");
    sname = str[5];
    System.out.println(sname);
    sock = new DatagramSocket(5050);
    byte[] data = new byte[1000];
    pack = new DatagramPacket(data, data.length);
    sock.receive(pack);
    String incoming = new String(data, "UTF-8");
    String s1 = incoming.replaceAll("\n", " ");
    StringTokenizer st = new StringTokenizer(s1, " ");
    int f1 = 0, f2 = 0;

    while (st.hasMoreTokens()) {
        String s2 = st.nextToken();
        if (s2.equals("Via:")) {
            if (st.nextToken().equals(sname)) {
                f1 = 1;
            }
        } else if (s2.equals("To:")) {
            if (st.nextToken().equals(name)) {
                f2 = 1;
            }
        }

    }
    if ((f1 == 1) && (f2 == 1)) {
        send = new Thread() {

            public void run() {
                while (true) {
                    try {
                        InetAddress host = InetAddress.getByName("localhost");
                        try {
                            Scanner input = new Scanner(System.in);
                            String in = input.nextLine();
                            System.out.println(in);
                            StringBuffer str = new StringBuffer("");
                            str.append("Via: ");
                            str.append(sname + "\n");
                            str.append("To: " + sname + "\n");
                            str.append("From: " + name + "\n");
                            str.append("Body: " + in);
                            byte[] data = new byte[1000];
                            data = str.toString().getBytes("UTF-8");
                            DatagramPacket sendPack = new DatagramPacket(data, data.length, host, 5050);
                            sock.send(sendPack);
                        } catch (Exception e) {
                            System.out.println(e);
                        }
                    } catch (UnknownHostException ex) {
                        Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }

        };
        send.start();
        accept = new Thread() {

            public void run() {
                while (true) {
                    try {
                        sock = new DatagramSocket(5050);
                        byte[] data = new byte[1000];
                        pack = new DatagramPacket(data, data.length);
                        sock.receive(pack);
                        String incoming = new String(data, "UTF-8");
                        String s1 = incoming.replaceAll("\n", " ");
                        StringTokenizer st = new StringTokenizer(s1, " ");
                        while (st.hasMoreTokens()) {
                            String s2 = st.nextToken();
                            if (s2.equals("From:")) {
                                s2 = st.nextToken();
                                StringTokenizer namefind = new StringTokenizer(s2, "$");
                                sender = namefind.nextToken();
                            } else if (s2.equals("Body:")) {
                                s2 = st.nextToken();
                                while (st.hasMoreTokens()) {
                                    message = st.nextToken();
                                }
                            }
                        }
                        System.out.println(sender + " says: " + message);
                    } catch (UnknownHostException ex) {
                        Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (SocketException ex) {
                        Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (IOException ex) {
                        Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        };
        accept.start();
    }
}

public static void main(String[] args) throws IOException {
    String str[] = {"Java", "Client", "Sheba", "12345", " 127.0.0.1", "NetworkingAssignmentServer"};
    new Client(str);
}

}

But i'm always getting errors, like:
Exception in thread "main" java.net.BindException: Address already in use: Cannot bind
at java.net.DualStackPlainDatagramSocketImpl.socketBind(Native Method)
at java.net.DualStackPlainDatagramSocketImpl.bind0(DualStackPlainDatagramSocketImpl.java:84)
at java.net.AbstractPlainDatagramSocketImpl.bind(AbstractPlainDatagramSocketImpl.java:93)
at java.net.DatagramSocket.bind(DatagramSocket.java:392)
at java.net.DatagramSocket.<init>(DatagramSocket.java:242)
at java.net.DatagramSocket.<init>(DatagramSocket.java:299)
at java.net.DatagramSocket.<init>(DatagramSocket.java:271)
at ChatBox.Client.<init>(Client.java:44)
at ChatBox.Client.main(Client.java:140)
C:\Users\HP\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53:          Java returned: 1
BUILD FAILED (total time: 0 seconds)

What should i do? Any help would be really appreciated.

A: I notice server code and client code both use the same port 5050, when they are in the same PC, bind will return error.
So you should put different port to the server and client. Or you can use different PC to run the server and client separately.
Put different in this statement:
sock = new DatagramSocket(5050); // Server : 5050, Client 5000


text:
Q: Convert associative array elements to object only My array
$arr = array(
  "name" => "Prakash",
  "tall" => "maybe",
  "nick_names" => array ("p", "b", "bee", "prak", "new_names" => array("short_name" =>   "sn", "long_name" => "ln"))
);

I want to be able to create an object from which the values can be accessed via attributes.
e.g.
 $obj->name // "PRAKASH"
 $obj->nick_names // array("p", "b", "bee", "prak", "new_names" => (object))

How could I get this ?
I seem to able to accomplish exactly what I need through
$obj = json_decode(json_encode($arr));

But obviously that is not the right thing to do.
Thanks.

A: You can cast it into an stdClass:
$obj = (stdClass) $arr;

Take note that in PHP an array is far superior to an stdClass in any thinkable way.

*

*Better performance

*Better traversing abilities

*Better readability (IMO)


text:
Q: Consider using the "jsdom" test environment I have this simple test:
import React from 'react'
import { render } from '@testing-library/react'

import Button from '.'

describe('Button', () => {
  it('renders button without crashing', () => {
    const label = 'test'

    render(<Button label={label} />)
  })
})

And I have a jest.config.json with this content
{
  "setupFilesAfterEnv": [
    "<rootDir>/lib/settings/setupTests.ts"
  ]
}

And on my setupTests.ts I have
import '@testing-library/jest-dom'

When I run npm run test (which just run jest), I got the following error:

The error below may be caused by using the wrong test environment, see
https://jestjs.io/docs/configuration#testenvironment-string.
Consider using the "jsdom" test environment.

What I am doing wrong? This used to work before an upgrade.

A: In your package.json, or jest.config.js/jest.config.ts file, change the value of the testEnvironment property to jsdom.
package.json
"jest":{
    "testEnvironment": "jsdom"
}

jest.config.[js|ts]
module.exports = {
    "testEnvironment": "jsdom"
}

Important note for jest >28
If you are using jest 28, you will need to install jest-environment-jsdom separately by either:
npm: npm i jest-environment-jsdom --save-dev
yarn: yarn add -D jest-environment-jsdom
Why?
By default, jest uses the node testEnvironment. This essentially makes any tests meant for a browser environment invalid.
jsdom is an implementation of a browser environment, which supports these types of UI tests.
For Jest version 28 and greater, jest-environment-jsdom was removed from the default jest installation to reduce package size.
Additional reading
jest testEnvironment documentation
Jest 28 breaking changes

A: This can be solved on a per-test-file basis by adding a @jest-environment docblock to the beginning of your file. For example:
/** @jest-environment jsdom */
import React from 'react'
import { render } from '@testing-library/react'

import Button from '.'

describe('Button', () => {
  it('renders button without crashing', () => {
    const label = 'test'

    render(<Button label={label} />)
  })
})

If your project has a mix of UI and non-UI files, this is often preferable to changing the entire project by setting "testEnvironment": "jsdom" within your package.json or Jest config. By skipping initializing the JSDom environment for non-UI tests, Jest can run your tests faster. In fact, that's why Jest changed the default test environment in Jest 27.

A: by default the value for testEnvironment is node which runs all test cases in node.js envioronment, but js-dom provides browser like enviornment. instead of adding jsdom value, you can even add file specific value like below which will work.
/**
 * @jest-environment jsdom
 */
// the above comment helps
test('use jsdom in this test file', () => {
  const element = document.createElement('div');
  expect(element).not.toBeNull();
});

We can even add test file specific environments, please refer this link.
https://jestjs.io/docs/configuration#testenvironment-string

A: Try this.
module.exports = {
testEnvironment: 'jsdom',

}


text:
Q: System of two ODEs, problem with finding eigenvectors I am fairly new to systems of ODEs so bear with me.
$$
\left\{
\begin{array}{c}
x' = 2x-y \\
y' = x+2y \\
\end{array}
\right.
$$
So, I know I have to find the eigenvalues, which is not a problem for me. The eigenvalues are $2 \pm i$
After inserting the first value in the matrix of the system and multiplying it by a column-matrix consisting of $C_1$ and $C_2$, I get the system:
$$
\left\{
\begin{array}{c}
-iC_1 - C_2 = 0\\
C_1-iC_2=0 \\
\end{array}
\right.
$$
Now, my question is as follows:
If I express $C_2$ from the first equation I get $C_2 = -i C_1$. After inserting that in the second equation I get that $C_1 - C_1 = 0$, which leads me to think that $C_1$ is any real number. After choosing the number $1$, I get that the eigenvector is $v_1 = (1,-i)$
However, WolframAlpha says that the eigenvector is $(i,1)$, which leads me to think that I should have expressed $C_1$ from the second equation and substituted it into the first, which is when I get the same solution as in WolframAlpha.
But does it matter what variable I express though? I'm also new to eigenvectors so I don't know a whole lot about them. Can anyone help?

A: Writing
\begin{align}
-iC_1 - C_2 &= 0 \\
C_1-iC_2 &=0
\end{align}
And multiplying the first relationship by $i$ one finds
\begin{align}
-C_1 +i C_2 &= 0\\
C_1-iC_2 &=0
\end{align}
Whereby one relationship is a factor of $-1$ of the other. Do you see where I am heading?


text: Q: Does mysql NDB Cluster support configuration of Maximum number of replicants in a Node group should be available for write operation to be performed? Example: If I have 3 replicants in a Node group, and I want the write operation should be allowed only if there are atleast more than 50% of data nodes I.e, 2 in this case, to be available in the respective Node group.


text:
Q: How to monitor a remote read-only subversion repo for commit changes and do "svn update" immediately? I want to enable monitoring of remote read-only subversion for commit changes and do "svn update" immediately. How i can do this ?
Maybe some script with wget of svn log page, cut(grep) everything except first line with revision, compare number with local copy(is there an svn command that will display local rev number?) and it it is not equal then run "svn update" and set this script to run every minute ?
SVN: http://code.google.com/p/miranda/source/list

A: This will do the trick:
#! /bin/bash

REMOTE_REPO="http://miranda.googlecode.com/svn/trunk/"
LOCAL_REPO="/lib/svn/miranda/"

REMOTE_REV=`svn info $REMOTE_REPO | grep '^Revision:' | awk '{print $2}'`
LOCAL_REV=`svn info $LOCAL_REPO | grep '^Revision:' | awk '{print $2}'`

if [ $REMOTE_REV -eq $LOCAL_REV ]; then
exit 0;
else
# Run your commands here.
cd $LOCAL_REPO
svn up
fi


text:
Q: Architechture python +flask and spring boot +java I would know how to describe this archtechture as a backend I used spring boot, java, flask and python to deploy rest api and as a frontend I used angular is it a mircoservices architechture ?

A:
"Is it a microservices architecture ?" -

It is not possible to say from the limited information you have provided.
There is no single canonical definition of Microservices; see Wikipedia.  So deciding whether a system is implementing a Microservices architecture is always somewhat subjective.
What you have described in your Question matches a couple of the bullet points in the Wikipedia page:

*

*The components are process that communicate over a network using a technology agnostic protocol.

*The components are implemented in multiple languages.

But these are not sufficient to say one way or another.  The other things that matter include the granularity of the services, whether they can be developed independently, whether they can be deployed and used independently, and so on.
My advice would be to read the descriptions for Microservices, then come to your own conclusion.


text:
Q: PHP Undefined offset: -1 in comparison loop I am receiving this error Undefined offset: -1.
I am pretty sure it is because I am comparing a value of an array index with the value of the previous index, so on the first iteration its failing because there is no -1 index.
for ($i=0; $i<$rows_n; $i++)
{
    formatTR($i, $rows, 'YEAR');
}

// Function
function formatTR($i, $rows, $year)
{

    if ($rows[$year][$i] != $rows[$year][$i-1] ) {
        print "
{$rows[$year][$i]}
";
    }

    print "
";
}

The function checks to see if the previous value of $rows[year][i] is the same as the previous $rows[year][i-1]. If its different, it prints out a formatted
.
Seems like a way to avoid this error would be to first check if the value of $i is zero, but I'm wondering if there is another way. Possibly in my if conditional.

A: I think the easest way is to check if $i>0
if ($i > 0 && $rows[$year][$i] != $rows[$year][$i-1] ) {
  // ...
}

A: "Undefined offset" is almost always an off-by-one error, and here is the culprit:
if ($rows[$year][$i] != $rows[$year][$i-1] ) {
-------------------------------------^^^^

Make sure you never call this row if $i == 0

A: function formatTR($i, $rows, $year)
{
    if($i > 0){
        if ($rows[$year][$i] != $rows[$year][$i-1] ) {
        print "
{$rows[$year][$i]}
";
        }
    }
    print "
"; //not sure why you have this here.

}

If you want $rows[$year][0] to print a
:
function formatTR($i, $rows, $year)
{
    if($i > 0){
        if ($rows[$year][$i] != $rows[$year][$i-1] ) {
          print "
{$rows[$year][$i]}
";
        }
    } else {
        print "
{$rows[$year][$i]}
";
    }
    print "
"; //not sure why you have this here.

}


text:
Q: WAN Miniport (Network Monitor) #2 network adapter has exclamation mark in device manager I have WAN Miniport (Network Monitor) #2 network adapter with exclamation mark in device manager.

Description says

This device is not working properly because Windows cannot load the
  drivers required for this device. (Code 31)

The Uninstall button does nothing.
How to fix/uninstall?

A: If you right-click on the WAN Miniport, select "Update Driver".
Then select "Browse my computer", Followed by "Let me pick driver from a list".
Un-check "Show compatible hardware". From the Manufacturer list, choose Microsoft, and from the Network Adapter list, choose "MAC Bridge Miniport". (Choose any device. If un-sure, just select the first entry, which should be the: Generic Broadband device driver.
Back in the device manager, delete the "MAC Bridge Miniport" device.
Once you're done deleting the device, you MUST reboot your PC.


text:
Q: Amazon Web Services : Setting S3 policy to allow putObject and getObject but deny listBucket I am using getObject and putObject requests on Amazon S3 and in creating a policy for access to the bucket I discovered that if I don't allow listBucket I get an 'access denied' error.
The problem with this is that listBucket means a user can list the keys in a bucket and this presents
a security threat.
Is it possible to allow getObject and putObject without allowing listBucket?
or is there a workaround for this?
Here is the policy:
 {
 "Version": "2012-10-17",
"Statement": [
{
  "Sid": "Stmt##",
  "Effect": "Allow",
  "Action": [
    "s3:ListBucket"
  ],
  "Resource": [
    "arn:aws:s3:::myBucket"
  ]
},
{
  "Sid": "Stmt##",
  "Effect": "Allow",
  "Action": [
    "s3:GetObject",
    "s3:PutObject"
  ],
  "Resource": [
    "arn:aws:s3:::myBucket/*"
  ]
}
 ]
}

A: From the Get Object documentation:

You need the s3:GetObject permission for this operation.  For more information, go to Specifying Permissions in a Policy in the Amazon Simple Storage Service Developer Guide. If the object you request does not exist, the error Amazon S3 returns depends on whether you also have the s3:ListBucket permission.

I've confirmed this behavior by editing a policy that was essentially identical to yours.
I am able to get an existing object without trouble, whether or not I have the s3:ListBucket privilege, as long as I have the s3:GetObject privilege.
The behavior changes only if I don't also have the s3:ListBucket privilege, and I request an object that does not exist.  In that case, S3 will not admit to me whether that object exists -- I'm denied access to knowledge about the existence of the object, since I'm not authorized to see the list.
Response for a valid request to a nonexistent object, without s3:ListBucket:
<Error>
 AccessDenied
 <Message>Access Denied</Message>
 <RequestId>xxxx</RequestId>
 <HostId>xxxx</HostId>
</Error>

Response for a valid request for the same nonexistent object, with s3:ListBucket:
<Error>
 NoSuchKey
 <Message>The specified key does not exist.</Message>
 <Key>fakefile.txt</Key>
 <RequestId>xxxx</RequestId>
 <HostId>xxxx</HostId>
</Error>

So, on objects that don't actually exist, "access denied" is the expected response without s3:ListBucket.  Otherwise, it works as expected.


text:
Q: NSError code check: Binary operator '==' cannot be applied to two Int operands Can someone tell me what I'm doing wrong here? "error" is NSError returned from CloudKit.
if error.code == Int(CKErrorCode.NetworkFailure) {
    //do something
}

Gives me this error:

Binary operator '==' cannot be applied to two Int operands

If I do this, it works fine:
if error.code == 4 {
    //do something
}

Where 4 is the actual error code.

A: The problem here is that Int doesn't have a constructor that takes CKErrorCode as input.
As in the comments, the way to compare the two values would be:
if error.code == CKErrorCode.NetworkFailure.rawValue {
    //do something
}

Thankfully, the error messages have been improved for XCode 7 and Swift 2, so you would see:

Cannot invoke initializer for type 'Int' with an argument list of type '(CKErrorCode)'

Which is a much better indicator of what went wrong.


text:
Q: Javascript countdown timer that visually counts from 'hours:minutes:seconds' using PHP Date info & variables I have a PHP script that calculates the difference between a set date and the current date (in h:m:s) and I'd like to use that data for a simple visual Javascript countdown timer (using the PHP variables). This is the PHP code:
$date = date('Y-m-d h:i:s a', time());
$d1 = new DateTime("2012-11-18 11:14:15");
$d2 = new DateTime($date);
$result = $d1->diff($d2);
$hours = ($result->d*24)+$result->h;
$minutes = $result->i;
$seconds = $result->s;

What would be your preferred and most efficient way to display a countdown timer in Javascript? (Using either $d1 and $d2 or $hours, $minutes, $seconds?)

A: Maybe you could use some Jquery plugin, like this one: Jquery Countdown
If you don't want to use plugins the general idea is this:

*

*PHP writes the starting datetime to a HTML tag or to a javascrit variable.
echo '
$year
';

*In javascript you create a function that decreases a current datetime by 1 second, decreasing minutes, hours, etc, when necessary.
function decrease_by_1_sec(){
     ...
}

*Next, on the $(document).ready() function you make the decrease_by_1_sec() function execute every second.
setInterval(decrease_by_1_sec(), 1000);
And that's it! that's the general idea.

A: Try this jQuery countdown plugin - http://keith-wood.name/countdown.html


text:
Q: Javascript stuck when calling an API method I use AJAX to gather data from a MySQL database through PHP, but all the Javascript functions on the web page get stuck when I'm trying to call an API method using the gathered data.
AJAX code structure:
$.post(
  "userdata.php",
  { id: ""+userid+"" },
  function(data) {
    // call my API when AJAX call completed
  }
);

The above code works perfectly. For example I tried alert(data);, it alerts the requested user's name.
My full code:
$.post(
  "userdata.php",
  { id: ""+userid+"" },
  function(data) {
    $.formdata.clear();
    $.formdata.addname(data);
  }
);

My API also works fine. I think the error is because of the $ sign, like $.post and inside of it again $.formdata.
Any solution for this?

A: The $ symbol is a name to reference jQuery. Here you are trying to reference a property of jQuery called formdata.
The formdata object looks like something you're written, since it has clear and addname methods. Try calling it without the dollar sign.
formdata.clear();
formdata.addname(data);


text:
Q: regular expression: matching certain format but excluding specific value I'd like to verify that a value is a mobile phone number and at the same time, does not match one specific mobile phone number.
For example, the value should be 7 or 8 numbers in length but should not be 01010101.

*

*12346789 (0)

*1234323 (0)

*01010101 (x)

*0101010 (0)

Some kind of AND operator is required, but I can't seem to figure out appropriate form.
Below is a failed approach.
/^(?=\d{7,8}))(?!(01010101))$/

Edit: This regex is going to be used in Javascript.

A: Your regex never going to match any string until moving the end anchor($) to the assertion parentheses. The below regex would be simple assert the position and it doesn't capture any value.
/^(?=\d{7,8}$)(?!01010101$)/

Use negative look-ahead assertion to avoid that particular pattern.

/^(?!01010101$)\d{7,8}$/

Regex explanation here
Where \d{7,8} would match any number combination of length 7 or 8 and for avoiding 01010101 combination use negative look-ahead assertion((?!01010101$)) which fail to match from the beginning itself.

A: The reason your approach is failing is that you are trying to match:
7-8 digits followed by not 01010101
If you want to have it the regex in that particular order you need to use negative lookbehind
^(\d{7,8})(?<!(01010101))$

Furthermore (this might be intetional, but) you are using both lookahead and negative lookahead which means you wont capture anything - just match.
The expression above will capture the numbers in the first capturing group ($1).

JavaScript does not support negative lookbehind according to http://regexr.com/
You could use the equivalent expression:
^(?!(01010101))(\d{7,8})$

Alternatively remove ^ and $ if you are using http://regexr.com/ and want to match multiple rows

A: This regex worked for me when testing:
^((?!01010101$)\d{7,8})$

Demo here:
Regex101
Explanation: This regex checks that the string contains either 7 or 8 digits, but at each point of the match, it asserts that the string does not contain 01010101, which is the number you don't want to match.
Note that using a negative lookahead appears to be completely acceptable in Javascript.  For example, the following match would return true:
/^((?!01010101$)\d{7,8})$/.test('1234567');

while the following would return false:
/^((?!01010101$)\d{7,8})$/.test('01010101');


text:
Q: WebApplicationContext in Spring.NET - Is it thread safe? I'm dealing with some tech debt on a web project I inherited.  Instead of using the context provided thru Spring.NET's WebContextHandler, I am instantiating the Spring application context programmatically, so I can consolidate multiple connection strings in this thing's numerous config files.
Right now, I have this instantiating once upon first use, using a singleton pattern.  Will this be fine for a web application, or do I need to initialize a new instance per web request?

A: I cannot find that class in the official Spring.NET API Documentation located here so I can't give you any definite answers.
But as Spring.NET is OpenSource I suggest you look at the source code of that class on their GitHub Repository and try to see whether they use some form of locking. I can't find anything like that in this class, so allthough I can't see any writes outside the constructors you probably should not rely on the thread safety here.
Actually nevermind: The base class and the base class of that do lots of things which write to the object's state so the class is definitely not thread safe.
As I am not familiar with the Spring Framework I am not sure what you try to accomplish. Maybe you could wrap accesses to this object in your own lock-statements.
Other than that: How to use this class should be documented somewhere.
Also: While I was looking through the code of AbstractApplicationContext I found a property called SyncRoot. Whenever a class has a SyncRoot-property there has to be a synchronization mechanism somewhere.


text:
Q: Retrieving the filenames from subdirectories I want to retrieve the filenames of all the files with .xml extension present in various subfolders in a single directory,

A: Use os.walk, and str.endswith.

A: code:
import os
xmlFiles = []
for directoryPath in os.walk(filePath):
    fileName = directoryPath[2]
    if fileName[:3] = 'xml':# or fileName.endswith('xml'):
        xmlFiles.append(fileName)


text:
Q: Let $G$ be a finite group with prime order $p$ and $H$ a finite group of prime order $q$. How many homomorphisms $f: G \to H$ are there?
Let $G$ be a finite group with prime order $p$ and $H$ a finite group of prime order $q$ such that $p \ne q$. How many homomorphisms $f: G \to H$ are there?

If $|G|=p$, then for $g \in G$ we have that $g^p=e_G$. If $f$ is a homomorphism, then $f(e_G)=e_H$ which means that $f(g^p)=f(g)^p=e_H$, thus $p$ must divide the order of $H$. That is we have $p \mid q$. I think that this implies that $p=q$ which contradicts the fact that $p \ne q$ so there are no homomorphisms?

A: More generally,  let $G,H$ be finite groups of relatively prime order.   Then there is only the trivial homomorphism from $G$ to $H$.
The argument is just the same:   for any $g\in G$, and any homomorphism $h:G\to H$,  we have that the order of $h(g)$ divides both the order of $G$ and of $H$.  Thus $h(g)=e$.


text:
Q: Vaadin - run client side javascript after image fully loaded I need to print a picture on client side. I used this as a template. My PrintUI looks like this:
@Override
protected void init(VaadinRequest request) {
    Item item = ..get item ..

    StreamResource imageStream = ... build image dynamically ...
    Image image = new Image(item.getName(), imageStream);
    image.setWidth("100%");
    setContent(image);
    setWidth("100%");

    // Print automatically when the window opens
    JavaScript.getCurrent().execute("setTimeout(function() {print(); self.close();}, 0);");
}

This works so far in IE but in chrome it opens the printing preview showing an empty page. The problem is that the image is loaded in some way that chrome does not wait for it and starts the printing preview immideatly.
To verify this, I tried: (setting a 5sec timeout)
JavaScript.getCurrent().execute("setTimeout(function() {print(); self.close();}, 0);");

Then it works in IE and Chrome, but its of course an ugly hack, and if the connection is slower than 5sec, then again it will fail.
In pure JS it would work like this, but Im not sure how to reference the  element from vaadin in cient-side js. Any ideas?

A: You can use AbstractJavascriptExtension.
Example extension class:
@JavaScript({ "vaadin://scripts/connector/wait_for_image_load_connector.js" })
public class WaitForImageLoadExtension extends AbstractJavaScriptExtension {

    private List<ImageLoadedListener> imageLoadedListeners = new ArrayList<>();

    public interface ImageLoadedListener {
        void onImageLoaded();
    }

    public void extend(Image image) {
        super.extend(image);
        addFunction("onImageLoaded", new JavaScriptFunction() {

            @Override
            public void call(JsonArray arguments) {
                for (ImageLoadedListener imageLoadedListener : imageLoadedListeners) {
                    if (imageLoadedListener != null) {
                        imageLoadedListener.onImageLoaded();
                    }
                }
            }
        });
    }

    public void addImageLoadedListener(ImageLoadedListener listener) {
        imageLoadedListeners.add(listener);
    }
}

and javascript connector (placed in wait_for_image_load_connector.js) with the waiting method you have linked:
window.your_package_WaitForImageLoadExtension = function() {
        var connectorId = this.getParentId();
        var img = this.getElement(connectorId);

        if (img.complete) {
            this.onImageLoaded();
        } else {
            img.addEventListener('load', this.onImageLoaded)
            img.addEventListener('error', function() {
                alert('error');
            })
        }

    }

Then you can do something like that:
Image image = new Image(item.getName(), imageStream);

WaitForImageLoadExtension ext = new WaitForImageLoadExtension();
ext.extend(image);
ext.addImageLoadedListener(new ImageLoadedListener() {

    @Override
    public void onImageLoaded() {
        JavaScript.eval("print()");
    }
});

In your case, when calling print() is the only thing you want to do after the image is loaded, you can also do it without server-side listener by just calling it in the connector:
if (img.complete) {
    print();
} else {
    img.addEventListener('load', print)
    img.addEventListener('error', function() {
        alert('error');
    })
}


text:
Q: How to get the Country-State-City selector in just one SelectMenu conditionally in reactJs? (not duplicate) The solution for a question related to this is already existing over the stack overflow, but there is huge difference .
The former questions on this topic is related to have 3 select menus viz,
one dropdown for selecting country
2nd dropdown for selecting state
3rd dropdown for selecting city.
But, I dont want 3 cascading dropdowns, rather I want them to get clubbed together to a single dropdown. ( mainly location), which would take care of the city, country, state, based on what is being typed into the textField for selectMenu.
Just like Linkdin's select employee menu..
could anyone tell me what could be the possible data schema of menu items, for linkedsIn select menu?.
do it have seperate values with ids like
cities (all cities in the globe), countries (all countries in the globe), (all states in the globe), and they got clubbed together based on their primary keys acting as the foreign key for other data, say primary key for country act as the foreign key for state and so on , so forth?
I just want to know, how could I achieve the cascade country, state, city select but with only a single select menu?
I am using ReactJs and Material UI as my front-end UI library
All suggestions would highly be valued.


text:
Q: What is Logistic regression with clustered standard errors? I am learning mixed effects logistic regression from this link. In section "Analysis methods you might consider", the author listed several options:

*

*Mixed effects logistic regression, the focus of this page.

*Mixed effects probit regression is very similar to mixed effects logistic regression, but it uses the normal CDF instead of the logistic CDF. Both model binary outcomes and can include fixed and random effects.

*Fixed effects logistic regression is limited in this case because it may ignore necessary random effects and/or non independence in the data.

*Fixed effects probit regression is limited in this case because it may ignore necessary random effects and/or non independence in the data.

*Logistic regression with clustered standard errors. These can adjust for non independence but does not allow for random effects.

*Probit regression with clustered standard errors. These can adjust for non independence but does not allow for random effects.

I think I understand 1-4, but What is "Logistic regression with clustered standard errors"?


text:
Q: Global conserved quantities for point particle coupled to a Schrodinger field We have a box (represented by a potential $V$) with a classical particle in it. If the box has a finite inertia and it's floating in space, then it shakes as the particle bumps on the walls. The total energy and momentum are both conserved (if collisions are elastic, which is the case as we are using a potential to represent the box's walls).
Now, let's imagine the same system but "quantum" (the particle in the box is now represented by a classical Schrodinger field $\psi$). We all know the usual Schrodinger equation for $\psi$ in an external potential $V$, but what if the center of the potential well acts-reacts to the motion of $\psi$?
I imagine that we have to deal with some problem of this type ($\hbar=1$):
$$
i\partial_t \psi(x,t) = H(t)\psi(x,t) =-\frac{1}{2 m }\partial_x^2 \psi(x,t) + V(x-x_0(t)) \psi(x,t)
$$
where $x$ is the coordinate in the "laboratory" reference frame, while $x_0(t)$ is the moving center of the box. For example, our box may be represented by a potential $V(y)$ centered at $y=0$, so that putting $y=x-x_0(t)$ accounts for the dynamics of the floating box.
Now, we need an additional equation for the floating box. I guess that we should conserve the total momentum ($m_0$ is the box's mass):
$$
\frac{d}{dt} \bigg[\,  m_0 \, \dot{x}_0(t) +  \int dx \,  \psi(x,t)^\dagger (-i\partial_x) \psi(x,t) \bigg] = 0
$$
or
$$
 \dot{x}_0(t) = \frac{p_{tot}}{ m_0 } + \frac{i}{ m_0 } \int dx \,  \psi(x,t)^\dagger  \partial_x \psi(x,t)
$$
for a constant and assigned total momentum of the system $p_{tot}$. This may be fine, but this equation is not in the form
$m \ddot{x}_0=F[x_0,\psi]$. The force $F$ should be related to $V$, but how?
Now, all this stuff is quite heuristic: I have not derived it from first principles. It is not even clear to me how to show that $p_{tot}$ should be conserved in the first place, even though I have heuristically used it to define the equation of motion of the box.
Is there a total energy that is conserved?
Something like:
$$
E_{tot} = \dfrac{1}{2} m_0  \, \dot{x}_0(t)^2 +  \int dx \,  \psi(x,t)^\dagger H(t)\psi(x,t)
$$
again, this is built on intuition, and it's not clear to me how to show that the dynamics (if the equations that I wrote are correct) conserves it. I think that everything should be more clear (including the presence of constants of motion) if it is possible to write down an action principle (see the update below!) for the dynamical degrees of freedom $\psi$ (the classical Schrodinger field) and $x_0$ (the classical point particle that represents the box).
Regarding the physical interest for this kind of system: The classical field $\psi$ represents a BEC of ultracold atoms (i.e. $\psi =\langle \hat\psi\rangle$ ) interacting with the potential trap $V$, but the trap is a floating one, so its center $x_0$ reacts dynamically as the BEC scatters off the trap's walls.
Update (see the comments): if instead of a classical particle at $x_0$ (i.e. the box) we have two quantum particles, then the problem is similar to the two-body problem in QM. This is not what I am interested in. My question is more: "how to define the (classical) dynamics of a point particle interacting with a classical scalar (complex) field?". This is typically done in classical electrodynamics, where $A^\mu$ evolves together with the charged point particles, see e.g. this answer. However, I have never seen a classical point particle coupled to a scalar field (note that the Newtonian gravitational potential $\phi$ for a configuration of point masses is not an example of "point particles"-"classical scalar field" interaction because $\phi$ is not dynamical).
Edit (variational principle): I figured out that we can obtain the dynamics by considering a total Langrangian that consists of three parts,
\begin{equation}
    L= L_\psi + L_0 + L_{0\psi} \, ,
\end{equation}
where $L_\psi$ is the usual Lagrangian for the Schrodinger field
\begin{equation}
    L_{\psi} = \int     \big\{
       Im [ \psi \partial_t \psi^*   ]
     -\frac{1}{2m}|\partial_x \psi |^2 \big\} \, d x \, .
\end{equation}
Then, we have that $ L_0 $ for the classical particle that represents the box's center of mass is simply
\begin{equation}
    L_0 =    \frac{ m_0 }{2} |\dot{ x}_0(t)|^2
\end{equation}
Finally, the coupling between the box and the Schrodinger field is
\begin{equation}
    L_{0\psi} = - \int dx \,   V( x - x_0 ) |\psi(x,t)|^2 \, .
\end{equation}
The action $I$ for the system is
\begin{equation}
  I = \int d t \, L(x_0, \dot{x}_0, \psi,\partial_t\psi,\partial_x \psi)
\end{equation}
and the Euler-Lagrange equations read
\begin{align}
  & \frac{\delta I}{\delta x_0 } = \frac{\partial L}{\partial x_0} -
  \frac{d}{dt} \frac{\partial L}{\partial \dot{x}_0} =0
  \\
  & \frac{\delta I}{\delta \psi^* } = \frac{\partial L}{\partial \psi^*} -
   \partial_t  \frac{\partial L}{\partial (\partial_t\psi^*)}
   - \partial_x  \frac{\partial L}{\partial (\partial_x \psi^*)} =0
\end{align}
Explicit calculation gives, respectively,
\begin{align}
  & i \, \partial_t \psi(x,t)=    V(x-x_0(t)) \psi(x,t) -\frac{1}{2m} \partial_x^2 \, \psi(x,t)
  \\
  &   m_0  \, \ddot{x}_0  =  - \int d x \,|\psi(x,t)|^2\,  \partial_x V(x-x_0(t))
\end{align}
Given this scheme, how to show that there is a total energy and a total momentum that are conserved? Probably for the energy $E_{tot}$ we should compute the Hamiltonian, and for the total momentum $p_{tot}$?
Finding the Hamiltonian: starting from the Lagrangian it is not obvious which is the associated Hamiltonian (this could be a strategy to find out the conserved energy). This is because the Lagrangian is first order in $\partial_t \psi$. See this paper and this question.
NOTE: I found good insights in this article.

A: Let us consider two quantum-mechanical particles, with coordinates $x$ and $X$ and momenta $p$ and $P$, interacting cia a central potential. Their joint Hamiltonian can be written as
$$
H=\frac{p^2}{2m} + \frac{P^2}{2M} + V(|x-X|)
$$
one can write the two-particle Schrödinger equation
$$
\partial_t \Psi(x, X) = H\Psi(x,X),
$$
and transform the variables to the center-of-mass and the relative coordinates, using the usual transformations:
$$
y_c = \frac{mx + MX}{m+M},\\
y_r = x-X.
$$
This procedure is usually done in quantum mechanics textbooks when solving the hydrigen atom, except that here we are dealing with one dimension and the potential is rectangular (such a potential is used sometimes to described nucleaons, e.g., deuterium).
If we want one particle to behave as classical, we could couple it to a bath of the oscillators and enforce its decoherence using one of the many existing methods (e.g., using quantum Langevin equations or master equations or a Keldysh Green's function approach, Caldeira-Legget, etc) - this is going to be by far the most difficult part of it.

A: To check the conservation of energy and momentum from the two given equations:
\begin{align}
  & i \, \partial_t \psi(x,t)=    V(x-x_0(t)) \psi(x,t) -\frac{1}{2m} \partial_x^2 \, \psi(x,t) \tag{1}
  \\
  &   m_0  \, \ddot{x}_0  =  + \int d x \,|\psi(x,t)|^2\,  \partial_x V(x-x_0(t))
= -\int d x \,|\psi(x,t)|^2\,  \partial_{x_0} V(x-x_0(t))
\tag{2}
\end{align}
Starting from Eq.(2) the semi-classical equation of motion:
\begin{align}
     m_0 & \frac{d}{dt}\dot{x}_0  =  -\frac{d}{dx_0}\int d x |\psi(x,t)|^2\,  V(x-x_0(t)) =-\frac{dt}{dx_0}\frac{d}{d t}\int d x |\psi(x,t)|^2\,  V(x-x_0(t)) \\
m_0  & \dot x_0 \frac{d}{dt}\dot{x}_0  =  - \frac{d}{d t} \langle  V(x-x_0(t))\rangle \\
 \frac{d}{dt}& \left\{ \frac{1}{2}m_0 \dot{x_0}^2 + \langle  V(x-x_0(t))\rangle  \right\} = 0 \tag{3}
\end{align}
where the braket denotes an quantum expectation value.
Now, lets examine the $\langle  V(x-x_0(t))\rangle$ from the Eq.(1)
\begin{align}
  i  \int dx \psi^* \frac{\partial}{\partial t} \psi & = \int dx  \psi^* V(x-x_0(t)) \psi -\frac{1}{2m} \int dx\psi^* \frac{\partial^2 \psi}{\partial x^2} \\
\langle E \rangle & = \langle  V(x-x_0(t))\rangle  +\langle \frac{p^2}{2m} \rangle  \\
\langle  V(x-x_0(t))\rangle & =\langle E \rangle -\langle \frac{p^2}{2m} \rangle
\tag{4}
\end{align}
Substitute Eq.(4) in Eq.(3):
\begin{align}
 \frac{d}{dt} & \left\{ \frac{1}{2}m_0 \dot{x_0}^2 + \langle E \rangle - \langle \frac{p^2}{2m} \rangle  \right\} = 0 \\
\langle E \rangle & + \frac{1}{2}m_0 \dot{x_0}^2 - \langle \frac{p^2}{2m} \rangle  = C
\tag{5}
\end{align}
Eq.(5) shows how the energy changes between the two parties.
To check the conservation of momentum:

The Eq.(2) give the time derivative of the momentum of the box:
\begin{align}
 \frac{d}{dt}m_0\dot{x}_0 &  =  \int d x \,|\psi(x,t)|^2 \frac{\partial}{\partial x} V(x-x_0(t))\\
\frac{d P_0}{dt} & =   \langle \frac{\partial}{\partial x} V(x-x_0(t)) \rangle \tag{6}
\end{align}
Then, we change the momentum change from $\frac{dp}{dt} = i \left[H, P\right]$. The commutator:
\begin{align}
 \left[H, P\right] & = \left[\frac{P^2}{2m} + V(x-x_0), P\right]=\left[V(x-x_0), P\right]\\
 & = V(x-x_0) \frac{1}{i}\frac{\partial}{\partial x} -  \frac{1}{i}\frac{\partial}{\partial x}V(x-x_0) =-\frac{1}{i}\frac{\partial V(x-x_0)}{\partial x}
\end{align}
Thus, the $\frac{dp}{dt}$:
$$ \tag{7}
\frac{dp}{dt} = i \left[H, P\right] = -\frac{\partial V(x-x_0)}{\partial x}
$$
Compare Eq.(6) with Eq.(7) (adding the expectation average), we have
\begin{align}
 & \frac{d \langle p \rangle }{dt} = - \frac{d P_0}{dt}.\\
 & \frac{d}{dt} \left\{\langle p \rangle + P_0 \right\} = 0. \tag{8}
\end{align}
Eq.(8) shows the conservation of momentum.


text:
Q: MySQL workbench 6.3 CE: can't run the empolyee sample database I have recently downloaded and unzipped the employee sample database for MySQL. I was instructed to run the employee.sql file to load the database, but it simply didn't run on my Workbench editor.
I was connecting to the localhost server. The part of employee.sql that couldn't run was as follows:
-- Before this part, a complete database with several tables have already been defined.

SELECT 'LOADING departments' as 'INFO';
source load_departments.dump ;
SELECT 'LOADING employees' as 'INFO';
source load_employees.dump ;
SELECT 'LOADING dept_emp' as 'INFO';
source load_dept_emp.dump ;
SELECT 'LOADING dept_manager' as 'INFO';
source load_dept_manager.dump ;
SELECT 'LOADING titles' as 'INFO';
source load_titles.dump ;
SELECT 'LOADING salaries' as 'INFO';
source load_salaries1.dump ;
source load_salaries2.dump ;
source load_salaries3.dump ;

source show_elapsed.sql ;

According to the error message raised, the source command was out of place here. These lines I think were intended to read data from the dump files into our already defined "frames", so they couldn't be omitted. However, since they couldn't run on the Workbench editor, I have to figure out another way to get it to run. It seems that we could also run SQL scripts on MySQL Shell or the command lines, but that would be too troublesome and what's more I don't want to lose the elegant Workbench GUI. So what can I do?
My goal is just to practice a bit on the sample database, I'm an absolute beginner on Databases.

A: You should run employee.sql from shell as source is a MySQL shell command and is not available through workbench. The link you posted has the steps to install through shell which are easy to follow.
This question is a duplicate of this.


text:
Q: getting errors in retrieving information through inputs I've written my code using semantic-ui-react and react redux, created a compose UI and when we pass inputs to the field it is showing error like this

"TypeError: Cannot read property 'value' of undefined"

I'm trying this using semantic-ui-react and react-redux
import React, { Component } from 'react'
import { Button, Header, Icon, Modal, Form} from 'semantic-ui-react';
import { connect } from "react-redux";

class Compose extends Component {
  handleSubmit = (e) => {
    e.preventDefault();
    console.log("button triggered")
    const From = this.getFrom.value;
    const To =  this.getTo.value;
    const Subject = this.getSubject.value;
    const outboxMessage = {
      From,
      To,
      Subject
    }
   console.log(outboxMessage)
  }

    render() {
      return (
        <Modal trigger={<Button animated inverted color='blue'>
          <Button.Content visible>Compose</Button.Content>
          <Button.Content hidden>
            <Icon name='plus'/>
          </Button.Content>
        </Button>} closeIcon>

           <Modal.Content>
      <Form onSubmit={this.handleSubmit}>
      <Form.Input fluid label='From' type="text" ref={(input)=>this.getFrom = input} />
      <Form.Input fluid label='To' type="text" ref={(input)=>this.getTo = input}/>
      <Form.Input fluid label='Cc' type="text" ref={(input)=>this.getTo = input}/>
      <Form.Input fluid label='Bcc' type="text"  ref={(input)=>this.getTo = input}/>
      <Form.Input fluid label='Subject' type='text'ref={(input)=>this.getSubject = input}/>
      </Form>
<Button animated inverted color='blue'   id='sendBtn'>
  <Button.Content visible>Send</Button.Content>
        <Button.Content hidden>
          <Icon name='envelope'/>
        </Button.Content>
      </Button>
      <Button animated inverted color='red'><Button.Content visible>Discard</Button.Content>
        <Button.Content hidden>
          <Icon name='remove circle'/>
        </Button.Content>
      </Button>

                    </Modal.Content>
      </Modal>
    );
  }
}
export default Compose;

"In redux folder, reducer file:"
import actions from './actions';

const initialState = {

outboxMessage: []

}

const emailReducer = (state = initialState, action) => {
  switch (action.type) {
    case actions.OUTBOX_MESSAGE:
      return {
        ...state,
        outboxMessage: state.outboxMessage.concat([action.outboxMessage])
      };
      default:
        return state;
    }
  }

  export default emailReducer;

"In Index.js, mofidied in this way:"
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import { createStore } from 'redux';
import { Provider } from 'react-redux';

import emailReducer from './components/redux/reducer';
const store = createStore(emailReducer);
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>, document.getElementById('root'));

I'm getting error Like this:
Compose.handleSubmit [as onSubmit]
F:/compose/src/components/Email/Compose.js:14
  11 |
  12 | handleSubmit = (e) => {
  13 |   e.preventDefault();
> 14 |   const to = this.getTo.value;
     | ^  15 |   const cc =  this.getCc.value;
  16 |   const bcc = this.getBcc.value;
  17 |   const subject = this.getSubject.value;

A: You can make use of state, which is a cleaner way as well.
Maintain a state for all your input's.
state = {
  from: "",
  to: "",
  cc: "",
  bcc: "",
  subject: ""
}

Now you can have Controlled Component.
We need name, value and onChange properties on input.
<Form onSubmit={this.handleSubmit}>
      <Form.Input fluid label='From' type="text"  name="from" value={this.state.from} onChange={this.changeHandler}/>
      <Form.Input fluid label='To' type="text" name="to" value={this.state.to} onChange={this.changeHandler}/>
      <Form.Input fluid label='Cc' type="text" name="cc" value={this.state.cc} onChange={this.changeHandler}/>
      <Form.Input fluid label='Bcc' type="text"  name="bcc" value={this.state.bcc} onChange={this.changeHandler}/>
      <Form.Input fluid label='Subject' type='text' name="subject" value={this.state.subject} onChange={this.changeHandler}/>
</Form>

Now your change handler would be,
changeHandler = (e) => {
   this.setState({
      [e.target.name] : e.target.value
   })
}

And finally you can use values from state,
handleSubmit = (e) => {
    e.preventDefault();
    console.log("button triggered")

    //Get the values from state
    const From = this.state.from;
    const To =  this.state.to;
    const Subject = this.state.subject;

    const outboxMessage = {
      From,
      To,
      Subject
    }
   console.log(outboxMessage)
}


text:
Q: OpenGL GL_TRIANGLE_STRIP; seemingly not getting the Z Coordinate to affect drawing I'm trying to draw a line using a GL_TRIANGLE_STRIP that will go deeper or more shallow with the z coordinate, but the the z value I'm passing into glVertex3f() doesn't seem to affect the perceived width.  In the code below (a modified example from OpenGL Programming Guide), the line should start closer to the perspective (larger), and get farther (smaller).
Would you point to my mistake, or a topic in which this it is addressed?
void init(void)
{
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_FLAT);
}
void display(void)
{
    GLdouble gran = 5.0;
    GLdouble width = 7.0;
    GLdouble theta = 1.047197551;
    GLdouble halfPi = 3.1459/2;
    GLdouble refpx = 50.0;
    GLdouble refpy = 50.0;
    GLdouble startr = 1.0;
    GLdouble startg = 1.0;
    GLdouble startb = .5;

    glClear(GL_COLOR_BUFFER_BIT);

    //glLoadIdentity();
    //glScalef(2.0, -.5,1.0);
    //glRotatef(45.0, 0.0, 0.0, 1.0);

    glBegin(GL_TRIANGLE_STRIP);

        for(int i = 0; i < 40; i++)
        {
            glColor3f(startr / i, startg / (20 - (i%20)), startb);

            GLdouble x1 = refpx + width*cos(theta + halfPi);
            GLdouble x2 = refpx + width*cos(theta + halfPi*3);
            GLdouble y1 = refpy + width*sin(theta + halfPi);
            GLdouble y2 = refpy + width*sin(theta + halfPi*3);

            glVertex3f(x1,y1, (GLdouble)i/40.0);
            glVertex3f(x2,y2, (GLdouble)i/40.0);

            refpx += gran*cos(theta);
            refpy += gran*sin(theta);
            if(i % 9 == 0) {
                theta += halfPi/8;
            }
            if(i == 20) {
                theta -= halfPi/2;
            }
            if(i == 5) {
                theta -= halfPi/2;
            }
        }
    glEnd();
    glDisable(GL_BLEND);
    glFlush();
}
void reshape(int w, int h)
{
    glViewport(0, 0, (GLsizei) w, (GLsizei) h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, (GLdouble) w, 0.0, (GLdouble) h, -1.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(450, 450);
    glutInitWindowPosition(100, 100);
    glutCreateWindow(argv[0]);
    init();
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutMainLoop();
    return 0;
}

A: You are setting the projection matrix to just an orthographic view. This means that changes in the distance from the camera will not affect the size of the object on the screen.
In a perspective projection far things are smaller, that is not true for an orthographic projection.
So in your vertex calculations the Z coordinate is controlled by i, but not the X and Y, they are only controlled by the trigonometry, and in particular, while refpx and refpy change, the size of the object in the XY plane never does (because the only variation is a sin or cosine term added to the refpx and refpy values).
So that's why: it can't vary, because you've got nothing in the math that calculates X and Y coordinates that varies the size by distance. On its own Z will make no difference to the size on screen unless you set a perspective transform in the projection matrix. Use gluPerspective for ease, or assemble your own camera matrix, the math is here: http://en.wikipedia.org/wiki/3D_projection#Perspective_projection


text:
Q: Spring-integration / ActiveMQ subscribe to multiple destinations in a single thread I am using multiple <si:service-activator>'s and <jms:message-driven-channel-adapter>'s to subscribe to multiple queues and topics. Messages from each destination are received in a separate thread, which means that my receiving code is full of locks to guard the mutable internal state.
I would like my receiving code to be lock free. Is it possible to configure spring-integration/activemq to receive from multiple destinations on the same thread?
If this is not possible, I can think of two alternatives:

*

*Start my own processing thread which reads from a blocking queue, put all received messages on this queue.

*Dispatch all received messages onto a single destination and consume from this.
Anyone have any better ideas?

A: Use the wildcard pattern on a single queue.
That is, instead of reading from two queues, use one queue and specify all queues you want to read from in the name.
that is: "QUEUE.NR1,QUEUE.NR2" or "SOME.PREFIX.>" to read all queues with that prefix. Your client code handle this as a single queue.


text:
Q: Spark Shell unable to read file at valid path I am trying to read a file in Spark Shell that comes with CentOS distribution of Cloudera on my local machine. Following are the commands I have entered in Spark Shell.
spark-shell
val fileData = sc.textFile("hdfs://user/home/cloudera/cm_api.py");
fileData.count

I also tried this statment for reading file:
val fileData = sc.textFile("user/home/cloudera/cm_api.py");

However I am getting
org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: hdfs://quickstart.cloudera:8020/user/cloudera/user/cloudera/cm_api.py

I haven't changed any settings or configurations. What am I doing wrong?

A: You are missing the leading slash in your url, so the path is relative. To make it absolute, use
val fileData = sc.textFile("hdfs:///user/home/cloudera/cm_api.py")

or
val fileData = sc.textFile("/user/home/cloudera/cm_api.py")

A: I think you need to put the file in hdfs first: hadoop fs -put, then check the file: hadoop fs -ls, then go spark-shell  , val fileData = sc.textFile("cm_api.py")

A: In "hdfs://user/home/cloudera/cm_api.py", you are missing the hostname of the URI. You should have pass something like "hdfs://<host>:<port>/user/home/cloudera/cm_api.py", where <host> is Hadoop NameNode host and the <port> is, well, port number of Hadoop NameNode, which is 50070 by default.

A: The error message says hdfs://quickstart.cloudera:8020/user/cloudera/user/cloudera/cm_api.py does not exist. The path looks suspicious! The file you mean is probably at hdfs://quickstart.cloudera:8020/user/cloudera/cm_api.py.
If it is, you can access it by using that full path. Or, if the default file system is configured as hdfs://quickstart.cloudera:8020/user/cloudera/, you can use simply cm_api.py.

A: You may be confused between HDFS file paths and local file paths.  By specifying
hdfs://quickstart.cloudera:8020/user/home/cloudera/cm_api.py

you are saying two things:
1) there is a computer by the name "quickstart.cloudera' reachable via the network (try ping to ensure that is the case), and it is running HDFS.
2) the HDFS file system contains a file at /user/home/cloudera/cm_api.py  (try 'hdfs dfs -ls /user/home/cloudera/' to verify this
If you are trying to access a file on the local file system you have to use a different URI:
file:///user/home/cloudera/cm_api.py


text:
Q: Can't get Grpc-net client to log to Serilog file No log file is created.  What's wrong with this code?  .Net Framework 4.8.
var log = new LoggerConfiguration()
        .WriteTo.File(@"d:\temp\mdlogfile.txt", rollingInterval: RollingInterval.Day)
        .CreateLogger();
//log.Information("Here I am, logging.");  // this works
var lf = LoggerFactory.Create(builder =>
          builder.AddSerilog(log).SetMinimumLevel(LogLevel.Trace));
var handler = new HttpClientHandler();
var grpcChannel = GrpcChannel.ForAddress(GrpcUrl,
         new GrpcChannelOptions {
            HttpHandler = new GrpcWebHandler(handler),
            LoggerFactory = lf
         });


text:
Q: Sum the infinite series $ \sum_{n=0}^\infty (2n^7 + n^6 + n^5 + 2n^2)/n! $ What is
$$ \sum_{n=0}^\infty \frac{2n^7 + n^6 + n^5 + 2n^2}{n!} $$

A: From Dobiński's formula, $\sum \limits_{n=0}^\infty \frac{n^k}{n!} = eB_k$, where $B_k$ is the $k$th Bell number, the number of set partitions of a set of size $k$..
So the answer is $e(2B_7 + B_6 + B_5 + 2B_2) = e(2 \times 877 + 203 + 52 + 2 \times 2) = 2013e$.

A: Here's a hint.  $$\sum_{n=0}^{\infty} \frac{n^k}{n!}=e B_k$$ where $B_k$ is the $k$-th Bell number (see Dobiński's formula for a proof).

A: You have that if:
$$
A(z) = \sum_{n \ge 0} a_n z^n
$$
then:
$$
z \frac{\mathrm{d}}{\mathrm{d} z} A(z) = \sum_{n \ge 0} n a_n z^n
$$
In general, using $\mathrm{D}$ for the differentiation operator, and $p$ a polyomial:
$$
\sum_{n \ge 0} p(n) a_n z^n = p(z \mathrm{D}) A(z)
$$
So you are looking for:
$$
(2 (z \mathrm{D})^7 + (z \mathrm{D})^6 + (z \mathrm{D})^5 + 2 (z \mathrm{D})^2)
  \mathrm{e}^z
$$
at $z = 1$.


text:
Q: Apollo Typescript Argument Type is not assignable to parameter type MutationFunctionOptions I'm fairly new to using Typescript, so please be kind, but I want to get this working. I'm using Apollo's useMutation which works fine, but Im getting a Typescript error when passing the variables:
"Argument Type {variables: {input: any}} is not assignable to parameter type MutationFunctionOptions"

From googling I've tried importing QueryFunctionOptions, MutationFunctionOptions, OperationVariables from @apollo/client and using them in various ways, but I cannot find how I'm supposed to use them.
Any help appreciated!
const [mutateFunction, { data, loading, error }] = useMutation(SET_ORDER_SHIIPING_ADDRESS);

const onSubmit = async (data) => {
    const response = await mutateFunction({
        variables: {
            input: {
              test: "123"
            }
        }
    });
    console.log(response)
};

A: Did you set up the graphql in TypeScript with tool like GraphQL Code Generator. You can check the official documentation https://www.apollographql.com/docs/react/development-testing/static-typing/


text:
Q: Where is the default cache path for cefsharp (chromiumwebbrowser)? I am using cefsharp's chromiumwebbrowser, and I want to test it separately with and without cache.
So I'm trying to test while deleting the cache in the path, but I can't figure out the default path.
Is there a default cache path of chromiumwebbrowser or a method to delete the cache?


text:
Q: Power requirements for this build enough? I am currently in the process of building a series of desktop base units to act as a cluster (running Linux). It will be running 24/7 mostly so i need something that lasts.
Here are the specs:

*

*CPU: Quad core AMD fx4100.

*RAM: 16GB (4GB per core)

*GPU: not required (i.e. any card that can output to HDMI - 50 W power usage maybe?)

*HDD: 500 GB

*Cooling:3x200mm fans.

Since I will need a certain number of the above, it would be great if somebody can advise me on the specs. I have used AMD for a while; will Intel be better for this?
My budget is about 300-400£ per node (i don't need a case); I'd like to know if this can be obtained for cheaper.
I haven't decided on the number of nodes, but I do not want to be limited by the PSU. I am considering the Corsair series (Corsair CMPSU-800GUK Gaming Series GS800 High Performance 800W Power Supply): is this a good choice?
How else can I bring the cost of this system down? The nodes will be connected via Ethernet.

A: While i can't advise with any certainty on machine specs for the use you intend, i can however recommend a great little tool that i use when assessing power requirements for a system build:
http://extreme.outervision.com/psucalculatorlite.jsp
Just plug your hardware in and it will give you a relatively accurate ESTIMATE of the power requirement needed to run said spec.
Hope that helps to answer at least one part of your question!

A: While my comments are additional to those by Dean and others, I'd like to bring up a point or two which is important enough to merit it an answer.
First of all, I agree with Lil' Smokey; 800W is probably much more than you need. My rig is about the same as yours above, WITH a medium/high performance GPU (Radeon HD 6670), and I run 200W when under full load. I have a 470W PSU and have NO problems at all.
So for Wattage, that PSU calculator is your best bet. If I had to make an educated guess, I'd say the 500W range should be enough for you, given my experience above.
The important part:
Your PSU should be 80 Plus Certified! This makes things run cooler (less heat produced by the PSU), and could lower your electricity bill (given a high power factor). The higher the certification (Bronze through Titanium) the better.
The 80 Plus article above also makes a good point about choosing a PSU of the "appropriate" Wattage for your setup.
Take the following example (roughly from the Wikipedia article above):
Say you have a 500W PSU. 80 Plus certification guarantees you that the PSU is at least 80% efficient at 20% or higher load.
20% * 500W = 100W. So your 500W PSU is only guaranteed 80% efficiency at 100+ Watts.
If your PC idles around 60-70W (very likely for most setups, including yours), it doesn't mean you're getting that 80% efficiency. The higher Wattage your PSU is, the larger this range between idle and 20% becomes, decreasing idle power efficiency.
Moral of the story: It's not always best to say "Screw it, I'll get a 1200W PSU! Go big or go home!!1!11" Choose wisely, and choose as low as you think you can get away with.
Good luck!


text:
Q: Multiuser chatting program using RMI I'm working on an RMI chatting application, and one of its features is to allow the user to chat with more than one friend at the same time.
My approach to design these scenario is as follows: there will be an object bind to the registry, any user(client) wants to log in to the application will call a log in method on that object which returns a session object, so every user log in to the application will gain a session object if successfully logged in.
These session objects contain a list of Chat Room objects, which will be used to open a conversation pipe between 2 or more users.  The chat room object would contains a method that allows the user to add any number of members to a chat room.
This is my approach.  If anyone sees something not suitable, or has another approach which is better, please let me know.


text:
Q: Is it possible to mix AMD and CommonJS modules within same Typescript project I'm trying to integrate Durandal with node.js server using Typescript for defining modules both on server and client side.
The problem I've encountered is that Durandal is strongly dependent on RequireJS and AMD style of defining modules that I would like not to introduce on the server side, and since it uses RequireJS I don't have any chance to run CommonJS-ish modules on the client (default for node.js).
The final nail in the coffin is that I found no way of defining which files should be compiled as AMD modules and which one as CommonJS by tsc - it seems like a simplest solution.
I don't think separating client part and server part is an option, since a lot of code will be common to both parts.
So, my question is threefold:

*

*is there a way to mix AMD and CommonJS modules in the same Typescript project (preferably using NodejsTools)

*if not, is there a way to force Durandal to work with CommonJS files to load views/viewmodels and so on

*if none of this is possible is it possible (and wise) to use AMD modules on node.js server
Any ideas are highly appreciated

A:
is there a way to mix AMD and CommonJS modules in the same Typescript project (preferably using NodejsTools)

Yes. Use grunt-ts. See https://github.com/basarat/demo-fullstack/tree/master/src specifically the gruntfile common files : https://github.com/basarat/demo-fullstack/blob/master/src/Gruntfile.js#L4-L6 commonjs : https://github.com/basarat/demo-fullstack/blob/master/src/Gruntfile.js#L26 amd : https://github.com/basarat/demo-fullstack/blob/master/src/Gruntfile.js#L37

A: This is more of a long comment than an answer
I've been looking at the same problem, and I did try grunt-ts ,gulp-ts, Webstorm file watchers, cmd line scripts , Everything but Visual Studio as I 'm  afraid  to   rely on the IDE for the build process (Webstorm watchers are an exception as  its the same as a grunt or any other watcher, easy to replicate ,  and its just handy to try configurations);
I'm currently using internal modules but compiling only  the 'exporting' modules  with file filters (extension based ,is the cleaner)
and tsc load the chain when they are referenced ;
I have different output targets based on what I'm trying to achieve, as in node, browser, angular, testing, mocha, jasmine, etc...
like in:
/MyModule
myModule.ts
myModule.d.ts
myModule.mdl.ts (exports amd)
myModule.export.ts (exports commonjs)
myModule.test.ts (exports mocha test, no KARMA!)
etc...

not relying on  Ts ' export module' ability
It works but ...
But I'm not  100% happy , to many files .... it smells ... too many targets
Gruntfile is difficult to read(too big) , I need to remember or document how it works  until I got the time to fully automate it (if reasonably possible)
I think the  options below make more sense on DRY  and KISS sense
but I'm also not 100% sold on the boilerplate needed.
Typescript modules should be templatable  so when they compile the module could have  the 'shape' I want without to rely on  extra build steps
Some Options to don't need to compile multiple targets , or file duplication
UMD (Universal Module Definition)
Browserify
amdefine
RequireJs in Node
Requirejs LOADING MODULES FROM COMMONJS PACKAGES

A: It should be possible to mix require based AMD files and common js.  Your html page would then include scripts similar to the following:
<script src="/tscode_common/common_js_file.js"></script>
<script data-main="/tscode_amd/tscode_amd_config.js" type="text/javascript" src="lib/require.js"></script>

But a specific TypeScript project can only be AMD or common js - as the compiler options are per project.
A solution to this issue may be to nest TypeScript sub-projects (.prj) in sub-directories of your main web application something like the following:
+- / (base directory for web application )
+- /main_app.prj ( main web app project file )
+- index.html
+- /tscode_common/ ( put all common js files here )
+- /tscode_common/common_js.prj ( project file with commonjs options)
+- /tscode_common/common_js_file.ts (common ts files )
+- /tscode_amd/ ( put all amd files here )
+- /tscode_amd/amd_js.prj ( project file with amd options )
+- /tscode_amd/tscode_amd_config.ts ( require config file )
+- /tscode_amd/amd_js_file.ts ( amd ts files )

A: Just create 2 copies of *.njsproj file. One copy for the server and one for the client side code. In the  client project only keep public and view (exclude everything related to the server). Keep only what relates to the server in the server-side project. Make sure the client's project has AMD and the server's has CommonJs. Enjoy!


text:
Q: How to send outer variable to a vue component I have a Vue Component called send-sms-btn which is next to an input tag like below :
<input v-model="number" placeholder="enter your phone number..." >
<send-sms-btn></send-sms-btn>

As you can see when user enters the phone number in the input it saves in to a data called number, but how can I pass this data to my send-sms-btn component?

A: you can use props in this case
<send-sms-btn :enteredNumber="number"></send-sms-btn>

and inside your send-sms component you can receieve it in the props section like
props: ['enteredNumber']

A: You could pass it as prop like :
<input v-model="number" placeholder="enter your phone number..." >
<send-sms-btn :number="number" ></send-sms-btn>

and send-sms-btn component should define that prop :
export default{
  name:'send-sms-btn',
  props:['number']


text:
Q: Read and write file from Azure Data Lake Storage Gen2 in python AS per Microsoft documents:
Connect to Azure Data Lake Storage Gen2 by using an account key:
def initialize_storage_account(storage_account_name, storage_account_key):

    try:
        global service_client

        service_client = DataLakeServiceClient(account_url="{}://{}.dfs.core.windows.net".format(
            "https", storage_account_name), credential=storage_account_key)

    except Exception as e:
        print(e)

Upload a file to a directory:
def upload_file_to_directory():
    try:
        file_system_client = service_client.get_file_system_client(file_system="my-file-system")

        directory_client = file_system_client.get_directory_client("my-directory/filter")

        file_client = directory_client.create_file("my_csv_write.csv")
        local_file = open("C:\\Users\\my_csv_read.csv",'r')

        file_contents = local_file.read()

        file_client.append_data(data=file_contents, offset=0, length=len(file_contents))

        file_client.flush_data(len(file_contents))
        print("File uploaded")

    except Exception as e:
      print(e)

I can upload file from my local to azure storage with this function, and it works.
but what I want to do is Read file from azure storage and write in azure storage.
What I did
def read_and_write_to_directory():
    try:
        file_system_client = service_client.get_file_system_client(file_system="my-file-system")

        directory_client_read = file_system_client.get_directory_client("my-directory")
        directory_client_write = file_system_client.get_directory_client("my-directory/filter")

        file_client_read = directory_client_read.get_file_client("my_csv_read.csv")
        file_path = open(file_client_read,'r')
        file_contents = file_path.read()

        file_client_write = directory_client_write.create_file("my_csv_write.csv")
        file_client_write.append_data(file_contents, overwrite=True)

    except Exception as e:
        print(e)

But it does not work,
error
expected str, bytes or os.PathLike object, not DataLakeFileClient

So What is the correct way to read file from azure lake storage and write in azure lake storage?

A: It's probably a little late, but I stumbled onto this while looking for a different issue.
I think you need to read the file content and then write that, as described here, and write it, as described here
So your code would look like this:
def read_and_write_to_directory():
try:
    file_system_client = service_client.get_file_system_client(file_system="my-file-system")

    directory_client_read = file_system_client.get_directory_client("my-directory")
    directory_client_write = file_system_client.get_directory_client("my-directory/filter")

    file_client_read = directory_client_read.get_file_client("my_csv_read.csv")
    #file_path = open(file_client_read,'r')
    #file_contents = file_path.read()

    download = file_client_read.download_file()
    downloaded_bytes = download.readall()

    file_client_write = directory_client_write.create_file("my_csv_write.csv")
    #file_client_write.append_data(file_contents, overwrite=True)
    file_client_write.append_data(downloaded_bytes, overwrite=True)

except Exception as e:
    print(e)


text:
Q: Range auto send in email body Is there any code to send a range in an email body if a certain time in a range is exceeded. This should be automated and not a button.

A: In order to get the email-sending sub to run at a set time every day, the easiest thing to do is to use the OnTime-method. In your case, you would put something like this in the ThisWorkbook-module:
Private Sub Workbook_Open()
  Call new_timer
End Sub

and something like this in a standard module:
Sub email_sending_macro
  <your code to send the email>
  Application.Wait(Now + TimeValue("0:00:01"))
  Call new_timer
End Sub

Sub new_timer
  Application.OnTime TimeValue("16:00:00"), "email_sending_macro"
End Sub

This should set your code to run at 4 o'clock every day. The Application.Wait is there just in case the macro takes less than a second to run, you do not want it to send more than one email, do you? :)