text:
Q: What is the students' jargon or abbreviation for assignments made up of "only" data downloaded from the internet in English? (If it exists) Japanese students call a report and essay made up by only putting data downloaded from the Internet e.g. passages from Wikipedia put together without including  their own thoughts or creative ideas, a "コピペ-Kopipe," which is pronounced as 'kopipay.'
It is a compound of 'copied + pasted + paper'. Incidentally 'copy ,' 'paste,' and 'paper' are all adapted to Japanese language, and pronounced as 'kopi-i, 'paisuto, and 'paypah'.
To me 'Kopipe' is akin to plagiarism, but it doesn't have the same criminal overtone as plagiarism itself. It seems to be just a labor-saving editing or blending job for students.
While riding on the train, I've overheard students say to each other:

"I submitted a report in time by 'kopipeing' articles"

innocently, as if they were playing a game.
Is there a similar student jargon or abbreviation for 'Kopipe' in English?

A: There is no special noun for that in English, but 'to copy' or 'to copy-paste' works, but is not jargon at all, it works for anything, whether plagiarized or reworked.
Plagiarizing from electronic articles is certainly a recognized phenomenon in English speaking cultures, but there is no noun, no special term for that class of objects.
One could refer to the situation in other ways, like

Did you get that off the internet?
I copy-pasted my paper from my friend.
He cobbled together his paper from wikipedia articles.

There are related terms: 'paper mill' where one can purchase a paper written by someone else on contract (the paper is said to be 'ghostwritten'). But there is no term for when one does the cut and paste onesself.

A: The expression I've heard is "copypasta", meaning anything put together with nothing but cutting and pasting.  The suggestion is that the result would be disorganized as a plate of spaghetti.
Sadly, there is no verb (as far as I know) for creating copypasta or for a person engaged in that activity.


text:
Q: Keep getting "message": "'from' parameter is missing" in Rest API client I want to send a mail through Mailgu n with Insomnia. This is what I have done:

*

*Created account at mailgun.com

*Added a verified recipient:

*Opened up Insomnia and added the following configuration:

3.1 This is the complete 'from':
from=sandboxcXXXXXX0a25422c87fdc18e0e6f8778.mailgun.org&to=VerifiedUser@hotmail.com&subject=subb&text=sometext

*This is the auth. I got the auth key from Mailgun (Settings -> API Key -> Private API keys)

*This is the header:

*When I click on 'Send' this is the error:

A: Your Form Encoded data shouldn't be one string. It should be all key-value pairs like:

redpajama_set_name: RedPajamaStackExchange


text:
Q: Thread management in a game loop? I am in the middle of developing a game and came across the problem of multithreading. I already used multithreading successfully when loading resources. I did that by creating some threads at some point, assigned them functions, and waited for them to finish, while drawing a loading screen, pretty straightforward.
Now I want to create some threads, that can wait idle till they receive a function, when they do, solve that, then stay idle again. They must operate in a game loop, which is roughly like this (I came up with these function names just for easy visualization):
std::thread t0,t1;
while(gamerunning)
{
   UpdateGame();
   t0.receiveFunc( RenderShadow );
   t1.receiveFunc( RenderScene );
   WaitForThreadstoFinishWork();
   RenderEverything(); //Only draw everything if the threads finished (D3D11's Deferred Context rendering)
}
t0.Destroy();
t1.Destroy();

My rendering engine is working, and for the time being (for testing), I created threads in my game loop, which is a terrible way of even a quick test, because my rendering speed even slowed down. By the way, I am using C++11's  library.
Long story short, I want to create threads before my game loop takes place, and use those in the game loop afterwards, hope someone can help me out. If it is an option, I would really want to stay away from the lower levels of threading, I just need the most straightforward way of doing this.

