text:
Q: How to draw the figure with four pentagons? I want to make the next figure formed by 4 pentagons.

I can only do with two and still have a space between them. I can't even do the reflection of the two pentagons to get the desired figure.
\documentclass[a4paper]{article}

\usepackage[brazil]{babel}

\usepackage{graphicx}

\usepackage{tikz}

\begin{document}

 \begin{center}

\begin{figure}[!htb]

  \begin{tikzpicture}

        \draw[ultra thick,rotate=18] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;

  \end{tikzpicture}

 \end{figure}

\begin{figure}[!htb]

   \begin{tikzpicture}
        \draw[ultra thick,rotate around={198:(-0.80,0.58)}] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;

  \end{tikzpicture}

  \end{figure}

\end{center}

\end{document}

A: This looks like a code golfing challenge ;)
\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
  \tikz
    \path[fill=violet](1,1.17557)foreach~in{1,-1}{[scale=~]foreach~in{1,-1}{[yscale=~]
      --(1,1.17557)node[regular polygon,regular polygon sides=5,
      inner sep=17.11435,draw,fill=white,transform shape,yshift=-9.24486]{}}};
\end{document}

Calculations

*

*1cm = 28.452755906694 pt

*x = 1 cm

*y = (cos(pi/5)+cos(2*pi/5))/sin(2*pi/5) = 1.1755705045849463 cm

*inner sep = cos(pi/5)/sqrt(2)/sin(2*pi/5)*28.452755906694 = 17.114359850473026 pt

*yshift = -cos(2*pi/5)/sin(2*pi/5)*28.452755906694 = -9.244860806192047 pt

A: You can draw more than one shape in the same tikzpicture:
\documentclass[a4paper]{article}

\usepackage[brazil]{babel}

\usepackage{graphicx}

\usepackage{tikz}

\begin{document}

 \begin{center}

\begin{figure}[!htb]

  \begin{tikzpicture}

        \draw[ultra thick,rotate=18] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;
        \begin{scope}[yshift=-3.22cm]
        \draw[ultra thick,rotate=198] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;
                \end{scope}
                \begin{scope}[xshift=3.8cm]
                        \draw[ultra thick,rotate=18] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;
                        \begin{scope}[yshift=-3.22cm]
                        \draw[ultra thick,rotate=198] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;
                                \end{scope}
                \end{scope}
  \end{tikzpicture}

  \end{figure}

\end{center}

\end{document}

To make things easier, you can use predefined pentagons:
\documentclass[a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}

\begin{figure}[!htb]
\begin{tikzpicture}[every node/.append style={regular polygon, regular polygon sides=5, minimum size=4cm, draw,ultra thick}]
    \node at (0,0) {};
    \node at (3.8,0) {};
    \node[rotate=180] at (0,-3.22) {};
    \node[rotate=180] at (3.8,-3.22) {};
\end{tikzpicture}
\end{figure}

\end{document}

Off-topic: please note that placing a floating figure environment inside a non-floating center environment does not make much sense..

A: Similar answer to @samcarter, but using named nodes -- avoids having to calculate the distances. My motto: Let TikZ do the work!
\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{shapes.geometric}
%% The size can easily altered by changing the minimum size
\tikzset{pgon/.style={regular polygon,regular polygon sides=5,minimum size=1in,draw,ultra thick,outer sep=0pt}}

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{shapes.geometric}

\tikzset{pgon/.style={regular polygon,regular polygon sides=5,minimum size=1.5in,draw,ultra thick,outer sep=0pt}}

\begin{document}

\tikz{%
    \node[pgon] (S) at (0,0) {S};
    \node[pgon,anchor=corner 2] (A) at (S.corner 5) {A};
    \node[pgon,rotate=180,anchor=corner 4] (B) at (S.corner 3) {B};
    \node[pgon,rotate=180,anchor=corner 4] (C) at (A.corner 3) {C};
    \draw[fill=purple!50,line join=bevel,ultra thick] (S.corner 5) --
            (A.corner 3) --
            (C.corner 5) --
            (S.corner 4) -- cycle;
}

\end{document}

Update
I have modified the code slightly so that there won't be a problem with mitre issues at the top and bottom of the colored shape. Updated the output as well.


text:
Q: Programming Issue in my counting sort algo Please let me know the issue i have in this short code. I tried to follow the algo from the book and convert it into a program but have done some error in the process. Its throwing arrayoutofbounds exception
Algo which i tried to follow is bellow:

countingsort(a,b,k)
    1)let c[0..k] be a new array
    2)for i =0 to k
    3)   c[i]=0;
    4)for j=1 to a.length
    5)  c[a[j]]=c[a[j]]+1
    6)for i = i to k
         c[i] = c[i] + c[i-1]
    7)for j=a.length downto 1
         b[c[a[j]]]= a[j]
         c[a[j]] = c[a[j]]-1

public class CountingSort {
    public static void main(String[] args) {
        int[] array_A = {6, 0, 2, 0, 1, 3, 4, 6, 1, 3, 2};
        int[] array_B = new int[array_A.length];

        int k = 6;
        countingSort(array_A,array_B,k);
        //System.out.println(array_B);

    }
    public static void countingSort(int[] A, int[] B, int k){
        int[] C = new int[k+1];
        for(int i = 0; i<=k; i++){
            C[i] = 0;
        }
        for(int j = 0; j<A.length; j++){
            C[A[j]] = C[A[j]] + 1;

        }
        for(int i = 1; i<=k; i++){
            C[i] = C[i] + C[i-1];
        }
        for(int j = A.length-1; j>=1; j--){
            B[C[A[j]]] = A[j];
            C[A[j]] = C[A[j]] - 1;
        }

        System.out.println(Arrays.toString(B));

    }

}

Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 11
    at importantPrograms.CountingSort.countingSort(CountingSort.java:22)
    at importantPrograms.CountingSort.main(CountingSort.java:11)

A: Change

*

*C[A[j]] = C[A[j] + 1]; to C[A[j]] = C[A[j]] + 1; because you are supposed to count the number of particular number occurrence.

A: Here is the modified code that worked for me.
import java.util.Arrays;
public class CountingSort {
    public static void main(String[] args) {
        int[] array_A = {6, 0, 2, 0, 1, 3, 4, 6, 1, 3, 2};
        int[] array_B = new int[array_A.length];
        int k = 6;
        countingSort(array_A,array_B,k);
        System.out.println(Arrays.toString(array_B));
    }
    public static void countingSort(int[] A, int[] B, int k){
        int[] C = new int[k+1];
        for(int i = 0; i<=k; i++){
            C[i] = 0;
        }
        for(int j = 0; j<A.length; j++){
            C[A[j]] ++;
        }
        for(int i = 1; i<=k; i++){
            C[i] += C[i-1];
        }
        for(int j = A.length-1; j>=0; j--){
            B[--C[A[j]]] = A[j];
        }
    }
}

Ideally, instead of hard-coding the max value (6), you would find the max programmatically and size your count array accordingly. Such as
In main method
countingSort(array_A,array_B,max(array_A));

Max method
public int max(int[] arr){
    int m = 0;
    for(int i : arr){
        if(i>m){
            m = i;
        }
    }
    return m;
}

A: I have no clue what you are doing but there is only a little mistake in your second for loop.
Change j<A.length to j<C.length

redpajama_set_name: RedPajamaStackExchange


text:
Q: Datastore efficiency, low level API Every Cloud Datastore query computes its results using one or more indexes, which contain entity keys in a sequence specified by the index's properties and, optionally, the entity's ancestors. The indexes are updated incrementally to reflect any changes the application makes to its entities, so that the correct results of all queries are available with no further computation needed.
Generally, I would like to know if
datastore.get(List<Key> listOfKeys);

is faster or slower than a query with the index file prepared (with the same results).
Query q = new Query("Kind")(.setFilter(someFilter));

My current problem:
My data consists of Layers and Points. Points belong to only one unique layer and have unique ids within a layer. I could load the points in several ways:
1) Have points with a "layer name" property and query with a filter.
- Here I am not sure whether the datastore would have the results prepared because as the layer name changes dynamically.
2) Use only keys. The layer would have to store point ids.
KeyFactory.createKey("Layer", "layer name");
KeyFactory.createKey("Point", "layer name"+"x"+"point id");

3) Use queries without filters: I don't actually need the general kind "Point" and could be more specific: kind would be ("layer name"+"point id")
- What are the costs to creating more kinds? Could this be the fastest way?
Can you actually find out how the datastore works in detail?

A:
faster or slower than a query with the index file prepared (with the same results).

Fundamentally a query and a get by key are not guaranteed to have the same results.
Queries are eventually consistent, while getting data by key is strongly consistent.
Your first challenge, before optimizing for speed, is probably ensuring that you're showing the correct data.
The docs are good for explaining eventual vs strong consistency, it sounds like you have the option of using an ancestor query which can be strongly consistent. I would also strongly recommend avoiding using the 'name' - which is dynamic - as the entity name, this will cause you an excessive amount of grief.
Edit:
In the interests of being specifically helpful, one option for a working solution based on your description would be:

*

*Give a unique id (a uuid probably) to each layer, store the name as a property

*Include the layer key as the parent key for each point entity

*Use an ancestor query when fetching points for a layer (which is strongly consistent)

An alternative option is to store points as embedded entities and only have one entity for the whole layer - depends on what you're trying to achieve.


text:
Q: Evaluating: $\int (x^{2}+x)\ln|x-1|dx$ Evaluating:
$\int (x^{2}+x)\ln|x-1|dx$
My problem is due to the presence of the absolute value.

A: Suggestion. Consider two cases:

*

*$x-1>0\Leftrightarrow x>1$ and the substitution $u=x-1$ $$\begin{eqnarray*}
\int \left( x^{2}+x\right) \ln \left\vert x-1\right\vert dx &=&\int \left(
x^{2}+x\right) \ln \left( x-1\right) dx \\
&=&\int \left( 2+3u+u^{2}\right) \ln u\,du \\
&=&\ldots
\end{eqnarray*}$$

*$x-1<0\Leftrightarrow x<1$ and the substitution $t=1-x$
$$\begin{eqnarray*}
\int \left( x^{2}+x\right) \ln \left\vert x-1\right\vert dx &=&\int \left(
x^{2}+x\right) \ln \left( 1-x\right) dx \\
&=&\int \left( -2+3t-t^{2}\right) \ln t\,dt \\
&=&\cdots
\end{eqnarray*}$$

Then integrate by parts
$$\begin{eqnarray*}
\int \ln u\,du &=&u\ln u-u+C \\
\int u\ln u\,du &=&\frac{1}{2}u^{2}\ln u -\int \frac{1}{2}u\,du
\\
\int u^{2}\ln u\,du &=&\frac{1}{3}u^{3}\ln u-\int \frac{1}{3}u^{2}\,du
\end{eqnarray*}$$

