text:
Q: dd-wrt router firmware QoS troubleshooting I've been using the dd-wrt firmware on my router and I like it a lot!
But -- I'm not sure the quality of service (QoS) is working on it. I have it set up as follows:

*

*http, port 80 -- Premium

*bittorrent, port 6969 -- Bulk

*https, port 443 -- Premium

*dns, port 53 -- Premium

Per the QoS documentation, these levels are:

bandwidth is allocated based on the following percentages of uplink and downlink values for each class:

*

*Exempt: 100mbps - ignores global limits.

*Premium: 75% - 100%

*Express: 15% - 100%

*Standard: 10% - 100%

*Bulk: 1.5% - 100%

This doesn't entirely seem to work, though -- with busy torrents going I get major pauses in my web browsing which sucks!
The QoS documentation gives some steps to check the QoS ...

What you'll be interested to look at will be the first set of source and destination IP, including the port numbers. Next the presence of l7proto and the "mark" field. The entries indicate the current live connection QoS priority applied on them based on the "mark" field. The "mark" values correspond to the following

*

*Exempt: 100

*Premium: 10

*Express: 20

*Standard: 30

*Bulk: 40

*(no QoS matched): 0

  You may see "mark=0" for some l7proto service even though they are in configured in the list of QoS rules. This may mean that the layer 7 pattern matching system didn't match a new or changed header for that protocol. Custom service on port matches will usually take care of these.

On port 6969 (bittorrent) I see a weird mixture of stuff with mark=0 and mark=40 like so

cat /proc/net/ip_conntrack

udp  17 105 src=98.162.182.42 dst=1.2.3.4 sport=64512 dport=6969 packets=3 bytes=290 src=10.0.0.2 dst=98.162.182.42 sport=6969 dport=64512 packets=4 bytes=202 [ASSURED] mark=0 secmark=0 use=1
tcp  6 117 TIME_WAIT src=98.248.173.174 dst=1.2.3.4 sport=51114 dport=6969 packets=12 bytes=704 src=10.0.0.2 dst=98.248.173.174 sport=6969 dport=51114 packets=10 bytes=440 [ASSURED] mark=40 secmark=0 use=1
tcp  6 598 ESTABLISHED src=165.132.128.201 dst=1.2.3.4 sport=57218 dport=6969 packets=8024 bytes=9919881 src=10.0.0.2 dst=165.132.128.201 sport=6969 dport=57218 packets=4211 bytes=239607 [ASSURED] mark=0 secmark=0 use=1
tcp  6 586 ESTABLISHED src=68.46.9.24 dst=1.2.3.4 sport=64688 dport=6969 packets=6 bytes=490 src=10.0.0.2 dst=68.46.9.24 sport=6969 dport=64688 packets=8 bytes=944 [ASSURED] mark=40 secmark=0 use=1
udp 17 45 src=222.254.228.38 dst=1.2.3.4 sport=25438 dport=6969 packets=5 bytes=454 src=10.0.0.2 dst=222.254.228.38 sport=6969 dport=25438 packets=3 bytes=154 [ASSURED] mark=0 secmark=0 use=1

( full file visible at http://pastebin.com/AZE6EtWm )
I've been playing around with this log for a little while and I can't see any patterns!
Why is some port 6969 bittorrent traffic tagged mark=0 (not matched) by dd-wrt's QoS while others are tagged mark=40 (Bulk) .. any ideas?

A: Though it only shapes outgoing traffic, you may find this excellent QoS script (mirror on pastebin) on Alex Rice's blog useful. It's been through several authors and incarnations. Be certain to set UPLINK as well as DEV correctly. For me the default value for DEV was incorrect, use the commented $(nvram get wan_ifname) instead, or the correct value from executing nvram get wan_iframe via SSH.
Also rather than using it, you may duplicate its configuration within the QoS GUI. You'll see it uses 1024:65535 for bulk traffic, with the other settings (80,22,3389, etc.) taking precendence. The script works well for me, and uses HFSC as recommended.

Also, if you don't use the script, you may encounter relevant bugs for your version.

For instance: QoS set to WAN sends uplink traffic to downlink queue
Then realize this patch fails, because: Commands in rc_firewall script are not applied in QoS
You can workaround the problem with a script that executes after rc_firewall as noted in the ticket. I personally ended up enabling JFFS and placing the script with the fix in /jffs/etc/config/qos.ipup, same as mentioned.
I found it convenient to use KiTTY and WinSCP. You can SSH into the router with KiTTY to troubleshoot/verify as in the first ticket, and launch straight into file browsing on the router with the Start WinSCP command under KiTTY's top left icon. If this fails (router isn't running SFTP by default) you can enable FTP and connect manually, or simply add the file with Unix commands. Remember to set the owner execute permission on the script.

A: I have found DD-WRT v24 sp2 build 15362 to be very stable on my Netgear WNDR3700 v1 BUT in spite a huge amount of time spent trying to setup both QoS and TCP Vegas (congestion control) neither mechanism appears to be working on this excellent firmware for inbound traffic (I have no need of outbound control as I do not use VOIP).
For example no matter what options (Mac Control, Netmask, Service Control) I use in my attempts to prioritize inbound video traffic and de-prioritize inbound bit torrent traffic nothing works. I have confirmed this with

*

*Telnet commands suggested for confirming QoS operation

*TCP Vegas
Bottom Line: Use DD-WRT if you want all the other features (particularly broadcast of muliple SSIDs) but use Tomato if you have an applicable chipset ( Tomato is not available for the Atheros based WNDR3700) and like its QoS features.

