PCA followed by Wilcoxon-Mann-Whitney test on PC1: is it problematic?

Question: I have two groups of animals and 60 to 100 variables per animal (describing their behavior during 24h). I want to know whether the two groups of animals behave differently (I have 11 data points per group), and I do not care much about knowing what is different.
I started by doing a SVM followed by a permutation to assess the accuracy of the SVM statistically. Got a good accuracy (5/6 correct prediction) but it is far from getting to the significant threshold (p>0,2), due to the over-dispertion of the distribution of accuracy scores, probably linked to the the low sample size.
Now I am wondering about a most simpler approach: making a PCA and do a basic wilcox test on the first component (keeping p<0.05 as the threshold, since I am doing only one test). I think it is allowed: since the PCA does not use the grouping variable, it will treat inter- and between- groups variance similarly. The fact that the p-value with 11 animals per group is super super low make me wonder if I do not make any wrong assumption here.
Comment: What you're calling a Wilcox test is presumably Wilcoxon-Mann-Whitney. At a guess you used R: the truncated name there presumably arose from a mistaken preference for brevity -- or perhaps because some prankster wanted to sprinkle minor confusion in the literature.
Comment: sorry, you guessed right for R, I edited the title.
Answer:
Your PCA technique might miss the difference between the groups: That is because it focuses on the total variation rather than the variation between the groups.
If you are focused on exploring/picking-out a difference between the groups, then a linear discriminant analysis (LDA) might be a better (stronger) tool.
But since you started with SVM (support vector networks?) instead of MANOVA/LDA I wonder if you have some restrictions that made you choose a non-linear technique? PCA is not helping on  such issues that  much.
See the image below for a simple example that expresses these effects. The largest variations in the variables between groups (e.g. a total of var1 + var2) might be perpendicular to the differences within the groups (e.g. a distribution among var1 and var2).

Aside from this limitation in power your PCA technique is robust regarding type I errors. Given the null hypothesis that 'the two groups are the same', then you could sample from a single distribution, perform PCA, and assign groups afterwards. So the PCA can't have any effect, if the null hypothesis is true.
Comment: While I said that your PCA+WMW technique is 'robust regarding type I errors', the fact that you already did some other analysis, and now are looking for something different (probably because the previous result did not make you happy), makes your approach as a whole *not* robust (the approach to try multiple things until finding something significant makes it more likely to find something significant). At best you can analyze if something went wrong with the SVM. Also, given the small sample, you can report differences, while not caring about significance (let the next experiment do that).
Comment: Thanks,
That is what I thought, but the results made me doubt myself. Since I have many variables for few animals, I was afraid a manova would be too prompt in type 2 errors and I indeed started with svm hoping to get a technique that would not miss existing difference with less false positive. I was very surprised to see that the SVM could not make significant prediction, while the PCA first discrimant was so much different in the 2 groups. I think this is due to a big difference in the spread of the data, but a large overlap, which becomes overrepresented using prediction on 6 animals.
Comment: And thank you for the reminder about robustness, I am working with a positive control now (young versus old animals), trying to find the best strategy to apply to future experiments. So I am safe there :)

It is behavior, so some non-linearity is to be expected, but in real, we just do not know.


show :target popup on page load With PURE CSS

Question: I know this is basic question. But I can't go through it.
I just have the code for a popup in Pure CSS and it pops up on clicking a link  tag.
I want this popup to be loaded on page load using either jquery or Pure JS.
Note that in CSS I have made the value of ".overlay" class's visibilty to none and on clicking changes to visible.
I have tried to trigger a click on page load and changing the visibility on page load. Unfortunately both fails.
I have added the code snippet. Help me Friends.

$(document).ready(function() {
    $("#popup1").trigger('click');
});
.overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  transition: opacity 500ms;
  visibility: hidden;
  opacity: 0;
}
.overlay:target {
  visibility: visible;
  opacity: 1;
}

.popup {
  margin: 70px auto;
  padding: 20px;
  background: #fff;
  border-radius: 5px;
  width: 30%;
  position: relative;
  transition: all 5s ease-in-out;
}

.popup h2 {
  margin-top: 0;
  color: #333;
  font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
  position: absolute;
  top: 20px;
  right: 30px;
  transition: all 200ms;
  font-size: 30px;
  font-weight: bold;
  text-decoration: none;
  color: #333;
}
.popup .close:hover {
  color: #06D85F;
}
.popup .content {
  max-height: 30%;
  overflow: auto;
}

  Let me Pop up

Notification

    ×

      App is under-construction.
      But payment on referral income has started.
      Please stay tuned.

Comment: Doing this instead works for me: `location.href += "#popup1";`
Comment: Got the answer.. Thanks For Everyone to take time for answering this out.
Comment: I'm confused. Do you want a solution that uses "PURE CSS" as per your title, or "jquery or pure JS" as per the second sentence in the body of your question?
Answer: If you want to use Javascript for sure, you can achieve this by setting the hash manually:

$(document).ready(function() {
  window.location.hash = "#popup1";
});
.overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  transition: opacity 500ms;
  visibility: hidden;
  opacity: 0;
}
.overlay:target {
  visibility: visible;
  opacity: 1;
}

.popup {
  margin: 70px auto;
  padding: 20px;
  background: #fff;
  border-radius: 5px;
  width: 30%;
  position: relative;
  transition: all 5s ease-in-out;
}

.popup h2 {
  margin-top: 0;
  color: #333;
  font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
  position: absolute;
  top: 20px;
  right: 30px;
  transition: all 200ms;
  font-size: 30px;
  font-weight: bold;
  text-decoration: none;
  color: #333;
}
.popup .close:hover {
  color: #06D85F;
}
.popup .content {
  max-height: 30%;
  overflow: auto;
}

Notification

    ×

      App is under-construction.
      But payment on referral income has started.
      Please stay tuned.

Comment: @HarishST `window.location.hash` is the part after the URL with the `#` symbol. The CSS `:target` selector is active whenever the hash in the URL matches the `id` of that particular element.
Comment: window.location.hash means ?
Comment: It doesn't work .. I need the popup to come on pageload
Comment: Hey... Sorry It Works.. I have added the script at the bottom of my page and it works..
Comment: Thank you so much for this fast and simple solution
Answer:

$(document).ready(function() {
   var href = $('#btn').attr('href');
 window.location.href = href;
});
.overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  transition: opacity 500ms;
  visibility: hidden;
  opacity: 0;
}
.overlay:target {
  visibility: visible;
  opacity: 1;
}

.popup {
  margin: 70px auto;
  padding: 20px;
  background: #fff;
  border-radius: 5px;
  width: 30%;
  position: relative;
  transition: all 5s ease-in-out;
}

.popup h2 {
  margin-top: 0;
  color: #333;
  font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
  position: absolute;
  top: 20px;
  right: 30px;
  transition: all 200ms;
  font-size: 30px;
  font-weight: bold;
  text-decoration: none;
  color: #333;
}
.popup .close:hover {
  color: #06D85F;
}
.popup .content {
  max-height: 30%;
  overflow: auto;
}

  Let me Pop up

Notification

    ×

      App is under-construction.
      But payment on referral income has started.
      Please stay tuned.


What does it mean for a solution to be regular (Legendre equation)?

Question: For example, Wikipedia says:

When $n$ is an integer, the solution $P_{n}(x)$ that is regular at $x = 1$ is also regular at $x =−1$, and the series for this solution terminates (i.e. it is a polynomial).

What is 'regular' in this context?
Answer: Regular means that the function is not singular in the point mentioned; singular points being the ones where you divide by zero. Of course there are singular points of functions that may be resolved, for instance $f(x)=\frac{x}{x}$, but other functions have singular points that cannot be resolved, like $f(x)=\frac{1}{x}$ or indeed the other solutions of the Legendre differential equation, for example $Q_0(x)=\frac{1}{2}ln(\frac{1+x}{1-x})$, which is singular (not regular) in $x=1$


received status code 400 invalid value 'ipaddress' for no_key

Question: i use chef-api for express js  and i wanna get only the ip address of node " server 1 " from a chef-server
im sending a request like this
Code  :

chef.partialSearch("node", "name:server1",{"ip":"ipaddress"} ,function(err, res){

  if (err){console.log(error);}

  else{console.log(res);}

});

Or

chef.partialSearch("node", { q: "name:server1"} ,{"ip":"ipaddress"} ,function(err, res){
....
});

=>  Response :
received status code 400 invalid  value 'ipaddress' for no_key

function in code source :

partialSearch: function(index, qs, data, fn){
            http_methods.post([config.host_url, "search", index].join("/"), qs, data, function(err, response){
                return fn(err, response);
            });
        }

and i cant understand the correct syntax for the request (http) from the official website doc api_chef_server
Can you please give a valid syntax with example .
Thanks
Comment: Are you always planning to access a single node at a time?
Answer: What you probably want is something like this:
chef.getNode('server1', function(err, node) {
    if(err) throw err;
    console.log(node.automatic.ipaddress);
});

Comment: Thanks you for your reply , and yes its a solution if you wanna request for only one server but if you wanna get all " ipaddress " for all servers belongs to a " role " isnt a good pratice for the performance of your chef-server and even the time reply of the application
take a look
http://dougireton.com/blog/2013/01/19/get-chef-clients-by-version/
and
http://engineering.voxer.com/2013/03/22/chef-part-2-performance/
and i found the correct syntax , Thanks again for your reply :D
Comment: That is correct, which is why I asked if you understated your use case :)
Answer: Finaly i found the correct syntax for both request
Simple Search :

    chef.search("node", {q: "name:server1" }, function(err, res){

       if (err){console.log(error);}

       else{console.log(res);}

     });

Partial Search :

chef.partialSearch("node", "chef_environment:prod", { name: ['name'] , 'ipaddress': ['ipaddress'] }, function(err, res){

        if (err){console.log(error);}

        else{console.log(res);}

    });

Hope this can help someone else who is still looking .


db_select with subquery including conditions from 2 tables

Question: I spent much time without success to search how to convert with db_select the following query, running perfectly with db_query :
    SELECT *
    FROM job_orders j
    WHERE j.statut = 'To do'
    AND j.job
    IN ( SELECT r.job
    FROM referential r
    WHERE r.category = j.category
    AND r.label = :label
    AND r.activity = :activity ),
    array(':label' => $label, ':activity' => $activity);

Here is the corresponding (?) db_select query I wrote :
$subquery = db_select('referential', 'r')
    ->fields('r', array('job'))
    ->condition('r.category', 'j.category')
    ->condition('r.label', $label)
    ->condition('r.activity', $activity);

$query = db_select('job_orders', 'j')
    ->fields('j')
    ->condition('j.statut', 'To do')
    ->condition('j.job', $subquery, 'IN');
$results = $query->execute();

I got no result with this db_select query, while I got answers with the db_query one... could somebody tell me what is wrong in my db_select query ?
Thank you.
Answer: To achieve your desired behavior you have two options.
If you really like to filter by using a subquery, you should execute it first, parse its result set to an array and set this array as parameter to the condition method of your second queries db_select:
// Run your subquery first.
$subquery = db_select('referential', 'r')
  ->fields('r', array('job'))
  ->condition('r.category', 'j.category')
  ->condition('r.label', $label)
  ->condition('r.activity', $activity);