A: I would go along with the suggestion made by Americo Tavares. I'll start where he left off on the first example and finish off the integral.
$$\int \left(2+3u+u^{2}\right) \ln u \ \ du$$
Multiplying through by $\ln u$ leaves us
$$\int \left(u^2 \ln (u) + 3u\ln (u) + 2 \ln (u)\right) \ \ du$$
Splitting the integrand into three separate integrals:
$$\int u^2 \ln (u)  \ \ du  + 2 \int \ln (u) \ \ du + 3\int u\ln (u) \ \ du$$
Recall integration by parts formula: $\int u \  dv =  uv - \int v \  du$
For our first integral $\int u^2 \ln (u)  \ \ du$, integrate by parts (since we are using $u$ already, I'll use $r$ and $s$.) Let $r = \ln u, dr = \frac{1}{u} \ \ du, s = \frac{u^3}{3}, ds = u^2 du.$
$$\int u^2 \ln (u)  \ \ du  + 2 \int \ln (u) \ \ du + 3\int u\ln (u) \ \ du$$
For $\int u \ln u$, let $f$ and $g$ denote our usual $u$ and $v$ in the integration by parts formula above. Use $f = \ln(u), df = \frac{1}{u} \ \ du, dg = u \ \ du, g = \frac{u^2}{2}$
Finally, for $\int \ln u \ \ du$, let $a$ and $b$ represent our usual $u$ and $v.$ Let $a = \ln u, da = \frac{1}{u} \ \ du, db = du, b = u$
After you carry out all of the integration by parts, you should get:
$$- \frac{u^3}{9} + \frac{1}{3} u^3 \ln (u) - \frac{3u^2}{4} + \frac {3}{2}u^2\ln (u) - 2u + 2u\ln(u) + C$$
If you need me to fill in some more details, let me know and I'll be glad to. Note that you may be able to simplify that last expression a bit if it pleases you. I'll leave the second case to you where $x < 1$. Simply comment if you need help with the second example and I'll help.


text:
Q: Redirecionar por faixa de ip javascript é possível redirecionar para algum site pela faixa de ip. Para um unico ip foi ok.
Segue meu codigo;

Teste redirecionar

teste


text:
Q: Sample Values of Linear Combination of MultiVariate Variables Suppose we have $p$ random variates :- $X_1, \cdots , X_p$. $n$ observations involving each random variable are made . Thus, the $jth $ trial or $jth$ observation is a vector of the form : $[x_{j1},x_{j2},\cdots, x_{jp}]^T$
where $x_{ji}$ means the value in the $jth$ trial for the $ith $ random variable.
Let matrix $X = [X_{.,1} ~~ X_{.,2} ~~ \cdots X_{.,p}]_{n \times p}$
Now, if we wish to investigate the linear combination of the $p$ variates, I believe the expression should be
$$c^T_{1 \times p} ~X^T_{p \times n} = c_1 X_1 + \cdots c_pX_p~~ $$
where $X_i$ is the $ith$ row of $X$ and represents the $ith$ trial.
But, my textbook multivariate statistical analysis by Richard Johnson seems to have a typo here in the image attached below. Could Someone please confirm the same?


text:
Q: I don't know how to go about a button to open a website I have a couple of questions, I'm making a personal/public tool for finding and opening external tool websites really quick, in the code (Which I will provide below) I want to have buttons with the text on them with the website, the links and names of each website are in the code at the bottom of the GUI Stuffs.
I just don't know how to go about the button and text thing, nor do I know how to open a website in chrome externally I know how to do it in a batch file, but not in AHK
; This is an ED tools Program built to allow you to open tools with a click of a button

Gui, Show, w310 h300, Elite Dangerous Tools

; GUI Stuffs
Gui, Add, Button, w50 19 x150 y10 Beddb

;Tools

;eddb.io
eddb:

return

;-----------

;www.edsm.net
edsm:

return

;-----------

;inara.cz
inara:

return

;-----------

;coriolis.io
coriolis:

return

;-----------

;edtools.ddns.net
edtools:

return

;-----------

;edshipyard.net/
edship:

return

;-----------

GuiClose:
ExitApp

I want to have a GUI with buttons on it, 6 buttons in total. 3 on each side, text saying the name of the website, whatever. but when I run it now, I get
Error: Invalid Option
Specifically Beddb

Line#
006 Gui,Add,Button,w50 h19 x150 y10 Bebbd

A: As Yane mentioned in the comment, you need a g before your sub-routine (label) name. (More info here.) Below is a working example of your code for one of the buttons and sites. It opens the site in Firefox. You can apply this to the rest of your buttons and sites.
f1::
Gui , Add , Button , w50 19 x150 y10 geddb , eddb.io
Gui , Show , w310 h300 , Elite Dangerous Tools
Return

eddb:
Run , firefox.exe "eddb.io"
Return

The help documentation does a great job explaining all the things you can do with GUIs.
https://www.autohotkey.com/docs/commands/Gui.htm


text:
Q: Change Default Scale Method Setting for KDE Wallpapers I wish to change the default scaling method for the desktop wallpaper in KDE(more specifically Kubuntu) by editing the configuration file KDE uses to fill in those defaults on a fresh install.  So that, when any new account is created, or someone is installing the OS, it is set to Scaled & Cropped instead of zoomed or scaled.
I know that gnome has this default setting stored in,
/usr/share/gnome-background-properties/ubuntu-wallpapers.xml

or in,
/usr/share/gconf/schemas/desktop_gnome_background.schemas

I have been searching the linux filesystem for a couple days know to find the KDE equivalent of the files listed above, but with no luck.
I have thoroughly search '/usr/share/kununtu-default-settings' but there doesn't seem to be any configuration file for the wallpaper settings listed there.  At this point I am assuming another program, not built into KDE, is handling the wallpaper, I don't know how to determine this though.

A: KDE Plasma desktop
The KDE configuration files: http://techbase.kde.org/KDE_System_Administration/Configuration_Files
The KDE is using the plasma desktop and the wallpaper is an applet/widget. The plasma desktop applet configuration file is: plasma-desktop-appletsrc.
The wallpaper setting can be set for the each activity/desktop.
The positioning information is saved to the 'wallpaperposition=X'
wallpaperposition=0 is 'Scaled'
wallpaperposition=1 is 'Centered'
wallpaperposition=2 is 'Scaled & Cropped'
wallpaperposition=3 is 'Tiled'
wallpaperposition=4 is 'Center Tiled'
wallpaperposition=5 is 'Scaled, keep proportions'
kde4rc
The default configuration profile path is read from the /etc/kde4rc. The information is used when the new user default configuration files are made.
The Kubuntu is using:
[Directories-default]
prefixes=/usr/share/kubuntu-default-settings/kde4-profile/default/

the user can change this - as example at here
[Directories-default]
prefixes=/usr/share/my-default-settings/kde4-profile/default/

The Kubuntu has in the /usr/share/kubuntu-default-settings/kde4-profile/default/share/config/plasma-desktop-appletsrc:
[AppletGlobals][plasma_applet_launcher]
SwitchTabsOnHover=false
askBeforeRemoval=true

You could edit your plasma desktop and then copy your ~/.kde/share/config/plasma-desktop-appletsrc to the /usr/share/my-default-settings/kde4-profile/default/share/config/plasma-desktop-appletsrc. The new user will then has your plasma applet settings as start default.


text:
Q: Saving captured picture to photo library in Swift? I know how to save the captured photo to the library but I added some extra code because I wanted the label in my camera view to combine together and save. When I try to save it to the photo library it doesn't save with the label. Here is the code I have:
@IBAction func takePicture(sender: AnyObject) {

    if let videoConnection = stillImageOutput!.connectionWithMediaType(AVMediaTypeVideo) {
        videoConnection.videoOrientation = AVCaptureVideoOrientation.Portrait
        stillImageOutput?.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: {(sampleBuffer, error) in
            if (sampleBuffer != nil) {
                let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer)
                let dataProvider = CGDataProviderCreateWithCFData(imageData)
                let cgImageRef = CGImageCreateWithJPEGDataProvider(dataProvider, nil, true, CGColorRenderingIntent.RenderingIntentDefault)
                let image = UIImage(CGImage: cgImageRef!, scale: 1.0, orientation: UIImageOrientation.Right)
                UIGraphicsBeginImageContextWithOptions(self.previewCamera.bounds.size, self.previewCamera.opaque, 0.0)
                self.previewCamera.layer.renderInContext(UIGraphicsGetCurrentContext()!)
                UIGraphicsEndImageContext()
                self.capturedImage.image = UIGraphicsGetImageFromCurrentImageContext()
                //saves captured picture to camera roll.
                UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
            }
        }


text:
Q: Does commons-io's FileUtils.readFileToByteArray close the newly created stream? I'm creating a program that produce checksums for each files in directory. I'm using FileUtils.readFileToByteArray which internally creates a new FileInputStream. The problem is I didn't find where the stream is closed and wondering about a possible memory leak.
So I'm asking: does this method close the stream after reading it?

A: Short answer: yes, it closes the stream.
Slightly longer answer:
Let's look at the code:
try (InputStream in = openInputStream(file)) {
    final long fileLength = file.length();
    // file.length() may return 0 for system-dependent entities, treat 0 as unknown length - see IO-453
    return fileLength > 0 ? IOUtils.toByteArray(in, fileLength) : IOUtils.toByteArray(in);
}

That you see here is the try-with resource syntax. Any AutoClosable opened in the try's parentheses (in this case, a FileInputStream) will be implicitly closed when the try block terminates, whether it terminated normally or by returning, throwing an exception, etc.


text:
Q: How to print Listboxtext to pdf in C# using Windows Forms? I have been working on an app, and am using dapper to map the data and data access from database.
I have a form for teams and players. I have coded so that when I click on a team name it displays players in that team. I want to print the players of a specific team to a pdf file. The following is the code for what I'm trying to do; moreover I'm attaching pictures for better understanding.
I want to print players in the listbox to a pdf file, with the pictures of each player.
image for manage teams
private void printButton_Click(object sender, EventArgs e)
{
    if (teamsListBox.SelectedItem is TeamModel selectedTeam)
    {
        playersListBox.DataSource = selectedTeam.Players;
        nameValue.Text = playersListBox.Name;
        printDialog1.Document = printDocument1;
        nameValue.Text = playersListBox.Name;
        SetBindings();
        string items = "";
        for (int i = 0; i < selectedTeam.Players.Count; i++)
        {
            PlayerModel item = selectedTeam.Players[i];
            items += Name.ToString() + " ";

        }
        MessageBox.Show(items);
        myReader = new StringReader(items);
        if (printDialog1.ShowDialog() == DialogResult.OK)
        {
            this.printDocument1.Print();
        }

    }
}

A: All you need to do is to loop on the player names and image path and send them to your pdf file, this is an easy code to create a PDF with players list using PDFFlow library
    {
        var imagePath = "imageFile.png";
        var numType = NumerationStyle.Arabic;
        DocumentBuilder.New()
        .AddSection()
            .AddParagraph("Cristiano Ronaldo").SetListNumbered(numType, 1).AddInlineImage(imagePath, 20, 20, ScalingMode.UserDefined).ToSection()
            .AddParagraph("Lionel Messi").SetListNumbered(numType, 1).AddInlineImage(imagePath, 20, 20, ScalingMode.UserDefined).ToSection()
            .AddParagraph("Ronaldinho").SetListNumbered(numType, 1).AddInlineImage(imagePath, 20, 20, ScalingMode.UserDefined).ToDocument()
        .Build("Result.pdf");}

The result will be like this:


text:
Q: Single query categories and subcategories internal relationship Having a design table like this one:
create table tbl_categories (
category_id int auto_increment,
parent_category_id int, -- internal foreign key
category_name varchar(255)
);

Let's add some records:
insert into tbl_categories (parent_category_id, category_name) values (null,'category 1'),(1, 'sub category 1'),(2, 'sub sub category 1'),(1, 'sub category 2'),(1, 'sub category 3');

How could I select to return as this:
category 1
category 1 >> sub category 1
category 1 >> sub category 1 >> sub sub category 1
category 1 >> sub category 2
category 1 >> sub category 3

just wondering if it there is any pattern to archive this on a single query.
Thank you.


text:
Q: Play framework 2 Java, return chunked response Based on the following code example that returns chunked data from Play server,
the out.write shouldn't create response each time it is called?
when using post client I get only 1 response which contains that wholl data with all the data.
I need to return a huge file from the server in chunks which should be downloaded in the client.
Any ideas?
public static Result index(){
// Prepare a chunked text stream
Chunks<String> chunks = new StringChunks()
{
    // Called when the stream is ready
    public void onReady(Chunks.Out<String> out)
    {
        out.write("kiki");
        out.write("foo");
        out.write("bar");
        out.close();
     }
 };// Serves this stream with 200 OK
return ok(chunks);
}

A: The amount of chunks depends on the chunk size, which usually defaults to 1024 KB throughout the framework. Your output is too small and thus only one chunk is sent.


text:
Q: IE PNG transparency issue + TwinHelix I'm trying to implement the Twin Helix PNG transparency issue in IE6 but when I downloaded the zip file the htaccess file is empty. Does anyone know what should be inside the file in order to complete the fix?
Thanks in advance!

A: The .htaccess file is not empty for me. It says:
AddType text/x-component .htc


text:
Q: How to show that the linear operator $T$ is invertible? Let $T$ be a linear operator defined on a finite vector space $V$. Suppose that there exists a constant $\alpha>0$ so that $$\|Tv\|\ge \alpha\|v\|$$ for all non-zero vector $v\in V $. Show that T is invertible.

I have no idea about this proof. I try to rewrite this inequality:
$$
\|Tv\|^2=\langle Tv, Tv\rangle\ge \alpha^2\langle v, v\rangle
$$
Our goal is that show that $T^{-1}$ exists.

A: Since we are working in a finite-dimensional vector space $V$, $T$ being injective implies $T$ surjective, hence $T$ is bijective and invertible. So, we just need to show that $T$ is injective.
Let's suppose $T(v_{1}) = T(v_{2}).$ Then, we have $T(v_{1} - v_{2}) = 0,$ by linearity. So, we have
$$\alpha||v_{1} - v_{2}|| \leq ||T(v_{1} -v_{2})|| = 0.$$ Since $\alpha$ is strictly positive, we have $||v_{1} - v_{2}|| = 0,$ but this means $v_{1}- v_{2} = 0$, and so $T$ is injective.


text:
Q: Odd number proof
Prove that for every odd number $n$, it holds that $n^2+3$ is not not divisible
  by $8$.

My idea:
Let $n=2k+1$ for $k \in \mathbb{N}$, which implies
$$n^2+3=(2k+1)^2+3=4k^2+4k+1+3=4k^2+4k+4$$
How can I conclude that I cannot divide $4k^2+4k+4$ by $8$?

A: Because $k(k+1)$ is divisible by $2$ and $4$ is not divisible by $8$.

A: There's a much simpler proof using $n^2 \equiv 1 \mod 8$ for odd $n$, which is easy to prove exhaustively.

A: Just for fun, a slightly different approach:
If $n^2+3$ is divisible by $8$, then so is $(n-4)^2+3=n^2+3-8n+16$, hence, by induction, $8$ divides $n^2+3$ for at least one $n$ between $-2$ and $2$. But $0^2+3=3$, $(\pm1)^2+3=4$, and $(\pm2)^2+3=7$ are not divisible by $8$.


text:
Q: Refactoring Database with EntityFramework from code I'm in the process of adapting the MVCMusicStore shopping cart. I wish to refactor the database using EntityFramework - not via the Server Explorer.
In my models folder I created a new FooEntities model.
public class FooStoreEntities : DbContext
{
    public DbSet<Foo> Foos { get; set; }
    public DbSet<Category> Categories { get; set; }
    public DbSet<FooMaker> FooMakers { get; set; }
    public DbSet<Cart> Carts { get; set; }
    public DbSet<Order> Orders { get; set; }
    public DbSet<OrderDetail> OrderDetails { get; set; }
}

I've also created the extra models Foo, FooMaker and Category. The other models already existed in the MVCMusicStore example.
I created a SampleFooData class which inherits from DropCreateDatabaseIfModelChanges<FooStoreEntities> and overrides the seed method to seed the new tables.
I changed the Application_Start method in the Global.asax.cs to contain System.Data.Entity.Database.SetInitializer(new FooStore.Models.SampleFooData());
In the web.config file I have:
<connectionStrings>
    <add name="FooStoreEntities"
    connectionString="Data Source=|DataDirectory|FooStore.sdf"
    providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>

Where FooStore.sdf still contains all the old tables from the MVCMusicStore application.
When I execute the web app it hits the SetInitializer breakpoint however it does not seem to create the SampleFooData object and create the new tables in the database. What am I missing? Or is there something fundamental I don't understand?

A: It will only be created when you use your DB context: see Entity Framework Database.SetInitializer simply not working
You could put
var ctx = new FooStoreEntities();
ctx.Database.Initialize(true);

after where you set the initializer in Application_Start.


text:
Q: copying a lot of files from bucket to bucket I'm trying to write a process to copy large amount of files from one bucket to another.
I started with google-cloud-python plain, it crashed at ~3k files with some 503 errors, then I moved to batch mode (still with python libs) and crashed at ~10k files because operations where taking more than the fixed 30 seconds time out, and then when I tried to use blob.rewrite found is not implemented on batch mode at python library.
Now I'm thinking of use subprocess.run to call gsutil, but as the files are arbitrary in the sense they don't share a dir or mask. I'll have to run the command for each file, and this could be super slow. I'm currently reading the documentation and can't find a way pass a list to one gustil execution (like a json, cvs, etc).
Said that so, what would be the proper way of copying a lot of arbitrary files from one bucket to another?

A: For a large number of file, I recommend you to set up a file transfert between 1 bucket to the another one.
Programmatically, it will take you a lot of time (to code and to transfert), you have to handle the retries in case of fail, the multi thread transfert and all this boring stuff. The transfert service do it for you.


text:
Q: How to apply reverse ajax in my php page to reload my listed items? I want to use reverse ajax in my php page to reload updated data on server. Another issue is that i need only those data which are recently added or updated to database, how can i filter such data in reverse ajax.
Please help me to reverse ajax using jquery in context of my problem  with example.
Thank you in advance.

A: You should have a look at this thread:
How do I implement basic "Long Polling"?
I think there is no way to do reverse ajax without extra software on serverside.
If you don't want to use something like comet you have to check with ajax every 1 or 2 minutes for updates and this will have a big impact on your scalability.


text:
Q: Getting [object Object] again but doesn't seem to be model issue I am trying to figure out how to access the author.id for a model when using a for loop with swig/twig. All of the others print out just fine but the ap.author.id is the issue I have tried ap.author.id, ap.author.id.type and ap.author.id.ref just hoping it was like my issue before seen HERE but it seems it is not model related far as I can tell. Also when I console.log out aps it shows all the documents and the path that makes sense would be ap.author.id. I am out of ideas, what am I missing?
Loop:
{%  for ap in aps  %}

   {{ap.name}}
   {{ap.manufacturer}}
   {{ap.model}}
   {{ap.type}}
   {{ap.notes}}
   {{ap.author.id}}

{% endfor %}
Model:
var accessPointsSchema = new Schema({
  name: {type: String},
  type: {type: String},
  manufacturer: {type: String},
  model: {type: String},
  IPAdress: {type: String},
  MACAdress: {type: String},
  range: {type: Number()},
  bands: {type: String},
  channel: {type: Number},
  dateBought: {type: Date},
  PoE: {type: Boolean},
  assetNumber: {type: Number},
  warrantyExpiration: {type: Date},
  location: {type: String},
  notes: {type: String},
  author: {
      id: {
         type: mongoose.Schema.Types.ObjectId,
         ref: "User"
      },
      email: String
   }
});

A: When you console.log author.id you get back an object that will contain the ID needed but you need to access it by doing author._id otherwise you will get the [object Object] error because it is trying to output an object into a string spot.


text:
Q: Meteor.js - what is the most convenient way to update a user profile? I find that I use the user profile extensively.  I would like to be able to do something like:
Meteor.user().profile.some_setting = 'something';
Meteor.user().update();

What is the most convenient way to update a user's profile?

A: Meteor.user() is a document, not a cursor. It's actually an alias for Meteor.users.findOne(this.userId).
You can either do so via a method call (server), or directly on the client.
Method call way:
//server code
Meteor.methods({
  updateProfile : function(newProfile) {
    if(this.userId)
      Meteor.users.update(this.userId, {$set : { profile : newProfile }});
  }
});

And on the client:
Meteor.call('updateProfile', myNewProfile);

I advise to do so through a server method, since the code runs in a cleaner environment.
If you want to do it directly on the client:
Meteor.users.update(Meteor.userId(), {$set : {profile : myNewProfile}});

(Meteor.userId() is an alias for Meteor.user()._id)
More infos on the doc!


text:
Q: Does Paypal send an IPN message when payment is captured? We are using Paypal's Authorisation/Capture. When a user manually captures the payment (on the Paypal website), does Paypal send any notification?
We want our backend to recognise payments that have been captured and authorised versus payments that haven't been captured yet.
We would also like to be notified about payments that were rejected.
Please note we are not using the API.

A: OK, found out that there is no special variable for this, it is simply stored in the 'payment_status' in the IPN message from Paypal.
The statuses relevant to authorisation/capture are:

*

*Completed (when the payment is captured)

*Refunded (when the payment is refunded)

*Pending (after the user makes payment but before the payment is manually captured)


text:
Q: Ubuntu 21.10 freezes during boot when using nvidia drivers First time actually asking a question here, but I've dug through 20 or so threads on this forum and others and can't find anything.
Basically, the issue is that when I try to use my GPU on my laptop (an ACER Predator, the GPU is an RTX 3060 Mobile / Max-Q), it freezes on the startup screen (specifically the Predator logo above the Ubuntu logo, no spinning dots).
It does this when I use any proprietary driver, including all of these:
The Software & Updates window showing the Additional Drivers tab. It shows the device, "NVIDIA Corporation: GA106M GeForce RTX 3060 Mobile / Max-Q", and then the options for drivers below.
and installing nvidia-driver-460 from the command line. All of them freeze in the same place when booting.
Adding nomodeset in GRUB hasn't worked as a temporary or permanent solution, but booting with the other kernel option GRUB provides (5.13.0-23 instead of 5.12.0-25) does get me in when using the nvidia-driver-460-server driver. It's a bit buggy though, with missing animations in GNOME and some other issues. Also, I can't actually use the drivers- NVIDIA Prime is missing.
My current method of fixing the problem each time so I can try something else is by using GRUB to get into recovery mode and doing sudo apt remove --purge nvidia*, then rebooting. None of the ctrl+alt+f1 keys work when it freezes.
Let me know if you have anything else I can try, or need any more information. I've tried a lot of things, and some of them probably escape me right now. I also did have it working for a little bit, but when I restarted my computer it was broken again and I honestly forget what it was I did back then. Thank you!

A: I was having the same issue. I solved it by installing the liquorix kernel as indicated here: https://forums.developer.nvidia.com/t/mouse-freezes-geforce-rtx-3060-with-either-ubuntu-22-04-or-mint-21/227375/4
This is the website of the liquorix kernel: https://liquorix.net/

Liquorix is a distro kernel replacement built using the best configuration and kernel sources for desktop, multimedia, and gaming workloads.

This installation instructions for Ubuntu are:

*

*sudo add-apt-repository ppa:damentz/liquorix && sudo apt-get update

*sudo apt-get install linux-image-liquorix-amd64 linux-headers-liquorix-amd64
After installing the liquorix kernel, I installed the latest nvidia driver, which by the time of this writing was (nvidia-driver-520):

*

*sudo apt install nvidia-driver-520
Hope it helps.
Update:
There is one more thing I found to help in this issue. After executing the steps mentioned above, do the following:
Go to settings -> power and set the options this way:

Why?
It seems like the issue is related to the drivers or the power supply of the graphics card. After applying these settings it hasn't frozen.
This also happens on Windows, see: https://www.dell.com/community/Alienware-Desktops/Aurora-R12-keeps-freezing/td-p/8154258


text:
Q: Run PL/pgSQL script using java It is possible to run PL/pgSQL script using java? I'm creating postgres db from java code and need creating some functions on this db.
I know I can run any sql script using DriverManager like that:
Connection connection = DriverManager.getConnection(
              connectionToDbUrl,
              getDbUser(),
              getDbPassword());
Statement statement = connection.createStatement()
statement.execute("select * from table);

but it will not execute PL/pgSQL script. Any ideas?
EDIT: I mean PL/pgSQL
EDIT 2: I found bug thanks @a_horse_with_no_name solution.
I read script from file using BufferedReader and join all lines. Adding " \n" on end of each line solves problem.
try (BufferedReader br = new BufferedReader(new FileReader(resource.getFile())))
    {
    statement.execute(br.lines().collect(Collectors.joining(" \n")));
    }

A: This works for me:
Connection con = DriverManager.getConnection("jdbc:postgresql://localhost/postgres", "...", "******");

Statement stmt = con.createStatement();

String create =
  "create function the_answer() \n" +
  "returns integer as $$\n" +
  "begin \n" +
  "   return 42;\n" +
  "end;\n" +
  "$$\n" +
  "language plpgsql;";

// create the function
stmt.execute(create);

// use the function
ResultSet rs = stmt.executeQuery("select the_answer()");
rs.next();
System.out.println("The answer is: " + rs.getInt(1));

A: You should refer to PostgreSQL JDBC documentation for that:
https://www.postgresql.org/docs/7.4/static/jdbc-callproc.html
In case your pgSQL returns a value call it like that:
ResultSet rs = stmt.executeQuery("SELECT * FROM your_func()");

A: PL/pgSQL is a special case of calling a stored procedure (or function or package).
You must use CallableStatement adding de corresponding parameters. See this example.

A: I ran into this same issue, but I got to solve it in a slightly different way which I wish to share here for anyone else.
I found using the JDBC approach rather clumsy. I wanted to use an approach as close to using pgqsl from the terminal as possible.
Requirement 1: As a prerequisite to using this approach, you should be able to run pgsql command for the terminal already.
Requirement 2: The file .pgpass in a user's home directory or the file referenced by PGPASSFILE can contain passwords to be used if the connection requires a password (and no password has been specified otherwise). This file should contain lines of the following format:
hostname:port:database:username:password
So create a file .pgpass in your home directory (or wherever else you may feel like actually since you'll need to reference this location later anyway)
Requirement 3: .pgpass requires restricted access, otherwise you will get this error - .pgpass" has group or world access; permissions should be u=rw (0600) or less. To fix this, just chmod the file to at least 600 chmod 600 ~/.pgpass
Requirement 4: Add this piece of java code to execute your sql script. Substitute <username>, <hostname> and <database> with the values you used in the .pgpass file
System.setProperty("PGPASSFILE", "~/.pgpass");
Process process = Runtime.getRuntime().exec("psql -U <username> -h <hostname> -d <database> -f src/main/resources/schema.sql");
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
        }
        int ret = process.waitFor();
        System.out.printf("Program exited with code: %d%n", ret);

And that should do it for you!

A: Here is the explain about buid, install and use PL/JAVA for PostgreSql:
https://tada.github.io/pljava/
And here is an example 'hello world' about it:
https://tada.github.io/pljava/use/hello.html


text:
Q: Equivalent of ToString() on an enum type in C++/CLI In C# you can declare an enum and once you have set its value call ToString on the variable and get a string representation of the value of the enum.
How do you do this in C++/CLI using a managed enum?

A: Whilst the other answers are not incorrect, I found myself with the same problem. In my case, I had declared a standard C++ enum and forgot to use the CLI syntax (even though I had it been exposed in public properties without compiler warnings!).
The proper syntax for a C++/CLI enum is (Note the word 'class'):
public enum class SomeEnum {
    Value1,
    Value2
}

NB: You can also use 'struct' rather than 'class'.
You will also need to go back through your code and change any assignments (the compiler will happily show you the errors however) from this:
SomeEnum value = Value1;

to this:
SomeEnum value = SomeEnum::Value1;

You will now find that 'ToString()' works as you'd expect it to.

A: Isn't it the same syntax ?
MyEnum enumValue = MyEnum::Enum1;
Console::WriteLine(enumValue.ToString());

Look at this page of the book "Pro Visual C++/CLI and the .NET 3.5 Platform" in Google Books

"The ToString() method for enum prints out the enum name as a character string"

A: ToString() should return the name of the enum value. Furthermore, if you decorate the managed Enum with a [Flags] attribute, then eg Colour::Red | Colour::Blue will ToString() as "Red, Blue". (This is from memory from Marcus Heege's book "Expert Visual C++/CLI: .NET for Visual C++ Programmers", not tried it myself)

A: Your issue was likely resolved.
I thought someone else might find it useful:
NOT: The number of members can be up to 96. ( ENUM96.inl )
#include "ENUM96.inl"

//
// DirectShowDeviceType
// ENUM96 sample definition
//
ENUM96(DirectShowDeviceType, unsigned int,
    None = 0,
    Input = 1,    // Capture
    Output = 2,   // Renderer
    Video = 4,    // Video support
    Audio = 8     // Audio support
    );

int main(int argc, char* argv[])
{
    DirectShowDeviceType eDevType = DirectShowDeviceType::Input
        | DirectShowDeviceType::Video
        | DirectShowDeviceType::Audio;

    printf("[ENUM96 Test]\n\n");

    _tprintf(_T("> %-24s --> \"%s\" (%u)\n"), _T("ToString()")
        , eDevType.ToString()
        , eDevType.ToUInt32());

    printf("> %-24s --> %s\n", "HasFlag(Output)",
        eDevType.HasFlag(DirectShowDeviceType::Output)
        ? "true"
        : "false");

    printf("> %-24s --> %s\n", "HasFlag(Input)",
        eDevType.HasFlag(DirectShowDeviceType::Input)
        ? "true"
        : "false");

    printf("> %-24s --> %s\n", "HasFlag(Video)",
        eDevType.HasFlag(DirectShowDeviceType::Video)
        ? "true"
        : "false");

    printf("> %-24s --> %s\n", "HasFlag(Audio)",
        eDevType.HasFlag(DirectShowDeviceType::Audio)
        ? "true"
        : "false");

    printf("> %-24s --> %s\n", "HasFlag(Input | Audio)",
        eDevType.HasFlag(DirectShowDeviceType::Input | DirectShowDeviceType::Audio)
        ? "true"
        : "false");

    printf("> %-24s --> %s\n", "HasFlag(Input | Video)",
        eDevType.HasFlag(DirectShowDeviceType::Input | DirectShowDeviceType::Video)
        ? "true"
        : "false");

    printf("> %-24s --> %s\n", "HasFlag(Output | Video)",
        eDevType.HasFlag(DirectShowDeviceType::Output | DirectShowDeviceType::Video)
        ? "true"
        : "false");

    printf("> %-24s --> %s\n", "HasFlag(Video | Audio)",
        eDevType.HasFlag(DirectShowDeviceType::Video | DirectShowDeviceType::Audio)
        ? "true"
        : "false");

    printf("\n");
    printf("> // Remove 'Video' flag\n");
    eDevType &= ~DirectShowDeviceType::Video;

    _tprintf(_T("> %-24s --> \"%s\" (%u)\n"), _T("ToString()")
        , eDevType.ToString()
        , eDevType.ToUInt32());

    printf("> %-24s --> %s\n", "HasFlag(Video)",
        eDevType.HasFlag(DirectShowDeviceType::Video)
        ? "true"
        : "false");

    printf("> %-24s --> %s\n", "HasFlag(Video | Audio)",
        eDevType.HasFlag(DirectShowDeviceType::Video | DirectShowDeviceType::Audio)
        ? "true"
        : "false");

    printf("> %-24s --> %s\n", "HasFlag(Audio)",
        eDevType.HasFlag(DirectShowDeviceType::Audio)
        ? "true"
        : "false");

    printf("> %-24s --> %s\n", "HasFlag(Input)",
        eDevType.HasFlag(DirectShowDeviceType::Input)
        ? "true"
        : "false");

    printf("> %-24s --> %s\n", "HasFlag(Input | Audio)",
        eDevType.HasFlag(DirectShowDeviceType::Input | DirectShowDeviceType::Audio)
        ? "true"
        : "false");

    printf("\n");
    printf("> // List ENUM members\n");
    printf("> %-24s --> %u\n", "MemberCount",
        eDevType.GetMemberCount());
    for (int i = 0; i < eDevType.GetMemberCount(); i++) {
        DirectShowDeviceType eMember = eDevType.GetMember(i);
        _tprintf(_T("  [%u] %s\n"), eMember.ToUInt32(), eMember.ToString());
    }

    getchar();
    return 0;
}

The result will be as shown below.

    [ENUM96 Test]

    > ToString()               --> "Input | Video | Audio" (13)
    > HasFlag(Output)          --> false
    > HasFlag(Input)           --> true
    > HasFlag(Video)           --> true
    > HasFlag(Audio)           --> true
    > HasFlag(Input | Audio)   --> true
    > HasFlag(Input | Video)   --> true
    > HasFlag(Output | Video)  --> false
    > HasFlag(Video | Audio)   --> true

    > // Remove 'Video' flag
    > ToString()               --> "Input | Audio" (9)
    > HasFlag(Video)           --> false
    > HasFlag(Video | Audio)   --> false
    > HasFlag(Audio)           --> true
    > HasFlag(Input)           --> true
    > HasFlag(Input | Audio)   --> true

    > // List ENUM members
    > MemberCount              --> 5
      [0] None
      [1] Input
      [2] Output
      [4] Video
      [8] Audio


text:
Q: Android Studio Tab View gray theme color So I created tab view with fragments, everything went well, besides the whole layout color is dark gray (don't know why) and the tab line color is pink (also don't know why).
It looks like thisenter image description here
Also, as you can see, iz has that weird spacing between action bar and tab bar (also don't know why).
Here is my code:
Vjezbe.java
package hr.app.liftme.liftmehr;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

public class Vjezbe extends AppCompatActivity {
    Toolbar toolbar;
    TabLayout tabLayout;
    ViewPager viewPager;
    ViewPagerAdapter viewPagerAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_vjezbe);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        toolbar = (Toolbar)findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        tabLayout = (TabLayout)findViewById(R.id.tabLayout);
        viewPager = (ViewPager)findViewById(R.id.viewPager);
        viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
        viewPagerAdapter.addFragments(new HomeFragment(), "Prsa");
        viewPagerAdapter.addFragments(new TopFreeFragment(), "Leđa");
        viewPagerAdapter.addFragments(new TopPaidFragment(), "Ramena");

        viewPagerAdapter.addFragments(new TrapeziFragment(), "Trapezi");
        viewPager.setAdapter(viewPagerAdapter);
        tabLayout.setupWithViewPager(viewPager);
    }

}

activity_vjezbe.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="hr.app.liftme.liftmehr.Vjezbe">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_vjezbe" />

</android.support.design.widget.CoordinatorLayout>

styles.xml
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

So if anyone can walk me through my errors I would really appreciate that!
Thank you!

A:
besides the whole layout color is dark gray (don't know why) and the tab line color is pink (also don't know why).

Try changing your primary and accent colors in res/values/colors.xml like:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#3F51B5</color> <!-- Tab color -->
    <color name="colorPrimaryDark">#303F9F</color> <!-- Status bar color -->
    <color name="colorAccent">#FF4081</color> <!-- Tab indicator color -->
</resources>

Also, as you can see, iz has that weird spacing between action bar and tab bar (also don't know why).

I don't know what ViewPagerAdapter is, but you should be using something like FragmentPagerAdapter or FragmentStatePagerAdapter like this:
public class MyFragmentPagerAdapter extends FragmentPagerAdapter {

    public StorePagerAdapter(FragmentManager manager, String[] titles) {
        super(manager);
        mTitles = titles;
    }

    private String[] mTitles;

    @Override
    public Fragment getItem(int position) {
        if (position == 0) {
            return new HomeFragment();
        } else if (position == 1) {
            return new TopFreeFragment();
        } else if (position == 2) {
            return new TopPaidFragment();
        } else if (position == 3) {
            return new TrapeziFragment();
        }
        return null;
    }

    @Override
    public int getCount() {
        return mTitles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}

and this in your activity's onCreate:
.
.
String[] titles = new String[] {"Prsa", "Leđa", "Ramena", "Trapezi"};
MyFragmentPagerAdapter myFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), titles);
.
.


text:
Q: Run command for Adobe Flash settings Is there a run command that brings up the Adobe Flash settings in the Control Panel?
Run commands such as WinKey+R and typing cmd, msconfig, control, etc. but to bring up the flash player settings.

A: Try running FlashPlayerCPLApp.cpl


text:
Q: Is there any way to customize an iOS keyboard to only show the microphone button? I've been ask if it is possible to create a custom iOS keyboard with nothing in it but the microphone button (lower left on the standard text keyboard) and still get the microphone functionality. Mainly this would be for a voice only entry (the resulting text would be processed elsewhere).
Yes, it's an oddball question...


text:
Q: How can I replace"span3" to "col3" without changing the "span"?

to

How can I replace span* to col* without changing the span?
Edit 1:
My question here is how to convert span3 to col3 without changing span, cause I don't know \1 or $1 when I was a newbie to regular expression. The solution for me at that time was to replace span to col, which will affect span, too.

A: Just do a simple find and replace.  Capture the number of the CSS class in parentheses, and then replace using this capture group.
Find:    class="span(\d)"
Replace: class="col\1"

A: You need to add an Id attribute to your span tag. For example:

Next, using JavaScript or similar (the example I include is JavaScript) you can replace with these two lines:
var elem = document.getElementById("myspan");
elem.setAttribute('class',"col3");

A: If you are using JQuery, use method switchClass().
$("span.span3").switchClass('span3', 'col3');


text:
Q: Mac mini stops blinking in standby I'm on Macmini6,2 with current firmware and 10.8.4. When I send it to sleep it starts its on and off fading status LED thing to indicate it is now asleep.
When I come back a few hours later, it is dark, but the computer is still asleep and enters wake mode when I touch any key.
What's wrong there? Isn't the indicator LED supposed to blink all the time?

A: I am not sure if it is only with the most recent model, but apparently by default it is set to go into deep sleep after a few hours, and this turns the power light off entirely.
This thread on AVForums provides a command that should disable deep sleep, if that is what you want.
pmset -g
sudo pmset -a autopoweroff 0

After entering this it will prompt you for your password.


text:
Q: How get code coverage on java production code with clojure unit tests? I got Java production code and unit tests written in Clojure. Is there a way of measuring the code coverage?
Is there an eclipse plugin for this? I use eclEmma for my Java unit tests, is there an similar one for tests written in Clojure?

A: I heard about this project in a ClojureWest talk, though have not used it my self. perhaps it would be worth looking into for this:
https://github.com/dgrnbrg/guzheng
"guzheng is a library for doing branch coverage analysis of clojure code."

it seems to have a lein plugin to make running it a bit smoother.


text:
Q: How can I rotate a coordinate around a circle? I need to rotate an object in a circle around a central point. All I know is the rotation of the centre point in degrees, the centre point location (Which will always be 0,0), and the object location (Well actually the object distance to the centre, but because the centre is 0,0 it is the same thing).
Why I want to do this is because I have a ship in the world and I can check for collisions for it, however when checking for if the CannonBall is colliding with the ship I cannot rotate the ship, meaning that to check for collisions I must instead rotate the CannonBall around the ship depending on the ship's rotation.
(As you can see on my trailer (https://www.youtube.com/watch?v=2YU7oEUnwlw), I already attempted to implement this however have been unable to do it. Also I uploaded that video april 30, which means I have actually been having the issue for over a month.)

A: If your central point is $(c_x,c_y)$ and you want to rotate counter-clockwise about this point by an angle of $\theta$ (in radians) you would shift the center to the origin (and the rest of the points of the plane with it), then rotate, then shift back.  You can use:
$x_{\text{rot}}=\cos(\theta)\cdot(x-c_x)-\sin(\theta)\cdot(y-c_y)+c_x$
$y_{\text{rot}}=\sin(\theta)\cdot(x-c_x)+\cos(\theta)\cdot(y-c_y)+c_y$
$(x,y)$ are your initial coordinates and $(x_\text{rot},y_{\text{rot}})$ are the new coordinates after rotation by $\theta$ about $(c_x,c_y)$
Example: If you want to rotate the point $(3,0)$ by $90^{\circ}$=$\frac{\pi}{2}$ radians about the point $(3,2)$ the formula should give $(5,2)$.  Computing to check:
$x_{\text{rot}}=\cos(\frac{\pi}{2})\cdot(3-3)-\sin(\frac{\pi}{2})\cdot(0-2)+3=5$
$y_{\text{rot}}=\sin(\frac{\pi}{2})\cdot(3-3)+\cos(\frac{\pi}{2})\cdot(0-2)+2=2$


text:
Q: reading whatsapp messages I want to create an android app which reads inbox as well as whatsapp messages. I want to make a backup kind of thing. Though there is option for doing so in whatsapp. But I want to read the messages and then back them up from my app. I got to know that whatsapp stores messages in encrypted format in the file system. So can anyone please tell me how to read that encrypted file.

A: WhatsApp makes a chat backup everyday at 4 AM on your SD Card. This is a single database encrypted with an AES key. Since it is on the external storage, your app can read it if you have access to the external storage.
You can easily decrypt this database (there is a paper available on this online).
However, this will only give you updated chats once every 24 hours.
If you want more realtime updates, your device has to be rooted, and you will need a completely new parser, as on the internal storage the chats are stored in more than one database.

A: *

*check out what is the decryption key of whatsapp ( you have to decompile it)

*read that file content

*decrypt the content with decryption key

Remark, with rooted phone you can have everywhere access, others maybe need JNI to do some tricks
upvote, if helps ! :)

A: use Whatsapp Xtract 2.0 tool to decrypt the whatsapp databases and convert it to HTML.
Link for download & discussion on xda forum


text:
Q: Magento2 the custom block class had extended abstract product but to get product that was null,please help me the code of My custom module block class
<?php
namespace  Customization\Design\Block;
use Magento\Catalog\Block\Product\AbstractProduct;

class  Design extends AbstractProduct {

    protected $_hash;

    protected $_cofig;

    /**
     * @var ProductRepositoryInterface
     */
    public function __construct(
            \Magento\Catalog\Block\Product\Context $context,
             array $data = []
    ){

        parent::__construct(
                $context,
                $data
        );
    }
}

The phtml file  code
<?php $buttonTitle = __('Add to Cart'); ?>
<?php $_product = $block->getProduct(); var_dump($_product);?>

print:NULL;

A: For ex. You have custom block

app/code/Vendor/Module/Block/Index/Index.php

namespace Vendor\Module\Block\Index;

class Index extends \Magento\Catalog\Block\Product\AbstractProduct
{

}

Then simple you can get AbstractProduct methods by this way in block or phtml file

app/code/Vendor/Module/view/frontend/templates/index/index.phtml

<?php echo $this->getAddToCompareUrl(); // AbstractProduct Method ?>


text:
Q: Derive state space model I'm trying to derive the state space model for the following system
$$ L \ddot{\theta} - g \sin(\theta) - \ddot{z} \sin(\theta) = 0 $$
I am allowed to use that $\sin(\theta) \approx \theta$. And I must set $x_1 = \theta$, $x_2 = \dot{\theta}$, input $u = \ddot{z}$, output $y = \theta$.
This is what I have come up with:
$$\begin{aligned}
\dot{x} &= \begin{bmatrix}
   \dot{x}_1 \\
   \dot{x}_2
  \end{bmatrix} =
  Ax + Bu =
  \begin{bmatrix}
   0 & 1 \\
   \frac{g}{L} & 0
  \end{bmatrix}
  x
  + \begin{bmatrix}
   0 \\
   \frac{\theta}{L}
  \end{bmatrix} u\\
  y &= Cx + Du = \begin{bmatrix} 1 & 0 \end{bmatrix}x
\end{aligned}$$
But I can't have the $\theta$ in $B$, since that is equal to $x_1 = y = \theta$, right? How should I solve it?
Thanks in advance!

A: This is a nonlinear model, even if you linearize $\sin\theta$ to $\theta$. If you want to linearize it further you would also have to assume that $\theta$ stays close to one value and use that value to define $B$. But if you want to solve this differential equation you could use separation of variables,
$$
\int\!\!\!\int \frac{1}{\sin\theta} d\theta\,d\theta = \int\!\!\!\int \frac{g + u(t)}{L}dt\,dt,
$$
but the left hand side does not yield a nice solution.


text:
Q: I try to save many lines in a txt file using isolated storage in WP7 but it will only saves one, how do I save many? I use this to save the score everytime the game is over
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
isf.CreateDirectory("Data");
StreamWriter sw = new StreamWriter(new IsolatedStorageFileStream("Data\\scoretest.txt", FileMode.Create, isf));
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "                                   Score: " + punc);
sw.Close();

and to read from the txt I use a for that stops when the reading is null
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
StreamReader sr = null;
try
{
    sr = new StreamReader(new IsolatedStorageFileStream(@"Data\scoretest.txt", FileMode.Open, isf));
    for (;;)
    {
        string x = sr.ReadLine();
        if (x == null)
           break;
        else
            listBox1.Items.Add(x);
    }
    sr.Close();
}
catch
{
    listBox1.Items.Add("");
}

It only charges the last line, Why it doesn't read more than one line?

A: FileMode.Create will overwrite the file every time. You should use FileMode.OpenOrCreate or FileMode.Append instead(ref: http://msdn.microsoft.com/en-us/library/system.io.filemode.aspx)
Also, take a look at the Isolated Storage Explorer tool to verify your file: http://msdn.microsoft.com/en-us/library/hh286408(v=VS.92).aspx


text:
Q: Why does Maeve do this in the last episode of Westworld? In the last episode of Westworld,

 Maeve goes into a train which is going to leave the complex. She had a hard time going there, but on the last minute, she changes her mind and leaves the train to reenter the park and take part in the revolution.

So..

 Why does she leave the train ? Was it a "robotic command" send to all robots, and thus, she could not resist ? Or was is her free-mind ? The memory (false) of her daughter ? Something else ?

A: Maeve reaches the train at the end of the first season after her long scheme to escape from Westworld. It is implied that in the process, she gains actual sentience, and her plan to get out is her own making.
However, earlier in the same episode, we learn that it's not her plan at all. Someone programmed her with it using Arnold's credentials – presumably Ford. Her long and seemingly free-willed escape was apparently nothing but a predetermined cog in Ford's plan. From this IGN interview, Jonathan Nolan says:

IGN: Of course, the reveal about Ford leads us down other paths and questions. Should we assume he is behind re-programming Maeve?
  Nolan: That's the strong implication of her storyline, is that it has been a feature of his overall plan here. Bernard has shown us -- and I'm sure all the lovely people over at Reddit have transcribed -- the programming of her plan.

(He also later says that we shouldn't assume it's Ford's doing, but that it's heavily implied.)
So the question (which you're not the first to ask) is: Was it Ford's plan that Maeve should reach the train and stir up some chaos along the way, but ultimately turn back and not leave the park after all? Is she controlled by her programming the whole way?
Or was Ford's plan that she should actually depart on the train into the real world? If so, her deciding to abort this plan and get out of the train to (presumably) find her daughter is her own free will actually taking over.
As it turns out, we have a "Word of God" from Jonathan Nolan on the matter. Also from Nolan in the IGN interview:

And the next step of her plan is not what she does at the end of the finale. What we're seeing there is both the kind of gut-wrenching realization that so much of the journey we've been on with her has been facilitated by Ford, who has apparently re-programmed her storyline toward a different narrative and also facilitated the overall security system cutting her a little a slack and letting her slide by. He has total control over this place, he's so absolute. We want to believe that what's happening here is free will and that belief is challenged. For me, that last moment with Maeve where she decides to get back off the train... We changed our approach in terms of shooting it. Everything that's taken her onto the train throughout the entire season has been steady cam or studio mode, and when she makes that decision and we pull her back on the train and for the first time and for the first time in the series, we're seeing handheld photography, which begins to suggest that we're entering a new phase with them. We just want to underline that visually a little bit.

So: Leaving the train to go back into Westworld was her own decision. In this Vulture interview it's stated a bit more definitively:

In the finale, when Maeve gets onto that train … the Steadicam is leading her over. Now, it's just keeping pace with her as she makes the decision. What we understand in the moment is it's the first real decision she's made all season. Which is, she's not going to fulfill the script she's been given, which is to take this train wherever it's going, and do whatever else she's programmed to do. She can get off the train. At which point, we shift to handheld camera, which we'd held back on throughout the entire season until one moment with her, and one moment with Dolores, when Teddy comes to rescue her. We get Maeve off the train with a handheld camera. And I remember watching the dailies and almost being shocked at how effective a cinematic technique can be if you hold off on it for long enough. If you dial it in at just the right moment, that suggests she's literally like a train coming off the tracks. We're no longer in programmatic or prescribed behaviors. She's improvising, and we're right there with her.


text:
Q: How do I check the answer to polynomial long division in $\mathbb{Z}_7$? The question that I was given on my homework was to find $q(x)$ and $r(x)$ that satisfy:
$f(x)=g(x)q(x)+r(x)$ in $\mathbb{Z}_7$ where $f(x)=x^6 +3x^5 +4x^2 -3x +2$ and $g(x)= 3x^2 +2x-3$. I think that I did everything correctly. However, my question is about checking my answer.
If I plug $g(x)q(x)+r(x)$ in WolframAlpha and then reduce the coefficients mod $7$ after will I necessarily get $f(x)$ if I did my math correctly?


text:
Q: Android add items to list I want to add some json items to my listview. How can I add the items in the java file?
json example:
{"responseData": {"media":[{
                              "freshness":"1",
                              "critic":"Roger Moore",
                              "quote":"Adequate",
                              "publication":"McClatchy-Tribune News Service",
                              "date":"2013-01-08"
                            },
                            {
                               "freshness":"1",
                               "critic":"Laremy Legel",
                               "quote":"You won't be upset you saw it, you'll have some fun, you'll see Wolvie beat the living hell out of a helicopter.",
                               "publication":"Film.com","date":"2010-07-07"
                             },
                             {
                               "freshness":"1",
                               "critic":"Sara Vilkomerson",
                               "quote":"Did the plot points stick in my head five minutes after leaving the theater? Not so much ... but I know I was having fun while watching.",
                               "publication":"New York Observer",
                               "date":"2009-05-06"
                              }
}]}}

java
  String url = "http://site.com/";

    aq.ajax(url, JSONObject.class, new AjaxCallback<JSONObject>() {

            @Override
            public void callback(String url, JSONObject json, AjaxStatus status) {

                    if(json != null){

                        JSONArray ja = json.optJSONObject("responseData").optJSONArray("media");

                        try {

                            String test = null;

                            for(int i = 0 ; i < ja.length(); i++){

                                JSONObject jo = ja.optJSONObject(i);

                                 test = jo.getString("critic");

                                 Toast.makeText(aq.getContext(), test, Toast.LENGTH_LONG).show();

                                 //add items to list//

                            }

                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }//end try

                    }//end if null
            }//end callback
    });

list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>

<ListView
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="#FF800000"
  >

</ListView>

list_body.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>

<TextView
android:id="@+id/freshness"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textStyle="bold"/>

<TextView
android:id="@+id/critic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textStyle="bold"/>

<TextView
android:id="@+id/quote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textStyle="bold"/>

<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textStyle="bold"/>

</LinearLayout>

I want to add some json items to my listview. How can I add the items in the java file?

A: I suggest you that:
You need a Adapter which extends BaseAdapter or ArrayAdapter

*

*Parse data from JSON String

*Add to Adapter

How to parse data?
With your JSON String:

*

*You must parse an Object which had name: "responseData"
JSONObject mResponseDataObject = new JSONObject(yourJSONString);

*Parse JSONArray "media"
JSONArray mMediaArray = mResponseDataObject.getJSONArray(JSON_MEDIA_KEY); // JSON_MEDIA_KEY = "media"
In each item in mMediaArray -> You should parse to an Object
class Media {
    private int freshness;
    private String critic;
    private String quote;
    private String publication;
    private Date date;

    // Constructors, Getters & Setters
}

You must parse by this way:
ArrayList<Media> mMedias = new ArrayList<Media>();

for (int i = 0; i < mMeidaArray.length(); i++) {
    JSONObject mMediaObject = mMediaArray.getJSONObject(i);
    int freshness = mMediaObject.getInt(MEDIA_FRESHNESS); // MEDIA_FRESHNESS = "freshness";
    //....
    mMedias.add(new Media(freshness, critic, quote, publication, date));
}

After tha you will create new instance which instance of Adapter.
MyAdapter mAdapter = new MyAdapter(getApplicationContext(), mMedias);
yourListView.setAdapter(mAdapter);

Example:
public class MyAdapter extends ArrayAdapter<Media> {
  private final Context context;
  private ArrayList<Media> mMedias;

  public MySimpleArrayAdapter(Context context, ArrayList<Media> aMedias) {
    super(context, R.layout.rowlayout, values);
    this.context = context;
    this.mMedias = aMedias;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rowView = inflater.inflate(R.layout.list, parent, false);

    TextView textView = (TextView) rowView.findViewById(R.id.critic);
    textView.setText(mMedias.get(position).getCritic());
    // ….
    return rowView;
  }
}


text:
Q: Вывод массива в ListBox Как сделать так, чтобы значения Items у ListBox заполнялись из массива?

A: Можно воспользоваться методом AddRange, как пример:
string [] myArr = new string[4];

myArr[0] = "One";
myArr[1] = "Two";
myArr[2] = "Three";
myArr[3] = "Four";

myListBox.Items.AddRange(myArr);

Так вот сразу можно заполнить, если надо (сразу в листе):
myListBox.Items.AddRange(new object[]{"One", "Two", "Three", "Four", "Five", "Six"});

Если не получится, то перебрать массив через цикл и добавить в лист:
string [] myArr = new string[4];

myArr[0] = "One";
myArr[1] = "Two";
myArr[2] = "Three";
myArr[3] = "Four";

myListBox.Items.Clear();

for (int i = 0; i < myArr.Length; i++) {
    myListBox.Items.Add(myArr[i].ToString());
}

A: Используйте свойство ListBox.DataSource для отображения элементов, и BindingList<T> вместо массива, если хотите чтобы изменения отображались в ListBox без дополнительного шаманства.
var source = new BindingList<string>()
{
    "One",
    "Two",
    "Three",
    "Four"
}
listBox1.DataSource = source;

Теперь любые строки добавленные в source будут добавлены и в ListBox. Если в массив состоит из составных объектов или структур, можно указать значение какого свойства должно быть выведено с помощью свойства ListBox.DisplayMember.
Можно конечно и так:
var source = new string []
{
    "One",
    "Two",
    "Three",
    "Four"
}
listBox1.DataSource = source;

Только в этом случае для отображения изменений придется делать что-то такое:
listBox1.DataSource = null;
listBox1.Items.Clear();
source[0] = "NewValue";
listBox1.DataSource = source;

Или как предложили ранее, в режиме ручного редактирования содержимого.


text:
Q: Azure RunCommand exit with -1 I am deploying a RunCommand to an azure vm (ubuntu) using ARM (bicep).
I can see my script never completes, and this is the output from the log that the waaagent keeps:
sudo cat /var/log/azure/run-command-handler/handler.log

Writing a placeholder status file indicating progress before forking: /devopsDeploymentAgent.0.status
+ nohup /var/lib/waagent/Microsoft.CPlat.Core.RunCommandHandlerLinux-1.3.2/bin/run-command-handler enable
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event=start
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event=pre-check
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="comparing seqnum" path=devopsDeploymentAgent.mrseq
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="seqnum saved" path=devopsDeploymentAgent.mrseq
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="reading configuration from /var/lib/waagent/Microsoft.CPlat.Core.
RunCommandHandlerLinux-1.3.2/config/devopsDeploymentAgent.0.settings"
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="read configuration"
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="validating json schema"
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="json schema valid"
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="parsing configuration json"
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="parsed configuration json"
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="validating configuration logically"
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="validated configuration"
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="creating output directory" path=/var/lib/waagent/run-command-hand
ler/download/devopsDeploymentAgent/0
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="created output directory"
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 scriptUri=
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="executing command" output=/var/lib/waagent/run-command-handler/do
wnload/devopsDeploymentAgent/0
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="prepare command" scriptFile=/var/lib/waagent/run-command-handler/
download/devopsDeploymentAgent/0/script.sh
time=2023-01-09T16:12:47Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 message="Execute with TimeoutInSeconds=600"
time=2023-01-09T16:12:48Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 message="Timeout:signal: killed"
time=2023-01-09T16:12:48Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="failed to execute command" error="command terminated with exit st
atus=-1" output=/var/lib/waagent/run-command-handler/download/devopsDeploymentAgent/0
time=2023-01-09T16:12:48Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="enable script failed"
time=2023-01-09T16:12:48Z version=v1.3.2/git@6efb77e-clean operation=enable extensionName=devopsDeploymentAgent seq=0 event="failed to handle" error="failed to execute command: command termi
nated with exit status=-1"

As you can see it looks like it exits with a -1 "Timeout:signal: killed". However the timeout for this runcommand (as also seen from the logs) is 5 minutes and it starts at 2023-01-09T16:12:47Z and terminates with this exit code at 2023-01-09T16:12:48 which is 1 second.
I have included the script.sh and the stdout and stderr below.
The script itself does this:-

*

*parses some arguments

*docker login to an azure container registry

*docker pull for an image

*checks to see if a named docker container is already running and if so stops it, removes it

*runs a new docker container based on the pulled image.

From the output that the script writes to stdout I can see that the script gets as far as successfully pulling the image, but then doesn't execute the next line after the docker pull - which is a simple echo statement. So it feels to me like something is actively killing the script - i.e waagent.
From stderr I can see that docker login writes a warning to say a credential helper should be configured, however this isn't causing the script to terminate as it proceeds to do the docker pull of the image, and there are no further errors or warnings written.
Here is the script.sh
#!/bin/bash
while getopts u:z:o:i:t:a:l:p: flag

do
    case "${flag}" in
          u) AZP_URL=${OPTARG};;
          z) AZP_TOKEN=${OPTARG};;
          o) AZP_POOL=${OPTARG};;
          i) AZP_AGENT_DOCKER_IMAGE=${OPTARG};;
          t) AZP_AGENT_DOCKER_IMAGE_TAG=${OPTARG};;
          a) AZP_AGENT_DOCKER_ACR_NAME=${OPTARG};;
          l) AZP_AGENT_DOCKER_ACR_USERNAME=${OPTARG};;
          p) AZP_AGENT_DOCKER_ACR_PASSWORD=${OPTARG};;
     esac