A: I've noticed that a lot of people complain about QoS not working in DD-WRT, so they switch to Tomato instead.  It works fine in Tomato (I use it).  Tomato also has very nice graphs, which is useful for adjusting your QoS settings.
The downside to Tomato, compared to DD-WRT, is that it has less features, although there are a few mod builds which add certain things, like USB storage and OpenVPN.  However, as Jeff Atwood mentioned below, it only supports Broadcom chipsets.
I use the Teddy Bear mod on my Netgear WNR3500L.  I now use the Toastman mod, which is based on Teddy Bear, with more features and better default QoS classes which work for most people.
Personally, the only things that I am missing in Tomato is VLAN support and multi-SSID broadcast. (Toastman's mod has them both now, as well as Captive Portal for the secondary SSID).

A: I noticed the same thing. I can't find the exact post now, but digging through the forums one of the devs stated that QoS as it is works great on uploads, not so much on downloads. The reasoning behind it is that the router has control of the traffic going out of the network (uplink), but not the traffic going in since it has no control over the incoming flux of data.
I know you're not a huge fan of browsing through forum posts, but you may want to post your questions there.

redpajama_set_name: RedPajamaStackExchange


text:
Q: If a surface, M, has $\pi_1(M)=\mathbb{Z}\ast…\ast \mathbb{Z}$, is M a finitely punctured closed surface? Let $M$ be a connected topological 2-manifold.  I.e. a Hausdorff space locally homeomorphic to $\mathbb{R}^2$.  Suppose $\pi_1(M)$ is a finitely generated free group.  Must $M$ be homeomorphic to a closed surface with finitely many punctures?
I don't think it matters, but I actually only care about orientable $M$.
This is inspired by the answer to this question:  Can two different topological spaces cover each other?

A: Yes. An open surface is either a finitely punctured surface or one has infinitely generated homology groups. A very light sketch is to pick an exhaustion by compact connected submanifolds; at each stage you're either gluing on cylinders, capping off boundary components with discs (or in the nonorientable case Mobius bands), or increasing the genus. If your homology is finitely generated, then your genus is finite, so eventually you're only adding on punctured spheres or capping off components; then show that adding punctured spheres without capping stuff off increases the rank of the homology, bounding the number of ends you can have.
A more precise argument in the case of $\pi_1 = 0$ is given here. You can modify the argument for the case of finitely-generated $H_1(\Sigma;\Bbb Z/2)$.
There is a classification of open surfaces following similar ideas: they are classified by their genus, whether or not they're orientable, and some data about precisely how they're noncompact: their space of ends, their space of non-orientable ends, and their space of ends with genus. If the fundamental group is finitely generated, it can't have any non-orientable ends or ends with genus; these contribute an infinitely generated summand to first homology. (This is why it's nice to work with homology instead of fundamental groups: Having an infinitely generated subgroup is ok, but not if you're abelian!)
At this point, we know that our surface is of finite genus, but it still might have a complicated space of ends (each end being genus zero). Each end contributes to homology: a manifold with at least $n$ ends has homology of rank at least $n-1$. So you had better have finitely many. Thus, you're a finitely punctured closed surface.

A: It is a bit annoying that, while it is well-known, there does not seem to be a complete proof of this result anywhere, while most pieces of the proof are in the literature. Mike Miller's answer is also missing details.
In what follows, an $n$-dimensional manifold is a 2nd countable Hausdorff space
locally homeomorphic to $R^n$. (In particular, by default, manifolds are not assumed to have boundary.)
I will start with a general definition:
Definition. A topological $n$-manifold $M$ is said to be tame if there exists a compact  $n$-manifold with boundary $\bar{M}$ such that $M$ is homeomorphic to the interior of $\bar{M}$, i.e. $\bar{M} -\partial \bar{M}$.
In this case, the inclusion $M\to \bar{M}$ is a homotopy-equivalence. In particular (if $M$ is connected), $\pi_1(M)\cong \pi_1(\bar{M})$ is finitely-presented. Thus, every connected tame manifold has finitely presented fundamental group. The converse is famously false already in dimension 3: The Whitehead manifold is contractible but is not tame. In what follows, will be using homology with $Z_2$-coefficients.
The situation in the case of surfaces, on the other hand, is much simpler:
Theorem 1. Suppose that $M$ is a noncompact connected surface. Then the following are equivalent:

*

*$M$ is tame.

*$H_1(M):=H_1(M; Z_2)$ is finitely generated (i.e. is finite).

*$\pi_1(M)$ is finitely-generated.

*$\pi_1(M)$ is finitely-presented.

*$\pi_1(M)$ is free of finite rank.
Proof. The implications (5)$\Rightarrow$(4)$\Rightarrow$(3)$\Rightarrow$(2) are immediate (the last one uses the Hurewicz theorem). The implication (1)$\Rightarrow$(5) follows from: If $M$ is tame then $\pi_1(M)\cong \pi_1(\bar{M})$. Since $M$ is assumed to be noncompact, $\bar{M}$ has nonempty boundary, hence, by applying inductively the van Kampen theorem, we conclude that $\pi_1(\bar{M})$ is free. Alternatively, one can use the much harder result that fundamental groups of connected noncompact surfaces are free.
Thus, it remains to prove the implication (2)$\Rightarrow$(1).
Since all surfaces admit triangulations, we can assume that $M$ is triangulated. Let $M^1$ denote the 1-skeleton of the triangulation.
Then $H_1(M^1)$ maps onto $H_1(M)$. Since $H_1(M)$ is assumed to be finitely generated and $M$ is connected, there is a finite connected subgraph $X\subset M^1$ such that the inclusion maps $X\to M^1\to M$ induce a surjective map $H_1(X)\to H_1(M)$. Let $Y\subset M$ be the regular neighborhood of $X$ in $M$. It is a compact surface with boundary. The inclusion $X\to Y$ is also a homotopy-equivalence, hence, the natural homomorphism $H_1(Y)\to H_1(M)$ is also surjective. Consider a boundary component $C$ of $Y$. If $C$ does not separate $M$ then, applying the Mayer-Vietoris sequence (or duality), we conclude that   $H_1(X)\to H_1(M)$ is not surjective, which is impossible. Thus, $C$ separates $M$ in two components, one of which contains the interior of $X$ and the other, $X_C$, is disjoint from $X$. If the inclusion map $C\to \bar{X}_C$ (the closure of $X_C$ in $M$) does not induce a surjection $H_1(C)\to H_1(\bar{X}_C)\cong H_1(X_C)$, then applying the Mayer-Vietoris sequence, we again see that  $H_1(X)\to H_1(M)$ is not surjective, which is a contradiction. In particular, by the classification of compact surfaces, either $\bar{X}_C$ is homeomorphic to a closed disk, or $X_C$ is noncompact and, thus,  $H_1(C)\to H_1(X_C)$ is 1-1.
We, therefore, enlarge $X$ by adding to it the complementary components $X_C$ homeomorphic to $R^2$. The new subsurface with boundary, denoted $Z$, still has the property that the inclusion $Z\to M$ induces a surjective homomorphism $H_1(Z)\to H_1(M)$ (since $Z$ contains $X$). Now, however, the homomorphism  $H_1(Z)\to H_1(M)$ is also injective. Therefore, $H_1(Z)\to H_1(M)$ is an isomorphism.
Let $N$ denote the interior of $Z$: It is a noncompact tame surface ($Z=\bar{N}$).
We still have isomorphisms induced by inclusions
$$
H_1(N)\cong H_1(Z)\cong H_1(M).
$$
So far, the proof was self-contained. I will now use:
Theorem 2. Suppose that $S'\subset S$ is a connected subsurface $S'$ in a noncompact connected surface $S$ such that the inclusion $S'\to S$ induces an isomorphism $H_1(S')\to H_1(S)$. Then $S'$ is homeomorphic to $S$.
See Theorem 7.1  in
Martin Goldman, An algebraic classification of noncompact 2-manifolds.
Trans. Amer. Math. Soc. 156 (1971), 241–258.
This theorem implies that the surfaces $N$ and $M$ are homeomorphic. Since $N$ is tame, so is $M$. qed
Remark. Since fundamental groups of noncompact connected surfaces are free, finiteness of $H_1(M; Z_2)$ is equivalent to the finite generation of $\pi_1(M)$.  This allows for an alternative geometric proof of the implication (2)$\Rightarrow$(1) which I give below. (But the proof uses much heavier machinery.)
Equip $M$  with an arbitrary Riemannian metric. This, in turn, defines a conformal structure on $M$. Lift this conformal structure to the universal covering $\tilde{M}\to M$. By the Uniformization Theorem, $\tilde{M}$ is conformal to either the open unit disk or to the complex plane. Accordingly, we obtain a properly discontinuous, free, isometric action of $\Gamma=\pi_1(M)$ on the hyperbolic plane ${\mathbb H}^2$ (in the unit disk model) or the Euclidean plane $E^2$. I will consider the former case since the latter is easier. We have a discrete finitely generated subgroup $\Gamma< Isom({\mathbb H}^2)$. Every such subgroup admits a finitely-sided fundamental polygon $F\subset {\mathbb H}^2$, see for instance Alan Beardon's book "The Geometry of Discrete Groups."
The sides of $F$ are pairwise identified by some generators $\gamma_1,...,\gamma_n$ of $\Gamma$ and the quotient of $F$ by this identification is homeomorphic to our surface $M$.  The polygon $F$ is noncompact (since $M$ is). Its noncompactness stems from two possible sources:
(a) $F$ may have "ideal vertices", points in the (ideal) boundary circle of ${\mathbb H}^2$, where two of the sides of $F$ meet.
(b) $F$ may have "ideal edges", arcs in the boundary of ${\mathbb H}^2$.
We enlarge $F$ by adding to it the ideal vertices and edges, the result is $\bar{F}$, a compact polygon. Identifying its boundary edges results in a compact surface with boundary $S$: The boundary of $S$ is the image of the union of ideal edges of $F$. The (finitely many) ideal vertices of $F$ project to finitely many points $p_1,...,p_k$ in $S- \partial S$. Thus, $M$ is homeomorphic to the complement
$$
S- (\partial S \cup \{p_1,...,p_k\}).
$$
Equivalently, let $D_1,...D_k$ denote small (pairwise disjoint and disjoint from $\partial S$) closed disk neighborhoods of $p_1,...,p_k$. Then $M$ is homeomorphic to the complement
$$
S- (\partial S \cup D_1\cup ...\cup D_k).
$$
Let $\bar{M}$ denote $M- (cl(D_1)\cup ...\cup cl(D_k))$. Then $\bar{M}$ is a compact surface with boundary and $M$ is homeomorphic to the interior of $M$. qed
Edit. Here is one more proof of the implication (3)$\Rightarrow$(1). It uses Lemma 2.2 in
D. B. A.  Epstein, Curves on 2-manifolds and isotopies. Acta Math. 115 1966 83–107:
Lemma 1. Suppose that $S$ is a connected surface and $G$ is a finitely-generated subgroup of $\pi_1(S)$. Then there exists a compact $\pi_1$-injective subsurface $S'\subset S$ such that the image of $\pi_1(S')$ in $\pi_1(S)$ contains $G$.
Now, assuming that $\pi_1(S)$ is finitely-generated and $G=\pi_1(S)$, we obtain a compact subsurface $S'$ whose fundamental group is isomorphic to $\pi_1(S)$ via the map induced by the embedding $S\to S'$. Now one can either quote Goldman's result to conclude a homeomorphism $int(S')\to S$, or directly argue that each component of $S- int(S')$ is homeomorphic to $S^1\times [0,1)$:
Lemma 2. Suppose that $A$ is a connected noncompact surface with connected boundary $C=\partial A$, such that the inclusion $C\to A$ induces an isomorphism of fundamental groups. Then $A$ is homeomorphic to $S^1\times [0,1)$.
Proof. Consider the surface $B$ obtained by attaching a closed disk $D$ to $A$ along $C$. Then, by the van Kampen theorem, $B$ is simply-connected (since $\pi_1(C)\to \pi_1(A)$ is surjective). Therefore, since $B$ is noncompact, $B$ is homeomorphic to ${\mathbb R}^2$,  see e.g. Corollary 1.8 in Epstein's paper. By the 2-dimensional Schoenflies theorem, there is a homeomorphism ${\mathbb R}^2\to {\mathbb R}^2$ sending $D$ to the closed unit disk $D(0,1)$ centered at the origin. This homeomorphism sends $A$ to the complement to the interior of $D(0,1)$, which is homeomorphic to $S^1\times [0,1)$. qed


text:
Q: MS Word VBA Find Variable-Length Pattern String Question: Is there a way to specify a repeating pattern of variable but bounded length in the Find.Text argument?
Background:
I have a collection of Word documents, each containing several hundred pages of numbered text blocks. I want to copy each block of text into its own cell in a spreadsheet, but the text blocks aren't in Ordered or Multi-Level Lists and each block of text may contain multiple paragraphs, so I can't simply select and copy each paragraph in the document. To work around this, I've tried to use the Range.Find method to locate two adjacent number headings and copy all the characters between them. For testing purposes, I'm using the following sample document:

The paragraph header numbers can be 2-5 levels deep, with 1-2 digits in each level (i.e. "x.x." through "xx.xx.xx.xx.xx."). I'm using a wildcard search of the form "xx.xx.", relying on the placement of the decimal points to identify the headers. Here's my code:
'Open the Word document
    Doc = CStr(folderPath & objFile.Name)
    Set wDoc = wApp.Documents.Open(Doc)
    Set wRange = wDoc.Range
    RngEnd = wRange.End

    'Search for text block
        With wRange
            Do While i < 7 And subRngStart2 < RngEnd
                With .Find  'Search for starting keyword
                    .ClearFormatting
                    .Text = "[0-9]{1,2}.[0-9]{1,2}."
                    .Forward = True
                    '.Format = True
                    .MatchWildcards = True
                    .MatchCase = False
                    .Execute
                End With

                If .Find.Found = True Then
                    subRngStart1 = wRange.Start 'Mark starting position
                    wRange.SetRange Start:=subRngStart1 + 6, End:=RngEnd 'Reset range starting at end of keyword
                    contentFlag = True
                Else
                    contentFlag = False
                End If
                With .Find  'Search for ending keyword
                    .ClearFormatting
                    .Text = "[0-9]{1,2}.[0-9]{1,2}."
                    .Forward = True
                    .MatchWildcards = True
                    .MatchCase = False
                    .Execute
                End With

                If .Find.Found = True Then
                    subRngStart2 = wRange.Start 'Mark ending position
                Else
                    subRngStart2 = RngEnd
                End If
                wRange.SetRange Start:=subRngStart1, End:=subRngStart2 'Set range between first and second keywords

                'Copy text in range to Excel
                If contentFlag = True Then
                    Cells(i + 1, 1) = wRange.Text
                End If

                wRange.SetRange Start:=subRngStart2 - 3, End:=RngEnd 'Reset range starting at last keyword
                i = i + 1
            Loop
        End With

This works fine for headers up to 3 levels but breaks down beyond that: the "Long Headers" example gets split in half because the search thinks the first two levels in the string form a complete text block (Row 7 in the output sample below).

I could just increase the starting offset (first IF statement, second line) from 6 to 10 to "skip over" long number strings, but this can cause problems with very short headers. I think the proper way to fix this is to search for a pattern of the form "xx.xx." which may repeat up to 4 consecutive times. I've tried a couple of variations on the wildcard string to achieve this, including:
.Text = "[0-9]{1,2}.*[0-9]{1,2}."
.Text = "[0-9]{1,2}.[0-9]{0,2}[.]{0,1}[0-9]{1,2}."

But these either don't do what I want or fail to compile (I'm guessing a min length of zero isn't allowed in wildcard charlists). Is it possible to specify variable-length patterns in Find.Text, or do I need to take a completely different approach?


text:
Q: Run a program as a service on Debian/Linux I have an older jetty server I want to turn into as a service on a Debian OS. It should start automatic each time I restart the computer.
Manually I start the server with the two following commands:

*

*root@myserver:/# cd /opt/jdk/jetty

*root@myserver:/opt/jdk/jetty# java jetty

Anyone know how to do this ?

A: If you want to start any program on booting you can add that entry in rc.local.
java /opt/jdk/jetty/jetty

It will start on reboot


text:
Q: How to catch KeyboardInterrupt when using blocking functions in Python I wanted to create a Python script that serves a connection until interrupted by Ctrl+C, but it simply does not work if a connection does not happen in the first place.
Simplified problem code:
...

try:
    conn, ADDR = listening_socket.accept() # Blocks, which is probably the problem.
    while True:
        # This code is never reached.
        ...
except KeyboardInterrupt:
    # Handle the interrupt (that does not happen).
    ...

I am guessing the issue is that socket.accept() blocks, in which case there will be multiple spots in the while loop that will also ignore interrupts. Are there any ways to make this work like I would like it to?


text:
Q: How do I conditionally use a class in Swift that may not be present in the targeted version of the OS? This answer addresses how to use a Swift class from a framework that may not be linked to an app, but is present in the target OS. Relatedly, but a bit different, I'd like to know how to conditionally use a Swift class that may not be included in the target OS. For example, say I have an app, written in Swift, that targets iOS 7. I want to use WKWebView if I'm on iOS 8, and UIWebView if I'm on iOS 7. This doesn't work:
if NSClassFromString("WKWebView") == nil {
    var wv = WKWebView()
} else {
    var wv = UIWebView()
}

Because my app targets iOS 7, I get a compile-time error:
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_WKWebView", referenced from:
      __TMaCSo9WKWebView in MyWebKitViewController.o

I tried just assigning the WKWebView to an AnyObject property, but then I can't call methods on it. So how can I get Swift to just check for these things at runtime?

A: I'm new to Swift so I don't know if this is Swift or not, but I found this on a different question. https://stackoverflow.com/a/25874127/1012144
http://floatlearning.com/2014/12/uiwebview-wkwebview-and-tying-them-together-using-swift/
 if (NSClassFromString("WKWebView") != nil) {
   // Use WebKit
 } else {
   // Fallback on UIWebView
 }

A: The code in the OP is nearly correct; it just needed to use != instead of ==:
if NSClassFromString("WKWebView") != nil {
    var wv = WKWebView()
} else {
    var wv = UIWebView()
}

To make it work, be sure to set iOS Deployment Target to 7.0. Otherwise you get the undefined symbol errors.


text:
Q: Firebase Queries don't Show Data in Adapter In my Application, I tried to get data in listview using simple queries with simple Adapters and FirebaseListAdapter, but the data ,which is selected, haven't shown in the listview, you can find FirebaseAdapter in comments in onCreateview, Code is as shown below:
package mainproject.mainroject.story;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;

import java.util.ArrayList;

import mainproject.mainroject.story.dummy.DummyContent.DummyItem;

/**
 * A fragment representing a list of Items.
 *

 * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener}
 * interface.
 */
public class ItemFragment extends Fragment {

    // TODO: Customize parameter argument names
    private static final String ARG_COLUMN_COUNT = "column-count";
    // TODO: Customize parameters
    private int mColumnCount = 1;
    private ArrayList<String> musername = new ArrayList<>();
    private OnListFragmentInteractionListener mListener;

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public ItemFragment() {
    }

    // TODO: Customize parameter initialization
    @SuppressWarnings("unused")
    public static ItemFragment newInstance(int columnCount) {
        ItemFragment fragment = new ItemFragment();
        Bundle args = new Bundle();
        args.putInt(ARG_COLUMN_COUNT, columnCount);
        fragment.setArguments(args);
        return fragment;
    }

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

        if (getArguments() != null) {
            mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.fragment_item_list, container, false);
        ListView recyclerView = (ListView) view.findViewById(R.id.list);

//        // Set the adapter
//        if (view instanceof RecyclerView) {
//            Context context = view.getContext();
//            if (mColumnCount <= 1) {
//                recyclerView.setLayoutManager(new LinearLayoutManager(context));
//            } else {
//                recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
//            }
//            recyclerView.setAdapter(new MyItemRecyclerViewAdapter(DummyContent.ITEMS, mListener));
////        }

        FirebaseDatabase mydatabase=FirebaseDatabase.getInstance();
        DatabaseReference myRef = mydatabase.getReference().child("UserDetail");
                Query query=FirebaseDatabase.getInstance().getReference().child("StoriesDetails").orderByChild("story_content").equalTo("story_content");

//The error said the constructor expected FirebaseListOptions - here you create them:
//        FirebaseListOptions<String> options = new FirebaseListOptions.Builder<String>()
//                .setQuery(query, String.class)
//                .setLayout(android.R.layout.simple_list_item_1)
//                .setLifecycleOwner(this)
//                .build();
//        FirebaseListAdapter<String> firebaseListAdapter = new FirebaseListAdapter<String>(options) {
//            @Override
//            protected void populateView(View v, String  model, int position) {
//                TextView text = (TextView)view.findViewById(R.id.id);
//                text.setText(model);
//            }
//        };
        musername.add(String.valueOf(query));
        final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),android.R.layout.simple_list_item_1, musername);
        recyclerView.setAdapter(arrayAdapter);

