text:
Q: How do I get the bonus treasure in the Mirro Shaz shrine? The Mirro Shaz shrine is fairly straightforward; you walk in, there is a ball tee'd up in the middle of the room, and a chest with a sledgehammer. Use Stasis on the ball, swing a few times with the hammer, bing bang boom, this golf game is over and the door opens when the ball lands in the hole on the other side of the wall.
Simple enough.
But where's the bonus treasure!?!? Every shrine has bonus treasure, and a simple iron sledgehammer required to solve the puzzle surely isn't it!

A: As you approach the altar to 'complete' the shrine, you'll notice that there's actually another path around the back to the left.
If you follow this path, you'll come to an elevator that leads down to a mirror of the first room. Same tee, another sledgehammer, and a door with a chest behind it.
But this time, the golf shot is far less forgiving. There are pillars obstructing all but the straightest of shots, and the hole doesn't have a large platform leading up to it to provide the relatively forgiving shot of the first tee. In order to land the shot at the exact distance, you'll need to hit it four times with the sledgehammer and then twice more with a one-handed weapon while under stasis. And it needs to be perfectly straight.
Good luck!

A: In addition to the other answer, another way to solve this bonus treasure puzzle is to just pick up the ball and move it backwards. This way you can adjust your distance a bit better. I moved the ball to be right next to the back wall, then it took 6 hits with the sledgehammer to send it into the goal.
The reward for this bonus section is

 a Giant Ancient Core

A: I tried the solutions provided here and resorted to looking at some playthrough videos in the end. The bottom line for me was: Everybody does it differently. Still, I will provide my solution in a seperate answer:

*

*Line up with the ball, don't move it. You should stand straight in front of it with the "handle" of the Sheikah eye (the arch over the hole) seen inside the dent of the pillar.

*Use stasis.

*Target the ball with ZL and hit it 5 times.

*Hit it with a one-handed weapon 1 time. Note: I am not sure how the damage affects the hit distance. I used a one-handed sword with ~30 dmg, a broad sword if I recall correctly.

*The ball should bounce once before the platform, then into the circle and roll into the hole.

The most important part, of course, is aim. The biggest problem for me was the perspective change when using stasis. If you find yourself aiming in the wrong direction after stasis, don't waste the hits and weapon durability.


text:
Q: Multithread server program in Java I am trying to write a multithread program in Java where a server listens for connections from clients and spawns a thread to acommodate each client. I have:
while(true)
    {
        Socket s = server.accept();
        ClientHandler ch = new ClientHandler(s);
        Thread t = new Thread(ch);
        t.start();
    }

My question is: whenever it accepts a connection in
Socket s = server.accept();

and starts executing the following lines of code to create the thread etc., what happens to a request for connection from a client during that time. Is it queued somehow and it will get served in the next loop of while(true) or will it be rejected?
thanks,
Nikos

A: After the accept() returns the TCP handshake is complete and you have a connected client socket (s in your code). Until the next call to accept() the OS queues pending connection requests.
You might want to check out some tutorial like this one for example.

A: I wrote a tiny http server in Java, which you can find on github. That might be a good example for you to take a look at real-world usage of Sockets and multithreading.

A: As it was answered already: yes it is queued and no it is not rejected.
I think that anyone reading this question should first know that when you instantiate a socket:
server = new ServerSocket(mPort, mNusers);

Java is already implementing a network socket ; which has clearly defined behavior. The connection will be rejected however after reaching the limit set.
Also, the code posted in the question accepts multiple connections but looses the refference for the previous. This may be a "duh" but just in case someone is copy-pasting , you should do something to store all the created sockets or handlers. Perhaps:
ClientHandler[] ch = new ClientHandler[mNusers];
int chIndex = 0;
while(true)
    {
        Socket s = server.accept();
        ch[chIndex] = new ClientHandler(s);
        Thread t = new Thread(ch);
        t.start();
        chIndex++;
    }

An array may not be the best option but I want to point out that with sockets you should know what's the limit of connections you will allocate

A: ugh :)
there is a so called SYN-queue, which takes up to the requested amount of not yet established connections (there is a per call and a system-wide limit - not sure if its even user limited).
when "listening" on a ServerSocket, you specify that by - one of the answers says "Nusers" but it is - the size of the "backlog" the socket should keep. in this backlog the pending connections are stored and if it is filled up, all other (should) get a ConnectionRefused.
So
a) increase that when you are to slowly accepting (server.accept())
    connections
b) accept the connections faster by
b.1)  using a ThreadPool (be happy moving the problem to context-switches of the os)
b.2)  use NIO and with that the ability to handle socket-states
    within single threads/CPUs (as long as the internal data throughput is better than the one in the network, this is the more performant option)
have fun

redpajama_set_name: RedPajamaStackExchange


text:
Q: using "that is" in a sentence I'm a bit confused about the use of "that is" to add explanatory info about what is being talked. Also, can I also use it when the noun deserving explanation is plural? Here an example:

Encircling the town were military stations of "changers", that is men
  hired by the government to make sure that all inhabitants obeyed the
  rules.

Is this sentence correct?
Also, in this case the noun that requires explanation "changers" is plural, yet I suppose I don't have to write "that are" instead of "that is" nor do I have to use the past tense and write "that were" or "that was".
Thank you

A: 'that is' means 'in other words'.
If you put a comma after 'that is', it becomes like an extra phrase in the sentence, so it doesn't matter whether the noun following is singular or plural.


text:
Q: Add a website to Azure AD I'm a Belgian student and I'm currently an intern in a small company.
I have configured Azure AD with Password Hash Sync + SSO WatchGuard (Allows all users automatically connect to the Internet), and it's working pretty well.
All the users connect to their computer with AD credentials and have access automatically to Internet and Office 365.
But now I would like to do another thing, we have a website in the internal network working with authentication by AD and I would like to add this website to Azure if possible ? In this way, all the users can access to this website automatically.
Thank you.

A: Azure AD and AD are very different and use different authentication protocols (Open ID vs LDAP etc.). Because of this, you cannot just substitute Azure AD for AD in your web application, you would need your web application to be updated to support authentication using Azure AD.


text:
Q: python rss feedparser can't parse description correctly My Python code can't parse "description" from RSS feed, when I run following script, it shows multiple lines of blanks, how could I parse it correctly?
import feedparser
import unidecode
rss_url = "http://my.blogspot.com/feeds/posts/default?alt=rss"
feed = feedparser.parse( rss_url )
for key in feed["entries"]:
    print unidecode.unidecode(key["description"])

RSS description section:
<description><iframe src="https://domain.com/embed/NTXFZhHw/01-10-1080p.mp4" scrolling="no" frameborder="0" width="700" height="430" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>  </description>

A: Please replace:
import feedparser

with:
import feedparser
feedparser._HTMLSanitizer.acceptable_elements.update(['iframe'])


text:
Q: How to change theme of a fragment programmatically in android I have a MainActivity where i show different fragments on button click. But for one particular fragment, I have to change the theme where toolbar has different color. I checked many posts and i came across the code,"setTheme(R.style.AppTheme)". I cannot apply this in MainActivity, because it will be applied to all Fragments. So how to set theme for a specific fragment.
.

A: Run the prefs sentences into run() method
  new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
pref = getSharedPreferences("MyPref", 0);
    editor = pref.edit();
    String userid=pref.getString("driver_id","");

    Log.e("userid",userid);
    if(!TextUtils.isEmpty(userid))
    {
        String usertype=pref.getString("userType","");
        if(usertype.equals("customer"))
        {
            Intent customer=new Intent(SplashActivity.this, NavigationActivity.class);
            startActivity(customer);
        }
        else if(usertype.equals("driver"))
        {

            Intent driver=new Intent(this, DriverNavigationActivity.class);
            startActivity(driver);
            finish();

        }
    }
    else
    {
        Intent walk=new Intent(SplashActivity.this,SigninActivity.class);
        startActivity(walk);
    }

        }
    }, 2000);


text:
Q: C# Upcasting / Polymorphism Issue I believe this question is fairly basic but I am having trouble finding an answer to this question. In C# let's say I have 3 classes: A, B, C
B derives from A
C derives from B
Now, if I wanted a list or array of objects of type class A but wanted the array to be able to house objects of type B and C this is no problem... I could do something like this:
A[] myArrayofAtypes;

However let's say I make the first element of this array of type C. If type C has a variable defined in its class definition that ONLY exists in class C's class definition... how do I access that variable from the array? I can't just do A[0].MyVariableGetter as that variable does not exist in the base class, A.
Any suggestions?

A: You have to downcast it:
C c = (C)myArrayofAtypes[0];
var v = c.MyVariableGetter;

A: You have to type cast it to type c and access the member.
If (arr[i] is c)
{
    ((C)arr[0]).member = value;
 }

A: Instead of casting as 'king.code' has suggested like this I would use these pretty C# operators which are 'is' and 'as'.
public void CallIfTypeC(A a)
{
    if (a is C)
    {
        C c = a as C;
        c.DoAction();
    }
}


text:
Q: How can I format the different sections of the input .txt in Java I need to format the I/O text, which comes from a .txt file. I am able to print it, but I can't separate it in the different categories.
public class Main {
    public static void main(String[] args) throws Exception {

    class Recipe implements java.io.Serializable {
        private String name, ingredients, steps;

        public Recipe(String name, String ingredients, String steps) {
            this.name = name;
            this.ingredients = ingredients;
            this.steps = steps;
         }

        public String toString(){
             return "dishName: " + name + " ingredients: " + ingredients + " steps: ";
         }

    }

        Scanner input = null;

        try {
            //Choose the file that you will use.
            input = new Scanner (new BufferedReader(new FileReader ("Root/src/recipes.txt")));

            while ( input.hasNext() ) {

                System.out.println(input.nextLine());

            }

            //Read your input and create the Objects Recipe

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (input != null){
                    input.close();
                }
            } finally {
                if (input != null){
                    input.close();
                }
            }
        }
    }
}


text:
Q: Workaround for exporting data to Excel with more than 255 columns SSMS and SSRS to Excel enable for more than 255 columns when copy-pasting.
SSIS does not allow for more than 255 columns to be exported to Excel 2007.
Is there a way to override this?

A: Problem
There are a lot of Limitations when exporting to an Excel Files using Sql server data tools
Workarounds
You can do some workaround to achieve this:

*

*Create a dataflowtask that export your data into a FlatFile (csv)

*Store your Destination FileName in a Variable

*Create another Dataflowtask that convert your csv file to an Excel File using a script task with a similar Function

Note: you have to add Microsoft.Office.Interop.Excel.dll file to the following directories (.Net Framework dll directory)  C:\Windows\Microsoft.NET\Framework\v2.0.50727 and (sql server data tools dll directory) C:\Program Files\Microsoft SQL Server\100\DTS\Binn (using vs 2005 and sql 2008) and then add this dll as a reference in your script task
    Imports Microsoft.Office.Interop

    Public Sub ConvertCSVToExcel(Fromcsv As String, Toxlsx As String)
        Dim Exl As New Excel.Application()
        Try
            Dim wb1 As Excel.Workbook = Exl.Workbooks.Open(Fromcsv, Format:=4)
            wb1.SaveAs(Toxlsx, FileFormat:=XlFileFormat.xlOpenXMLWorkbook)
            wb1.Close()
            Exl.Quit()
        Catch ex As Exception

                        Exl.DisplayAlerts = False
            Exl.Quit()

        End Try
    End Sub