done
## start devops agent
## pull image
## The PAT must have Agent Pools (read, manage) scope (for a deployment group agent, the PAT must have Deployment group (read, manage) scope), and while a single PAT can be used for registering multiple agents, the PAT is used only at the time of registering the agent, and not for subsequent communication.
if [ -n "$AZP_URL" ]; then
echo "docker image is $AZP_AGENT_DOCKER_IMAGE"
echo "installing az agent"
AZP_AGENT_NAME=$(hostname)
echo $AZP_AGENT_DOCKER_ACR_PASSWORD| sudo docker login $AZP_AGENT_DOCKER_ACR_NAME.azurecr.io --username $AZP_AGENT_DOCKER_ACR_USERNAME --password-stdin
# az acr login --name $AZP_AGENT_DOCKER_ACR_NAME
imagePath="$AZP_AGENT_DOCKER_ACR_NAME.azurecr.io/$AZP_AGENT_DOCKER_IMAGE:$AZP_AGENT_DOCKER_IMAGE_TAG"
dockerPullOutput=$(sudo docker pull $imagePath)
echo "finished pulling image $imagePath output was: $dockerPullOutput"
containerName="devops-agent"
# name container and stop and remove any previous one to make this idempotent
if [ ! "$(sudo docker ps -a -q -f name=$containerName)" ]; then
    sudo docker stop $containerName
    sudo docker rm $containerName
