text:
Q: Understanding kmap on 64-bit Linux Let me start by admitting that the concept of high memory and low memory on Linux is still not completely clear in my mind even after reading several relevant resources. However, from what I understand on 64-bit Linux there's no high memory anyway (correct me if I am wrong).
I am trying to understand how kmap and address spaces work on Linux kernel version 5.8.1 configured with defconfig for arm64.
I have added the following system call:
SYSCALL_DEFINE1(mycall, unsigned long __user, user_addr)
{
    struct page *pages[1];
    int *p1, *p2;

    p1 = (int *) user_addr;
    *p1 = 1; /* this works */
    pr_info("kernel: first: 0x%lx", (long unsigned) p1);

    if (get_user_pages(user_addr, 1, FOLL_WRITE, pages, NULL) != 1)
        return -1;

    p2 = kmap(pages[0]);
    *p2 = 2; /* this also works */
    pr_info("kernel: second: 0x%lx", (long unsigned) p2);

    return 0;
}

From user-space I allocate a whole memory page (on a page boundary) which I pass to the kernel as a parameter to that system call. Modifying that memory by dereferencing either pointer from within the kernel works perfectly fine. However, the two pointers have different values:
[    4.493480] kernel: first: 0x4ff3000
[    4.493888] kernel: second: 0xffff000007ce9000