$result = $query->execute()->fetchAllAssoc('job');

// Make sure $results is initialized for further evaluation.
$results = array();

// If we have referential results, execute the query on job orders.
if (!empty($result)) {
  $query = db_select('job_orders', 'j')
    ->fields('j')
    ->condition('j.statut', 'To do')
    ->condition('j.job', array_keys($result), 'IN');
  $results = $query->execute();
}

The far more elegant and therefore suggested solution is to using an INNER JOIN on your query. The target query would look like:
SELECT j.*
  FROM job_orders j
  INNER JOIN referential r ON (r.job = j.job)
  WHERE j.statut = 'To do' AND r.label = :label AND r.activity = :activity

You can achieve this solution using db_select by adding a join to your $query:
  // Run the query using an INNER JOIN.
  $query = db_select('job_orders', 'j')
    ->join('referential', 'r', 'r.job = j.job');
  $query->fields('j')
    ->condition('j.statut', 'To do')
    ->condition('r.label', $label)
    ->condition('r.activity', $activity);
  $results = $query->execute();

Edit:
As I don't see any special reason for using db_select in your use case, I'd also suggest on sticking to db_query here for better performance of your application.
Edit 2:
In the above 'solutions' I have overseen you are using two conditions between the tables. In this case, you have to add both conditions to your JOIN:
SELECT j.*
  FROM job_orders j
  INNER JOIN referential r ON (r.job = j.job AND r.category = j.category)
  WHERE j.statut = 'To do' AND r.label = :label AND r.activity = :activity

Which would need the following db_select:
  $query = db_select('job_orders', 'j')
    ->join('referential', 'r', 'r.job = j.job AND r.category = j.category');
  $query->fields('j')
    ->condition('j.statut', 'To do')
    ->condition('r.label', $label)
    ->condition('r.activity', $activity);
  $results = $query->execute();

Comment: Thanks for your quick answer. I'd want to use `db_select` because I need a pager to display results, and extend `PagerDefault` doesn't work with `db_query`. I've tried your 2 solutions, but still no success :( - the first one can't work because of `"condition('r.category', 'j.category')"` : `"j"` alias isn't yet associated with the corresponding table
- the second one return no results too But it gave me an idea : I tried to run `db_select` queries without `"condition('r.category', 'j.category')"`, and it return results ! but too much of course, the condition is needed. Here is a summary of wh
Comment: Altered my above answer. (Edit 2)
Comment: "Mais c'est bien sûr !" as we say in France :)
Thank you very very much Mario, it's working like a charm !
Comment: Sorry bummi and kiamlaluno, I'm new on the forum and I didn't know. I'll remember that !


Parametric Weighted Graph problem

Question: Let $G=(V,E)$ be a weighted directed graph with edge-weights given by linear functions $f_i(x) = ax-b$, $0 < a < 1$, $b > 0$. For a given starting parameter $x_0$, a path from $v_i$ to $v_j$ across edges $e_0, e_1, e_2, ... e_n$ is given a cost of $x_0 - f_n(f_{n-1}(...(f_1(f_0(x_0)))...))$. The problem is to find the center of the graph - the node with the minimal cost to reach any other node.
As an example of this problem, consider a vehicle traversing roads between cities. The vehicle has very poor gas mileage per weight of fuel, so that $x$ represents fuel remaining, and $f_i(x)$ represents the remaining fuel in the tank after traversing the road with $x$ amount of fuel in the tank to start with. The goal is to determine which starting city would allow the smallest possible amount of fuel in the tank to start with.
The only way I can think of is exhaustively testing each node to find the smallest $x_0$ which would reach all other nodes on the graph, and then select the node with the smallest $x_0$. Is there a faster way?
Comment: This paper: "Two-phase algorithms for the parametric shortest path problem", link: http://www.cmi.ac.in/~sourav/papers/parametric-sp.pdf might help you.
Answer: Sounds like you have an all-pairs shortest path problem. I guess there isn't a non-exhaustive way to solve it. The complexity is around $O(|V|^3)$.
Comment: This sounds pretty likely, thanks!

Parametric Weighted Graph problem


What does environment dynamic means in Reinforcement learning

Question: From the book Reinforcement learning: an introduction, I have two questions:
1) there is the following sentence: "If the environment's dynamics are completely known, then finding the optimal policy for the state-value function is a system of |S| simultaneous linear equations in |S| unknowns"
where |S| is the number of different states.
Does environment's dynamic means the different states, actions, probabilities and rewards?

2) Also, I was wondering how it was possible to select an optimal policy in a stochastic policy. Indeed, in a deterministic policy, of course, we decide which action to take in each state. However, in a stochastic policy, it's all about probabilities, right? So, what choices do we have to do? Aren't we subject to probabilities without the possibility to do anything more?
Thanks !!
Answer:
Does environment's dynamic means the different states, actions, probabilities and rewards?