A: Following your most recent comments, here is an example implementation of a thread that wakes up on demand, runs its corresponding task and then goes back to sleep, along with the necessary functions to manage it (wait for task completion, ask for shutdown, wait for shutdown).
Since your set of functions is fixed, all you'll have left to do is to create as much threads as you need (ie. 7, probably in a vector), each with its own corresponding task.
Note that once you remove the debugging couts there's little code left, so I don't think there is a need to explain the code (it's pretty self-explanatory IMHO). However don't hesitate to ask if you need explanations on some details.
class TaskThread {
public:
    TaskThread(std::function<void ()> task)
      : m_task(std::move(task)),
        m_wakeup(false),
        m_stop(false),
        m_thread(&TaskThread::taskFunc, this)
    {}
    ~TaskThread() { stop(); join(); }

    // wake up the thread and execute the task
    void wakeup() {
        auto lock = std::unique_lock<std::mutex>(m_wakemutex);
        std::cout << "main: sending wakeup signal..." << std::endl;
        m_wakeup = true;
        m_wakecond.notify_one();
    }
    // wait for the task to complete
    void wait() {
        auto lock = std::unique_lock<std::mutex>(m_waitmutex);
        std::cout << "main: waiting for task completion..." << std::endl;
        while (m_wakeup)
          m_waitcond.wait(lock);
        std::cout << "main: task completed!" << std::endl;
    }

    // ask the thread to stop
    void stop() {
        auto lock = std::unique_lock<std::mutex>(m_wakemutex);
        std::cout << "main: sending stop signal..." << std::endl;
        m_stop = true;
        m_wakecond.notify_one();
    }
    // wait for the thread to actually be stopped
    void join() {
        std::cout << "main: waiting for join..." << std::endl;
        m_thread.join();
        std::cout << "main: joined!" << std::endl;
    }

private:
    std::function<void ()> m_task;

    // wake up the thread
    std::atomic<bool> m_wakeup;
    bool m_stop;
    std::mutex m_wakemutex;
    std::condition_variable m_wakecond;

    // wait for the thread to finish its task
    std::mutex m_waitmutex;
    std::condition_variable m_waitcond;

    std::thread m_thread;

    void taskFunc() {
        while (true) {
            {
                auto lock = std::unique_lock<std::mutex>(m_wakemutex);
                std::cout << "thread: waiting for wakeup or stop signal..." << std::endl;
                while (!m_wakeup && !m_stop)
                    m_wakecond.wait(lock);
                if (m_stop) {
                    std::cout << "thread: got stop signal!" << std::endl;
                    return;
                }
                std::cout << "thread: got wakeup signal!" << std::endl;
            }

            std::cout << "thread: running the task..." << std::endl;
            // you should probably do something cleaner than catch (...)
            // just ensure that no exception propagates from m_task() to taskFunc()
            try { m_task(); } catch (...) {}
            std::cout << "thread: task completed!" << std::endl;

            std::cout << "thread: sending task completed signal..." << std::endl;
            // m_wakeup is atomic so there is no concurrency issue with wait()
            m_wakeup = false;
            m_waitcond.notify_all();
        }
    }
};

int main()
{
    // example thread, you should really make a pool (eg. vector<TaskThread>)
    TaskThread thread([]() { std::cout << "task: running!" << std::endl; });

    for (int i = 0; i < 2; ++i) { // dummy example loop
      thread.wakeup();
      // wake up other threads in your thread pool
      thread.wait();
      // wait for other threads in your thread pool
    }
}

Here's what I get (actual order varies from run to run depending on thread scheduling):
main: sending wakeup signal...
main: waiting for task completion...
thread: waiting for wakeup or stop signal...
thread: got wakeup signal!
thread: running the task...
task: running!
thread: task completed!
thread: sending task completed signal...
thread: waiting for wakeup or stop signal...
main: task completed!
main: sending wakeup signal...
main: waiting for task completion...
thread: got wakeup signal!
thread: running the task...
task: running!
thread: task completed!
thread: sending task completed signal...
thread: waiting for wakeup or stop signal...
main: task completed!
main: sending stop signal...
main: waiting for join...
thread: got stop signal!
main: joined!


text:
Q: Designing a turing machine I need help designing a turing machine that will compute the following f(x) = x mod 3. I just need help getting started since I am not familiar on how to approach this problem

A: Extracts from the comments:
The input and input is in unary as a string of 1. Space is 0. The output should rewrite the input.
The input is {x, 3} with one space between each argument or {x}.
The output is {x mod 3}.
Algorithm:

*

*Go to the end of the input.

*Remove the second argument.

*While there are at least three symbols in the argument, remove them.

State machine:

*

*Start: If input is 0, move right and go to "deleting right", else move right.

*Deleting right: If input is 0, move left and go to "finding arg". Else write 0 and move right.

*Finding arg: If input is 0, move left. If input is "start of tape", finish. Else move left and go to state "found 1".

*Found 1: If input is "start of tape", finish. Else move left and go to the state "found 2"

*Found 2: If input is "start of tape", finish. Else and go to the state "deleting right".


text:
Q: Why my keyword search service is incomplete? I want to use the sharepoint search service to search content in some specific lists. However, some of those columns and items cannot be searched.
Let me list some problems,

*

*some items cannot be found. for example, row A and row B has the same value in columnX, but only row B can be found (the result only shows 1 item). my query: columnXMap:"*theValue*".

*some columns cannot be used to search. The possible reason should be the mapping name of the column is ows_admin/user. I am not sure will the slash bring any error or not even i set the Property name to AdminORuser in search service. my query: AdminORuser:*.

Moerover, I had finished a Full Crawling and the Crawl Log has no error.

A: *

*Wildcard operator (*) in KQL is supported only at the end of the phrase. Read more.

*Ensure that managed properties for these columns are set as Queryable. Read more.


text:
Q: SQL Server Management Studio 2012 DB Backup script I have SQL Server Management Studio 2012 installed on a VM. We have an active DB (attached to an ASP.Net application whose target Framework is 4.0). What I was looking for is a script to backup a DB that I can attach to Task Scheduler to take backup once a day and copy that backup file to my local machine.
As far as copying of file is concerned I can do that using Robocopy, but I am yet to create a script to automatically take backup. I read a few articles but they were too outdated (SQL Server 2000).
I also checked this link: https://support.microsoft.com/en-us/kb/930615 But Step 8 in this link becomes invalid as "Script Action to Job" is disabled.
Is there a work-around for this?


text:
Q: Compatible maps in $\mathbb{R}$ Our teacher told us to make three maps  $\left ( U, φ \right ), \left ( V, ψ \right ), \left ( W, χ \right )$ in $\mathbb{R}$ such that $\left \{φ,ψ \right\}$ and $\left \{ψ,χ\right\}$ are differentiably compatible, but $\left \{φ,χ\right\}$ aren't.
Two maps $\left ( U, φ \right ), \left ( V, ψ \right )$ to be differentiably compatible means that the functions:
$$φ\circ ψ^{-1}: ψ(U\cap V)\rightarrow φ(U\cap V)$$
$$ψ\circ φ^{-1}: φ(U\cap V)\rightarrow ψ(U\cap V)$$
are $\mathcal{C^\infty}$, i.e. infinite times differentiable.
I can't see how this is going to happen, because when you compose two $\mathcal{C^\infty}$ functions the outcome is $\mathcal{C^\infty}$. Am I missing something? Do you have any idea how to proceed? Thank you very much!

A: Hint: Consider $\varphi : \mathbb R \to \mathbb R$ given by $\varphi(x) = x$ and $\psi:  \left(\frac{\pi}{2}, \frac{3\pi}{2}\right) \to \mathbb R$, $\psi (x) = \tan x$, $\chi : \mathbb R \to \mathbb R$, $\chi (x) = x^3$.


text:
Q: code not working when jquery version is changed using an example code given on jsfiddle, that clicking on one checkbox unchecked all other checkboxes is working fine, but when i change the jquery version to 1.10.1, it doesn't work, any solution
 $(".chb").each(function(){
      $(this).change(function(){
        $(".chb").attr('checked',false);
        $(this).attr('checked',true);
     });
  });

here is the link
http://jsfiddle.net/44Zfv/

A: The version is being switched from 1.5.2 to 1.10.  After jQuery 1.6 it is recommended to use .prop() in place of .attr().
$(".chb").each(function(){
   $(this).change(function(){
       $(".chb").prop('checked',false);
       $(this).prop('checked',true);
   });
});

A better solution would be to use radio buttons, which will give you the desired behavior without any additional script.
<input type="radio" name="cb" class="chb" /> Radio1
<input type="radio" name="cb" class="chb" /> Radio2
<input type="radio" name="cb" class="chb" /> Radio3
<input type="radio" name="cb" class="chb" /> Radio4

JS Fiddle: http://jsfiddle.net/44Zfv/292/

A: Hi muzaffar try prop instead of attr
$(".chb").each(function()
    {
    $(this).change(function()
    {
    $(".chb").prop('checked',false);
    $(this).prop('checked',true);
    });
 });

A: Since you're not changing the attribute but the property use jQuery's prop method instead. This will work with version 1.10+
$(".chb").each(function(){
    $(this).change(function(){
        $(".chb").prop('checked',false);
        $(this).prop('checked',true);
    });
});

Difference between attribute and property
http://www.w3.org/TR/SVGTiny12/attributeTable.html
Attributes are generally defined by the the HTML whereas properties are defined by the DOM. For some elements the property and the attribute reflect the same (e.g. the id of an element). A good way to show the DOM interaction is the following:
<input type="text" value="some value">

This element has two attributes (type, text). When the browser parses the document it will create an object for this specific element with the properties type and value. If you then write something in it, it will affect the elements value property. You can better see the difference when trying to retrieve the value:
input.getAttribute('value') // -> will return the inital value: "some value"
input.value // -> will return the object's value property (the text you've entered)


text:
Q: Passive vs active voice I came across this sentence in a test:

The first computer was built in 1943, but since then the computer technology has developed a great deal.

My confusion is can we use has been developed instead of the active form of present perfect? If not, can you help me clarify this?

A: Develop is a verb that is "ergative". This means that there are two senses, one is transitive and one is intransitive.
Another ergative verb is "to open".  We can say

The door opens   (intransitive ergative)

John opens the door (transitive)

The door is opened   (transitive passive)

Note the similarity between transitive-passive and intransitive. The difference is that the transitive passive implies that the door didn't open "by itself".  Someone did it.
With your example we could use

Computer technology has been developed...

But this would imply that  "Someone developed computer technology"   The writer wants to suggest that it developed "naturally", as a result of many actions. So they use the intransitive-ergative.  It doesn't carry the unwanted meaning  "Somebody has developed computer technology."


text:
Q: Is there a way to use Duck typing in Python method with same return type as class's method? I'd like to use Duck typing in my Python code but everytime I use return type same as class it shows "Unresolved reference" error.
class SomeClass:
    def some_method -> SomeClass:
        pass

To be more specific, I am trying to use it with Generator with same result:
import abc
from typing import Generator

class Node(abc.ABC):
    def __init__(self):
        self.nodeDepth: int = 0

    @abc.abstractmethod
    def __hash__(self):
        pass

    @abc.abstractmethod
    def __eq__(self, other):
        pass

    @abc.abstractmethod
    def getNextNodes(self) -> Generator[Node, None, None]:  # is there any way to achieve this with use of duck Typing ??
        pass

    @abc.abstractmethod
    def isGoalState(self) -> bool:
        pass

I will be thankful for any hints and tips, maybe I am just too accustomed to Java and using typing where I should not.


text:
Q: JSON encoding in chicagoBoss I have created a table name 'drugs' in chicagoboss. Mnesia has been used. Schema of the table is:

id, generic_name, brand_name, description

One record of the table is:
{
    drugs,
    "drugs-3",
    "Generic name",
    ["Trade Name","AnotherTradeName"],
    "This is the description of the drug"
}

To print the data in json format the code I have used:
-module(appname_drug_controller, [Req]).
-compile(export_all).

get('GET',[])->
  ADrugs=boss_db:find("drugs-3"),
  {json, [{resposne,ADrugs}]}.

I supposed to get:
{
  "resposne": {
    "id": "drugs-3",
    "generic_name": "Generic name",
    "brand_name": [
      "Trade Name",
      "AnotherTradeName"
    ],
    "description": "This is the description of the drug"
  }
}

But I am getting:
{
  "resposne": {
    "id": "drugs-3",
    "generic_name": "Generic name",
    "brand_name": "Trade NameAnotherTradeName",
    "description": "This is the description of the drug"
  }
}

So instead of array brand_name is returned as a single line of string. How can I get the correct structure?


text:
Q: How I can hide this php echo? I have a php code that gets the lat and long of the users in a database, is like this:
$data = array();
echo " var latlong = [ " ;

for ( $x = 0; $x < mysql_num_rows( $result); $x++) {
    $data[] = mysql_fetch_assoc( $result);
    echo " [ " , $data[ $x][ 'lat' ], " , " , $data[ $x][ 'lng' ], " ] " ;
    if ( $x <= ( mysql_num_rows( $result) - 2) ) {
        echo " , " ;
    }
}
    echo " ]; " ;

 json_encode($data);

And then in my index.php I have this to read it in javascript:
var latlong =  <?php echo json_encode($data); ?>;

The problem is that my php prints all the values in the screen, how I can hide that?

A: You forgot to wrap your JS Code in script tags (and you also output var latlong twice).
<script>
  <?php echo json_encode($data); ?>;
</script>

A: Maybe you need to understand the code :
$data = array();
echo " var latlong = [ " ;

for ( $x = 0; $x < mysql_num_rows( $result); $x++) {
    $data[] = mysql_fetch_assoc( $result);
    echo " [ " , $data[ $x][ 'lat' ], " , " , $data[ $x][ 'lng' ], " ] " ;
    if ( $x <= ( mysql_num_rows( $result) - 2) ) {
        echo " , " ;
    }
}

echo " ]; " ;

json_encode($data);

Since there is some "echo" in the code, for example : echo " [ " , $data[ $x][ 'lat' ], " , " , $data[ $x][ 'lng' ], " ] " ;, this print the json.
Just remove thoses echo or comment them using // or /* echo part */


text:
Q: Domain email, GMail, Postfix So, after a long trek around the blog-o-tubes, I arrive here.
I'm trying to set up email for my domain. I don't really want to do my own email hosting with my own mailserver, especially since my teeny tiny VPS instance is probably straining under the weight of running a webserver+app server+DB+the various message passing frameworks (hosting a prototype webapp)
I want to use my GMail address to send and receive email using my VPS as a relay - I set up email forwarding already using Postfix, so if someone sends something to "bobbytables@domain.com" it lands in my GMail account. Yay!
But now I want to respond from my GMail account, and have it forwarded to the recipient, with my domain specific email showing in the From: field. It'd be nice if everything could be done over SSL/TLS as well, for forwarding from my server to GMail, as well as requiring (or strongly preferring) it for incoming send/receive email connections. But I'm a bit lost in the master.cf/main.cf/iptables.rules files at the moment.
I just tried to close port 25 and open port 587 in iptables.rules (I understand 465 is now deprecated for SMTPS?), just to see what would happen, and incoming emails were just rejected according to the syslog - Google was trying to connect to port 25 still. But I guess I have to actually tell postfix to prefer SMTPS on 587? Is that the "smtps inet ...." line or the "submission inet..." line that I have to uncomment? And I understand that I can point my gmail account at an SMTP server, but then how do I actually create users for postfix? Do I actually create user accounts with useradd (bad, more attack "surface"), or can I create "virtual" accounts just for postfix to send mail with? In both cases, SSL/TLS seems kind of mandatory at least for the auth step...
So far I created some self-signed certs and told Postfix where they are, but now I'm kinda stuck: what ports do I open, what...err...things do I point at other things...how do I tell incoming connections "yo, encrypt yo'self homeboy"?
I've struggled with this for quite a while, and had a look through quite a few guides, but most were geared towards setting up a full mail stack, which I don't really want to do (out of resource-scarcity rather than laziness :P)

A: *

*Follow this Ubuntu Postfix Guide to configure postfix, pay attention for sasl setup. That is for postfix authentication. Submission port will be 587.

*Create Linux user(eg bobbytables) for email address bobbytables@domain.com.
sudo adduser bobbytables

*SASL Check List
Go through the SASL check list in this post to make sure sasl configuration is complete.


text:
Q: Android NDK thread aborts program Why does this c++ (NDK) thread brings the whole program down ?
{
sleep(2);

// The JNIEnv
JNIEnv* jenv = NULL;

// attach thread to running JVM
int err = jvm->AttachCurrentThread(&jenv, NULL);

char szerr[256];
sprintf(szerr, "AttachCurrentThread() returned: %d", err);

__android_log_print(ANDROID_LOG_ERROR, "MYPROG", szerr);

jvm->DetachCurrentThread();

sleep (5);
}

szerr is 0, and the program would not abort if I do not AttachCurrentThread. The abortion
happens without any error being indicated in console / logcat.
Any help?

A: Check this out:
http://comments.gmane.org/gmane.comp.handhelds.android.ndk/4687
Perhaps you should use GetEnv() to see if the environment is setup, before calling AttachCurrentThread() (otherwise no need to). More info here.


text:
Q: How to properly fail a Logic App workflow using custom inline JS exceptions I want to mark a Logic App workflow as failed by throwing custom exceptions using standard JavaScript, and I want to properly redirect the exception message to the Azure portal output. How do I accomplish this?
Here's some test code to show what I mean:
function testError() {
    throw 'this is an error error';
}

testError();

return 'nothing';

When executing this step, I get InlineCodeScriptRuntimeFailure. The inline code action 'JavaScriptCode' execution failed, with error '<null>'.

That '<null>' error is really unhelpful, and I'm surprised it doesn't work out of the box. When running the exact same code in a Node.js environment, I get Uncaught Error this is an error error, which is more in line with what I want to display in the portal.
What am I missing here?


text:
Q: How get all titles of sub-windows? I have a window with text. When I find this window in program Microsoft Spy++, this text is displayed as a title of its sub-windows.

I have this code:
interface User32 extends StdCallLibrary {
    User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class);
    int WM_SETTEXT = 0x000c;
    int WM_GETTEXT = 0x000D;

    HWND FindWindowA(String lpClassName, String lpWindowName);
    HWND FindWindowExA(HWND hwndParent, HWND hwndChildAfter, String lpClassName,
                       String lpWindowName);
    LRESULT SendMessageA(HWND paramHWND, int paramInt, WPARAM paramWPARAM, LPARAM paramLPARAM);
    LRESULT SendMessageA(HWND editHwnd, int wmGettext, long l, byte[] lParamStr);
    int GetClassNameA(HWND hWnd, byte[] lpString, int maxCount);
}