fi

echo "running devops agent $AZP_URL $AZP_POOL $AZP_TOKEN $AZP_AGENT_NAME $imagePath"
sudo docker run -d --name $containerName --restart=always -e AZP_URL="$AZP_URL" -e AZP_POOL="$AZP_POOL" -e AZP_TOKEN="$AZP_TOKEN" -e AZP_AGENT_NAME="$AZP_AGENT_NAME" -v /var/run/docker.sock:/var/run/docker.sock $imagePath --once
else
echo "skipping install of devops agent as no devops url provided."
fi

and here is the complete stdout as you can see it only executes up to the docker pull based on this output:
sudo cat /var/lib/waagent/run-command-handler/download/devopsDeploymentAgent/0/stdout
docker image is devops/deployment-agent
installing az agent
Login Succeeded
0.1.0-alpha.14: Pulling from devops/deployment-agent
eaead16dc43b: Pulling fs layer
9e72ce0a20ef: Pulling fs layer
e3e8dc6cc33c: Pulling fs layer
b1da6338b120: Pulling fs layer
d746e1c7437c: Pulling fs layer
f9a8bd2a02f1: Pulling fs layer
264e044344ec: Pulling fs layer
2f8fea2b75d2: Pulling fs layer
ffbdacaca4cc: Pulling fs layer
3dd9baa15bcf: Pulling fs layer
891f9750edbc: Pulling fs layer
669c2f9dbfd8: Pulling fs layer
264e044344ec: Waiting
2f8fea2b75d2: Waiting
ffbdacaca4cc: Waiting
3dd9baa15bcf: Waiting
891f9750edbc: Waiting
669c2f9dbfd8: Waiting
b1da6338b120: Waiting
d746e1c7437c: Waiting
f9a8bd2a02f1: Waiting
e3e8dc6cc33c: Download complete
eaead16dc43b: Download complete
9e72ce0a20ef: Verifying Checksum
9e72ce0a20ef: Download complete
f9a8bd2a02f1: Verifying Checksum
f9a8bd2a02f1: Download complete
264e044344ec: Verifying Checksum
264e044344ec: Download complete
b1da6338b120: Verifying Checksum
b1da6338b120: Download complete
ffbdacaca4cc: Verifying Checksum
ffbdacaca4cc: Download complete
3dd9baa15bcf: Verifying Checksum
3dd9baa15bcf: Download complete
891f9750edbc: Verifying Checksum
891f9750edbc: Download complete
669c2f9dbfd8: Verifying Checksum
669c2f9dbfd8: Download complete
d746e1c7437c: Verifying Checksum
d746e1c7437c: Download complete
2f8fea2b75d2: Verifying Checksum
2f8fea2b75d2: Download complete
eaead16dc43b: Pull complete
9e72ce0a20ef: Pull complete
e3e8dc6cc33c: Pull complete
b1da6338b120: Pull complete
d746e1c7437c: Pull complete
f9a8bd2a02f1: Pull complete
264e044344ec: Pull complete
2f8fea2b75d2: Pull complete
ffbdacaca4cc: Pull complete
3dd9baa15bcf: Pull complete
891f9750edbc: Pull complete
669c2f9dbfd8: Pull complete
Digest: sha256:b2c4f630720565fab01993473d3838f5f20632b581d649ea16d7383dac11538d
Status: Downloaded newer image for labdocker.azurecr.io/devops/deployment-agent:0.1.0-alpha.14
labdocker.azurecr.io/devops/deployment-agent:0.1.0-alpha.14