Third party components
Or you have to use a third party components like cozyRoc SSIS+
Side Note
if you are looking to Import data from excel with more than 255 columns you can follow this Link

References
Third party components

*

*SSIS: Export more than 255 columns from SQL table to Exce

*Cozyroc website
Workaround

*

*convert csv to xlsx

*trying to use custom assembly with script task in SSIS 2008 - can't find correct version of GACUtil

A: Refer the link. Best would be to create an script in SSIS to copy the content as csv format. You can use c# or VB.Net.

A: just for anyone come to this page and use  SQL Server Import and Export Wizard to export to excel
in tab Review Data Type Mapping
section Data Type Mapping:  ==> double click your column that has length more than 255 char open its Column Conversion Details Dialog then close it
then next to end...Lool


text:
Q: How does Linux display Unicode characters? I have a simple Python PIL script that's render some list of unicode symbols with FreeSerif font, which is have the most full unicode support (about 65k glyph)
but in reality Arch Linux with last version of KDE Plasma can render more
meanwhile as main OS font i'm using Noto - which is have very poor coverage
can someone explain why?

Asian symbols with plain simple Noto Sans ( not CJK! )

A: With a dedicated font rendering script, we can expect it to render only the specified font.
However, either on KDE (with kcharselect) or Gnome, (with gnome-characters), we have an application which load some fonts to cover a larger charset.


text:
Q: Can a which-clause be used with another which in this sentence? Apologies for the unclear title, but I wasn't sure how to phrase it.

Situation
Assume a table, on which lies an object, occupying half of the table. A hat is placed on the table.

Question

Which of the following sentences is correct?

*

*The hat was placed on the table, half of which was occupied by an object

*The hat was placed on the table, which half of which was occupied by an object
The second sentence feels so unnatural to me, but isn't the first one not quite right either? Though not ungrammatical, it has a ring of offering a rather parenthetical, separate clause rather than a clause describing the previous one (that is, reading the first sentence, I get an impression of "and by the way, half of the table was occupied by an object". Indeed, I feel a semi-colon rather than a comma would be preferable in that case).
Also consider the sentences

*The hat was placed on the table, which was occupied by an object

*The hat was placed on the table, which was partly occupied by an object

Any input on the matter would be appreciated.

A: The problem with using which in either of your example sentences (between the two, the first sounds more natural) is that it's not entirely clear if which refers to the hat or to the table. We can assume it refers to the table, but it's possible that it doesn't.
One way of rephrasing the sentence is to remove the comma and use an adjectival phrase:

The hat was placed on the table which was half-occupied by an object.

Without the comma, which is now easily parsed as applying to the table specifically.

But there is now another problem. Without the comma, the sentence implies that there is more than a single table and that, of all of the tables, the hat was placed on the one that was half-occupied by some object.
(If that actually is the intended meaning, then there is no problem.)
You mention using a semicolon. That would certainly be one way of removing this particular ambiguity:

The hat was placed on the table; half of the table was occupied by an object.

This works but it's a bit long-winded.

Perhaps the most appropriate method of saying this is to reuse an earlier suggestion but simply change the definite article in front of table to the indefinite article:

The hat was placed on a table which was half-occupied by an object.

This is concise, presents no ambiguity, and also doesn't convey the implication that there is necessarily more than a single table.


text:
Q: Conversion error in converting Redhawk device from 1.8.4 to 1.9 I am using Redhawk 1.9. I have created a Redhawk Device from the 1.8.4 IDE.

*

*1.8.4 Redhawk Device (created with all default settings)

*C++ implementation

*Import existing project into 1.9 IDE

*I read the Redhawk 1.9 Release notes on how to convert between 1.8.4 and 1.9 projects
*http://redhawksdr.github.io/Documentation/Release_Notes_1.9.0.pdf*

I import the default 1.8.4 device into the 1.9 IDE. I am able to run and build the 1.8.4 device in the 1.9 IDE. When I try to regenerate the code for 1.8.4 device, the IDE ask me if I want to upgrade to 1.9. The popup says "ConversionTestDevice uses deprecated code generators. Would you like to upgrade this project?". I decided to do an upgrade. I then get the following error message:
/usr/local/redhawk/core/bin/update_project returned with error code 1
Traceback (most recent call last):
  File "/usr/local/redhawk/core/bin/update_project", line 222, in ?
    if check_bulkio_input(compCpp):
  File "/usr/local/redhawk/core/bin/update_project", line 105, in check_bulkio_input
    for line in strip_comments(open(filename, 'r')):
  File "/usr/local/redhawk/core/bin/update_project", line 86, in strip_comments
    ch += safe_next(chars)
  File "/usr/local/redhawk/core/bin/update_project", line 56, in safe_next
    return next(item)
NameError: global name 'next' is not defined
I would appreciate suggestions on how to convert 1.8.4 device  to 1.9 device.