public static void main(String[] args) {
    User32 user32 = User32.INSTANCE;

    HWND zavhwnd = com.sun.jna.platform.win32.User32.INSTANCE.FindWindow
            (null, "ZAV - 1.0.05");

    HWND editHwnd = user32.FindWindowExA(zavhwnd, null,
            "WindowsForms10.RichEdit20W.app.0.2004eee", null);

    byte[] lParamStr = new byte[512];
    LRESULT resultBool = user32.SendMessageA(editHwnd, User32.WM_GETTEXT, 512, lParamStr);

    System.out.println("string: "+Native.toString(lParamStr));
}

It found that window (zavhwnd), because it isn't null, but I still cannot read text, that I want. And it would be better if it retrieve all titles of the sub-windows, because the class "WindowsForms10.RichEdit20W.app.0.2004eee" may not always be the same. Can someone help me with it?

A: I have already found how to do this:
interface ExtendedStdLib extends StdCallLibrary {
    ExtendedStdLib INSTANCE = (ExtendedStdLib) Native.load("user32", ExtendedStdLib.class);
    int WM_SETTEXT = 0x000c;
    int WM_GETTEXT = 0x000D;

    HWND FindWindowA(String lpClassName, String lpWindowName);
    HWND FindWindowExA(HWND hwndParent, HWND hwndChildAfter, String lpClassName,
                       String lpWindowName);
    LRESULT SendMessageA(HWND paramHWND, int paramInt, WPARAM paramWPARAM, LPARAM paramLPARAM);
    LRESULT SendMessageA(HWND editHwnd, int wmGettext, long l, byte[] lParamStr);
    int GetClassNameA(HWND hWnd, byte[] lpString, int maxCount);
}

public void getSelectableText() {
    ExtendedStdLib EXT_INSTANCE = ExtendedStdLib.INSTANCE;

    HWND zavhwnd = User32.INSTANCE.FindWindow(null, "{Window Title}");
    if (zavhwnd == null) {
        log.error("Window wasn't found");
        return;
    }

    User32.INSTANCE.EnumChildWindows(zavhwnd, (hwnd, pntr) -> {
        char[] textBuffer = new char[512];
        char[] textBuffer2 = new char[512];
        User32.INSTANCE.GetClassName(hwnd, textBuffer, 512);
        User32.INSTANCE.GetWindowText(hwnd, textBuffer2, 512);
        String wText = Native.toString(textBuffer);
        String wText2 = Native.toString(textBuffer2);
        if (wText.contains("RichEdit")) {
            byte[] lParamStr = new byte[2048];
            LRESULT resultBool = EXT_INSTANCE.SendMessageA(hwnd, ExtendedStdLib.WM_GETTEXT, 2048, lParamStr);
            String text = Native.toString(lParamStr, "windows-1250");
        }
        return true;
    }, null);
}


text:
Q: Add widget to a float layout Kivy im new in kivy, i am trying to attack a widget to a float layout, i have use a code from an example:
http://kivy.org/docs/guide/firstwidget.html
 from random import random
 from kivy.app import App
 from kivy.uix.widget import Widget
 from kivy.graphics import Color, Ellipse, Line
 from kivy.uix.floatlayout import FloatLayout

 class MyPaintWidget(Widget):

      def on_touch_down(self, touch):
         color = (random(), random(), random())

         with self.canvas:
             Color(*color)
             d = 15.

             Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d))
             touch.ud['line'] = Line(points=(touch.x, touch.y))

     def on_touch_move(self, touch):
         touch.ud['line'].points += [touch.x, touch.y]

 class KivyDotsLayout(FloatLayout):

     def __init__(self):
         super(KivyDotsLayout, self).__init__()
         self.add_widget(MyPaintWidget)

 class MyPaintApp(App):

def build(self):
    return KivyDotsLayout()

 if __name__ == '__main__':
     MyPaintApp().run()<code>

but then he gives me this error:
Traceback (most recent call last):
   File "/Users/Painkiller/PycharmProjects/Prova/Game/DotsGAme/example.py", line 40, in <module>
     MyPaintApp().run()
   File "/Applications/Kivy.app/Contents/Resources/venv/lib/python2.7/site-packages/kivy/app.py", line 798, in run
     root = self.build()
   File "/Users/Painkiller/PycharmProjects/Prova/Game/DotsGAme/example.py", line 36, in build
     return KivyDotsLayout()
   File "/Users/Painkiller/PycharmProjects/Prova/Game/DotsGAme/example.py", line 29, in __init__
     self.add_widget(MyPaintWidget)
   File "/Applications/Kivy.app/Contents/Resources/venv/lib/python2.7/site-packages/kivy/uix/floatlayout.py", line 115, in add_widget
     pos_hint=self._trigger_layout)

 TypeError: descriptor 'bind' of 'kivy._event.EventDispatcher' object needs an argument

but there arent bind...please help me

A:
self.add_widget(MyPaintWidget)

This should be self.add_widget(MyPaintWidget()) - you need an instance of the class, not the class declaration itself.


text:
Q: Can CSS Box shadow flow onto items below it? Is there a way cover an item below with the box shadow of the item above it?
Please take look at:this example
Is there a way to cover the the white box with the shadow of the red box? Thanks in advance.

A: Give both boxes position: relative and give the red box a higher z-index than the white box:
#d1, #d2 {
    position: relative;
}

#d1 {
    /* Other styles */
    z-index: 1;
}

#d2 {
    /* Other styles */
    z-index: 0;
}

A: #red-box { z-index: 2000; }
#white-box { z-index: 1000; }

A higher z-index means that it'll be placed on top of lower z-indexed items.

By the way, very useful that your page reloads itself so I cannot change the stylesheet from Web Inspector to test this.

A: If you give it (the top one) position:relative it will work.

A: set position: relative on div 1 before tinkering with z-index


text:
Q: Aggregate replace in SQL Server? What I'm trying to achieve is to make dynamic a series of replacements that have to be performed on a certain field. (To make things even easier, I want in fact to remove data, so I'll be always comparing with
Say that sometimes I will have to do just one replacement:
... REPLACE(myField, stringToRemove, '')

Sometimes, I will need two replacements:
... REPLACE(REPLACE(myField, stringToRemove, ''), anotherStringToRemove, '')

However, I need to make this dynamic and I do not know in advance how many of those values I'll have, and so, how many replacements (removals) I'll have to do.
I tried searching for aggregate string manipulation functions and, of course, there's none. I also know that this can be achieved through a CLR aggregate function but I don't have the possibility of using it.
Any ideas?

A: You can setup a table variable with FromValue and ToValue and use a while loop to do the replacements.
-- Table to replace in
declare @T table
(
  Value varchar(50)
)

insert into @T values
('first second third'),
('first second third')

-- Table with strings to replace
declare @Rep table
(
  ID int identity primary key,
  FromValue varchar(50),
  ToValue varchar(50)
)

insert into @Rep values
('second', 'fourth'),
('third', 'fifth')

declare @ID int
select @ID = max(ID)
from @Rep

while @ID > 0
begin
  update @T
  set Value = replace(Value, FromValue, ToValue)
  from @Rep
  where ID = @ID

  set @ID -= 1
end

select *
from @T

Result:
Value
-------------------
first fourth fifth
first fourth fifth

If you only want to query the values you can do something like this.
;with C as
(
  select 0 as ID,
         Value,
         0 as Lvl
  from @T
  union all
  select R.ID,
         cast(replace(C.Value, R.FromValue, R.ToValue) as varchar(50)),
         Lvl + 1
  from @Rep as R
    inner join C
      on C.ID + 1 = R.ID
)
select top 1 with ties Value
from C
order by Lvl desc

A: Once you implement the CLR aggregate function below, you can do:
SELECT dbo.ReplaceAgg(t.[text], w.badword, w.goodword) // call CLR aggregate function
FROM [Texts] t CROSS JOIN BadWords w
GROUP BY t.[text]

CLR aggregate function in C#
/// <summary>
/// Allows to apply regex-replace operations to the same string.
/// For example:
/// SELECT dbo.ReplaceAgg(t.[text], w.badpattern, "...")
/// FROM [Texts] t CROSS JOIN BadPatterns w
/// GROUP BY t.[text]
/// </summary>
[Serializable]
[Microsoft.SqlServer.Server.SqlUserDefinedAggregate(Format.UserDefined,
    IsInvariantToDuplicates = true, IsInvariantToOrder = false,
    IsInvariantToNulls = true, MaxByteSize = -1)]
public class RegexReplaceAgg : IBinarySerialize
{
    private string str;
    private string needle;
    private string replacement;
    public void Init()
    {
        str = null;
        needle = null;
        replacement = null;
    }
    public void Accumulate(SqlString haystack, SqlString needle, SqlString replacement)
    {
        // Null values are excluded from aggregate.
        if (needle.IsNull) return;
        if (replacement.IsNull) return;
        if (haystack.IsNull) return;
        str = str ?? haystack.Value;
        this.needle = needle.Value;
        this.replacement = replacement.Value;
        str = Regex.Replace(str, this.needle, this.replacement, RegexOptions.Compiled | RegexOptions.CultureInvariant);
    }

    public void Merge(RegexReplaceAgg group)
    {
        Accumulate(group.Terminate(), new SqlString(needle), new SqlString(replacement));
    }

    public SqlString Terminate() => new SqlString(str);

    public void Read(BinaryReader r)
    {
        str = r.ReadString();
        needle = r.ReadString();
        replacement = r.ReadString();
    }

    public void Write(BinaryWriter w)
    {
        w.Write(str);
        w.Write(needle);
        w.Write(replacement);
    }
}

A: You might have to write a scalar function to which you pass the original string, and enough information for it to know which strings to remove, and have it loop through them and return the result of the set of replacements.


text:
Q: create a coefficient matrix based on a formula using elements of a data frame in R I have the following dataframe named (A) in R:
A <- data.frame("budget_range" = c("less_than_1", "1-5", "5-20", "20-50", "50-100", "100-500", "more_than_500"),
        "coefficient" = c(0.005, 0.01, 0.05, 0.2, 0.5, 1, 5))

Budget_range    Coefficient
1_less_than_1     0.005
2_1-5             0.01
3_5-20            0.05
4_20-50           0.2
5_50-100          0.5
6_100-500         1
7_more_than_500   5

I now would like to create a 7x7 matrix where each element of the matrix = min(BudgetRange1,BudgetRange2) / max(BudgetRange1,BudgetRange2).
For example with element 2,1 or 1,2 (they should be the same), the math would be 0.005/0.01 = 0.5.
It should give something like this:
   1     2     3     4     5     6     7
1  1   0.5    0.1  0.025  0.01  0.005  0.001
2  0.5  1     0.2   0.05  0.02   0.01  0.002
3  ...
4
5
6
7

Any idea how to do it? Thanks a lot in advance!