Yes, not just a list of them, but some model of how the states and rewards behave on each time step, dependent on the current state and action. Sutton & Barto 2nd edition captures this in the probability distribution function $p(s', r| s, a)$ - the probability of transitioning to state $s'$ and receiving reward $r$ when starting in state $s$ and taking action $a$.
If you know this function completely accurately, then you could in theory calculate optimal behaviour in terms of $|S|$ simultaneous equations based on the Bellman optimality equation.

Also, I was wondering how it was possible to select an optimal policy in a stochastic policy.

Stochastic policies are a generalisation of deterministic policies, and have a few different roles to play in RL, covered in the Sutton & Barto book.
In terms of solutions to environments, it is relatively common to want to find a deterministic solution, and for the optimal policy to be deterministic. However, you want to explore alternative behaviour in order to discover the optimal policy. There are two basic approaches to that:

On-policy learning has a single stochastic policy that is "close to" optimal, typically $\epsilon$-greedy, and switches between different $\epsilon$-greedy policies - there is a proof in Sutton & Barto that generalises the policy improvement theorem to this case and shows that it still works. If you are searching for a fully optimal deterministic policy, then over time you can reduce $\epsilon$. The SARSA algorithm is in this category.
Off-policy learning has two policies - a behaviour policy that is stochastic and allows for exploration, and a target policy which is what the agent learns. There is some maths/rules to convert results seen in the behaviour policy to the values expected by the target policy. Q-learning is in this category (and the "some maths" in the simplest case is just taking maximum predicted value of next step).

Sometimes the optimal policy is stochastic. For example in two-player games when trying to be unpredictable is a goal, such as scissor-paper-stone. Those cases are more complex, require learning a policy more directly, and are covered in much later chapters of the book.
Comment: Have you got an example of a situation in which there are at least two different stochastic policies?
Comment: @nolw38: That would be a new question. You also need to clarify what you mean by "different" and what the other constraints are implied by your question - e.g. what kind of scenario are you thinking about and trying to understand? There are multiple different stochastic policies used whilst SARSA is learning for instance, but only one - the current policy - is active at any time. I don't think you want to know about that?


Can some one explain what this code is doing? what are all the special characters in sed doing?

Question: <code>jsonval () {
temp=`echo $haystack | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text"    '     {n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed '  s/\"//g' | grep -w $needle`
    echo ${temp##*|}
}

dev_key='xxxxxxxxxxxx'
zip_code='48446'
city='Lapeer'
state='MI'
red=$(tput setaf 1)
textreset=$(tput sgr0)

haystack=$(curl -Ls -X GET              http://api.wunderground.com/api/$dev_key/conditions/q/$state/$city.json)
needle='temperature_string'

temperature=$(jsonval $needle $haystack)

needle='weather'
current_condition=$(jsonval $needle $haystack)

echo -e '\n' $red $current_condition 'and' $temperature $textreset '\n'
</code>
this code is supposed to parse json weather data to terminal using a developer key to call the information.
This the full code, can someone explain what sed is doing, I know it supposed to act as a substitute method, but why are there so many slashes and special characters used?
Also what is the echo ${temp##*|} doing, all these special characters is making it hard for me to understand this code.
Comment: Run this kind of cmd with your own input and see... echo "a\\b" | sed 's/\\\\\//\//g'

http://www.grymoire.com/Unix/Sed.html#uh-1
Comment: Second, it is not in good style and written mess, learn from it will direct you to wrong way.
Comment: what is the value of "$haystack"?. without this value it will be impossible to know what sed is doing to the string you will have to cut the codes up into piece, trying each piece to see their output.
Answer: It seems that this command try to parse json It's far to be a good idea, since there's some nice item in the toolbox. One of them is jq. It's good at formatting JSON outputs or retrieving items in complicated Data Source. Example :
file.json
<code>{
    "items": [
        {
            "tags": [
                "bash",
                "vim",
                "zsh"
            ],
            "owner": {
                "reputation": 178,
                "user_id": 22734,
                "user_type": "registered",
                "profile_image": "https://www.gravatar.com/avatar/25ee9a1b9f5a16feb1432882a9ef2f06?s=128&d=identicon&r=PG",
                "display_name": "Brad Parks",
                "link": "http://unix.stackexchange.com/users/22734/brad-parks"
            },
            "is_answered": false,
            "view_count": 2,
            "answer_count": 0,
            "score": 0,
            "last_activity_date": 1417919326,
            "creation_date": 1417919326,
            "question_id": 171907,
            "link": "http://unix.stackexchange.com/questions/171907/use-netrw-or-nerdtree-in-zsh-bash-to-select-a-file-by-browsing",
            "title": "Use Netrw or Nerdtree in Zsh/Bash to select a file BY BROWSING?"
        }
    ]
}
</code>
Output from searching owner's sub HASH :

Don't reinvent the wheel badly ;)


Checking whether a map between the fibre of an associated bundle $(P_F:=(P\times F)/\sim_G,\pi_F,M)$ and F is well-defined

Question: This is related to a previous post of mine: How do I prove that the typical fibre of the associated bundle $(P_F:=(P\times F)/\sim_G,\pi_F,M)$ is $F$? so I apologise (and please let me know) if I'm breaking any rules of the site.
To tackle this problem, I've tried a different route by first defining a map
$$\begin{alignat*}{2}
j:A_x&\longrightarrow F \\
[(p,f)]&\longmapsto j([(p,f)]):=f
\end{alignat*}$$
where $x\in M$ and $A_x:=\{[(p,f)]\in P_F \mid \pi_F([(p,f)])=x\}$, with $\pi_F$ the projection for the associated bundle. The equivalence relation is defined $[(p',f')]\sim_G [(p,f)] :\iff \exists g\in G: p'=p\triangleleft g:f'=g^{-1}\triangleright f$.
I want to show that this is well-defined (and ultimately a bijection, but I haven't got there yet), i.e $j([(p',f')])=j([(p,f)])$. My attempt so far is this: $$j([(p',f')]) = j([(p\triangleleft g,g^{-1}\triangleright f)]) = g^{-1}\triangleright f=j([(p,g^{-1}\triangleright f)])$$
but I'm not sure where to go next. I'm not entirely confident that the map is indeed well defined and that I'm not trying to prove something true that is simply false, any help would be much appreciated.
Comment: I have written it somewhere, with different notations, if you want I can post it here.
Comment: If you could, that would be very helpful. Thank you.
Answer: Let me change your notation slightly so I can wrap my head around it. Let $P \xrightarrow{\pi} M$ be a principal $G$ bundle and $F$ a left $G$ space. If $p \in P$ denote the right action of $G$ on $P$ by $p \cdot g$ and if $f \in F$ the left action of $G$ on $F$ by $g \cdot f$. Then $P_F = (P \times_G F)$ where we have $[p,f] = [p \cdot g, g^{-1} \cdot f]$. If $m \in M$, we wish to identify the fiber $(P_F)_m$ with $F$ by a homeomorphism.
First consider the product $P \times F$ and fix a basepoint $b \in P$ such that $\pi(b) = m$, then consider $F_b = \lbrace b \rbrace \times F$. Then for any point $p$ in $P$ such that $\pi(p) = m$, there exists a unique $g \in G$ such that $p = b \cdot g$. So if $(p,f) \in P \times F$ and $p = b \cdot g$, then define a map $(P \times_G F)_m \to F_b$ by $[p,f] \mapsto (b,gf)$. This is well defined because $[p,f] = [bg,f] = [b,gf]$ and $[ph,h^{-1}f] = [bgh,h^{-1}f] = [b,ghh^{-1}f] = [b,gf] \mapsto (b,gf)$.
I claim this map is a homeomorphism by providing an inverse $F_b \to (P \times_G F)_m$ given by $(b,f) \mapsto [b,f]$. Then $(b,f) \mapsto [b,f] \mapsto (b,f)$ is the identity and $[p,f] = [bg,f] \mapsto (b,gf) \mapsto [b,gf] = [p,f]$ is also the identity.
Now it is clear that $F_b = \lbrace b \rbrace \times F$ is homeomorphic to $F$.
Comment: Are we not already assuming/asserting that the fiber of $P_F$ is $F$ by saying that $P_F\mid_{U_m}$ is homeomorphic to $U_m\times F$? I absolutely agree that locally $P_F$ has to be homeomorphic to $(chart\space domain)\times (fiber\space of \space P_F)$, but how do we know that the fiber is $F$ in the first place?
Comment: @AliChopping, $F_b = \lbrace b \rbrace \times F$, it is a point times $F$ so it is homeomorphic to $F$.
Comment: I see what you are looking for now, let me revise my answer then
Comment: Also, are we not done already once we have shown that $P_F\mid_{U_m}$ is isomorphic to $U_m\times F$? From that, isn't it clear that the fiber is $F$? Perhaps I should wait for you to revise your answer before I ask any more...
Comment: Yes you are correct, I provided a different proof
Comment: Brilliant, thanks. Do you mind clarifying what you mean by "$F_b$ is homeomorphic to $F$ by projection"?
Comment: I've posted an answer, if you could let me know what you think I'd appreciate it.
Answer:
$\textbf{Set Up Notation:}$ Let $\pi: P\to M$ be a smooth surjective map and $ G$ be a Lie group
with a smooth action map $\mu: P\times G\to P$. We say, $\pi: P\to  M$
a principal $ G$-bundle if following conditions hold :

$(i)$
$\text{Stab}(p):=\{g\in  G|p\cdot g=p\}=e$, identity element of $ G$,
for all $p\in  P$,

$(ii)$ There is an open covering $\{U_\alpha\}$ of
$ M$ and a collection of diffeomorphisms
$\big\{\varphi_\alpha:\pi^{-1}(U_\alpha)\to U_\alpha\times  G\big\}$
such that the composition
$\pi^{-1}(U_\alpha)\xrightarrow{\varphi_\alpha}U_\alpha\times
 G\xrightarrow{\text{projection}}U_\alpha$ is same as
$\pi\big|{\pi^{-1}(U_\alpha)}\to U_\alpha$ i.e. for each $\alpha$ we
have a smooth $\Xi_\alpha:\pi^{-1}(U_\alpha)\to  G$ with
$\varphi_\alpha=\big(\pi\big|_{\pi^{-1}(U_\alpha)},\Xi_\alpha\big)$,

$(iii)$ for each $\alpha$ action map $\mu$ sends
$\pi^{-1}(U_\alpha)\times  G$ to $\pi^{-1}(U_\alpha)$ and
$\varphi_\alpha$ satisfies $\varphi_\alpha(p\cdot
 g)=\big(\pi(p),\Xi_\alpha(p)\cdot g\big)$ for each $p\in
 \pi^{-1}(U_\alpha).$

Condition $(iii)$ gives $\pi^{-1}\big(\pi(p)\big)=\{p\cdot g|g\in G\}=\text{Orbit}(p)$ for all $p\in P$.
$\textbf{Vector Bundle from a  Principal Bundle :}$ Let $\pi: P\to M$ be a principal $ G$-bundle and $\tau: G\to \text{GL}(V)$ be a smooth group homomorphism, i.e. a representation, where $V$ is a finite dimensional vector space. Consider $$E=P\times_\tau V:=\frac{ P\times V}{(p,v)\sim \big(p\cdot g, \tau(g^{-1})(v)\big)}$$ and the natural map $\widehat\pi: E\to  M$ defined by $\widehat\pi:[p,v]\mapsto \pi(p)$, but  $\big[p\cdot g,\tau(g^{-1})(v)\big]\xrightarrow{\widehat \pi}\pi(p\cdot g)=\pi(p)$, so $\widehat\pi$ is well-defined.
Choose a chart $\varphi_\alpha:\pi^{-1}(U_\alpha)\to U_\alpha\times  G$ as in the definition of principal $ G$-bundle. Note that a typical fibre of $\widehat\pi$ is $\widehat\pi^{-1}(m)=\big\{[p,v]\big|v\in V\big\}$, where $\pi(p)=m$, hence the fibre $\widehat\pi^{-1}(m)$ is isomorphic to $V$ as $\text{Stab}(p)=e\in G$.
$\textbf{Some Extra Facts:---}$Here I show with above construction we have a vector bundle, called Associated bundle. Consider $\Phi_\alpha:\pi^{-1}(U_\alpha)\times_\tau V\longrightarrow U_\alpha\times V$ given by $[p,v]\mapsto\big(\pi(p),\tau\big(\Xi_\alpha(p)\big)v\big)$, where $\varphi_\alpha=\big(\pi\big|_{\pi^{-1}(U_\alpha)},\Xi_\alpha\big)$ and $\Phi_\alpha$ is well-defined due to $ (iii)$. Note also that $\Psi_\alpha:U_\alpha\times V\longrightarrow \pi^{-1}(U_\alpha)\times_\tau V$ given by $(m,v)\mapsto\big[p,\tau\big(\Xi_\alpha(p)^{-1}\big)v\big]$, where $p$ is any element in $\pi^{-1}(m)$, is the inverse of $\Phi_\alpha$.
Next, choose another chart $\varphi_\beta:\pi^{-1}(U_\beta)\to U_\beta\times  G$ as in the definition of principal $ G$-bundle with $U_\alpha\cap U_\beta\not=\emptyset$. Then, $\Phi_\alpha\Psi_\beta:\big(U_\alpha\cap U_\beta\big)\times V\to \big(U_\alpha\cap U_\beta\big)\times V$ is given by $(m,v)\longmapsto\big(m,\tau\big(\Xi_\alpha(p)\cdot\Xi_\beta(p)^{-1}\big)v\big)$, where $p$ is any element in $\pi^{-1}(m)$.
Now we show that, $\Phi_\alpha\Psi_\beta$ is smooth. So choose $m_0\in U_\alpha\cap U_\beta$ Since $\pi: P\to M$ is a surjective submersion, we have another open nbd $\widetilde U_{\alpha\beta}$ of $m_0$ contained in $U_\alpha\cap U_\beta$ and a smooth map $s_{\alpha\beta}:\widetilde U_{\alpha\beta}\to \pi^{-1}\big(\widetilde U_{\alpha\beta}\big)$ with $\pi\circ s_{\alpha\beta}=\text{Id}_{\widetilde U_{\alpha\beta}}$. Then, $$\Phi_\alpha\Psi_\beta(m,v)=\bigg(m,\tau\bigg(\Xi_\alpha\big(s(m)\big)\cdot\Xi_\beta\big(s(m)\big)^{-1}\bigg)v\bigg)$$ for all $m\in \widetilde U_{\alpha\beta}$, so we are done as $\tau$ is a smooth map. So by vector bundle chart lemma, $\widehat\pi: E=P\times_\tau V\to M$ is a vector bundle, whose typical fibre is $V$.
Answer: Here's an attempt at an alternative proof I've tried, though I'm somewhat uncomfortable about it, particularly the surjectivity part.
Define a map $$\begin{alignat*}{2}
i:F&\longrightarrow A_x \\
f&\longmapsto i(f):=[(p,f)]
\end{alignat*}$$
where $p$ is in the fiber over $x\in M$, in the total space of the corresponding principal bundle $(P,\pi,M)$. Well-definedness does not need to be checked because the domain of the map is not a quotient space, only the target is.
Injectivity: Let $i(f)=i(a)$. $i(f)=i(a)\iff [(p,f)]=[(p,a)]\implies\exists g\in G: p=p\triangleleft g : a=g^{-1}\triangleright f$. Since the group action is free, $p=p\triangleleft g \implies g=e \implies a=f$, so $i$ is injective.
Surjectivity Let $[(p,f)]$ be some arbitrary element in $A_x$ we want to hit. We can hit this element simply by applying the map to $f$, ie $i(f)=[(p,f)]$, so the map is surjective because we have found an element in the domain that hits this arbitrary element.
Therefore, $i$ is bijective, so $F$ is isomorphic to the fiber of the associated bundle.
The surjectivity part feels wrong - am I allowed to just pluck the $p$ out of thin air like that? Do I need to somehow choose a particular $p$ from the $f$ I am applying the map to?
Comment: you could choose any other, this is just a convenient one
Comment: it is surjective because there is a local homeomorphism $P \to U \times G$, so assign $i(f) = [(b,e),f]$, you have to fix a basepoint.
Comment: Ah, so can I simply state that "$i(f)=[(p,f)]$ where the point $p$ is in the fiber of the principal bundle with base point $x$" (since we're asserting that $[(p,f)]\in A_x$)? Is that enough?
Comment: There is more than one point $p \in P$ such that $\pi(p) = x$, so you need to assign a specific element of $P$ such that it projects to $x$. If $U$ is a neighborhood around $x$ that trivializes $P$ and $\phi$ is the homeomorphism $P|_U \to U \times G$, then $i(f) = [\phi^{-1}(x,e),f]$, where $e \in G$ is the identity element.
Comment: Ah I see! And why do you choose the identity element $e$? Why can't you choose any other element of $G$?


Regarding a basic ODE solution

Question: I solved a simple separable (and also linear) first-order ODE as follows:
$$
\begin{align}
\frac{dy}{dx}&=x(1-y) \\
\frac{1}{1-y}\frac{dy}{dx}&=x \\
\int\frac{1}{1-y}\frac{dy}{dx}dx&=\int xdx \\
\ln|1-y|&=\frac{x^2}{2}+C\\
y&=1-e^{\frac{x^2}{2}+C}.
\end{align}
$$
However, online calculators suggest that the exponent in the solution is negative:
$$
y=1-e^{-\frac{x^2}{2}-C}.
$$
I'm sure the mistake is trivial, but I can't see it! Where am I going wrong?
Comment: I think you made a mistake in the integral of $\frac{1}{1-y}$. Hint: $$\frac{d}{dy}\ln(1-y)=-\frac{1}{1-y}$$ and $$\frac{d}{dy}-\ln(1-y)=\frac{1}{1-y}$$ Everything else seems to be fine.
Answer: $\int \frac{1}{1-y}dy=\int x dx$
put $u=1-y$
$\int -u^{-1} du=\int x dx$
$-\ln (u)=\frac{x^2}{2}+C$
$u=e^{-\frac{x^2}{2}+ C}$
$1-y=e^{-\frac{x^2}{2}+ C}$
$y=1-e^{-\frac{x^2}{2}+ C}$

Regarding a basic ODE solution


Syntax highlighting for regular expressions in Vim

Question: Whenever I look at regular expressions of any complexity, my eyes start to water. Is there any existing solution for giving different colors to the different kinds of symbols in a regex expression?
Ideally I'd like different highlighting for literal characters, escape sequences, class codes, anchors, modifiers, lookaheads, etc. Obviously the syntax changes slightly across languages, but that is a wrinkle to be dealt with later.
Bonus points if this can somehow coexist with the syntax highlighting Vim does for whatever language is using the regex.
Does this exist somewhere, or should I be out there making it?
Answer: Regular expressions might not be syntax-highlighted, but you can look into making them more readable by other means.
Some languages allow you to break regular expressions across multiple lines (perl, C#, Javascript).   Once you do this, you can format it so it's more readable to ordinary eyes.  Here's an example of what I mean.
You can also use the advanced (?x) syntax explained here in some languages.  Here's an example:
(?x:          # Find word-looking things without vowels, if they contain an "s"
   \b                       # word boundary
   [^b-df-hj-np-tv-z]*      # nonvowels only (zero or more)
   s                        # there must be an "s"
   [^b-df-hj-np-tv-z]*      # nonvowels only (zero or more)
   \b                       # word boundary
)

EDIT:
As Al pointed out, you can also use string concatenation if all else fails.  Here's an example:
regex = ""          # Find word-looking things without vowels, if they contain an "s"
   + "\b"                       # word boundary
   + "[^b-df-hj-np-tv-z]*"      # nonvowels only (zero or more)
   + "s"                        # there must be an "s"
   + "[^b-df-hj-np-tv-z]*"      # nonvowels only (zero or more)
   + "\b";                      # word boundary

Comment: +1: This is a good way of doing it.  When you write functions in native Vim, there's no support for verbose REs, but if you want to do it, you can use string concatenation to achieve the same thing.
Answer: This Vim plugin claims to do syntax higlighting:
http://www.vim.org/scripts/script.php?script_id=1091
I don't think it's exactly what you want, but I guess it's adaptable for your own use.
Answer: Vim already has syntax highlighting for perl regular expressions. Even if you don't know perl itself, you can still write your regex in perl (open a new buffer, set the filetype to perl and insert '/regex/') and the regex will work in many other languages such as PHP, Javascript or Python where they have used the PCRE library or copied Perl's syntax.
In a vimscript file, you can insert the following line of code to get syntax highlighting for regex:
let testvar =~ "\(foo\|bar\)"

You can play around with the regex in double-quotes until you have it working.
It is very difficult to write syntax highlighting for regex in some languages because the regex are written inside quoted strings (unlike Perl and Javascript where they are part of the syntax). To give you an idea, this syntax script for PHP does highlight regex inside double- and single-quoted strings, but the code to highlight just the regex is longer than most languages' entire syntax scripts.


Como criar um Live Wallpaper

Question: Gostaria de saber em que área do aplicativo (AndroidManifest.xml, etc) eu preciso indicar que meu aplicativo é capaz de fornecer wallpapers para a a área de Live Wallpapers.
Answer: Sua pergunta é bem ampla, mas o Live Wallpaper é um serviço, então você terá que declarar esse serviço no seu AndroidManifest.xml, lembrando que este serviço requer a permissão android.permission.BIND_WALLPAPER e deve ser registrado via intent-filter para a action android.service.wallpaper.WallpaperService.
Eis o exemplo fornecido pelo site Vogella;
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="de.vogella.android.wallpaper"
    android:versionCode="1"
    android:versionName="1.0" >

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name" >
        <service
            android:name="MyWallpaperService"
            android:enabled="true"
            android:label="Wallpaper Example "
            android:permission="android.permission.BIND_WALLPAPER" >
            <intent-filter>
                <action android:name="android.service.wallpaper.WallpaperService" >
                </action>
            </intent-filter>

            <meta-data
                android:name="android.service.wallpaper"
                android:resource="@xml/mywallpaper" >
            </meta-data>
        </service>

        <activity
            android:name=".MyPreferencesActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Light.WallpaperSettings" >
        </activity>
        <activity
            android:name=".SetWallpaperActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Light.WallpaperSettings" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

    <uses-sdk android:minSdkVersion="10" />

    <uses-feature
        android:name="android.software.live_wallpaper"
        android:required="true" >
    </uses-feature>

</manifest>

Neste mesmo site você pode encontrar toda a informação que precisa para criar um Live Wallpaper mas requer um conhecimento básico de inglês.

Como criar um Live Wallpaper


WPF Binding to ObservableCollection - only update collection when row is complete

Question: I have a basic DataGrid that I'm using to create a list of enemies for a game project I've been playing around with:
<DataGrid x:Name="EnemyGrid" Margin="0,10,0,0" VerticalAlignment="Top" RenderTransformOrigin="8.273,3.781" Height="162" ItemsSource="{Binding}" CanUserReorderColumns="False" ColumnWidth="*" AutoGenerateColumns="False">
    <DataGrid.Columns>
        <DataGridTextColumn Binding="{Binding Name, UpdateSourceTrigger=Explicit}" ClipboardContentBinding="{x:Null}" Header="Name"/>
        <DataGridTextColumn Binding="{Binding Level, UpdateSourceTrigger=Explicit}" ClipboardContentBinding="{x:Null}" Header="Level"/>
        <DataGridTextColumn Binding="{Binding Role, UpdateSourceTrigger=Explicit}" ClipboardContentBinding="{x:Null}" Header="Role"/>
    </DataGrid.Columns>
</DataGrid>

The DataGrid is bound to an ObservableCollection that is read in from a json file:
public partial class MainWindow : Window
{
    public ObservableCollection<Enemy> EnemyList;

    public MainWindow()
    {
        InitializeComponent();

        var data = JsonHelpers.ReadFile<Enemy>("Enemy.json");
        EnemyList = data["Enemy"];
        EnemyGrid.DataContext = EnemyList;
     }
}

In case it matters, the ReadFile method uses JSON.Net:
public static Dictionary<string, ObservableCollection<T>> ReadFile<T>(this string fileName)
{
    string text = File.ReadAllText(dataPath + fileName);

    Dictionary<string, ObservableCollection<T>> data = JsonConvert.DeserializeObject<Dictionary<string, ObservableCollection<T>>>(text);

    return data;
}

Side note: the return type is Dictionary<string, ObservableCollection<T>> because I need to maintain the table declaration in the json file. If I can keep the format as "TableName" : [{Table}] without this then I'd appreciate the input.
In short, the problem I'm having is related to when the DataGrid posts an update. Per some related questions, I've created an empty constructor for the Enemy class. As soon as I type the first character in the Name field on EnemyGrid, the collection tries to update and I get default values for most of the properties on the Enemy class.
Also note that although I've set UpdateSourceTrigger=Explicit on the columns, the collection continues to update as soon as I've started typing. Ideally, I would like for the object to be created once I've finished adding values in the row, but the update happens once a cell is edited.
How can I make the DataGrid wait to perform this update so that I have all of my required parameters when the object is created?
Answer: I don't know of a direct way to do what you're trying to do. If your only option is to edit within a data grid, you may need to create an EnemyViewModel for your data that has the same properties as your Enemy, except every property is nullable.
So, if your Enemy looks like this:
public class Enemy
{
    public string Name { get; set; }
    public int Level { get; set; }
    public Role Role { get; set; }
}

...your EnemyViewModel would look like this:
public class EnemyViewModel
{
    public string Name { get; set; }
    public int? Level { get; set; }
    public Role? Role { get; set; }
}

This way, the default values for everything across the row of a table will be null, which will appear blank/unfilled to the user.
A simple LINQ query will allow you to convert the enemies you read in from your JSON to an ObservableCollection<EnemyViewModel>:
EnemyGrid.DataContext =
    new ObservableCollection<EnemyViewModel>(
        enemies.Select(x => new EnemyViewModel { Name = x.Name, Level = x.Level, Role = x.Role }));

The problem, though, is that unfilled values will not get a red box around them. So, if you have some sort of "Save" or "Submit" button, you will need to check your view model items for blank values and put up a warning for the user to fix that.

If you don't absolutely need to edit within the data grid, you could use it only for displaying your data and create a small form with each field getting its own label and TextBox (or whatever input widget makes the most sense). When the user submits this, you would then add it to your observable collection, and the table would update automatically. This would be a little more work, but will give you a lot more control over the user interface and could result in a better user experience.


How to select a button which has a certain class name and a unique "name" attribute in jquery?

Question: I'm trying to create a comment system. In this comment system, when a user a posts a reply to a comment, I wish to display a button called toggle replies - but this is only if it doesn't already possess replies that is. If there are already replies to the comment, then I don't want to hide the replies toggle button.
This button has althe class <code>.repliestogglebutton</code>, and has a name which is the same as the comment id of the comment to which the reply is being posted.
This is the html for the button:
<code>'<button class="repliestogglebutton" name="'.$commentId.'" style="display:none">toggle all replies</button>';
</code>
What can I use to select it and toggle it in jQuery? I'm writing this in the success function in my ajax that I'm using to post the reply.
Comment: Pls post a sample code of the jQuery you've written..
Comment: Thank you very much all...@Satpal, it worked..that was exactly what I was looking for ..thanks a lot!
Comment: You can use attribute value selector `$(".repliestogglebutton[name='.$commentId.']")`
Comment: I would give it an id and make your life easier.
Comment: you can also try $("button.repliestogglebutton[name='.$commentId.']")
Comment: @Satpal I'm confused! He has a php variable `$commentId` and the line of code he posted is obviously a `php` string. So he has concatenated his variable with "." But you have a JavaScript string in your sample. Can you please elaborate what does `name='.$commentId.'` exactly means in JavaScript?!
Comment: @EhsanT, Its actually simple. PHP developers generally use jQuery statement in php files,  so `'.$commentId.'` will be modified by PHP engine to something like `name='EhsanT'`
Comment: @Satpal, Actually I did not find it that simple! In that case You either should use `$(".repliestogglebutton[name='']")` if you assume the jquery code is not inside a php tag. or if you assume it is in a php tag, then you should use `'$(".repliestogglebutton[name='.$commentId.']")';` as he has enclosed all of his string in single quote!
Comment: @EhsanT, My bad, actaully it will be interpreted as `$(".repliestogglebutton[name=EhsanT]")'`
Answer: You can use:
<code>$(".repliestogglebutton[name='.$commentId.']")
</code>
Comment: Really? it worked? Are you sure? Even with the syntax error of concatenation with "." instead of "+" in JavaScript?!?


Importing data into specific fields from CSV - into pre-existing nodes?

Question: I've used the Feeds module before to import nodes and users. I need to import data into new fields on pre-existing nodes - is that possible?
Answer: Feeds requires you to map a unique identifier in order to update existing content; I've not tried this but presumably if your existing content has a unique field/property which you can map to your import then you will be able to update existing content.
Comment: I'll experiment & see. It's possible I may not need to do this after all (you know how clients can be ;)).


How to clone any standard webform element

Question: I've been able to copy the example webform element, as detailed at Create webform element.
Although I've not tested submission yet, I think it's all looking good.
What would be great is if I could clone any of the standard webform elements.
I've made a copy of src/WeformElement/Email.php - and it appears in the list of webform elements available to be inserted into the webform - but when viewing the actual webform, it is not rendered.
It may be that I have to use the example webform element to create a new copy, and then change stuff in there to render an email field instead, but as mentioned I'd appreciate any pointers towards being able to clone any of the elements.
(The reason we need to clone them is due to styling. One text field might be used for a name, and another for a completely different purpose which will be styled differently, and as the cloned element has a new id then we can use the module Themable forms to provide more template suggestions.)
Answer: The WebformElement plugin acts as a wrapper around a Drupal Form element plugin.  Therefore to actually create a webform element you need to define a Form element plugin with a corresponding Webform element plugin.
If you want to extend the Email element you need to extend the below classes

\Drupal\Core\Render\Element\Email
\Drupal\webform\Plugin\WebformElement\Email

All you might missing is a \Drupal\custom_module\Element\CustomModuleEmail class which probably will look something like...
<?php

namespace Drupal\custom_module\Element;

use Drupal\Core\Render\Element\Email;

/**
 * @FormElement("custom_moduel_email")
 */
class CustomModuleEmail extends Email { }

Comment: Thanks for the response - I'll try that on Monday.  I was a bit puzzled because in the webform module the:

src/Plugin/WebformElement/*

files do not all seem to have equivalent

src/Element/*

classes in the webform module.  From reading your reply I'm guessing that those Form elements are defined in core.  Not able to check currently - will report back.

Big thanks again - I feel I'm close to a really neat solution for the current requirements.
Comment: Hmm..

I'm having difficulty with this - and how the class wrapping works.

In the webform module there is /src/Plugin/WebformElement/Email.php

but no corresponding Element/Email.php class being wrapped around.

It would be great to know how to clone the existing webform elements - but for now I think I need to use the webform element example and modify that to suit.

Cheers,

Kev


Project Pages of Drupal

Question: I have seen project pages in drupal under http://drupal.org/project/xyz. I don't know how that works really.
Is this a specific 'Content Type' it is, but each node (aka project) has extremely consistent layout where as the whole thing look more like an basic article or a book page. Also, the elements within also has sections and further content; so it doesn't look like a pure single node. Or is this a different entity using a module like Project? But it is not available for D7.
Specifically, I want something exactly like this, but i don't quite know how to make specialized and consistent.
Answer: Drupal.org is using the Project module.
What you see as project page is a normal node to which the Project module adds extra fields. Keep in mind that the project page is also showing blocks shown just for those pages, and which are not part of the project page output.
The Project module automatically creates a path alias for every project node. That is the reason you see http://drupal.org/project/views, instead of http://drupal.org/node/38878; if you try the last link you will see you are accessing the Views project page.

The fact the project page is just a content type is proved from the fact project is shown in http://drupal.org/node/add, which lists the possible content types for which a user can create a node.

What you see in that page depends from the permissions you have on Drupal.org; as site maintainer, I see listed some content types a normal user doesn't see, such as the Story content type.
As alternatives to using the Project module there is the Storm module, which is more complex, in some way, and lack integration with CVS, or Git repositories (as far as I can see).

Storm is a structured system for project management, including:

Organizations, Teams, People,
Projects, Tasks, Tickets, Timetrackings,
Notes, Invoices, and Expenses.

Each part provides permissions to control the sharing of data with other Drupal users, and based on assignment of projects/tasks/tickets to particular users or teams.

The difference is that the Project module has been thought to be used on Drupal.org, even if it can be used on other sites, and the main features are the ones required from Drupal.org.
The Support Ticketing System module implements a ticketing system, and a help desk.

The support module provides a basic ticketing system and helpdesk that is native to Drupal, offering complete email integration.
The Support module offers the following features:

Ticketing activity is illustrated with colorful charts (depends on the Chart API module).
  -Tickets can be assigned to users (and users can view all tickets assigned to them).
Tickets support states (new, active, pending, closed, etc) and priorities (low, normal, high, critical, etc).
Configurable email notifications for new and updated tickets.
Email integration allows tickets to be created and updated via email, with support for attachments. New users can be automatically created. Ticket properties can be updated via email (using included support_mailcmd module).
Highly configurable client and user ticket overviews, highlighting tickets that haven't been updated for a long time.
Fully integrated with Drupal's search functionality, users can only search for tickets they have access to.
Supports an unlimited number of clients, each with their own configuration and access permissions.
Tickets are nodes, ticket updates are comments.
Comment: +1 thanks a lot. Support Tracking system is a bit different from my use. I am actually not using it for SW projects or customer co-ordination per say. Is storm ready for production env in D7? We dont have bandwidth for development or bug fixing really.
Comment: So far, there is just a development snapshot for the Storm module, which is used in 47 websites, out of the 846 sites using that module. (The data are referring to March 4, and are the last available from the project page.)

Project Pages of Drupal


How to set up a Weekly Digest

Question: I need to set up a weekly email digest of all content from a few particular content types (latest news, latest tech articles etc.) for all users in a particular group.
I have Simplenews installed and it looks like the Simplenews Digest module is not updated. Is there anything else that offers the feature I am looking for?
Answer: You can make an RSS feed of the digest and then use Mailchimp to make a newsletter of that RSS feed.
This has to be setup one time and the rest is automated.
Mailchimp module synchronizes Drupal user groups with the mailing lists and groups.

How to set up a Weekly Digest


Count characters from 3 textboxes

Question: I need count and limit characters in 3 textboxes. I can`t have more chars than 60 in all the textboxes included. Thats my code.
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">

<asp:TextBox ID="TextBox1" ClientIdMode="static" TextMode="MultiLine"  Width="200px" Rows="3" runat="server"  onkeyup="textCounter(TextBox1, this.form.remLen, 60);" onkeydown="textCounter(TextBox1, this.form.remLen, 60);" />

    <asp:TextBox ID="TextBox2" ClientIdMode="static" TextMode="MultiLine"  Width="200px" Rows="3" runat="server"  onkeyup="textCounter(TextBox2, this.form.remLen, 60);" onkeydown="textCounter(TextBox2, this.form.remLen, 60);" />

    <asp:TextBox ID="TextBox3" ClientIdMode="static" TextMode="MultiLine"  Width="200px" Rows="3" runat="server"  onkeyup="textCounter(TextBox3, this.form.remLen, 60);" onkeydown="textCounter(TextBox3, this.form.remLen, 60);" />

<input readonly="readonly" type="text" name="remLen" size="3" maxlength="3" value="60" /> characters left
</asp:Content>

Comment: It counts all separately.
Comment: https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.textbox.maxlength?view=net-5.0
Comment: it`s  not api, i have to add that in a old project.
Answer: The way you do it you check the current textbox. You can add comman class to all textboxes, for example "textBoxes", then add this to your code.

Count characters from 3 textboxes


Automatic task in NodeJS/Firebase

Question: I have some functions in Firebase (with NodeJS) to make a post on Facebook. After an hour, I need to get the current status of this publication automatically.
Is there any way to activate a task that makes the query to Facebook in exactly one hour after having made the publication?
Comment: You may want to have a look at https://bunkat.github.io/later/
Answer: The traditional way to do that would be with the setTimeout() method. I'm not experienced with firebase, but here's some pseudocode on how it might be done.
// Create facebook post
var post = createPost();
setTimeout(function() {
    // Code to execute in one hour
    post.getInformation();
}, 3600);

Comment: This won't work with code running in Cloud Functions.

Automatic task in NodeJS/Firebase


How to add android C# library (Binding Library) to MAUI android references only

Question: I have created a .Net C# Android Binding Library. I want to reference that project to only to android references(net6.0-android). When I'm trying to add it is referencing to net6.0, net6.0-android, net6.0-ios, which is not correct as the library is android C# library.
How to add the android C# library to MAUI net6.0-android only.
android library should be referenced to MAUI net6.0-android only.
Comment: When you are creating the library it should only Target Android...
Comment: @FreakyAli Yes, I have created the Library targeting to Android. I want the same library to add as reference to only MAUI project (net6.0-Android) instead it is referencing to net6.0, net6.0-iOS.
Comment: You can watch this official video of MAUI which explains how to bind Android Library: https://learn.microsoft.com/en-us/events/dotnetconf-focus-on-maui/binding-native-libraries-for-dotnet-maui
Answer: It is simpler than it looks, but there is no way (or at least I have not found it) to do it visually or with a wizard.
Just add the reference, then download the project and edit the project file.
Find the ItemGroup with the references you want unique to a platform(for example android) and add this:
<ItemGroup Condition="$(TargetFramework.Contains('-android')) != false ">


How can I decide I should use r or not?

Question: In my final exam, there were a divergence theorem question. Our 3-dimensional domain was a curve which has radius 4 and $y\le0$, $z\le0$
I have found $divF=4xy$ and I obtain this integral below.
$$ \iiint_D 4xydV$$
I have used cylinderical coordinates
$x=rcos\theta$ , $y=rsin\theta$, $z=z$
$x^2+y^2+z^2=16$ , $y\le0$, $z\le0$
$$\iiint_D 4xydV = 8\int_0^{\pi/2}cos\theta sin\theta d\theta \int_0^4r^3dr \int_0^ \sqrt{16-r^2}dz $$
I got zero because I should have written $x=4cos\theta$ , $y=4sin\theta$
Lecturer has said that we should take radius instead of $r$ variable in some situations. How can I decide, what are these situations?
Thanks in advance
Comment: @gimusi sorry I did not understand exactly
Answer: I hope to have clearly understood your doubt.
In this case you are integrating over a solid domain thus r is variable.
You will take a specific values for r (e.g. r=4) when you are integrating over a cylindrical surface with a fixed radius.
Comment: Cannot we say cure is a solid domain?

How can I decide I should use r or not?


Find the correlation between two binary observations when the parameter is one of two possible values with priors $p(\theta_1)$ and $p(\theta_2)$

Question: Consider two binary observations, $x_1$ and $x_2$, which are independent given $\theta$. Now suppose there is uncertainty with respect to $\theta$. Find the correlation between two binary observations when the parameter is one of two possible values with priors $p(\theta_1)$ and $p(\theta_2)$.
Answer: By your assumption of conditional independence, $$
p(X_1=x_1,X_2=x_2\mid\theta=\theta_k) = p(X_1=x_1\mid\theta=\theta_k)\,p(X_2=x_2\mid\theta=\theta_k)
$$
where $x_i\in\{0,1\}$ and $\theta_k\in\{\theta_1,\theta_2\}$.
You can find the marginal distributions via
$$
p(X_1=x_1) = \sum_{k=1}^2 p(X_1=x_1, \theta=\theta_k)=\sum_{k=1}^2 p(X_1=x_1\mid \theta=\theta_k)p(\theta=\theta_k),
$$
and the same calculation to compute $p(X_2 = x_2)$. The joint distribution can be calculated as
$$
p(X_1=x_1,X_2=x_2) = \sum_{k=1}^2 p(X_1=x_1,X_2=x_2,\theta=\theta_k) = \sum_{k=1}^2 p(X_1=x_1,X_2=x_2\mid\theta=\theta_k)p(\theta=\theta_k).
$$
Now that you have all distributions of interest, you can calculate things like $\mu_{X_1}$ and $\mu_{X_2}$ (which will be equal). If you want to calculate the covariance,
$$
\text{Cov}(X_1,X_2) = E\left[(X_1-\mu_{X_1})(X_2-\mu_{X_2})\right] = E\left[X_1 X_2\right] - \mu_{X_1}\mu_{X_2}
$$
where
$$
E\left[X_1 X_2\right] = \sum_{x_1=0}^1 \sum_{x_2=0}^1 x_1 x_2 \, p(X_1=x_1,X_2=x_2).
$$
In this case,
$$
E\left[X_1 X_2\right] = p(X_1=1,X_2=1) = \sum_{k=1}^2 p(X_1=1,X_2=1\mid\theta=\theta_k)p(\theta=\theta_k)
=
\sum_{k=1}^2 p(X_1=1\mid\theta=\theta_k)p(X_2=1\mid\theta=\theta_k)p(\theta=\theta_k).
$$
Note that, in this case we have
$$
\mu_{X_1} = \sum_{x_1=0}^1 x_1 \, p(X_1=x_1) = p(X_1 = 1) = \sum_{k=1}^2 p(X_1 = 1\mid\theta=\theta_k)p(\theta=\theta_k).
$$


Correlation Analysis of Standarized Testing Data

Question: I need some insight on how to correctly analyze some data using correlations.
The nature of the data and research endeavor is as follows:
I have two independent samples of different sizes that contain four different data points per observation reflecting scores of four different standardized testing measurements. For the sake of conversation the data sets will be N1 and N2 and the tests will be A, B, C and D. Essentially, measure A is a test that is issued to students once a year at the end of the year and B C and D are issued mid-year. The basic research question is: Do students scores of the midyear tests of B, C and D correlate to the scores on test A?
I need advice on what how to properly conduct this analysis.
Sample Sizes: N1 = 54  N2 =56
I need to know what type of correlation to conduct and why and how to determine that the results of that correlation procedure are statistically significant. I do not need to compare the between the samples. I need to conduct correct analysis for the test A compared to tests B C and D for each sample independently.
I have some statistical understanding, I am just confident somebody on this forum has much a much more fluid and comprehensive understanding of how to best approach this.
FYI: I am using SAS software to conduct my analysis.
Answer: the most suitable approach to your analysis will depend on the question you are trying to address. The following answer considers your objective is to (exclusively) measure the correlation between A score and other scores, as you stated, in a predictive manner, not causal. It means that after estimating the parameters of the model, you will be able to obtain some good estimates for B, C and D scores given that you only know A score. I am not familiar with SAS, but I am sure you can implement the following approach, called linear regression:
$Yscore_i=\beta_0+\beta_1 Ascore_i+\varepsilon_i$
where $i=\{1, 2, 3, \ldots, N\}$ is an "id" that uniquely identifies each individual in your sample; $Ascore_i$ is the score obtained by individual $i$ on test $A$; $Yscore_i$ may assume $Bscore_i$, $Cscore_i$ or $Dscore_i$; and $\varepsilon_i$ is some random part of $Yscore_i$ that cannot be explained by $Ascore_i$. Roughly speaking, $\hat{\beta}_1$ (the "hat" indicates $\hat{\beta}_1$ is an estimative of the real value of $\beta_1$) indicates how $Ascore_i$ relates to $Yscore_i$ on average. I imagine SAS output automatically displays p-values and confidence intervals, so you will be able to check for statistical-significance.
Remember that even when those scores are statistically correlated (and they probably are), this correlation might vanish or even change signal (Simpson's paradox, though it's not really a paradox) when you add other control variables to your regression, such as students' background. Also note that scores of individuals in the same class might be correlated with each other, which leads us to an extensive discussion of clusters and clustered standard errors. At last I highlight that, for causal inference purposes, on estimating the model above you are assuming some strong hypothesis hold, such as $Ascore_i$ and $\varepsilon_i$ are not correlated. It implies that the only thing that matters to determine $Yscore_i$ is $Ascore_i$, something I strongly believe is not true. If any of those topics are of your interest, you shall ask latter providing further details of your intended analysis.
All the best!


Getting only the last item data from hashmap arraylist

Question: I have parsed json data in which there is a main json array and it contains sub json array. But the main json array not containing the sub json array in every item. So i have parsed all the data accroding to it. and i am getting perfect data from it. But the problem is that the main json array data is displaying in listview and after click on list view item the sub json array is display accroding to main json array item but its only get the last element of sub json array from hash map array list. So i can't get proper way to display so please find out some standard solution.
Here is My Code
public class MainCategories extends Fragment {
WebserviceClass wservice = new WebserviceClass();
Context c;
View v;
String data = "";
String User_id, countryid;
JSONObject jobj;
JSONArray datas;
int currentpage = 1;
ArrayList<HashMap<String, String>> dataList = new ArrayList<HashMap<String, String>>();
// testAdapter adapter
ArrayList<Allcategories> listing = new ArrayList<Allcategories>();;
public static ArrayList<subCateData> subList = new ArrayList<subCateData>();
int limit = 3, id;
Button bt1, bt2, bt3;
String img, img1;
String name, count;
String subname, subcount, subCategoryId;
View fragmentview;
ListView lv1, lv2, lv3;
JSONObject ca;
MainTest test;
String url, main, subnameData, subCountData, subID, cateGoryID;
LinearLayout ll;
ProgressDialog pDialog;
HashMap<String, String> map;
JSONArray dataa;
// SimpleAdapter adp;
Button b1, b2, b3;

public MainCategories(Context mainActivity, int id) {
    // TODO Auto-generated constructor stub
    this.c = mainActivity;
    this.id = id;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    SharedPreferences sp = c.getSharedPreferences("key", 0);
    User_id = sp.getString("userid=", User_id);
    countryid = sp.getString("countryid", countryid);
    v = inflater.inflate(R.layout.categories_tab, container, false);
    lv2 = (ListView) v.findViewById(android.R.id.list);

    if (FirstTab.adp == null) {
        new CategoryTest().execute();
    } else {
        lv2.setAdapter(FirstTab.adp);
    }

    lv2.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {

            for (int i = 0; i < subList.size(); i++) {
                subID = subList.get(i).getsubcatId();
                subnameData = subList.get(i).getsubcatname();
                subCountData = subList.get(i).getsubcatcount();

                Log.v("ALLDATA", subnameData + "/" + "/" + "/"
                        + subCountData);
            }

            String catid = listing.get(position).getCategoryid();
            int mycatID = Integer.parseInt(catid);
            Log.v("CAtegory ID", mycatID + "");

            addfragment(new CategoriesListClick(c, subID, mycatID,
                    subnameData, subCountData, position), true,
                    FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

        }
    });
    return v;
}

public class CategoryTest extends AsyncTask<String, Integer, String> {

    @Override
    protected String doInBackground(String... params) {
        // TODO Auto-generated method stub

        url = String.format(Common.view_main_category + "country_id=%s",
                countryid);
        Log.v("CateGory URL:", url);
        jobj = wservice.getjson(url);

        return null;
    }

    @Override
    protected void onPostExecute(String result) {
        // TODO Auto-generated method stub

        super.onPostExecute(result);

        try {

            JSONObject jdata = jobj.getJSONObject("data");

            datas = jdata.getJSONArray("allcategories");

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

                Log.e("length", "" + datas.length());
                ca = datas.getJSONObject(i);

                cateGoryID = ca.getString("categoryid");
                name = ca.getString("categoryname");
                count = ca.getString("categorystorecount");

                // map = new HashMap<String, String>();

                // map.put("categoryname", name);
                // map.put("categorystorecount", "(" + count + ")");
                // String countc=c.getString("categoryid");

                Log.e(name, count);

                if (ca.has("subcategories")) {
                    dataa = ca.getJSONArray("subcategories");
                    for (int j = 0; j < dataa.length(); j++) {

                        JSONObject d = dataa.getJSONObject(j);
                        // subList = new ArrayList<subCateData>();
                        subCategoryId = d.getString("subcategoryid");
                        subname = d.getString("subcategoryname");
                        subcount = d.getString("subcategorystorecount");

                        // map.put("subcategoryid", subCategoryId);
                        // map.put("subcategoryname", subname);
                        // map.put("subcategorystorecount", "(" + subcount
                        // + ")");
                        subList.add(new subCateData(subCategoryId, subname,
                                subcount));
                        /*
                         * Log.v("This is Data for Sub:",
                         * map.get("subcategoryname").toString());
                         */

                    }

                } else {
                    System.out.println("JSONArray is null");
                }
                listing.add(new Allcategories(cateGoryID, name, count));

            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Log.v("Size", listing.size() + "");
        FirstTab.adp = new MyCustom(c, listing);

        lv2.setAdapter(FirstTab.adp);

    }
}

void addfragment(Fragment fragment, boolean addBacktoStack, int transition) {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.replace(R.id.simple_fragment, fragment);
    ft.setTransition(transition);
    if (addBacktoStack)
        ft.addToBackStack(null);
    ft.commit();

}

class MyCustom extends BaseAdapter {

    Context Mcontext;
    ArrayList<Allcategories> thisCatList;
    LayoutInflater inflater;

    public MyCustom(Context c, ArrayList<Allcategories> listing) {
        // TODO Auto-generated constructor stub
        this.Mcontext = c;
        this.thisCatList = listing;
        inflater = LayoutInflater.from(Mcontext);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return thisCatList.size();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView(int position, View v, ViewGroup parent) {

        if (v == null) {

            v = inflater.inflate(R.layout.list_categories, parent, false);
            TextView catName = (TextView) v.findViewById(R.id.txtcname);
            TextView catCount = (TextView) v.findViewById(R.id.txtccount);
            catName.setText(thisCatList.get(position).getCategoryname());
            catCount.setText("(" + ""
                    + thisCatList.get(position).getCategorystorecount()
                    + "" + ")");
            Log.v("CatCount", catCount.getText().toString());

        }
        // TODO Auto-generated method stub
        return v;
    }

}

class AllCategories Data:
public class Allcategories {
private String arabicname;
private String categoryid;
private String categoryname;
private String categorystorecount;
private String fatherid;
private String order;
private String status;

// private List subcategories;

public Allcategories(String name, String count) {
    // TODO Auto-generated constructor stub
    this.categoryname = name;
    this.categorystorecount = count;
}

public String getCategoryname() {
    return this.categoryname;
}

public void setCategoryname(String categoryname) {
    this.categoryname = categoryname;
}

public String getCategorystorecount() {
    return this.categorystorecount;
}

public void setCategorystorecount(String categorystorecount) {
    this.categorystorecount = categorystorecount;
}

SubCategory Data Class:
public class subCateData {

String subcatId, subcategoryname, subcategorystorecount;

public subCateData(String id, String name, String count) {
    // TODO Auto-generated constructor stub
    this.subcatId = id;
    this.subcategoryname = name;
    this.subcategorystorecount = count;
}

public String getsubcatId() {
    return this.subcatId;
}

public void setsubcatId(String subID) {
    this.subcatId = subID;
}

public String getsubcatname() {
    return this.subcategoryname;
}

public void setsubcatname(String name) {
    this.subcategoryname = name;
}

public String getsubcatcount() {
    return this.subcategorystorecount;
}

public void setsubcatcount(String count) {
    this.subcategorystorecount = count;
}

This is My Json parsing URL:
http://www.sevenstarinfotech.com/projects/demo/okaz/API/view_categories.php?country_id=4
Stack Trace:
06-27 12:23:34.361: V/ALLDATA(8533): High School///0
06-27 12:24:02.001: I/Adreno200-EGLSUB(8533): <ConfigWindowMatch:2218>: Format RGBA_8888.
06-27 12:24:02.011: D/memalloc(8533): /dev/pmem: Mapped buffer base:0x53153000 size:1536000 offset:0 fd:74
06-27 12:24:02.041: D/memalloc(8533): /dev/pmem: Mapped buffer base:0x54048000 size:15683584 offset:14147584 fd:80
06-27 12:24:02.091: D/OpenGLRenderer(8533): Flushing caches (mode 0)
06-27 12:24:02.111: D/memalloc(8533): /dev/pmem: Unmapping buffer base:0x51b26000 size:3072000 offset:1536000
06-27 12:24:02.121: D/memalloc(8533): /dev/pmem: Unmapping buffer base:0x552a2000 size:9093120 offset:7557120
06-27 12:24:02.121: D/memalloc(8533): /dev/pmem: Unmapping buffer base:0x55b4e000 size:17219584 offset:15683584
06-27 12:24:03.081: D/CLIPBOARD(8533): Hide Clipboard dialog at Starting input: finished by someone else... !
06-27 12:24:03.141: D/OpenGLRenderer(8533): Flushing caches (mode 0)
06-27 12:24:03.141: D/memalloc(8533): /dev/pmem: Unmapping buffer base:0x53153000 size:1536000 offset:0
06-27 12:24:03.141: D/memalloc(8533): /dev/pmem: Unmapping buffer base:0x54048000 size:15683584 offset:14147584
06-27 12:24:03.441: D/OpenGLRenderer(8533): Flushing caches (mode 2)

Comment: You should provide a minimal sample code showing the problem.
Comment: Here is the coding for fetch all data from json parsing
Answer: you should have to put new HashMap inside your current HasHMap so you can get subcategories items for particular index.
see this for how to use nested HashMap? and use it in subcategories loop.
i am using ArrayList of getter setter class to bind the data. so if you can convert your code into arraylist and edit the question that will be a great..
and see below code
import java.util.ArrayList;

public class MainCategories extends Fragment {
WebserviceClass wservice = new WebserviceClass();
Context c;
View v;
String data = "";
String User_id, countryid;
JSONObject jobj;
JSONArray datas;
int currentpage = 1;
ArrayList<HashMap<String, String>> dataList = new ArrayList<HashMap<String, String>>();
// testAdapter adapter
ArrayList<Allcategories> listing = new ArrayList<Allcategories>();;
public static ArrayList<subCateData> subList = new ArrayList<subCateData>();
int limit = 3, id;
Button bt1, bt2, bt3;
String img, img1;
String name, count;
String subname, subcount, subCategoryId;
View fragmentview;
ListView lv1, lv2, lv3;
JSONObject ca;
MainTest test;
String url, main, subnameData, subCountData, subID, cateGoryID;
LinearLayout ll;
ProgressDialog pDialog;
HashMap<String, String> map;
JSONArray dataa;
// SimpleAdapter adp;
Button b1, b2, b3;
/// sanket
 ArrayList<Allcategories> list = new ArrayList<Allcategories>();

public MainCategories(Context mainActivity, int id) {
// TODO Auto-generated constructor stub
this.c = mainActivity;
this.id = id;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
// TODO Auto-generated method stub
SharedPreferences sp = c.getSharedPreferences("key", 0);
User_id = sp.getString("userid=", User_id);
countryid = sp.getString("countryid", countryid);
v = inflater.inflate(R.layout.categories_tab, container, false);
lv2 = (ListView) v.findViewById(android.R.id.list);

if (FirstTab.adp == null) {
    new CategoryTest().execute();
} else {
    lv2.setAdapter(FirstTab.adp);
  }

lv2.setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {

        for (int i = 0; i < subList.size(); i++) {
            subID = list.get(position).get(i).getList().getsubcatId();
            subnameData = list.get(position).get(i).getList().getsubcatname();
            subCountData = list.get(position).get(i).getList().getsubcatcount();

            Log.v("ALLDATA", subnameData + "/" + "/" + "/"
                    + subCountData);
        }

        String catid = listing.get(position).getCategoryid();
        int mycatID = Integer.parseInt(catid);
        Log.v("CAtegory ID", mycatID + "");

        addfragment(new CategoriesListClick(c, subID, mycatID,
                subnameData, subCountData, position), true,
                FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

    }
});
return v;
}

public class CategoryTest extends AsyncTask<String, Integer, String> {

@Override
protected String doInBackground(String... params) {
    // TODO Auto-generated method stub

    url = String.format(Common.view_main_category + "country_id=%s",
            countryid);
    Log.v("CateGory URL:", url);
    jobj = wservice.getjson(url);

    return null;
}

@Override
protected void onPostExecute(String result) {
    // TODO Auto-generated method stub

    super.onPostExecute(result);

    try {

        JSONObject jdata = jobj.getJSONObject("data");

        datas = jdata.getJSONArray("allcategories");

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

            // sanket
            Allcategories binAll = new Allcategories();

            Log.e("length", "" + datas.length());
            ca = datas.getJSONObject(i);

            cateGoryID = ca.getString("categoryid");
            name = ca.getString("categoryname");
            count = ca.getString("categorystorecount");

            // map = new HashMap<String, String>();

            // map.put("categoryname", name);
            // map.put("categorystorecount", "(" + count + ")");
            // String countc=c.getString("categoryid");

            //sanket
            binAll.setcategoryid(cateGoryID);
            binAll.setcategoryname(name);
            binAll.setcategorystorecount(count);

            Log.e(name, count);

            if (ca.has("subcategories")) {
                dataa = ca.getJSONArray("subcategories");
                for (int j = 0; j < dataa.length(); j++) {

                    JSONObject d = dataa.getJSONObject(j);
                    // subList = new ArrayList<subCateData>();
                    subCategoryId = d.getString("subcategoryid");
                    subname = d.getString("subcategoryname");
                    subcount = d.getString("subcategorystorecount");

                    // map.put("subcategoryid", subCategoryId);
                    // map.put("subcategoryname", subname);
                    // map.put("subcategorystorecount", "(" + subcount
                    // + ")");

                    //// sanket
                    ArrayList<subCateData> sublist = new ArrayList<subCateData>();
                    subCateData binSub = new subCateData();

                    binSub.setsubcatId(subCategoryId);
                    binSub.setsubcatname(subname);
                    binSub.setsubcatcount(subcount);

                    subList.add(new subCateData(subCategoryId, subname,
                            subcount));
                    /*
                     * Log.v("This is Data for Sub:",
                     * map.get("subcategoryname").toString());
                     */
                    sublist.add(binSub);

                }
                /// sanket  note : make arraylist of subdata in Allcategories class and generate getter and settter

                binAll.setList(sublist);

            } else {
                System.out.println("JSONArray is null");
            }
            listing.add(new Allcategories(cateGoryID, name, count));
            list.add(binAll);
        }

    } catch (JSONException e) {
        e.printStackTrace();
    }
    Log.v("Size", listing.size() + "");
    FirstTab.adp = new MyCustom(c, listing);

    lv2.setAdapter(FirstTab.adp);

}
}

 void addfragment(Fragment fragment, boolean addBacktoStack, int transition) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.simple_fragment, fragment);
ft.setTransition(transition);
if (addBacktoStack)
    ft.addToBackStack(null);
ft.commit();

}

 class MyCustom extends BaseAdapter {

Context Mcontext;
ArrayList<Allcategories> thisCatList;
LayoutInflater inflater;

public MyCustom(Context c, ArrayList<Allcategories> listing) {
    // TODO Auto-generated constructor stub
    this.Mcontext = c;
    this.thisCatList = listing;
    inflater = LayoutInflater.from(Mcontext);
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return thisCatList.size();
}

@Override
public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return arg0;
}

@Override
public long getItemId(int arg0) {
    // TODO Auto-generated method stub
    return arg0;
}

@Override
public View getView(int position, View v, ViewGroup parent) {

    if (v == null) {

        v = inflater.inflate(R.layout.list_categories, parent, false);
        TextView catName = (TextView) v.findViewById(R.id.txtcname);
        TextView catCount = (TextView) v.findViewById(R.id.txtccount);
        catName.setText(thisCatList.get(position).getCategoryname());
        catCount.setText("(" + ""
                + thisCatList.get(position).getCategorystorecount()
                + "" + ")");
        Log.v("CatCount", catCount.getText().toString());

    }
    // TODO Auto-generated method stub
    return v;
}

}

Comment: I have implemented like this which you sad earlier but i couldn't get right way...so please tell me that where i have to need to change in my code
Comment: HashMap map...... this means i have to change this hashmap arraylist to arraylist of string??
Comment: Yes....  i have done it and i am getting all data...But whenever i have printed in log then it was displaying me only one last item for subcategories.
Comment: On List Item click Log.v("ALL DATA");
Comment: Yes..My friend I have seen your answers...But still i can't get all data from subcategories...It just display last items..                 In log the value for "ALL DATA": High School(0) which is the last item of subcategory... I have also implemented the getter setter but though it displayed last item..so this is my issues....
Comment: You can see in log cat for ALL DATA


Is there a definition of closed sets in terms of closed balls

Question: In my general topology lectures, closed sets are defined in terms of open sets but I wonder whether closed sets can be defined in terms of closed balls in metrisable topological spaces.
Comment: I actually think the answer is *no*, which surprises me, but I'm having difficulty thinking of a correct example.
Comment: I think this is an unusually good question.
Answer: What about this:

A set $C$ is closed if around every point not in $C$, there exists a closed ball of non-zero radius which doesn't intersect with $C$.

Explanation:
A set is closed iff its complement is open. In the standard definition, its complement is open if it contains an open ball around every of its points. A closed ball has an open ball as subset iff its radius is not zero (namely the open ball with the same radius). Moreover, every open ball contains a closed ball of non-zero radius (for example, the closed ball with half the radius). Therefore there's an open ball in the complement of $C$ around a point iff there is a closed ball with non-zero radius in the complement of $C$ around that point. Of course a closed ball in the complement of $C$ is a closed ball that doesn't intersect with $C$.
Comment: 1....If for every $p$  in the complement $C^c$ of $C$  there exists $r_p>0$ such that $C \cap \overline { B(p,r_p)}=\phi$ then $C^c=\cup_{p\in C^c}B(p,r_p)$ is open.....2.... If $C$ is closed and $p\in C^c$ there exists $s>0$ with $C\cap B(p,s)=\phi,$  and $p\in \overline {B(p,s/2)}\subset B(p,s).$
Answer: It is true that in a metric space every closed set can be represented as the union of (possibly degenerate, or singleton) closed balls. However the arbitrary union of closed sets is not closed in the usual metric topology, or in general spaces. If we were to define a topology where the closed sets were the arbitrary union closed balls we would have so many closed sets that the topology would be discrete.


Django -- Admin page is empty HTML

Question: I don't exactly know what to provide you with for this one. I am running my project on Xubuntu 12.04 under an Apache2 server. Let me know what information you need.
My admin.py file:
<code>from django.contrib import admin
from notendur.models import * # notendur is the application
</code>
This is what the page looks like:
https://i.stack.imgur.com/JzeOQ.jpg
This is not how it should look like. It should look like this:
https://i.stack.imgur.com/6BbTM.jpg
Comment: As written below, you should configure media and static file locations for Apache, but also remember to run collect static to copy the needed files. The correct apache config file for adding the alias line depends on you server setup. If you have only one site http.conf is the right file. If you have virtual sites, you need to edit a different file.
Comment: Did you make sure to run `python manage.py collectstatic`? EDIT: Ooh beat me to it, @het.oosten
Comment: Thank you for your help. I had mistakenly believed I was running a Virtual host, which I was not. In that case, the Alias goes into httpd.conf
Answer: Configure your apache server to look for admin MEDIA.
See these location in site packages where admin module is installed.
Configure your apache by adding these lines.
Alias /static/ PATH/TO/LOCATION
Alias /media/ PATH/TO/LOCATION
PATH/TO/LOCATION is your admin media and static file location generally located at site-packages.
Msoni
Comment: Do I add these lines to httpd.conf?
Comment: Also, where is the site-packages? The one in /usr/local/lib/python2.7/site-packages is empty.
Comment: @Gudmundur you need to be aware of where your Django was installed. This is really more of a general server admin issue.
Comment: I'm pretty sure I know where it is. There is an admin folder under dist-packages/contrib, which holds /static/. I suppose that is where I should point the static Alias to? What about the media Alias?
Comment: You should make a static and a media direction in your project folder. Then make the correct settings for static files etc. in settings.py. After that you are ready to run collectstatic (this command copies all needed files to the static dir in your project folder. The line in httpd.conf should point to the static dir in your project folder.
Comment: Even dist-packages are considerable. You should not worry about it. consider both site-packages and dist-packages as same to configure apache.

Django -- Admin page is empty HTML


How to re-create content types using the feature module which removes deleted fields?

Question: I've been looking into the Feature module to move changes from Dev to Staging without redoing everything.
On my Dev site I made changes in the content types (added new fields, deleted some field). Then I exported all content types as a feature and imported in to Staging. But still I see the deleted fields on staging.
I thought to delete all content types on staging and enable the module exported by feature but there is no delete option in content types.
Am I doing it in the correct way?
Comment: "Delete content type" appeared after i disabled the feature generated module.
Comment: i deleted all content types, and then enabled the features generated module of content types. All the content has empty "body" and the webforms are empty aswell.
Answer: The answer to your question boils down to what is mentioned by the Features maintainer in this comment, i.e.:

FInally going to mark this as "won't fix" until somebody proposes something better.
1) Features will never do anything that might cause content to be lost on your site. This includes deleting fields. Just because you remove a field from a feature doesn't mean you might not still have content stored that would be lost if features auto-deleted it. I've never been in favor of any sort of auto-deletion.
2) Now that fields are split into bases and instances, this gets even more complicated.