and stderr:
sudo cat /var/lib/waagent/run-command-handler/download/devopsDeploymentAgent/0/stderr
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

This is not the first time I have seen a run command script seemingly exits for no reason - it happened with another where I was calling sudo gluster volume create commands. Also worth mentioning I am executing multiple separate run commands, one after the other as part of the same deployment. I am being very sure to only deploy one Run Command at a time as I wasn't sure the waagent could deal with concurrency.
For this example, here are the deployment activities shown in the portal - each activity (marked in red) corresponds to a bicep template file that depoys one or more run commands accross a cluster of vm's - one per vm. Each activity runs it's commands accross the seperate vm's, and finishes, before the next one starts. I can't see anything from the times of these activities or how its written that would mean multiple run commands are being executed on a single vm at the same time, so this looks ok to me.

Note: If I run the same exact deployment a second time, this time the script finishes. The difference is that the scripts, when run a second time, have already done lots of work the first time round, and in the case of this script it has already pulled the image, so this time round the pull completes very fast and it then hasn't terminated and successfully runs the docker container.
My question is, what is causing the script to terminate?


text:
Q: HTTPInternalServerError when accessing published Google Docs spreadsheet with Ruby We're on Rails 3.0.6, Ruby 1.8.7.
Code:
url = 'https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0Ala-Qy5xnYGFdE83bng2RC0yTVFVUDVfNW5NV2hwc1E&output=csv'
uri = URI.parse url
req = Net::HTTP::Get.new uri.path