A: We can use outer to do this
outer(A$coefficient, A$coefficient, FUN = function(...) pmin(...)/pmax(...))
#    [,1]  [,2] [,3]  [,4] [,5]  [,6]  [,7]
#[1,] 1.000 0.500 0.10 0.025 0.01 0.005 0.001
#[2,] 0.500 1.000 0.20 0.050 0.02 0.010 0.002
#[3,] 0.100 0.200 1.00 0.250 0.10 0.050 0.010
#[4,] 0.025 0.050 0.25 1.000 0.40 0.200 0.040
#[5,] 0.010 0.020 0.10 0.400 1.00 0.500 0.100
#[6,] 0.005 0.010 0.05 0.200 0.50 1.000 0.200
#[7,] 0.001 0.002 0.01 0.040 0.10 0.200 1.000


text:
Q: Quill modules in Nuxt.js I have been trying to add Quill.js on my Nuxt.js project for the most part of this past day, and it is driving me crazy.
I installed vue-quill-editorand followed the steps specified in order to serve it through Nuxt. And sure enough, it worked!
Then I tried to add custom modules, and everything I've tried has failed.
Even the "example" from Quill's documentation doesn't work. It throws a ModuleClass is not a constructor error.
Here is some sample code:
nuxt-quill-plugin.js:
import Vue from 'vue'
import VueQuillEditor from 'vue-quill-editor'
import Quill from 'quill'
import Counter from './counter'

uill.register('modules/Counter', Counter);
Vue.use(VueQuillEditor)

counter.js (Identical to the example I've linked above):

class Counter {
  constructor(quill, options) {
    this.quill = quill;
    this.options = options;
    this.container = document.querySelector(options.container);

    quill.on('text-change', this.update.bind(this));
    this.update();  // Account for initial contents

  }

  calculate() {
    let text = this.quill.getText();
    if (this.options.unit === 'word') {
      text = text.trim();
      // Splitting empty text returns a non-empty array
      return text.length > 0 ? text.split(/\s+/).length : 0;
    } else {
      return text.length;
    }
  }

  update() {
    console.log("update")
    var length = this.calculate();
    var label = this.options.unit;
    if (length !== 1) {
      label += 's';
    }
    this.container.innerText = length + ' ' + label;
  }
}

editor.vue (Where the component is used):
<template>

    <client-only>
      <quill-editor
        :options="editorOption"
        @blur="onEditorBlur($event)"
        @focus="onEditorFocus($event)"
        @ready="onEditorReady($event)"
        ref="editor"
        v-model="content"
      />

0

    </client-only>

</template>

For what's it worth, I've also set the plugin to ssr:false in nuxt.config.js
Any help will be greatly appreciated!

A:
nuxt-quill-plugin.js

import Vue from 'vue'
import VueQuillEditor from 'vue-quill-editor'

Vue.use(VueQuillEditor)

nuxt.config.js

import webpack from 'webpack'
export default {

build: {
        plugins: [
        new webpack.ProvidePlugin({
            'window.Quill': 'quill/dist/quill.js',
            'Quill': 'quill/dist/quill.js'
        }),
        ]
      }
}

page.vue

<template>

<quill-editor
    v-model="content"
    :options="editorOption"
    />

</template>


text:
Q: Why I have to restart IIS even if I change image? I have web application in ASP.Net - web form. I have facing weird problem with only this project.
1) When I make any change in code, I have to change port of IIS express to see my change after running.
2) Even when I change image or javascript and release on live, I need to restart IIS then only it shows updated image or javascript.
I checked but not getting what is the actual cause of this weird issue. It is tedious job to do IIS restart for small image change or even in local change port every time to see my change.
Any help what could be reason?


text:
Q: Space of Operators on a vector space I am taking a course on Linear Algebra and Group Theory. So, we have a definition of an linear operator on a vector space, which is simply a map $O:\mathbb{V}\rightarrow\mathbb{V}$.
with properties,
1.) $ O|v\rangle = |Ov\rangle $
2.) $(\alpha O_1 + \beta O_2)|v\rangle = \alpha O_1|v\rangle + \beta O_2|v\rangle = \alpha|O_1v\rangle + \beta |O_2v\rangle$
3.) $O_1O_2|v\rangle = O_1|O_2v\rangle = |O_1O_2v\rangle \equiv O_3|v\rangle$
I was wondering if these linear operators form a vector space by themselves. Because if they do, then cause of third property the vector space of operators will have an automatic vector product and we can have an Operator algebra. (Algebra is defined for me in my course as a ring over a vector space with vector multiplication as second binary operation).

My resolution is something like, since the dual of vector space can also be understood in terms of linear maps from vector space to itself, the linear operators look exactly like those linear maps and therefore seem to elements of the dual vector space. But there is a multiplication operation on operators which is like a composition of maps and i am not sure if the linear maps are closed under composition i.e. ( $\lambda_1o\lambda_2 \equiv ?  \mathbb{V}\rightarrow\mathbb{V}$)
A follow up doubt can be do the general operators on vector space (including non-linear ) form a vector space?

I am curious to know more about operators on vector spaces, so any extra info which overlaps (even slightly) with my doubt above will be helpful.
Thanks.

A: The dual of a vector space $V$ is the vector space of linear maps from $V$ to its underlying field of scalars $\mathbb F$.
The linear maps from $V$ to itself also forma  vector space. This is isomorphic to the vector space of $n \times n$ square matrices with elements in  $\mathbb F$ (where $n$ is the dimension of $V$, which for the purposes of simplicity we will assume to be finite). To set up the isomorphism you have to choose a specific basis for $V$, but once you do this everything falls into place. Addition and scalar multiplication of linear maps correspond to addition and scalar multiplication of vectors.
As well as addition of maps, we can also introduce the second operation of composition of maps. Composition of linear maps corresponds to multiplication of their relevant matrices. As long as you restrict yourself to invertible linear maps/matrices then you can use this second operation to create a group of linear maps/matrices, which is the general linear group of degree $n$ over the underlying field $F$.


text:
Q: What's the process "sugov:0" I have an Orange Pi installed Armbian.
I find that when I use a CPU governor called schedutil a process called
sugov:0 will exist in top. And the sugov:0 can spend about 13% CPU.
When I use the governor ondemand this process will not exist.
What's this process?

A: Sugov is a kernel thread used in ARM architecture as part of the scheduling governor.

the sugov kthread is a special RT task, which goal is just that to activate a frequency transition

As far as I can tell from the referenced documents the 13% CPU usage is a fake measurement and you needn't be worried about it.
It has a strange name so that grep can now easily find all its references in the kernel source without being overwhelmed by false matches.
References

*

*https://lwn.net/Articles/740546/

*https://lore.kernel.org/patchwork/patch/806725/


text:
Q: ASH if statement in a if statement I've seen many examples with multiple conditions related to each other, but there are 2 different unrelated conditions where the second one only should happen if the first one is true.
How can I get the following nicely organised and in 1 line?
funtion1
if [[ $valueX == 2 ]]; then
    funtion2
    if [[ $valueY -gt 16 ]]; then
        sleep $valueZ
    fi
fi