//        myRef.addChildEventListener(new ChildEventListener() {
//            @Override
//            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
//                GenericTypeIndicator<Map<String, String>> genericTypeIndicator = new GenericTypeIndicator<Map<String, String>>() {};
//                Map<String,String> map=dataSnapshot.getValue(genericTypeIndicator);
//                String value =map.get("Name");
//
////                musername.add(value);
////                arrayAdapter.notifyDataSetChanged();
//            }
//
//            @Override
//            public void onChildChanged(DataSnapshot dataSnapshot, String s) {
//
//            }
//
//            @Override
//            public void onChildRemoved(DataSnapshot dataSnapshot) {
//
//            }
//
//            @Override
//            public void onChildMoved(DataSnapshot dataSnapshot, String s) {
//
//            }
//
//            @Override
//            public void onCancelled(DatabaseError databaseError) {
//
//            }
//        });
       return view;
    }

//    @Override
//    public void onDetach() {
//        super.onDetach();
//        mListener = null;
//    }
//
    /**
     * This interface must be implemented by activities that contain this
     * fragment to allow an interaction in this fragment to be communicated
     * to the activity and potentially other fragments contained in that
     * activity.
     *

     * See the Android Training lesson Communicating with Other Fragments for more information.
     */
    public interface OnListFragmentInteractionListener {
        // TODO: Update argument type and name
        void onListFragmentInteraction(DummyItem item);
    }
}

layouts
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/list1"
    android:orientation="vertical">

    <TextView
        android:id="@+id/id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/text_margin"
        android:textAppearance="?attr/textAppearanceListItem" />

</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<ListView 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:id="@+id/list"
    android:name="mainproject.mainroject.story.ItemFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    app:layoutManager="LinearLayoutManager"
    tools:context="mainproject.mainroject.story.ItemFragment"
    tools:listitem="@layout/fragment_item" />

A: when you get data from firebase database used below code ...
   Query query=FirebaseDatabase.getInstance().getReference().child("StoriesDetails").orderByChild("story_content").equalTo("story_content");
    query.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

            for (DataSnapshot issue : dataSnapshot.getChildren()) {

                musername.add(issue.getValue(User.class).name); // define your pojo class for getting firebase data.
            }
            final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),android.R.layout.simple_list_item_1, musername);
            recyclerView.setAdapter(arrayAdapter);
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}


text:
Q: How to paraphrase this sentence?
The effects of the mechanization of women's work have not borne out
  the frequently held assumption that new technology is inherently
  revolutionary.

I am perplexed to understand the above sentence. Could anyone help me to paraphrase this sentence, that way I can understand this clearly.

A:
The effects of the mechanization of women's work
  = Whatever effects such mechanization may cause
have not borne out
  = don't show
the frequently held assumption
  = that the assumption that is the commonly believed
that new technology is inherently revolutionary.
  = that new technology is essentially revolutionary is true.

NOTE: I simplified the tense a little to make it a little clearer. To stick to the original, it should've been "haven't shown". I wrote this answer assuming that the phrasal verb bear out (to show that something is true or that someone is telling the truth) was the main confusion.


text:
Q: How to increase the number of hashing rounds for /etc/shadow? I usually use long passwords for my machines, but I heard that it's possible to increase the number of hashing rounds and get the same security with a shorter one. How would I make my system use more rounds when hashing the password?

A: The number of rounds can be set by modifying the file /etc/pam.d/common-password. The relevant line is the one containing the pam_unix.so module. Add rounds=<n> at the end of the line to use <n> rounds for subsequent password changes.
Verify the setting by adding a user, e.g., by doing adduser test1. After adding the user, the /etc/shadow file should contain a line starting with test1:$6$rounds=<n>$.... Don't forget to delete the test user afterwards (deluser test1).
If everything looks good, change the passwords for all relevant users to apply the increased number of rounds to their hashes.
More information on pam_unix parameters can be found in the man page (man pam_unix).


text:
Q: Subgroup of rotations in $D_n$ is normal. Here is what I did:
Suppose R $\leq$ $D_n$ is the subgroup of rotation. Suppose $x \in fRf^{-1}$. Then $x = frf^{-1}$ for some r and for any r. Therefore, $x = r'$ a rotation and hence $x \in R$. therefore by definition R is normal in $D_n$
Is this correct and complete verification?
Thanks, any other suggestions??

A: Well, it is correct. But you should emphasize and expand a bit more the essence of the thought, and this is:

Therefore $x=frf^{-1}$ is a rotation.

So.. Why is it a rotation? That's the point.


