text:
Q: Recreate WebApi code from .NET in .NET Core Framework I have this web API code in .NET framework that I want to recreate in .NET Core 3.1. As you can see I have 3 routes: Overview, GetMenu & SubMenu. I want to just implement those 3 in .NET Core 3.1 Visual Studio 2019. Kindly help.
    [HttpGet]
    [JWTAuthenticate]
    [CustomAttribute]
    [LogInfo]
    [LogException]
    [Route("Overview")]
    public string GetAccount()
    {
        return "Hello this is a sample api";
    }

    [HttpGet]
    [JWTAuthenticate]
    [CustomAttribute]
    [LogInfo]
    [LogException]
    [Route("GetMenu")]
    public ResponseStatus GetMainMenuSubmenu()
    {
        ResponseStatus objResponseStatus = new ResponseStatus();
        JObject obj = new JObject();
        MenuResponseModel objMMSMModel = new MenuResponseModel();
        string allowedMenus = "";
        try
        {
            allowedMenus = CommonUtility.GetConfigValue("AllowedMenuIDs");
            MainMenuViewModel objMainMenuViewModel = LoginBizModel.GetMainMenuSubmenu(Convert.ToString(System.Web.HttpContext.Current.Items["emailID"]));
            if (objMainMenuViewModel != null && objMainMenuViewModel.MainMenuDetails != null && objMainMenuViewModel.MainMenuDetails.Count > 0)
            {
                objMMSMModel.CustomerName = Convert.ToString(System.Web.HttpContext.Current.Items["CustomerName"]);
                objMMSMModel.UserName = Convert.ToString(System.Web.HttpContext.Current.Items["userName"]);
                objMMSMModel.emailID = Convert.ToString(System.Web.HttpContext.Current.Items["emailID"]);
                objMMSMModel.roleName = Convert.ToString(System.Web.HttpContext.Current.Items["RoleName"]);

                objMMSMModel.MenuDetails = new List<MenuSubMenuModel>();

                //Expose menu(s) only that are given in webconfig
                objMainMenuViewModel.MainMenuDetails = objMainMenuViewModel.MainMenuDetails.Where(x => allowedMenus.Contains(x.MainMenuName)).ToList();
                foreach (MenuModel mm in objMainMenuViewModel.MainMenuDetails)
                {
                    MenuSubMenuModel menu = new MenuSubMenuModel();
                    menu.MainMenuName = mm.MainMenuName;
                    menu.SubMenuName = mm.SubMenuName;
                    menu.SubMenuId = mm.SubMenuId;
                    objMMSMModel.MenuDetails.Add(menu);
                }
            }

            objResponseStatus = ResponseStatus.SetResponseStatus(objResponseStatus, 0, 1000, Constants.Success, objMMSMModel);
        }
        catch (Exception ex)
        {
            Common.LogError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex, new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileLineNumber());
            ResponseStatus.SetExceptionResponseStatus(objResponseStatus, ex);
        }
        return objResponseStatus;
    }

A: As far as I know, if you want to convert the asp.net web api to asp.net core web api, you could refer to below steps:
1.[HttpGet]:asp.net core also contains [HttpGet], there is no need to modify.
2.[JWTAuthenticate]: asp.net core has a new feature called schemem, if you want to use jwtAuthenticate, more details, you could refer to this article.
3.[CustomAttribute] asp.net core also contains custom attribute, you could move the custom attribute to asp.net core.
4.[LogInfo][LogException], if you want to use log in asp.net core, you should use DI to inject the loggder in the controller, and use it. Details, you could refer to this article.
5.[Route("Overview")], asp.net core also contains routes, there is no need to modify it.

*There is no change to this api method.
public string GetAccount()
{
return "Hello this is a sample api";
}
7.Asp.net core and asp.net are not contain ResponseStatus type in web api, it seems you have create a new response, you could install that Nugetpackage in asp.net core. For the code part, there is no change for the C#.
    public ResponseStatus GetMainMenuSubmenu()
    {
        ResponseStatus objResponseStatus = new ResponseStatus();
        JObject obj = new JObject();
        MenuResponseModel objMMSMModel = new MenuResponseModel();
        string allowedMenus = "";
        try
        {
            allowedMenus = CommonUtility.GetConfigValue("AllowedMenuIDs");
            MainMenuViewModel objMainMenuViewModel = LoginBizModel.GetMainMenuSubmenu(Convert.ToString(System.Web.HttpContext.Current.Items["emailID"]));
            if (objMainMenuViewModel != null && objMainMenuViewModel.MainMenuDetails != null && objMainMenuViewModel.MainMenuDetails.Count > 0)
            {
                objMMSMModel.CustomerName = Convert.ToString(System.Web.HttpContext.Current.Items["CustomerName"]);
                objMMSMModel.UserName = Convert.ToString(System.Web.HttpContext.Current.Items["userName"]);
                objMMSMModel.emailID = Convert.ToString(System.Web.HttpContext.Current.Items["emailID"]);
                objMMSMModel.roleName = Convert.ToString(System.Web.HttpContext.Current.Items["RoleName"]);

                objMMSMModel.MenuDetails = new List<MenuSubMenuModel>();

                //Expose menu(s) only that are given in webconfig
                objMainMenuViewModel.MainMenuDetails = objMainMenuViewModel.MainMenuDetails.Where(x => allowedMenus.Contains(x.MainMenuName)).ToList();
                foreach (MenuModel mm in objMainMenuViewModel.MainMenuDetails)
                {
                    MenuSubMenuModel menu = new MenuSubMenuModel();
                    menu.MainMenuName = mm.MainMenuName;
                    menu.SubMenuName = mm.SubMenuName;
                    menu.SubMenuId = mm.SubMenuId;
                    objMMSMModel.MenuDetails.Add(menu);
                }
            }

            objResponseStatus = ResponseStatus.SetResponseStatus(objResponseStatus, 0, 1000, Constants.Success, objMMSMModel);
        }
        catch (Exception ex)
        {
            Common.LogError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex, new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileLineNumber());
            ResponseStatus.SetExceptionResponseStatus(objResponseStatus, ex);
        }
        return objResponseStatus;
    }


text:
Q: Optimize Product of Linear Equations Given a $3 \times 6$ coefficient matrix $A$, I want to find vector $X \in R^{3}$ to maximize the following function:
$$ \prod_{i,j,k \in [1, 6]} (1 + A_{1i}X_{1} + A_{2j}X_{2} + A_{3k}X_{3}),$$
$$ \text{with constraints:}\;\;\; X_{i} \ge 0, \sum X_{i} \le 1.$$
Basically, given $6$ coefficients for each of the $3$ variables, I want to maximize the product of the $216$ linear equations formed by taking any combination of the coefficients.
Note that there are no constraints on the matrix $A$.
It would be equally helpful if you could provide a MATLAB/Python code using which I could find the maximum.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Writing junits in Test Driven Development before writing actual code? Folks it is always said in TDD that

we should write junits even before we write the actual code.

Somehow I am not able to understand this in right spirit. I hope what it means is that you just write empty methods wih right signatures and your test case is expected to fail initially
Say in TDD approach i need to get the list of customers.
As per my understanding i will write the empty method like below
public List<CustomerData> getCustomers(int custId){

return null;
}

Now i will write junit test case where i will check the size as 10(that i am eactually expecting). Is this Right?
Basically my question is in TDD, How we can write junit test case before writing actual code?

A: Often you'll write the test alongside the skeleton of the code. Initially you can write a non-functional implementation (e.g. throw an UnsupportedOperationException) and that will trigger a test failure. Then you'd flesh out the implementation until finally your test passes.
You need to be pragmatic about this. Obviously you can't compile your test until at least your unit under test compiles, and so you have to do a minimal amount of implementation work alongside your test.
Check out this recent Dr Dobbs editoral, which discusses exactly this point and the role of pragmatism around this, especially by the mavens of this practise (Kent Beck et al)

A key principle of TDD is that you write no code without first writing
  a failing unit test. But in fact, if you talk to the principal
  advocates of TDD (such as Kent Beck, who popularized the technique,
  and Bob Martin, who has taught it to thousands of developers), you
  find that both of them write some code without writing tests first.
  They do not — I should emphasize this — view these moments as lapses
  of faith, but rather as the necessary pragmatism of the intelligent
  developer.

A:
I hope what it means is that you just write empty methods wih right signatures

Yes. And with most modern IDEs, if you write a method name which does not exist in your test, they will create a stub for you.

Say in TDD approach i need to get the list of customers. whats the right way to proceed?

Your example is not quite there. You want to test for a 0-length array, but you already return it: you should first return null, the test will obviously fail.
Then modify the method so that the test succeeds.
Then create a test method for customer add. Test fails. Fix it. Rinse. Repeat.
So, basically: with TDD, you start and write test that you KNOW will fail, and then fix your code so that they work.
Recommended read.

A: That's partly right.
Using an IDE (Eclipse, IntelliJ) you can create a test. In that test invoke a method (that does not exist) and using a refactoring tool create a method with the proper signature.
That's a trick that makes working with TDD easier and more fun.
According to Now i will write junit test case where i will check the size as 0. Is this Right? you should write a test that fails, and the provide proper implementation.

A: I think go write the test first, Think about the signature of the function while writing the test.
It's the same as writing the signature and then writing the test, But when inventing the signature of the function while writing the test will be helpful since you will have all information about the responsibility of the function and you will be able to come up with the proper signature.


text:
Q: Чем плоха авторизация через htaccess? Есть простенькая страница с админкой, авторизация в админку сделана через htaccess и htpasswd.
Поясните, пожалуйста, чем плохая такая авторизация?
Опыта php разработки не много.

A: Это небезопасно: username / password передаются открытым текстом с каждым запросом. С https это не большая проблема, но у вас, скорее всего, сайт открывается только по незащищённому протоколу http?

A: Чтобы добавить админа, удалить админа или  сменить пароль, придётся редактировать .htpasswd каждый раз.

A: Если у вас одностраничник, то это хорошый вариант. Так как никто не будет замарачиваться с однастраничником который не принесет ни какой выгоды. Только про бэкапы не забывайте.


text:
Q: How do I check if a tkinter window is minimized? How do I check if the tkinter window is minimized?
Something like this:
from tkinter import *
def check_if_window_minimized():
    if root.minimized:
        print("True")
    else:
        print("False")
root = Tk()
while True:
    check_if_window_minimized()
root.mainloop()

How do I do this?

A: try this code:
from tkinter import *

root=Tk()

if root.state()=="iconic":
    print("minimized")

root.mainloop()

root.state() can show your window status.


text:
Q: Datastax DevCenter freezes on startup Just installed (copied over the app from the downloaded dmg) DevCenter 1.6 on my mac, running macOs Sierra 10.12.6 with jdk 8u152 installed. The application loads a UI (splash screen then a couple of checkboxes in a window for getting started) but the UI is frozen (with the splash screen still there). No response to mouse clicks or keyboard. Also can't click on the app name in the menu bar. The app however is not labeled "Not responding" by activity monitor.
So far I've tried -

*

*Looking at the logs both in the app folder and in ~/.devcenter. Nothing fishy there

*Running the app from a different user account - same issue there

*Deleting all datastax and devcenter related files (searched by name) on my machine and fresh start - still the same issue

any ideas what I could do here?
I was running DevCenter on a previous mac with the same config / os version but a slightly older JDK, never had issues then.

A: On OSX, you can specify which version of Java DevCenter uses so that you do not need to downgrade your global Java version.

*

*Right-click on Devcenter.app

*Click "show package contents"

*Open Contents/info.plist

*At the bottom of the file, there's an Eclipse key with lines commented out explaining how to specify the version of Java.  Uncomment the line and specify the version of Java that you want DevCenter to use.