From what I understand get_user_pages returns the physical page corresponding to that user address (in current's address space). Then since there's no high memory, I expected kmap to return the exact same address from the user part of the address space.
According to the virtual memory layout of arm64, the address returned by kmap lies in a range described as "kernel logical memory map". Is this a new mapping just created by kmap or is this another previously existing mapping for the same page?
Can somebody explain what exactly is going on here?

A: The memory referred to by user_addr (or p1) and by p2 will be the same physical memory pages once they have actually been pinned into physical memory by get_user_pages(). (Before the get_user_pages() call, the pages might not be in physical memory yet.) However, user_addr (and p1) are a user-space address of the page, and p2 is a kernel-space address of the page. kmap() will create a temporary mapping of a physical memory page to kernel-space.
On arm64 (and also amd64), if bit 63 is treated as a sign bit, then user-space addresses are non-negative and kernel space addresses are negative. So there is no way that the numeric values of the user-space and kernel-space addresses can be equal.
Most kernel code should not dereference user-space pointers directly. The user-space memory access functions and macros should be used, and should be checked for failures. The first part of your example should be something like:
    int __user *p1 = (int __user *)user_addr;

    if (put_user(1, p1))
        return -EFAULT;
    pr_info("kernel: first: 0x%lx\n", (unsigned long)p1);

put_user() will return 0 on success or -EFAULT on failure.
get_user_pages() will return either the number of pages pinned into memory, or a negative errno value if none of the requested pages could be pinned. (It will only return 0 if the number of requested pages is 0.) The number of pages actually pinned may be less than the number requested, but since your code only requests a single page, the return value in that case would be either 1 or a negative errno value.  You can use a variable to capture the error number. Note that it must be called with the current task's mmap semaphore locked:
#define NR_REQ 1

    struct page *pages[NR_REQ];
    long nr_gup;

    mmap_read_lock(current->mm);
    nr_gup = get_user_pages(user_addr, NR_REQ, FOLL_WRITE, pages, NULL);
    mmap_read_unlock(current->mm);
    if (nr_gup < 0)
        return nr_gup;
    if (nr_gup < NR_REQ) {
        /* Some example code to deal with not all pages pinned - just 'put' them. */
        long i;

        for (i = 0; i < nr_gup; i++)
            put_page(pages[i]);
        return -ENOMEM;
    }

Note: You could use get_user_pages_fast() instead of get_user_pages(). If get_user_pages_fast() is used, the calls to mmap_read_lock() and mmap_read_unlock() above must be removed:
#define NR_REQ 1

    struct page *pages[NR_REQ];
    long nr_gup;

    nr_gup = get_user_pages_fast(user_addr, NR_REQ, FOLL_WRITE, pages);
    if (nr_gup < 0)
        return nr_gup;
    if (nr_gup < NR_REQ) {
        /* Some example code to deal with not all pages pinned - just 'put' them. */
        long i;

        for (i = 0; i < nr_gup; i++)
            put_page(pages[i]);
        return -ENOMEM;
    }

kmap() will temporarily map a page into kernel address space. It should be paired with a call to kunmap() to release the temporary mapping:
    p2 = kmap(pages[0]);
    /* do something with p2 here ... */
    kunmap(p2);

Pages pinned by get_user_pages() need to be 'put' using put_page() when finished with.  If they have been written to, they first need to be marked 'dirty' using set_page_dirty_lock(). The last part of your example should be something like:
    p2 = kmap(pages[0]);
    *p2 = 2; /* this also works */
    pr_info("kernel: second: 0x%lx\n", (unsigned long)p2);
    kunmap(p2);
    set_page_dirty_lock(pages[0]);
    put_page(pages[0]);

The above code is not completely robust.  The pointer p2 could be misaligned for the *p2 dereference, or *p2 could straddle a page boundary. Robust code needs to deal with such situations.
Since accessing the memory through user-space addresses needs to be done through special user-space access functions and macros, may sleep due to page faults (unless the pages have been locked into physical memory), and are only valid (if at all) within a single process, locking the user-space address region into memory with get_user_pages() and mapping the pages to kernel address space (if required) is useful in some circumstances. It allows the memory to be accessed from an arbitrary kernel context such as an interrupt handler. It allows bulk copies to and from memory mapped I/O (memcpy_toio() or memcpy_fromio()). DMA operations can be performed on user-memory once it has been locked down by get_user_pages(). In that case the pages will be mapped to "DMA addresses" by the DMA API.


text:
Q: Heroku Build keeps failing, node issue? Heroku asks that I specify version in package.json, which I have done:
"engines": {
    "node": "16.16.0",
    "npm": "8.11.0"
  }

I would normally have put the x after version, but read that specifying the exact version may help.
Below are the errors I get with the build:
-----> Build
remote:        Detected both "build" and "heroku-postbuild" scripts
remote:        Running heroku-postbuild
remote:
remote:        > wino@1.0.0 heroku-postbuild
remote:        > npm run build
remote:
remote:
remote:        > wino@1.0.0 build
remote:        > cd client && npm run build
remote:
remote:
remote:        > wino@0.1.0 build
remote:        > react-scripts build
remote:
remote:        Creating an optimized production build...
remote: Error: error:0308010C:digital envelope routines::unsupported
remote:     at new Hash (node:internal/crypto/hash:71:19)
remote:     at Object.createHash (node:crypto:140:10)
remote:     at module.exports (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/util/createHash.js:90:53)
remote:     at NormalModule._initBuildHash (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:401:16)
remote:     at handleParseError (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:449:10)
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:481:5
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:342:12
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:373:3
remote:     at iterateNormalLoaders (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
remote:     at iterateNormalLoaders (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:236:3
remote:     at runSyncOrAsync (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
remote:     at iterateNormalLoaders (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
remote:     at Array.<anonymous> (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
remote:     at Storage.finished (/tmp/build_25ff6fd3/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
remote:     at /tmp/build_25ff6fd3/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9
remote: /tmp/build_25ff6fd3/client/node_modules/react-scripts/scripts/build.js:19
remote:   throw err;
remote:   ^
remote:
remote: Error: error:0308010C:digital envelope routines::unsupported
remote:     at new Hash (node:internal/crypto/hash:71:19)
remote:     at Object.createHash (node:crypto:140:10)
remote:     at module.exports (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/util/createHash.js:90:53)
remote:     at NormalModule._initBuildHash (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:401:16)
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:433:10
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:308:13
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:367:11
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:233:18
remote:     at context.callback (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
remote:     at /tmp/build_25ff6fd3/client/node_modules/babel-loader/lib/index.js:51:103 {
remote:   opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
remote:   library: 'digital envelope routines',
remote:   reason: 'unsupported',
remote:   code: 'ERR_OSSL_EVP_UNSUPPORTED'
remote: }
remote:
remote: Node.js v19.2.0
remote:
remote: -----> Build failed

Also, I have been getting errors about upgrading the stack to Heroku-22. I was working on that, but it seems to be trying to build to that stack anyway so I don't think that's the issue.
Thanks in advance for the help!

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to change the real value of Complex array elements in c++ Hey I have a Complex double array and I want to change the values of it from another basic float array, so basically I want to copy all the float array values into the real value of each complex element.
I tried to iterate in a for loop and copy the value but I get errors such lvalue required as left operand of assignment
Here is my code:
typedef std::complex<double> Complex;

const Complex test[] = { 0.0, 0.114124, 0.370557, 0.0, -0.576201, -0.370557, 0.0, 0.0 }; // init the arr with random numbers

for ( i = 0; i < N; i++ )
{
    printf ( "  %4d  %12f\n", i, in[i] );
    test[i].real() = in[i]; // this line returns an error
}

can someone please let me know what the correct way of doing so as I'm new to this subject.

A: There are two issues with your code:

*

*You cannot assign to the result of calling std::complex::real() - it returns a value, not a reference.  You need to use the void real(T value); overload instead, see: https://en.cppreference.com/w/cpp/numeric/complex/real.

*test is declared const so you cannot assign to it in any case
To fix these issues, change your code to this:
typedef std::complex<double> Complex;

Complex test[] = { 0.0, 0.114124, 0.370557, 0.0, -0.576201, -0.370557, 0.0, 0.0 };

for (int i = 0; i < N; i++ )
{
    printf ( "  %4d  %12f\n", i, in[i] );
    test[i].real (in[i]);
}


text:
Q: Why is LabView converting decimals into tiny floating point numbers? UPDATE: It turns out it was just LabView messing up. Even ints weren't coming through properly. Deleting and recreating some of the nodes solved the problem.
I wrote a .Net 3.5 assembly which is being consumed by a LabView engineer. It's at least LabView 7, but I think higher. A method in my assembly is returning an array of objects where each instance has a property of type decimal (among other things). The LabView engineer is doing nothing particular fancy, and is just dumping the sequence to the front-end of the VI, and each of these decimal properties look like very tiny floating point numbers. The actual decimal might be 740.0, but it gets seen in LabView as a double, with a value like 8.12345E-315. That's off by quite a few orders of magnitude!
The string and boolean properties are coming through just fine.
Any idea why this is happening?
EDIT: We tested this using a very simple class with some decimal fields and properties, and it worked perfectly fine in LabView. There's something fishy going on with this one DLL, so we're trying some other tests to see if we can replicate the issue using a different DLL.
Here is a screenshot of some endian-changing tests. Swapping the endian type of the properties of our simple test class produced the same values. Swapping the endian type of the decimals from the real class library just produces different tiny floats.
http://i.imgur.com/WpZ8bYX.jpg

A: A LabVIEW double is a 64-bit float in Big Endian (because of its Mac heritage). Your decimal might be something different.
If you want to fix it on the LabVIEW side you can use the following code:

Perhaps he should need to alter the conversion constants around.

A: It smells like a bad cast, LabVIEW believing the decimal is a double or single precision floating point number. You should explicitly convert the decimal to a standard floating point, before passing it to LabVIEW. Note that you'll lose digits of precision. Or, find a numeric type that matches the precision of decimal in LabVIEW and make the proper conversion.

A: Here's a work-around I could do:
Make an adapter class that changes the interface to use a well-supported data type like double, and then use this adapter class in LabView instead of the original class.

A: Try deleting and recreating the property access nodes. Sometimes LabView gets confused and messes up the data.


text:
Q: Cocoapod - Command /bin/sh failed with exit code 23 I recently uploaded a new cocoapod of mine, and I was trying to test it. But when I opened up .xcworkspace and ran it...I got an error:
".../APMultiMenu.bundle" failed: No such file or directory (2)
done

sent 29 bytes  received 20 bytes  98.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]
Command /bin/sh failed with exit code 23

Also I noticed in my Products folder (under Pods), it says there is a file APMultiMenu.bundle, but it is red so it is missing. But what I dont understand is why the .bundle file is even there, because it should not be there? Can someone help


text:
Q: Generate random numbers between two numbers public class TestSample {
    public static void main(String[] args) {

        int a = Integer.parseInt(args[0]);
        int b = Integer.parseInt(args[1]);

        double ran = Math.random();

    }
}

I don't want to use Random r = new Random(); class. Is there any other way to generate random numbers. I am just struck with what logic could be applied to generate random numbers between two numbers.

A: It's really easy... you only need to figure out which is the minimum value and what is the difference between the two numbers (let's call it diff). Then, you can scale the Math.random value (between 0 and 1) by multiplying by diff (now its range is between 0 and diff). Then, if you add the minimum value, your range is between min and min + diff (which is the other value)
int min = min(a,b);
int max = max(a,b);

int diff = max - min;

int result = min + diff * Math.random();

A: Consider using this code:
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
double ran = Math.random();
double random;

if(a < b)
    random = (b-a)*ran + a;
else
    random = (a-b)*ran + b;

This will work for a >= 0 and b >= 0 if you consider using negative number the logic sligtly changes

A: If you are expecting a double result, the simplest approach is
int a =
int b =
double result = (a-b)*Math.random() + b;

It doesn't matter which is greater as you get the same distribution.
However, if you want a random integer between 'a' and 'b' is a bit more complex.
int a =
int b =
int result = Math.floor((Math.abs(a-b)+1) * Math.random()) + Math.min(a, b);

The reason the result is different is that a random double between 0 and 1 will be just less than 1 i.e. [0.0, 1.0) However a random integer between 1 and 6 usually includes 1, 2, 3, 4, 5, 6 equally. As a decimal this is the round down of [0.0 ... 7.0)

A: You may get white noise from your microphone, and take any number from there. After that you may take any number from the given data, and do with it what you want. The example of getting data from the microphone can be found here.


text:
Q: Ejecutar nuevo task desde start date en airflow Buenas el caso es que si disponemos de un DAG que esta ejecutado por ejemplo desde 2022.01.01 (start_date) e incorporamos una nuevo task hoy, este se ejecuta desde su incorporación en adelante.
La duda es ¿Cómo se podría hacer para que ese task se ejecutara desde el start date?
La idea es que no bloquee las ejecuciones diarias del dag, tomando todas las run disponibles para la task nueva en cuestion.
La intención es evitar crear un nuevo dag que recorra solo ese task desde inicio rellenado en segundo plano, lo ideal seria incorporar un relleno de datos desde el start date en el mismo Dag.


text:
Q: Making a copy of a site I was tring to make a copy of this site using html and css for practise
https://www.raidhqgame.com/
But I found some problems while using padding in the menuArea div.
HTML

        HOME
        FEATURES
        VIDEO & SCREENS
        REVIEWS
        DOWNLOAD
        HELP
        EPS

CSS
body{
    margin:0;
    padding:0;
}
.head1{
    height:60px;
    background:black;
}
.logoArea{
    float:left;
    width:40%
}
#logo{
    height:40px;
    padding:10px 0px 10px 110px;
}
.menuArea{
    display:block;
    float:right;
    width:60%;
}
a:link{
    text-decoration:none;
    color: green;
    font-family: "Poppins",sans-serif;
    font-weight:bold;
    font-size:12px;
    letter-spacing: 1px;
}

The problem: when I add padding to the menuArea div the menuArea jumps down. And also there is a gap between "head1" class and "background_img" class.
How can I resolve these two issues?

A: I think you might get the desired effect by adding padding to the head1 div instead of the menuArea.
Here is your updated code: https://jsfiddle.net/ntb7nt39/
CSS
.head1{
    height:60px;
    background:black;
    padding: 20px; // You should change this value to whatever you want
}

'And also there is a gap between "head1" class and "background_img" class.' I could not recreate that gap.
UPDATE
'I want to have padding for the menu section. Not the whole head1.'
I updated the code: https://jsfiddle.net/ntb7nt39/1/
CSS
.head1{
    height: 80px; // Increased height to make space for the navigation bar
    background:black;
}

.menuArea{
    display:block;
    float:right;
    width:60%;
    padding: 20px 0; // Added padding at the top and bottom of the navigation bar, change these values according to your needs.
}

A: *

*You can just remove the width=60% from class menuArea and than you will be able to add any kind of padding or

*use top and bottom padding only, no left right padding because you covered the full 100% width by setting 40% 60% and when you add left right padding to it increases the width which leads to this issue.

and for second issue add height:100% to logoArea class.


text:
Q: Dynamically add navigations to the masterpage using Javascript I am getting a list of data, using javascript while loading the home page.
Eg:
[Accounts","Transactions","Amounts","Requests]
And I need to add above list of data to the navigation bar which includes in the master page.
Eg: Navigation Bar

A: this is very simple. Suppose you have the menu on your master page is UL/LI based menu with an ID "ul"

then you should write following javascript code on your child page to add menu items dynamically


text:
Q: SSRS: bracketed identifier missing closing Let me preface this that I am not a developer and I don't normally work in SSRS.
I am receiving Textbox16.Paragraphs[0].TextRuns[0] contains an error:
[BC30034] Bracketed identifier is missing closing ']'.

The expression in Textbox16 is
=IIF(ReportItems!Pallets.Value=0,[Sum(NumUnits)]*ReportItems!FloorLocations.Value,[Sum(NumUnits)]*ReportItems!Pallets.Value)

I tried just =[Sum(NumUnits)]*ReportItems!FloorLocations.Value and get the same error.
What am I missing?

A: I actually tried something different and used the ReportItem name that corresponds to [Sum(NumUnits)]. No more error.

A: SSRS is expecting an identifier name between the [ and ], not an expression. Instead of [Sum(NumUnits)] you should use Sum([NumUnits]), putting only the identifier name in the brackets and then summing that.
Alternatively, if NumUnits is a field, just reference it from the Fields collection:
Sum(Fields!NumUnits.Value)


text:
Q: Connect SSH Tunnel with the Java Desktop program (.jar) to remote server I developed a JavaFx Desktop program the employees of the company. Now, they want to use the program in their houses with their own personal computers. The program has MySQL and FTP services.
I need to use SSH Tunnel or VPN so that the program can connect from outside to the remote server in the office(port forwarding for FTP and MySQL).
If I want to use SSH Tunnel I have to install(or copy/paste) the certificates in the own employees' computers and I think that this option is dangerous because of the certificates can be engaged to attacks of their computers.
Sometimes I have thought to create one certificate for each employee (100 people) to control better who is connected in each time, but it's too much laborious to maintain.
I would like to use SSH Tunnel but I don't know if the best option in this situation.
What other options can I use to connect my program to remote server securely?

A: There aren't a lot of protocol choices - whatever you choose needs to be:

*

*Auditable - no sharing of credentials

*Secured - to limit risk of traffic interception/MitM

*Manageable - if you've 100+ employees.

You could use SSH, but setting up a VPN is what most business do (in my experience). You can then only allow VPN connections through the firewall and nothing else needs to change.
Your best bet is to look into a small business VPN device. A quick search here brings up lots of (off-topic) posts asking for recommendations.
Long story short, whatever you use you're going to have to create and issue a cert or key to every employee. The only sensible way to do this is using script or management tool.

A: As you mentioned I would authorize the employees with the private key from the generated public/private rsa key pair for ssh connection to the office server. You can store the public key in ~/.ssh/authorized_keys and secure the private key with passphrase so that the employee can connect to server. But you must open the ssh port in the firewall for outside.


text:
Q: Is there a way to add arrow from a token/word to another in graphviz? I'm wondering if it's possible to create something like this usint graphviz, where an arrow points from a token/word to the other, instead of a node.

A: It is possible to simulate (a lot of things) with tables, though it's usually very ugly in source code:
digraph  {
    node [shape=plain]
    node1 [
        label=<

foo bar

>
    ]
     node2 [
        label=<

baz qux

>
    ]

    node1:label:n -> node2:label:n [constraint=false]
}

Result:

What I did here:

*

*I used a plain node shape and HTML-like label syntax to create a table:

node [shape=plain]
node1 [
    label=<>
]

*I added 3 rows for my table, first and last one being empty:

foo bar

*The middle row contains the actual label. Also, to be able to point an edge to specific cell I've added a port to it: foo bar	.

*Finally when defining an edge I've specified the ports to be connected (documentation on ports):
node1:label:n -> node2:label:n


text:
Q: Transfer an EDI or XML document from one machine to another machine through AS1 or AS2 or AS3 protocol I want to write a simple java program to transfer an EDI or XML document from one machine to another machine using the AS1 or AS2 or AS3 protocol.
Can anyone help me to get started with it?

A: The latest updates to OpenAS2 have just been released and includes fairly documentation which should help anyone reading this to better understand setting up and using the OpenAS2 application from sourceforge

A: All three use different transport layers (SMTP, HTTP, FTP).  AS2 would probably be easier.
This should put you in the right direction:
http://sourceforge.net/projects/openas2/
You would need it on both machines - to listen and send.  Also MDNs would need to be considered.  AS2 is a good fit for B2B, but the way your question is worded, that makes it seem like its not the case (machine to machine - on the same network), in which case it probably isn't the most efficient method of transferring files.

A: OpenAs2 would be a good choice. I have recently did some configurations on OpenAS2 to do the file transferring. If you have any questions on installing, configuring, applying certificates, running the OpenAS2 server on both Windows and Linux, I may be able to help you.

A: There is a few more free solutions for AS2:

*

*If you are not an EDI provider and only one trading partner is
enough, you may try RSSBus AS2 connector. It has web-interface
and easy to start.

*There is also an opensource version of Mendelson
AS2 with Swing GUI and a lot of features.

Both of them are not as flexible as OpenAS2, but have their own features and disadvantages.


text:
Q: VirtualBox VM lags after increasing the numbers of CPUs the VM has allocated to it I have a VirtualBox VM running Windows 10 on Windows 10.
My host computer specs:
Device name _______________
Processor   Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz   1.80 GHz
Installed RAM   8.00 GB (7.88 GB usable)
Device ID               ______________________________________
Product ID  ________________________
System type 64-bit operating system, x64-based processor
Pen and touch   Pen and touch support with 10 touch points

My guest VM specs are:

*

*RAM: 3040MB

*CPU: 1 Processor

*Execution Cap: 100%

*GPU Memory: 256MB

*3D Acceleration: Enabled

I have VirtualBox's Guest Additions installed in my guest OS. With these specs, it runs pretty smooth, but when I click buttons on the PC, it takes time to load. When I change the number of processors to 3, it got dramatically laggy.

How can I improve the performance of my VM?

A:
When I change the # of processors to 3, it got dramatically laggy.

Guest slows with more CPUs

No, you're not doing anything wrong, and yes, adding processors will
make a guest go slower. There's overhead in the CPU load needed to
keep track of instructions in a multi-processor guest, and the more
processors the more overhead.

Host machine (i5 8GB) is just adequate, so Guest machines will not be speedy.
Try using 2GB for the Guest machine as a test.
Check the speed of your host hard drive.  5400-rpm will be very slow for virtual machine use. A 7200-rpm drive is workable (my X230 has a 7200-rpm drive). A fast SSD will work well. My production Thinkpad has a fast drive.

A: In a comment elsewhere, VirtualBox expert "mpack" writes:
In real life, a lot of operations are disk-bound or network-bound.  Only a minority of operations are CPU-bound.
The more cores you create for your VM, the more overhead these cores will cause (due to context switches).
In practice, the ideal choice is usually to assign two cores to each VM.
If you need to run CPU-intensive tasks all day, such as video encoding, don't run these tasks in a VM.  Run them on the host OS:  they'll run faster there.

A: I would check that the appropriate storage driver is used. AFAIK virtio drivers are not included in virtualbox extensions for windows yet, so you should install them separately, by mounting the iso from Fedora project.
Then you will be able to switch the "controller" providing your existing virtual harddrive from  SATA to Virtual I/O Device SCSI.
Windows 10/11 really cares about two things, storage speed, and available RAM (at least up to 8GB).
So, for your case I would use the following specifications:
RAM: 4096MB
(Running desktop distributions of Windows 10 on under 4GB of ram is qualitatively different (literally triggers some different code paths) than running it on 4 or more. It's practically in "survival mode", which makes it rely on other resources liek CPU and storage more instead of having things cached.)
vCores: 2
(Otherwise you are starving your host system, which has to keep the virtual devices of the VM fed as well, which one core will definitely not be enough for, especially when it's competing with all of the other process on the host OS)


text:
Q: Use create-react-app behind corporate firewall there is any way for work with create-react-app behind corporate firewall by setting a proxy.
i have setted the proxy on npm and yarn, but this is what i see when try to create-react-app my-app:
Creating a new React app in F:\react\my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

You appear to be offline.
Falling back to the local Yarn cache.

yarn add v0.23.4
info No lockfile found.
[1/4] Resolving packages...
error Couldn't find any versions for "react" that matches "latest" in our cache. Possible versions: ""
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact --offline react react-dom react-scripts has failed.

Deleting generated file... package.json
Deleting my-app / from F:\react
Done.

A: I have had this issue as well, and I solved this with this command:
create-react-app hello-world --use-npm --cache /tmp/empty-cache

A: As a workaround, try first running yarn add react react-dom react-scripts in an empty folder.  This will add the required packages to yarn's local cache.  You can then delete that folder and run create-react-app my-app again and it will hopefully work.

A: Update: Looks like this bug has now been fixed, and should no longer be present in version 1.1.0.

This problem is caused by the fact that the yarn registry is hard-coded in react-scripts to registry.yarnpkg.com: https://github.com/facebookincubator/create-react-app/blob/master/packages/create-react-app/createReactApp.js#L692
As per this pull request, if the yarn registry is not reachable, then it will check to see if you have the https_proxy environment variable set, and then if so it will verify that that server is reachable, instead of the hard-coded yarn registry.
To reiterate, it's not enough to set the proxy/https-proxy configs in npm/yarn - you also need to set the https_proxy environment variable, because that's what create-react-app will check when determining if you are online. For example:
https_proxy=https://my.corporate.proxy create-react-app my-new-project

A: I had been struggling with this for weeks. What worked for me was to include --use-npm at the end of the command and finally I got rid of the "no lockfile found" error. I sincerely hope this helps someone else struggling with the same issue.

A: This solved my problem - See details
npm config set registry "https://registry.npmjs.org"

A: These settings solved it for me:
npm config set proxy http://username:password@host:port
npm config set https-proxy http://username:password@host:port


text:
Q: How to check what the current users role is How do I check in C# what the current users role is, and print it to the screen.
Thanks!

A: The most general method is to get an IPrinciple and then call IsInRole() on it. How you get the Principle denpends on your runtime environment. This example works well for apps running under the user's account.
Example:
    static void PrintIsInAdministrators()
    {
        // There are many ways to get a principle... this is one.
        System.Security.Principal.IPrincipal principle = System.Threading.Thread.CurrentPrincipal;
        bool isInRole = principle.IsInRole("MyDomain\\MyRole");
        Console.WriteLine("I {0} an Admin", isInRole ? "am" : "am not");
    }

A: You can use Roles.GetRolesForUser() method to get all the rols user belong to . use it like this;
string[] rolesuserbelongto = Roles.GetRolesForUser();

you will have all roles in string array.
you can even pass a UserName as a parameter to get the roles for that particular User like this:
string[] rolesuserbelongto = Roles.GetRolesForUser("Shekhar_Pro");

A: Roles.GetRolesForUser(); gave me the error The Role Manager feature has not been enabled.
If you are using ASP.NET Identity UserManager you can get it like this:
var userManager = Request.GetOwinContext().GetUserManager<ApplicationUserManager>();

var roles = userManager.GetRoles(User.Identity.GetUserId());

If you have changed key for user from Guid to Int for example use this code:
var roles = userManager.GetRoles(User.Identity.GetUserId<int>());

A: string[] userroles = Roles.GetRolesForUser(Page.User.Identity.Name);
foreach(var role in userroles)
{
Response.Write(role);
}

A: This is what you are looking for:
@if (Request.IsAuthenticated)
{
    if (User.IsInRole("Admin"))
    {
      <h1> I only show this text to admin users </h1>
    }
}

Note: You can check the roles defined in your AccountController.cs file, if you have one implemented.

A: You can use user manager for that purpose:
 var userRoles = await _userManager.GetRolesAsync(user);

A: Not entirely sure of you question.
You can do:
this.User.IsInRole();
//loop and check whether the user is in your role.

this would correspond to a page class, so you can write the above code only inside a page and this.User returns an IPrincipal.


text:
Q: how to construct a php variable containing html code and php code in a php page that is called by ajax $table="

    FIRST NAME
    LAST NAME
    EMAIL
    GENDER	".
    while($row = mysql_fetch_array($result3))
    {
        $action="Action";
        $var=$action.$count;
         ."" .$var. "	".
        $count=$count+1;

    }

    ."
".

    while($row = mysql_fetch_array($result2))
    {

         ."
".
         "".$row['firstname']."	".
         "".$row['lastname']."	".
         "".$row['email']."	".
        if($row['gender']=='m')
        {
            $gend='male';
        }
        else
        {
            $gend='female';
        }
         "".$gend."	".

        $result3=$db->selectUserPermission($uid);
        $id=$row['userid'];
        $loginuser=$_SESSION['LOGINUSER'];
        while($row = mysql_fetch_array($result3))
        {

              ."".
            if($row['permid']==1)
            {
                $permission="VIEW";
                $btnid=$id."_VIEW";
                 ."<button id=$btnid name=$btnid onclick='getFunctionView($id)'>".$permission."</button>".
            }
            else  if($row['permid']==2)
            {
                $permission="EDIT";
                $btnid=$id."_EDIT";
                 ."<button id=$btnid name=$btnid onclick='getFunctionEdit($id)';>".$permission."</button>".
            }
            else  if($row['permid']==3)
            {
                if($id!=1 || $id!=$loginuser)
                {
                $permission="DELETE";
                $btnid=$id."_DELETE";
                 ."<button id=$btnid name=$btnid onclick='getFunctionDelete($id)';>".$permission."</button>".
                }
            }
            else  if($row['permid']==4)
            {
                if($id!=1)
                {
                $permission="PERMISSION";
                $btnid=$id."_PERMISSION";
                 ."<button id=$btnid name=$btnid onclick='getFunctionPermission($id)';>".$permission."</button>".
                }
            }
            else  if($row['permid']==5 && $loginuser==$id)
            {
                $permission="ADD USER";
                 ."<button id=$btnid name=$btnid onclick='location.href=\"adduser.html\"'>".$permission."</button>".
            }
            else
            {
            }

             ."	".
        }
    }
     ."

";
     echo $table;

This is a code from a php page that is called by ajax.Here $result2 and $result3 are 2 result sets obtained using 2 sql queries.I want generate a table using theese two results and store that table into a php variable $table and in ajax ,i want to assign it directly as a html text,ajax code is shown below.
   $(document).ready(function(){

    var temp='getUser';
    $.ajax ({
                type:'GET',
                url: 'listdetails.php',
                data:{ud:temp},
                success:function(data)
                        {
                            document.getElementByID("userList").innerHTML=data;
                        }

           });

});
And my problem is in creating php variable $table.It is showing error in every concatination( "." ).this is the error message "Parse error: syntax error, unexpected T_WHILE in C:\wamp\www\listdetails.php on line 39".Can any one suggest a good method for making php variable $table.and remember that this $table is in php page called by ajax.

A: You're using the concatenations wrong.

*

*Don't concatenate a variable assignment ($someVar = ) with a conditional (if) or loop (while) statement

*Don't put a . after a ; or } because these characters terminate the previous command and you can't start the next command with .

Here's a reworked version of the first part of your code to get you started:
$table="

FIRST NAME
LAST NAME
EMAIL
GENDER	";

while($row = mysql_fetch_array($result3))
{
    $action="Action";
    $table.="" .$action.$count. "	";
    $count++;
}

$table .= "
";

A: $sTable = '

';

while( false ) {
 $sTable .= '';
}

$sTable .= '

';

echo $sTable;

Or as I would do
$sBuffer = '';
while( code goes here ) {
 $sBuffer .= '

';
}

echo '

 ' . $sBuffer . '

';

A: Considering all you want to do is echo the table, I would end/start PHP only when I need it. The cleaned code is below.

FIRST NAME
LAST NAME
EMAIL
GENDER
<?php
while($row = mysql_fetch_array($result3))
{
        $action="Action";
        $var=$action.$count;  //$count is not defined yet in your example, first time will be ''
        echo "" .$var. "	";
        $count=$count+1;
}
?>

<?php
while($row = mysql_fetch_array($result2))
{
    ?>

    <?php echo $row['firstname']; ?>
    <?php echo $row['lastname']; ?>
    <?php echo $row['email']; ?>
    <?php echo (($row['gender']=='m') ? 'male' : 'female'); ?>

    <?php
    $result3=$db->selectUserPermission($uid);
    $id=$row['userid'];
    $loginuser=$_SESSION['LOGINUSER'];
    while($row = mysql_fetch_array($result3))
    {
        echo "";

        switch ($row['permid']) {
            case 1:
                $permission="VIEW";
                $btnid=$id."_VIEW";
                echo "<button id=$btnid name=$btnid onclick='getFunctionView($id)'>".$permission."</button>";
                break;
            case 2:
                $permission="EDIT";
                $btnid=$id."_EDIT";
                echo "<button id=$btnid name=$btnid onclick='getFunctionEdit($id)';>".$permission."</button>";
                break;
            case 3:
                if($id!=1 || $id!=$loginuser)
                {
                    $permission="DELETE";
                    $btnid=$id."_DELETE";
                     echo "<button id=$btnid name=$btnid onclick='getFunctionDelete($id)';>".$permission."</button>";
                }
                break;
            case 4:
                if($id!=1)
                {
                    $permission="PERMISSION";
                    $btnid=$id."_PERMISSION";
                    echo "<button id=$btnid name=$btnid onclick='getFunctionPermission($id)';>".$permission."</button>";
                }
                break;
            case 5:
                if($loginuser==$id)
                {
                    $permission="ADD USER";
                    echo "<button id=$btnid name=$btnid onclick='location.href=\"adduser.html\"'>".$permission."</button>";
                }
                break;
        }

        echo "	";
    }
}
?>


text:
Q: Using Recyclerviews inside nestedscrollview is causing speed issue I am using 2 recyclerviews inside nestedscrollview, but after items loaded, app is very slow.
it's not scrolling smooth
I tried to optimize images and views, but it didn't help at all.
<androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="@color/md_grey_100"
            android:clickable="true"
            android:fillViewport="true"
            android:focusable="true"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toBottomOf="@id/layout_toolbar">

            <androidx.appcompat.widget.LinearLayoutCompat
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
                      <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/rv_service_types"
                    android:layout_width="match_parent"
                    android:layout_height="42dp"
                    android:layout_marginTop="8dp"
                    android:nestedScrollingEnabled="false" />

                          <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/rv_stores"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="8dp"
                    android:nestedScrollingEnabled="false" />

    </androidx.appcompat.widget.LinearLayoutCompat>

     </androidx.core.widget.NestedScrollView>

A: You should avoid using RecyclerView inside NestedScrollView if you have big number of items in RecyclerView
If it's items consist images from online, it's causing much laggings and delays
Instead using different RecyclerViews, try to use one.
In this case, you should define different viewtypes for Adapter.
class YourAdapter(){
override fun getItemViewType(position: Int): Int {
    return when (position) {
       x-> xx
       y-> yy
    }
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
    return when (viewType) {
        xx-> YourFirstViewHolder
        yy ->YourSecondViewHolder
    }
}


text:
Q: What is purpose of 'else' block after try-except? While learning python, I have read questions regarding my one but I could not get why such implementation is done by python.
Case-1: Exception is thrown & sd is set to 45
try:
    raise ValueError()
    sd = 45
except(OSError):
    sd = 50
else:
    sd = 23

Case-2: Exception is handled by except & sd is set to 50
try:
    raise ValueError()
    sd = 45
except(ValueError):
    sd = 50
else:
    sd = 23

Case-3: No error is occurred then else will be executed & sd is set to 23
try:
    sd = 45
except(ValueError):
    sd = 50
else:
    sd = 23

We always wish that our code must work & if error is thrown it should be handled. But why else play role here that, if code in try block have no error then run this.
Please suggest if I misunderstood, missed or misdirected.

A: I recommend checking out https://docs.python.org/3/tutorial/errors.html - There's an entire section on this:

The try … except statement has an optional else clause, which, when present, must follow all except clauses. It is useful for code that must be executed if the try clause does not raise an exception. ....

@Edit To elaborate on this - The point of else is when you do something that you think might error (like, opening a file that might not exist), you can put the code utilizing that file in the else statement rather than within try, allowing you avoid catching an exception not raised by your try statement (ie, what if something completely unrelated to opening the file broke in your usage of the file?)


text:
Q: Execute Immediate Statement issue - Variable field name and table name Hi there I am trying to build a function to reset a sequence to synch with table ID's which have gotten out of synch with the sequence.  Function is as follows:
 create or replace
 FUNCTION P_FNC_SEQUENCERESET(sourceTable IN VARCHAR2, idField IN VARCHAR2, seqname VARCHAR2) RETURN NUMBER
 IS
 ln NUMBER;
 ib NUMBER;
 maxId NUMBER;
 newValue NUMBER;
 diffValue NUMBER;
 interimValue NUMBER;
 sqlStmt VARCHAR2(2000);

 BEGIN

 -- Get the maximum of the id field
 EXECUTE IMMEDIATE 'SELECT MAX(' || idField || ') INTO ' || maxId || ' FROM ' || sourceTable;

 ...code continues...

My understanding of the EXECUTE IMMEDIATE statement leads me to believe that this should be possible, however when executed I get this error:

ORA-00936: missing expression
  ORA-06512: at "PSALERT_ADMIN.P_FNC_SEQUENCERESET", line 16
  ORA-06512: at line 11

A: It would need to look something like this:
EXECUTE IMMEDIATE 'SELECT ' || idField ||' FROM ' || sourceTable into maxid;

the keyword "into" is not part of the string that is dynamically executed, but it is part of the syntax of the "execute immediate" statement
https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/executeimmediate_statement.htm


text:
Q: Report matching status of all characters in a phrase with all characters in an alphabet I have the following method in Java:
void searchPhrase(String[] phrase){
        searchResult = new int[phrase.length];
        int j=0, k=0;
        for (int i=0; i<frase.length;i++)
            if (!phrase[i].equals(alphabet[k])){
                System.out.println("\nLetter "+phrase[i]+" was not found when comparing it to "+alphabet[k]);
                k++;
            }
            else{
                System.out.println("\nLetter "+phrase[i]+" was found when comparing it to "+alphabet[k]);
                searchResult[j] = i;
                k=0;
            }
    }

I have two String arrays, phrase and alphabet. Phrase is any given phrase, and alphabet contains the alphabet from A to Z.
I need the method to receive a phrase, let's say: "HELLO STACK". Then, it must compare every letter to the alphabet, like this:
   H == A? No.
   H == B? No.
...
   H == H? Yes
     Then, searchResult[0] = 7, because letter H from phrase[i] was equal to alphabet[7]. Now that it's found letter H, it should go on with letter E, and so on.
Unfortunately, my code is doing this:
   H == A? No.
   E == B? No.
   L == C? No.
   L == D? No.
   O == E? No.
(blank space)  == F? No.
   S == G? No.
and it goes on until it completes the phrase "HELLO STACK". What can I do to stop it from going onto the next letter if it is not found in the alphabet?
Many Thanks!

A: To get that logic, use another (nested) loop.
The outer loop iterates over the characters in the phrase (as done) and the inner loop iterates the characters in the alphabet. "Stopping it from going onto the next letter" is done when the inner loop (which loops over the alphabet) terminates because it matched the current phrase character. Then the next iteration of the outer loop continues and so on, until the phrase is done being iterated.
Using break (the example code also shows using nested loops) will be helpful when/if using an if inside the inner loop. Also, depending on the assignment, it may be required to handle the case when a character in the phrase isn't in the alphabet. Once the task is completed using a regular loop, see ehanced for loops which can clean up the code as no index must be fiddled with.

A: if you dont want to continue if phrase[n] != alphabet[k] then the phrase would always need to be 'abc.....' because if you use HELLO STACK the first letter is H which is != alphabet[0](A).
you can use a nested loop here
is your phrase an array? do you have several phrase? if not this would be the function
i prefer to make the alphabet array to be char[] alphabet
void searchPhrase(String phrase){

 //string length()
 outer:
 for(int x = 0 ; x < phrase.length() ; x++){
     //char length
     inner:
     for(int y = 0 ; y < alphabet.length ; y++){

         if(phrase.charAt(x) == alphabet[y]){
            //alphabet found
         }else{
            //not found
         break outer;
         }
     }
  }
 }

A: If I understood what you want to do, the code should be:
void searchPhrase(String[] phrase){
    searchResult = new int[phrase.length];
    int j=0;
    for (int i=0; i<frase.length;i++){
        for (int k=0; k<alphabet.length;k++){
            if (!phrase[i].equals(alphabet[k])){
                System.out.println("\nLetter "+phrase[i]+" was not found when comparing it to "+alphabet[k]);
                k++;
            }
            else{
                System.out.println("\nLetter "+phrase[i]+" was found when comparing it to "+alphabet[k]);
                searchResult[j] = i;
                k=0;
                break;
            }
        }
    }
}

I haven't tested the code, but it should work.

A: Is this what you want?
void searchPhrase(String[] phrase){
            searchResult = new int[phrase.length];
            int j=0, m=-1, n=-1;
            for (int i=0; i<phrase.length;i++)
            {
              for (int k=0; i<26;i++)
              {
                if (phrase[i].equals(alphabet[k]))
                {
                 searchPhrase[i] = k;
                 System.out.println("\nLetter "+phrase[i]+" was found when comparing it to"+alphabet[k]);
                }
               }
             }

A: Working example, use both String array to match
public static void searchPhrase(String[] phrase) {
        int[] searchResult = new int[phrase.length];
        String[] alphabet = "abcdefghijklmnopqrstuvwxyz".split("");
        int j = 0;
        for (int i = 0 ; i < phrase.length ; i++)
            for (int k = 0 ; k < alphabet.length ; k++) {
                if (!phrase[i].toLowerCase().equals(alphabet[k])) {
                    System.out.println("\nLetter " + phrase[i] + " was not found when comparing it to " + alphabet[k]);
                } else {
                    System.out.println("\nLetter " + phrase[i] + " was found when comparing it to " + alphabet[k]);
                    searchResult[j] = i;
                    break;
                }
            }
    }

Output
Letter H was not found when comparing it to

Letter H was not found when comparing it to a

Letter H was not found when comparing it to b

Letter H was not found when comparing it to c

Letter H was not found when comparing it to d

Letter H was not found when comparing it to e

Letter H was not found when comparing it to f

Letter H was not found when comparing it to g

Letter H ** was found when comparing it to ** h

Letter E was not found when comparing it to

Letter E was not found when comparing it to a

Letter E was not found when comparing it to b

Letter E was not found when comparing it to c

Letter E was not found when comparing it to d

Letter E ** was found when comparing it to ** e

Letter L was not found when comparing it to

Letter L was not found when comparing it to a

Letter L was not found when comparing it to b

Letter L was not found when comparing it to c

Letter L was not found when comparing it to d

Letter L was not found when comparing it to e

Letter L was not found when comparing it to f

Letter L was not found when comparing it to g

Letter L was not found when comparing it to h

Letter L was not found when comparing it to i

Letter L was not found when comparing it to j

Letter L was not found when comparing it to k

Letter L ** was found when comparing it to ** l

Letter L was not found when comparing it to

Letter L was not found when comparing it to a

Letter L was not found when comparing it to b

Letter L was not found when comparing it to c

Letter L was not found when comparing it to d

Letter L was not found when comparing it to e

Letter L was not found when comparing it to f

Letter L was not found when comparing it to g

Letter L was not found when comparing it to h

Letter L was not found when comparing it to i

Letter L was not found when comparing it to j

Letter L was not found when comparing it to k

Letter L ** was found when comparing it to ** l

Letter O was not found when comparing it to

Letter O was not found when comparing it to a

Letter O was not found when comparing it to b

Letter O was not found when comparing it to c

Letter O was not found when comparing it to d

Letter O was not found when comparing it to e

Letter O was not found when comparing it to f

Letter O was not found when comparing it to g

Letter O was not found when comparing it to h

Letter O was not found when comparing it to i

Letter O was not found when comparing it to j

Letter O was not found when comparing it to k

Letter O was not found when comparing it to l

Letter O was not found when comparing it to m

Letter O was not found when comparing it to n

Letter O ** was found when comparing it to ** o

Letter S was not found when comparing it to

Letter S was not found when comparing it to a

Letter S was not found when comparing it to b

Letter S was not found when comparing it to c

Letter S was not found when comparing it to d

Letter S was not found when comparing it to e

Letter S was not found when comparing it to f

Letter S was not found when comparing it to g

Letter S was not found when comparing it to h

Letter S was not found when comparing it to i

Letter S was not found when comparing it to j

Letter S was not found when comparing it to k

Letter S was not found when comparing it to l

Letter S was not found when comparing it to m

Letter S was not found when comparing it to n

Letter S was not found when comparing it to o

Letter S was not found when comparing it to p

Letter S was not found when comparing it to q

Letter S was not found when comparing it to r

Letter S ** was found when comparing it to ** s

Letter T was not found when comparing it to

Letter T was not found when comparing it to a

Letter T was not found when comparing it to b

Letter T was not found when comparing it to c

Letter T was not found when comparing it to d

Letter T was not found when comparing it to e

Letter T was not found when comparing it to f

Letter T was not found when comparing it to g

Letter T was not found when comparing it to h

Letter T was not found when comparing it to i

Letter T was not found when comparing it to j

Letter T was not found when comparing it to k

Letter T was not found when comparing it to l

Letter T was not found when comparing it to m

Letter T was not found when comparing it to n

Letter T was not found when comparing it to o

Letter T was not found when comparing it to p

Letter T was not found when comparing it to q

Letter T was not found when comparing it to r

Letter T was not found when comparing it to s

Letter T ** was found when comparing it to ** t

Letter A was not found when comparing it to

Letter A ** was found when comparing it to ** a

Letter C was not found when comparing it to

Letter C was not found when comparing it to a

Letter C was not found when comparing it to b

Letter C ** was found when comparing it to ** c

Letter K was not found when comparing it to

Letter K was not found when comparing it to a

Letter K was not found when comparing it to b

Letter K was not found when comparing it to c

Letter K was not found when comparing it to d

Letter K was not found when comparing it to e

Letter K was not found when comparing it to f

Letter K was not found when comparing it to g

Letter K was not found when comparing it to h

Letter K was not found when comparing it to i

Letter K was not found when comparing it to j

Letter K ** was found when comparing it to ** k


text:
Q: Question related to "example of free module with bases of different cardinality" In this Planet Math article, it shows an example where a free module has bases with different cardinality.
I am having some problems with show why $\phi$ is an $R$-module homomorphism.

A: I agree with D_S's comment that this is best done on your own, and probably first in the case $R^2 \cong R$ instead of the general version you're looking at. But if it helps, I'll give the full proof of the requested fact. Here's the setup from the linked article:
$k$ is a field, $V$ is an infinite-dimensional $k$-vector space with basis $\{e_i\}_{i \in I}$, $R = \operatorname{End}_k(V)$, and $J$ is a set such that $\lvert J \rvert \leq \lvert I \rvert$.
Then we pick any bijection $\alpha : I \to J \times I$, and $\pi_1 : J \times I \to J$ and $\pi_2: J \times I \to I$ denote the canonical projections. Now $\phi : R^J \to R$ is defined as follows:
For each $f \in R^J$, $\phi(f) : V \to V$ is the unique endomorphism such that
$$\phi(f)(e_i) = f(\pi_1(\alpha(i)))(e_{\pi_2(\alpha(i))})$$
for all $i \in I$.
To show that $\phi$ is an $R$-module homomorphism, let $f, g \in R^J$ and $\lambda \in R$ be arbitrary. Recall that the $R$-module structure on $R^J$ is defined such that $(f + \lambda g)(j) = f(j) + \lambda \circ g(j)$ for all $j \in J$. Now let $i \in I$ be arbitrary. We have that
\begin{multline*}
\phi(f + \lambda g)(e_i)
= (f + \lambda g)(\pi_1(\alpha(i)))(e_{\pi_2(\alpha(i))})\\
= (f(\pi_1(\alpha(i))) + \lambda \circ g(\pi_1(\alpha(i))))(e_{\pi_2(\alpha(i))})\\
= f(\pi_1(\alpha(i)))(e_{\pi_2(\alpha(i))}) + \lambda(g(\pi_1(\alpha(i))))(e_{\pi_2(\alpha(i))})\\
= \phi(f)(e_i) + \lambda(\phi(g)(e_i))\\
= \phi(f)(e_{\pi_2(\alpha(i))}) + (\lambda \circ \phi(g))(e_i)\\
= (\phi(f) + \lambda \circ \phi(g))(e_i)\\
= (\phi(f) + \lambda \phi(g))(e_i).
\end{multline*}
Since $i$ was arbitrary, we conclude that $\phi(f+\lambda g) = \phi(f) + \lambda \phi(g)$. Since $f$,$g$, and $\lambda$ were arbitrary, this shows that $\phi$ is an $R$-module homomorphism.
Edit: fixed some typos.


text:
Q: Spring roo entities - storing long strings I have to store long strings in MySQL database using spring roo. I assumed that "field string" command generates field with size 255 which is too small. I prefer to not use blob. What should I do?

A: If you create the field using a command like field string --fieldName field1 --sizeMax 500 then Roo will annotate the field with @Size(max = 500) and it works for me if I let Hibernate to create the database schema.
(--sizeMax is an optional parameter, you can display all optional parameters after you defined all mandatory ones with -- and hitting TAB)
Another solution is to add manually the JPA annotation on the field: @Column(length=500).
Or if you don't generate the database schema but create it by hand then you can define your column as you like.


text:
Q: Linqpad & EF5 Code First Getting the following error when trying to run a query against a dbcontext assembly in Linqpad.

InvalidOperationException: The model backing the 'UserQuery' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

Having done a bit of reading it seems that:
Database.SetInitializer<DiaryAssistantContext>(null);

is needed. However this is already in my derived DbContext class.
Can anybody give me a pointer?

A: While an answer has already been accepted, in my case I wanted a solution that was a little more compile-time friendly. The following solution is similar to the example in the accepted answer that uses reflection, but will provide a little extra compile-time checking:
Expression<Action> setInitializerExpression = () => Database.SetInitializer<MyContext>(null);
var setInitializerCall = (MethodCallExpression) setInitializerExpression.Body;
var setInitializerMethodInfo =
    setInitializerCall.Method.GetGenericMethodDefinition().MakeGenericMethod(GetType());
setInitializerMethodInfo.Invoke(null, new object[] {null});

A: LINQPad subclasses your typed data context so you can run queries without referencing the instance. Maybe the SetInitializer method needs the subclassed type.
What happens if you replace this code:
Database.SetInitializer<DiaryAssistantContext>(null);

with this:
typeof (Database).GetMethod ("SetInitializer").MakeGenericMethod (GetType()).Invoke (null, new object[] { null });

?


text:
Q: CALL in stored procedure doesn't work I have next data set in table rel_user_article
+---------+------------+
| user_id | article_id |
+---------+------------+
|       1 |         -1 |
|      97 |        153 |
+---------+------------+

This table implies next logic: each author must have at least 1 article and each article must have at least 1 author. When author hasn't articles, than table must have fake relation:(uid, -1)
When author adds his first article than this fake relation must be deleted.
I have stored procedures for creating new relation and deleting fake ones.
Deleting fake relations looks like this:
CREATE PROCEDURE `rel_delete_fake`(IN `ids` TEXT, IN `tbl` VARCHAR(255),
IN `fake_f` VARCHAR(255), IN `real_f` VARCHAR(255))
        MODIFIES SQL DATA
    proc: begin
        if (`ids` = '') then
            leave proc;
        end if;

        set @s = concat('DELETE FROM ', `tbl`, ' WHERE (', `fake_f`,
                        ' = "-1" AND ', `real_f`, ' IN (', `ids`, '))');

        prepare qr from @s;
        execute qr;
        deallocate prepare qr;
    end proc

Creating "real" relations looks like this:
CREATE DEFINER=`root`@`localhost` PROCEDURE `rel_create`(IN `ids1` TEXT,
IN `ids2` TEXT, IN `tbl` VARCHAR(255), IN `field1` VARCHAR(255),
IN `field2` VARCHAR(255))
    MODIFIES SQL DATA
proc: begin
    set @cur = 0;
    set @id1_cur = 0;
    set @id2_cur = 0;

    set @id1_cur_old = NULL;
    set @id2_cur_old = NULL;

    if (`ids1` = '' or `ids2` = '') then
        leave proc;
    end if;

    set @sql_str = concat('insert into ', `tbl`, ' (', `field1`, ', ', `field2`, ") values (?, ?)");
    prepare qr from @sql_str;
    loop1: loop
        set @cur = @cur + 1;
        set @id1_cur = substring_index(substring_index(`ids1`, ',', @cur), ',', -1);
        set @id2_cur = substring_index(substring_index(`ids2`, ',', @cur), ',', -1);

        if (@id1_cur = @id1_cur_old and @id2_cur = @id2_cur_old) then
            leave proc;
        end if;

        execute qr using @id1_cur, @id2_cur;

        set @id1_cur_old = @id1_cur;
        set @id2_cur_old = @id2_cur;
    end loop loop1;
    deallocate prepare qr;

        -- deleting fake records that became needless
        -- even this doesn't work
    call `rel_delete_fake`('1','rel_user_article','article_id','user_id');
    leave proc;

    -- deleting fake records that became needless
    call `rel_delete_fake`(`ids1`, `tbl`, `field2`, `field1`);
    call `rel_delete_fake`(`ids2`, `tbl`, `field1`, `field2`);
end proc

Procedure for deleting fake relations works. Procedure for creating relations only creates new record but don't even call rel_delete_fake procedure.
For test I'm issuing next call:
call `rel_create`('1','153','rel_user_article','user_id','article_id');

and have in result:
+---------+------------+
| user_id | article_id |
+---------+------------+
|       1 |         -1 |
|       1 |        153 |
|      97 |        153 |
+---------+------------+

Why this (1, -1) not deleted?

A: I found mistake. There must be "leave loop1;" in place of "leave proc;" in loop.


text:
Q: How do I manage files (upload/delete) in an asp.net core web application using a razor component I am trying to make a razor page where I can upload/delete files out of a specific folder in wwwroot I have found many ways to do it but I want to use a razor component so I can reuse it on multiple pages I found in the documentation to upload a files
(https://learn.microsoft.com/en-us/aspnet/core/blazor/file-uploads?view=aspnetcore5.0&pivots=webassembly)
and many videos an element called
<InputFile />
but when I try to use it says that it isn't a valid element?


text:
Q: How to delete custom log created by Log Analytics Data collector API How can i perform delete operation on custom log in azure log analytics ?
ex : DemoExample_CL

I can delete it when create one in Advanced settings>Data>Custom Logs, but when i use "Log Analytics Data collector API", it did not show up.

A: AFAIK, this is currently unsupported.
Similar feedback shown here ->  (https://feedback.azure.com/forums/267889-log-analytics/suggestions/16434184-delete-custom-logs-sended-by-http-data-collector-a) was shared directly with the responsible Azure feature team. I recommend navigating to the above link and clicking the vote button to raise visibility and priority on this (or) you may raise another feedback which clearly states that you are looking for a feature which helps to 'delete custom log type that is created by Log analytics Data Collector API'.
Just a side note, if you want to delete only content under particular log type then you may try this -> https://learn.microsoft.com/en-us/azure/azure-monitor/platform/personal-data-mgmt#delete purge API. Also please note that this API must not be treated as general-purpose data delete API, but used for GDPR purposes only.
Hope this helps!! Cheers!!

A: I managed to do it following the documentation here:
https://learn.microsoft.com/en-us/rest/api/loganalytics/workspacepurge/purge
You can click on "Try It", then you will have to login, provide the name of resource group, workstation name and table name and it will do the trick.
Not ideal, but at least it's possible somehow.

A: You can delete the logs by going to the log analytics workspace of the corresponding sentinel instance.
Inside the log analytics workspace there is a "Custom Logs" tab under settingsImage
Click on the three dots of the required custom logs to be deleted.


text:
Q: AJAX External URL? I am developing a simple Mobile App that displays currency rates from an XML file. Now, the problem is that I read the XML from my server so I have to put the full URL in .ajax but it dosen't seem to work with external URLs. Can someone tell me how can I fix this or how to replace the code so it will work?
$(document).ready(function() {
  $.ajax({
    type: "GET",
    url: "http://www.domain.com/currencies.xml",
    dataType: "xml",
    success: function(xml) {

    $(xml).find('Currency').each(function(){

    var Name = $(this).find('Name').text();
    var ValueUSD = $(this).find('ValueUSD').text();
    var ValueEUR = $(this).find('ValueEUR').text();
    var ExValueUSD = $(this).find('ExValueUSD').text();
    var ExValueEUR = $(this).find('ExValueEUR').text();

    $('#content').append('

'+Name+'

'+ValueUSD+'

'+ValueEUR+'

'+ExValueUSD+'

'+ExValueEUR+'

');

    });

    }
  });
});

</script>

A: Look at jquery doc about jsonp. There is possibility to do cross site request in html5 especially, however most tools (firebug, noscript, adblock) and some browsers on default are bloking such requests. So I would stick to jsonp as most reliable source.

A: Ajax Doesnot work with Cross-Domain due to same origin policy. Try JSONP in such case.


text:
Q: discord.py how to get last message I am using discord.py 2.1.0 and I want to get last message in channel
i tried this
@tree.command(guild = discord.Object(id=941748573937209344), name = 'kontrol', description='kontrol')
async def check(ctx):
    channels = ctx.guild.text_channels
    for channel in channels:
        if channel.name.startswith('test-'):
            last_message = [msg async for msg in channel.history(limit=1)]
            print(last_message)

output :
[<Message id=1060085926157619221 channel=<TextChannel id=1060078850417111112 name='test-supraaaaaa' position=19 nsfw=False news=False category_id=941749835328012328> type=<MessageType.default: 0> author=<User id=323516141777715202 name='supraaaaaa' discriminator='0966' bot=False> flags=<MessageFlags value=0>>]

but there is no date last message created at and it gives this error when getting its id :
@tree.command(guild = discord.Object(id=941748573937209344), name = 'kontrol', description='kontrol') #guild specific slash command
async def check(ctx):
    channels = ctx.guild.text_channels
    for channel in channels:
        if channel.name.startswith('övgü-'):
            last_message = [msg async for msg in channel.history(limit=1)]
            print(last_message.id)

AttributeError: 'list' object has no attribute 'id'

A: last_message is a list. A list does not have the id property.
What you are trying to do is to access the element in the list. There is only one, in the example you provided, so you should do:
print(last_message[0].id)

It means: In the list named last_message, access the first element (the Message object in your case) and from this object, access the id property in order to print it to STDIN.

To get the author's id, it is the same logic:
print(last_message[0].author.id)

Becasue last_message.author gives you the User object, which has the id property.
Concerning the date, it does not appear in the example you provided. I am not familiar with Discord's API, so you'll have to wait for another answer or look at the doc' by yourself.


text:
Q: Send email reminders based on Excel values in two workbooks I am attempting to send automated emails to staff when they are within 45 days of any particular training's expiration date, without having to open the file to run macros (if possible). Also, to have this done without an email preview for each training, as hundreds may pop up each time the macro is run.
I want to pull the name of the training that determines the email body from the values in one of my columns.
I want to pull the expiration dates from a separate Excel file that is a record of training dates.
I managed to queue email previews for trainings within 45 days of the expiration date, however the code allows Excel to send reminders on trainings that are already expired.
I would like Excel to stop once the expiration date has been reached. I attempted: If mydate2 - datetoday2 <= 45 Then. This works but will send emails to inactive staff but still have a record of their trainings in the training record file.
I tried to pull the training names from a column and have them autofill in the email body. For instance the email will say "Training due to Expire:" and then have excel fill the training name based on the values in column 4.
Sub datesexcelvba()
Dim myapp As Outlook.Application, mymail As Outlook.MailItem

Dim mydate1 As Date
Dim mydate2 As Long
Dim datetoday1 As Date
Dim datetoday2 As Long

Dim x As Long
lastrow = Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row

For x = 2 To lastrow

    mydate1 = Cells(x, 5).Value
    mydate2 = mydate1

    Cells(x, 11).Value = mydate2

    datetoday1 = Date
    datetoday2 = datetoday1

    Cells(x, 12).Value = datetoday2

    If mydate2 - datetoday2 <= 45 Then

        Set myapp = New Outlook.Application
        Set mymail = myapp.CreateItem(olMailItem)
        mymail.To = Cells(x, 6).Value

        With mymail
            .Subject = "Training Expiration Reminder"
            .Body = "Please contact your supervisor to enroll in the next possible recertification class. Training Expiring:" value=x3

            .Display
            '.send
        End With

        Cells(x, 7) = "REMINDER SENT"
        Cells(x, 7).Font.Bold = True

        Cells(x, 13).Value = mydate2 - datetoday2

    End If
Next

Set myapp = Nothing
Set mymail = Nothing
End Sub

A: Posting comment as answer so this can be listed as Answered.
.Body = "..." value=x3

needs to be
.Body = "..." & cells(x,3).value

, or similar to your context.

Regarding your question about tips/points, don't be afraid to compartmentalize your code, so it's easier to handle the sections.
You have 2 or 3 sections of your code, and you can do something like the below to call the different sections:
Public Sub execute()
    If ActiveSheet.name <> "SQDC" Then Exit Sub
    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
        .Calculation = xlManual
    End With
    '''
    task_one
    task_two
    task_three
    '''
    With Application
        .ScreenUpdating = True
        .DisplayAlerts = True
        .Calculation = xlAutomatic
    End With
End Sub

Regarding using Outlook and Excel back and forth, save your key items as variables so Outlook can do what it needs to do without searching for cell references.
'at the top of the module, outside of the subroutine:
public email_address as string, employ_name as string

'where If mydate2 - datetoday2 <= 45 Then is TRUE
email_address = cells(x,6).value
employ_name = cells(x,3).value

Then you can use those in the email portion of your code.  It is assumed you are compartmentalizing the excel activities from the outlook activities, so the global variables are there so you can define them in one subroutine and utilize them in another.

One thing that helped me with getting to mediocrity in VBA is reading other people's questions and attempting to answer them (even if just in your head), by finding the correct terms, etc.  Eventually you will have enough knowledge to struggle by with the best of 'em!


text:
Q: In an Oracle database query, is there any way to block when an uncommitted row has been INSERTed? In an Oracle database, is there any way for a query to be blocked when an uncommitted row has been INSERTed?
Suppose I want to get all rows in a table that match my WHERE clause, but there is an uncommitted row that has been inserted that might match it.  I want my query to be blocked till the inserted row's transaction completes. Ordinary SELECTs, of course, only return the committed data. Is there a way to be blocked and thus wait for the recently-inserted row (which presumably has an exclusive row lock on it)?
I was thinking that perhaps, before my INSERT, I might acquire a shared lock on some other row in another table, then as part of the query in question, try to SELECT the desired data FOR UPDATE, even though I don't intend to update it.  If this is a viable approach, any ideas how to acquire this shared lock?
Is there any easier way than that?


text:
Q: Enhancing TVS diode circuit I was reading into Electromagnetic Compatibility Engineering by Henry W. Ott about ESD protections and I was interested by the following part.

First, a series resistor (or ferrite) added in front of the
  diodes to limit the magnitude of the ESD current, and second, additional bulk
  capacitance (5 to 50 mF) added across the power supply rails. Both of these
  approaches are shown in Fig. 15-18B

This picture reminded me of the schematics seen inside a TVS Diode. The TVS diodes I am using up till now are the TVS DIODE (würth 8240116)

*

*Can the shown figure actually be compared to a TVS diode?

*If so, can the functionality of TVS diodes be improved by adding the
current limiting series resistance and a bulk capacitance?

*Why aren't any of these improvements suggested in the datasheet just
like decoupling or bypass capacitors are recommended in every IC
datasheet?

A:
Can the shown figure actually be compared to a TVS diode?

It can be compared to the TVS diode array you referenced.  Both work by having diodes to prevent the signal level from exceeding the power rails by more than a diode drop.

If so, can the functionality of TVS diodes be improved by adding the current limiting series resistance and a bulk capacitance?

Series resistance, if practical with your circuit requirements, will reduce the stress on any ESD protection device.  The bulk capacitance above, from the ESD protection standpoint, fulfills the same function as the zener in the 8240116, keeping the power rail from moving much.

Why aren't any of these improvements suggested in the datasheet just like decoupling or bypass capacitors are recommended in every IC datasheet?

Because they don't know your exact design requirements.  Static protection on a cell phone is different from static protection for guys jumping out of helicopters.

A:
Can the shown figure actually be compared to a TVS diode?

A TVS has a similar function as two regular diodes, but the ESD current can be shunted to ground instead of one of the rails. The diagram above is mainly for overcurrent\overvoltage protection. A TVS has a higher breakdown voltage which is mainly useful for very high voltages such as those from ESD. You probably wouldn't want the ESD spike ending up on your power rails, even with a limiting resistor, so a port to the outside world should have TVS diodes close to the entrance of the input to the board to shunt the currents directly to ground.

Source: https://www.slideshare.net/KevinDuke/aodesignprotection2015nonda

If so, can the functionality of TVS diodes be improved by adding the current limiting series resistance and a bulk capacitance?

See this answer TVS diode before or behind resistor :

You have three components there that are all there for protecting the
  AVR, but all are doing a different job.
The resistor is there to stop steady state high voltages.
The capacitor is to remove ripple/RF/slow transients.
The TVS is to suppress fast transients.
In order to get the best out of your protection, you need to have the
  shortest (lowest inductance) path back for the fast transient impulses
  (such as ESD). To do this, you fit the TVS (the fastest responding
  device) as close to the input to the board as possible. The capacitor
  would then be a bit further in (depending on the layout and design)
  and the resistor (which only deals with very slow, or steady state
  situations) can pretty much be on the pin of the AVR
Why aren't any of these improvements suggested in the datasheet just like decoupling or bypass capacitors are recommended in every IC
  datasheet?

Because the IC datasheets don't know what the designer is going to connect the ports to. Most IC pins are connected internally on the board, and don't require extra protection. They do specify what not to do to the IC in the absolute maximum ratings section and in the ratings section for different pins. To provide this information on every datasheet would provide too much information. This information is provided in the form of app notes as it applies to many different IC's
Analog: Solving IEC System Protection for Analog Inputs
and Using ESD Diodes as Voltage Clamps
TI: http://www.ti.com/interface/circuit-protection/esd-protection-and-tvs-surge-diodes/technical-documents.html
ST micro: https://www.st.com/content/st_com/en/support/resources/resource-selector.html?querycriteria=productId=CL1137$resourceCategory=technical_literature$resourceType=application_note

A: The drawing in your post does not show a TVS diode, but does have a diode array clamping to the power-rail (positive polarity) or GND.  You can look at an app note (here is an OnSemi one).  Usually TVS datasheets are pretty bare bones, and app notes have more information.
Having a diode array is a way to remove the capacitance of the TVS diode or capacitors that the ESD (or lightning) sourced current is being shunted into.  It also allows small diode arrays to steer multiple inputs into a single power rail or protective device.
Including bulk capacitance is probably not relevant for situations that include a TVS, although it does impact the amount of over-voltage excursion between the TVS hitting threshold and actually clamping.
Using resistors is common in front of most clamping methods.  If the parts are already designed to handle transients, it might not be necessary.  And series resistors can also have a dramatic input on the possible signal rate you can get through a net.
As an aside on clamping to a power rail as shown in your initial post, that setup can easily cause system upsets / resets if any device you are using needs consistent power rails.  Having more capacitance can limit the amount of movement, but you can also use a resistor to isolate your power rail from the capacitor that clamping current is being dumped into.

A: TVS diodes are multi- and single-purpose depending line impedance and energy absorption levels.
The part you showed has a differential line with a full-wave bridge and a power Zener.
vs.
The block diagram shows a single line with a half-bridge to a power Zener to a bulk storage cap.
Current limiting is normally externally dependant on signal impedance requirements . For example all CMOS being low input current , high speed,  use a series R of 10k for inputs with 2 high speed diodes in half bridge to each rail rated for 5mA DC followed by a 2nd similar diode pair to rails for each input. Pulse current drops voltage in the series R then clamps further to <=0.2 outside each rail with Schottky diodes. This is adequate for 100pF 1k~2kV  ESD discharges only.
Ferrite would be used for low impedance circuits near transients << 1us.


text:
Q: JDK from extern drive without installing its files locally How to make applications use JDK without installing them both locally? Mac.
I try to have and extern drive(sim-card) for programs and apps I do not want to have installed in my computer. I've spend a few hours(30) trying to figure it out. Warning - I usually try things that I am unsure exist in the computer science world.
What I've done:

*

*App

*

*Find the installer and move the app to a new folder

*Open content and try to run the program which ask for the JDK

*JDK

*

*Download the JDK and move the files to the same folder

*Run the app above with bin/java and bin/jar and a few crazy mixtures of these commands

*Tried to use jshell but things get messier

*Brew in action

*

*Tried to install JDK i a different folder without succeeding

*Tried to install the App without luck

*Tried to install Brew in the folder in the extern drive

*Cry

*Considering

*

*Symlink App and JDK in the outside(extern drive) folder

*Putting the App (package contents) together with the JDK files in the same folder

*Invent a new wheel