The next comment in that same issue includes a link to a 32 steps process, which describes Deleting a Drupal Field Saved in Features. IMHO this is "as good as it gets" today (and my recommended work around until further notice).
Comment: Okay so for the mean time I will go for deleting the fields manually from the content type before enabling a feature.  As long as the features is adding new fields, I don't have a problem . any how just one thing to confirm " I should not delete the content types on stag site , instead I should enable the feature and revert. ? "
Answer: The right way of deploying the changes between the environment including delete operations can be achieved by drush command or hook_update() as part of your deployment, since auto-deletion of any content by Features module is not possible to avoid any content lost (which is the last thing that you want to do on your production). See: #649298 for further details.
hook_update
Here is example by using hook_update():
/**
 * Deletes fields.
 */
function MYMODULE_update_7001() {
  $fields = array(
    'field_foo',
    'field_bar',
  );
  foreach($fields as $field) {
    if (field_info_field($field)) {
      field_delete_field($field);
      field_purge_batch(10);
      drupal_is_cli() ? drush_log("Deleting field $field", "ok") : NULL;
    };
  }
}
?>

or this one posted at GH gist by insparrow:
<?php
/**
 * Remove a shared field from a content type.
 */
function custom_module_update_7027() {

  // Fetch instance info.
  $entity_type = drush_field_get_entity_from_bundle('custom_content_type');
  $instance = field_info_instance($entity_type, 'field_to_remove', 'custom_content_type');

  // Mark field for deletion.
  field_delete_instance($instance);

  // Remove field marked for deletion.
  field_purge_batch(10);

  watchdog('custom_module', 'Removed field_to_remove instance from custom_content_type', array(), WATCHDOG_INFO);
}