*Save & Re-launch DevCenter

The updated info.plist file should look something like this:
<key>Eclipse</key>

    <array>
            <string>-vm</string><string>/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java</string>
    </array>

A: I reached out to someone at Datastax and learnt that complaints have surfaced about this behavior when using DevCenter with jdk 8u152.
For now, I've downgraded to jdk 8u151 and that fixes the issue.

A:
Without downgrade the Java version

Scenario
I couldn't create any connection and press buttons and everything was frozen; Changing the swt plugin in the DevCenter plugin folder worked. This was my configuration:

*

*DevCenter version DevCenter-1.6.0-macosx-x86_64

*Mac OSX version 10.14.6

*JDK Version jdk1.8.0_231.jdk
Steps to fix it

*

*From here download the version 3.108.0. (This version works for me)

*Rename the file downloaded as swt.jar (short name)

*[Optionally] create a backup of the current swt plugin jar of the DevCenter
cp DevCenter/DevCenter.app/plugins/org.eclipse.swt.cocoa.macosx.x86_64_3.103.2.v20150203-1351.jar ~/Desktop

*Replace the plugin with the swt.jar downloaded

mv swt.jar DevCenter/DevCenter.app/plugins/org.eclipse.swt.cocoa.macosx.x86_64_3.103.2.v20150203-1351.jar

*Startup DevCenter

Finally it worked