http = Net::HTTP.new uri.host, uri.port
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.use_ssl = true
response = http.request req
puts response

Output:
#<Net::HTTPInternalServerError:0xc80edb8>
<!DOCTYPE html>

         <meta name="description" content="Web word processing, presentations and spreadsheets" />
         <link rel="shortcut icon" href="//www.google.com/images/icons/product/spreadsheets-16.png" />
         <title>Google Docs Error</title>

Google Docs has encountered a server error. If reloading the page doesn't help, please contact us.

We're sorry, a server error occurred. Please wait a bit and try reloading your spreadsheet.

                             To discuss this or other issues, visit the Google Docs Help forum. To see the list of known problems, check the Google Docs Known Issues page.

Sorry, and thanks for your help!

                             - The Google Docs Team

The response suggests it's a Google server error, but we can't imagine it's choking on such a routine call.
The spreadsheet is published and thus accessible to anyone with the link.
Are we doing something wrong?

A: Give this a try
require 'net/https'
url = 'https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0Ala-Qy5xnYGFdE83bng2RC0yTVFVUDVfNW5NV2hwc1E&output=csv'
uri = URI.parse url

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(uri.request_uri)

response = http.request(request)
puts response.body


text:
Q: ActivityGroup inside TabHost does not show content after first run I have issue with ActivityGroup. My app has 4 tabs, 2 of which has ActivityGroup and 2 more simple activity. The problem is that after first run of app content is shown properly, and when leave app through back button and return, tabs with activity group dont shown any content, including menus. While tabs with simple activity work properly.
D'you have any ideas?