text:
Q: How to find the number of divisors of a given number? I am stuck on this question...please help me
 `

Find the number of divisors of $2^3 * 21^2 * 91^1$ excluding $1$ and the product itself.

Please answer this and also tell me how to do it?

A: The first step is to completely factor the number into a product of prime numbers. By the product you listed, your number is 321,048.
Its prime factorization is given by: $321,048=2^3 \cdot3^2 \cdot 7^3 \cdot13$
For a number, $n=p^a$ where $p$ is a prime number, it has $a+1$ divisors ($1,p,p^2, ..., p^a$). For $n=p_1^a \cdot p_2^b$, it has $(a+1)(b+1)$ total divisors ($a+1$ options for a divisor coming from the first prime, and (b+1) for the second. Multiplying gives the possible combinations of them together).
At this point we can see the pattern: increment the power of each of the prime factors by 1, and multiply them together for the total number of divisors.
Moving back to your number, it has $4\cdot 3 \cdot 4 \cdot 2=96$ total divisors. Removing 1 and the number itself, by your constraints, the answer is $94$ divisors.


text:
Q: Trying to connect to MySQL server: A network-related or instance-specific error occurred while establishing a connection to SQL Server I want to connect to the MySQL server, but as the error suggests, my program is trying to connect to the SQL Server. How can I change that it connects to MySQL? Also I'm using NHibernate for mapping. Should this be a problem? I installed the MySQL Connector, and added as References MySQL.Data and MySql.Web but didn't changed anything.
This is my class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using NHibernate;
using NHibernate.Cfg;

namespace ConsoleApp1
{
    class Program
    {
        public void testMethod()
        {
            Configuration config = new Configuration();
            config.Configure();

            ISessionFactory factory = config.BuildSessionFactory();
            ISession session = factory.OpenSession();
            ITransaction tx = session.BeginTransaction();

            User u = new User();
            u.Name = "AAA";
            u.Password = "BBB";

            session.Save(u);
            tx.Commit();

            session.Close();
        }

        static void Main(string[] args)
        {
            Program p = new Program();
            p.testMethod();
        }
    }
}

And this is the full stack trace:
Unhandled Exception: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception: The system cannot find the file specified
   --- End of inner exception stack trace ---
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at NHibernate.Connection.DriverConnectionProvider.GetConnection()
   at NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare()
   at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper)
   at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactoryImplementor sessionFactory)
   at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
   at NHibernate.Cfg.Configuration.BuildSessionFactory()
   at ConsoleApp1.Program.testMethod() in C:\Users\Stark\Documents\Visual Studio Projects\ConsoleApp1\ConsoleApp1\ConsoleApp1\Program.cs:line 19
   at ConsoleApp1.Program.Main(String[] args) in C:\Users\Stark\Documents\Visual Studio Projects\ConsoleApp1\ConsoleApp1\ConsoleApp1\Program.cs:line 36

Also, the hibernate configuration file:

  <session-factory name="Test">
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Server=localhost;DataBase=assignment_4;uid=root;pwd=1234</property>

    <property name="show_sql">true</property>

    <mapping assembly="ConsoleApp1" />
  </session-factory>

</hibernate-configuration>

A: You must change details in config to use proper driver:
<property name="connection.driver_class">
    NHibernate.Driver.MySqlDataDriver
</property>

Some of the examples can be found here: https://www.codeproject.com/Articles/26123/NHibernate-and-MySQL-A-simple-example


text:
Q: Linux dropfolder where users can't delete files I am working on a file server project for school and I am using samba to share the folders. I have been playing around with the folder permissions but I can't seem to figure out how to make a drop only like folder. This is what I want to achieve:

*

*Owner (server account): Full control (chmod number 7xx)

*Group (users that sign in to the samba server) : Only place (drop) files,so this means don't open/edit/delete files in the folder (chmod number x?x)

*others : no access (chmod number xx0)
I have tried a lot of different chmod settings but never achieved the wanted result. Is this even possible? I googled a lot but couldn't really find a concluding answer.
Maybe a way to set permissions on files whenever they are placed in the folder?
If you need more information about the samba configuration or anything else please ask!
Thank you for helping out!

A: Unfortunately, your problem is not solvable so easily. If a user has write permission in a directory, he can also delete files. Even if he wasn't able to delete them, he could still fill a file with zeros, which would be a deletion of data, but not of the filesystem node.

An idea which I once used:
You create a cronjob, which recusively removes the write permission of every file in a directory tree (like every file in /home/guest).
Note that you can't simply use chmod g-w -R /home/guest. This would take the write bit off the directories too, making it impossible to place new files there. So you'd need to iterate over every file and remove it's group write bit.
The interval of the cronjob execution is up to you - back then I set it to 10 minutes. I don't know your environment, so I can't give you a recommendation.
Unfortunately I don't have this script any more, so you'll have to do some bash scripting to get it to work. But seriously, I doubt that this is an efficient method.

A: Try this procedure.
Create shared folder and give right permission:
  mkdir /pathYouWant/share
  chmod 770 /pathYouWant/share

This gives no access to other.
  chmod +t /pathYouWant/share

This mode, according to chmod manual page:
   The  restricted  deletion  flag  or  sticky  bit is a single bit, whose
   interpretation depends on the file type.  For directories, it  prevents
   unprivileged  users  from  removing or renaming a file in the directory
   unless they  own  the  file  or  the  directory

As told by Marty Fried files created in the share folder should have the right permissions and this can be achieved with samba share masks in smb.conf:
  create mask = 440
  directory mask = 550

Windows programs shouldn't try to remove read-only files unless delete readonly option is set to yes.
  delete readonly = no

Also if you want to hide all file in share folder:
  veto files = /*/
  delete veto files = no

According to samba manual these directive:

What happens if the user tries to delete a directory that contains
  vetoed files? This is where the delete veto files option comes in. If
  this Boolean option is set to yes, the user can delete both the
  regular files and the vetoed files in the directory, and the directory
  itself is removed. If the option is set to no, the user cannot delete
  the vetoed files, and consequently the directory is not deleted
  either. From the user's perspective, the directory appears empty, but
  cannot be removed.

After this configuration, the only problem left is that user can still delete his/her own files even if he/she do not see it (It is unclear to us why).
So we decide to follow the_Seppi suggestion to complete the task and Bram Driesen did a script that changes file ownership to the host pc.
He used incron to fire the script whenever a file is placed in the folder, following this as guide to set it up.

A: We can modify the files and folders but can't delete.
To remove the attributes, run the following commands:
For files:
sudo chattr -R -a file.txt

For directories:
sudo chattr -R -a dir1/


text:
Q: ffmpeg perspective filter animation error I'm trying to create a pseudo-3d pan effect in ffmpeg using the perspective filter.
Here is a sample for the starting point...
ffmpeg -y -filter-complex "color=black:s=1600x900,trim=0:5,drawgrid=width=100:height=100:thickness=2:color=white,perspective=x0=200:y0=200:x1=1600:y1=0:x2=200:y2=700:x3=1600:y3=900[skew]" -an -map [skew] "skew-start.mp4"

And here is a sample for the end point...
ffmpeg -y -filter-complex "color=black:s=1600x900,trim=0:5,drawgrid=width=100:height=100:thickness=2:color=white,perspective=x0=0:y0=0:x1=1600:y1=0:x2=0:y2=900:x3=1600:y3=900[skew]" -an -map [skew] "skew-end.mp4"

So far so good. Adding the animation would give this...
ffmpeg -y -filter-complex "color=black:s=1600x900,trim=0:5,drawgrid=width=100:height=100:thickness=2:color=white,perspective=eval=frame:x0='200-(200*t/5)':y0='200-(200*t/5)':x1=1600:y1=0:x2='200-(200*t/5)':y2='700+(200*t/5)':x3=1600:y3=900[skew]" -an -map [skew] skew.mp4

This is where the problem occurs. I get an error saying [Eval @ 000000f36ebfebf0] Undefined constant or missing '(' in 't/5)' Error while filtering: Invalid argument
The perspective docs say it should work with an eval=frame option. Anyone got any ideas? Does this look like a bug in ffmpeg? I'm using the latest version, 4.3.2.

A: As the docs say,
The expressions can use the following variables:

W
H

    the width and height of video frame.
in

    Input frame count.
on

    Output frame count.

t is not one of the allowed variables. Use in where in is an integer representing time x fps. I could add time but give me a few days to push that.


text:
Q: How to retry connect multiple times when doing http request in node.js if the server is not responding? If a server is not responding, how can I retry the connect?
I get the error ECONNREFUSED, but I want to retry the connection at least 5 times.
Here is my code:
var body = JSON.stringify(saveObj);
var request = http.request({
    host: BASE_URL,
    port: PORT,
    path: LINK_SAVE,
    url : 'https://coherent-bay-777.appspot.com/_ah/api/timesOfIndia/v1/addChannel',
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Content-Length': Buffer.byteLength(body)
    }
}, function(res) {
    var resp = '';
    res.on('data', function(data) {
        resp += data;
    });
    res.on('end', function() {
        resp = JSON.parse(resp);
        if(resp.id) {
        winston.info(resp.id);
            saveObj.update({$set : { id : resp.id }},
                function(err) {
                    if(err) {
                        winston.error(err);
                    } else {
                        cb();
                    }
                });
        } else {
            cb();
        }

    });
    res.on('error', function(err) {
        winston.error(err);
        //cb();
    });
    winston.info('Request Ended');
});

if(body == '{}') {
    cb();
    return;
}

request.on('socket', function (socket) {

    socket.setTimeout(15000);
    socket.on('timeout', function() {
        console.log("Timeout, aborting request")
        request.abort();
    });
}).on('error', function(e) {
    console.log("Got error: " + e.message);
      error callback will receive a "socket hang up" on timeout
});

request.write(body);
request.end();


text:
Q: A question on almost simple groups We know that if $G$ is a simple group with  $p+1$ Sylow $p$-subgroups, then $G$ is 2-transitive. Now let $G$ be almost simple group with $p+1$ Sylow $p$-subgroups. Is $G$ 2-transitive group?

A: I think there is a direct argument. Let $M$ be the unique minimal normal subgroup of $G,$
which is non-Abelian simple. Then $M$ must act faithfully by conjugation
on the $(p+1)$ Sylow $p$-subgroups of $G$- otherwise, $M$
has a normal Sylow $p$-subgroup, which must then be trivial.
But even then, $M$ must normalize, and hence centralize, a Sylow $p$-subgroup $P$
of $G$, as $M$ and $P$ normalize each other and have trivial intersection.
Then $P$ is contained in $C_G(M)=1,$ a contradiction.
Thus $G$ is isomorphic to a subgroup the symmetric
group of degree $p+1$ and a Sylow $p$- subgroup
of $G,$ say $P,$ has order $p.$ Now $P$ fixes no other Sylow $p$- subgroup
 of $G$ in the conjugation action, so permutes the remaining
$p$ such subgroups in one orbit of length $p.$ Hence $G$
Is doubly transitive.
Later addition: Let me try to address more precisely Mart's question in the comments-
the argument is less elementary, but still avoids the classification of finite simple
groups. Let me retain my notation of $M$ for the unique minimal normal subgroup of $G,$ (called $S$ by Derek and Mart) and let $P$ be  a Sylow $p$-subgroup of $G,$ which has order $p,$ as we have seen already.
   The key point I will use is a Theorem of Feit and Thompson (Nagoya J. Math ~1963), which built on an earlier result of Brauer: the combined result asserts that if $X$ is a finite irreducible subgroup of ${\rm GL}(n,\mathbb{C})$ for some $n \leq \frac{p-1}{2},$ where $p$ is a prime, then either $X$ has a normal Sylow $p$-subgroup, or $X/Z(X) \cong {\rm PSL}(2,p).$
Our group $G$ has a transitive faithful permutation action on $p+1$ points, affording a permutation character $\chi,$ say. We are assuming that $M$ has order prime to $p,$ and aiming to derive a contradiction. The orbits of $M$ all have equal length, and are permuted by $G$. If $M$ has two or more orbits, then ${\rm Res}^{G}_{M}(\chi)$ has at least two trivial constituents, and $M$ has a faithful irreducible character of degree at most $\frac{p-1}{2},$ which extends irreducibly to $MP$ (it can't induce irreducibly by degree considerations). Now $P$ is not normal in $MP$ as $[M,P] \neq 1.$ But $MP/Z(MP)$ is not isomorphic to ${\rm PSL}(2,p),$ since ${\rm  PSL}(2,p)$ has no normal $p$-complement, while $MP$ does have a normal $p$-complement (note that we do need $p >3$ here, but $S_{4}$ is solvable and $G$ is not, so we do indeed have $ p >3$). This contradicts the result of Brauer, Feit and Thompson. Hence $M$ is transitive.
    Now $M$ is not doubly transitive, as $p$ does not divide $|M|,$ so that ${\rm Res}^{G}_{M}(\chi)$ is a sum of at least $3$ irreducible characters (allowing multiplicities). However, the trivial character only occurs once, and $M$ has no other linear character. Hence ${\rm Res}^{G}_{M}(\chi)$ has a faithful irreducible constituent $\mu$ of degree at most $\frac{p-1}{2},$ which once more extends irreducibly to $MP,$ and we obtain the same contradiction as above.
Third edit: Actually, there is a simpler argument using less sophisticated representation theory to obtain $p$ divides $|M|$. Suppose otherwise, and retain the notation above. Note that ${\rm Res}^{G}_{MP}(\chi)$ can't have an irreducible constituent of degree $p$ (but does have a trivial constituent): for if $\mu$ were such  constituent, then Clifford's theorem would force $\mu$ to restrict to a sum of non-trivial linear characters of $M$, contrary to the fact that $M$ is perfect. Hence $MP$ has a non-trivial complex irreducible character $\theta$ say, of degree less than $p$ (and $\theta$ is faithful using the simplicity of $M$). Let $r$ be an odd prime divisor of $|M|$, and let $R$ be a $P$-invariant Sylow $r$-subgroup of $M$ (which exists). Then by the theorem of Hall-Higman-Shult, we have $[M,R] \leq {\rm ker} \theta = 1.$ Let $Q$ be a $P$-invariant Sylow $2$-subgroup of $M$. Then as $r$ was arbitrary, we have $M = QC_{M}(P).$ Hence $[M,P] \leq Q.$
But $[M,P] \lhd M$ and $M$ is non-Abelian simple, so $[M,P] = 1$ and $P \leq C_{G}(M) = 1,$ a contradiction.

A: I am sure that the answer is yes, but you might have to do a bit of work to write down a completely rigorous proof.
Let $S \unlhd G$ with $S$ simple and $G \le {\rm Aut}(S)$, and suppose that $G$ has $p+1$ Sylow $p$-subgroups. If $p$ divides $|S|$, then $S$ has at most $p+1$ and hence exactly $p+1$ Sylow $p$-subgroups, and so $S$ and hence $G$ act 2-transitively by conjugation on the set of Sylow $p$-subgroups of $S$ (or of $G$).
Using the classification, we find that the only finite simple groups $S$ that have an automorphism of prime order $p$ that does not divide $|S|$ are groups $S=L(r^{p^k})$ of Lie type that have a field automorphism of order $p^k$. So a Sylow $p$-subgroup $P$ of $G$ is cyclic of order $p^l$ for some $l \le k$. Then the centralizer of $P$ in $S$ is isomorphic to $L(r^{p^{k/l}})$, which has index greater than $p+1$ in $S$, so it is not possible for $G$ to have $p+1$ Sylow $p$-subgroups in this situation.


text:
Q: reduce number of obervations by summarizing columns I have a dataframe in the following structure:
structure(list(SUB_DISTRICT_CODE = c(90101L, 90101L, 90101L,
90101L, 90101L, 90101L, 90102L, 90102L, 90102L, 90102L, 90102L,
90102L, 90103L, 90103L, 90103L, 90103L, 90103L, 90103L), SEX = c(1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L,
2L), AGR3 = c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L, 1L, 2L, 3L), TOTAL_per_GROUP = c(184L, 1245L, 456L,
167L, 1216L, 567L, 91L, 463L, 150L, 96L, 476L, 217L, 118L, 618L,
256L, 116L, 627L, 293L)), row.names = 21295:21312, class = "data.frame")

At the moment there are 6 entries for every SUB_DISTRICT CODE. In the final dataframe there should only be 3 entries for every SUB_DISTRICT_CODE (one for each unique value of AGR3).
The column SEX should be dropped and the TOTAL_per_GROUP values be summarized by the AGR3 column. How can I do this in a easy way (using dplyr)?
Thanks

A: Try using group_by() for AGR3 and SUB_DISTRICT_CODE and then summarise():
df %>% group_by(AGR3, SUB_DISTRICT_CODE) %>%
  summarise(sum = sum(TOTAL_per_GROUP))

Output:
# AGR3 SUB_DISTRICT_CODE   sum
# <int>             <int> <int>
# 1     1             90101   351
# 2     1             90102   187
# 3     1             90103   234
# 4     2             90101  2461
# 5     2             90102   939
# 6     2             90103  1245
# 7     3             90101  1023
# 8     3             90102   367
# 9     3             90103   549

A: # Base R solution: base_r_res => data.frame
base_r_res <- aggregate(
  TOTAL_per_GROUP ~ AGR3 + SUB_DISTRICT_CODE,
  data = df,
  FUN = sum
)

# Send result to console: data.frame => stdout(console)
base_r_res

# Data table solution: import library
library(data.table)

# Aggregate by group: dt_res => data.table
dt_res = setDT(df)[,.(TOTAL_per_GROUP=sum(TOTAL_per_GROUP)), by = list(AGR3, SUB_DISTRICT_CODE)]

# Send result to console: data.table => stdout(console)
dt_res


text:
Q: Unexpected results using Repast Simphony I need to develop a Java version of the Iterated Prisoner Dilemma using Repast Simphony as simulator.
The ideas is that each Player is an agent, and we have a n x n grid of Player that can't be moved. Each Player has to play with 4 neighbours (northern, southern, western and eastern one), finding the best strategy based on the outcome of the 4 different games in each round.
Since there's not a built-in system to exchange messages between agents in Repast Simphony, I had to implement some kind of workaround to deal with agents' sync (A vs B and B vs A should count as the same round, that's why they need to be sync'ed).
This is done by seeing each round as:

*

*Player i chooses the next move for each of the 4 enemies

*Player i sends the correct move to each of the 4 enemies

*Player i waits for each of the 4 enemies to reply

From my understanding of Repast Simphony, scheduled methods are sequential (no agent-level parallelism), meaning that I'm forced to do the waiting in a different method from the send one (scheduled with lower pritority to ensure that all the sends are completed before starting the waits).
The issue here is that, despite receiving all the 4 expected messages (at least this is what gets printed), once the waiting method starts it reports less than 4 received elements.
Here's the code taken from Player class:
// myPoint is the location inside the grid (unique, agents can't move and only one per cell is allowed)
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((myPoint == null) ? 0 : myPoint.hashCode());
    return result;
}

// Returns enemy's choice in the previous round
private byte getLastPlay(Player enemy) {
    return (neighbors.get(enemy)[1]) ? COOPERATE : DEFECT;
}

// Elements are saved as (player, choice)
private void receivePlay(Player enemy, byte play) {
    System.out.println(this + " receives (" + play + ") from " + enemy);
    while (!playSharedQueue.add(new Object[] { enemy, play })){
        // This doesn't get printed, meaning that the insertion is successful!
        System.out.println(this + " failed inserting");
    }
}

@ScheduledMethod(start = 1, interval = 1, priority = 10)
public void play() {
    System.out.println(this + " started playing");
    // Clear previous plays
    playSharedQueue.clear();
    for (Player enemy : neighbors.keySet()) {
        // properties[0] = true if we already played together
        // properties[1] = true if enemy choose to cooperate on the previous round
        Boolean[] properties = neighbors.get(enemy);
        // Choose which side we take this time
        byte myPlay;
        if (properties[0]) {
            // First time that we play, use memory-less strategy
            myPlay = (Math.random() <= strategy[0]) ? COOPERATE : DEFECT;
            // Report that we played
            properties[0] = false;
            neighbors.put(enemy, properties);
        } else {
            // We already had a round, use strategy with memory
            byte enemyLastPlay = enemy.getLastPlay(this);
            // Choose which side to take based on enemy's previous decision
            myPlay = (Math.random() <= strategy[(enemyLastPlay) == COOPERATE ? 1 : 2]) ? COOPERATE : DEFECT;
        }
        // Send my choice to the enemy
        System.out.println(this + " sent (" + myPlay + ") to " + enemy);
        enemy.receivePlay(this, myPlay);
    }
}

// Waits for the results and processes them
@ScheduledMethod(start = 1, interval = 1, priority = 5)
public void waitResults() {
    // Clear previous score
    lastPayoff = 0;
    System.out.println(this + " waits for results [" + playSharedQueue.size() + "]");
    if (playSharedQueue.size() != 4) {
        // Well, this happens on the first agent :(
        System.exit(1);
    }
    // ... process ...
}

Here's the console output, so that you can see that everything seems to be sent and received without issues (used a 3 x 3 grid):
Player[2, 0] started playing
Player[2, 0] sent (0) to Player[2, 1]
Player[2, 1] receives (0) from Player[2, 0]
Player[2, 0] sent (0) to Player[2, 2]
Player[2, 2] receives (0) from Player[2, 0]
Player[2, 0] sent (0) to Player[0, 0]
Player[0, 0] receives (0) from Player[2, 0]
Player[2, 0] sent (0) to Player[1, 0]
Player[1, 0] receives (0) from Player[2, 0]
Player[1, 2] started playing
Player[1, 2] sent (1) to Player[2, 2]
Player[2, 2] receives (1) from Player[1, 2]
Player[1, 2] sent (1) to Player[0, 2]
Player[0, 2] receives (1) from Player[1, 2]
Player[1, 2] sent (1) to Player[1, 0]
Player[1, 0] receives (1) from Player[1, 2]
Player[1, 2] sent (1) to Player[1, 1]
Player[1, 1] receives (1) from Player[1, 2]
Player[0, 2] started playing
Player[0, 2] sent (1) to Player[2, 2]
Player[2, 2] receives (1) from Player[0, 2]
Player[0, 2] sent (1) to Player[0, 0]
Player[0, 0] receives (1) from Player[0, 2]
Player[0, 2] sent (1) to Player[0, 1]
Player[0, 1] receives (1) from Player[0, 2]
Player[0, 2] sent (1) to Player[1, 2]
Player[1, 2] receives (1) from Player[0, 2]
Player[0, 1] started playing
Player[0, 1] sent (1) to Player[2, 1]
Player[2, 1] receives (1) from Player[0, 1]
Player[0, 1] sent (1) to Player[0, 0]
Player[0, 0] receives (1) from Player[0, 1]
Player[0, 1] sent (1) to Player[0, 2]
Player[0, 2] receives (1) from Player[0, 1]
Player[0, 1] sent (1) to Player[1, 1]
Player[1, 1] receives (1) from Player[0, 1]
Player[1, 0] started playing
Player[1, 0] sent (0) to Player[2, 0]
Player[2, 0] receives (0) from Player[1, 0]
Player[1, 0] sent (0) to Player[0, 0]
Player[0, 0] receives (0) from Player[1, 0]
Player[1, 0] sent (0) to Player[1, 1]
Player[1, 1] receives (0) from Player[1, 0]
Player[1, 0] sent (0) to Player[1, 2]
Player[1, 2] receives (0) from Player[1, 0]
Player[1, 1] started playing
Player[1, 1] sent (0) to Player[2, 1]
Player[2, 1] receives (0) from Player[1, 1]
Player[1, 1] sent (0) to Player[0, 1]
Player[0, 1] receives (0) from Player[1, 1]
Player[1, 1] sent (0) to Player[1, 0]
Player[1, 0] receives (0) from Player[1, 1]
Player[1, 1] sent (0) to Player[1, 2]
Player[1, 2] receives (0) from Player[1, 1]
Player[2, 2] started playing
Player[2, 2] sent (0) to Player[2, 0]
Player[2, 0] receives (0) from Player[2, 2]
Player[2, 2] sent (0) to Player[2, 1]
Player[2, 1] receives (0) from Player[2, 2]
Player[2, 2] sent (0) to Player[0, 2]
Player[0, 2] receives (0) from Player[2, 2]
Player[2, 2] sent (0) to Player[1, 2]
Player[1, 2] receives (0) from Player[2, 2]
Player[0, 0] started playing
Player[0, 0] sent (1) to Player[2, 0]
Player[2, 0] receives (1) from Player[0, 0]
Player[0, 0] sent (1) to Player[0, 1]
Player[0, 1] receives (1) from Player[0, 0]
Player[0, 0] sent (1) to Player[0, 2]
Player[0, 2] receives (1) from Player[0, 0]
Player[0, 0] sent (1) to Player[1, 0]
Player[1, 0] receives (1) from Player[0, 0]
Player[2, 1] started playing
Player[2, 1] sent (1) to Player[2, 0]
Player[2, 0] receives (1) from Player[2, 1]
Player[2, 1] sent (1) to Player[2, 2]
Player[2, 2] receives (1) from Player[2, 1]
Player[2, 1] sent (1) to Player[0, 1]
Player[0, 1] receives (1) from Player[2, 1]
Player[2, 1] sent (1) to Player[1, 1]
Player[1, 1] receives (1) from Player[2, 1]
Player[2, 2] waits for results [1]

As you can see in the last line, playSharedQueue.size() is 1 and I really don't understand why.
If methods invocation are sequential the waitResults()methos is invoked after the 9play()` executions, and given that each of the correctly sends 4 messages, I can't find a reason why that size is still 1.
Of course being everything sequential means that there are no synchronization issues, even if I had the same problem using LinkedBlockingQueue instead of HashSet.
Do you guys have any hint on this?