text:
Q: How to update Antd's Form Item Input values & content based on a state variable? I've been trying to implement the Google Places API to autofill the fields of a simple address form with Antd, but so far, after have chosen a place, the fields won't populate the way I want.
I am using the package react-google-autocomplete successfully to get what I want.
To test things, I have been focusing on just using 1 field, the city one.
Right now, my form is decomposed in 2 elements.
NewForm.tsx
const NewForm = (props: Props) => {
const [form] = Form.useForm();

const formRef = useRef<any>(null);

const onFinish = async (values: any) => {
    const newAddressData: NewAddressInput = {
        name: values.name?.toUpperCase(),
        company: values.company?.toUpperCase(),
        street1: values.street1.toUpperCase(),
        street2: values.street2?.toUpperCase(),
        city: values.city.toUpperCase(),
        state: values.state.toUpperCase(),
        zip: values.zip.toUpperCase(),
        country: values.country.toUpperCase(),
        phone: values.phone,
        notes: values.notes,
    };
    const onFinishFailed = (errorInfo: any) => {
    console.log('Failed:', errorInfo);
    if (errorInfo.errorFields.length > 0) {
        errorInfo.errorFields.map((field: { errors: string[]; }, index: any) => {
            toast.error(field.errors[0] as string);
        });
    }
};

useEffect(() => {
    console.log('form values in useEffect', form.getFieldValue('city'));

}, [form]);

console.log('form values', form.getFieldValue('city'));

return (
    <Dashboard>
         <Form
            ref={formRef}
            form={form}
            name="newClientForm"
            labelCol={{ span: 3 }}
            wrapperCol={{ span: 22 }}
            initialValues={{ remember: true }}
            onFinish={onFinish}
            onFinishFailed={onFinishFailed}
            autoComplete="off"
            className={styles.createClientForm}
            layout="horizontal"
            onValuesChange={(changed, all) => console.log('values change', changed, all)}
            onFieldsChange={(first, second) => console.log('fields change', first, second)}
            fields={[
                {
                    name: 'city',
                    value: form.getFieldValue('city')
                }
            ]}
        >

Create a New Client

            <Divider />
            <CreateAddressFields />
            <Form.Item
                style={{ textAlign: 'center' }}
            // wrapperCol={{ offset: 4, span: 16 }}
            >
                <Button
                    type="primary"
                    htmlType="submit">
                    Submit
                </Button>
            </Form.Item>
        </Form>
    </Dashboard>
);
};

CreateAddressFields.tsx
function CreateAddressFields({ }: Props) {
const [foundAddress, setFoundAddress] = useState<NewAddressInput | null>(null);
const [city, setCity] = useState<string | null>(null);

const inputRef = useRef<any>(null);
const options = {
    componentRestrictions: { country: ["ca", "us"] },
    fields: ["address_components", "geometry", "icon", "name"],
    types: ["address"]
};
// inputRef.current.focus();

const { ref, autocompleteRef } = usePlacesWidget({
    apiKey: PLACES_API_KEY,
    onPlaceSelected: (place, inputRef, something) => {
        console.log('place selected', place);
        const address = place.address_components;
        let { street1, street2, city, state, zip, country }: NewAddressInput = {
            street1: '',
            street2: '',
            city: '',
            zip: '',
            state: '',
            country: ''
        };
        if (address) {
            console.log('going through found address');
            for (const component of address) {
                const type = component.types[0];
                switch (type) {
                    case "street_number":
                        street1 = `${component.long_name} ${street1}`;
                        break;
                    case "route": {
                        street1 += component.short_name;
                        break;
                    }

                    case "postal_code": {
                        zip = `${component.long_name}${zip}`;
                        break;
                    }

                    case "locality":
                        city = `${component.long_name}${city}`;
                        break;

                    case "administrative_area_level_1": {
                        state = `${component.short_name}${state}`;
                        break;
                    }

                    case "country":
                        country = `${component.short_name}${country}`;
                        break;

                    default:
                        break;
                }
            }
            setFoundAddress({ street1, street2, city, state, zip, country });
            console.log('results', { street1, street2, city, state, zip, country });
        }
    },
    options
});

const handleChange = (event: any) => {
    console.log('name', event.target.name);
    const name = event.target.name;
    console.log('value', event.target.value);
    const value = event.target.value;
    setFoundAddress({ ...foundAddress!, [event.target.name]: event.target.value });
    if (name === 'city') {
        setCity(value);
    }

};
return (
    <>
        <Form.Item
            label="Name: "
            name="name"
            rules={[{ required: true, message: 'Please input your name!' }]}>
            <Input
            // onChange={handleChange}
            />
        </Form.Item>
        <Form.Item
            label="Company: "
            name="company">
            <Input />
        </Form.Item>
        <Form.Item
            label="Street Info 1:"
            name="street1"
            rules={[{ required: true, message: 'Please input your street1!' }]}>
            <Input
                placeholder=''
                ref={(c) => {
                    inputRef.current = c;
                    if (c) ref.current = c.input;
                }}
            // ref={inputRef}
            />
        </Form.Item>
        <Form.Item
            label="Street Info 2:"
            name="street2">
            <Input />
        </Form.Item>
        <Form.Item
            label="City:"
            name="city"
            // initialValue={foundAddress?.city ? foundAddress.city : ''}
            // getValueFromEvent={handleChange}
            getValueProps={(v) => {
                return ({ name: 'city', value: v });
            }}
            rules={[{ required: true, message: 'Please input your city!' }]}>
            <Input
                onChange={handleChange}
                value={city!
                    // ? foundAddress.city : ''
                }
            // placeholder={foundAddress?.city}
            />
        </Form.Item>
        {/* <input
            name={"city"}
            value={foundAddress?.city}
            placeholder={"City"}
            onChange={handleChange}
        /> */}
        <Form.Item
            label="State:"
            name="state"
            rules={[{ required: true, message: 'Please input your state!' }]}>
            <Input />
        </Form.Item>
        <Form.Item
            label="Zip:"
            name="zip"
            rules={[{ required: true, message: 'Please input your zip!' }]}>
            <Input />
        </Form.Item>
        {/* {countriesList && ( */}
        <Form.Item
            label="Country:"
            name="country"
            rules={[{ required: true, message: 'Please choose your country!' }]}>
            <Input />
        </Form.Item>
        {/* )} */}
        <Form.Item
            label="Phone:"
            name="phone"
            rules={[{ required: true, message: 'Please input your phone number!' }]}>
            <Input />
        </Form.Item>
        <Form.Item
            label="Notes:"
            name="notes">
            <Input />
        </Form.Item>
    </>

The suggestion is triggered when typing in street1 field. Once a place is selected, it successfully sets the state variable foundAddress. But none of the other fields (in this test case, city) get populated with the selected value.
I've tried quite a few things:

*

*using the props of the Form.Item, such as initialValue, getValueFromEvent, getValueProps.

*adding the props on the Input component

*using the props of the Form component: onValuesChange, onFieldsChange, fields.

*creating a unique state variable for the city field.

The field never gets updated.
On the other hand, if I use a simple <input> instead, I tested and got the value showing when the state variable is populated.
Also, if I fill the placeholder of the <Input>as placeholder={foundAddress?.city}, it does work after selecting an address properly as expected.
What am I doing wrong in value handling with this Antd form?

A: Update form fields using form.setFieldValue("key", value)


text:
Q: Port forwarding in apache with additional parameter How can I forward all incoming requests on one port say 8000 to another port say 8081, & add a static parameter in all request url while forwarding so that I can check for that specific parameter in my script?

A: Try with below rules in your root htaccess,
RewriteEngine On
RewriteCond %{SERVER_PORT} ^8000$
RewriteRule ^$ http://%{HTTP_HOST}:8081%{REQUEST_URI}?param=value [QSA,L]


text:
Q: What is the lifetime of variables inside a self calling function in javascript I've been trying to understand the following code:
var add = (function () {
        var counter = 0;
        return function () {return counter += 1;}
    })();
    add();
    add();
    add();

Here add is assigned the return value of the anonymous self calling function -- that is the function function() { return counter += 1 }. Now the first time add() is called it returns 1 as expected. But the second time add() is called it returns 2.
My question is since counter is defined inside a function so wouldn't every time the function finishes execution counter should die? That is, after the first call to add() 1 will be displayed. Now we are out of that function so shouldn't counter forget it's previous value and be destroyed from the stack like automatic variables are?

A:
What is the lifetime of variables inside a self calling function in javascript

The same as variables in any other kind of JavaScript function: They exist for as long as they can be referenced, which sometimes means long past the time the function that contains them returns.
Your counter variable continues to exist after the IIFE returns because the function it creates and returns (return function () {return counter += 1;}) is a closure over the variable. The variable will exist as long as that function exists.
More technically: Calling a function creates something called an execution context for that call, which has a variable enviroment object. Any function created during the call receives a reference to that outer variable environment object; that object, like all objects, exists as long as there's a reference to it, and so the functions keep the object alive. Variables are actually properties of that variable environment object, and so they exist as long as something references the object they're on. (This is the very simplified form.) While in theory the entire variable environment object is kept, in practice JavaScript engines are free to optimize if the effects of optimization aren't observable, so a variable that isn't actually used by the closure may (or may not) be released, depending on the engine and the code in the function.
Your IIFE can only be called once, so there can only be one counter, but it's common for a function creating a closure to be called more than once, in which case you have multiple variable objects, and multiple copies of the variables that are closed over.
Example:

function helloBuilder(name) {
  var counter = 0;
  return function() {
    ++counter;
    display("Hi there, " + name + ", this is greeting #" + counter);
  };
}

var helloFred = helloBuilder("Fred");
var helloMaria = helloBuilder("Maria");

helloFred();  // "Hi there, Fred, this is greeting #1"
helloFred();  // "Hi there, Fred, this is greeting #2"
helloMaria(); // "Hi there, Maria, this is greeting #1"
helloMaria(); // "Hi there, Maria, this is greeting #2"
helloFred();  // "Hi there, Fred, this is greeting #3"

function display(msg) {
  var p = document.createElement('p');
  p.appendChild(document.createTextNode(msg));
  document.body.appendChild(p);
}

In the above, the function returned by helloBuilder closes over both its name argument and its counter variable. (Because arguments are also stored on the execution context's variable object.) So we can see that after calling it twice, there are two variable objects, each with its own name and counter, one referenced by each function we asked helloBuilder to create.


text:
Q: Reverse calculation depending on percentage and difference The below is a calculation variables and steps where it gives you a result of 89.47%
[Calculation Variables]

*

*Starting num: 19

*Ending num: 17

*Difference: 2

[Calculation Steps]

*

*19 - 2 = 17

*17 / 19 * 100 = 89.47%

[Question]
I want to know how to get the Starting num & Ending num if the result would yield 95.00% by only using any of the above numbers: 19, 17, 2, 89.47%. And the key point is that the Starting num and Ending num difference MUST be 2.
I know the answer for Starting num is 40 and Ending num is 38, which is the difference is 2. However, I want to know the formula for this reverse calculation.
Is this even possible? Thank you.


text:
Q: xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection I've tried various ways to coerce xterm (versions 285 and 292) to copy the selection to the CLIPBOARD clipboard whenever I press Ctrl-Shift-C.  The most promising way thus far has been, in ~/.Xresources, to put this:
XTerm*vt100.translations: #override \
    Ctrl Shift <KeyPress> C:  copy-selection(CLIPBOARD) \n\
    Ctrl Shift <KeyPress> V:  insert-selection(CLIPBOARD)

Ctrl-Shift-V works perfectly, but the copying has a nuance...
If I restart xterm, highlighting text puts things in the PRIMARY clipboard; this is expected, proper, default behavior.  If I hit Ctrl-Shift-C, it properly copies the current selection to CLIPBOARD clipboard.
The bug, however, is that if you highlight text after the first time you pressed Ctrl-Shift-C, you'll see that highlighting now copies to both PRIMARY and CLIPBOARD.  I cannot figure out how to stop xterm from updating CLIPBOARD upon selection... and it doesn't make sense to me that it would do it in the first place.
I said, at a specific point in time, to copy the selection to the clipboard... yet it just starts updating it automatically upon selection after doing it once...
Anyone have a workaround?

A: You might find Bug588785 interesting to read. A quick workaround would be to install and use xclipboard as seen in Comment 145.


text:
Q: Why can't I access this folder? A while back I bought a 1TB USB external drive. I formatted it ext4 in Ubuntu and copied a bunch of files / folders to it from several machines, all to /home/machinename/whatever, respectively.
At some point I ran a chmod -R shell command on it to change the permissions. That was months ago and I don't remember what I typed but it made the drive so I could only access its /home folder as root. This wasn't a problem because I could still access everything, but today I decided to try to fix it.
I went to my shell as root, went to that drive and typed:
chown -R rick:rick ./
chmod -R 666 ./

It seemed to work.  That home directory and everything else in it now shows up as rw for each:
rick@rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ ls -l
drw-rw-rw- 7 rick rick 4096 2012-03-04 13:08 home

So, if I try to access that directory with the shell, I get:
rick@rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ ls -l
drw-rw-rw- 7 rick rick 4096 2012-03-04 13:08 home
rick@rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ cd home
bash: cd: home: Permission denied
rick@rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ _

When I access it with nautilus I can see the multiple machine names within the /home/ folder, but they all appear with a file icon.  I can right-click on them and choose "Properties" but it won't let me see the permissions.
Am baffled.  Why can't I access that folder?  I'm the owner?  I'm even the group.  I have r/w privileges.  What am I doing wrong?

A: You're neither trying to read (list) nor write (create a new entry) the directory. You want to enter it, therefore you need (slightly misnamed in the case of directories) exexute permissions.


text:
Q: How to configure pm2 serve command to serve multi-page React app? I created a ReactJS application using Create-React-App, and wanted to deploy it on a Linux server. I followed a tutorial that showed how to do so very simply by installing pm2 and serve, then after running the command:
npm run build

I ran the command that actually hosted the application:
pm2 serve build

Now the problem is whenever I visit a url that is not the base one, or click reload from browser while I'm on a page other than home page, I get 404 not found error.
I understand the previous command is meant to serve a single page only. My question is: is there a way to make the url for example http://myserver:port/a go to Route a in my app? Or at least go to http://myserver:port/ ?
I already have Nginx installed on the same server, as I am using it to host a Flask Python app, but I'm very new to all this and I am looking for a simple way that works, as I faced some difficulties to get the Python app hosted.
Please note that I am only using React, no Redux, express, or any Database, if that is of any relevance. I am also using BrowserRouter inside my app.

A: pm2 serve has a Single-Page-Application Mode (https://pm2.keymetrics.io/docs/usage/expose/#serving-spa-redirect-all-to-indexhtml)
From the docs:

To automatically redirect all queries to the index.html use the --spa option:
pm2 serve build --spa

Or if using ecosystem.config.js file:
module.exports = {
  script: "serve",
  env: {
    PM2_SERVE_PATH: 'build',
    PM2_SERVE_PORT: 8080,
    PM2_SERVE_SPA: 'true',
    PM2_SERVE_HOMEPAGE: '/index.html'
  }
}

A: I use Vue.js, "npm run build" command generates static files into dist folder, the pm2 command looks like this:
pm2 --name <appName> serve --spa <staticFolder> <port>

A: pm2 serve build just serves build folder statically. So http://myserver:port/a will request file named 'a' in build folder. If it doesnt find it, it returns 404
To make ur server able to handle other routes, you cannot use pm2 serve. Instead you should start your flask server through pm2. You may take a look at How to run a python script like pm2 for nodejs


text:
Q: Unexpected token = import/no-named-as-default eslint error I create an AppBar component and I want to export the component in the App component.
src/components/appbar.jsx:
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
import LeftDrawer from './leftDrawer';

const styles = {
  root: {
    flexGrow: 1,
  },
  flex: {
    flexGrow: 1,
  },
  menuButton: {
    marginLeft: -12,
    marginRight: 20,
  },
};

class  ButtonAppBar extends React.Component {
  state = {
    left: false,
  }
  toggleDrawer = (side, open) => () => {
    this.setState({
      [side]: open,
    });
  };
  render() {
    const { classes } = this.props;
    return (

        <AppBar position="static">
          <Toolbar>
            <IconButton
              className={classes.menuButton}
              color="inherit"
              aria-label="Menu"
              onClick={this.toggleDrawer('left', true)}
            >
              <MenuIcon />
            </IconButton>
            <LeftDrawer
              open={this.state.left}
              toggleDrawer={this.toggleDrawer}
            />
          </Toolbar>
        </AppBar>

    );
  };
}

ButtonAppBar.propTypes = {
  classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(ButtonAppBar);

src/app.jsx:
import React from 'react';
import ButtonAppBar  from './components/appBar';

const App = () => (

    <ButtonAppBar />

        );

export default App;

.estlinrc.json:
{
"extends": [
    "airbnb", "prettier"
],
"env": {
    "browser": true
},
"rules": {
    "react/forbid-prop-types": "off"
  },
"settings": {
    "import/extensions": [".jsx", ".js"],
    "import/resolver": {
      "webpack": {
        "config": "webpack.config.js"
      }
    }
  }
}

.babelrc.json:
{
"presets": [
    "env",
    "react"
],
"plugins": ["transform-class-properties"]
}

package.json:
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"eslint": "^5.4.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.11.1",
"prettier": "^1.14.2",
"webpack": "^4.17.0",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5"

}
When I run the instruction:
./node_modules/.bin/eslint --ext .js,.jsx ./

I got this error:
Parse errors in imported module './components/appBar': Unexpected token = (24:9)  import/no-named-as-default

I found a similar question here How do I resolve eslint import/no-named-as-default and in the accepted answer it disable the rule import/no-named-as-default.
Is there any solution to keep this rule and update the code to not get this error?

A: Seems you're either not using babel-eslint as the parser, missing the babel-transform-class-properties plugin in your setup, or eslint is not configured to use it, or it's an older version of eslint.
Hope one of these is the culprit!


text:
Q: Setting up httpd.conf / mod_rewrite to redirect to codeigniter? I'm sorry to ask this here, as I'm sure the solution is fairly easy but for the life of my I can't setup httpd.conf on my localhost apache server to automatically load the codeigniter files.
Instead I'm having to go into the folder itself localhost/trunk/etc/etc until I get index.php - which messes with some of the relative paths (our backend coder is gone for the week so I can't ask him, but he has already setup the rewrite rules on our development server).
Can someone tell me how to setup httpd.conf and mod_rewrite on my local environment so going to http://localhost goes straight into codeigniter's index.php?

A: If you want to mess with httpd.conf, look for the Document Root line:
DocumentRoot "/path/to/CI/folder"
save it, and restart apache.
If you plan on changing httpd.conf MAKE A BACKUP OF IT FIRST. I've messed up many installs changing things around and regretted not backing up the file first :)
And you'll need to adjust the CI conf settings with path info etc. after changing httpd.conf


text:
Q: How to use Angular8 project inside my main angular project? I have one situation come where i have two projects one is in AngularJS which is main project and one is in angular 8. Now, i want to import Angular8 project inside angularJS Project.
Can any one suggest me better way for this?How can i overcome from this problem?

A: The only possible way to start using A8 components/services etc. in an existing AngularJS project is ngUpgrade. Here is a detailed step-by-step explanation.
With ngUpgrade module you can downgrade an existing Angular component
angular.module('heroApp', [])
  .directive(
    'componentNameInAngularJS',
    downgradeComponent({ component: ModernAngularComponent }) as angular.IDirectiveFactory
  );

But you probably (I'm not sure, it depends on existing code base) should give up A8 routing and let AngularJS control the flow, until you completely replace all AngularJS components with modern Angular. You should consider such an option, cuz` AngularJS official support ends in 2021.


text:
Q: Continuous relations? What might it mean for a relation $R\subset X\times Y$ to be continuous, where $X$ and $Y$ are topological spaces? In topology, category theory or in analysis? Is it possible, canonical, useful?
I have a vague idea of the possibility of using continuous relations in science, for example in biochemistry or celestial mechanics, as a less deterministic approach.
I have never seen anything about this topic on internet. I have an opinion of my own, but would like to hear what professional mathematicians think about it.

Can it be adequately defined? And if so, would it possibly be of any
  use at all?

Conditions on the definition:

*

*Composition of continuous relations should be continuous.

*Partial functions, continuous on its domain, should be continuous.

*Given a partial function $f:X\times Y \rightarrow Z$ that is continuous on its domain,
then $R=\{(x,y)\in X\times Y|f(x,y)=z_0\}$ should be a continuous relation.

A: Here's a different and quite generic approach: Let $X,Y$ be topological spaces. Then we topologize $\mathcal{P}(Y)$ and say that $R\subseteq X\times Y$ is continuous if and only if the function $f_R: X \to \mathcal{P}(Y)$ defined by $x\mapsto \{y\in Y: (x,y) \in R\}$ is continuous.
As for topologizing $\mathcal{P}(Y)$ you can take the topology generated by $\{\mathcal{S} \subseteq \mathcal{P}(Y): (\bigcup \mathcal{S}) \textrm{ is open in }Y\}$. Possibly other topologies on $\mathcal{P}(Y)$ are more natural.

A: The category of topological spaces and continuous functions does not have canonical notion of a relation. Let me elaborate.
There is only one reasonable 1-categorical notion of a relation: a relation from $A$ to $B$ is a "subobject" of the product $A \times B$. Therefore, if $\mathbb{C}$ is a category, then to define a concept of a relation in $\mathbb{C}$, you have to decide what you mean by a subobject of an object in $\mathbb{C}$.
The most general way to think of a subobject $\phi$ of an object $A$, is to think of $\phi$ as of a logical formula over $A$ (i.e. the "virtual" subobject of $A$ corresponding to formula $\phi$ is given by generalized elements that satisfy the formula $\{a \in A \colon \phi(a)\}$; in the presence of comprehension, such "virtual" subobjects may be materialized in the category, but the point is that we do not need to materialize --- a relation does not have to be representable in the category; it can belong to another world). Therefore, to define subobjects in $\mathbb{C}$, you have to define logic over $\mathbb{C}$. The concept of logic over a category is encapsulated by the concept of fiberwise posetal fibration.
Let us assume that $p \colon \mathbb{U} \rightarrow \mathbb{C}$ is such a fibration over $\mathbb{C}$. A relation $\phi \colon A \nrightarrow B$ in $\mathbb{C}$ corresponds to an object $\phi$ in the fibre of $p$ over $A \times B$. The only problem that remains to solve, is to find a way to compose two relations in such a way that the composition is associative and has neutral elements (i.e. identities). It is not hard to see that to define the composition in the natural way (i.e. ${a (\psi \circ \phi) c} \Leftrightarrow {\exists_{b \in B} {a \phi b} \wedge {b \psi c}}$), our logic $p$ has to have stable cartesian connectives and stable existential quantifiers. Category-theorists call such $p$ a regular logic fibration over $\mathbb{C}$. If you have a regular logic fibration, then you can take its resolution and obtain a 2-posetal category of relations $\mathit{Rel}(p)$ together with a canonical embedding:
$$\mathbb{C} \rightarrow \mathit{Rel}(p)$$
which gives an interpretation of morhpisms from $\mathbb{C}$ as relations in $\mathit{Rel}(p)$.
Now, every (sufficiently complete) category $\mathbb{C}$ has associated one canonical internal logic --- the logic of canonical subobjects (i.e. subobjects associated to monomorphisms $A_0 \rightarrow A$). For example, the canonical internal logic of $\mathbf{Set}$ gives the usual notion of a relation between sets and induces the usual category of relations. It is a good exercise to show that the canonical internal logic of a (finitely complete) category is regular if and only if the category is regular in the usual sense (i.e. it has stable images). Because the category of topological spaces and continuous maps is not regular, there is no canonical notion of a relation between topological spaces. There are three ways to overcome this annoying aspect of topological spaces:

*

*move to a more general category that is regular,

*move to a regular subcategory,

*take a non-canonical logic that is regular over the category of topological spaces.

Which way is the best way depends on your particular applications (I guess this is the reason why your question was closed --- it is completely unclear what you want to achieve).
BTW, there is a bit more general notion of a relation (and one may encounter it in category theory --- for example in the definition of sheaves over quantales): we can substitute regular logic with regular monoidal logic; i.e. we can weaken cartesian connectives to monoidal connectives and define the composition of $\phi \colon A \nrightarrow B$ with $\psi \colon B \nrightarrow C$ as ${a (\psi \circ \phi) c} \Leftrightarrow {\exists_{b \in B} {a \phi b} \otimes {b \psi c}}$. To be honest, one may imagine even more general notion of a relation, but I do not think it gives us anything useful in our context, so I will refrain from writing about it.

A: Different possibilities to extend continuity to relations:

A relation $X\overset{R}\rightarrow Y$ is continuous if it is upper hemicontinuous and lower hemicontinuous.
Upper hemicontinuous at $a\in X$ if for any open neighbourhood $V$ of $R(a)$ there exists an open neighbourhood $U$ of $a$ such that for all $x\in U$ it holds $R(x)\subset V$.
It seems like upper hemicontinuous is used in game theory for maximizing goal functions.
Lower hemicontinuous at $a\in X$ if for any open set $V$ such that $V\cap R(a)\ne\emptyset$ there exists a neighbourhood $U$ of $a$ such that $V\cap R(x)\ne\emptyset$ for all $x\in U$.

There is a lot of equivalent conditions on continuity for functions that might be considered as candidates for an extension, such as:

*

*$f^{-1}(V)$ is open for all open sets $V\subset Y$

*$f^{-1}(F)$ is closed for all closed sets $F\subset Y$

*$\overline{f^{-1}(M)}\subset f^{-1}(\overline{M})$, for all sets $M\subset Y$

*$f(\overline{L})\subset\overline{f(L)}$, for all sets $L\subset X$

*For all sets $M\subset Y$, it holds that $x\in \overline{f^{-1}(M)}\Rightarrow f(x)\in \overline{M}$
While they are equivalent conditions for functions, they might be non equivalent conditions on relations.

For multivalued functions $\mathcal{F}:X\rightarrow \mathcal M$, hemicontinuity is defined for topologies on $X$ and on a set $\mathcal M$ of subsets. This differs from the question of an eventual extension of continuity from functions to continuity for general relations between topological spaces $R\subset X\times Y$:

*

*first, in the latter case the topology is defined for the points in $Y$,
independent of any induced or otherwise defined topology on a set of
subsets of $Y\!$,

*second, a multivalued function is defined in the whole domain $X$, in contrary to the general case.

About the conditions $(1)$-$(5)$ above: $(2)$ and $(3)$ are equivalent, but non of the others. $(1)$-$(4)$ is satisfied by $X\times Y$, which not in general satisfies $(5)$, see my answer to my question on MATHEMATICS.

A: The discussion here is mostly from the foundations point of view. However, the OP mentioned applications in sciences like celestial mechanics. In fact, for such purposes one might not need general topological spaces. For example, subsets of $\mathbb{R}^n$ may be good enough. Also, sometimes one may get away with only local homeomorphisms as maps. Here is a rather elementary definition of what a reasonable notion of a continuous relation could be generalizing a local homeomorphism:
A locally homeomorphic relation is a relation $R$ which "locally looks like a homeomorphisms". That is, for any pair of elements $x \in X$ and $y \in Y$, such that $(x, y) \in R,$ there exit neighborhoods $U_x$ and $V_y$ and a homeomorphism between them, whose graph coincides with the restriction of the relation $R$.

A: This is a remarkable application in topology. It has been given by Mike Freedman in his work about the classification of simply connected closed topological 4-manifolds, which had as a main consequence the topological Poincaré conjecture in dimension 4. Actually, this is one of the many steps in his proof.
Friedman's ball to ball theorem. Let a map $f \colon B^4 \to B^4$ be such that the collection of the inverse sets is null, the singular image is nowhere dense and $f$ is a homeomorphism near the boundary. Then $f$ is approximable by homeomorphisms.
Roughly speaking, the null condition means that the collection of the preimages of $f$ with more than one point, are, a part from finitely many of them, of arbitrary small diameter.
In the proof there is an extraordinary usage of closed relations (that are analogous to continuous functions for compact Hausdorff spaces, as it has been remarked in other answers). The proof starts with a modification of the given map $f$, so that the outcome is not a map, but a relation instead. Then it follows with an infinite construction such that a sequence of relations is defined by induction. The construction is made so that this sequence converges to a homeomorphism close to $f!$
See these notes Chapter 5 for reference, definitions, as well as a proof.

A: Any function $f\colon A\to B$ defines a triple adjunction $f_*\dashv f^{-1}\dashv f_!$ between the powersets $\mathcal{P}(A)$ and $\mathcal{P}(B)$, where
\begin{align*}
    f_*(U)    &:= \{b\in B\ |\ \text{there exists $a\in U$ such that $f(a)=b$}\}\\
    f^{-1}(V) &:= \{a\in A\ |\ f(a)\in V\}\\
    f_!(U)    &:= \{b\in B\ |\ f^{-1}(b)\subset U\}
\end{align*}
with $U\in\mathcal{P}(A)$ and $V\in\mathcal{P}(B)$. Now, we may define open, closed, and continuous maps using these:

*

*A map $f$ is open if $f_*$ sends opens to opens.

*A map $f$ is continuous if $f^{-1}$ sends opens to opens.

*A map $f$ is closed if $f_!$ sends opens to opens (see the proof by მამუკა here).

We could now repeat this procedure with relations, although this time the triple adjunction breaks down into two adjunctions: any relation $R\colon A ⇸ B$ defines two adjunctions $R_*\dashv R_{-1}$ and $R^{-1}\dashv R_!$, where
\begin{align*}
    R_*(U)    &:= \{b\in B\ |\ \text{there exists $a\in U$ such that $b\in R(a)$}\}\\
    R_{-1}(V) &:= \{a\in A\ |\ R(a)\subset V\}\\
    R^{-1}(V) &:= \{a\in A\ |\ R(a)\cap V\neq\emptyset\}\\
    R_!(U)    &:= \{b\in B\ |\ R^{-1}(b)\subset U\}
\end{align*}
with $U\in\mathcal{P}(A)$ and $V\in\mathcal{P}(B)$.

Note: A nice fact here is that $R_{-1}=R^{-1}$ iff $R$ is total and functional, i.e. $R^{-1}$ and $R_{-1}$ coincide precisely if $R$ comes from a function.

Mimicking the situation for functions, we could now make the following definitions:

*

*A relation $R$ is open if $R_*$ sends opens to opens.

*A relation $R$ is strongly continuous if $R_{-1}$ sends opens to opens.

*A relation $R$ is weakly continuous if $R^{-1}$ sends opens to opens.

*A relation $R$ is closed if $R_!$ sends opens to opens (A very similar argument to the one given by მამუკა for functions shows that this is the same as asking $R_*$ to send closed sets to closed sets).

There is, however, an issue: continuous maps can be equivalently defined as those $f$ for which $f$ sends closed sets to closed sets, which follows from the equality $A\setminus f^{-1}(V)=f^{-1}(B\setminus V)$. Now, this equality doesn't need to hold for either $R_{-1}$ or $R^{-1}$, as we have
\begin{align*}
R_{-1}(B\setminus V) &= \{a\in A\ |\ R(a)\subset B\setminus V\},\\
A\setminus R_{-1}(V) &= \{a\in A\ |\ R(a)\not\subset V\},\\
R^{-1}(B\setminus V) &= \{a\in A\ |\ R(a)\setminus V\neq\emptyset\},\\
A\setminus R^{-1}(V) &= \{a\in A\ |\ R(a)\cap V=\emptyset\}.
\end{align*}
Considering also relations $R$ for which $R^{-1}$ or $R_{-1}$ send closed sets to closed sets thus leads to a total of four different definitions of continuity for relations using this approach. (Edit: the situation turns out to be way better if $R$ is total; see below)

Edit: I've since found two references which develop the above ideas further:

*

*The first one is Clementino–Tholen's A characterization of the Vietoris topology [PDF], which develops further the theory of open and closed relations, in particular proving the following theorem:

Theorem (Clementino–Tholen). Let $R\colon X\times Y\to\{0,1\}$ be a relation from $X$ to $Y$, and let $\mathcal{P}^{-}(X)$, $\mathcal{P}^{+}(X)$, and $\mathcal{P}(X)$ denote the lower Vietoris, upper Vietoris, and Vietoris topology on $\mathcal{P}(X)$. The following conditions are equivalent:

*

*The relation $R$ is open.

*The map $R^{-1}\colon\mathcal{P}^{-}(Y)\to\mathcal{P}^{-}(X)$ is continuous.

*The adjunct $R\colon Y\to\mathcal{P}^{-}(X)$ of $R$ is continuous.

*We have $R^{-1}(\overline{V})\subset\overline{R^{-1}(V)}$ for each $V\in\mathcal{P}(Y)$, where $\overline{S}$ denotes the closure of a set $S$.

Similarly, the following conditions are also equivalent:

*

*The relation $R$ is closed.

*The map $R^{-1}\colon\mathcal{P}^{+}(Y)\to\mathcal{P}^{+}(X)$ is continuous.

*The adjunct $R\colon Y\to\mathcal{P}^{+}(X)$ of $R$ is continuous.

*We have $R_{*}(\overline{U})\supset\overline{R_{*}(U)}$ for each $U\in\mathcal{P}(X)$.

*

*The second one is Klein–Thompson, Theory of Correspondences [Link], which develops the theory of "weakly/strongly continuity" as defined above for total relations (the situation is a little complicated for general relations):

*

*First, it seems that the definitions of continuity for relations commonly used in practice are instead the following:

*

*lower semicontinuity, called "weak continuity" above;

*upper semicontinuity, the property that $R^{-1}$ sends closed sets to closed sets.

*Now, the four definitions situation for continuity of relations described above gets better for total relations: when $R$ is total Proposition 6.3.5 there notes that we have the following equalities:
\begin{align*}
    R_{-1}(B\setminus V) &= A\setminus R^{-1}(V),\\
    R^{-1}(B\setminus V) &= A\setminus R_{-1}(V).
\end{align*}
As a consequence, $R^{-1}$ preserves opens (resp. closed sets) iff $R_{-1}$ preserves closed sets (resp. opens)!

*Lastly we have the following result (Theorems 7.1.4 and 7.1.7) which gives equivalent conditions for $R$ to be continuous:

Theorem (Klein–Thompson). If $R$ is total, then the following conditions are equivalent:

*

*The relation $R$ is upper semicontinuous, i.e. $R^{-1}$ sends closed sets to closed sets.

*The adjunct $R\colon X\to\mathcal{P}^{+}(Y)$ of $R$ is continuous.

*The function $R_{-1}$ sends opens to opens.

*For every $x\in X$, every net $(x_n)_{n\in D}$ in $X$ converging to $x$, and every open set $V$ of $Y$ with $f(x)\subset V$, we have $f(x_n)\subset V$ for sufficiently large $n$.

Similarly, the following conditions are equivalent:

*

*The relation $R$ is lower semicontinuous, i.e. $R^{-1}$ sends opens to opens.

*The adjunct $R\colon X\to\mathcal{P}^{-}(Y)$ of $R$ is continuous.

*The function $R_{-1}$ sends closed sets to closed sets.

*For every $x\in X$, every net $(x_n)_{n\in D}$ in $X$ converging to $x$, and every open set $V$ of $Y$ with $f(x)\cap V\neq\emptyset$, we have $f(x_n)\cap V\neq\emptyset$ for sufficiently large $n$.

Lastly Klein–Thompson also give two results comparing continuity/closedness of relations in the above senses to $R\subset X\times Y$ being a closed set in the product topology:

Theorem 7.1.15. If $Y$ is regular, $R$ is upper semicontinuous, and $R_*(x)$ is closed for each $x\in X$, then $R\subset X\times Y$ is closed with respect to the product topology.
Theorem 7.1.16. If $Y$ is compact and $R$ is a closed relation in that $R_*$ maps closed sets to closed sets, then $R\subset X\times Y$ is closed with respect to the product topology.
(Theorem 7.1.16 fails if $Y$ is allowed to be noncompact; see Example 7.1.17 there)

Some remarks on equivalences relation.
One reason for us to care about relations being upper/lower semicontinuous, open or closed is because of quotient spaces: when an equivalence relation $\sim$ on a topological space $X$ satisfies some of these properties, we in fact get a bunch of nice facts about the quotient $X/\mathord{\sim}$ being well-behaved. For instance, here's a result from Clementino–Tholen:

Let $R$ be an equivalence relation on $X$. The following conditions are equivalent:

*

*The relation $R$ is closed (resp. open)

*The quotient map $\pi\colon X\twoheadrightarrow X/\mathord{\sim}_R$ is closed (resp. open)

*The inclusion map $\iota_{X/\mathord{\sim}_R}\colon X/\mathord{\sim}_R\to\mathcal{P}^{+}(X)$ (resp. to $\mathcal{P}^{-}$(X)) is continuous.

Here are a couple of other results I found:

*

*See Daniele Zuddas's answer

*(Tu An Introduction to Manifolds, Theorem 7.7.) If $R$ is an open equivalence relation on $X$, then $X/\mathord{\sim}_R$ is Hausdorff iff $R\subset X\times Y$ is closed in the product topology.

*(Tu An Introduction to Manifolds, Corollary 7.10.) If $R$ is open and $X$ second-countable, then $X/\mathord{\sim}_R$ is second-countable.

*Daverman's Decompositions of Manifolds has a bunch of other results, too.

Comparisons with definitions in other answers. Here's a comparison of the notions above with some of the ones in the other answers:

*

*Putting topologies on powersets. As seen above, continuity, openness and closedness of relations in the above senses correspond to asking the associated functions $X\to\mathcal{P}(Y)$ or $Y\to\mathcal{P}(X)$ to be continuous with respect to the Vietoris topologies. (There are other interesting powerset topologies to consider besides the Vietoris ones, though, like the Fell topology (or maybe the Alexandroff topology; I don't know if it is different from the Vietoris ones))

*Closedness in the product topology. Klein–Thompson's Theorems 7.1.15 and 7.1.16 relate closedness of $R$ in the product topology to $R$ being a closed relation. The two notions are distinct in general, however.

*Eric Wofsey's approach via nets. As Klein–Thompson's Theorem  7.1.7 shows, a total relation $R$ satisfies Eric's criterion iff it is lower semicontinuous, i.e. iff $R^{-1}$ sends opens to opens.

*Lehs's upper/lower hemicontinuity. These are equivalent (I think!) to asking that $R_{-1}$ and $R^{-1}$ preserve opens!

A: Here is an expansion of my comment into an answer which I think is very compelling as the "correct" definition for compact Hausdorff spaces, though I agree with others who have said that for general spaces there may be several competing definitions with different merits.  My argument for this being the right definition is that it is natural in two different ways: it arises naturally by taking the definition of "homomorphism" and modifying it in an obvious way to apply to relations, and it also coincides with the categorical definition of relations as subobjects of the product $X\times Y$.  Furthermore, the coincidence of these two definitions occurs very generally (in particular, in any category monadic over sets).
Let me start by considering this question in different (concrete) categories.  For instance, what might it mean for a relation $R\subseteq G\times H$ to be "homomorphic"?  If you think of a relation as a multivalued function, the following definition seems pretty reasonable: for any $g,g'\in G$, if $h$ is a value of $R(g)$ and $h'$ is a value of $R(g')$, then $hh'$ should be a value of $R(gg')$.  We should also demand that $1$ is a value of $R(1)$ and that if $h$ is a value of $R(g)$, then $h^{-1}$ is a value of $R(g^{-1})$ (demanding these is redundant for functions but not for relations).  It is then easy to check that this is actually equivalent to $R\subseteq G\times H$ being a subgroup of the product group.  This easily generalizes to any other sort of algebraic object: there is an analogous definition of "homomorphic relation", and it is equivalent to being a subobject of the product.
What, then, is the analogue for topological spaces?  Well, if you want to think of a space as a set with some sort of "operations" on it, those operations should be taking limits.  Because limits neither always exist nor are unique in general, there are a few different ways you might define what it means for a relation to preserve limits.  The following is the one I have found to be most natural:
(1)$\,$a relation $R\subseteq X\times Y$ is continuous if whenever $x$ is an accumulation point of a net $(x_a)$ in $X$ and $y_\alpha$ is a value of $R(x_\alpha)$, then there is some accumulation point of $(y_\alpha)$ that is a value of $R(x)$.
Equivalently, we could restrict to universal nets and replace "accumulation point" with "limit" everywhere (however, unlike for functions, it is not equivalent to consider arbitrary nets and replace "accumulation point" with "limit", because there might be values of $R(x)$ that are limits of every universal subnet but no single value that is simultaneously a limit of all of them).
This definition has advantages and disadvantages.  A function is continuous as a relation iff it is continuous in the usual sense and a composition of continuous relations is continuous.  A partial function that is continuous on its domain is continuous as a relation iff its domain is closed.  However, this definition is not symmetric in $X$ and $Y$ (as Joonas Ilmavirta observed, this is a necessary consequence of agreeing with the usual definition on functions).  It also does not coincide with subobjects of $X\times Y$ in the category of topological spaces (which include not only all subspaces of $X\times Y$ but also all subsets equipped with any finer topology).
However, if we restrict to compact Hausdorff spaces, the disadvantages disappear.  Limits of universal nets or ultrafilters are well-defined single-valued operations on compact Hausdorff space, so there is a clear choice for what it means for a relation to be "homomorphic with respect to limits".  A relation between compact Hausdorff spaces is continuous iff it is closed as a subset of $X\times Y$, and thus continuity is symmetric in $X$ and $Y$.  In addition, these continuous relations are also exactly those subsets of $X\times Y$ that are themselves compact Hausdorff spaces, just as in the case of homomorphic relations between algebraic structures.
As a final note, there is a simultaneous generalization of the algebraic case and compact Hausdorff spaces, which is algebras over a monad (compact Hausdorff spaces are the same as algebras over the monad that takes a set to the set of ultrafilters on it, with the structure map of an algebra telling you how to take limits of ultrafilters).  Let $T:\mathrm{Set}\to\mathrm{Set}$ be a monad and let $A$ and $B$ be sets.  Given a relation $R\subseteq A\times B$, we can consider the two projections $A\leftarrow R\to B$ and apply $T$ to get a diagram $TA\leftarrow TR\to TB$.  Let $\tilde{T}R$ be the image of $TR$ in the product $TA\times TB$.  In this way, $T$ naturally extends to a functor $\tilde{T}:\mathrm{Rel}\to\mathrm{Rel}$.
We can now define a "homomorphic relation" between $T$-algebras.  Let $A$ and $B$ be $T$-algebras with structure maps $\mu_A:TA\to A$ and $\mu_B:TB\to B$.  We say a relation $R\subseteq A\times B$ is homomorphic if for any $x\in TA$, if $y$ is a value of $\tilde{T}R(x)$, then $\mu_B(y)$ is a value of $R(\mu_A(x))$.  But this is just saying that $\mu_A\times \mu_B:TA\times TB\to A\times B$ restricts to a map $\tilde{T}R\to R$, and this restriction will then make $R$ itself a $T$-algebra via the composition $TR\to \tilde{T}R\to R$ and a subalgebra of $A\times B$.  Conversely, if $R$ is a subalgebra of $A\times B$, then the structure map $TR\to R$ must factor through $\tilde{T}R$ as a restriction of $\mu_A\times \mu_B$.  Thus homomorphic relations between algebras over a monad always coincide with subalgebras of the product.

A: I have a couple of remarks regarding continuity and some natural constructions of relations:

*

*Unlike functions, relations have no preferred direction.
So if $R\subset X\times Y$ is a relation, its inverse relation $R^{-1}\subset Y\times X$ is an equally valid relation.
Now if we want the concept of a continuous relation to respect this symmetry ($R$ is continuous iff $R^{-1}$ is), we have a significant restriction.
The obvious attempt to define a continuous relation so that the preimage of any open set needs to be (relatively) open leads to a nonsymmetric concept; it is easier to generalise open continuous functions symmetrically.
In fact, a generalization of continuous functions cannot be symmetric (without additional structural assumptions on the spaces) since there are continuous bijections without continuous inverse.

*Let $R\subset X\times Y$ be a relation.
The preimage $R^{-1}Y\subset X$ need not be all of $X$ (unlike for functions).
If we define $R$ to be continuous when the preimage of every open set is open, a partial function obtained by dropping part of a continuous function need not be continuous.
This seems weird (but may be inevitable).
One could also demand that the preimage of any set relatively open in $RX$ (or just open in $Y$ if it seems better) is relatively open in $R^{-1}Y$.

*If $R\subset X\times Y$ and $S\subset Y\times Z$ are relations, their composition $S\circ R=\{(x,z);\exists y\in Y:xRySz\}\subset X\times Z$ is a relation.
If $R$ and $S$ are continuous, it would seem natural to require that $S\circ R$ be continuous as well.
This poses restrictions on the definitions presented in the previous remark; it could happen, for example, that $S^{-1}Z\cap RX\subset Y$ is empty or somehow bad (neither open nor closed).
If we define a continuous relation so that the preimage of an open set must be open, composition preserves continuity, but passing to partial functions does not.
The composition of two (usual/partial/multivalued) functions is again a (usual/partial/multivalued) function, so I think respecting composition is a good idea.
It seems that we can't keep all the good properties of continuous functions and ordinary relations in a theory of continuous relations.
Therefore different applications will probably call for different definitions.
(This vacuously true if there is at most one application.)

A: Since the question is open-ended and basically just seems to be a request for cool ideas, is it okay if I answer a slightly different question? Namely: what is the "right" notion of a measurable relation?
The obvious answer --- take $X$ and $Y$ to be measure spaces and $R$ to be a measurable subset of $X \times Y$ --- is badly behaved. If $X$ is nonatomic then the reflexivity condition for relations on $X$ becomes vacuous, and making sense of transitivity is also problematic.
But there is a good answer! Work with positive measure subsets modulo null sets and assume $X$ and $Y$ are $\sigma$-finite, so we can take joins of arbitrary families of positive measure subsets. Then we characterize measurable relations by saying which pairs of positive measure subsets belong to the relation. The condition is: a measurable relation is a family $R$ of ordered pairs of positive measure subsets of $X$ and $Y$ such that
$$\big(\bigvee A_\alpha, \bigvee B_\alpha\big) \in R\qquad \Leftrightarrow\qquad \mbox{some }(A_\alpha, B_\alpha) \in R,$$
for any families $\{A_\alpha\}$ and $\{B_\alpha\}$ of positive measure subsets of $X$ and $Y$, respectively.
The intuition is that a pair $(A,B)$ belongs to the relation if and only if some point of $A$ is related to some point of $B$.
There is a well-developed theory of measurable relations in this sense. They can be composed, for example. The diagonal relation $\Delta$ is defined by setting $(A,B) \in \Delta$ iff $A \cap B$ is nonnull, and a relation is reflexive if it contains $\Delta$, etc. The details are given in Section 1 of this paper of mine.
Interestingly, as far as I know, there is no good definition of the complement of a measurable relation in this sense.

A: Following is only a partial answer to the question posted above. More specifically it only attempts to answer $(1)$ of the original question.

First Approach

Definition 1. Let $X$ and $Y$ be two sets and $R\subseteq X\times Y$ be a relation. Let $A\subseteq X$. Then we will define the image of $A$ under the relation $R$, denoted by $R(A)$ as the following set, $$R(A):=\{y\in Y:(x,y)\in R\ \text{for some}\ x\in A\}$$

Let us now try to prove the following lemmas,

Lemma 1. Let $X,Y$ be two sets and $R\subseteq X\times Y$. Let $A\subseteq B\subseteq X$. Then we have, $R(A)\subseteq R(B)$.
Lemma 2. Let $X,Y,Z$ be three sets and $R\subseteq X\times Y$ and $S\subseteq Y\times Z$ are two relations. Then we have, $$(S\circ R)(A)\subseteq S(R(A))$$for all $A\subseteq X$.

Proof. Let us choose $A\subseteq X$. If $(S\circ R)(A)=\emptyset$ then we are done because then $(S\circ R)(A)=\emptyset\subseteq S(R(A))$. So we may assume that $(S\circ R)(A)\ne\emptyset$.
Let $z\in (S\circ R)(A)$. Then there exists some $x\in A$ such that $(x,z)\in S\circ R$. But $(x,z)\in S\circ R$ implies that there exists some $y\in Y$ such that $(x,y)\in R$ and $(y,z)\in S$.
Since $x\in A$ and $(x,y)\in R$ so we can conclude that $y\in R(A)$. Similarly since $y\in R(A)$ and $(y,z)\in S$, we can conclude that $z\in S(R(A))$. Since $z$ was arbitrarily chosen, we have thus shown that, $$(S\circ R)(A)\subseteq S(R(A))$$and furthermore since $A$ was also arbitrarily chosen, we have proved our theorem.

Let us now come to our main definition.

Definition 2. Let $(X,\tau_X)$ and $(Y,\tau_Y)$ be two topological spaces. A relation $R\subseteq X\times Y$ will be said to be continuous iff $R(\overline{A})\subseteq \overline{R(A)}$ for all $A\subseteq X$.

And now the main theorem.

Theorem 1. Let $(X,\tau_X), (Y,\tau_Y)$ and $(Z,\tau_Z)$ be three topological spaces and let $R\subseteq X\times Y$ and $S\subseteq Y\times Z$ be two continuous relations. Then $S\circ R\subseteq X\times Z$ is also continuous.

Proof. Observe that for all sets $A\subseteq X$ we have, \begin{align*}(S\circ R)(\overline{A})&\subseteq S(R(\overline{A}))\\&\subseteq S(\overline{R(A)})&\text{(since}\ R\ \text{is continuous)}\\&\subseteq \overline{S(R(A))}&\text{(since}\ S\ \text{is continuous)}\end{align*}and hence we are done.
Second Approach

Definition 3. Let $X$ and $Y$ be two sets and $R\subseteq X\times Y$ be a relation. Let $B\subseteq Y$. Then we will define the pullback of $B$ under the relation $R$, denoted by $R^{-1}(B)$ as the following set, $$R^{-1}(B):=\{x\in X:(x,y)\in R\ \text{for some}\ y\in B\}$$

Let us now try to prove the following lemmas,

Lemma 3. Let $X,Y$ be two sets and $R\subseteq X\times Y$. Let $A\subseteq B\subseteq Y$. Then we have, $R^{-1}(A)\subseteq R^{-1}(B)$.
Lemma 4. Let $X,Y,Z$ be three sets and $R\subseteq X\times Y$ and $S\subseteq Y\times Z$ are two relations. Then we have, $$(S\circ R)^{-1}(C)\subseteq R^{-1}(S^{-1}(C))$$for all $C\subseteq Z$.

Proof. Let us choose $C\subseteq Z$. If $(S\circ R)^{-1}(C)=\emptyset$ then we are done because then $(S\circ R)^{-1}(C)=\emptyset\subseteq R^{-1}(S^{-1}(C))$. So we may assume that $(S\circ R)^{-1}(C)\ne\emptyset$.
Let $x\in (S\circ R)^{-1}(C)$. Then there exists some $z\in C$ such that $(x,z)\in S\circ R$. But $(x,z)\in S\circ R$ implies that there exists some $y\in Y$ such that $(x,y)\in R$ and $(y,z)\in S$.
Since $z\in C$ and $(y,z)\in S$ so we can conclude that $y\in S^{-1}(C)$. Similarly since $y\in S^{-1}(C)$ and $(x,y)\in R$, we can conclude that $x\in R^{-1}(S^{-1}(C))$. Since $x$ was arbitrarily chosen, we have thus shown that, $$(S\circ R)^{-1}(C)\subseteq R^{-1}(S^{-1}(C))$$and furthermore since $C$ was also arbitrarily chosen, we have proved our theorem.

Let us now come to our main definition.

Definition 4. Let $(X,\tau_X)$ and $(Y,\tau_Y)$ be two topological spaces. A relation $R\subseteq X\times Y$ will be said to be continuous iff $\overline{R^{-1}(B)}\subseteq R^{-1}(\overline{B}) $ for all $B\subseteq Y$.

And now the main theorem.

Theorem 2. Let $(X,\tau_X), (Y,\tau_Y)$ and $(Z,\tau_Z)$ be three topological spaces and let $R\subseteq X\times Y$ and $S\subseteq Y\times Z$ be two continuous relations. Then $S\circ R\subseteq X\times Z$ is also continuous.

Proof. Observe that for all sets $C\subseteq Z$ we have, \begin{align*}\overline{(S\circ R)^{-1}(C)}&\subseteq \overline{R^{-1}(S^{-1}(C))}\\&\subseteq R^{-1}(\overline{S^{-1}(C)})&\text{(since}\ R\ \text{is continuous)}\\&\subseteq R^{-1}(S^{-1}(\overline{C}))&\text{(since}\ S\ \text{is continuous)}\end{align*}and hence we are done.

A: I think the key point is to figure out what it means for a relation $R\subset X\times Y$ to "converges" to some point. To achieve this, one could apply the notion of a "convergence space".
So far we have mainly two approaches to define a "convergence space". One approach uses  Moore-Smith's notion of "net", the other one uses Cartan's notion of "filter". It could be shown that these two approaches are essentially the same, if we establish the connection between a net and a filter via taking the "eventual filter" $\mathcal F(\nu)$ for a net $\nu,$ and in this way convert a "net convergence space" into a "filter convergence space". For simplicity I'll only give some details for "filter convergence space".
Following the definition given by R.Beattie and H.P.Butzmann, (which could be found in their treatise Convergence Structures and Applications to Functional Analysis), a convergence space(established on the notion of filters) is a set $X$ endowed with a "convergence structure", which is a family of sets $(\lambda(x))_{x\in X},$ satisfying the following axioms for each $x\in X$:
A1 The members of $\lambda(x)$ are filters on $X;$
A2 If $F\in \lambda(x)$ and $G$ is another filter on $X$ with $F\subset G,$ then $G\in\lambda(X);$
A3 If $F,G\in\lambda(x)$ then $F\cap G\in\lambda(x);$
A4 The principal filter at $x$(i.e., the set of $\left\{A\subset X|\ x\in A\right\}$) belongs to $\lambda(x).$
We say that a filter $F$ on $X$ converges to $x\in X,$ written $F\to x,$ if $F\in\lambda(x).$
Now assume that $X$ and $Y$ areboth endowed with some convergence structures, let $a\in X$ and $b\in Y,$ then we say that the second argument of relation $R$ converges to $b$ as the first argument converges to $a,$ written $\displaystyle\lim_{(x,y)\in R,\ x\to a}y=b,$ if for any filter $F$ on $R,$ we have $\pi_{1}(F)\to a\Longrightarrow \pi_2(F)\to b,$ where $\pi_i:R\to X\ \text{or}\ Y,\ (x,y)\mapsto x\ \text{or}\ y$ are the projection maps.
An equivalent formulation is that, $\displaystyle\lim_{(x,y)\in R,\ x\to a}y=b,$ if for any filter $F$ on $X,$ we have $F\to a\Longrightarrow \left\{S(U)|\ U\in F\right\}\to b,$ where $S(U):=\left\{y\in Y|\ \exists x\in U,\ s.t.\ (x,y)\in R\right\}$ for all subset $U$ of $X.$
Once we've established the setting of the convergence of a relation, it's not that difficult to give a definition of "continuous relations". We say a relation $R$ is continuous at point $a\in X,$ if for all $b\in Y,$ if $(a,b)\in R,$ then $\lim_{(x,y)\in R,\ x\to a}y=b.$ It could be seen that the continuity of a function at one point becomes a special case.
To come back to the familiar notion of convergence in a topological space, one can define the convergence structure $(\lambda(x))_{x\in X}$ to be
$$\lambda(x):=\left\{F\ \text{is a filter on $X$}|\ F\supset N(x)\right\},$$
where $N(x)$ is the collection of all neighborhoods of $x,$ which is a filter on $X.$ (BTW, when I say a "neighborhood of $x$" I mean "a subset of $X$ that contains an open set $U$ with $x\in U.$")
Now we can derive from the notion of convergence of a relation  the familiar criterion of the continuity of a function at a point:
$ f:X\to Y$ is continuous at point $x\in X$ if and only if for any neighborhood $U$ of $f(x),$  there is a neighborhood $V$ of $x$ such that $f(V)\subset U.$

A: I'll introduce continuous selection relations or sontinuous for short. I believe them to be useful and having potential for appearing in many topological theorems, say in the topic of selectors.

NOTATION (set theory):
A relation (from $\ X\ $ to $\ Y$) is an ordered triple
$\ (X\,\ Y\ R)\ $ such that $\ R\subseteq X\times Y.$
The composition $\ \circ\ $ of relations $\ (X\,\ Y\ R)\ $ and $\ (Y\ Z\,\ S)\ $ is defined as
$$ (Y\ Z\,\ S)\ \circ\ (X\,\ Y\ R)\,\ =\,\ (X\ Z\ Q) $$
where
$$ Q\ :=\ \{\,(x\ z)\in X\times Z:\ \exists_{\,y\in Y}\,
   (\,(x\ y)\in R\quad\text{and}\quad (y\ z)\in S\,)\} $$
Functions and partial functions are treated as relations too hence one may apply to them the set-theoretical inclusion, etc.
Next, given a relation $\ (X\ Y\ R),\ $ the r-domain
$\ D_R,\ $ and r-codomain $\ C_R\ $ are defined as:
$$ D_R\ :=\ \{x\in X: \exists_{y\in Y}\ (x\ y)\in R\} $$
and
$$ C_R\ :=\ \{y\in Y:\ \exists_{x\in X}\ (x\ y)\in R\}. $$
Finally, a multi-valued function -- I call them the rulers -- is any relation $\ (X\,\ Y\ R)\ $ such that
$$ D_R\ =\ X.$$

Sontinuous relations (topology):
Let $\ (X\ \rho)\ $ and $\ (Y\ \sigma)\ $ be topological spaces. Together with topologies $\ \rho\ $ and $\ \sigma\ $
we consider also the induced topologies as it's standard in topology.
Ruler $\ (X\,\ Y\ R)\ $ is said to be sontinuous
$\ \Leftarrow:\Rightarrow $ there exists a continuous function
(yes, function) $\ s:X\to Y\ $ such that
$\ s\subseteq R.$

A: A function $R\subseteq X\times Y$ is continuous iff for all sets $M\subseteq Y$:
$(1)\quad x\in \overline{R^{-1}(M)}\wedge (x,y)\in R \Rightarrow y\in\overline{M}$, or
$(2)\quad x\in \overline{R^{-1}(M)}\wedge (x,y)\in R \Rightarrow
R(x)\cap\overline{M}\ne\emptyset$
Applied to relations $R\subseteq X\times Y$ the condition $(1)$ implies that $R$ is a (continuous) function if $Y$ is Hausdorff and the condition $(2)$ implies that the maximal relation $X\times Y$ is continuous. Maybe $(1)$ could be of interest for non Hausdorff spaces, but $(2)$ violates my intuition (whatever it is worth) about continuity.
Perhaps one can use conditions between $(1)$ and $(2)$ as
$(3)\quad x\in \overline{R^{-1}(M)}\wedge (x,y)\in R \Rightarrow
R(x)\cap\overline{M}\ne\emptyset\wedge |R(x)\setminus\overline{M}|\in\mathbb{N}$?
I guess that every algebraic curve is continues in the sense of $(3)$,  but in general not the maximal relation.
Any condition on continuity for functions induces a family of relations. Every open (closed) set $R\subseteq X\times Y$ fulfill the condition that the inverse image of any open (closed) subset of $Y$ is open (closed) in $X$. But for both these conditions the maximal relation is continuous.


text:
Q: Hyperkahler and symplectic complex geometry: reference? I would need some references regarding symplectic and hyperkahler (complex) geometry. My background is mostly from algebraic geometry and I know a little bit the basics on Kahler manifolds.
I would be interested in a book or notes which could introduce me to those subjects with an approach linked to algebraic geometry if possible. Apparently also symplectic and hyperkahler complex geometry are key tools in many areas of representation theory : if someone knew a book which could explain the basics and the reason why these are such important tools, that'd be great!
I've already " Representation theory and complex geometry": I find this is a very good reference but sometimes it is very technical/ I get a little bit lost.

A: I recommend Namikawa's 複素シンプレクティック代数多様体: 特異点とその変形, if you read Japanese.


text:
Q: Regarding Raspberry Pi Zero W - USB Access from GPIO Header I am using Raspberry Pi Zero W for my project. I want to use GPIO Pins as USB instead of the on-bard MicroUSB connector. Is it possible?
Thanks in advance.

A: Sorry, the GPIO connector does not include any USB signals.
There are some USB hubs that connect to the test pads on the back side of the zero, e.g this one sold by Adafruit: https://www.adafruit.com/product/3298
If you are happy with just one USB port but don't like the micro connector, you could probably solder your own connector with a short pigtail lead to the same test points.
You can't use the micro usb connector at the same time as a hub or usb connector attached to the test pads as they are the same signals as in the micro connector.
The test pads p22 and p23 can be seen in this schematic:
https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/schematics/Raspberry-Pi-Zero-V1.3-Schematics.pdf


text:
Q: Making Raspberry Pi Windows IoT into a router? There are a number of resources explaining how to turn a Raspberry Pi into a router, for example:
http://lifehacker.com/turn-a-raspberry-pi-into-a-wireless-router-1582672426
http://raspberrypihq.com/how-to-turn-a-raspberry-pi-into-a-wifi-router/
http://yannickloriot.com/2016/03/turn-your-raspberry-pi-into-a-wifi-router/
However, none of the guidelines I found were related to Windows 10 IoT on Raspberry.
Is there anyway that we could make a Raspberry Pi, running Windows 10 IoT as OS, to a router.
It could be helpful if a component (the router) can be removed in server/client applications, and can embedded in Raspberry Pi itself.


text:
Q: Draft.js невозможно выделить/удалить картинку Необходимо парсить html в draft.js
Но картинки выделяются и все равно не удаляются. так-же если поставить курсор после картинки ее тоже нельзя удалить
Код декоратора для картинки
function findImageEntities(contentBlock, callback, contentState) {
contentBlock.findEntityRanges(
    (character) => {
        const entityKey = character.getEntity();
        if(entityKey !== null && contentState.getEntity(entityKey).getType() === 'IMAGE'){
            console.log('props');
        }
        return (
            entityKey !== null &&
            contentState.getEntity(entityKey).getType() === 'IMAGE'
        );
    },
    callback
);}

const Image = (props) => {
const {
    height,
    src,
    width,
} = props.contentState.getEntity(props.entityKey).getData();
return (
        <img src={src} />
);};

A: Добавьте картинку в качестве background-image для тега <span>, тогда Draft.js будет воспринимать содержимое как редактируемый контент.


text:
Q: Parse Python protoBuf binary data (trained model) using Tensorflow and C++ I've a serialized my trained tensorflow model that I obtained from Python using the tf.train.export_meta_graph().SerializeToString() function. This gives me a huge string of binary data. Something like the following.
b'\n\x9a\x15\x12\x84\x15\n9\n\x03Add\x12\x06\n\x01x"\x01T\x12\x06\n\x01y"\x01T\x1a\x06\n\x01z"\x01T"\x1a\n\x01T\x12\x04type:\x0f\n\r2\x0b\x13\x01\x02\x04\x06\x05\x03\t\x08\x12\x07\n\x83\x01\n\x0cApplyAdagrad\x12\x0b\n\x03var"\x01T\x80\x01\x01\x12\r\n\x05accum"\x01T\x80\x01\x01\x12\x07\n\x02lr"\x01T\x12\t\n\x04grad"\x01T\x1a\x0b\n\x03out"\x01T\x80\x01\x01"\x1d\n\x01T\x12\x04type:\x12\n\x102\x0e\x01\x02\t\x03\x04\x11\x05\x06\x08\x12\x0b\x0c\r\x13"\x17\n\x0buse_locking\x12\x04bool\x1a\x02

Note: This is not the complete data but just to give you an idea.
Now I want to deserialize this data using the Tensorflow C++ API and I am not sure how to do this. I imported it in Python successfully like this.
Python:
meta_graph_def = meta_graph_pb2.MetaGraphDef()
meta_graph_def.ParseFromString(data)

with tf.Graph().as_default() as graph:
    # new_saver = tf.import_graph_def(graph_def)
    new_saver = tf.train.import_meta_graph(meta_graph_def)
return graph

This returns me the correctly initialized graph using the binary data I provided in the "data" variable. How can I achieve the same in C++?
Update:
I already tried to achieve the same but I get the following error.
error: 'b' was not declared in this scope

Here's the code I am using to achieve the same.
tf::GraphDef graph_def;
std::string data = "[the long binary string defined above]";
graph_def.ParseFromString(data);

As I know this has something to do with the preceeding b in the binary data shown above, shouldn't it be compatible with the C++ ParseFromString function from protoBuf since this binary data was generated from the python protoBuf using SerializeToSTring(). What could be the reason behind this problem ?


text:
Q: Cron service in multiple k8s pod I have an application running on multiple k8s pods. Forgive me for my lack of knowledge about k8s pod, from my understanding k8s will route incoming traffic to a different pod just like a proxy.
What happened if my application is running a cron job that fetches data. Is the cron job gonna be called multiple times based on how much pod is running, my concern is that will be a data duplication because these pod will fetch the same data.
My question is how to avoid data duplication when a cron job fetches data? can these pod configured to become something like a worker? let's say the cron job is fetching 500 data. Given 5 pods, each pod will fetch 100 data.

A: Ideally, it should be not like that way POD will be mostly running the workload like API or socket servers
For cronjobs there are other options n Kubernetes is especially for the cronjob.
There are cronjobs & jobs two things in Kubernetes.
https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/
cron jobs get executed as per the corn timing while jobs get executed when you create it using YAML.
Cronjob indirectly creates the job run time. you can check out using the kubectl get jobs & kubectl get cronjobs

can these pod configured to become something like a worker? let's say
the cron job is fetching 500 data. Given 5 pods, each pod will fetch
100 data.

now this depends on your scenrio you can create the single cronjob which fetch all those 500 data and single pod will be running at a time or corn execution.

My question is how to avoid data duplication when a cron job fetches
data?

Run that type of workload as Cronjob pod.
https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/


text:
Q: How do I call concat_idents inside a recursive macro expansion? I'm trying to create a macro to expand a set of names and define fields for a struct:
macro_rules! expand {
  ($($name:ident),*) => {
     pub struct Test {
       $(
          concat_idents!(var_, $name) : Vec<$name>
        ),*
     }
  }
}
//fails
expand!(a,b,c);

This fails as the compiler does not recognize concat_idents! as a macro. How am I supposed to work around this?

A: It is not at present possible to do this in any way. Substitutions ($foo) are fine there, but not macro calls.


text:
Q: TinyMCE: Retrieving information from popup I'm having trouble with the documentation on TinyMCE for plugin development.
I simply want to display a popup to choose between internal links / external links then either choose another page on the site or let the user insert an external link.
To launch the window I'm using the following code :
tinymce.PluginManager.add( 'insumolinks', function( editor, url ) {
    // Add a button that opens a window
    editor.addButton( 'insumolinks', {
        text: 'Link',
        icon: false,
        onclick: function() {
            // Open window
            editor.windowManager.open( {
                title: 'Insert Link',
                url: '/admin/pages/add_link',
                onsubmit: function( e ) {
                    // Insert content when the window form is submitted
                    // editor.insertContent( '' + editor.selection.getContent() + '' );
                    console.log( e.data );
                }
            });
        }
    });
});

The page that is being loaded inside the window is :

    <select name="link_type" class="link_type" style="margin-top: 20px;">
    <option value="none">No Link</option>
    <option value="other-page">Other Page</option>
    <option value="external-link">External Link</option>
</select>

    <select name="link" class="resource-link" style="display: none;">
    <?php foreach( $pages as $page ) : ?>
        <option value="<?= $page->id ?>" data-url="<?= $page->url ?>">
        <?= $page->title ?>
    </option>
    <?php endforeach; ?>
</select>

    <input type="text" name="link" class="resource-link" value="http://" style="display: none;">

<button type="submit" class="btn btn-primary">Add Link</button>

What code would I have to run to send the link values through to the onsubmit call?
In the docs they use the WindowManager to create the page but I can't find much information about how to create different elements.
Thanks in advance

A: Old question, but still relevant.
Here's how I did it. I'm using tinymce v4.
I am finding the popup/iframe in jQuery, but it could easily be done in vanilla JS.
I created my JS plugin, included it externally in my init section
tinymce.init({
    selector: "textarea.tinymce",
    external_plugins: { 'myplugin': 'url-to-my-plugin' }
});

Plugin:
tinymce.PluginManager.add('myplugin', function(editor, url) {
   // Adds a menu item to the tools menu
   editor.addMenuItem('myplugin', {
      id: 'myPluginId',
      text: 'My Plugin Menu Title',
      context: 'insert',
      onclick: function() {
         editor.windowManager.open({
            title: 'Title Of My Plugin',
            url: 'myplugin.html',
            //we create the submit buttons here instead of in our HTML page
            buttons: [{
                  text: 'Submit',
                  onclick: 'submit'
               }, {
                  text: 'Cancel',
                  onclick: 'close'
               }],
            width: 500,
            height: 325,
            onsubmit: function(e) {
               //find the popup, get the iframe contents and find the HTML form in the iFrame
               form = $('#myPluginId iframe').contents().find('form');

               //once you have the form, you can do whatever you like with the data from here
            }
         });
      }
   });
});


text:
Q: Trouble with clearcase VOB database I am getting the following error for most of the clearcase activities, like labeling, checkout etc.
cleartool: Error: Error from VOB database: "\11.3.0".
cleartool: Error: Trouble finding the global definition for local type "???".
cleartool: Error: Trouble applying label to

Some times it is going on, but most often failing with this error. Above is the error while applying a label. Please suggest

A: Following the technote "Fixing broken hyperlinks with Administrative VOBs", check if you don't have a missing hyperlink between your vob and your admin vob (which, if you are using UCM, should be a PVob).

An AdminVOB is a normal VOB that will be principally used to store globally defined metadata types (branch, label, attribute, elements and hyperlinks). See here for more.

Example of resolution (here in the case of a global type being a branch):
cleartool unlock vob:\ClientVOB
cleartool describe -long vob:\ClientVOB
 Hyperlinks:
   AdminVOB@53@\ClientVOB -> <object not available>
cleartool describe -local -long brtype:MyBranch@\ClientVOB
GlobalDefinition@54@\ClientVOB -> <object not available>
cleartool checkvob -hlink vob:\ClientVOB
cleartool describe -local -long brtype:MyBranch@\ClientVOB
cleartool checkvob -hlink brtype:MyBranch@\ClientVOB
cleartool mkhlink AdminVOB vob:\ClientVOB vob:\AdminVOB3
cleartool mkbrtype -global -acquire MyBranch@\AdminVOB3

Doing all of this can be very lengthy in a case where numerous metadata types are broken, especially when it has to be done in all VOBs.
  This could be scripted to automate the process.

Another cause: technote "Deleted user accounts and ClearCase performance":

A user account that no longer exists, but is still listed in the -nusers option for cleartool lock of a branch can cause a checkout, checkin and merge to fail like:

So if you have a lock on a branch, that can also be an issue.


text:
Q: Setting Maximum Zoom Level kGMSMaxZoomLevel for Google Maps for iOS SDK I am trying out the iOS Google Maps SDK and notice in GMSCameraPosition.h header file there is reference to kGMSMaxZoomLevel to set the maximum zoom level allowed. I'd like to be able to set this but when #defining a value for that in the implementation, XCode states that there are duplicate symbols when doing so, so won't compile. Can someone point me in the right direction for setting the Minimum and Maximum zoom levels using this new SDK?
Many thanks

A: The kGMSMaxZoomLevel is the maximum value which the SDK supports, ie which you can set when creating a GMSCameraPosition. You can't change its value, to make maps stop at a different zoom level.
You could maybe try listening for [mapView:didChangeCameraPosition:], and then if the camera position is more zoomed in than you'd like, move it back out again. I haven't tried this, so I'm not sure if it would work. It might stutter a bit - ie the user will zoom a bit past the max, you'll set it back, then the user will zoom a bit past again, and so on.

A: I know this is an old post, but just for the sake of completeness I am posting this.
Recent version of google maps SDK features -setMinZoom:maxZoom: which should serve your purpose.
Reference link here.

A: func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {

    if position.zoom < 10 {

        let latitude = mapView.camera.target.latitude
        let longitude = mapView.camera.target.longitude

        let mapCamera = GMSCameraPosition.camera(withLatitude: latitude, longitude: longitude, zoom: 10)
        mapView.camera = mapCamera

    }
}


text:
Q: C++ Change address of array element I'm writing a function to combine m x m blocks into an n x n matrix. The blocks are a 3d pointer array B[BlockIndex][BlockRow][BlockColumn], and the n x n matrix is a 2d pointer array M[Row][Column]. If M is 4x4 and B is 4 2x2 matrices then BlockIndex = 0 is the top-left block, BlockIndex = 1 is the top-right, BlockIndex = 2 is the bottom-left, and BlockIndex = 3 is the bottom right.
I'd like to just point elements of M to the beginnings of rows of the appropriate blocks, but I can't seem (nor do I know if it's possible) to set the address of an element [i][j] of M. I can set M[i] to B[BlockIndex][i] so that (using the 2x2 and 4x4 example) the first 2 elements of the ith row of M point to the ith row of the BlockIndex-th block, but how can I point the third element of the ith row of M to the ith row of the (BlockIndex+1)-th block?
I understanding I'm kind of contradicting the idea of contiguous memory here, as I'm taking an array of 4 elements (the ith row of M) that exist side-by-side in memory and trying to break that sequence by pointing the last 2 elements of that array to a different array of 2 elements. However, If I can get away with this then it'll save time when the matrices get huge, since I don't want to resort to deep-copying B to M element-wise. I also realize I may be misusing "deep copy" here...
To clarify, I want to (basically) change the address of elements of an array X that are not the first element to that of (the first element of) a different arrays Y,Z. After this operation, as you iterate of the elements of X you would be accessing different sets of sequential memory, X...Y...Z.
Below is the current incarnation of the function I'm writing to split/combine matrices into/from smaller blocks.
Thanks,
Tim
bool    SplitCombineMat(double** &Mat, double*** &Blocks, int const& MatSize,
                                int const& BlockSize, bool const& SplitMatrix)
{
    bool IsOk = true;

    if (SplitMatrix)
        IsOk = PrepareBlocks(Blocks, MatSize, BlockSize);

    if (IsOk)
    {
        //  Set the beginnings (pointers) of the rows of blocks
        //  to the right elements of Mat.
        //  This is a shallow copy.
        int BlockIndex = 0;
        for (int i = 0 ; i <= MatSize - BlockSize ; i += BlockSize)
            for (int j = 0 ; j <= MatSize - BlockSize ; i += BlockSize){
                for (int k = 0 ; k < BlockSize ; k++)
                    if (SplitMatrix)
                        Blocks[BlockIndex][k] = &Mat[k+i][j];
                    else    //  Here want to use pointers as above but can't figure it out...
                            //  Something like -- &Mat[k+i][j] = Blocks[BlockIndex][k];
                        for (int l = 0 ; l < BlockSize ; l++)
                            Mat[k+i][l] = Blocks[BlockIndex][k][l];
                BlockIndex++;
            }
    }

    return IsOk;
}

A: What you want to do is impossible in C++. As you said, an array is a contigous area of memory and you can't have it continue from another address in the middle.
Also, you can't "change" the address of an array, it's a constant. You can, however, use arrays of pointers but in your case, it wouldn't work either. The only option is to copy the contents of the arrays.
There might be some non-standard vector class which lets you do this, but then your accesses to the arrays will be slow.
I think just copying everything shouldn't be too much of a problem for performance. Most probably, generating the initial blocks (or reading them in) will dominate the copying time. Cheers.


text:
Q: Disappear columns when datagrid.datacontext changed I have some problems with viewing DataGrid (DataGrid is one), when I change it dataContext.
I extract information from sqlite DB and put it into DataTable then I clear DataGrid columns and place new DataTable data into DataGrid, code is here:
sqliteDataAdapter = new SQLiteDataAdapter(query, sqliteConnection);

if (tableFromDB == null)
tableFromDB = new DataTable();

tableFromDB.Reset();

sqliteDataAdapter.Fill(tableFromDB);

dataGrid.Columns.Clear();
dataGrid.DataContext = tableFromDB;

And it's work for one time, when I choose other information from DB and repeat this code I have data (I see it in DataTable ), but number of column = 0 (in DataGrid).

A: When I comment line: dataGrid.Columns.Clear(); I have an exception... But I soleved my problem. After dataGrid.Columns.Clear(); I did it:
foreach (DataColumn col in tableFromDB.Columns)
{
   dataGrid.Columns.Add(
     new DataGridTextColumn
     {
        Header = col.ColumnName,
        Binding = new Binding(string.Format("[{0}]", col.ColumnName))
     });
}

dataGrid.ItemsSource = tableFromDB.Rows;
dataGrid.Items.Refresh();


text:
Q: Is posting the message on Kinesis stream asynchronous? Is posting the message on Kinesis stream asynchronous, or there any way to run it asynchronously using GoLang SDK API?

A: The documentation appears to be pretty thorough about which operations are asynchronous, so I would say no: posting a message is not asynchronous. But that only makes sense anyway--how can it return an error, if the operation hasn't yet completed?
But can you make it asynchronous? Of course. In Go it's trivial to make anything asynchronous--just run it in a goroutine.
If you're new to goroutines, A Tour of Go is a great introduction to the concept.

A: No, it's synchronous.
When you call PutRecord API endpoint, a record is written in Kinesis, and as a response "ShardId" and "SequenceNumber" is returned. That displays where the recorded data is placed upon a stream (shard).
See document: https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html


text:
Q: change the position of my div container based on scroll I am actually styling my app. I have container between my header and footer, when i scroll the page, when the container meets the header i want  the position changed to fixed from relative.
Initial setting :
.div {
        position: relative;
        zoom: 1;
        z-index: auto;
  }

once the div container is new the header i want the position of the div changed to fixed .
.div {
        position: fixed;
        zoom: 1;
        z-index: 1;
        top: 0px;
        padding-top: 10px;
        left: 400px;
    }

how do i achieve this? can any help me.
thank you.

A: Use onscroll for your container:

...

...

You have to use javascript and check if the container meets the header or not:
function onScroll() {
    var content = document.getElementById('content');
    var container = document.getElementById('container');
    var scrollTop = content.scrollTop;
    var elOffsetTop = container.offsetTop;
    var elHeight = container.offsetHeight;
    if ((scrollTop > elOffsetTop)&&(scrollTop<elOffsetTop+elHeight)) {
      content.classList.add("on-top");
    } else {
      content.classList.remove("on-top");
    }
  }

And in css:
.on-top {
  position: fixed;
  ...
}

Here is an example:
https://jsfiddle.net/en7Lf2wz/6/