field_delete_field

Marks a field and its instances and data for deletion.

field_purge_batch

This function will purge deleted field data in batches. If a deleted field instance with no remaining data records is found, the instance itself will be purged. If a deleted field with no remaining field instances is found, the field itself will be purged.

drush
Use drush which can be invoked as part of your deployment process and its field-delete command.
For example:
drush field-delete field_name

to delete a field and its instances.
To delete only instance attached to specific bundle, try:
field-delete field_name --bundle=bundle

Alternatively you can consider to implement your own drush command which find all abandoned fields and removes them.
Here is example code posted by Chi:
<?php

/**
 * @file
 * Drush command to find all abandoned fields.
 *
 * @see http://drupal.org/node/649298
 */

/**
 * Implements hook_drush_command().
 */
function abandoned_fields_drush_command() {

  $items['abandoned-fields'] = array(
    'description' => 'Find all abandoned fields',
    'drupal dependencies' => array('features'),
    'aliases' => array('af'),
  );

  return $items;
}

/**
 * Drush command callback;
 */
function drush_abandoned_fields() {
  module_load_include('inc', 'features', 'features.export');

  $commited_fields = array();
  foreach (features_get_default('field') as $id => $field) {
    if (!in_array($field['field_config']['field_name'], $commited_fields)) {
      $commited_fields[] = $field['field_config']['field_name'];
    }
  }

  $rows[] = array('Field name', 'Location');
  $rows[] = array('-------------', '----------');
  foreach (field_info_fields() as $field_name => $field) {
    if (!in_array($field_name, $commited_fields)) {
      $bundle_strs = array();
      foreach ($field['bundles'] as $entity_type => $bundles) {
        $bundle_strs[] = $entity_type . ' (' . implode(',', $bundles) . ')';
      }
      $rows[]= array(
        $field_name,
        implode(' ', $bundle_strs),
      );
    }
  }
  drush_print_table($rows);
}