A: After some time I opened the code again and I found out that I was doing a simple, yet serious mistake:
@ScheduledMethod(start = 1, interval = 1, priority = 10)
public void play() {
    System.out.println(this + " started playing");
    // Clear previous plays
    playSharedQueue.clear();

The playSharedQueue.clear(); is executed to clear out the previous results, but since invocations are sequential the second player will call it after the first one sent him his play, so that play is discarded.
Moving that line at the end of waitResults solved it.


text:
Q: Content of SSL Certificate CA bundle file can be called CERTIFICATE (CHAINED) for Runcloud Custom SSL/TLS Hi i am trying to secure my website with ssl from namecheap they sent me zip file that contain three files CA bundle File, Security Certificates and PKCS #7 Certificates
I am using runcloud.io for server managment. they have SSL/TLS section.
screenshot below
runcloud ssl/tls
They need two Things to implement SSL. one is PRIVATE KEY and Other is CERTIFICATE (CHAINED). I already have PRIVATE KEY that i generated during CSR file creation. My question is what will be content of CERTIFICATE (CHAINED). Should i put content of CA bundle File ? or CERTIFICATE (CHAINED) is not same as CA bundle File it is something else ?
My Server is Ubuntu 18.04 and Ngnix + Apache Thanks

A: Hi Finally figured out way,
Sectigo formerly called Comodo Knowledge Base Helps me,
So For CERTIFICATE (CHAINED) I had to combine the content of both CA bundle File, Security Certificates (a.k.a .crt File) Paste the content of .crt File on top then after that content of CA bundle File. It will be then your CERTIFICATE (CHAINED)


text:
Q: Does $\Sigma$ generate the variety of all groups? Suppose $FT$ is the class of all isomorphism classes of finite T-groups (a T-group is a group, where all subnormal subgroups are normal). Define, $\Sigma$ as the set of all functions $f$ from $FT$ to $\mathbb{Z}$, such that $f(E) = 1$, where $E$ is the trivial group. Now, if $f, g \in \Sigma$, define $$(f \ast g) (G)= \Sigma_{H \triangleleft G} f(H)g(\frac{G}{H}).$$
It is not hard to see, that $(\Sigma, \ast)$ is a group:
$f \ast (g \ast h) = \Sigma_{K \triangleleft H \triangleleft G} f(K)g(\frac{H}{K})h(\frac{G}{H}) = (f \ast g) \ast h$
The function $e$, such that $e(E) = 1$ and $e(G) = 0$ for any non-trivial $G$, is the identity element.
The inverse to $f$ is the function $f^{-1}$ satisfying the recurrent relation $\Sigma_{H \triangleleft G} f(H)f^{-1}(\frac{G}{H}) = 0$ and $f^{-1}(E) = 1$.
Moreover, it is quite easy to prove that this group is torsion-free:
Suppose $f \in \Sigma$, $G$ is the nontrivial group of minimal order, such that $f(G) \neq 0$. Then $\forall H \triangleleft G$ if $H \neq G$ and $H \neq E$, then $f(H) = 0$ (as $|H| \leq |G|$). Then $f^n(G) = f(G) + f^{n-1}(G) = nf(G) \neq 0$. That means $\forall n \in \mathbb(N)  f^n \neq e$
Personally, I think that this group is also very likely to generate the variety of all groups. However, I do not know how to prove that.
First, I wanted to show, that every marginal subgroup corresponding to a proper variety is trivial in $\Sigma$. However, I failed even to prove that $Z(\Sigma) \cong E$.
Then I thought, that maybe I have to find a subgroup of $\Sigma$ isomorphic to $F_2$ (a free group to two generators). However, I failed in that direction too.


text:
Q: Condition inside getAll for compound index what will be the equivalent query for
select * from emails where to="someemail" and from="some@email"

need to use get instead of filter

A: getAll is your friend:

table.getAll([key, key2...], [, {index:'id'}]) → selection

Assuming that you have a compound key index, something like:
r.db('emails')
    .table('emails')
    .indexCreate('conversation', [r.row('from'), r.row('to')])

you can easily get all emails:
r.db('emails')
    .table('emails')
    .getAll(['some@email', 'someemail'], {index: 'conversation'})

For example, having the following dataset
r.db('emails')
    .table('emails')
    .insert([
        {from: 'foo@mail', to: 'bar@mail', text: 'Hi Bar!'},
        {from: 'bar@mail', to: 'foo@mail', text: 'Hi Foo!'},
        {from: 'foo@mail', to: 'bar@mail', text: 'Bye Bar!'},
        {from: 'bar@mail', to: 'foo@mail', text: 'Bye Foo!'}
    ])

that's queried with the following query
r.db('emails')
   .table('emails')
   .getAll(['foo@mail', 'bar@mail'], {index: 'conversation'})
   .pluck('text')

will produce:
[
    {"text": "Bye Bar!"},
    {"text": "Hi Bar!"}
]

(The order above is undefined.)


text:
Q: Objective c : How to set time and progress of uiprogressview dynamically? Say I have a UIProgressBar with size (394,129,328,9) and I increased the height with
CGAffineTransform transform = CGAffineTransformMakeScale(1.0f, 3.0f);
PgView.transform = transform;

What I need to implement is : If I have 5 minute time,the progressView should be filled with a certain amount and totally filled at the end of 5 minute. Same for 1 minute and 30 minutes too.
I am implementing like this :
-(void)viewWillAppear:(BOOL)animated
{
    CGAffineTransform transform = CGAffineTransformMakeScale(1.0f, 3.0f);
    PgView.transform = transform;

    recievedData = 0.01;
    xpectedTotalSize = 1.0;
    PgView.progress = 0.0;
    [self performSelectorOnMainThread:@selector(makeMyProgressBarMoving) withObject:nil waitUntilDone:NO];
}

- (void)makeMyProgressBarMoving
{
    float actual = [PgView progress];
    if (actual < 1)
    {
        PgView.progress = actual + ((float)recievedData/(float)xpectedTotalSize);
        [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(makeMyProgressBarMoving) userInfo:nil repeats:NO];
    }
    else{

    }
}

And it works. But I want to implement progress and time interval dynamically? Any idea??
Thanks in advance.

A: It's difficult to understand your intention. As I suppose, you want to update the progress bar only if new values are available instead of updating with a fixed timer interval.
This would result in the simple answer: update your progress bar whenever you change the value of 'recievedData'. So, the method 'makeMyProgressBarMoving' doesn't need a timer. Also, you don't need to remember the 'actual' value. You can directly assign the 'receivedData/xpectedTotalSize' to the progress bar.
- (void) updateProgressBar
{
    PgView.progress =  ((float)receivedData/(float)xpectedTotalSize);
}

- (void) updateReceivedData
{
    if (receivedData < 20)
        receivedData += 1.0;
    else
        receivedData += 10.0;

    [self updateProgressBar];
}

-(void)viewWillAppear:(BOOL)animated
{
    receivedData = 0.0;
    xpectedTotalSize = 100.0;

    [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateReceivedData) userInfo:nil repeats:YES];
}