Ok, some sort of code)
Setting this tab:
private TabSpec getFrontPageTab() {

        Intent intent = new Intent(context, ActivityGroupHome.class);
        return tabHost
                .newTabSpec("home")
                .setIndicator(
                        getTabView(R.drawable.tabbar_home, "str_home"))
                .setContent(intent);

    }

ActivityGroupHome:
public class ActivityGroupHome extends ActivityGroupBase {

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    ActivityUtils activityUtils = ActivityUtils.getInstance(this);

    activityUtils.addActivityGroup("Home", this);
    activityUtils.startHomeActivity("Home");

}

}

Methods from ActivityUtils:
public void startHomeActivity(String activityGroupName) {

    if (activityGroupName != null) {

        startHomeActivityForActivityGroup(activityGroupName);

    } else {

        Intent intent = new Intent(context, AsyncMainActivity.class);
        // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(intent);

    }

}

private void startHomeActivityForActivityGroup(String activityGroupName) {

    ActivityGroupListItem activityGroupItem = activityGroups
            .findGroupByName(activityGroupName);

    if (activityGroupItem != null) {

        Intent intent = new Intent(activityGroupItem.activityGroup,
                AsyncMainActivity.class);

        intent.putExtra(ACTIVITY_GROUP_NAME, activityGroupItem.name);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        View view = activityGroupItem.activityGroup
                .getLocalActivityManager().startActivity("Home", intent)
                .getDecorView();
        activityGroupItem.activityGroup.setContentView(view);
        activityGroupItem.stack.add("Home");

    }

}