A: Based on your error message "NameError: global name 'next' is not defined" and the contents of the 1.9.0 release of update_project python script, I am assuming that you are running a version of python less than 2.6.  The next function is a python builtin that was introduced in Python 2.6 (http://docs.python.org/2/library/functions.html#next).  This is a known bug in the upgrade script as it should be compatible with Python 2.4 as well as Python 2.6 (The default python installations in CentOS 5 and 6 respectively).  To fix this, you may modify the update_project script located in $OSSIEHOME/bin/update_project and define the following function:
if not hasattr(__builtins__, 'next'):
    # Python 2.4 does not have a free-standing next() function
    def next(iterator, default):
        """
        Backwards compatibility next() equivalent for Python 2.4.
        """
        try:
            return iterator.next()
        except StopIteration:
            return default

You should then remove the previously defined "safe_next" function.
Lastly, you need to replace the two calls to "safe_next" with a call to the newly implement next function and add a second argument of empty string ''
For clarity, a diff of update_project with these changes is below:
@@ -46,16 +46,16 @@ Options:

 _bulkio_re = re.compile('BULKIO_data[A-Za-z]+_In_i')

-def safe_next(item):
-    """
-    Returns the next value of the iterator, or an empty string if the end of
-    iteration has been reached. Allows string processing to gracefully handle
-    the end of a line without explicit catch statements.
-    """
-    try:
-        return next(item)
-    except StopIteration:
-        return ''
+if not hasattr(__builtins__, 'next'):
+    # Python 2.4 does not have a free-standing next() function
+    def next(iterator, default):
+        """
+        Backwards compatibility next() equivalent for Python 2.4.
+        """
+        try:
+            return iterator.next()
+        except StopIteration:
+            return default

 def strip_comments(source):
     """
@@ -75,7 +75,7 @@ def strip_comments(source):
                 # Look for end comment token; if the end of the line is reached
                 # ch will be an empty string
                 while ch == '*':
-                    ch = safe_next(chars)
+                    ch = next(chars, '')
                     if ch == '/':
                         inComment = False
                         break
@@ -83,7 +83,7 @@ def strip_comments(source):
             if ch == '/':
                 # Read the next character to see if it matches a comment token
                 # (if it does not, both characters will be added to the output)
-                ch += safe_next(chars)
+                ch += next(chars, '')
                 if ch == '/*':
                     # Comment, start discarding
                     inComment = True


text:
Q: Bash split a list of files I have 200 files in a folder like: test_1_cfg.dat, test_2_cfg.dat,.... and so on. I need to include in a bash script the first 40 files as input and run some process, another script to read the next 40 files and run another process.
So I was thinking of a way to have a list of the names of the files and then just split that list but I'm not sure how to do it in bash.
Any idea?

A: This is a perfect recipe for xargs:
cat list_of_files | xargs -n 40 command

Quoting from man xargs:
 -n number   Set the maximum number of arguments taken from standard input
             for each invocation of the utility.  An invocation of utility
             will use less than number standard input arguments if the
             number of bytes accumulated (see the -s option) exceeds the
             specified size or there are fewer than number arguments
             remaining for the last invocation of utility.  The current
             default value for number is 5000.

In order to perform different actions for each set, you'd need to get relevant lines before passing those to xargs:
 sed -n '1,40p' list_of_files | xargs command1
 sed -n '41,80p' list_of_files | xargs command2
 ...

A: FYI, I LOVE the xargs -n 40 <<<$files but since it does "40 args" per line I did
threads=10
xargs -n $((40/threads)) <<<$files

or if in an array..
n=(1 2 3 4 5 6)
xargs -n $((${#n[@]}/threads))

while read -r input; do
  for item in $input; do
    <..stuff..>
  done &
done <<< $(for x in ${n[@]}; do echo $x; done | xargs -n $((${#n[@]}/threads)))
wait

A: Method #1 - Using head & tail
You can use the command head to pull out the first 40 files from a file listing like so:
$ head -40 input_files | xargs ...

To get the next 40:
$ tail -n +41 input_file  | head -40 | xargs ...

...

$ tail -n +161 input_file | head -40 | xargs ...

You can keep walking down the list, 40 at a time using this same technique.
Method #2 - Using xargs
If you happen to have all your filenames in a variable, you can use xargs like so to break up the list into chunks of X number of elements.
Example
Pretend my files are called 1-200. So I load them up into a variable like so:
$ files=$(seq 200)

You can see the first couple of items in this variable:
$ echo $files  | head -c 20
1 2 3 4 5 6 7 8 9 10

Now we use xargs to divide it up:
$ xargs -n 40 <<<$files
1 2 3 4 5 6 7 8 9 10 ...
41 42 43 44 45 46 47 ...
81 82 83 84 85 86 87 ...
121 122 123 124 125 ...
141 142 143 144 145 ...
161 162 163 164 165 ...
181 182 183 184 185 ...

You could then pass the above command to another xargs which would then run your program:
$ xargs -n 40 <<<$files | xargs ...

If the contents of the list of files isn't easily accessible from a variable you can give xargs a list via a file instead:
$ xargs -n 40 <input_file
1 2 3 4 5 6 7 8 9 10 ...
41 42 43 44 45 46 47 ...
81 82 83 84 85 86 87 ...
121 122 123 124 125 ...
141 142 143 144 145 ...
161 162 163 164 165 ...
181 182 183 184 185 ...

Method #3 - Bash arrays
Say you had your filenames in a Bash array. Again I'm using a sequence of number 1-200 to represent my filenames.
$ foo=( $(seq 200) )

You can see the contents of the array like so:
$ echo ${foo[@]}
1 2 3 4 5 ....

Now to get the 1st 40:
$ echo "${foo[@]:0:40}"

The 2nd 40, etc:
$ echo "${foo[@]:40:40}"
...
$ echo "${foo[@]:160:40}"


text:
Q: How to count cells in row with different length based on value of previous cell in row? I need to make a formula to count how many sessions occurred during user lifetime after session with an event (1).
Each row (user) have different number of sessions.
0 means an event didn't occur during the session of user.
1 means an event occurred during the session of user.
Here is an example of dataset: https://docs.google.com/spreadsheets/d/1HSzkzQm0k-KAlVlAmVO_P86jROYfLwFkPJPKLhtQ7Kg/edit#gid=0
I filled column A3:A with manual counted values.
And now I need help to calculate it with formula. Could you help me?

A: The solution:
=IFERROR(COLUMNS(SPLIT(REGEXEXTRACT(TEXTJOIN(",",true,C3:Y3),"1,(.+)"),",")),0)

textjoin+regexextract+split+columns+iferror


text:
Q: Verify that that the initial value problem $y'=2\sqrt{y} \ \ , y(0)=0$ has two two different solutions $y_1(x)=x^2$ and $y_2(x)=0$. Solving for the general solution, I got
$y(x)= x^2 +c_1x + \frac{{c_1}^2}{4}$
How is $y(x)=0$ a solution for $y'=2\sqrt{y}$  ?

A: Sometimes there exist some solutions that are not particular cases of the general solution. These singular solutions can take place when uniqueness of a solution is not guaranteed from the usual conditions (here $f(x,y)=2\sqrt y$ fails to satisfy some condition; check the theorems you have to see which one).
In any case, for what I see you just are asked to check that these are indeed solutions for an IVP (I assume that $y=0$ is actually the condition $y(0)=0$. It should also be the case that the domain of $y$ is taken to be $[0,\infty)$ or something smaller, because otherwise $y_1$ won't be a solution.
If that is so, then you just have to see that
$$y_1(0)=0$$
(which is obvious)
and that
$$y_1'(x)=2\sqrt {y_1(x)}, \quad \forall x\in [0,\infty),$$
which is also true; then do the same for $y_2(x)=0$, which is straightforward.


text:
Q: Function doesn't do operations on dataset in R I'm fairly new to R programming, so my question can appear naive.
I want to define all my functions of R in a single file, named functions.R, and call when I need them. I thought to use source().
That's my code:
main.R:
 library(gstat)
 library(lattice)
 library(rgdal)

 source("functions.R")
 source("script_import.R")

script_import.R:
source("functions.R")

#Here I import the dataset named "dati"
dati<-read.csv2("/home/eugen/Documenti/file_da_importare.csv", header = TRUE, skip=4, dec = ",")

colnames(dati)<-c("provider", "ente", "nome_stazione", "long", "lat", "quota", "periodo_dati", "anni_dati", "tm_01", "tm_02", "tm_03", "tm_04", "tm_05", "tm_06", "tm_07", "tm_08", "tm_09", "tm_10", "tm_11", "tm_12", "remove", "tn_01", "tn_02", "tn_03", "tn_04", "tn_05", "tn_06", "tn_07", "tn_08", "tn_09", "tn_10", "tn_11", "tn_12", "remove1", "tx_01", "tx_02", "tx_03", "tx_04", "tx_05", "tx_06", "tx_07", "tx_08", "tx_09", "tx_10", "tx_11", "tx_12", "stato", "note", "nazione")

#That's the function call with which I have problems
clean_main_ds()

#If I use this commands instead of the function all works well
#dati$remove<-NULL
#dati$remove1<-NULL

functions.R:
clean_main_ds<-function(){
  #I want to delete two columns
  dati$remove<-NULL
  dati$remove1<-NULL
  cat("I'm exiting the function")
  return(dati)
}

When compiling I don't receive any error, the function appears as declared in rstudio, is called by script_import.R, the cat() works well (so I imagine that there's no problem with the call), but the function doesn't delete the two columns. If I use the same commands ("dati$remove<-NULL") in script_import.R, instead of the function, all works well.
Where's the error? How can I do to let my function operate on a dataset defined in another file?
Thank you very much for the help,
Eugen
Ps: sorry for the errors in the language, I'm not english. I hope that the text is clear enough...

A: When you use the assignment operator <- within a function, it only does an assignment within the function's own environment. That is, the function creates a copy of the object dati, and then assigns NULL to elements remove and remove1 of dati within the function's environment.
Now when you use return, the function will return this modified copy of the original object dati. It will not modify the object dati in the global environment. If you do str(clean_main_ds()), you'll notice that that object is actually your data frame with the columns removed.
There's a couple of things you could do to get around this. First, you could specify your function using the assignment operator <<-, which will do assignment in the global environment instead of the function's own environment:
clean_main_ds<-function(){
      #I want to delete two columns
      dati$remove<<-NULL
      dati$remove1<<-NULL
      cat("I'm exiting the function")
      return(dati)
    }

(In fact, doing this, you don't even need the last line return(dati) in the function. By the time you get there your function has already done the modifications to your object in the global environment.)
Another option would be to just assign the value returned by your original function to the original data frame by
dati <- clean_main_ds().
Finally, you could just remove the columns from your data frame directly, without writing a function for it, by using indexes.
dati <- dati[ , -which(colnames(dati) %in% c("remove", "remove1"))]

(You could do this directly by just specifying the column numbers of the columns to remove instead of the which() segment. That part just looks up the indexes of the columns whose name is remove or remove1.)


text:
Q: Expansion in a non-orthogonal basis in infinite-dimensional space The functions
\begin{align}
\psi_n(x)= e^{-x^2/2} H_n(x)/\sqrt{2^n n! \sqrt{\pi}}
\end{align}
where $H_n(x)$ is the $n$'th Hermite polynomial, form a complete set of orthonormal function over the real line in the sense that for any function $f(x)$ we have
\begin{align}
\int dx \psi_n(x)\psi_m(x)&=\delta_{mn}\, ,\\
\hat {\mathbb{I}}&= \sum_{n=0}^{\infty}\psi_n(x)\, \int dx \psi_n(x)\, , \tag{1}\\
f(x)=\hat{ \mathbb{I}} f(x)&=\sum_{n=0}^{\infty} \psi_n(x) c_n\, , \tag{2}\\
c_n&=\int dx \psi_n(x)f(x) \tag{3}\, .
\end{align}
These functions appear as eigenfunctions of the quantum harmonic oscillator Hamiltonian.
Suppose instead I choose a "basis" of functions of the type
\begin{align}
\phi_n(x)= e^{-x^2/2} x^n \sqrt{\frac{2^n}{\sqrt{\pi} (2n-1)!!}}
\end{align}
so that
\begin{align}
\mathbf{S}_{ij}=\int dx \phi_i(x)\phi_j(x)&=\frac{2^{\frac{1}{2} (i+j-2)} \left((-1)^{i+j}+1\right) \Gamma \left(\frac{1}{2} (i+j+1)\right)}{\sqrt{\pi } \sqrt{(2 i-1)\text{!!} (2
   j-1)\text{!!}}}\, ,
\end{align}
with $\mathbf{S}_{ii}=1$,
so the set functions $\{\phi_n(x),n=0,\ldots,\infty\}$ is no longer orthogonal.
Q: How does one write the equivalent of (1),(2), (3) for the $\phi$ functions?
I thought of computing $\mathbf{S}^{-1}$ and using
\begin{align}
\hat {\mathbb{I}}&= \sum_{n=0}^{\infty}\phi_n(x)\,  \mathbf{S}^{-1}_{nm} \int dx \phi_m(x)
\end{align}
because
\begin{align}
\phi_i(x)&= \sum_{n,m=0}^{\infty}\phi_n(x)\,  \mathbf{S}^{-1}_{nm} \int dx \phi_m(x)\phi_i(x)\, \\
&=  \sum_{n,m=0}^{\infty}\phi_n(x)\,  \mathbf{S}^{-1}_{nm}\mathbf{S}_{mi}\, ,\\
&=\sum_{n }^{\infty}\phi_n(x)\, \left( \mathbf{S}^{-1}\mathbf{S}\right)_{ni}=\phi_i(x)\, ,
\end{align}
but this displaces the problem to one of computing $\mathbf{S}^{-1}$.  To compute $\mathbf{S}^{-1}$ one could use the formal series
\begin{align}
\mathbf{S}^{-1}=(\mathbb{I}+\mathbf{K})^{-1}=\sum_{p}(-1)^{p} \mathbf{K}^p \tag{4}
\end{align}
where $\mathbb{I}$ is the "identity matrix" in the infinite-dimensional space and
\begin{align}
\mathbf{K}_{ij}=\left\{\begin{array}{cc}
\mathbf{S}_{ij}&i\ne j\\
0&i=j\, .\end{array}\right.
\end{align}
but the series does not converge.


text:
Q: arraycopy in Binary Search I need help with my code here please. I wanted it display the arrays every time it is splitted while containing the key value until it arrives with the simplest array with key value in it then it display "Found!". My problem is, it worked for key = 2 only and not others keys. Please help me for that.
   package Search;
    import java.util.*;
    public class BinarySearch{
/**Example is below of what I expected which is a result I obtained from key = 2

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
[1, 2, 3, 4, 5, 6]
[1, 2]

Found!
**/
        public static int binarySearch(int[] list, int key){
            int low = 0;
            int high = list.length;

            while(high >= low){
                int mid = (low+high)/2;

                int[] temp = new int[high];
                System.arraycopy(list, low, temp, 0, high);
                System.out.println(Arrays.toString(temp));
                int count = 0;
                if(key < list[mid]){
                    high = mid - 1;
                    if(count<temp.length){

                    }
                }
                else if(key == list[mid]){
                    return mid;
                }
                else{
                    low = mid + 1;
                }
            }
            return -1;
        }
        public static int User(){
            Scanner scan = new Scanner(System.in);
            System.out.println("Enter key: ");
            String input = scan.nextLine();
            int user = Integer.parseInt(input);
            return user;
        }

        public static void main(String[] args){
            int[] list = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};

            System.out.println("The array: "+Arrays.toString(list));
            System.out.println("The key is found at "+BinarySearch.binarySearch(list, BinarySearch.User()));
        }

}


text:
Q: Polynomial contrasts following a one way ANOVA I have a small dataset that is amenable to trend analysis. Only 1 IV with three levels, a balanced design. Both the linear and quadratic contrasts came back as significant.
What would be the appropriate approach to take regarding these (incompatible) results?

A: There's nothing incompatible about having both the linear and quadratic terms significant.
For example, the following pattern of means (combined with small variation about the means) would do so:
               3

         2
 1

That the average of groups 1 and 3 differs from the mean for 2 is precisely how you tell that the effect differs from linearity. There's nothing incompatible about this. Unless your quadratic is close to symmetric about the middle group the linear term should be non-zero and unless the three means are essentially on a straight line the quadratic term should be non-zero.
I don't see any difficulty in interpretation of the quadratic term; it's the linear effect that's somewhat harder to interpret (though arguably still easier in the orthogonal framework than in the "raw" case).
[The likely reason that this didn't get an answer for a long time is that it's not really clear what you're trying to do when you say "What would be the appropriate approach to take" ... (approach to what?). If you clarified that, more help might be possible]


text:
Q: The various number of queries with Spring (Tomcat) and Java EE (JBoss) I created one application using Spring on Tomcat, and the second app using Java EE (EJB + JSF) on JBoss AS 7. As ORM I choose Hibernate, or I think so.
Suppose, I have a page with trip offers. I can click on a link to load trip descriptions using AJAX.
With the Spring version, after choosing a description link, only one query is sent to the database. This is good.
But with the Java EE version, in the same case, seven queries are sent! Seven queries for each trip offer displayed on the current site. So, if I can see 4 trip offers, there are 4*7 SQL queries! That is why the performance is low.
The service layer, so SQL queries, are the same in both versions. In the Spring version, the request is sent (by post) using jQuery. In Java EE, I use JSF AJAX support.
What is the cause of this behaviour? I am not sure, maybe Hibernate is not really used in the Java EE version? In persistance.xml I have the following: <provider>org.hibernate.ejb.HibernatePersistence</provider>.

A: First you have to determine whether the multiple SQL queries are induced by the client or whether there's something on the backend that's different.
Try opening up Firebug or similar tool and check to see whether your browser is sending a bunch of separate HTTP requests.


text:
Q: R - Convert list of list into data frame I have the next issue trying to convert this list of list into a data frame where is unique element of the list is a column of its own.
This is what I have right now:
> head(data$egg_groups)
[[1]]
 name   resource_uri
1   Plant /api/v1/egg/7/
2 Monster /api/v1/egg/1/

[[2]]
 name   resource_uri
1   Plant /api/v1/egg/7/
2 Monster /api/v1/egg/1/

[[3]]
 name   resource_uri
1   Plant /api/v1/egg/7/
2 Monster /api/v1/egg/1/

[[4]]
 name    resource_uri
1  Dragon /api/v1/egg/14/
2 Monster  /api/v1/egg/1/

[[5]]
 name    resource_uri
1  Dragon /api/v1/egg/14/
2 Monster  /api/v1/egg/1/

[[6]]
 name    resource_uri
1  Dragon /api/v1/egg/14/
2 Monster  /api/v1/egg/1/

What I would like to have is a data frame where is one of those entries (just name) is a column of its own.
Something like this:
    Plant Monster Dragon
1     1      1
2     1      1
3     1      1
4            1      1
5            1      1
6            1      1

I have tried the library plyr and the using unlist and so far nothing has worked. Any tips would be appreciated. Thanks
EDIT: This is the dput pastebin link:
dput

A: You can use rbindlist() from data.table v1.9.5 as follows:
(Using @lukeA's example)
require(data.table) # 1.9.5+
dt = rbindlist(l, idcol="id")
#    id x y
# 1:  1 a 1
# 2:  1 b 2
# 3:  2 b 2
# 4:  2 c 3

dcast(dt, id ~ x, fun.aggregate = length)
#    id a b c
# 1:  1 1 1 0
# 2:  2 0 1 1

You can install it by following the instructions here.

A: I would suggest using mtabulate from the "qdapTools" package. First, just loop through the list and extract the relevant column as a vector, and use the resulting list as the input for mtabulate, something like this:
library(qdapTools)
head(mtabulate(lapply(L, `[[`, "name")))
#   Bug Ditto Dragon Fairy Flying Ground Human-like Indeterminate Mineral Monster
# 1   0     0      0     0      0      0          0             0       0       1
# 2   0     0      0     0      0      0          0             0       0       1
# 3   0     0      0     0      0      0          0             0       0       1
# 4   0     0      1     0      0      0          0             0       0       1
# 5   0     0      1     0      0      0          0             0       0       1
# 6   0     0      1     0      0      0          0             0       0       1
#   Plant Undiscovered Water1 Water2 Water3
# 1     1            0      0      0      0
# 2     1            0      0      0      0
# 3     1            0      0      0      0
# 4     0            0      0      0      0
# 5     0            0      0      0      0
# 6     0            0      0      0      0

A: Here's one way to do it:
(l <- list(data.frame(x = letters[1:2], y = 1:2), data.frame(x = letters[2:3], y = 2:3)))
# [[1]]
# x y
# 1 a 1
# 2 b 2
#
# [[2]]
# x y
# 1 b 2
# 2 c 3
df <- do.call(rbind, lapply(1:length(l), function(x) cbind(l[[x]], id = x) ))
#   x y id
# 1 a 1  1
# 2 b 2  1
# 3 b 2  2
# 4 c 3  2
library(reshape2)
dcast(df, id~x, fun.aggregate = function(x) if (length(x)) "1" else "" )[-1]
#   a b c
# 1 1 1
# 2   1 1


text:
Q: Why do phpinfo() and the php command show different .ini file paths? I have just spend some time trying to figure out why a setting from my php.ini wasn't correctly loading, when I know for sure I have changed it in the file.
After finally trying out the good old <?php phpinfo(); ?> code through a PHP file, as opposed to previously reading the output from the php -i command in the console, it turns out the paths are different.
phpinfo() output:
+------------------------------------+--------------------------------+
+ Configuration File (php.ini) Path  + /etc/php5/apache2              +
+------------------------------------+--------------------------------+
+ Loaded Configuration File          + /etc/php5/apache2/php.ini      +
+------------------------------------+--------------------------------+

php -i | grep "php.ini" output:
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini

But why does this happen, why are there two configurations, and why are these two environments using separate ones? Also, shouldn't the php command be the same one that Apache2 is using when it executes scripts, and therefore load the same ini file as when being executed from the console?


text:
Q: Apply MUI styles to non-MUI markup elements In my Gatsby app I am using MUI v5, and must also output user created markup. I want the user-markup to get the same base-styles as their analogous Typography elements (see below). How can I achieve this?
Note - the user markup already contains

 or other tags, which cannot be directly modified by React.
Additionally the app is wrapped with ThemeProvider and I'm using styled-components as the style engine for MUI (if that matters...).
import {Typography} from "@mui/material"
export default function() {
  return (
    <>
      <Typography variant="body1" paragraph>My styled Typography</Typography>
      // The next line can't receive any classses or modifiers,
      // but must end up styled like the <Typography> element.

my custom user content - how can i style this like above?

    </>
  )
}

A: You need to import your theme.  From there you can access the body1 default typography style to apply to the p element.
import {Typography} from '@mui/material'
import {useTheme} from //im not exactly sure where this comes from '@mui/material' or '@mui/styles'

export default function() {

  const theme = useTheme()

  return (
    <>
      <Typography variant="body1" paragraph>My styled Typography</Typography>

my custom user content - how can i style this like above?

    </>
  )
}

A: import {useTheme ,Typography} from "@mui/material"

    export default function() {

      const theme = useTheme()

      return (
        <>
          <Typography variant="body1" paragraph>My styled Typography</Typography>

my custom user content - how can i style this like above?

        </>
      )
    }

A: If you want to add the sx prop in your custom component:
const P = styled("p")({});

const theme = useTheme()

If you want to use system properties:
import { unstable_extendSxProp as extendSxProp } from "@mui/system";

const Psx = styled("p")();

function P(inProps) {
  const { sx, ...other } = extendSxProp(inProps);
  return <Psx sx={sx} {...other} />;
}

If you want to use variant prop like in Typography:
const T = styled('p')(({ theme, variant = 'body1' }) => ({
  ...theme.typography[variant],
}));

<T variant="h3">

Live Demo

Related Answer

*

*Passing props to MUI styles


text:
Q: How to document object's contract I'm trying to find a good way to document expected "interface" or "contract" of an object in JavaScript, e.g. which methods would be called, which properties are expected to be present and so on. I want it to be as close to code as possible (e.g. not in external documentation files).
Let's say I'm trying to design UI controls library in JavaScript. I would like to process a set of controls in a polymorphic way, e.g. call control.loadDataFromServer() regardless of whether it's a text field or dropdown or whatever. But some behavior may not be present in all types of controls, for example for editable controls I would call control.validate() or control.getValue() which won't happen for static text labels and such.
My main main goal is so a new developer trying to implement new control or modify the existing one can immediately understand what is possible to implement without having to sift through all the calling code.
In a statically typed language like C# or Java, I would have used interfaces like IControl and IEditableControl. Now, I know JavaScript is duck typed, but I do want to give some hints to further developers. I could provided dummy implementation in a control's prototype, but that solution seems dirty to me. What are my options?

A: In the end I decided to use something along the lines of this quacksLike solution http://fitzgeraldnick.com/weblog/39/.
For each logical "interface" I create an object which lists members along with very basic type indication using JS prototypes (String, Number, Function etc.). This interface objects are very easy to document with JSDoc (also to add missing information about method parameters).
When working with target objects, I check if object intends to support the "interface" and if so, I go ahead and call methods. It's not as safe as static typing, but good enough for me.
var interfaces = {
     ...
     validatable: {
         validate: Function,
         isValid: Boolean,
         getValidationMessages: Function
     }
     ....
}

...
if (typing.checkSupport(control, interfaces.validatable)) {
    control.validate();
    if (!control.isValid) {
      ....
    }
}


text:
Q: How to develop app for mutiple devices and versions in android I developed an application in galaxys version 2.3.3 and i want this app on galaxy tab also with same version what is step i have to follow can anybody help how to setup layout versions in xml...

A: Go through the following links if you haven't already been through them:
http://developer.android.com/guide/practices/screens_support.html
http://developer.android.com/guide/practices/screens-distribution.html
http://developer.android.com/guide/practices/screen-compat-mode.html
http://developer.android.com/guide/practices/tablets-and-handsets.html

A: Android provide lot of way for to do this, using below
For supporting all versions, you must set the API versions in manifest like
<uses-sdk android:minSdkVersion="API version" />
<uses-sdk android:manSdkVersion="API version" />
<uses-sdk android:targetSdkVersion="API version" />

For supporting all devices, such as tablet also means you must create drawable folders like and place the images to this folders with needed size
res/drawable-ldpi
res/drawable-mdpi
res/drawable-hdpi
res/drawable-xhdpi

and also you must create the layouts like
res/layout/my_layout.xml
res/layout-small/my_layout.xml
res/layout-large/my_layout.xml
res/layout-xlarge/my_layout.xml
res/layout-xlarge-land/my_layout.xml

And refer below also
Tips to Create Android app


text:
Q: Android : Get view Reference to a Menu Item I plan to use quick actions UI pattern in my application. Android Quick Actions UI Pattern . The quick action window needs a pivot view to stick to.
    quickAction.show(View pivotView);

I intend to use quick action for the menu Item, I can get access to the item that is clicked.
But the problem is i need to reference a view from the menu item so that i can pass it to the quick action.
How can i get reference to a view in the menuItem that is selected.

A: An update for anyone that want to find the menu view item for other reasons (like I wanted).
If you have access to and use AppCompat's Toolbar there is a way. It's not the most efficient way, but it's the easiest way I've found to access the menu item's view.
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);

    // Find Menu
    for (int toolbarChildIndex = 0; toolbarChildIndex < toolbar.getChildCount(); toolbarChildIndex++) {
        View view = toolbar.getChildAt(toolbarChildIndex);

        // Found Menu
        if (view instanceof ActionMenuView) {
            ActionMenuView menuView = (ActionMenuView) view;

            // All menu items
            for (int menuChildIndex = 0; menuChildIndex < menuView.getChildCount(); menuChildIndex++) {
                ActionMenuItemView itemView = (ActionMenuItemView) menuView.getChildAt(menuChildIndex);
                // Do something to itemView...
            }
        }
    }
}

A: Old question, but I ran into some issues with the actionViewClass attribute. For anyone who runs into this later...
Calling findViewById(R.id.mnu_item) in onOptionsItemSelected will return a View anchor.
QuickActions on the MenuItems aren't good design, but I found that they are the simplest way to implement submenus with custom backgrounds.

A: Inorder to get reference Views of menu items we need to do this,
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.section, menu);

    new Handler().post(new Runnable() {
        @Override
        public void run() {

            final View menuItemView = findViewById(R.id.action_preview);
            // SOME OF YOUR TASK AFTER GETTING VIEW REFERENCE

        }
    });

    return true;
}

A: You can achieve this by providing your menu item with an actionViewClass property in xml and then you will be able to get the pivot view u wanted. The code would be something like this

<item
    android:id="@+id/menu_find"
    android:showAsAction="ifRoom"
    android:actionViewClass="android.widget.ImageButton"
    />

In your OnCreateOptionsMenu do this
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_search, menu);
    locButton = (ImageButton) menu.findItem(R.id.menu_find).getActionView();
    locButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            createPopup();
            mQuickAction.show(v);
        }
    });
    return true;
}

A: Universal code which also works on Android 10
/**
* pass toolbar and menu item id, i.e. R.id.menu_refresh
*/
@Nullable
@Throws(
    IllegalAccessException::class,
    NoSuchFieldException::class
)
fun getMenuItemView(toolbar: Toolbar?, @IdRes menuItemId: Int): View? {
    val mMenuView: Field = Toolbar::class.java.getDeclaredField("mMenuView")
    mMenuView.setAccessible(true)
    val menuView: Any? = mMenuView.get(toolbar)
    (menuView as ViewGroup).children.forEach {
        if(it.id == menuItemId) {
            return it
        }
    }
    return null
}

A: in the main activity class, best to override the onOptionsItemSelected(...) method; should be something as below:
public boolean onOptionsItemSelected(MenuItem item) {
  // the id is of type int
  int someId = item.getItemId();
  // can use an if() or switch() statement to check if id is selected
  //a Toast message can be used to show item is selected
}

A: Kotlin!!
override fun onCreateOptionsMenu(Menu menu): Boolean {

  /*Adding menu items to action bar*/
  menuInflater.inflate(R.menu.main, menu)

  /*Getting menu item*/
  val locButton: MenuItem = menu.findItem(R.id.menu_find)

  /*Creating click listener*/
  locButton.setOnMenuItemClickListener{
    /*TODO: Handle it*/
    true
  }

  return true;
}


text:
Q: Got BSOD with USBXHCI.SYS It said Bad_pool_caller
here is the dump file
https://drive.google.com/file/d/0B0z47lWdEdGPR1JXR1Z5WFpEN2s/view?usp=sharing
All my drivers are up-to-date and I didn't connect any external device. Machine was running fine for 2 weeks and now this error. First time I got this error.
The name tells me it has something to do with USB. But what exactly caused this error?
My hardware is fine as I had tested my hardware by memtest and chkdisk.


text:
Q: Display data from firestore I am trying to display the data I get back from the firestore in my swiftUI app but am having some trouble.
Here is where I get the data
import Foundation
import Firebase

class RecipesViewModel: ObservableObject {

    @Published var userRecipes = [RecipesData]()

    func getData() {

        // Get a reference to the database
        let db = Firestore.firestore()

        // Read the documents at a specific path
        db.collection("Recipes").getDocuments { snapshot, error in

            // Check for errors
            if error == nil {
                // No errors

                if let snapshot = snapshot {

                    // Update the list property in the main thread
                    DispatchQueue.main.async {

                        self.userRecipes = snapshot.documents.map { d in

                            return RecipesData(id: d["id"] as? String ?? "", name: d["name"] as? String ?? "", cuisine: d["cuisine"] as? String ?? "", difficulty: d["difficulty"] as? String ?? "", dishType: d["dishType"] as? String ?? "", prepMins: d["prepMins"] as? Int ?? 0, prepHours: d["prephours"] as? Int ?? 0, cookMins: d["cookMins"] as? Int ?? 0, cookHours: d["cookHours"] as? Int ?? 0, restMins: d["restMins"] as? Int ?? 0, restHours: d["restHours"] as? Int ?? 0, likes: d["lkies"] as? Int ?? 0)
                        }
                    }

                }
            }
            else {

            }
        }
    }

}

and here is where the data gets stored
import SwiftUI
import FirebaseFirestoreSwift

struct RecipesData: Identifiable{
    var id: String
    var name: String
    var cuisine: String
    var difficulty: String
    var dishType: String
    var prepMins: Int
    var prepHours: Int
    var cookMins: Int
    var cookHours: Int
    var restMins: Int
    var restHours: Int
    var likes: Int
}

I can get the Data and if I choose to display the name of each recipe in a list I can do that.
But what I want to do is to have my data too like this when being displayed
import SwiftUI

struct AllRecipesView: View {

    @ObservedObject var model = RecipesViewModel()
    private var gridCollum = [GridItem(.flexible(),spacing: 0), GridItem(.flexible(),spacing: 0)]

    var body: some View {
        VStack{
            LazyVGrid(columns: gridCollum, spacing: 0){
                ForEach(model.userRecipes) {item in
                    overlayView()
                }
            }
        }
    }
    init(){
        model.getData()
    }
}

struct AllRecipesView_Previews: PreviewProvider {
    static var previews: some View {
        AllRecipesView()
    }
}

struct overlayView:View{

    @ObservedObject var model = RecipesViewModel()

    var body: some View{
        ForEach(model.userRecipes) {item in
            VStack{
                VStack{
                    Spacer()
                    HStack{
                        HStack{
                            Image(systemName: "star")
                                .foregroundColor(.white)
                                .font(.system(size: 20))
                            Text(item.likes)
                                .foregroundColor(.white)
                                .font(.system(size: 15))

                        }
                        .padding(.trailing)
                        Text(item.prepMins)
                            .foregroundColor(.white)
                            .font(.system(size: 15))
                            .padding(.horizontal)

                    }
                    .padding(.bottom)
                }
                .frame(width:180,height:130)
                .background(Color.red)
                .cornerRadius(8)
                .shadow(color: .black, radius: 3, x: 2, y: 2)
                .padding(.bottom)
                Text("Salmon and Rice")
                Text("Some User")
            }

        }
    }
    init(){
        model.getData()
    }
}

But I keep getting error saying No exact matches in call to initializer  on the lines
Text(item.likes)

and
Text(prepMins)

How can I fix my errors please

A: try something like this example code, using @StateObject var model = RecipesViewModel() and passing it using @EnvironmentObject.
To fix the errors you get, remenber Text() needs a string, such as, Text(String(item.likes)) or Text("\(item.likes)").
struct AllRecipesView: View {

    @StateObject var model = RecipesViewModel() // <-- here

    private var gridCollum = [GridItem(.flexible(),spacing: 0), GridItem(.flexible(),spacing: 0)]

    var body: some View {
        VStack{
            LazyVGrid(columns: gridCollum, spacing: 0){
                ForEach(model.userRecipes) {item in
                    OverlayView()
                }
            }
        }
        .environmentObject(model)  // <-- here
        .onAppear {
            model.getData()  // <-- here
        }
    }
}

struct OverlayView:View{

    @EnvironmentObject var model: RecipesViewModel // <-- here

    var body: some View{
        ForEach(model.userRecipes) {item in
            VStack{
                VStack{
                    Spacer()
                    HStack{
                        HStack{
                            Image(systemName: "star")
                                .foregroundColor(.white)
                                .font(.system(size: 20))
                            Text(String(item.likes)) // <-- here
                                .foregroundColor(.white)
                                .font(.system(size: 15))

                        }
                        .padding(.trailing)
                        Text(String(item.prepMins))  // <-- here
                            .foregroundColor(.white)
                            .font(.system(size: 15))
                            .padding(.horizontal)

                    }
                    .padding(.bottom)
                }
                .frame(width:180,height:130)
                .background(Color.red)
                .cornerRadius(8)
                .shadow(color: .black, radius: 3, x: 2, y: 2)
                .padding(.bottom)
                Text("Salmon and Rice")
                Text("Some User")
            }
        }
    }
}


text:
Q: Referencing a URL that includes a hyphen (NOT a dash) I ran into a website that used a hyphen (not a dash) to build it's URL. I want to link to this website from another HTML document using the following code:
The Course

Difficult to see, but the hyphen is the 14th character from the right in the href. (Immediately before the second TSO abbreviation.)
Is there a way to reference this character properly using an ASCII escape code similar to a %20 for a space?
Or am I stuck with sending the other web-dev kindly asking them to fix the problem? :-)

A: You would use %e2%80%93 to encode that hyphen character:
The Course

I used this C# code to find out the encoding:
Console.WriteLine(HttpUtility.UrlEncode("–"));


text:
Q: Laravel redirects login page after a delete operation When I try to destroy a record with resource controller, laravel redirects to login page
although I applied auth middleware in the controller.
Laravel Version is 6.x.
Web.php
<?php
Auth::routes();

Route::resource('sliders', 'Admin\SliderController');

SliderController.php
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Slider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Storage;
use Validator;

class SliderController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

...other methods

    public function destroy(Slider $slider)
    {
        Slider::destroy($slider->id);

        Session::flush('status', 'success');

        return redirect('sliders');
    }
    }
}

I couldn't understand why it redirects to login page.
Help please
Thanks

A: Session flush is to delete all data https://laravel.com/docs/master/session#deleting-data
Use
$request->session()->flash('status', 'success');


text:
Q: Hadwiger's conjecture graph without $K_{4}$ minor has degree $2$ I'm stuck with the question that asks to prove how I can show by induction based on Hadwiger's conjecture that a graph without a $K_{4}$ minor is at most two connected.
I know that a graph without a $K_{4}$ minor is $3-\text{colorable}$ but how can I prove the degree $2?$
Can anybody help me? Thanks!

A: We proceed by structural induction. It is clear that no graph with 4 or fewer vertices which contains no $K_4$ minor can be 3-connected.
Further assume we now have a graph $G = (V, E)$ with no $K_4$ minor which is at most 2-connected.
Now let us define a new graph $G'$ obtained from $G$ by adding a new vertex $v'$ and connecting it to the vertices in some set $X \subseteq V$ such that $G'$ also does not contain a $K_4$ minor.
We assume towards a contradiction that $G'$ is 3-connected.
By Menger's theorem we find that $G$ must have already been 2-connected as adding $v'$ cannot add more than one additional path (disjoint from existing ones in $G$) between any two vertices.
As $G$ was 2-connected, we also get the existence of two vertices $v$ and $w$ such that any triple of disjoint $v$-$w$-paths in $G'$ must include a path containing $v'$ and since we required $G$ to be simple, one of the two $v$-$w$-paths in $G$ must contain some other vertex $x$, giving us the following situation:

By Menger's theorem, we again obtain 3 disjoint paths between $x$ and $v'$ in $G'$ and thus at least one such path containing neither $v$ nor $w$.
Contracting all these considered paths between the vertices in $\{v, w, x, v'\}$ yields a $K_4$ minor in $G'$.
Note that this proof does not use Hadwiger's conjecture and I see no reason for why it should be used.
Indeed I found other proofs of this fact not using it either, see e.g. Theorem 2.2 in these lecture notes.


text:
Q: Redis commands synchronous or asynchronous? AFAIK redis is a single threaded and its uses event loop under the hood. I would want to understand 2 things:

*

*are all redis commands synchronous?

*if they are asynchronous

  SET mykey "Hello" (first command)
  GET mykey (second command)

there is a possibility for the second command to return nil, if the set command isn't executed yet. Is that correct?

A: Redis is single-threaded , which means all commands should be atomic. For details
In your above example; If  the SET command gets to executed first then GET command will wait until SET completion; if GET command gets to executed first then then it will return nil and SET will subsequently be executed. so each command execution is atomic.
refer documentation; https://redis.io/topics/faq.
ps: for redis4.0 there is some multi-threading capability;  refer documentation for details


text:
Q: Is there any way to automatically cast literal to text for a parameter defined as anyelement? PostgreSQL is not so friendly with user in this case,
CREATE FUNCTION foo(anyelement)  RETURNS text AS $$
   SELECT 'The type is ' || pg_typeof($1);
$$ LANGUAGE SQL IMMUTABLE;

SELECT foo(123); -- OK
SELECT foo('123'::text); -- OK
SELECT foo('123'); -- ERROR

There are an "option", a (low cost) workaround to avoid this kind of interruption?
Perhaps some "automatic casting" for literal-to-text convertion? In pg9+ no news about it?

A: In PostgreSQL the 'literal' notation is used to denote different types of data. For instance all the following expressions are correct and return a valid result of different type:
select ('123':: bytea)
select ('123':: money)
select ('123':: float)
select ('123':: text)
select ('123':: integer)
select ('123':: json)
...

so that the syntax '123' is inherently ambiguous, and Postgres does not provide any automatic convertion for, at least in the current version (and probably in future releases as well).


text:
Q: Shaded area under different density curves (grouping factor) in the same plot I am trying to plot a density line with and want to shade or fill only the area associated with the 95% of the x axis. I am trying to follow answers given in the attached answers, but non of them talk about shading an area when we are plotting more than one distributions at the same time with a grouping factor. In this case the grouping factor is the different central electrodes ("Fz", "Cz, "Pz"). I am trying to visualise something similar to the highest density interval, or the area under the curve comprising between percentile 5 and 95.
Area Under Curve
AUC by Group
My data looks something like this:
> head(dframe1)
         x            y Electrode
1 1.571296 0.0001474116        Fz
2 1.576496 0.0001487649        Fz
3 1.581697 0.0001497564        Fz
4 1.586897 0.0001504074        Fz
5 1.592098 0.0001507446        Fz
6 1.597298 0.0001507776        Fz

And at the moment the code I am using to plot the distributions by group in ggplot looks like this:
p1 <- ggplot(data = dframe1, mapping = aes(x = x, y = y)) +
  geom_density_line(stat = "identity", size=.5, alpha=0.3, aes(color=Electrode, fill=Electrode)) +
  scale_fill_discrete(breaks=c("Fz","Cz","Pz")) +
  guides(colour = FALSE) +
  geom_vline(xintercept = 0) +
  xlab("values") +
  xlim(-2, 10) +
  ylab("density") +
  ylim(0, .7) +
  theme(axis.text=element_text(size=12),
        axis.title=element_text(size=16),
        plot.title = element_text(size=18)) +
  labs(title="Interval")

I sketched something similar to what I am looking for:

Of course I could use bayestestR HDI standard output but I prefer the ggplot aesthetic and flexibility.
Any help will be much appreciated.

A: Since you need to do some maths on the density curves to work out where the 95% intervals are, it is best to do this outside ggplot. I often find that people run into problems because they try to get ggplot to do too much of their data wrangling and summarizing. It is often easier to work out what you want to plot, then plot it.
In your case, your x and y co-ordinates already represent densities. For each Electrode, you just need to create a logical vector that tells you when the integral of the density is between 0.025 and 0.975, so that you can easily subset out the 95% confidence interval. You can do that using the split-aplly-bind method like this:
densdf <- do.call(rbind, lapply(split(dframe1, dframe1$Electrode), function(z)
{
  integ <- cumsum(z$y * mean(diff(z$x)))
  CI <-  integ > 0.025 & integ < 0.975
  data.frame(x = z$x, y = z$y, Electrode = z$Electrode[1], CI = CI)
}))

Now we are ready to plot:
ggplot(data = densdf, mapping = aes(x = x, y = y)) +
  geom_area(data = densdf[densdf$CI,],
            aes(fill = Electrode, color = Electrode),
            outline.type = "full", alpha = 0.3, size = 1) +
  geom_line(aes(color = Electrode), size = 1) +
  scale_fill_discrete(breaks = c("Fz", "Cz", "Pz")) +
  guides(colour = FALSE) +
  geom_vline(xintercept = 0) +
  geom_hline(yintercept = 0) +
  lims(x = c(-2, 10), y = c(0, 0.7)) +
  labs(title = "Interval", x = "values", y = "density") +
  theme_bw() +
  theme(axis.text  = element_text(size = 12),
        axis.title = element_text(size = 16),
        plot.title = element_text(size = 18))


text:
Q: Bootstrap carousel content needs to be an output of html How to display the output of a html page into my bootstrap carousel instead of displaying images? I'd tried creating a div and used css to supply the contents to that ac1_div using content:url(carousel_content.html). It doesn't work.

        Previous

        Next

/*my css code*/

    #ac1_div
        {
            content: url("../pages/achievers/ac1.html");
            }

<!DOCTYPE html>

    <title></title>

achiever

A: TRY to Create a container and put the carousel inside it Code


text:
Q: Letsencrypt certificate renewal issue on Ubuntu 18.04 machine using Apache Server I am using Apache servers to host my Django (v2.1) app. I've installed Letsencrypt certificate for HTTPS. Now the time of renewal has come and it is giving me some unauthorized access error.
When I run sudo certbot command, I got the following output.
/usr/lib/python3/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.23) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: noppera.tk
2: www.noppera.tk
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 2
Cert is due for renewal, auto-renewing...
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for www.noppera.tk
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. www.noppera.tk (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.noppera.tk/.well-known/acme-challenge/U0D416-6zOf7YRW0jAVIG8oiLthmpy_xmewRdUlwrQM [34.240.58.158]: 400

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: www.noppera.tk
   Type:   unauthorized
   Detail: Invalid response from
   http://www.noppera.tk/.well-known/acme-challenge/U0D416-6zOf7YRW0jAVIG8oiLthmpy_xmewRdUlwrQM
   [34.240.58.158]: 400

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address.

Also if I run this for option 1, I got the same error. (If you want, I can paste that log too)
What I've already tried is the following:

*

*Has already installed django-letsencrypt==3.0.1

*Added letsencrypt in settings.py

*Added the following line in urls.py url(r'^\.well-known/', include('letsencrypt.urls')),
Right now site is accessible using HTTPS. Can anyone help me out renewing the certificate?
EDIT 1
Option 1 Logs:
/usr/lib/python3/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.23) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: noppera.tk
2: www.noppera.tk
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for noppera.tk
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. noppera.tk (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from https://noppera.tk/.well-known/acme-challenge/y6dj0WW9qDgZiBnDTmXmA5FTSusyjabeE3dZs5eEGpI [34.240.58.158]: "\n\n<html>\n<head>\n  <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js\"></script>\n\n\n\n\n\n\n\n<style>\n    /*"

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: noppera.tk
   Type:   unauthorized
   Detail: Invalid response from
   https://noppera.tk/.well-known/acme-challenge/y6dj0WW9qDgZiBnDTmXmA5FTSusyjabeE3dZs5eEGpI
   [34.240.58.158]: "\n\n<html>\n<head>\n  <script
   src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js\"></script>\n\n\n\n\n\n\n\n<style>\n
   /*"

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address.

Django Log for option 1 (noppera.tk)
Invalid HTTP_HOST header: '{{HOST IP}}'. You may need to add '{{HOST IP}}' to ALLOWED_HOSTS.
Bad Request: /console/login/LoginForm.jsp
Not Found: /.well-known/acme-challenge/WRiDAIe3JPBlZXVWduKBYKrmYKbyS3I2eetsth0YBD0

Django Log for option 2 (www.noppera.tk)
Invalid HTTP_HOST header: 'www.noppera.tk'. You may need to add 'www.noppera.tk' to ALLOWED_HOSTS.
Bad Request: /.well-known/acme-challenge/GTX3_zQ6XPymDUn1WVZ_27vO_XtYxPClBD5uA8Y1nhM

Right now, ALLOWED_HOSTS = ["*"]
EDIT 2
Changed ALLOWED_HOSTS = ["*"] to ALLOWED_HOSTS = ["www.noppera.tk", "*"] for Option 2, but same error.

A: I have found a solution. Posting to help others.
The problem was lying with the duplicate conf in the apache2/sites-available folder. There were 2 default configs and 2 custom config for my site (for each http and https). So what I did was disable the default config and reload Apache using sudo a2dissite default-ssl.conf and sudo a2dissite 000-default.conf.
After that I executed sudo certbot and it renewed certificates successfully.
Few of the useful resources are below:

*

*https://www.jbarrett.me/blog/items/4/setting-ssl-django-app-lets-encrypt-ubuntu-apache-and-mod_wsgi

*https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04#step-5-%E2%80%94-setting-up-virtual-hosts-(recommended)


text:
Q: How to hide specific odoo server action from action drop down for some records conditionally? Here is my code.
I want to hide this action for some records conditionally?
I found some tutorials about ir.action.server but did not find the way to hide an action.
    <record id="ar_change_state_bulk_assign_id" model="ir.actions.server">
        <field name="name">Assign AR Number</field>
        <field name="type">ir.actions.server</field>
        <field name="model_id" ref="model_olims_analysis_request"/>
        <field name="state">code</field>
        <field name="code">self.bulk_change_states_pre("to_be_sampled",cr, uid, context.get('active_ids'), context=context)</field>
        <field name="sequence" eval="5"/>
    </record>
   <record id="ar_id_of_the_action_value_assing_ar" model="ir.values">
        <field name="name">Assign AR Number</field>
        <field name="action_id" ref="ar_change_state_bulk_assign_id"/>
        <field name="value" eval="'ir.actions.server,'+str(ref('ar_change_state_bulk_assign_id'))"/>
        <field name="key">action</field>
        <field name="model_id" ref="model_olims_analysis_request"/>
        <field name="model">olims.analysis_request</field>
        <field name="key2">client_action_multi</field>
    </record>


text:
Q: \pagestyle{ruled} adds superfluous text in glossary I'm writing my thesis using the memoir package, using \pagestyle{ruled}, and have created glossaries for a glossary and an acronym list. The resulting pdf, contains the superfluous text "Glossary" and "Acronyms" right below the chapter headings of the same name.
I use latexmk to build the pdf, using a custom .latexmkrc:
add_cus_dep('glo', 'gls', 0, 'makeglossaries');
sub makeglossaries {
    system("makeglossaries '$_[0]'");
}

Here is my minimal example:
\documentclass[a4paper]{memoir}
\usepackage[acronym,toc]{glossaries}
\makeglossaries
\pagestyle{ruled}
\newglossaryentry{UML}{name={UML},description={definition}}
\newacronym{XML}{XML}{Extensible Markup Language}
\begin{document}
\chapter{Intro}
text \gls{XML}
\gls{UML}
\printglossaries
\end{document}

Removing the \pagestyle{ruled} line removes the extra text.
How do I get rid of the extra text, while still using a ruled pagestyle?

A: Issue \pagestyle{ruled} before loading the glossaries package. (I've tested my solution with a glossary with about 30 entries, and its page style is indeed ruled.)
Partial explanation: Both memoir and glossaries define the \glossarymark macro. glossaries adds some compatibility code in case memoir is used, and so it seems the sensible thing to choose a page style first and then let glossaries do its work.
\documentclass[a4paper]{memoir}
\pagestyle{ruled}
\usepackage[acronym,toc]{glossaries}
\makeglossaries
\newglossaryentry{UML}{name={UML},description={definition}}
\newacronym{XML}{XML}{Extensible Markup Language}
\begin{document}
\chapter{Intro}
text \gls{XML}
\gls{UML}
\printglossaries
\end{document}


text:
Q: messages using mesibo javascript api not delivered,it shows only sent status sending message using below function
function sendTextMessage(to, message) {
    var profile = api.getProfile(to, 0);
    var id = parseInt(Math.random()*10000);
    profile.sendMessage(id, message);
}

after that when i log listner response using
MesiboListener.prototype.Mesibo_OnMessageStatus = function(m) {
    console.log("Mesibo_OnMessageStatus: from "
            + m.peer + " status: " + m.status);
}

it show Mesibo_OnMessageStatus: from 4688250 status: 1 but not change status to 2(delivered)

A: We answered you on the mesibo tickets with minor corrections in your code (check SPAM if you have not received it).
You are giving UID as the destination. You should give the address as the destination. Try the code below
var demo1_user_token = '81...';
var demo1_destination = 'vivek';
var demo_appid = 'com.f...';
var demo2_user_token = 'c9...';
var demo2_destination = 'maulik';


text:
Q: Website is showing up as part text and part html on PC I was searching for C programs on the net and I landed on this program:
#include<stdio.h>

void areaperi ( int r, float *a, float *p )
{
*a = 3.14 * r * r ;
*p = 2 * 3.14 * r ;
}

void main( )
{
int radius ;
float area, perimeter ;

printf ( "nEnter radius of a circle " ) ;
scanf ( "%d", &radius ) ;

areaperi ( radius, &area, &perimeter ) ;

printf ( "Area = %f", area ) ;
printf ( "nPerimeter = %f", perimeter ) ;
}

I opened it on my phone and it opened properly but it shows some part text and some part html on my pc.
I wanted to know why this was happening. Thanks in advance.

A: That "c4learn.com" site is broken, and I don't see it working on a phone either.
They meant to publish a syntax-highlighted listing of the C program, but instead they published the HTML source code for the syntax-highlighted listing.
To see the C program, you need to "run" the HTML source code. You can do this by saving it to an HTML file and opening the file in your browser, or using one of the online HTML/CSS/JS editors, such as the one provided on StackOverflow (click the "Run code snippet" button below):

#include<stdio.h>

void areaperi ( int r, float *a, float *p )
{
*a = 3.14 * r * r ;
*p = 2 * 3.14 * r ;
}

void main( )
{
int radius ;
float area, perimeter ;

printf ( "nEnter radius of a circle " ) ;
scanf ( "%d", &radius ) ;

areaperi ( radius, &area, &perimeter ) ;

printf ( "Area = %f", area ) ;
printf ( "nPerimeter = %f", perimeter ) ;
}

(Note that I wrapped the code in
 to make the whitespace display properly.)


text:
Q: Transition matrix for Jordan canonical form I have this matrix:
$$A = \begin{bmatrix}
3 & 1 & 2 \\
0 & 3 & -1 \\
0 & 0 &  3
\end{bmatrix}$$
The characteristic polynomial is $(3-\lambda)^3,$ so the eigenvalue is $\lambda=3$ alone.
$$(A-\lambda I) = \begin{bmatrix}
0 & 1 & 2 \\
0 & 0 & -1 \\
0 & 0 &  0
\end{bmatrix}\implies \textrm{the eigenvalue is } v=(1,0,0)\textrm{ alone.}$$
So, I have the Jordan canonical form:
$$J = \begin{bmatrix}
3 & 1 & 0 \\
0 & 3 & 1 \\
0 & 0 &  3
\end{bmatrix}.$$
Now, I want to find the transition matrix $P$ such that $A=PJP^{-1}.$
I know that I need to find the generalized eigenvector, but I don't know what to do with them.
I saw that
$$(A-\lambda I)^{2} = \begin{bmatrix}
0 & 0 & 0 \\
0 & 0 & -1 \\
0 & 0 &  0
\end{bmatrix}$$
So, can I take as the generalized eigenvector the vector $w=(0,1,0)$? Since $\ker((A-\lambda)^{2})=\textrm{Span}\{v,(0,1,0)\}$, I think that is fine.
Now,
$$(A-\lambda I)^{3} = \begin{bmatrix}
0 & 0 & 0 \\
0 & 0 & 0 \\
0 & 0 &  0
\end{bmatrix},$$
so, the generalized eigenspace is $\Bbb{R}^{3}.$ Can I take as the final generalized eigenvector the vector $u=(0,0,1)$?
And now, how can I construct the matrix P?
I think there is something wrong, since the basis that I found is just the canonical basis, and in this basis the matrix $A$ is not in Jordan form.

A: The basis you find, in the end, will have the form $\beta=[\mathbf{v}_1,\mathbf{v}_2,\mathbf{v}_3]$, where:

*

*$(A-3I)\mathbf{v}_3 = \mathbf{v}_2$;

*$(A-3I)\mathbf{v}_2 = \mathbf{v}_1$;

*$(A-3I)\mathbf{v}_1 = \mathbf{0}$.

So you need to find a vector, $\mathbf{v}_3$, which is (i) in the nullspace of $(A-3I)^3$; but (ii) not in the nullspace of $(A-3I)^2$.
Here, everything is in the nullspace of $(A-3I)^3$, since $(A-3I)^3$ is the zero matrix.
You've compute $(A-3I)^2$ incorrectly: the correct calculation gives
$$(A-3I)^2 = \left(\begin{array}{rrr}
0 & 1 & 2\\
0 & 0 & -1\\
0 & 0 & 0\end{array}\right) \left(\begin{array}{rrr}
0 & 1 & 2\\
0 & 0 & -1\\
0 & 0 & 0\end{array}\right) = \left(\begin{array}{rrr}
0 & 0 & -1\\
0 & 0 & 0\\
0 & 0 & 0
\end{array}\right).$$
The nullspace is $\{ (x,y,z) \mid z=0\}$ (note your calculation is wrong, even for the matrix you got; you don't need $y=0$, you need $z=0$). So all you need to do is take any vector that is not in that nullspace. In particular, you cannot take $(0,1,0)$ (which is in the nullspace of $(A-3I)^2$); but you can take $(0,0,1)$, which is not.
If you pick $\mathbf{v}_3=(0,0,1)$, then $\mathbf{v}_2 = (A-3I)\mathbf{v}_3 = (2,-1,0)$; and $\mathbf{v}_1 = (A-3I)\mathbf{v}_2 = (-1,0,0)$.


text:
Q: How do the nanites fit? In Infinity War, Tony Stark has a nanite suit, which fits in a casing which is not much larger than his old Arc Reactor. While in Black Panther it makes sense that his suit fits in the necklace, since he wears a thin, skin tight suit; there is no way that all of the nanites for a suit that large fit in that casing. How did they fit?
(I know in the comics he stores them in the hollows of his bones, but there is no mention of that in the movie.)

A: Keep in mind that most of the volume of any given material (even a solid) is empty space. There's a ton of empty space between molecules, and between the atoms in molecules. So it could be that the nanites are just closer together when they're being transported compared to when they're forming a suit or weapon.
Think about how a balloon works. I could take a balloon out of my pocket and blow it up so it's much larger than the pocket. Or I could take a bunch of small balloons and combine them into a larger balloon animal. The nanites could be doing something very similar, forming a mostly hollow shape from a relatively small volume of materials.
Similarly, think about a bucket of paint. You can paint an entire room with just one bucket of paint, even though the room is larger than the bucket. Again, the nanites are like paint, or more like ink for a 3D printer.
It all comes down to surface area and volume.


text:
Q: Oracle sql,plsql create a sql building up the variables Wonder if someone could guide me in the right direction.
I have a data table structure as below:
table2_type char (1)

table2_key char (40)

table2_reftype char (20)

table2_seq char (10)

table2_ref char (50)

and data rows like(comma separated for readability only):
I,123456789,typea,0000000001,abc

I,123456789,typeb,0000000002,999

I,123456789,typec,0000000003,9z9

I,123456789,typed,0000000004,zyx

I,123456789,typee,0000000005,qwe

I,987654321,typea,0000000006,bcd

I,987654321,typeb,0000000007,444

What I have to do at the moment to get all the table_ref values for the same table_key values is below (spaced for ease of reading):
select table1_bkey,

nvl((case when (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad('typea',20)) is not null then (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad('typea',20)) else (select table2_ref from table2 where table2_key = table1_alt and table2_reftype = rpad('typea',20)) end),' ') as REF_A,

nvl((case when (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad('typeb',20)) is not null then (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad('typeb',20)) else (select table2_ref from table2 where table2_key = table1_alt and table2_reftype = rpad('typeb',20)) end),' ') as REF_B,

nvl((case when (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad('typec',20)) is not null then (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad('typec',20)) else (select table2_ref from table2 where table2_key = table1_alt and table2_reftype = rpad('typec',20)) end),' ') as REF_C,

nvl((case when (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad('typed',20)) is not null then (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad('typed',20)) else (select table2_ref from table2 where table2_key = table1_alt and table2_reftype = rpad('typed',20)) end),' ') as REF_D,

nvl((case when (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad('typee',20)) is not null then (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad('typee',20)) else (select table2_ref from table2 where table2_key = table1_alt and table2_reftype = rpad('typee',20)) end),' ') as REF_E

from table1 where table1_bkey = '123456789';

I currently could have up to 25 different table2_reftype per table2_key so I have to do 25 case statements. And if/when new table2_reftype are added I have to do new case statements.
My question, is there a way to get all the table2_reftype values per table2_key without having to do multiple case statements eg:
illustration purpose only, not to be taking literal as code in any way!!
while table2_key = table1_bkey

get table2_reftype

then for each table2_reftype

nvl((case when (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad(<table2_reftype variable>,20)) is not null then (select table2_ref from table2 where table2_key = table1_bkey and table2_reftype = rpad(<table2_reftype variable>,20)) else (select table2_ref from table2 where table2_key = table1_alt and table2_reftype = rpad(<table2_reftype variable>,20)) end),' ') as REF_<table2_reftype  variable>

where table1_bkey = '123456789';

First post so hope I have put enough information.

A: I think you could use something like this:
select key, ref_a, ref_b, ref_c
  from (
    select table1_bkey key, table2_ref ref, trim(table2_reftype) type,
           row_number() over (partition by table1_bkey, table2_reftype
                              order by case table2_key when table1_bkey then 1 else 2 end) rn
      from table1
      left join table2
        on trim(table2_reftype) in ('typea', 'typeb', 'typec')
        and table2_key in (table1_bkey, table1_alt))
  pivot (max(ref) for type in ('typea' ref_a, 'typeb' ref_b, 'typec' ref_c))
  where rn = 1

dbfiddle demo
What is going on here? I left join-ed both tables using your conditions. Then I assigned rn which depends on if match is done on base key or alternate key. Base has higher priority, so in case both were found second is removed (where rn = 1). Rest was easy, just pivot data for types which you hardcoded. Also please note that I trimmed ref_type.
This is example for 3 types, when you add new, just put it in both lists. As you can see in my dbfiddle query works, but I had to imagine some data which you did not describe (for table1).
In case something is wrong and you would not be able to correct / adapt this solution please edit your question and provide sample data for both tables in the form of working create and insert statements and show us desired result for this data.
You can also solve it like you described in your pseudo-code, but this requires either dynamic PLSQL, either constructing query in some other code (I did similiar things in .NET). Why? Because Oracle has to know all columns when it compiles query.
I hope this helps :)


text:
Q: Sparx EA Templates & Template fragment Document Generation approach questions Trying to build template (with possibly included template fragments, but anyway) in Sparx EA.
Struggled to find answers in Internet (but I tought it would be popular thou)
First:
Is there are way to output(or even prevent output), as example, packadge properties in different styles depends on packadge level (root, first level packs, second level etc)?
Let say I don't want to ouput name of root packadge, but I want to output name of child packadges.
If I remove tag {Pkg.Name} inside child packdages it will proceed each child packadge data as described in template above, but if I leave it like in this picture - it will output only names of child packadges

Second:
Is there a way, for template fragment scripting, to get currently processing object data (lets say Diagram.Note) and construct table from it?
(lets say I got some html markup or wiki markup inside and I want to render it as table)
P.S.
I know that I can achieve all this by writing my own document generation addin, only fetching data from Sparx Ea project and render it by some third-party library, but still wondering, maybe built-in features could replace that type of solution
UPD
Well, article by mr. Geert Bellekens (link in his answer) & this article helped me to find solution of first problem!

A: You can do almost anything with the current built-in document generator and fragments.
Just don't try to make one big template for your complete document. Instead make small manageable templates and use virtual documents to tie all to the pieces together.
With Custom Script template fragments, Custom SQL template fragments and Document Script template fragments you really have all the freedom you need to make professional document using only standard document generation features.
I used to build my own generators in the past, and loved it, but I can't honestly defend the business case anymore with the current state and flexibility of the built-in document generator.
For an example template and model see Tutorial: Generate complex documents from Enterprise Architect with a two-step semi-automated approach


text:
Q: As well as about Should the word about be repeated after as well as?
Last month I started attending the science workshop. As a result, I would like to write some articles about nature as well as about the science experiments we do in the school laboratory.


text:
Q: How to Delete WordPress Media File in PHP I uploaded a photo to Wordpress (../upload/…) folder; using this function:
$attachment_id = wp_insert_attachment( $attachment, $upload_file['file'], $ref_id );

From the Media Library, when I clicked the Edit option, it showed me that the attachment_id is 2260
Permalink: http://localhost/outafire/?attachment_id=2260
When I tried to get the full path using this function:
$attached_path = wp_get_original_image_path(2260); // **ALWAYS FAILED - CANNOT FIND FILE**

It always failed.
How can I get the original image path with the attachment_id as input; 2260?


text:
Q: produce dataframe of Count no. of sheets in all workbooks in a directory path =r"C:\Users\Ayush\Desktop\New folder"

filenames = glob.glob(path + "\*.xlsx")
print('File names:', filenames)

xl = pd.ExcelFile('C:\\Users\\Ayush\\Desktop\\New folder\\1.xlsx')
res = len(xl.sheet_names)
print(res)

for file in filenames
xl1 = pd.ExcelFile(filenames)
res = len(xl1.sheet_names)
print(res)

A: Try this...
import pandas as pd
from os import listdir
from os.path import isfile, join

mypath = r"C:\Users"
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]

filename, cnt, sheets = [],[],[]
for file in onlyfiles:
    if ".xlsx" in file:
        df = pd.ExcelFile(mypath+"\\"+file)
        filename.append(file)
        cnt.append(len(df.sheet_names))
        sheets.append(df.sheet_names)
df_final = pd.DataFrame({"filename":filename,"sheets cnt":cnt,"sheets name":sheets})

Hope this helps...


text:
Q: Why does style attribute change p block color, but style sheet won't? This is a simple question:
This code prints WELCOME in RED.

WELCOME

When I switch to a css style sheet it prints it in BLACK

p {
  font-size: 12pt;
  text-align: left;
  padding: 1em 1em 0 1em;
  color: RED;
}

 WELCOME

How come?
Every time I've tested the css style sheet version, I changed the font-size and text-align properties. And each time the browser rendered those changes but ignored color.
For example,

p {
  font-size: 30pt;
  text-align: left;
  padding: 1em 1em 0 1em;
  color: GREEN;
}

 WELCOME

Rendered very large type ... but still in BLACK.


text:
Q: complex array initialization Can somebody explain me why do I have this error and how should complex array initialization done in my case ?
z3 src # head -37 company.c
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include "company.h"
#include "mytypes.h"
#include "depserv.h"
#include "table_defs/t_cat_deptype.h"

#define NUM_DEFAULT_DEPTYPES            9
typedef struct itl_cat_deptypes_t {
        t_cat_deptype_t         deptypes[NUM_DEFAULT_DEPTYPES];
} itl_cat_deptypes_t;

itl_cat_deptypes_t cat_deptypes[2] = {
        {
                {"Information Request",'\0'},
                {"Question",'\0'},
                {"Meeting",'\0'},
                {"Event",'\0'},
                {"Task",'\0'},
                {"Objective/Goal",'\0'},
                {"Authorization Request",'\0'},
                {"Dependency",'\0'},
                {"Custom",'\0'}
        },{
                {"Solicitud de Informacion",'\0'},
                {"Pregunta",'\0'},
                {"Junta",'\0'},
                {"Evento",'\0'},
                {"Tarea",'\0'},
                {"Objetivo/Meta",'\0'},
                {"Solicitud de Autorizacion",'\0'},
                {"Dependencia",'\0'},
                {"Personalizado",'\0'}
        }
};

z3 src # head table_defs/t_cat_deptype.h
#ifndef _T_CAT_DEPTYPE_
#define _T_CAT_DEPTYPE_

typedef struct t_cat_deptype_t {
        char                            description[64];
        char                            inactive;
} t_cat_deptype_t;

#endif

z3 src # make company.o
gcc -ggdb -Wmissing-prototypes -Wmissing-declarations -Wunused -Winline -Wno-format      -Wstrict-prototypes -Wimplicit-function-declaration -fmax-errors=5 -D_GNU_SOURCE -I./table_defs  -c company.c
cc1: warning: command line option "-fmax-errors=5" is valid for Fortran but not for C
company.c:17:3: error: extra brace group at end of initializer
company.c:17:3: error: (near initialization for 'cat_deptypes[0]')
company.c:17:3: warning: excess elements in struct initializer
company.c:17:3: warning: (near initialization for 'cat_deptypes[0]')
company.c:18:3: error: extra brace group at end of initializer
company.c:18:3: error: (near initialization for 'cat_deptypes[0]')
company.c:18:3: warning: excess elements in struct initializer
company.c:18:3: warning: (near initialization for 'cat_deptypes[0]')
company.c:19:3: error: extra brace group at end of initializer
company.c:19:3: error: (near initialization for 'cat_deptypes[0]')
company.c:19:3: warning: excess elements in struct initializer
company.c:19:3: warning: (near initialization for 'cat_deptypes[0]')
company.c:20:3: error: extra brace group at end of initializer
company.c:20:3: error: (near initialization for 'cat_deptypes[0]')
company.c:20:3: warning: excess elements in struct initializer
company.c:20:3: warning: (near initialization for 'cat_deptypes[0]')
company.c:21:3: error: extra brace group at end of initializer
company.c:21:3: error: (near initialization for 'cat_deptypes[0]')
company.c:21:3: warning: excess elements in struct initializer
company.c:21:3: warning: (near initialization for 'cat_deptypes[0]')
company.c:22:3: error: extra brace group at end of initializer
company.c:22:3: error: (near initialization for 'cat_deptypes[0]')
company.c:22:3: warning: excess elements in struct initializer
company.c:22:3: warning: (near initialization for 'cat_deptypes[0]')
company.c:23:3: error: extra brace group at end of initializer
company.c:23:3: error: (near initialization for 'cat_deptypes[0]')
company.c:23:3: warning: excess elements in struct initializer
company.c:23:3: warning: (near initialization for 'cat_deptypes[0]')
company.c:24:3: error: extra brace group at end of initializer
company.c:24:3: error: (near initialization for 'cat_deptypes[0]')
company.c:24:3: warning: excess elements in struct initializer
company.c:24:3: warning: (near initialization for 'cat_deptypes[0]')
company.c:27:3: error: extra brace group at end of initializer
company.c:27:3: error: (near initialization for 'cat_deptypes[1]')
company.c:27:3: warning: excess elements in struct initializer
company.c:27:3: warning: (near initialization for 'cat_deptypes[1]')
company.c:27:20: error: expected '}' before '.' token
make: *** [company.o] Error 1
z3 src #

A: On the line
{"Pregunta",'\0'}.

in
itl_cat_deptypes_t cat_deptypes[2] = {
        {
                {"Information Request",'\0'},
                {"Question",'\0'},
                {"Meeting",'\0'},
                {"Event",'\0'},
                {"Task",'\0'},
                {"Objective/Goal",'\0'},
                {"Authorization Request",'\0'},
                {"Dependency",'\0'},
                {"Custom",'\0'}
        },{
                {"Solicitud de Informacion",'\0'},
                {"Pregunta",'\0'}.
                {"Junta",'\0'},
                {"Evento",'\0'},
                {"Tarea",'\0'},
                {"Objetivo/Meta",'\0'},
                {"Solicitud de Autorizacion",'\0'},
                {"Dependencia",'\0'},
                {"Personalizado",'\0'}
        }
};

There is a . instead of a , at the end of the line. Which is also what the compiler tells you:
company.c:27:20: error: expected '}' before '.' token