Now, a timer is still used for demonstration to call 'updateReceivedData' which just increments 'receivedData' and calls 'updateProgressBar'. As you see, 'updateReceivedData' does not increment linear, again just for demonstration. If 'updateReceivedData' would be called on demand instead by the timer then also the progress bar would be updated on demand. Now it's just an issue of how and when you want to update your receivedData. It's not an issue regarding progress bars.


text:
Q: Array re-order keeping current value in same index I have an array -
Array
    (
        [1] => 10890.000
        [2] => 3751.000
        [0] => 0
        [3] => 0
        [4] => 0
        [5] => 0
        [6] => 0
        [7] => 0
    )

how can i re-order this keeping the current values under the same index. such as following-
Array
(
    [0] => 0
    [1] => 10890.000
    [2] => 3751.000
    [3] => 0
    [4] => 0
    [5] => 0
    [6] => 0
    [7] => 0
)

i already tried array_values() but it does not return expected output


text:
Q: Crux problem #39 with vectors approach
It's given a point $P$ inside an equilateral triangle $ABC$ such as segment lengths $PA$, $PB$, $PC$ are $3$, $4$ and $5$ units respectively. Calculate the area of
$\triangle ABC$.

So, let $b:=\overrightarrow{AB},\,c:=\overrightarrow{AC},\,
\overrightarrow{AP}=xb+yc$,
$$\begin{cases}
(\overrightarrow{AP})^2&=x^2b^2+y^2c^2+2xybc=9\\
(\overrightarrow{AP}-\overrightarrow{AB})^2&=(x-1)^2b^2+y^2c^2+2(x-1)ybc=16\\
(\overrightarrow{AP}-\overrightarrow{AC})^2&=x^2b^2+(y-1)^2c^2+2x(y-1)bc=25
\end{cases}$$
As we have equilateral triangle, $b^2=c^2=2bc=:\frac{1}{a^2}$, then
$$\begin{cases}
x^2+y^2+xy=9a^2\\
(x-1)^2+y^2+(x-1)y=16a^2\\
x^2+(y-1)^2+x(y-1)=25a^2
\end{cases}$$
$$\begin{cases}
x^2+y^2+xy=9a^2\\
-2x+1-y=7a^2\\
-2y+1-x=16a^2
\end{cases}$$
$$\begin{cases}
x^2+y^2+xy=9a^2\\
-2x+1-7a^2=y\\
-2(-2x+1-7a^2)+1-x=16a^2
\end{cases}$$
$$\begin{cases}
9x^2+9y^2+9xy=81a^2\\
-2x+1-7a^2=y\\
3x-1=2a^2
\end{cases}$$
$$\begin{cases}
(2a^2+1)^2+(1-25a^2)^2+(2a^2+1)(1-25a^2)=81a^2\\
y = \frac{1 - 25 a^2}{3}\\
x=\frac{2a^2+1}{3}
\end{cases}$$
$$193 a^4 - 50 a^2 +1=0$$
$$\left[
\begin{array}{l}
\begin{cases}
a^2 = \frac{1}{193}\left(25 - 12 \sqrt{3}\right)\\
x = \frac{1}{193}\left(81 - 8 \sqrt{3}\right)\\
y = \frac{4}{193}\left(25 \sqrt{3} - 36\right)
\end{cases}\\
\begin{cases}
a^2 = \frac{1}{193}\left(25 + 12 \sqrt{3}\right)\\
x = \frac{1}{193}\left(81 + 8 \sqrt{3}\right)\\
y = -\frac{4}{193}\left(25 \sqrt{3} + 36\right)
\end{cases}
\end{array}
\right.$$
The second case doesn't fit as $y<0$, then we have
$$S_{ABC}=\frac{\sqrt{3}}{4a^2}=\frac{1}{4} \left(36 + 25 \sqrt{3}\right)$$
Although there are two solutions given in [Crux Vol. 1, No. 7][1] (pp. 64-66), I wonder is there more neat geometrical solution?

A: Rotate The whole figure about $B$ anticlockwise by $\pi/3$ radians and assume  $P$ moves to $P'$ then $PP'B$ is equilateral and since $C$ moves to $A$ ,   $APP'$ is a $3-4-5$ triangle.
Now you easily calculate $AB$ from $AP'B$ by cosine rule.

A: Set the triangle with $A(0,0)$, $B(0,z)$ and $ C(z/2, z\sqrt{3}/2)$, where $z$ is the side length (this is the same orientation of the figure in the OP). Call $x$ and $y$ the coordinates of $P$. Now you can solve the problem nearly in one step by solving the following system in three variables, where the equations express the distances of $P$ from the vertices:
$$\displaystyle\left\{ \begin{array}{ll}
                  (x^2+y^2)=9\\
                  (z-x)^2+y^2=16\\
                  (z/2-x)^2+(z\sqrt{3}/2-y)^2=25
                \end{array}
              \right.
 $$
Solving the system and taking the only solution where $x$, $y$, and $z$ are all positive  directly leads, after some simplification of the radicals, to
$$z = (14 \sqrt{3} - 3) \sqrt{\frac{1}{579} (31 + 16 \sqrt{3})}\\
=  \sqrt{25+12\sqrt{3}}$$
as confirmed by WA here and here.
From this we easily obtain
$$S= \frac{\sqrt{3}}{4}  (25+12\sqrt{3})\\
=\frac{1}{4} (36 + 25 \sqrt{3})  $$


text:
Q: Property of modulo congruation If I have:
$$a^b \equiv 1 \mod xy$$
where $x,y$ are primes,
is then true that:
$$ a^b \equiv 1 \mod x$$
$$ a^b \equiv 1 \mod y$$
I don't sure if this is true, because I don't know how can I prove it

A: $x = 1 \pmod {y(z+1)} \implies x = 1 \pmod {z+1}, \ = 1 \pmod y$.  Similarly, $ x = 1 \pmod {y(z+k)} \implies x = 1 \pmod{y}, \pmod{z+k}$.  Simlarly for any polynomial in $\Bbb{Z}[x_1, \dots, x_k], \ \ p(\bar{x}) = \ p_1(\bar{x}) \cdots p_n(\bar{x}), $ we have that if $z = z' \pmod {p(\bar{y})}$, then $z = z' \pmod{p_i(\bar{y})}, \ \forall i=1\dots n$.


text:
Q: Why is the drawContour() in OpenCV generating this strange Mask? I started by reading in this Mat.

Then I converted it to Greyscale and applied Imgproc.canny() to it, getting the following mask.

Then I used Imgproc.findContours() to find the contours, Imgproc.drawContours(), and Core.putText() to label the contours with numbers:

Then I did Rect boundingRect = Imgproc.boundingRect(contours.get(0));
        Mat submatrix = new Mat();
        submatrix = originalMat.submat(boundingRect); to get following submatrix:

So far so good. The Problem starts hereafter:
NOW I NEEDED A MASK OF THE submatrix. So I decided to use Imgproc.drawContours() to get the mask:
Mat mask = new Mat(submatrix.rows(), submatrix.cols(), CvType.CV_8UC1);
        List<MatOfPoint> contourList = new ArrayList<>();
        contourList.add(contours.get(0));
        Imgproc.drawContours(mask, contourList, 0, new Scalar(255), -1);

I got the following mask:

WHAT I WAS EXPECTING was a filled (in white color) diamond shape on black background.
WHy am I getting this unexpected result?

EDIT:

*

*When I replaced Mat mask = new Mat(submatrix.rows(),
submatrix.cols(), CvType.CV_8UC1); by Mat mask =
Mat.zeros(submatrix.rows(), submatrix.cols(), CvType.CV_8UC1);,
the last mask with white colored garbage was replaced by an empty
black mask withOUT any white color on it. I got the following submat
and mask:

*I was getting the first contour in the list of contours (named
contours) by contours.get(0), and using this first contour to
calculate Imgproc.boundingRect() as well as in
contourList.add(contours.get(0)); later (where contourList is
the list of just one contour which will be used in the last
drawContours()).
Then I went ahead to change contours.get(0) to
contours.get(1) in Imgproc.boundingRect() as well as in contourList.add(); (just before Imgproc.drawContours()). That
resulted in this submat and mask:

*Then I changed back to contours.get(0) in
Imgproc.boundingRect(); and let
contourList.add(contours.get(1)); be there. Got the following
submat and mask:

NOW I am completely Unable to Understand what is happening here.

A: I am not sure how this is handle in JAVA (I usually use OpenCV in c++ or python), but there is an error in your code...
The contours list will have a list of list of points. This points will refer to the original image. So, this mean that if the figure one is in lets say, x=300, y= 300, width= 100, height=100 then when you get your submatrix it will try to draw those points in a smaller image... so when it tries to draw point (300,300) in a 100 x 100 image, it will simply fail... probably throws an error or simply doesn't draw anything...
A solution for this is, do a for loop and substract to each point of the contour the initial point of the bounding rect (in my example (300,300)).
As, why there is some garbage drawn... well you never initialize the matrix. Not sure in JAVA, but in c++ you have to set them to 0.
I think it should be something like this:
Mat mask = new Mat(submatrix.rows(), submatrix.cols(), CvType.CV_8UC1, new Scalar(0));

I hope this helps :)
EDIT
I think I did not explain myself clearly before.
Your contours are an array of points (x,y). These are the coordinates of the points that represent each contour in the original image. This image has a size, and your submatrix has a smaller size. The points are outside of this small image boundaries....
you should do something like this to fix it:
for (int j = 0; j < contours[0].length; j++) {
    contours[0][j].x -= boundingrect.x;
    contours[0][j].y -= boundingrect.y;
}

and then you can draw the contours, since they will be in boundaries of the submat.
I think in java it is also possible to subtract the opencv points directly:
for (int j = 0; j < contours[0].length; j++) {
    contours[0][j] -= boundingrect.tl();
}

but in this case I am not sure, since I have tried it in c++ only
boundingrect.tl() -> gives you the top left point of the rect


text:
Q: What are ways to run a MySQL query in PHP and output the result to an array in less space? I'm getting really tired of writing:
$rows = array();
$result = $db->query("SELECT * FROM `table` WHERE `field`='".$information."'");
while($row = $result){
    $rows[] = $row;
}

I tried a function, but it was kinda of messy feeling changing the input to field inputs. I thought maybe this or something similar would help:
$rows = array();
while($row = ($db->query("SELECT * FROM `table` WHERE `field`='".$information."'"))->fetch_assoc()){
    $rows[] = $row;
}

but I get unexpected T_OBJECT_OPERATOR. I'm still on the line about using a function. Maybe there's a more efficient way of writing one. This is how I tried writing a function:
$array = SELECT ($db,$toSelect,$table,$where);

It still seems cumbersome, however. I would like something like $array = $db->("MYSQL");

A: *

*The simplest solution is to write a function, which expects a database handle and a string query parameter, and returns all the rows.
$rows = fetch_all($db, "SELECT ...");

*A bit more advanced is to write your own database class which wraps the database handle and adds such functionality.
$rows = $mydb->fetch_all("SELECT ...");

*If you don't want to reinvent the wheel, simply use an existing ORM / PHP database library which does all this (and more) for you.
$db
    ->select('*')
    ->from('table')
    ->where('field', $information);
Note: http://www.php.net/manual/en/security.database.sql-injection.php - the third solution automatically solves this problem.


text:
Q: Article or no article: "at the price of a higher workload"? The finer points (the infamous 10%?) of when to use indefinite articles still manage to elude me sometimes. Does the article "a" belong in the following sentence or not?

However, [foo] yields [bar] at the price of a higher workload for [baz].

Bonus question: Which rule applies here?

A: The object of the preposition ("workload") is singular, so yes, the article works there. If you were speaking of a quantity, however, you wouldn't use the article:

... at the price of more working hours for [baz].


text:
Q: Propel is losing parameters to a query ->where("((Job.TwCountry = ? AND Job.TwAbroad = 1) OR (Job.TwCountry != ? AND Job.TwCountryTarget LIKE \"%?%\"))", array($site,$site,$site))

is part of a Propel 1.7 query. As you can see, the three parameters are the same. This does not work, here is the error:
Invalid parameter number: number of bound variables does not match number of tokens

As far as I can tell, the intermediary Propel representation uses the same array keys for all three parameters, thereby losing the fact that they should map to three different PDO parameters. Is there a way round this?

A: Here is my guess:
->where(
    "((Job.TwCountry = ? AND Job.TwAbroad = 1) OR (Job.TwCountry != ? AND Job.TwCountryTarget LIKE %?%))",
    array($site,$site,$site)
)

The difference is that this Propel method is type-aware, and so will quote your LIKE parameter automatically.

A: Move your wildcard characters from the query, and placed it on the parameter instead:
->where("((Job.TwCountry = ? AND Job.TwAbroad = 1) OR (Job.TwCountry != ? AND Job.TwCountryTarget LIKE ?))", array($site,$site,'%' . $site . '%'))


text:
Q: Concatenate only when all values are true in mysql The following is the query I have used to concatenate siretagprefix and siretagsec
CONCAT('TZN',
            `adggtnz`.`reg04_rpt_animreg`.`siretagprefix`,
            `adggtnz`.`reg04_rpt_animreg`.`siretagsec`) AS `siretagid`,

The result of the query when siretagprefix and siretagsec when the values are null, I get TZN as the result. How can I concatenate only when all the values are true.

A: You could use CASE to check your column values
CASE WHEN `adggtnz`.`reg04_rpt_animreg`.`siretagprefix` IS NOT NULL
      AND `adggtnz`.`reg04_rpt_animreg`.`siretagsec` IS NOT NULL
THEN
    CONCAT('TZN',
                `adggtnz`.`reg04_rpt_animreg`.`siretagprefix`,
                `adggtnz`.`reg04_rpt_animreg`.`siretagsec`)
ELSE NULL END AS siretagid

A: You could use a case expression:
CASE WHEN `adggtnz`.`reg04_rpt_animreg`.`siretagprefix` IS NOT NULL AND
          `adggtnz`.`reg04_rpt_animreg`.`siretagsec`    IS NOT NULL
     THEN CONCAT('TZN',
                 `adggtnz`.`reg04_rpt_animreg`.`siretagprefix`,
                 `adggtnz`.`reg04_rpt_animreg`.`siretagsec`)
END AS `siretagid`


text:
Q: Java LocalDateTime giving different output on different servers. Same timezone configurations I Have a simple program that just outputs the time but I am getting different results on different Linux Distros.  I verified that the default timezone is set property and on SuSe I get my default timezone but on Ubuntu I get UTC time.  I can't figure out why.
Here is the code
import java.time.LocalDateTime;

public class Main {
    public static void main(String[] args) {
        LocalDateTime nowTime = LocalDateTime.now();
        System.out.print(nowTime);
    }
}

On my Suse (& Windows) server this is my output
/home/user/test # timedatectl
      Local time: Sat 2020-04-11 12:18:49 PDT
  Universal time: Sat 2020-04-11 19:18:49 UTC
        RTC time: Sat 2020-04-11 19:18:49
       Time zone: America/Los_Angeles (PDT, -0700)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no
/home/user/test # java Main
2020-04-11T12:18:51.461

Then on my Ubuntu Distro
/home/user/test# timedatectl
                      Local time: Sat 2020-04-11 12:19:53 PDT
                  Universal time: Sat 2020-04-11 19:19:53 UTC
                        RTC time: Sat 2020-04-11 19:19:53
                       Time zone: America/Los_Angeles (PDT, -0700)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no
/home/user/test# java Main
2020-04-11T19:19:57.232828

What do I have to do to make sure the output is consistent no matter what OS I deploy this code on?
Edit:
Upon adding another line of code to check what Timezone java is using this is what I got
System.out.println(java.util.TimeZone.getDefault().getDisplayName());
Suse => Pacific Standard Time
Ubuntu => Coordinated Universal Time
So now I need to figure out why it's using a different timezone

A: Something must of been wrong with the timezone setup on the Ubuntu server.  I re-ran the timezone configuration tool and everything works fine now
dpkg-reconfigure tzdata


text:
Q: how to display .json file contents from an absolute path of client's computer I have come accross the following html5 code which selects the .json from from local file system and displays its contents.
     But I need help in selecting the json file (without file upload dialog) from the pre-defined absolute path "C:\data.json"
<!DOCTYPE html>

  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>On loaded file + AngularJS</title>

Select text file

    <input type="file" on-read-file="showContent($fileContent)" />

File content is:

{{ content }}

A: What you're asking effectively is reading a local file without the client's explicit permission (having once being selected doesn't count), which has been avoided by design as it obviously introduces many kinds of threats. ;-)
It seems impossible to be done in any formal way. If you could explain on your actual goal, we might be able to suggest a different way.


text:
Q: How to extract current time in HH:mm format without converting into string in asp.net mvc? I need to get current time in TimeSpan data type (not in string) in the format HH:mm (only hour and minute parameters).
I have written the following code:
AdminRequestTime = DateTime.Now.TimeOfDay

Here the data-type of AdminRequestTime is TimeSpan. It gives the value 15:52:28.2843710, but I only want 15:52.
How do I do this (preferably without using parse)?

A: A timespan doesn't have a format, it just contains the data to represent a timespan. The base unit there is ticks.
What you're asking is incompatible: you want a timespan, but you also want a specific format.
If what you're asking is how to format the current time of day in HH:mm, you can achieve that like this:
Console.WriteLine(DateTime.Now.ToString("HH:mm"));

If what you're asking is how to create a timespan that only has the hour and minute component, try this:
var x = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, 0);
Console.WriteLine(x); // Outputs 15:52:00

A: try this:
AdminRequestTime =  new TimeSpan(DateTime.Now.TimeOfDay.Hours, DateTime.Now.TimeOfDay.Minutes, 0)


text:
Q: How can I center this JQuery dialog? I was using a JQuery dialog like this: $(thisDialog).dialog(); until I learned that it doesn't like IE9 Quirks mode and doctype strict is not an option because of legacy code, how can I center the popup from this example?
http://jsfiddle.net/46jYC/3/

A: A jQuery solution, considering the modal-dialog is position absolute/relative/fixed:
var windowHeight = $(window).height();
var windowWidth = $(window).width();
var boxHeight = $('.modal-dialog').height();
var boxWidth = $('.modal-dialog').width();
$('.modal-dialog').css({'left' : ((windowWidth - boxWidth)/2), 'top' : ((windowHeight - boxHeight)/2)}); //change selector to whatever your selector is :)

A jQuery solution, considering the modal-dialog is not position absolute/relative/fixed:
css:
margin-left: auto;
margin-right: auto;

jquery:
var windowHeight = $(window).height();
var boxHeight = $('.modal-dialog').height();
$('.modal-dialog').css({'margin-top' : ((windowHeight - boxHeight )/2)});  //change selector to whatever your selector is :)

A: You should write something like this:
function abrirPopup(url,w,h) {
    var newW = w + 100;
    var newH = h + 100;
    var left = (screen.width - newW) / 2;
    var top = (screen.height - newH) / 2;
    var newwindow = window.open(url, 'name', 'width=' + newW +
            ',height=' + newH + ',left=' + left + ',top=' + top);
    newwindow.resizeTo(newW, newH);

    //posiciona o popup no centro da tela
    //(position the popup in the center of the canvas)
    newwindow.moveTo(left, top);
    newwindow.focus();
    return false;
}

HTML:
Google