text:
Q: AutoBoxing/Unboxing not working on return types ? Look at the below code
public class Parent {
    public Object doSomething() {
        return null;
    }
}

class Child extends Parent {
    public Integer doSomething() {
        return 0;
    }
}

Which is perfect under covariance and compiles fine.
Where as
public class Parent {
    public Integer doSomething() {
        return null;
    }
}

class Child extends Parent {
    public int doSomething() {
        return 0;
    }
}

Not compiling. But it can easily transform itself under autoboxing and unboxing right  ?

A: In your first case that code compiles because java supports Covariance which means,
If Cat is Subtype of Animal, then an expression of type Cat can be used whenever an expression of type Animal could.
According to that the first case is fine.
Coming to the second case,
Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes. For example, converting an int to an Integer, a double to a Double, and so on.
It's a direct relation between a wrapper and it's primitive, which doesn't mean that int is SubClass of Integer
int ---> Integer  //conversion, not subtype


text:
Q: Find the safest of the two vehicles There is vehicle A with 4 engines which can operate safely with at least 3 engines, then there is vehicle B which has 2 engines and can operate safely with at least 1 engine. The engine failure probability is p and the engine failures are independent. Which of the two vehicles is safer?
I solved in this way:
Vehicle B fails when all the engines stop working and the probability is:
$P(0E) = p^{2}  $
Vehicle A fails when only 0, 1 or 2 engines are working so:
$P(0E \cup 1E \cup 2E) = P(0E) + P(1E) + P(2E) = p^4 + p^3(1-p) + p^2(1-p)^2$
Is my solving method right?

A: I see a problem in this solving method. If we call the engines of Vehicle A: $a,b,c,d$. The probability of an engine failing is the probability of any of them failing while the others don't fail:
$$P(1E) = \\P(Fa)P(1-Fb)P(1-Fc)P(1-Fd) +\\ P(Fb)P(1-Fa)P(1-Fc)P(1-Fd) +\\ P(Fc)P(1-Fa)P(1-Fb)P(1-Fd) +\\ P(Fd)P(1-Fa)P(1-Fb)P(1-Fc)\\ = 4p(1-p)^3$$
Therefore, we have to keep in mind the different permutations to compute the total probability. We have to multiply each of those monomials by $4 \choose i$. The other expression will be correct only for the probability that an identified engine fail. In this question, the same concept is explained.
In this case, there are 4 ways in which only one engine can fail, and there are 6 ways in which two engines can fail. There is only one way in which no engine can fail:
$$P(0E \cup 1E \cup 2E) = p^4 + 4p^3(1-p) + 6p^2(1-p)^2$$
Note that this makes perfect sense if you use the binomial theorem:
$$P(0E \cup 1E \cup 2E \cup 3E \cup 4E) = \\ p^4 + 4p^3(1-p) + 6p^2(1-p)^2 + 4p(1-p)^3 + (1-p)^4 =\\ \sum_{i=0}^4 {4 \choose i} p^i(1-p)^{4-i} =  (p+(1-p))^2 = 1$$


text:
Q: How to automatically update Windows definitions of daylight saving times in various countries without doing Windows update We have a Windows server application that has to be aware of daylight saving times (DST) in various countries.
(Note: This is not a question about setting the correct daylight saving time for the computer itself)
In order to be up to date, Windows updates sometimes also include updates to the DST meta definitions.
This is important if for instance a country suddenly decides to change the rule when DST will start from  first Sunday of April to second Sunday of April.
However, as this is a production server, automatic windows update is disabled.
Microsoft issues from time to time patches with such changes, that can be applied without Windows-Update. For each of this patches however, a new Microsoft KB is created, with its own proprietary URI, which makes automatic updates impossible.
Question: How can we schedule a task, which periodically downloads and applies all patches

A: Can you update Windows automatically without running Windows Update, or selectively tell Windows to only update time zone data?  NO - sorry, there is no mechanism for that.
You could manually watch the RSS feed for the Microsoft Daylight Saving Time & Time Zone Blog and apply updates yourself, but there is no programmatic way to do that.
Since you mentioned in comments that your application is .NET and you can modify it, I'll provide another option for you.  (Incidentally, without this aspect of the problem, your question would be off-topic for StackOverflow).
The usual way to deal with time zones in a .NET application is with the TimeZoneInfo class, which relies on Windows to have current time zone data.  However, there is another option, you could write your application to use the IANA time zone database instead of the Windows time zone data.  The differences between these two data sources are covered in the timezone tag wiki under the "Time Zne Databases" section.
In .NET, by far the best way to work with the IANA database is through the Noda Time library.  I encourage you to read through the user guide to understand how to use this library in your application.
Assuming you've updated your application to use Noda Time instead of TimeZoneInfo, you can now follow the directions here on how to keep it updated with the latest time zone data.  Essentially, you can ping a URL periodically (daily, weekly, etc.) to see if there is a newer version of the tzdb available in Noda Time's .NZD format.  You could easily write your app to download the new data file and install it.  Now you've removed the dependency on Windows time zone data, and thus no longer need to concern yourself with Windows Updates or time zone hotfixes.


text:
Q: Why /user/local/go isn't recognized as a Go SDK in GoLand I'm trying to setup GoLand to use WSL 2 as in this guide: https://www.jetbrains.com/help/go/how-to-use-wsl-development-environment-in-product.html
I've installed Go in the Ubuntu distro following the linux instructions on the GoLang website, and go version prints outs the version I downloaded, so it appears that Go is working inside WSL.

So now I tried to create a new project in GoLand, and I'm getting errors, which appear to come from the fact that the SDK isn't loaded in GoLand. The guide doesn't offer much guidance on this, so I just tried to add a local SDK.
When I select /usr/local/go I get an error that it's not a valid SDK.

So I created the ~/go directory, and then updated my .zshrc file to export the GOPATH and GOROOT environment variables, even though they already showed up when I ran go env, doing this got them to show up on a simple env call.
But I'm still getting the invalid SDK error like above.
Is there a configuration step I'm missing that isn't spelled out in the guide? I came across this old post about creating symlinks to fake the expected directory structure. I haven't done this because it's a really old post, has comments that say this has been fixed, and seems like a really odd solution.

A: Support for Go SDK in WSL2 will be available in the next 2021.3 release, please see GO-10618.
October 2021 update.
2021.3 reaches Early Access Program at the moment. GoLand suggests selecting Go SDK on WSL2 mount if the location of the project is on WSL2 as well.

A: I experienced this on my Debian machine and I wasn't using WSL2. I found that the actual cause of the issue is that Goland is unable to read the directory /usr/local/go/bin due to inadequate permission.
A possible solution is to run the goland.sh script as root. The script can be found in the bin/goland.sh directory of the Goland IDE folder. Here is a simple command to do run Goland as the root
export HISTIGNORE='*sudo -S*' && echo "sudo-password-here" | sudo -S /absolute-path-to-goland.sh
export HISTIGNORE='*sudo -S*' tells bash history to ignore caching any command matching sudo -S* to bash history. This way, your sudo-password isn't saved into the bash-history file.
echo "sudo-password-here" | pipes your sudo password as input to the next command.
sudo -S tells bash to read input for password prompt from stdin, which has been provided through the echo command.
Alternatively, you can just install the latest version of Goland. Hopefully, it doesn't come with this bug


text:
Q: The calculation of $\dim(U + V + W)$ Is there a (valid) formula for $\dim(U + V + W)$? I know from MO that
$$\begin{align*}
\dim(U + V + W) &= \dim(U) + \dim(V) + \dim(W)\\
&\qquad\mathop{-} \dim(U \cap V) - \dim(U \cap W) - \dim(V \cap W)\\&\qquad \mathop{+} \dim(U \cap V \cap  W)
\end{align*}$$
is wrong.
Can we relate $\dim(U + V + W)$ with the cardinality of some of their quotient spaces? (sorry if this is a dummy question but I'm not any familiar with quotient spaces).

A: I don't think you can do better than this:
$$\begin{align*} \dim(U +V + W) &= \dim((U +V) + W) \\ &= \dim(U +V) + \dim W - \dim((U+V)\cap W) \\ &=
\dim U + \dim V - \dim (U \cap V) + \dim W - \dim((U+V)\cap W) \end{align*}$$
Now you're stuck with $\dim((U+V)\cap W) $, for which there does not seem to be a simple formula.
(BTW, see also https://mathoverflow.net/questions/17740/is-there-a-version-of-inclusion-exclusion-for-vector-spaces but you probably know about this already.)