A: You can have it nicely organized, or you can have it in one line.
I'd say what you have now is already nicely organized.  I don't think there's any way to reorganize it in fewer lines without making it less legible.
(If the funtion2 weren't there, you could combine the two conditions.)
If you insist on putting that entire chunk of code on line line, you can do it simply by joining the lines and adding semicolons, like this:
funtion1 ; if [[ $valueX == 2 ]]; then funtion2 ; if [[ $valueY -gt 16 ]]; then sleep $valueZ ; fi ; fi

But as I said, I don't think anyone would call this "nicely organized"; it's more difficult to read, and to maintain, than the original multi-line nicely indented version.
Note that the [[ syntax is specific to bash; ash doesn't support it.
(Oh, and you've misspelled "function".)


text:
Q: Java compile error: package does not exist In my workspace (wsPrivate) I have 3 gradle projects.

*

*Hangman

*PixelView

*Reports

Projects PixelView and Reports compile fine. However Hangman uses those both projects and some how can't find the packages while compiling.
See the error below (which pop up during compiling Hangman):
D:\_wsGitlab\wsPrivate\Hangman\src\main\java\game\core\Game.java:10: error: package hangman does not exist
import hangman.Messages;
              ^
D:\_wsGitlab\wsPrivate\Hangman\src\main\java\game\core\Game.java:13: error: package viewer does not exist
import viewer.Box;
             ^
D:\_wsGitlab\wsPrivate\Hangman\src\main\java\game\core\Game.java:14: error: package viewer.figures.boxes does not exist
import viewer.figures.boxes.Borders;

I've read almost every bit of info I could find about classpaths and how to fix this [in my opinion] "scope-problem" as also I've tried multiple solutions but I think I'm making it worse.
The program does work fine without compiling in eclipse, so I assume the code withing is correct.
I'm now like 3 days stuck on this so if anyone could explain to me where I'm driving of the road that would be really nice. If anymore information is wanted: just ask ;)
So this is basically what I have at the moment:
Layout of my packages and added library:

Custom library that I've added to Hangman:

Projects on build path of project Hangman:

Order and export of project Hangman:

Other two projects that are referenced (pixelview / reports):

Last but not least my build.gradle:
apply plugin: 'application'

mainClassName = "game.core.Game"

repositories {
    jcenter()
}

dependencies {
    compile 'org.apache.commons:commons-math3:3.6.1'
    implementation 'com.google.guava:guava:23.0'
    testImplementation 'junit:junit:4.12'
}

jar {
    baseName = 'HangmanGame'
    version = '2.00.0'
    manifest {
        attributes(
        'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
        'Main-Class': 'game.core.Game'
        )
    }
}

A: You say you have three projects - I interprete that as one Gradle project with three separate Gradle subprojects.
If so, you need a settings.gradle file at the root level with contents like
include 'Hangman', 'PixelView', 'Reports'

You can read more about authoring multiproject Gradle builds in the Gradle documentation.

A: I have met the same problem under docker uBuntu (Without Android Studio Installed), with all the settings set as the indicated above, still got same error.
Then I found there was no local.properties file under project root, after copied local.properties from another project and correctly set up the ndk and sdk path, multi projects built successfully, my ndk/sdk path maybe different from yours.
Also this project can be built successfully on other machine with android studio installed even missing following files: local.properties(will appear after first build), gradlew, gradlew.bat, gradle-wrapper.jar
ndk.dir=/home/username/Android/Sdk/ndk-bundle
sdk.dir=/home/username/Android/Sdk


text:
Q: difference between gradle plugin android-library and AndroidStudio default com.android.library In every example I've seeing floating around the internet, they say to build an android library, I should apply the android-library plugin. When I use the AndroidStudio IDE wizard to set up a library, it applies the com.android.library plugin instead. Are these the same thing?

A: They're the same thing. The fully-qualified form is replacing the old style, which is deprecated. This will become important in the future because Gradleware is planning on implementing a global plugin repository to replace the need to specify repositories in a buildscript tag, and using fully-qualified names will help properly locate plugins in that repository.


text:
Q: Easiest way to return list without first element Somehow I don´t get this at the moment as I want.
I get data from database via NHibernate.
ICriteria criteria = session.CreateCriteria(typeof(Price));
criteria.AddOrder(new NHibernate.Expression.Order("ValidFrom", false));
List<Price> prices = criteria.List().Cast<Price>().ToList();

Now I want to return the list without the first element (the newest price). I got something working, but what would be the easiest way?

A: The easiest way would be writing criteria.List().Cast<Price>().Skip(1).ToList();


text:
Q: Find a basis of $V$ containing $v$ and $w$
Find a basis of $V$ containing $v$ and $w$, where $V=\mathbb{R}^4, v=(0,0,1,1), w=(1,1,1,1)$.

I am not sure how to begin so a hint would be appreciated. I suspect I must use the following fact: If $V$ is a finite dimensional vector space and if $U$ is a subspace of $V$, then any independent subset of $U$ can be enlarged to a finite basis of $U$.

Alright, here's my stab at an attempt for a solution:
$V_{\text{basis}}=\{(0,0,1,1),(1,1,1,1),(0,0,0,1),(1,0,0,0) \}$
Would this be correct? The two vectors I added to the basis were the standard basis vectors for $\mathbb{R}^4.$

A: Your solution works.  Here's a way to approach the question systematically:
suppose you have two linearly independent vectors $v_1,v_2$.  We know that if we include the vectors $e_1,e_2,e_3,e_4$ (that is, the standard basis vectors), then the set $\{v_1,v_2,e_1,e_2,e_3,e_4\}$ spans $\mathbb R^4$. We would like to extract a basis including $v_1$ and $v_2$ from this spanning set.  In order to do so, put the matrix
$$
\begin{bmatrix}
|  &|  &|  &|  &|  &|  \\
v_1&v_2&e_1&e_2&e_3&e_4\\
|  &|  &|  &|  &|  &|
\end{bmatrix}
$$
into reduced row echelon form.
For your example, this matrix is
$$
\left[
\begin{array}{cccccc}
 0 & 1 & 1 & 0 & 0 & 0 \\
 0 & 1 & 0 & 1 & 0 & 0 \\
 1 & 1 & 0 & 0 & 1 & 0 \\
 1 & 1 & 0 & 0 & 0 & 1 \\
\end{array}
\right]
$$
The resulting rref matrix is
$$
\left[
\begin{array}{rrrrrr}
 1 & 0 & 0 & -1 & 0 & 1 \\
 0 & 1 & 0 & 1 & 0 & 0 \\
 0 & 0 & 1 & -1 & 0 & 0 \\
 0 & 0 & 0 & 0 & 1 & -1 \\
\end{array}
\right]
$$
Now, we select only the vectors whose columns correspond to pivots in the rref form.  That is, we select $\{v,w,e_1,e_3\}$.  We now have a basis of $\mathbb R^4$ including $v$ and $w$.
Note that the answer you receive changes depending on the order in which you place the vectors in the matrix.  However, as long as you place your desired linearly independent subset first, this process is guaranteed to give you a valid basis containing that subset.
Note also that systematic approaches are only particularly useful if you don't have strokes of insight. If you have a set of vectors of which you would like to check linear independence, put vectors as columns vectors in a matrix.  Then, take the determinant or row reduce.  The vectors are independent iff the resulting rref is the identity matrix, which is true iff the resulting determinant is zero.

Verification of asker's solution:
First of all, you could check that the solution $\{v,w,e_1,e_4\}$ is received by row reducing the matrix
$$
\begin{bmatrix}
|  &|  &|  &|  &|  &|  \\
v_1&v_2&e_1&e_2&e_4&e_3\\
|  &|  &|  &|  &|  &|
\end{bmatrix}
$$
Setting that aside, there are two good methods of checking that a set of vectors is linearly independent, using (in this case) the matrix
$$
M = \begin{bmatrix}
|  &|  &|  &|  \\
v_1&v_2&e_1&e_4\\
|  &|  &|  &|
\end{bmatrix}
=
\left[
\begin{array}{cccc}
 0 & 1 & 1 & 0 \\
 0 & 1 & 0 & 0 \\
 1 & 1 & 0 & 0 \\
 1 & 1 & 0 & 1 \\
\end{array}
\right]
$$
Method 1: row reduce
Take the matrix $M$, and find its reduced row echelon form.  In this case, that comes out to
$$
\begin{bmatrix}
1&0&0&0\\
0&1&0&0\\
0&0&1&0\\
0&0&0&1
\end{bmatrix}
$$
Verifying that the matrix has full rank, which means that the set is indeed linearly independent.
Along the same lines, you could row reduce until you have an upper triangular matrix.  If the diagonal entries are non-zero, then your matrix is invertible.
Method 2: take the determinant
Now, there are several methods to computing the determinant of a matrix, and I'm not going to go too far into that.  Suffice it to say that in this case, the determinant comes out to $-1$.  Since this result is non-zero, we conclude that the matrix has full rank, which means that its column vectors are linearly independent.


text:
Q: Install Matlab on Manjaro I am trying to install Matlab on Manjaro, but after I run the script "install", I got error: ...Downloads/matlab_R2020a_glnxa64/bin/glnxa64/libexpat.so.1: file too short

Does anyone know how can I fix it?

A: From the matlab aur package:
Maybe you'd create this archive like this:
1) download the matlab installer form themathworks, let's imagine that file is ~/Downloads/matlab_R2019b_glnxa64.zip
2) extract it: unzip ~/Downloads/matlab_R2019b_glnxa64.zip -d ~/matlab
3) run the installer almost completely through manually: ~/matlab/install -downloadFolder ${HOME}/matlab/dl -destinationFolder ${HOME}/matlab/deleteme
you must enter all your proper license info here, the purpose of this is to get the toolbox files you'll need for the offline install later when you see that the installer has finished downloading everything, press the Cancel button in the gui and end the installer early you don't really want the installer to extract/decrypt the files it has downloaded
4) delete anything that might have started to be installed in the above step: rm -rf ~/matlab/deleteme
5) now you can create the tarball you'll need here: tar -cvf matlab.tar -C ~/matlab/ .
You can get your file installation key (that you must manually put into matlab.fik) from https://mathworks.com/licensecenter
Then maybe you could make the matlab.fik file you need for this package like this:
echo "xxxxx-xxxxx-xxxxx-xxxxx-..." > matlab.fik

A: Use root as the ID for the Matlab. Otherwise, the key recognition may cause errors.


text:
Q: How to access the keyboard in Xamarin.Android? I need to get the current keyboard instance in Xamarin.Android (which is currently visible in the application). Is there any way to achieve this?

A: Alternatively, if you want to use a dependency service, the following will close the soft keyboard. Unfocus is probably safer though, as the below might not take into account any assumptions made within the XF framework:
iOS:
UIApplication.SharedApplication.KeyWindow.EndEditing(true);

Android:
InputMethodManager inputManager = (InputMethodManager)MainActivity.TheInstance.GetSystemService(Context.InputMethodService);
            var currentFocus = MainActivity.TheInstance.CurrentFocus;
            if (currentFocus != null)
            {
                inputManager.HideSoftInputFromWindow(currentFocus.WindowToken, HideSoftInputFlags.None);
            }

            MainActivity.TheInstance.Window.SetSoftInputMode(SoftInput.StateHidden);


text:
Q: QLineEdit placeholder text not working in Qt 4.6.3 I am using Qt 4.6.3, and tried to set some placeholder text on a QLineEdit. But these methods didn't work:

*

*using Qt designer (uic)

*through code ui->lineedit.setPlaceholderText("phtext")

*setProperty("placeholderText","phtext")
The error is that setPlaceholderText is not a member of the QLineEdit class.
Is this a bug and\or is there a way to fix it?

A: The placeholderText property was introduced in Qt 4.7 (see documentation), so it doesn't exist in Qt 4.6.

A: While the placeholderText property exists in Qt 4.6.3, it's only enabled for Maemo5 builds:
// ### Qt 4.7: remove this #if guard
#if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5)
    Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
#endif

It seems like you're somehow mixing Qt platforms.


text:
Q: Programmatically set mat-select default option I have a component which repeats a set of elements based on a array called lstSinisDiaria in my Angular material project.

        {{linha.cd_letra_sinistro}}-{{linha.cd_local_contabil}}-{{linha.cd_ramo}}-{{linha.cd_sinistro}}

    <mat-form-field>

        <mat-select [(value)]={{linha.ds_tipo_erro}}>

            <mat-option *ngFor="let tipoErro of lstTipoErro" [value]="tipoErro.value">
                {{tipoErro.value}}
            </mat-option>

        </mat-select>

    </mat-form-field>

As you can see, one element in particular is a mat-select, which is also built from a different, static list (lstTipoErro) inside the component:
import { Component, OnInit } from '@angular/core';

import { ListaSinistroDiariaService } from './lista-sinistro-diaria-service.service';

@Component({
  selector: 'app-lista-sinistro-diaria',
  templateUrl: './app-lista-sinistro-diaria.component.html',
  styleUrls: ['./app-lista-sinistro-diaria.component.css']
})
export class AppListaSinistroDiariaComponent implements OnInit {

  lstSinisDiaria : any[];

  lstTipoErro : any[] = [
    {value: 'ACSELX'},
    {value: 'BASE'},
    {value: 'CIR'},
    {value: 'CONTABIL'},
    {value: 'NÃO INFORMADO'},
    {value: 'ONLINE'},
    {value: 'REGRA'}
  ];

  lstSituacao : any[] = [
    {value: 'AGUARDANDO CIR'},
    {value: 'AGUARDANDO USUÁRIO'},
    {value: 'AGUARDANDO PAGTO'},
    {value: 'CONTABILIZADO'},
    {value: 'VERIFICANDO'},
    {value: 'AGUARDANDO ACSELX'}
  ];

  lstAnalista : any[] = [
    {value: 'FISCH'},
    {value: 'LEO'},
    {value: 'R. ABAMBRES'},
    {value: 'MARCIO'}
  ];

  constructor(private service : ListaSinistroDiariaService) {

    this.lstSinisDiaria = this.service.getLista();
  }

  ngOnInit(){

  }

}

Even though I am able to populate the mat-options with said list, I am stuck trying to set the default value of the mat-select element, to match the value returned by the array.
What I'm trying to do is set the default selected option for each repeating mat-select to be the same as the value returned by linha.ds_tipo_erro, which is a value within the original array.
Is there a way to do something like this <mat-select [(value)]={{linha.ds_tipo_erro}}>?
PS.: This is my first time asking something here, please let me know if more information is needed or if I forgot to write or format something.

A: If you want the value be connected to the value linha.ds_tipo_erro. The correct syntax for binding is this:
<mat-select [(value)]="linha.ds_tipo_erro">
   <mat-option *ngFor="let tipoErro of lstTipoErro" [value]="tipoErro.value">
      {{tipoErro.value}}
   </mat-option>
</mat-select>

This means that the value will be also updated back to the object when you change the selection since [(value)] is syntax for two way binding. If you want just to set the value once the first time then use [value]="linha.ds_tipo_erro".
Check the official Angular documentation on binding for more details this is not specific to material controls.