For further details, you may want to read Deleting a Drupal Field Saved in Features.
Answer: So on staging, you updated the custom content type feature folder/files and did drush fr machine_name_of_your_content_type_feature -y right? This assumes that you already have the custom content type feature installed in your staging site.
drush fr should apply all the new changes from code into your staging site's DB.
Also if your deleting fields in the staging site, might want to double check if you need to manually delete the field using hook_upadte_N. An example and discussion can be found here https://www.drupal.org/node/649298#comment-10219951. It can also be the basis for the code you want to execute.
Comment: I am not using Drush on staging. I just packed all content types in a feature module and placed it on staging. Enabled the module and i was able to see the fields on staging, which were not on dev ( means were deleted on the dev )
Comment: Oh ok. Did you try to do Revert Components?
Comment: Yes i selected "Field Base"  as shown above in the picture # 2 and clicked on revert. but nothing changed.
Comment: So just to see if I understand you correctly, in staging, all your desired new configurations were applied including adding new fields but the issue is only the removed fields still exists? Am I right? If yes then you may need to do the recommendation I specified on the last sentence where you need to delete them manually. I have updated my answer for a reference on this.
Comment: Okay I will give it a try.  But is it suppose to work this way ? . I will be doing changes in the content types every now and then and exporting and importing it to the staging site . every Time I won't get what I am expecting ?
Comment: Yes I think we need to do clean-ups for some parts ourselves. I also remembered a colleague added some code like that not too long ago in a project. You can also verify from others though if you like. :)
Answer: You may try Features Cleanup sandbox module (GH fork) as add-on to Features which can do cleanup of fields, vocabularies, panel nodes, mini panels, and image styles that are in the database, but not in any enabled features module.
This is potentially dangerous module, since it can irreversibly delete database components once they got removed from the Features, so you should test it first if that meets your expectations and it has been tested with your deployment plan and scripts.
This module is separated into two different tasks:

Resolve Overrides
You will have new option Resolve All Overrides at the bottom of Feature's overview screen which will attempt to cleanup all overrides by deleting existing database components (mainly fields). After that, it will revert this feature.
Delete existing components that are not in any Features modules
This includes: content types, mini panels, node panels, taxonomy vocabularies, image styles, etc.
Before doing it, you need to enable all features that you want to compare against. Then click on Features Cleanup in the Features listing screen.

This module also has drush integration and provides the following commands:

drush fca/drush features-cleanup-all
Cleans out all content types, panel pages, mini panels, vocabularies, and image styles from database based on existing enabled features and run features-revert-all afterwards. This is useful to include as part of your deployment process before you backup your database.
drush fcf/drush features-cleanup-feature [feature name] [component list]
Attempts to resolves all overrides on a single feature module. Run features-revert afterwards.