text:
Q: Fail to call execve on linux after weeks I have encountered a very strange error. I execute a command with fixed args from a c++ code (execve). All was working fine during weeks.
And finally I get an error on one of my testing systems. After some monitoring and test, I understand the problem is the binary is not executed.
I have no logs and no error except the binary is not call (To be sure the problem is not on the binary, I have replace the target binary by a log script and he's not executed.)
A reboot has solved the problem, but I cannot figure why a fixed args command execution could fail, after dozen of time.
Does linux has some limitation I have hit ? There is the code who has fail :
int spawnWithRet(const std::string& file, const std::vector<std::string>& args)
{
    auto procArgs = prepareProcessArguments(file, args);
    pid_t pID = fork();
    if (pID == 0)
    {
        execCmd(file, procArgs);
        exit(0);
    }
    else
    {
        int status = -1;
        // We are the parent process
        if (waitpid(pID, &status, 0) < 0)
        {
            return status;
        }

        return status;
    }
}

void execCmd(const std::string& file, const std::vector<char*>& args)
{
    execv(file.c_str(), args.data());
    // If we reach this statement the process launch failed.
    // We have no way to inform the parent because we are detached from it.
    // Just log and continue to exit.
    sdn::log::Logger m_lg;
    sdn::log::configureLogger(m_lg, "LinuxT", "spawn");
    BOOST_LOG_SEV(m_lg, sdn::log::Sev::trace) << "Failed to execute [" << file << "]: [" << strerror(errno) << "].";
}

std::vector<char*> prepareProcessArguments(const std::string& file, const std::vector<std::string>& args)
{
    // Prepare process arguments.
    auto procArgs = std::vector<char*>{};
    procArgs.reserve(args.size() + 2); // +2 to include process name + terminator arg.
    // First add the process.
    procArgs.push_back(const_cast<char*>(file.c_str()));
    // Then the args.
    std::transform(args.begin(), args.end(), std::back_inserter(procArgs), [](const std::string& s) { return const_cast<char*>(s.c_str()); });
    // Last argument: a NULL pointer.
    procArgs.push_back(NULL);
    return procArgs;
}

linux version : 3.14.49-ge9cd4cc819 #2 Fri Oct 26 09:41:36 CEST 2018 armv7l GNU/Linux
command: /usr/sbin/pppd /dev/ttyACM3 4000000 debug lcp-echo-failure 5 lcp-echo-interval 30 nodefaultroute noipdefault usepeerdns noauth unit 3 connect"


text:
Q: Tomcat directly serve static (css, js) files shared by multiple applications I'm using the ExtJS framework which has a bulk of js and css files that are used for all apps. I intend to share these between a number of web applications (different war files).
For this reason I would like to serve ExtJS js and css directly from the web server, in my case Tomcat6, which can be used to serve static files, as in this helpful link.
Therefore I put my files under /var/lib/tomcat6/webapps/ROOT/extjs/. The static files that are directly under that directory are served correctly, e.g. /extjs/ext.js correctly serves the file at /var/lib/tomcat6/webapps/ROOT/extjs/ext.js.
However files in lower-level directories, for example /extjs/welcome/css/welcome.css, which should serve the file at /var/lib/tomcat6/webapps/ROOT/extjs/welcome/css/welcome.css, return a 404.
TL/DR
Tomcat serves static files only at top-level directory. A 404 is returned for files deeper in the hierarchy.
Config file contents:

*

*server.xml

*application's web.xml
FIXED - SOLUTION:
The issue was that I was placing the clause:
<Context docBase="/path/to/extjs-static-files" path="/extjs"/>

within Tomcat's server.xml <Engine> clause. Once I placed it within the <Host> tag it started working. Reading this doc was very helpful in identifying what I was doing wrong.

A: I'm running a RESTful web service that serves some static content stored in a directory outside of Tomcat. The directory is specified by a servlet parameter in web.xml
You could do something similar and just specify an absolute path to the files you need - place them in Tomcat somewhere or wherever road you like. I can post some sample code if you like.
Of course all other files that reference the javascript and CSS would need to change because these files will be at a different URL directory than the web apps that use them. For instance, src="restAppContextName/serve/youJavaScript.js" where serve is a @Path for the REST web service and whatever follows is a @PathParam. To the browser, /serve will be treated like it's a directory, so a relative reference from one js file to another should work.

A: This is a very basic setup to give you better understanding of what-is-what:
server.xml
<Context docBase="appname" path="/appname" reloadable="true" source="org.eclipse.jst.jee.server:appname"/>

docBase is the application root folder (webapp)
web.xml
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/res/*</url-pattern>
  </servlet-mapping>

res is just the URI distinguisher; useful if you have another one like /* pointing to a smarter servlet.
The default servlet serves statics from the root of the application.
Basically, if the file test.js is in the folder js, that corresponds to the project's:
src/main/webapp/js/test.js
It can be now reached by the URL:
http://localhost:8080/appname/res/js/test.js


text: Q: Analytically compare two 3D heatmaps of the brain I have two heatmaps of a 3D model of the brain, with the color of each pixel being an intensity of the response to a stimulus, and I want to get a metric of how "alike" those two heatmaps are, what can I use? In this picture you can see an example (2D projection) of a heatmap I want to analyze


text:
Q: angularjs stop incrementing on uncheck of checkbox I have a checkbox that adds +2 if the user checks it. I need it to only do this one time. Right now the user can constantly add plus 2 which is not what I need. I need it to add it only once. (factors.Delivery is the ng-model)
I also need it to remove the --2 and stop if the checkmark is removed, but right now, it keeps subtracting.
Any help would be appreciated
Even disabling the check after clicking would be good, but it wont disable after clicking only before.
$scope.factors.Delivery = 0;
$scope.increment = function() {
    if ($scope.factors.Delivery >= 0) {
         $scope.factors.Delivery+=2;
    } else {
        $scope.factors.Delivery-=2;
    }
};

A: 2 is greater than or equal to 0. It sounds like the only acceptable values are 2 and 0 based on your post. I would suggest:
$scope.factors.Delivery = 0;
$scope.increment = function() {
    if ($scope.factors.Delivery == 0) {
       $scope.factors.Delivery=2;
   } else {
        $scope.factors.Delivery=0;
   }
};`

or using your code, you can disable the checkbox with something like this:
ng-disabled="clickedOnce" on the checkbox and the modifications below.
$scope.factors.Delivery = 0;
$scope.clickedOnce = false;
$scope.increment = function() {
    $scope.clickedOnce = true;
    if ($scope.factors.Delivery >= 0) {
         $scope.factors.Delivery+=2;
    } else {
        $scope.factors.Delivery-=2;
    }
};


text:
Q: Difference between Search Dialog and Search Widget Android I want to know the difference between Search Dialog and Search Widget in Android. I know how to implement each of them with code but don't know difference in terms of looks, behaviors etc. Any help would be highly appreciated.

A: The search dialog is a UI component that's controlled by the Android system. When activated by the user, the search dialog appears at the top of the activity.
The search widget is an instance of SearchView that you can place anywhere in your layout. By default, the search widget behaves like a standard EditText widget and doesn't do anything, but you can configure it so that the Android system handles all input events, delivers queries to the appropriate activity, and provides search suggestions


text:
Q: Selecting rows for panda dataframe based on a condition import numpy as np
import pandas as pd

lst2 = [[0.23,"f1"],[5.36,'f2']]
lst2_df = pd.DataFrame(lst2,index=list('pd'),columns=list('ab'))
lst2_df = lst2_df.rename({'a':'A'},axis='columns')

print(lst2_df)

m = ['1','f2']
print(lst2_df.loc[lst2_df['b'].isin(m)])

If I wish to iterate this condition for every column and not hard code it what do I write?
I tried print(lst2_df.loc[lst2_df['A':'b'].isin(m)]) it didnt worked.
I know there are similar question on the site but I could not find one that addresses my issue.

A: Use:
m = ['1','f2']
print(lst2_df.loc[lst2_df.isin(m).any(axis=1)])
      A   b
d  5.36  f2

Explanation:
Compare DataFrame (all columns) by DataFrame.isin for boolean:
print (lst2_df.isin(m))
       A      b
p  False  False
d  False   True

And then add DataFrame.any for check at least one True per row:
print (lst2_df.isin(m).any(axis=1))
p    False
d     True
dtype: bool

And last filter by boolean indexing.


text:
Q: Node.js E11000 duplicate key error collection I'm trying to create a reservation with node.js and express and mongoose!
This is my Schema:
let mongoose = require("mongoose");
let Schema = mongoose.Schema;

let reservationSchema = new Schema({
  car: [
    {
      type: Schema.Types.ObjectId,
      ref: "cars",
      required: true,
      unique: false,
    },
  ],
  client: [
    {
      type: Schema.Types.ObjectId,
      ref: "users",
      required: true,
      unique: false,
    },
  ],
  request: {
    type: "Date",
    default: Date.now(),
  },
  from: {
    type: "Date",
    required: true,
  },
  days: {
    type: "Number",
    required: true,
  },
});

let reservation = mongoose.model("Reservation", reservationSchema);
module.exports = reservation;

And this is my function that I'm using to make it work while the dates does not match
function check(reservations, newReservation) {
    console.log("chegou");
    return new Promise(function (resolve, reject) {
      ReservationModel.find({}, function (err, reservations) {
        console.log("chegou aqui lol");
        console.log([reservations]);
        console.log(newReservation);
        if (err) reject(err);
        reservations.forEach(myFunction);
        function myFunction(reservations) {
          console.log("Siga ze");
          console.log(reservations.car);
          console.log(newReservation.car);
          if ((reservations.car = newReservation.car)) {
            console.log("chegou ao if");
            let date = reservations.from;
            let days = reservations.days;
            var result = new Date(date);
            result.setDate(result.getDate() + days);
            console.log(result);
            console.log(newReservation.from);
            if (newReservation.from >= result) {
              console.log("devia funfar crlh");
              resolve(newReservation);
            } else {
              console.log("Nao funfou");
            }
          } else {
            console.log("fds nao da esta merda pqp");
          }
        }
      });
    });
  }

It reaches the
if (newReservation.from >= result) {
  console.log("devia funfar crlh");
  resolve(newReservation);

So it should work, but when I get to the part when it is going to save to the database it gives me the error:

E11000 duplicate key error collection: rent-a-car.reservations index: car_1 dup key: { car: ObjectId('625af24b81b1edc90fdef50a') }

Saying that the car is already in use, and I have specifically in the Schema to not be unique.
What can I do?


text:
Q: pip3.7 ubuntu 16 pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available I'm using gitbash virtualbox and ubuntu 16 and windows 10.  I've installed the python 3.7 package from python.org and before I did that I installed
build-essential
checkinstall
libreadline-gplv2-dev
libcurfsesw5-dev
libssl-dev
libsqlite3-dev
tk-dev
libgdbm-dev
libc50-dev
libbz2-dev
libffi-dev
zlib1g-dev
and I can't install any packages with pip3.7.  I read that there are some lines I might need to uncomment in /usr/local/bin/python3.7/Modules but when I try to get into python3.7 I get the error Not a directory, so I can't try that solution.  When I try to install a package with
sudo pip3.7 install psycopg2

I get these errors:
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

I've searched everywhere for a fix to this and can't find a solution that works.
is there anything I can try to get this working?
Thanks
Michael

A: I had the same issue myself on Kali 2020.3, and found this over on askubuntu.com. It worked for me.

*

*Install the necessary packages for Python and ssl: sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

*Download and unzip Python from https://www.python.org/ into your Downloads directory.

*Open terminal in that directory and run: ./configure

*Build and install: sudo make && sudo make install
Now you should be able to install Python3 packages without TLS/SSL errors, using: pip3 install package_name


text:
Q: Configuration File Sanity Checking Framework/Software/Concept I am searching for something (be it a Framework, Software or even just a Best Practice) for the following requirement:
I want to provide a kind of blacklist of configuration values (in several configuration file formats) which must not be set/changed.
The system is a Linux(CentOS) appliance, which houses only one application, configuration changes should be rare.
I want to check several configuration files for sanity. Ranging from apache over ifcfg-eth* etc.
Is there a solution which already provides a mechanism like that for a set of 'standard' configuration files?
An Example: I want to prevent users from accidently deativating KeepAlive in Apache but they should be able to change other things in the configuration. I want to prevent 'common mistakes'.

A: I've done something similar to this with Puppet (painful) using the solution documented at: Set sysctl.conf parameters with Puppet
It was quite a bit of work to obtain a pretty basic function. In your situation, what's the ratio of parameters you wish to blacklist to those you don't mind being modified? That would impact the approach to solving this. A lot of engineers I know prefer to move entire config files versus using templates or modifying values.
CFEngine had a string modification parameter that would ensure that certain lines were present in a file and add them if they weren't. Same for comments...

A: Your use cases are the primary goals of configuration management tools like Puppet, Chef, CFEngine, bcfg2 and others.
Suppose you wanted to prevent changes to ifcfg-eth0.
You would configure these tools to track this file.
When the tools agent wakes up at regular intervals, it can either inform you that a change has occurred, or can revert the file to its original state.


text:
Q: Suddenly slow Windows File Sharing on Closed Network I'm here just to get ideas. We have two PC's running XP SP2 sharing their C drives (I know this is a security risk, but its a closed network with proprietary software). They are on a closed network with static IPs. From "My Network Places" I see "C on ComputerA" on ComputerB and vice versa. When I double click them, it locks up explorer - both machines are having this issue -- which causes the proprietary software to have issues. Ping times are relatively quick, chkdsk returned no errors. Any answers appreciated!

A: Verify:

*

*DNS Resolution if connecting via hostname rather than IP

*Firewalls are disabled on both machines, or allow File Sharing ports (UDP and TCP 135-139, 445)

*Results from command line: net view \\PCNAME

A: How about trying to connect through the administrative share at (from windows>run):
\\serverip\C$\

Does this also crash explorer?

A: Couple of ideas:

*

*Add an lmhosts or hosts entry (c:\windows\system32\drivers\etc) to expedite name resolution

*Authentication might be slowing down the responsiveness. Make sure you dupe the usernames and passwords on both systems. Or make sure you save credentials

A: Along the lines of Dave Drager, another issue could be the network cards themselves.  Just had an issue with a Broadcom NIC causing connection drops when trying to RDP.  I had to disable the 'IPv4 Large Send Offload' property of the NIC.
After that, all the problems with communication between that computer and any others went away...
-JFV

A: Based on Evan's comment, it was the network switch.


text:
Q: Question about a determinant property I encountered in a question. Here's the question:
let $A,B\in \mathbb{R}^{3\times 3}$ such that $AB=|A|I$ and $|(2A)^2(A^t)^{-1}B|=16$ then $|A|=?$
I wanted to ask about how to deal with the information that $AB=|A|I$, can I just $|AB|=||A|I|=|A|$? am I allowed to do that?
From the other information I got that $4^3|A||B|=16$ so $|AB|=\frac {1}{4}$.
So what I said was $|A|=\frac {1}{4}$, but the answer was $|A|=(\frac{1}{4})^{\frac {1}{3}}$, so I think I have a miss understanding about how to calculate $||A|I|$.
Thanks in advance for all the help.

A: From $AB=|A|\operatorname{Id}$ and from the fact that $A$ is a $3\times3$ matrix, you get that$$|A||B|=\bigl||A|\operatorname{Id}\bigr|=|A|^3.$$And from the fact that $\left|(2A)^2\left(A^T\right)^{-1}B\right|=16$, you get that$$64|A|^2\frac1{|A|}|B|=16\left(\iff|A||B|=\frac14\right).$$So, $|A|^3=\frac14$, and therefore $|A|=\frac1{\sqrt[3]4}$.

A: Hint:
$|kA|=k^3|A|$, if $A$ is $3 \times 3$.similarly $||A|I|=|A|^3$.


text:
Q: SQL figuring out days remaining based on days interval (using SQL Server 2005)? I have a table that represents a user's subscription to our system. I have two tables. One represents the subscription for an account and the other represents the type of subscription. The subscription table relates to the subscription type table with a subscriptionTypeID field in the subscription types table. I need to figure out the days remaining for that account. Here is my example:
The user signed up on January 1, 2010 and their term is 30 days. Based on today's date (January 25, 2010) they would have 6 days remaining.
I need help designing the SQL. Here is what I have so far in my stored procedure:
@SubscriptionTypesID int

Declare @term int
Declare remainder int
Set @term = (SELECT subscriptionTerm
         FROM dbo.SubscriptionTypes
         where dbo.SubscriptionTypes.SubscriptionTypesID = @SubscriptionTypesID)

Now i need to figure out what to do with the remainder query, or if I can somehow have one SQL statement so I don't have to get the term separately.
Update:
Here is what I got now with all your help, but I still want a more elgant way to pump the term field value into the query:
Select (DateDiff(day,getDate(),DATEADD (day , 30, '01/01/2010' ))) days

Update 2.0 ;)
Sometimes the answer is right in front of me and I can't even see it. I tend to over think problems and make them more complicated than they need to be. Thanks to everyone who helped! HEre is the code:
SELECT (DateDiff(day,getDate(),DATEADD (day , subscriptionTerm, dbo.Subscriptions.subscriptionDate ))) days
FROM
  dbo.Subscriptions
  INNER JOIN dbo.SubscriptionTypes ON (dbo.Subscriptions.subscriptionTypeID = dbo.SubscriptionTypes.SubscriptionTypesID)
WHERE
  dbo.Subscriptions.userID = 129

A: Err, why don't you just compare the current date to the subscription date +30 days? I believe that would look like
if(GETDATE() > DATEADD(day,30,@SubscriptionDate))
BEGIN

END

In the comments below you asked how to get teh number of days. SQL has a method for that...
SELECT DATEDIFF(datepart,start,end)

To get the value and use it in different places you can use the following syntax:
DECLARE @Difference int
SELECT @Difference = DATEDIFF(day,@SubscriptionDate,GETDATE())

A: You can use Datadiff functionality from sql:
http://msdn.microsoft.com/en-us/library/ms189794.aspx
You could also solve it using:
DATEADD (datepart , number, date )

You can find more in the same MSDN page, just use  the searchbox and type "Dateadd"
Good luck with your remaining time thingie ;)

A: HEre it is...Thanks all for the insight:
SELECT (DateDiff(day,getDate(),DATEADD (day , subscriptionTerm, dbo.Subscriptions.subscriptionDate ))) days
FROM
  dbo.Subscriptions
  INNER JOIN dbo.SubscriptionTypes ON (dbo.Subscriptions.subscriptionTypeID = dbo.SubscriptionTypes.SubscriptionTypesID)
WHERE
  dbo.Subscriptions.userID = 129


text:
Q: Django delete an object from within one of its own methods I have a model:
class MyModel(models.Model):
    parent_content_type = models.ForeignKey(ContentType, related_name='prereq_parent')
    parent_object_id = models.PositiveIntegerField()
    parent_object = GenericForeignKey("parent_content_type", "parent_object_id")

    ...

    def get_parent(self):
       try:
           return self.parent_content_type.get_object_for_this_type(pk=self.parent_object_id)
       except ObjectDoesNotExist:
           #do something that will result in this instance of MyModel to be deleted

it will break if the foreign key is deleted, so instead of breaking, I am catching it when a needed foreign key has been deleted.  When this happens, how do I delete this entire instance of MyModel, and then carry on.

A: Before you deleted your Foreign Class:
foreign = ForeignClass.objects.get(pk=id)
myModel = MyModel.objects.filter(content_object=foreign)
myModel.delete()
foreign.delete()

Hope this works for you.


text:
Q: How do I get Proton on Steam to work? I've heard about the new Steam Proton, but I have no idea how to get it to work. I'm obviously a newbie to Ubuntu and any help is appreciated! I followed the quick start on the Steam website and installed the NVIDIA driver.
What do I do?

A: You can activate Steam Play by doing:

*

*Update Steam to the latest version.

*Open Steam > Settings.

*Go to Steam Play.

*Enable all checkboxes.

*Save the settings and restart Steam.


text:
Q: Parallel Ajax Calls in Javascript/jQuery I am completely new to Javascript/jquery world and need some help. Right now, I am writing one html page where I have to make 5 different Ajax calls to get the data to plot graphs. Right now, I am calling these 5 ajax calls like this:
$(document).ready(function() {
    area0Obj = $.parseJSON($.ajax({
        url : url0,
        async : false,
        dataType : 'json'
    }).responseText);

    area1Obj = $.parseJSON($.ajax({
        url : url1,
        async : false,
        dataType : 'json'
    }).responseText);
.
.
.
    area4Obj = $.parseJSON($.ajax({
        url : url4,
        async : false,
        dataType : 'json'
    }).responseText);

    // some code for generating graphs

)} // closing the document ready function

My problem is that in above scenario, all the ajax calls are going serially. That is, after 1 call is complete 2 starts, when 2 completes 3 starts and so on .. Each Ajax call is taking roughly around 5 - 6 sec to get the data, which makes the over all page to be loaded in around 30 sec.
I tried making the async type as true but in that case I dont get the data immediately to plot the graph which defeats my purpose.
My question is:
How can I make these calls parallel, so that I start getting all this data parallely and my page could be loaded in less time?
Thanks in advance.

A: Using jQuery.when (deferreds):
$.when( $.ajax("/req1"), $.ajax("/req2"), $.ajax("/req3") ).then(function(resp1, resp2, resp3){
    // plot graph using data from resp1, resp2 & resp3
});

callback function only called when all 3 ajax calls are completed.

A: You can't do that using async: false - the code executes synchronously, as you already know (i.e. an operation won't start until the previous one has finished).
You will want to set async: true (or just omit it - by default it's true). Then define a callback function for each AJAX call. Inside each callback, add the received data to an array. Then, check whether all the data has been loaded (arrayOfJsonObjects.length == 5). If it has, call a function to do whatever you want with the data.

A: Let's try to do it in this way:
<script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
        var area0Obj = {responseText:''};
        var area1Obj = {responseText:''};
        var area2Obj = {responseText:''};

        var url0 = 'http://someurl/url0/';
        var url1 = 'http://someurl/url1/';
        var url2 = 'http://someurl/url2/';

        var getData = function(someURL, place) {
            $.ajax({
                type     : 'POST',
                dataType : 'json',
                url      : someURL,
                success  : function(data) {
                    place.responseText = data;
                    console.log(place);
                }
            });
        }

        getData(url0, area0Obj);
        getData(url1, area1Obj);
        getData(url2, area2Obj);

    });
</script>

if server side will be smth. like this:
public function url0() {
    $answer = array(
        array('smth' => 1, 'ope' => 'one'),
        array('smth' => 8, 'ope' => 'two'),
        array('smth' => 5, 'ope' => 'three')
    );
    die(json_encode($answer));
}

public function url1() {
    $answer = array('one','two','three');
    die(json_encode($answer));
}

public function url2() {
    $answer = 'one ,two, three';
    die(json_encode($answer));
}

So there, as you can see, created one function getData() for getting data from server and than it called 3 times. Results will be received in asynchronous way so, for example, first can get answer for third call and last for first call.
Console answer will be:
[{"smth":1,"ope":"one"},{"smth":8,"ope":"two"},{"smth":5,"ope":"three"}]

["one","two","three"]

"one ,two, three"

PS. please read this: http://api.jquery.com/jQuery.ajax/ there you can clearly see info about async. There default async param value = true.
By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active...

A: The following worked for me - I had multiple ajax calls with the need to pass a serialised object:
    var args1 = {
        "table": "users",
        "order": " ORDER BY id DESC ",
        "local_domain":""
    }
    var args2 = {
        "table": "parts",
        "order": " ORDER BY date DESC ",
        "local_domain":""
    }

    $.when(
        $.ajax({
                url: args1.local_domain + '/my/restful',
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                },
                type: "POST",
                dataType : "json",
                contentType: "application/json; charset=utf-8",
                data : JSON.stringify(args1),
                error: function(err1) {
                    alert('(Call 1)An error just happened...' + JSON.stringify(err1));
                }
            }),
        $.ajax({
            url: args2.local_domain + '/my/restful',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            type: "POST",
            dataType : "json",
            contentType: "application/json; charset=utf-8",
            data : JSON.stringify(args2),
            error: function(err2) {
                calert('(Call 2)An error just happened...' + JSON.stringify(err2));
            }
        })

    ).then(function( data1, data2 ) {
        data1 = cleanDataString(data1);
        data2 = cleanDataString(data2);

        data1.forEach(function(e){
            console.log("ids" + e.id)
        });
        data2.forEach(function(e){
            console.log("dates" + e.date)
        });

    })

    function cleanDataString(data){
            data = decodeURIComponent(data);
            // next if statement was only used because I got additional object on the back of my JSON object
            // parsed it out while serialised and then added back closing 2 brackets
            if(data !== undefined && data.toString().includes('}],success,')){
                temp = data.toString().split('}],success,');
                data = temp[0] + '}]';
            }
            data = JSON.parse(data);
            return data;                    // return parsed object
      }

A: In jQuery.ajax you should provide a callback method as below:
j.ajax({
        url : url0,
        async : true,
        dataType : 'json',
        success:function(data){
             console.log(data);
        }
    }

or you can directly use
jQuery.getJSON(url0, function(data){
  console.log(data);
});

reference

A: You won't be able to handle it like your example.  Setting to async uses another thread to make the request on and lets your application continue.
In this case you should utilize a new function that will plot an area out, then use the callback functions of the ajax request to pass the data to that function.
For example:
$(document).ready(function() {
    function plotArea(data, status, jqXHR) {
      // access the graph object and apply the data.
      var area_data = $.parseJSON(data);
    }

    $.ajax({
        url : url0,
        async : false,
        dataType : 'json',
        success: poltArea
    });

    $.ajax({
        url : url1,
        async : false,
        dataType : 'json',
        success: poltArea
    });

    $.ajax({
        url : url4,
        async : false,
        dataType : 'json',
        success: poltArea
    });

    // some code for generating graphs

}); // closing the document ready function

A: It looks like you need to dispatch your request asynchronously and define a callback function to get the response.
The way you did, it'll wait until the variable is successfully assigned (meaning: the response has just arrived) until it proceeds to dispatch the next request. Just use something like this.
$.ajax({
  url: url,
  dataType: 'json',
  data: data,
  success: function(data) {
     area0Obj = data;
  }
});

This should do the trick.

A: you may combine all the functionality of the different ajax functions into 1 ajax function, or from 1 ajax function, call the other functions (they would be private/controller side in this case) and then return the result. Ajax calls do stall a bit, so minimizing them is the way to go.
you can also make the ajax functions asynchronous (which then would behave like normal functions), then you can render the graph at the end, after all the functions return their data.

A: Here's a solution to your issue: http://jsfiddle.net/YZuD9/


text:
Q: How to know if there's a dependency update using Gradle Version Catalog My project is using now Version Catalog for all the Gradle modules, and now using the type safe declaration of dependencies in the build.gradle file I don't get any suggestions from the IDE when there's an update of a specific dependency.
What would be the best approach to know if there's an update of a dependency, instead of checking manually one by one?

A: My recommendation is to use the gradle-versions-plugin or this extension of it (https://plugins.gradle.org/plugin/se.ascp.gradle.gradle-versions-filter). Both add an additional gradle task dependencyUpdates to your project that will tell you which version updates are available.
Also works fine in combination with the new versions catalog feature you mentioned. I am using it too.


text:
Q: Can I enforce use of DataContracts when creating a service end point from WSDL? I am trying to create a WCF service client using VS 2010. The service itself is not WCF and I have no control over it. As the service uses polymorphic arrays in its responses, I must inject KnownTypes in my client. What I wanted to do is adding a DataContractResolver as described in
http://msdn.microsoft.com/en-us/magazine/gg598929.aspx, but this does not work, because the classes generated in my client stub do not use DataContracts (my code is never called). Is there any possibility to enforce that? Or can I do something like the DataContractResolver on classes only that have the following attributes:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.233")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.SoapTypeAttribute(Namespace="...")]


text:
Q: As for the expression of MariaDB's manual I learn about MariaDB reading the below page.
https://mariadb.com/blog/getting-microsoft-sql-server-data-mariadb-connect-storage-engine
The part of the first sentence "MariaDB works with many clients" is a little bit vague for me.
Could you tell me what this means if you were a native English speaker or an advanced English leaner?
Here are the options.
(a) The MariaDB foundation cooperates with other companies or organizations.
(b) The MariaDB server works with other middleware such as ODBC.


text:
Q: Is it possible to specify rule processing order in Amazon Route 53? I'd like to setup a catch-all for my subdomains:
*.domain.com.    CNAME    domain.com

But, a few specific subdomains should have their own entry:
mail.domain.com.    A        X.X.X.X
*.domain.com.       CNAME    domain.com

The problem is, how can I specify that I want the first rule to be processed before the catch-all?
As far as I can see, there is no way to reorder the rules. So, if I create a rule after the catch-all, the catch-all might be processed before the specific rule.
There's a weight parameter, but it doesn't look like it's designed for this purpose, but for load balancing.

A: Reply from the AWS support (emphasize mine):

If you setup a wildcard DNS entry for your Domain this will catch all
  queries where you haven`t specified a record.
As example:
localhost.domain.com. A 127.0.0.1
*.domain.com.         A 127.0.0.2
www.test.domain.com.  A 127.0.0.3

A query for localhost.domain.com. will return the specified A Record 127.0.0.1
  A query for test.domain.com. will return the wildcard record 127.0.0.2
  A query for www.test.domain.com. will return the specified record 127.0.0.3
This means a specified Record within your hosted Zone will always have
  a higher priority as a wildcard record.


text:
Q: Use of past perfect tense We normally use past simple tense to talk about the past and past perfect tense to talk about the past in the past, i.e. to talk about some event that that happened before some other event. I often see that when we use past perfect tense, we use it with past simple tense,e.g. I had learned Chinese before I moved to China. What if I use a non-finite adverb clause, e.g. I had learned Chinese before moving to China? How different are these two alternatives?

A: I had learned Chinese before I moved to China.
I had learned Chinese before moving to China.
There is no difference in meaning of these sentences except that the latter is more formal.


text:
Q: Dropdown not disable when radio button is clicked It's supposed to be working but unfortunately it isn't. I don't know what is wrong with my code. When I try in jsfiddle , it's working but in my Notepad++ it doesn't works. I can't figure out what's wrong with this.

 <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

Senior :

<input name="senior" type="radio" id="Yes" value="Yes" />Yes
<input name="senior" type="radio" id="No" value="No" selected="selected" />No

<select name="seniordis" id="select">
<option value="100" >100% discount</option>
<option value="50">50% discount</option>
<option value="10">10% discount</option>
</select>

A: The issue is not with the code. The issue is with the way you are referencing the libraries. Change the references to have a https://
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

It is not working in your Notepad++ because you are viewing this file in the brwoser which will have the file:// request and not https://. It works in your fiddle because there you might be referencing the library in different way but Valid way.
Also pointing out a mistake in your code.
This line $('#seniordis').removeAttr('disabled', true);
Here seniordis in the value of name attribute of your select tag and not the id if it... so use Either $('[name="seniordis"]') to target the element by name or $('#select') to target the element by id.
So the code should be
$('#select').attr('disabled', true);
OR this
$('#select').removeAttr('disabled');

A:

Your problem is,  senoirdis is name not a id. Your id is select.

$().ready(function()
{
    $('input:radio[name="senior"]').change(function() {
        if ($(this).val()=='Yes') {
            $('#select').prop('disabled',false);
        }
        else
        {
            $('#select').prop('disabled',true);
        }
    });

});

A: There are some Errors with your code

*

*This line
input:radio[name="senior"]

Must be this
input[name=senior]:radio

*This Line
$('#seniordis').attr('disabled',false);

Must be
$('#select:input').removeAttr('disabled');

Use code Below:

    <input name="senior" type="radio" id="Yes" value="Yes"  />Yes
    <input name="senior" type="radio" id="No" value="No" />No

    <select name="seniordis" id="select">
        <option value="100">100% discount</option>
        <option value="50">50% discount</option>
        <option value="10">10% discount</option>
    </select>

A: $('input:radio[name="senior"]').change(function() {
    if ($(this).val() == 'Yes') {
        $('select[name="seniordis"]').attr('disabled',false);
    } else {
        $('select[name="seniordis"]').attr('disabled', true);
    }
});

jsFiddle


text:
Q: Picking 'linux-signed' as source package instead of 'linux-image-4.15.0-23-generic' I added
deb-src http://security.ubuntu.com/ubuntu bionic-security main

into my sources.list, did apt update
Here's what I'm getting:
vm@vm-Standard-PC-i440FX-PIIX-1996:~$ apt-get source linux-image-4.15.0-23-generic
Reading package lists... Done
Picking 'linux-signed' as source package instead of 'linux-image-4.15.0-23-generic'
Need to get 17,8 kB of source archives.
Get:1 http://security.ubuntu.com/ubuntu bionic-security/main linux-signed 4.15.0-23.25 (dsc) [2.050 B]
Get:2 http://security.ubuntu.com/ubuntu bionic-security/main linux-signed 4.15.0-23.25 (tar) [15,8 kB]
Fetched 17,8 kB in 1s (11,9 kB/s)
dpkg-source: info: extracting linux-signed in linux-signed-4.15.0
dpkg-source: info: unpacking linux-signed_4.15.0-23.25.tar.xz

it keeps downloading linux-signed
UPDATE:
If I do
apt-get source linux

it works but then I still need to do
sudo apt-get build-dep linux-image-$(uname -r)

in order to install the dependencies. However, it will install the dependencies of linux-signed. If I try sudo apt-get build-dep linux it installs a lot of things that are not necessary to build a kernel