mysql_result returns filed name as result

Question: I'm kinda new at webprograming. I've only studied it for a year or so.
My problem is the following. For some reason when I use this query(in phpadmin wampserver), the last 4 field results are the field names.
SELECT  `latin_name` ,
    `group` ,
    `name` ,
    `continent` ,
    `country` ,
    `position` ,
    `hight_min` ,
    `hight_max` ,
    `light_min` ,
    `light_max` ,
    `temp_min` ,
    `temp_max` ,
    `nk_min` ,
    `nk_max` ,
    `gh_min` ,
    `gh_max` ,
    `ph_min` ,
    `ph_max` ,
    `growth_rate` ,
    'growth_min',
    'growth_max',
    'gfactor',
    'period'
FROM  `plants`
WHERE continent LIKE  'As'
    AND growth_rate LIKE  'slow'
LIMIT 0 , 30

What could be the problem?
Comment: And the data in your database for those fields is good data?
Comment: The type of quotes used for the last four field names?
Answer: You seem to have a mixture of quote types. The first few fields use `, but the last 4 use ', which turn them into string literals.
Try:
SELECT  `latin_name` ,
`group` ,
`name` ,
`continent` ,
`country` ,
`position` ,
`hight_min` ,
`hight_max` ,
`light_min` ,
`light_max` ,
`temp_min` ,
`temp_max` ,
`nk_min` ,
`nk_max` ,
`gh_min` ,
`gh_max` ,
`ph_min` ,
`ph_max` ,
`growth_rate` ,
`growth_min`,
`growth_max`,
`gfactor`,
`period`
FROM  `plants`
WHERE continent LIKE  'As'
AND growth_rate LIKE  'slow'
LIMIT 0 , 30

Comment: Yeah, it seems that was the problem.
THX a lot!
Answer: You have apostrophes (') instead of backticks (`) for these last 4 fields.


Cable amplifier repeater setup for best signal

Question: I have a long run from the pole to my house, so the cable company installed a repeater.  After doing some research I'm starting to see that I'm still not getting the full signal strength to my Main TV and My Cable Modem.
Here is what I have now:

the two things I'd like to accomplish are
1 - get the best signal possible to my Main TV and to my Cable Modem
2 - Add one more TV
So here is what I was thinking should work:

Please let me know your thoughts on this approach or if there is a better way to do it.
TIA
M
UPDATE 5/19/2015 12:47 am EST
Here are the current results from my modem:
<code>Downstream Bonded Channels

Channel Lock Status Modulation Channel ID Frequency Power SNR Corrected
Uncorrectables
1 Locked QAM256 1 651000000 Hz 3.6 dBmV 38.8 dB 6238 3004
2 Locked QAM256 2 657000000 Hz 3.3 dBmV 38.6 dB 5254 2258
3 Locked QAM256 3 663000000 Hz 3.2 dBmV 38.5 dB 4282 1875
4 Locked QAM256 4 669000000 Hz 3.3 dBmV 38.5 dB 3444 1327
5 Locked QAM256 5 675000000 Hz 2.9 dBmV 38.1 dB 4326 1508
6 Locked QAM256 6 681000000 Hz 2.9 dBmV 38.4 dB 4995 2056
7 Locked QAM256 7 687000000 Hz 2.8 dBmV 38.4 dB 5716 2352
8 Locked QAM256 8 693000000 Hz 2.6 dBmV 38.3 dB 7679 4029

Upstream Bonded Channels

Channel Lock Status US Channel Type Channel ID Symbol Rate Frequency Power
1 Locked ATDMA 10 5120 Ksym/sec 36500000 Hz 45.5 dBmV
2 Locked ATDMA 11 5120 Ksym/sec 30100000 Hz 45.0 dBmV
3 Locked ATDMA 12 5120 Ksym/sec 23700000 Hz 44.5 dBmV
</code>
Comment: With 3 amplifiers, I wouldn't be surprised if the cable company came knocking on your door.  You will likely throw off a huge amount of noise into the system and might impact other customers.
Comment: Note that putting a splitter first REDUCES the (already weak) signal into your "wall of amplifiers." You want an amplifier as the first thing your weak signal sees.
Answer: Before going crazy adding amplifiers you might want to spend a little time investigating the current wiring/splitting situation in your house, if you haven't already.
Every splitter and every foot of cable contribute to signal loss:

Verify that you have only the bare minimum number of splitters in your system (in this case it seems like you can get away with 1).
Make sure you don't have any unnecessary long bundles of cable, or cable splices. Sometimes people will buy a long amount of cable and then just coil it all up in the basement instead of trimming it.
Make sure all your existing cables are in good condition: no nicks in the jacket, hard kinks (a bend is fine but a hard kink can break the interior insulation). Make sure all connections are secure. If any cable or connector seems questionable, replace it.
Make sure the splitter only has as many outputs as you need. A 4-way splitter will drop the signal on each leg more than a 3-way, no matter how many devices are plugged in.

If you're trying to troubleshoot signal strength, you may be able to use the config page on your DOCSIS modem, which should display the signal strength ("power level" in dBmV and "signal-to-noise ratio" in dB).
I think it's unlikely you'll really need 3 amplifiers in your house, especially if the cable company has verified that their own amplifier is providing a sufficient signal to your property. Typically the utility company is responsible for getting a usable signal as far as the exterior wall. If the above suggestions don't yield anything, you might want to call them back and ask them.
Edit based on additional cable modem signal info
The signal numbers you've posted all look perfectly within spec according to several websites, e.g. What cable modem signal levels are considered good?. I am not a cable tech and there may be other signal issues in play but as a rough cut you seem to be getting a decent signal. I don't think an amp will help.
I assume you're using a site like Speedtest.net to measure your internet speed and you're not getting what you think you should?
There are a couple reasons this might happen:

Poor signal to cable modem (I think we can probably rule this out, but who knows)
Poor wifi signal, if you're using wifi. Make sure you do these test with a hardwired ethernet cable if possible, to remove that variable.
Competition between other internet users in your area. Peak internet usage is between 7-9pm. Try running a test late at night or early in the morning to see if you get a different result.
Unsupported cable modem: is your cable modem provided by your utility or did you buy it yourself? Is it an approved model? You mention "DOCSIS 3" in your post so I assume you've thought about this, but make sure you have an approved modem that supports your utility's network.
Some other issue with your cable provider

To test whether your house's wiring / splitters are the problem, try moving the cable modem to be directly connected to the utility-installed amplifier (i.e. remove all the household wiring and splitters), and see if you get different speed or signal numbers.
Comment: I can't format my response very well in the comments, So I added it to my original post..
Comment: Oh I also forgot to mention the run to my house is about 400 ft
Comment: @mreinsmith: I'm not a cable tech but those seem like solid numbers to me, based on some checking online. I'm not sure adding an amplifier will help. What specifically is wrong with your internet?
Comment: It's a long story, to summarize we've never seen the speeds they've promised and I want the numbers to prove it.  I haven't pushed the issue yet because I'm doing some remodeling and I relocated several of these connections and replaced the cable.  I'm also concerned that when they originally installed the repeater that they only did the minimum to make it work.  We always have problems with slow response on the TV cable box.  So now I'm to the point where I can do the connections right and I want to make sure I've got the best signal possible and not just adequate.  See where I'm coming from?
Comment: @mreinsmith: I added some more info to my answer. I'm not convinced you have a signal problem.
Comment: Thanks Henry, I'm going to hook up the modem at the source and see what I get and then get comcast to test it and see what they get.  The bottom line is that not only is my cable box flakey but I've been paying for 105 Mbps and only getting 35 to 40 on average.   This is the first time I feel comfortable that they can't blame the wiring in the house, thanks again


Median Concentration implies mean concentrarion

Question: I want to prove that if X is such that
$$P[|X-m_X|\geq t] \leq c_1 e^{-c_2t^2},$$
for $c_1, c_2$ positive constants, $t\geq 0$, then it holds that $$P[|X-E[X]|\geq t] \leq c_3 e^{-c_4t^2},$$ with $c_3=1+2c_1$ and $c_4=c_2/4$.
There is a proof of reverse direction here.
Comment: see my answer below
Comment: While it does not directly answer your question, you might be interested in this question I just posted: https://math.stackexchange.com/questions/3609200/concentration-around-mean-from-concentration-around-median
Comment: Edit: I don't think the answer I got uses the specifics of the question at all, so it should answer your question, afterall.
Comment: @mathworker21 I can't see your answer below.
Comment: Ramon Van Handel's notes on high dimensional probability contain a very similar question 4.2 , with suggested approach : https://web.math.princeton.edu/~rvan/APC550.pdf
Answer: First, note that we may re-write the problem using auxiliary variable $Y=X-m_X$. Hence, we need to show,
$$ P[|Y|\geq t] \leq c_1 e^{-c_2t^2} \Rightarrow P[|Y-E[Y]|\geq t] \leq c_3 e^{-c_4t^2}.$$
A proof may be obtained using the properties of sub-Gaussian random variables. It can be shown that if $P[|Y|\geq t] \leq c_1 e^{-c_2t^2} $ then there exist finite $c_3,c_4$ such that $E[\exp(c_4Y^2)]\leq c_3$ (You may find the proof in Proposition 2.5.2 of R.Vershynin (2018) book).  Hence,
$$P[|Y|\geq t] \leq c_1 e^{-c_2t^2} \Rightarrow \exists c_3,c_4>0,\quad E[\exp(c_4Y^2)]\leq c_3.$$
By Markov inequality we may write
$$P[|Y-E[Y]|\geq t] = P\left[\exp(c_4|Y-E[Y]|^2)\geq \exp(c_4t^2)\right] \leq e^{-c_4t^2}E\left[\exp(c_4|Y-E[Y]|^2)\right].$$
Then it can be easily seen that:
$$e^{-c_4t^2}E\left[\exp(c_4|Y-E[Y]|^2)\right] \leq e^{-c_4t^2}E\left[\exp(c_4|Y|^2)\right],$$
which gives
$$P[|Y-E[Y]|\geq t]\leq e^{-c_4t^2}E\left[\exp(c_4|Y|^2)\right]\leq c_3 e^{-c_4t^2}.$$
Vershynin, Roman, High-dimensional probability. An introduction with applications in data science, Cambridge Series in Statistical and Probabilistic Mathematics 47. Cambridge: Cambridge University Press (ISBN 978-1-108-41519-4/hbk; 978-1-108-23159-6/ebook). xiv, 284 p. (2018). ZBL1430.60005.
Comment: Your answer works for every constant instead of $m_X$ as well and is correct. But this is only the first part of proof and in the second part it's important what constant to use, because we should also find the relation between $c_3, c_4$ and $c_1, c_2$
Comment: That is true. It works for every constant instead of $m_X$. Preposition 2.5.2 implicitly gives the value of $c_3$ and $c_4$ in terms of $c_1$ and $c_2$, which is difficult to follow. I think some other references on high dimensional probability might have the exact relationship between the constants.


Change color or border to highlight specific bar in `geom_bar`

Question: I am creating a bar chart considering two years and a set of countries. To do this, I am using the geom_bar function from the ggplot package. I would like to highlight the colors for a specific country only. Is there a way to do that?
Here's an example of the chart, which is similar to what I'm working on:
Panel <- read.dta("http://dss.princeton.edu/training/Panel101.dta")
Panel$y = Panel$y / 1000000

Panel %>%
  filter(year %in% c(1990, 1991)) %>%
  ggplot(mapping = aes(x = country, y = y, fill = as.factor(year))) +
  geom_bar(stat = 'identity',
           position = 'dodge2', colour = 'white') +
  scale_fill_manual(values = c('#001d87', '#d9912e')) +
  labs(fill = 'Year', x = 'Country') +
  theme_classic()

The goal is to highlight the colors for country C, for instance, by making the colors for this country more solid compared to the others or by adding distinctive borders, something that can differentiate this country without affecting the legend. I appreciate any assistance!
Answer: You can put color within aes, then supply a vector of named vector specifying the colors of each country.
library(foreign)
library(tidyverse)

Panel <- read.dta("http://dss.princeton.edu/training/Panel101.dta")
Panel$y = Panel$y / 1000000

Panel %>%
  filter(year %in% c(1990, 1991)) %>%
  ggplot(mapping = aes(x = country, y = y, fill = as.factor(year), color = country)) +
  geom_bar(stat = 'identity',
           position = 'dodge2') +
  scale_fill_manual(values = c('#001d87', '#d9912e')) +
  scale_color_manual(values = setNames(c(rep("white", 2), "red", rep("white", 4)), LETTERS[1:7]), guide = NULL) +
  labs(fill = 'Year', x = 'Country') +
  theme_classic()

Created on 2023-09-18 with reprex v2.0.2


Logging in: fields in a header, or dedicated link?

Question: Does anyone know if it's better practice to include user login fields in the header of a website, or just a login link that takes the user to a login page (or a modal lightbox style login)?
For example, Facebook has login boxes on every guest-side header:

Whereas Yahoo has a link:

Alternatively, Twitter has a box that pops up when you click the login link:
Any thoughts either way?
Answer: As it is quite often the case: it totally depends on what you want to achieve. Using Facebook eventually only makes sense when you're logged in – so that's probably he first thing you would want to do when visiting their website. Other websites might prefer the opposite approach.
We were just discussing this in a project I'm currently working on – and while the client first wanted to have the login fields present at all times, we finally decided it actually suits the purpose of the website better to have them on a seperate page. The client is a rather exclusive 'club' of some hundrets of people – so while having the login form present at all times would be user friendly for them, it would awake the wrong expectations to everybody else.
Personally I prefer form fields on seperate pages – also when visiting other people's websites. IMHO form fields often take too much attention off the actual content – and they're usually only needed in quite special situations (login/search). If I really want to login or do a search I'm patient enough to do the extra click. But maybe that's just my personal opinion.


How to install rtorrent on Ubuntu 12.04?

Question: I have newly installed Ubuntu Server 12.04 and I want to use rtorrent. How can I install it?
Comment: http://blog.walakka.com/2010/07/20/installing-rtorrent-rutorrent-on-ubuntu-server-10-04-lts/
Comment: I have followed step by step in this tutorial, everything is describe, how to install and configure ruTorrent and rtorrent on Ubuntu. http://terminal28.com/how-to-install-and-configure-rutorrent-rtorrent-libtorrent-xmlrpc-screen-ubuntu/
Answer: You should just run
<code>sudo apt-get update
sudo apt-get install rtorrent
</code>
from the console.
Answer: To use rtorrent in Ubuntu 12.04, simply install the rtorrent  package in the Software Center.
(However, if you have a command-line only system without the Software Center, you should use this way. You may want to accept that answer.)


How to change color of JPanel with ActionListener

Question: I'm learning basics of Java Applet and Swings. I'm trying a simple code. I want to change the color of my panel when a button is clicked. Here's the code:
SimpleGui.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SimpleGui implements ActionListener {
    JFrame frame;
    JButton button;

    public static void main(String[] args) {
        SimpleGui gui = new SimpleGui();
        gui.go();
    }

    public void go() {
        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        button = new JButton("changes colour");
        button.addActionListener(this);

        MyPanel drawPanel = new MyPanel();

        frame.getContentPane().add(BorderLayout.SOUTH,button);
        frame.getContentPane().add(BorderLayout.CENTER,drawPanel);

        frame.setSize(300, 300);
        frame.setVisible(true);
    }

    //event handling method
    public void actionPerformed(ActionEvent event) {
        frame.repaint();
        button.setText("color changed");
    }
}

class MyPanel extends JPanel {

    public void paintCompenent(Graphics g) {
        g.setColor(Color.green);
        g.fillRect(20, 50, 100, 100);
    }
}

I added some println statements to debug and I found out that paintComponent method is not called. Can you please correct me. Where I am making mistake. Is my entire implementation is wrong?
Answer: paintComponent must be protected (see here).
change your code to :
class MyPanel extends JPanel {
     protected void paintComponent(Graphics g) {
        g.setColor(Color.green);
        g.fillRect(20, 50, 100, 100);
    }
}

Result:
Comment: @Tanzeel Ok. Try to use some tools like `WindowBuilder` or equivalent ... it will be more simple
Comment: @Tanzeel can i know why you do all this?
Comment: I want to see how GUI of Java works. How things are implemented and how they react. I'm learning java gui basically.
Comment: But changes are happening as program loads, it should happen only when i press the button.
Comment: thanks @Landstalker, Can I add some `rgb` code in `g.setColor(Color.green);` so that with every click I can increment integer values like `count++` and thus apply a different color with every click?
Comment: Ok. I found my answer here: https://stackoverflow.com/questions/42855224/how-to-add-rgb-values-into-setcolor-in-java


How is Pokérus handled in championship?

Question: I was thinking, is Pokérus negated or banned at all for the Pokémon video game championships? Because if not, I would think it would be absolutely necessary for any level of competition in the tournaments.
I looked through the posted championship rules and I couldn't find any reference to Pokérus, and on Serebii's entry for Pokérus there is no mention of championship at all, so is there any ruling about this?
Comment: @Angzuril So they increase how fast your EVs go up, but they don't change EV cap so it wouldn't be any different from  training without Pokerus?
Comment: What do you think Pokerus does? It helps with EV training but not during an actual fight
Comment: @Angzuril Don't EVs help with the gaining of base stats (HP, Attack, Defense, Sp. Attack, Sp. Defense, Speed) which would boost the overall capabilities of a Pokemon?
Comment: I've tried to update my answer to address your comment
Comment: That is correct
Comment: @Angzuril Don't effort values affect how many stat points a Pokemon gets when leveling up?
Comment: @Cyberson indirectly, yes. EVs are a part of the stat formula, so if a Pokemon has many EVs in one stat, that stat will also grow more. At the end of the day, though, every Pokemon has a limit of 510 total EVs, 252 in each individual stat (255 in some generations). Pokerus just makes it easier to gain those 510 points.
Comment: @scenia wouldn't that mean a Pokemon that gained pokerus early on in training would have higher stats than the same Pokemon if it had not gained pokerus?
Comment: Yes, the Pokemon with Pokerus will have the double of EVs then the "uninfected" one, and therefore higher stats. But the total EVs they can gain is the same.
Comment: I play VGC and nobody even cares if you hack your team in, just as long as everything's legal during the battles themselves.
Comment: @Cyberson only while none of them reaches the maximum. Since it only doubles the rate at which EVs are gained, but doesn't affect how many a Pokemon can have in total, it makes it a little easier to train it. It's a little like the Lucky Egg, which increases experience gained. This makes it faster to get a Pokemon to Level 100 (or 50 for competitive purposes), but it won't make a Pokemon go over Level 100. Since in championships, a Pokemon will always be fully EV trained, it makes no difference how quick it was to get there.
Answer: Championships do not care about Pokérus. It is useful for training Pokémon, but having Pokérus does not have any effect in online battles.
Pokérus is used to raise Effort Values (EVs) faster than normal. Note that it is not required for EV Training, but just cuts the amount of time required in half. From Bulbapedia :

When a Pokémon has the Pokérus, it gains double the effort values from battling.

However it does not increase the maximum EVs a Pokémon can obtain. This means you can fully EV train your Pokémon without ever having Pokérus. Bulbapedia:

A Fully Trained Pokémon is a Pokémon that has reached 510 EVs overall, the maximum a Pokémon can achieve

It does not matter when a Pokemon gains EVs. Since Generation V, EVs are applied as soon as they are gained, and you do not need to level up in order for them to apply. The formulas for stat totals only care about the EV values, when they changed doesn't matter. Bulbapedia.

Lastly, although Pokerus may appear as a 'status' it does not prevent status conditions

When a Pokémon is infected with Pokérus, their status screen will display an icon indicating this special "status" the same way status conditions would be noted. If the Pokémon becomes affected by a status condition such as Sleep, the Pokérus icon will be temporarily replaced until the status condition is cured.

How is Pokérus handled in championship?


How to prevent Firefox Developer Tools to scroll page to top?

Question: I've noticed that when I've the Firefox Developer Tools opened and I open any page (i.e. http://www.bbc.com/news) it scrolls the page to the top.
I've the 53.0.3 (64 bit). 32bit is the same.
How can I prevent this?
Comment: Related: [Page jumps to the beginning after reload with open developer tools in firefox](https://stackoverflow.com/q/43974146)
Answer: This is obviously a regression in the Firefox DevTools. So I've created bug 1371050 for it.
Update:
My bug report got marked as duplicate of bug 1365209.


Remove leading and tailing whitespaces from filename

Question: I need a little help with a bash command in Ubuntu 14.04.
I have a folder with many subfolders and some of the folder- and filenames have leading or tailing whitespaces. I like to rename these folders and files, but with the same filename, just without the whitespace an the beginning and the end of the filename. Like a recursive file-rename or something like that. I've tried it with sed, but i don't get it running like it should.
I hope somebody can help me.
Answer: This should do:
shopt -s extglob
while IFS= read -r -d '' f; do
    d=${f%/*} b=${f##*/*([[:space:]])} b=${b%%+([[:space:]])}
    echo mv -v -- "$f" "$d/$b"
done < <(
    find -depth \( -name '[[:space:]]*' -o -name '*[[:space:]]' \) -print0
)

As written, it won't do anything, it'll only echo the mv that will be performed. Remove the echo if you're happy with that.


How do you formally justify using limits on an interval?

Question: Example: Let $f$ be continuous at $c$, and let $m_h = \inf \{ f(x) : c \le x \le c + h \}, M_h = \sup \{ f(x) : c \le x \le c + h \}$. Then $\displaystyle\lim_{h\to0} m_h = \displaystyle\lim_{h\to0} M_h = f(c)$, but what is the formal justification for this?
Really, what we have is an interval $I = [c,c+h]$ and then $\lim_{h\to0} I = c$, correct? But still, this seems non-rigorous in the sense that the $\varepsilon-\delta$ definition of a limit existing that I know of won't support taking the limit of an interval in that form. Of course, intuitively it makes sense.
But also, we don't necessarily require a closed interval. For example: The MVT states that if $f$ is differentiable on $[a,b]$, then $\exists c \in (a,b)$ such that $f(b) - f(a) = f'(c)(b - a)$. Now when solving a certain problem in Spivak's Calculus, he used the fact that if $f$ is differentiable on $[a,b]$, then for $x \le b$, $f(x) - f(a) = f'(\zeta)(x - a)$ for some $\zeta \in (a,x)$. Then he argued that as $x \to a$, $f'(\zeta) \to f'(a)$. But how does this make sense? $\zeta \in (a,x)$, so as $x \to a$, we get the interval approaching $(a,a)$.
Comment: You don't need "limits of intervals" to answer this question, and you don't need to go into the MVT to understand it. A straightforward proof using the definitions of continuity, of limits, and of infimums is certainly possible. Did you make any attempts in that direction?
Comment: @LeeMosher Yes, in the first example would want to show that $\forall \varepsilon > 0, \exists \delta > 0, 0 < |h| < \delta \implies |\inf \{ f(x) : c \le x \le c + h\} - f(c)| < \varepsilon$. If we let $\alpha$ be the infimum, then $\alpha \le f(c)$ by definition, so we want to show that $f(c) - \alpha < \varepsilon$.

The point of my second example is that the open interval goes to $(a,a)$ and so MVT is not even satisfied!
Answer: I assume that $f : \mathbb{R} \to \mathbb{R}$ and $h \ge 0$.
Note that $m_h \in \mathbb{R}$. So actually,  we could write $g : \mathbb{R}^{\ge 0} \to \mathbb{R}$,
$$g(h) = \text{inf} \{f(x):c \le x \le c+h\}$$
There are no limits of intervals (although you can imagine that $g$ is related to a family of descending intervals). The limit can equivalently be written as $\lim_{h \to 0} g(h)$, where as noted, $g$ is a standard function $\mathbb{R} \to \mathbb{R}$. Similarly for $M_h$.
Hopefully, this answers your main question. With Spivak's proof, the issue is that:
$$x \to a, \; \zeta \in (a,x) \not \Rightarrow \zeta \in \lim_{x \to a} (a,x)$$
even if the limit on the RHS is/was well-defined. Again, we are only concerned with the limit of a function $\mathbb{R} \to \mathbb{R}$, which in this case is $f'$. We seek to show that $\forall \epsilon > 0, \exists \delta >0 $ such that:
$$|x - a| < \delta \implies |f'(\zeta)-f'(a)| < \varepsilon$$
(Or you could use an equivalent formulation in terms of sequences.)
In this case, there is a simpler way to do it:
$$f(x)-f(a)=(x-a)f'(\zeta)$$
$$\implies  f'(\zeta) = \frac{f(x)-f(a)}{x-a}$$
$$\implies \lim_{x \to a} f'(\zeta) = \lim_{x \to a} \frac{f(x)-f(a)}{x-a}$$
$$ \implies \lim_{x \to a} f'(\zeta) = f'(a)$$
Comment: But why doesn't it matter that $\zeta \in (a,x)\to(a,a)$ as $x \to a$?
Comment: @politeproofs It doesn't matter because it is not what Spivak claims in the proof. He writes $f'(\zeta) \to f(a)$ as $x \to a$, which is a statement about $f'$, not the interval $(a,x)$. Remember also that we can define limits $x \to a$ of a function $g$ even if $g(a)$ is not defined. Limits are about the behaviour *near* a certain point, not at the point.
Comment: But to even get the existence of $f'(\zeta)$, we use the MVT which tells us that $\zeta \in (a,x)$.
Comment: And another thing: you're right we could write $m_h$ as $g(h)$. But isn't $\lim_{h\to0^+} m_h$ undefined? We need $\lim_{h\to0^-} m_h$
Comment: @politeproofs We are only concerned with the limit of $f'(\zeta)$. This is perfectly well-defined even if $ \zeta \in (a,x)$. If you disagree, please explain why the reasoning I gave fails. The issue is just that you are misinterpreting the limit. As for $m_h$, note that if $h < 0$, we are taking the infimum of an empty set. This is unlikely to be what is intended, which is why I assumed at the start of my answer that $h \ge 0$. I do not see any reason why the limit $h \to 0^+$ would be undefined.
Comment: I disagree, because $(a,a)$ is empty. So no such $\zeta$ exists. As for the other one, I meant to say $h \to 0^-$ would be undefined if we assume $h > 0$.
Comment: @politeproofs And where did I use in my proof that $(a,a)$ is non-empty?
Comment: @politeproofs You are fundamentally misunderstanding the nature of limits. The fact that $(a,a)$ is empty is totally irrelevant to any attempt to prove or disprove this. This is evidenced by the fact that I have given a perfectly valid proof despite your doubts. At no point do we require that $\zeta \in (a,a)$, so at no point is there an issue. There's not really much more I or anyone else could say; you simply need to revise your understanding of limits. (As Lee Mosher said and I have also said, no limits are actually being applied to any intervals.)
Comment: But why don't we care if $\zeta$ could be in an empty set...
Comment: @politeproofs It is not part of the proof. The same reason we don't care for this proof if my watch is broken or platypuses are mammals. *It is not relevant*. Given that you can't actually demonstrate where I used in my proof $\zeta \in (a,a)$, there is nothing left to say. If logical mathematical reasoning is sufficient for you, then read my proof. If it isn't, then no one here will be able to help you. If you want to continue pondering the *completely irrelevant* idea that $\zeta \in (a,a)$, there's nothing else I can do. It doesn't prove or disprove anything; it is *irrelevant*. Goodbye.
Comment: I'll accept your answer, but I don't think your attitude was appropriate. Yelling that $\zeta \in (a,x) \to (a,a)$ as $x \to a$ is irrelevant is not quite right since $\zeta \in (a,x)$ by the first line of your proof.
Comment: @politeproofs I don't think your repeated refusal to properly read anything I said was appropriate. Don't accept my answer if you don't want to. As I wrote in my answer the very first time, $\zeta \in (a,x)$ "$\to (a,a)$" (which doesn't even make sense) does not imply $\zeta \in (a,a)$, as you kept on insisting. "Why don't we care if $\zeta$ is in an empty set"? *It never is*, as I repeatedly pointed out to you, and this should be clear to you since you are clearly familiar with the concept of a limit. Try not to force someone to repeat themselves thrice in the future.


Industry Specialization in Cities: Skylines

Question: I have tried to set my district specialization to an Oil district.  However when I go into the district menu, I see that it has no specializations.  How do you set up industry specialization in district?
Answer: In order to build 'specialized' industry, you need to fulfil the requirements necessary for that type of specialized industry. Make sure the following things are present in your city:

You have zoned an area of industry within a district with the specialization you want.
The zoned area (partially) covers the correct natural resource.
You have enough workers available of the correct education level. Oil and Ore industries want a mix of education levels, while Farming and Forestry prefer 'low' education levels.
Provide the industry buildings with the services they need. Typically this includes Power, Water, Crime protection and Fire protection services.
Answer: I figured out the issue.  In order to specialize you need to first create your district.  AFTER you create the district go into the second tab on industry specialization, and click the industry you want.  Then with that selected, click on the district you want to set specialization for.
Comment: That's for zoned (vanilla) industry specialization.  For Industries DLC specialization you have to click on the tab for that industry and plop a main building in the zone.


Microwave replacement

Question: I need to replace a microwave that used to be in the space shown below. I am not sure what kind of microwave should I put there or what kind of prep work I should do. I think the microwave that hangs onto a plate won't work here. Notice also that trim work around the opening is pretty rough, it used be covered by microwave surround kit. The space opening is 25"x15"x16".
Comment: If the total opening is 30 inches, you may be able to remove the entire cabinet box and hang an above the range micro there.  If not you will just have to shop for a countertop micro that fits.
Comment: Not sure what the question is. Buy a micro that fits. Go to microtrim.com or equivalent for the surround.
Comment: @RMDman that was my first thought too.  If the gap between the adjacent cabinets is 30", an OTR nuke would fit there well (door opening to the left would be best).  OP might have to relocate the outlet to the cabinet above, but that should be reasonably trivial.
Answer: You'll have to shop for countertop microwaves that (a) fit the space, (b) do not require ventilation in the back or, if they require ventilation in the top, bottom or sides do not require more than you can provide here. What is likely to work best is models that are designed for in-cabinet mounting, which is often an option that includes a kit to (a) surround the front (solving your trim problem) and (b) lift the microwave up so that there can be sufficient ventilation underneath.
Sample search on Home Depot, first result is Frigidaire Gallery which is available with various trim kits. Go to the specifications page (link is on the Home Depot product page) and it shows height 13-5/8" (OK), width 24-7/16" (OK), depth 19-5/8" (NOT OK). But more importantly, there is another page with the dimensions for the trim kits and it also has the "CABINET OR WALL CUTOUT" dimensions:

Height 16-3/4" - 17"
Width 24-3/4" - 25"
Depth 20" Minimum

The 27" trim kit has overall dimensions of, you guessed it, 27" wide. Which would cover up the rough trim nicely.
So while this particular model won't work, those are the sorts of specifications you need to look at until you find one (hopefully) that matches.
A lot of appliances like this are designed for 20" - 23" depth because that's the standard "full depth" appliance size. Typical upper cabinets for dishes and stuff, but not for appliances, are 12" deep and there are some in-between sizes like you have. So it may be a little tough to find something to match the depth that you have.
An alternative is an ordinary countertop microwave oven. Which, provided it fits, will work just fine as long as the ventilation is OK. It just won't have the "built in" look.
Comment: Thank you mentioning ventilation, didn't consider that at first.
Answer: Anything that fits will work, just follow the manufacturers clearance on sides, top and back.  Removing the trim will give you a larger space to work with.

Microwave replacement


usb installation not working properly

Question: I have installed ubuntu from usb so do I need to use that usb in future launches? Cause when I dont it always starts windows and when i use usb it gives me only option to try ubuntu or install ubuntu.
Answer: It appears that GRUB was not installed when you installed ubuntu to your hard disk. You should be able to fix by using Boot-Repair, follow the instructions Link here>  https://help.ubuntu.com/community/Boot-Repair   After using Boot-Repair it will give you the option of which Operating system you would like to use, Ubuntu or Windows :-) Just follow directions on Link that I posted.  Be patient it might seem as tho the operation has frozen, but let it work it's Magic and you Will be HAPPY :-)    Don't forget to reboot :-)

usb installation not working properly


Postgresql drop role command not working

Question: drop role command not working in my postgresql 11. I can't delete the role named 'ckdev' .
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 ckdev |                                                            | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

postgres-# drop role ckdev
postgres-# \du
                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 ckdev |                                                            | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

Answer: Missing ; at the end of sql command?
drop role ckdev;

Comment: it is syntax error, `;` is missing, and postgres didn't talk when there is errors


How to get the elapsed time of a .NET WebAPI call

Question: How can I get the elapsed time for a .NET WebAPI call within C#?
I need such information for my log file
I could easily do a DateTime.Now() just before and after the api call, however, if there is something already made... let's use it!
Comment: I think "Elapsed time" concept refers to `TimeSpan` instead of `DateTime`. How about using `Stopwatch` class with it's `ElapsedMilliseconds` property instead?.
Answer: You can use filter
using System;
using System.Diagnostics;
using System.Net.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using System.Web.Mvc;

namespace App.Utility
{
    ///
    /// Used to log requests to server
    ///
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public class LogActionRequestsAttribute : ActionFilterAttribute
    {
        public LogActionRequestsAttribute()
        {
             //You can inject to constructors ILog or what ever
        }

        public static Stopwatch GetTimer(HttpRequestMessage request)
        {
            const string key = "__timer__";
            if (request.Properties.ContainsKey(key))
            {
                return (Stopwatch)request.Properties[key];
            }

            var result = new Stopwatch();
            request.Properties[key] = result;
            return result;
        }

        public override void OnActionExecuting(HttpActionContext actionContext)
        {

            var timer = GetTimer(actionContext.Request);
            timer.Start();
            base.OnActionExecuting(actionContext);
        }

        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            base.OnActionExecuted(actionExecutedContext);
            var timer = GetTimer(actionExecutedContext.Request);
            timer.Stop();
            var totalTime = timer.ElapsedMilliseconds;
        }
    }
}

Then in webapi config
config.Filters.Add(
                (LogActionRequestsAttribute)
                    GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof (LogActionRequestsAttribute)));

AttributeUsage prevent calling attribute twice.
But i think other option could be yo write http module to use begin, end request events which is probably the best and precise measurements, in my app its enough to use attributes since few milliseconds would not make a big deal for me
Comment: this works well but I find if there's an unhandled exception then OnActionExecuted never gets called, so I lose the timing for that method. Something to keep in mind, if you only need successful calls that's fine, otherwise you need to look at implementing an ExceptionHandler.
Comment: Why would the call to `GetService` when registering the filter result in `null`?
Answer: In case it helps someone, I've added an updated version of Vova's answer below that works for .NET Core.
///
/// Used to log requests to server
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class LogActionRequestsAttribute : ActionFilterAttribute
{
    private const string ACTION = "Action";
    private const string RESULT = "Result";

    private static Stopwatch GetTimer(HttpContext context, string type)
    {
        var key = $"__timer__{type}";
        if (context.Items.ContainsKey(key)) return (Stopwatch) context.Items[key];
        var stopWatch = new Stopwatch();
        context.Items[key] = stopWatch;
        return stopWatch;
    }

    public override void OnActionExecuting(ActionExecutingContext context)
    {
        var timer = GetTimer(context.HttpContext, ACTION);
        timer.Start();
        base.OnActionExecuting(context);
    }

    public override void OnActionExecuted(ActionExecutedContext context)
    {
        base.OnActionExecuted(context);
        var timer = GetTimer(context.HttpContext, ACTION);
        timer.Stop();

        var logger = context.HttpContext.RequestServices.GetService<ILogger<LogActionRequestsAttribute>>();
        logger.LogInformation($"{ACTION} call to {context.HttpContext.Request.Path} took {timer.ElapsedMilliseconds} ms");
    }

    public override void OnResultExecuting(ResultExecutingContext context)
    {
        var timer = GetTimer(context.HttpContext, RESULT);
        timer.Start();
        base.OnResultExecuting(context);
    }

    public override void OnResultExecuted(ResultExecutedContext context)
    {
        base.OnResultExecuted(context);
        var timer = GetTimer(context.HttpContext, RESULT);
        timer.Stop();

        var logger = context.HttpContext.RequestServices.GetService<ILogger<LogActionRequestsAttribute>>();
        logger.LogInformation($"{RESULT} call to {context.HttpContext.Request.Path} took {timer.ElapsedMilliseconds} ms");
    }
}

This attribute can be applied directly to an ApiController with no additional registration.


Attributed Strings for UILabels in Xcode 6

Question: I wanted to change the text of a label that says "hello world" such that "hello" is red, and "world" is blue. I'm doing this programmatically and obviously simplifying this example.
Is there a way to do this?
My alternative was to just create two uilabels, and set the attributes of each one accordingly, and then just add them together next to each other, but I thought it would be great if I could just assign the text of a label as per above instead.
By the way it doesn't have to be a UILabel as long as I can just render this text inside a UITableView row.
Thanks!
Comment: You just have to use `NSAttributedString`. There are plenty of tutorial in `Objective-C` that you could adapt into `Swift`.
Answer: Here is a small example on how to use NSAttributedString:
var resultString = NSMutableAttributedString(string: "Hello ", attributes: [NSForegroundColorAttributeName : UIColor.redColor()])
var worldString = NSMutableAttributedString(
    string: "World",
    attributes: [
        NSForegroundColorAttributeName : UIColor.redColor(),
        NSFontAttributeName : UIFont.boldSystemFontOfSize(13.0)
    ]
)

resultString.appendAttributedString(worldString)

Then you can assign it to UILabel:
UILabel().attributedText = resultString

Comment: Hey thanks for your help - quick question is there a way to also make "world string" bold? What would it look like?
Comment: Updated my answer with example. You can cmd+click on `NSForegroundColorAttributeName` in Xcode to explore other possible attributes.


Why is my hardwood splitting apart and how do I fix it?

Question: I purchased a new home about 2 years ago (the home was built in 1968). I paid someone to resurface/stain my hardwood to be darker and to also get rid of my metal heating vents and replace them with hardwood heating vents that flow naturally. The outcome was wonderful.
The problem I'm running into is that this winter (not the prior winter) I started to notice that a lot of the hardwood is starting to come apart and leave large gaps between the boards. It's not every piece, but it's also enough pieces to be noticeable, with some pieces being very noticeable.
Even though I have hardwood throughout most of the house, it seems to be a problem in the dining room area for the most part; I have my dining room, family room, stairs, and all bedrooms upstairs with hardwood, but only the dining room seems to exhibiting issues.

I checked my heating unit and it has a built in humidifier, and I think that seems to be working (I opened it up and water was in the honeycomb item). I also am not sure why this seems to be only happening in the dining room (it's situated above the heating unit which is in the basement of course).
What is causing this?

Is this due to winter?
Do I have an infestation issue (termites perhaps); note that I have not noticed any critters like ants or anything else in the home?
Is this a humidity issue?

How do I fix it?

Do I have to do something to fix this?
Will it naturally fix itself when the weather warms up and wood expands?
Answer: They say that wood never sleeps.
Seasonal fluctuations in relative humidity cause wood to expand and contract. Winter is traditionally the dry season, which causes wood to shrink. Similarly, summer is typically more humid, which causes expansion.
This is absolutely positively not an infestation of any type.
Not sure why this wouldn't have happened last year, but local weather or changes to your humidifier may have been related.
Short version: don't worry about it.


Why were these things removed from the game?

Question: Does anybody have a source as to why these awesome things didn't make it into the game?
The pneumatic diversity vent: http://www.thinkwithportals.com/media_05.php
This level: http://www.thinkwithportals.com/media_07.php
Is it possible the game could be updated with this content in the future?
EDIT: It's as if I knew about it, except I didn't
Answer: The puzzle from the repulsion gel intro appears like a fairly direct port of part of a Tag: The Power of Paint level, and that as an entire chamber is fairly basic and doesn't teach much except timing.  Stylistically, crushers are fairly absent from the single player campaign, so it doesn't fit well.
According to The Final Hours of Portal 2, the pneumatic diversity vents were removed "at the last minute" after some high-level executive review, as they weren't found to be working well in test chambers.  Ultimately, the mechanism of using portals to knock stuff around can also be accomplished with the blue paint, so they may have wanted to avoid duplicating functionality.
Answer: Likely they were removed because Valve thought they made the game too difficult.
The test chamber in particular required exact timing.


Android Assets and NDK

Question: I'm trying to read a simple text file from my native code.

I placed file.txt under assets folder
In my activity I'm creating asset manager: assetManager = getAssets();
Then I'm passing the assetManager to my native method and(as in the native audio example):
AAssetManager* mgr = AAssetManager_fromJava(env, assetManager);
AAsset* asset = AAssetManager_open(mgr, "file.txt", AASSET_MODE_UNKNOWN);
AAssetManager* mgr = AAssetManager_fromJava(env, assetManager);

off_t start, length;

int fd = AAsset_openFileDescriptor(asset, &start, &length);

The problem is that fd is smaller than 0!!!
Can anyone help on this?
Answer: AAsset_openFileDescriptor will work only with files that are not compressed (like mp3,jpg,png, etc...). It's written in documentation (asset_manager.h header file):
/**
 * Open a new file descriptor that can be used to read the asset data.
 *
 * Returns < 0 if direct fd access is not possible (for example, if the asset is
 * compressed).
 */
int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength);

Use either AAsset_read or AAsset_getBuffer.
Comment: Thanks. So it compressed text file by default?
Comment: For compressed files you can not get file descriptor. If you are using ant task to build apk, then you can modify aapt build task to exculde files with specific extensions from compression: http://stackoverflow.com/questions/6809651/documentation-for-aapt-element-in-ant-script Of course, then your apk file will be bigger.
Comment: Sorry for recomennting but I realy need filedescriptor so what is the way using AAsset_read or AAsset_getBuffer to un compres the file?
Comment: apk file is zip file. So most of files it contains (including ones in assets subdirectory) are compressed. Only specific files like mp3, jpeg, png and few other are not compressed.
Comment: Thanks. Is there a way to config the apk builder of eclipse?
Comment: if you have an .obj file for a model you will need to make sure to not be compressed, this happened to me as well

Android Assets and NDK


how to download turbo c++ in DOSBOX?

Question:
I'm not be able to download TURBO C++. It says it is already extracted.
Comment: @BharadwajRaju The reasons behind why people do or use different things doesn't change or modify the question in any way. If something is supported, even if it isn't recommended or even if it is deprecated, the question is legitimate.
Comment: @Zzzach... Still — is DosBox on-topic?
Comment: @BharadwajRaju I'll agree with you that dosbox by itself is offtopic. If this is an issue with dosbox interacting with Ubuntu in a way that is different than Windows or Mac, then I'd be on-topic. But you're right, seems this question is just about dosbox (as far as I can tell).
Answer: You need to change directory to "Desktop" by cd Desktop and then to tc3 by cd tc3.
Comment: plz, can you be more specific?
Comment: thnx ..but after almost 60% process,i stucked...TC.exe is not able to open in dosbox..dosbox is just coming for 2 sec after clicking on tc.exe...plz,suggest what to do?

how to download turbo c++ in DOSBOX?


How to center text in xfce desktop?

Question: I just installed Flatabulous (a theme) on my computer that runs Xubuntu.
This happened on my desktop:

It seems that the icon text is left-aligned.
I tried looking around /usr/share/themes/Flatabulous/gtk-2.0/gtkrc like others have suggested, but I couldn't find any styles that concerned the icon alignment.
From the xfce docs, it says:

Hidden Xfconf Options
There are a couple of hidden xfconf settings that cannot be set by the xfdesktop-settings application. The channel name that xfdesktop uses is 'xfce4-desktop'. For more information see the Xfconf Documentation.
…
/desktop-icons/center-text

Boolean, default is TRUE.

This value controls whether the text for all the desktop icons label are centered.

I believe this is the correct setting, but I couldn't find it anywhere. It says it should be in xfdesktop-settings (the "Desktop" application), but it's not there. Any tips?
Answer: Based on the quote you provided, it seems that the setting /desktop-icons/center-text should not be in xfdesktop-settings. Instead, it must be accessed via  xfconf-query.
Strangely, it seems that the property /desktop-icons/center-text must be set to false in order to work properly with Flatabulous. This property does not seem to be created by default. In order to make it and set it to false, you can do the following:
xfconf-query -c xfce4-desktop -p /desktop-icons/center-text -n -t bool -s false

You should see the change immediately, but you can log off or reboot if it is not showing up.
Comment: @JonathanLam Thanks for catching the typo. The effect should persist.
Comment: It worked with `false` at the end, not `true`. I think you just made a typo there. Thanks!
Comment: Will this change persist? Will I have to set this setting every time I login?

How to center text in xfce desktop?


Card Problem from Gardner

Question: The following problem is from aha! Insight by Martin Gardner.

On a draw of $n$ cards from a deck without replacement, what is the
  probability that seven of the $n$ cards all have the same suit?

It has been a while since I have done a probability computation so I am here to have my solution verified.
Let $X_n$ be the random event of drawing at least seven cards of the same suit upon drawing $n$ cards.
$$P(X_n) = \left\{
     \begin{array}{ll}
       0 & : n < 7\\
       \dfrac{\binom{4}{1}\binom{13}{7}\binom{39}{n-7}}{\binom{52}{n}} & : 7 \le n < 25\\
       1 & : 25 \le n
     \end{array}
   \right. $$
EDIT: So this counts the number of ways to draw exactly seven cards with $n$ draws. Robert's post gives the desired answer, but I am wondering if there is a simpler expression for the probability given solely in terms of $n$.
EDIT2: Started bounty looking for a solution in terms of $n$. I would also accept an explanation as to why Robert's solution is as simple as it gets.
Comment: Yes, that and the possibility that you have multiple seven-card suits.  I don't have time to work it out now, but your answer is indeed currently incorrect.
Comment: You're getting illogical answers if you replace the 39 with a 45 because it's double (or more) counting some of the hands.  For example, you could choose all of the hearts and some set of the $n-13$ remaining cards by getting 7 hearts from $13 \choose 7$ and 6 from $45 \choose n-7$, but you could just as well choose any other set of 7 hearts from $13 \choose 7$ and still get the same hand by choosing the remaining 6 hearts AND the same set of $n-13$ cards from the $45 \choose n-7$.
Answer: For each
four-tuple $(c,d,h,s)$ of nonnegative integers with $c+d+h+s = n$ and
$\max(c,d,h,s) \ge 6$, the probability of getting $c$ clubs, $d$ diamonds,
$h$ hearts and $s$ spades is
$$ p(c,d,h,s) = \dfrac{{13 \choose c}{13 \choose d} {13 \choose h} {13 \choose s}}{{52 \choose n}}$$
You then have to add this over all $(c,d,h,s)$.  For example, if $n= 15$
the possible $(c,d,h,s)$ are
$$[2, 3, 3, 7], [2, 2, 4, 7], [1, 3, 4, 7], [0, 4, 4, 7], [1, 2, 5, 7], [0, 3, 5, 7], [1, 1, 6, 7], [0, 2, 6, 7], [0, 1, 7, 7], [2, 2, 3, 8], [1, 3, 3, 8], [1, 2, 4, 8], [0, 3, 4, 8], [1, 1, 5, 8], [0, 2, 5, 8], [0, 1, 6, 8], [0, 0, 7, 8], [2, 2, 2, 9], [1, 2, 3, 9], [0, 3, 3, 9], [1, 1, 4, 9], [0, 2, 4, 9], [0, 1, 5, 9], [0, 0, 6, 9], [1, 2, 2, 10], [1, 1, 3, 10], [0, 2, 3, 10], [0, 1, 4, 10], [0, 0, 5, 10], [1, 1, 2, 11], [0, 2, 2, 11], [0, 1, 3, 11], [0, 0, 4, 11], [1, 1, 1, 12], [0, 1, 2, 12], [0, 0, 3, 12], [0, 1, 1, 13], [0, 0, 2, 13], [0, 0, 1, 14], [0, 0, 0, 15] $$
and their rearrangements.
In Maple:
<code>with(combinat):
for n from 7 to 24 do
  P:= map(`+`,select(t -> nops(t) = 4 and max(t) >= 8, partition(n+4)),
          [-1,-1,-1,-1]);
  prob:= add(mul(binomial(13,p[i]),i=1..4)
          *nops(permute(p))/binomial(52,n),p=P);
  printf("The probability for n = %d is %a, or approximately %4.5f\n",
         n, prob, evalf(prob));
od:
</code>
The probability for n = 7 is 33/643195, or approximately 0.00005
The probability for n = 8 is 1166/3215975, or approximately 0.00036
The probability for n = 9 is 272/189175, or approximately 0.00144
The probability for n = 10 is 116534/27657385, or approximately 0.00421
The probability for n = 11 is 40148/3951055, or approximately 0.01016
The probability for n = 12 is 40654/1905803, or approximately 0.02133
The probability for n = 13 is 44677/1108025, or approximately 0.04032
The probability for n = 14 is 397745888/5669763925, or approximately 0.07015
The probability for n = 15 is 491355875/4309020583, or approximately 0.11403
The probability for n = 16 is 139443061606/797168807855, or approximately 0.17492
The probability for n = 17 is 11953182762/46892282815, or approximately 0.25491
The probability for n = 18 is 11865928058/33494487725, or approximately 0.35427
The probability for n = 19 is 14099080786/29968752175, or approximately 0.47046
The probability for n = 20 is 3579684638/5993750435, or approximately 0.59724
The probability for n = 21 is 60779104513/83912506090, or approximately 0.72432
The probability for n = 22 is 1090469390477/1300643844395, or approximately 0.83841
The probability for n = 23 is 261904914329/282748661825, or approximately 0.92628
The probability for n = 24 is 8032961212957/8199711192925, or approximately 0.97966
Comment: Thanks. I was hoping this could be finessed to represent the probability in terms of $n$ alone; this feels a bit brute force.
Answer: Here is a Mathematica code that returns Robert's computations above:
Table[f[list_] :=
  Binomial[13, list[[1]]] Binomial[13, list[[2]]] Binomial[13,
    list[[3]]] Binomial[13, list[[4]]]/Binomial[52, n];
 Total[Map[f, Select[Compositions[n, 4], Max[#] >= 7 &]]], {n, 7, 25}]
Answer: Let's consider a simpler problem with only two suits, say spades and hearts.  Lets suppose there are $S$ cards of each suit in the deck, that you will choose $n$ cards, and that you want to know the probability of getting $k$ or more cards of at least one suit.
The probability of getting exactly $k$ spades is
$$
\frac{\binom{S}{k}\binom{S}{n-k}}{\binom{2S}{n}}.
$$
The probability of getting $k$ or more spades is
$$
\sum_{j=k}^n\frac{\binom{S}{j}\binom{S}{n-j}}{\binom{2S}{n}}.
$$
The probability of getting $k$ or more cards of at least one suit can be obtained using the principle of inclusion-exclusion by adding the probability of getting $k$ or more spades to the probability of getting $k$ or more hearts, and then subtracting the probability of getting $k$ or more of both suits.  This computation gives
$$
2\sum_{j=k}^n\frac{\binom{S}{j}\binom{S}{n-j}}{\binom{2S}{n}}-\sum_{j=k}^{n-k}\frac{\binom{S}{j}\binom{S}{n-j}}{\binom{2S}{n}}.
$$
There is no simple, closed form for these sums.  They can be expressed in terms of the cumulative distribution function of the hypergeometric distribution.  The linked Wikipedia article gives the formula for the cumulative distribution function in terms of a ${}_3F_2$ generalized hypergeometric function, but this is no help, since the generalized hypergeometric function is defined to be precisely the kind of sum of products that I presume you're trying to get away from.
There is an algorithm for determining when sums such as these have a closed form, under suitable definition of "closed form".  See the Wikipedia articles on Gosper's algorithm and Wilf–Zeilberger pairs and the references in those articles for information about this.  I am not in a position at the moment to tell you what this theory has to say about the sums above, but, suffice it to say, there is no closed form.
When you increase the number of suits to four, things get more complicated.  The principle of inclusion-exclusion yields the formula
$$
\begin{aligned}
&4\sum_{h=k}^n\frac{\binom{S}{h}\binom{3S}{n-h}}{\binom{4S}{n}}-6\sum_{h=k}^n\sum_{i=k}^{n-h}\frac{\binom{S}{h}\binom{S}{i}\binom{2S}{n-h-i}}{\binom{4S}{n}}+4\sum_{h=k}^n\sum_{i=k}^{n-h}\sum_{j=k}^{n-h-i}\frac{\binom{S}{h}\binom{S}{i}\binom{S}{j}\binom{S}{n-h-i-j}}{\binom{4S}{n}}\\
&\qquad-\sum_{h=k}^n\sum_{i=k}^{n-h}\sum_{j=k}^{n-h-i-k}\frac{\binom{S}{h}\binom{S}{i}\binom{S}{j}\binom{S}{n-h-i-j}}{\binom{4S}{n}}
\end{aligned}
$$
for the probability of $k$ or more cards of at least one suit.  Only the first of the sums in this formula can be expressed in terms of generalized hypergeometric functions.  I am not sure whether the Wilf-Zeilberger method can be extended to multiple sums, but, given the difficulties that present themselves even in the two-suit case, it is almost certain that there is no closed form.

Card Problem from Gardner


How is an affine connection defined?

Question: Let $M$ be a smooth manifold, and $\Gamma(TM)$ the space of all vector fields on $M$. Wikipedia says that an affine connection on $M$ is a map $\nabla:\Gamma(TM)^2\rightarrow \Gamma(TM)$ that satisfies:
$$\nabla(X,Y)=\nabla_XY$$
$$f(\nabla_XY)=\nabla_{f(X)}Y$$
$$\nabla_Xf(Y)=\partial_Xf(Y)+f(\nabla_XY)$$
for all $f$ in the set of smooth functions on $M$... But the only way that these equations make sense is if the function $f$ satisfies $f:\Gamma(TM)\rightarrow \Gamma(TM)$, since the second equation can be rewritten as:
$$f(\nabla(X,Y))=\nabla(f(X),Y)$$
and then, for this to be true, the manifold should be $M=\Gamma(TM)$, wich makes the definition completely circular.
Maybe there is something I'm not getting but, by this logic, the definition isn't well-posed.
If this definition is indeed incorrect, how is the affine connection properly defined when working with things like Riemann curvature tensors?
Comment: This is incorrectly parsed. You should have $f\nabla_XY$ and $fX$ — scalar multiplication pointwise. The third equation also should have no parentheses in either term. If Wikipedia wrote things this way, you should abandon it and read a good textbook.
Comment: Try reading this: https://math.stackexchange.com/questions/354561/question-regarding-the-definition-of-affine-connection?rq=1
Comment: @MatteoIaccarino No, the derivative of $f$ along $X$ is $X(f)$.
Comment: @TedShifrin, i'm sorry, my original idea was to put a link for the wikipedia article, but i forgot to do it. I've edited the post to include it. As for the parentheses... those are actually added by me... but i don't see why that matters since, clearly, $fX=f(X)$ unless the yuxtapostioning of elements is regarded as multiplication.
Comment: @SimónFlavioIbañez and what does $fX$ mean if not the pointwise scalar multiplication? I guess that one has to first clarify that in order to understand that definition
Comment: Actually in this case the parenthesis change the meaning of the expression. As @TedShifrin has already pointed out $fX$ means pointwise multiplication, while $f(X)$ is the derivative of $f$ along the vector field $X$. So in the definition it should be written without parenthesis.
Comment: @TedShifrin yes sorry, you are right!
Answer: The definition is actually correct (without parenthesis, as already pointed out in the comments). Given $f$ a smooth function on $M$ and $X\in\Gamma(TM)$, you can define $fX\in\Gamma(TM)$ by pointwise multiplication, namely $(fX)(p):=f(p)X(p)$ for any $p\in M$. This is what the $fX$ (and $f\nabla_XY$) in the definition means.
Comment: Thanks. It is not clarified in the article that $fX$ means pointwise multiplication, so i got confused.

How is an affine connection defined?


How to uninstall Neo4j from Window7?

Question: I have been trying to uninstall Neo4j from my laptop.But not able to do so.This is the snippet of the issue I face every time I try to uninstall.
Can somebody help me out?
Answer: It appears the process is running in the background.
I believe terminating the running neo4j community edition process will allow you to uninstall it.
You should be able to do this from the Task manager.
If you dont know how to terminate a running process from the command prompt, you could also try the following

Bring up the run prompt (press both the windows key and "r" key)
Paste this in

taskkill /f /im neo4j-ce.exe

(the running task should be terminated)

uninstall the application now.

Hope this helps.

How to uninstall Neo4j from Window7?


Universal Windows Library (UWP) Way to take screenshot?

Question: I would like to create a ScreenCaptureLib.dll which is intended to be built for Universal Windows.
We already have the following using Windows.Forms:
https://github.com/ShareX/ShareX/tree/master/ShareX.ScreenCaptureLib
Obviously none of the Windows Forms code does not work and I would like some pointers in the right direction to get started.
Comment: I'm afraid there is no api can be used directly to capture the screen from an UWP app on a desktop for now, but you can try to render the XAML Tree to a bitmap, please refer to [Capturing Snapshot in Windows 8.1 Store App](http://blogs.msdn.com/b/lighthouse/archive/2013/10/18/capturing-snapshot-in-windows-8-1-store-app.aspx). You may also submit a request to add this new feature for developing through the Windows Feedback tool. If you find my comments are helpful, can I post them as an answer?
Comment: Please try to follow the official document: [Record the screen with ScreenCapture](https://msdn.microsoft.com/en-us/library/windows/apps/mt282147.aspx).
Comment: @GraceFeng-MSFT thank you! There is a warning however: The ScreenCapture API is only available on mobile devices. Does that mean I cannot use this feature in a Desktop PC?
Comment: @GraceFeng-MSFT thanks for your reply. So basically there is no current way in UWP to do a screenshot or screencast on a Desktop PC, is that right? Are you planning on having this functionality in the future?
Comment: Hi @GraceFeng-MSFT yes please, thanks for your info.
Comment: Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/104476/discussion-between-mcored-and-grace-feng-msft).
Answer: You may follow the official document for Record the screen with ScreenCapture, but please notice that:

The ScreenCapture API is only available on mobile devices.

And for now there is no API can be used directly to capture the screen on a desktop from an UWP app. However, as a workaround method, we can render the XAML tree to a bitmap, to do this, please refer to Capturing Snapshot in Windows 8.1 Store App.
You may also submit a request to add this new feature for developing through the Windows Feedback tool.
Update:

The ScreenCapture feature is only supported for mobile devices running Windows Phone 8.1. This API is not supported on Windows 10.


Android appcompat v7 - imported with an error

Question: I just created a new Android project in Eclipse. After that I managed to import the android-support-v7-appcompat lib. Unfortunately an errors are given:
<code>../res/values-v21/styles_base.xml:75: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:79: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.CloseMode'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:83: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.Overflow'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:25: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabView'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:29: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabView'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:33: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabText'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:37: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:41: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:65: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Title'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:69: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Subtitle'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:45: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Menu'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:49: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:53: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:57: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title.Inverse'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:61: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle.Inverse'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:178: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:182: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:113: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:115: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:110: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.DropDownItem.Spinner'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:107: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView.DropDown'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:121: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:126: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListPopupWindow'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:138: error: Error: No resource found that matches the given name: attr 'android:overlapAnchor'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:143: error: Error: No resource found that matches the given name: attr 'android:overlapAnchor'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:129: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.PopupMenu'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:132: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.PopupMenu'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:146: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:150: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:154: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:158: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:164: error: Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Title'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:168: error: Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Subtitle'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:172: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.AutoCompleteTextView'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:174: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.AutoCompleteTextView'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:93: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Toolbar.Button.Navigation'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:97: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base.xml:101: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:62: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:20: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:22: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display4'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:24: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display3'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:26: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display2'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:28: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display1'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:30: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Headline'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:32: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Title'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:34: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Subhead'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:36: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:38: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:40: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:42: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Menu'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:60: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:46: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:48: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:50: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:52: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:54: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:56: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/styles_base_text.xml:58: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:26: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:31: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:36: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Dialog'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:41: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light.Dialog'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v11/themes_base.xml:338: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v14/themes_base.xml:29: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v11/themes_base.xml:345: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v14/themes_base.xml:37: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v11/themes_base.xml:352: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v14/themes_base.xml:45: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v11/themes_base.xml:359: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v14/themes_base.xml:53: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:202: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:212: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Light'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:205: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Dark'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:219: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.ActionBar'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:223: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Dark.ActionBar'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:81: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:83: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:84: error: Error: No resource found that matches the given name: attr 'android:colorControlHighlight'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:82: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:79: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:80: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:118: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:120: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:121: error: Error: No resource found that matches the given name: attr 'android:colorControlHighlight'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:119: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:116: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:117: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:155: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:157: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:158: error: Error: No resource found that matches the given name: attr 'android:colorControlHighlight'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:156: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:153: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:154: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:192: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:194: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
[2015-02-08 16:23:01 - android-support-v7-appcompat]
../res/values-v21/themes_base.xml:195: error: Error: No resource found that matches the given name: attr 'android:colorControlHighlight'.
</code>
And that's not even the whole error log. The complete one is here.
I have the latest sdk installed. Ther error is in res/values-v21/styles_base.xml Do you have any idea what causes this problem and how to fix it?
Comment: I did the following, Project, Properties, Android, choose android 5.0.1, Project, Properties, Choose Java Compiler 1.7 and in the manifest
Comment: Possible duplicate of [Error in styles\_base.xml file - android app - No resource found that matches the given name 'android:Widget.Material.ActionButton'](http://stackoverflow.com/questions/26530415/error-in-styles-base-xml-file-android-app-no-resource-found-that-matches-the)
Answer: This fixed my problem. I don't know why it is not accepted but it worked out for me.
Answer:
To solve, download this appcompat v7 and import in to your workspace.
android-support-v7-appcompat


Installed some Gnome Shell Extentions with apt (deb package) - Howto enable them?

Question: I did:
sudo apt install gnome-shell-extension-show-ip
sudo apt install gnome-shell-extension-weather

I checked the GUI "Extensions" and "gnome-tweaks" and don't see them in this list. How to enable and configure them?
Answer: Once installed the extensions with those commands, try to restart the gnome-shell by Alt+F2 type restart and Press Enter..

Then open extensions app or tweaks to control them..
Alternatively logout and logback in is also a way..
I just relogin, once the two commands you mentioned are ran.


cs50 pset2 caesar---validating the key

Question: I'm going through cs50 and I'm stuck on pset2 caesar. I'm taking it step-by-step as instructed and I got past the part about validating the key--making sure the command-line argument is only a number (./caesar 20) and if not (./caesar 20x or ./caesar xyz) to print out Usage: ./caesar key\n. But once I add the next lines to prompt the user for plaintext and then print back the ciphertext it doesnt seem to register the former lines that validate the key. I am aware of Harvard's academic integrity policy so I'm more asking for hints/help/explaination with this. I've posted my code below and any help is greatly appreciated.
int main(int argc, string argv[])
{

        int i = 0;
        if(isalpha(argv[1][i]))
        {
            printf("Usage: ./caesar key\n");
            return 1;
        }
        else
        {
            int key = atoi(argv[1]);
            string text = get_string("plaintext: ");
            printf("ciphertext: ");
            int n = strlen(text);
            for(i = 0; i < n; i++)
            {
                if(isupper(text[i]))
                {
                    printf("%c", (((text[i] - 65) + key) % 26) + 65);
                }
                else if(islower(text[i]))
                {
                    printf("%c", (((text[i] - 97) + key) % 26) + 97);
                }
                else
                {
                    printf("%c", text[i]);
                }
            }
    }
    printf("\n");
    return 0;
}

Comment: It just readabillity thing, but use the char literals like `'a'` rather then their ASCII values.
Comment: `printf("Usage: ./caesar key\n"); return 1;` is an anti pattern.  If there was no error, the you should `return 0`.  If there was an error, then an error message should have been written to stderr.  A usage statement is not an error message (countless annoying programs that write 100 lines of usage statement as error message to stderr which are then bypassed by the pager when the user re-runs the program with `| less` appended).  In this case, an invalid character is an error, but a usage statement is the incorrect response.  Specify the error, and write to stderr.
Comment: I am not sure what your problem is, but to debug, assign the cipher calculation  to a variable and inspect the variable with the debugger before printing it.
Comment: I assume `get_string` gets a string and allocates a buffer which it returns?
Comment: Don't hard code values like '65', '97', and '26'.  Pretty sure you want `'A'`, `'a'`, and `'z' - 'a' + 1`.  (An argument could be made that 26 is okay, but you definitely want `'a'` and `'A'` instead of 97 and 65.
Answer: You need to rework the input validation.

It does not ensure that one argument is supplied at the command line.
It is only validating the first character of argv[1]. Program should test that every character of the argument is a digit (see man isdigit). isalpha() is not a good test. What if user enters $?

It is not clear when program doesn't work, but this will not pass check50 based on these defects.
Answer: You have to check 2 things in the command-line argument.
1. Check if you have 2 arguments. (This is not checked in your program)
2. Check if it is not an alphabet... Since the second argument is automatically a string (due to string argv[]), you must convert it first to integers. ---- this breeds sub-problems that you must take care of by:
2.A. Check the string one-by-one (per CHARACTER) and all must be an integer.
2.B. If at least one is a character then return false...
2.A. and 2.B. should be a nested in a separate function that would return a boolean value(T/F), then from that boolean value, enclose those two boolean expressions in the while loop.
2 months late on my answer but since I just finished this problem, I thought maybe someone might be experiencing the same difficulty I had with this so hope someone can read this and help them out. :)

cs50 pset2 caesar---validating the key


What do I need to do to configure a new iPhone project so it can be seen as the same as my current iPhone app in the Appstore?

Question: I currently have an app in the Appstore. I need to make changes to the app, but they are significant enough that we've decided it would be easier to create a new Xcode project from scratch rather than modify our existing project. I don't fully understand everything that goes into an iPhone application, just enough to support the code and make basic changes. But I assume that the binary I upload to the Appstore, to replace my existing code there, needs to be similar enough so Apples sees it as the "same" code. What things in the new project do I need to make sure are the same as the old project so Apple knows it's the "same" app?
I've compared the Info.plist file in both projects to make sure they're the same. I only needed to change the bundle identifier in the new project to match the old. Also, the Product Name has been modified to be the same. I don't know if these changes are necessary, but they are the sort of things that I think need to be the same. Are there others? If so, what are they?
Answer: The only thing that matters, as far as the app store is concerned, is the app id (Bundle identifier).  You can rename the app, change the icon, upload an entirely different program, whatever.  As long as the app id matches, the store considers it the same.
Answer: Other things I would check are the Build Settings if the defaults are not suitable or the Code is having issues compiling and the Build Phases and Build Rules for all your Targets.
Essentially if your Code compiles fine and you have no issues within the Application then the Bundle Identifier and the name (Basically the Info.plist) needs to be the same to replicate.
Edit: If you have migrated from an older Xcode version then you may have different Build Settings and Build Phases. I would just see if compilation is okay and the App works properly in functionality under all your Targets
Comment: The new project compiles just fine. So I verified that the Info.plist file is named the same as well as the Bundle identifier. Thanks.


How to extract multiple dictionaries from a text file with no new line using Python?

Question: I have a text file with the following type of data:
{'key1':'data','key2':'data','key3':'data','key4':{'subkey1':'data','subkey2':'data'}}, {'key1':'data','key2':'data','key3':'data','key4':{'subkey1':'data','subkey2':'data'}},
{'key1':'data','key2':'data','key3':'data','key4':{'subkey1':'data','subkey2':'data'}}

Please note that the quotes(' ') are also present in the text file. Each dictionary is separated by a comma and there are no newlines(\n) in the file.
I would like to extract these from the text file as a list of dictionaries.
I am very new to Python and though of reading the entire text file as a single variable using readlines() function and then separating them using pattern matching with regex.
I am unable to figure out a reliable pattern for using regex for the same.
Ultimately, it should look something like this:
extracted_list = [{'key1':'data','key2':'data','key3':'data','key4':{'subkey1':'data','subkey2':'data'}}, {'key1':'data','key2':'data','key3':'data','key4':{'subkey1':'data','subkey2':'data'}},
{'key1':'data','key2':'data','key3':'data','key4':{'subkey1':'data','subkey2':'data'}}]

for dict in extracted_list:
      print(dict['key1'])     #should print 'data under key1'
      print(dict['key4'])     #should print 'sub-dictionary under key4'

Answer: I'm not sure if this is what you mean, but if you want to extract dicts from a text file, then you can do:
import json

extracted_list = []

with open("dicts_file") as f:
    for line in f.readlines():
        extracted_list.append(json.loads(line))

json.loads() creates a dictionary (or list) from a json string. This is then stored in extracted_list.
I hope this helps.


How do I reduce how much the sun heats up a front room of my house?

Question: My office room is in the front of the house and facing south. It gets hot very fast during hot days (even in spring). It is a fairly small room and I have computers there attributing to heat. There's a small double pane window with cloth blinds. There's a central AC but running it full time just cool a small room does not seem very efficient.
What are the ways to reduce amount of heat from the direct sun hitting the wall? Special paint? Drapes? Tent? Fan?
Answer: A good deciduous tree helps, but it will take a while for that to work.  Just be sure not to plant it too close to the foundation.
Light blocking blinds are very good at blocking both heat and light.  This may not be good if you're trying to work in the room.
Insulation helps if you have an attic above, just don't block the ventilation from the soffits.
However, the important thing to realize is that cooling systems spend a significant effort overcoming the heating effects of people themselves.  And a couple computers doesn't help.  No matter how much you block the outside heat, the heat being generated is still there.  Therefore, make sure your vents are adjusted to cool the rooms you use (closing doors also helps), and direct most of your cooling to the upstairs.  If that still isn't enough, try a small fan in the doorway blowing in cool air from the floor (which will push out the hot air above).

Edit: Couple other thoughts.
Get an IR thermometer to check all your walls and various other heat sources.  You may discover a patch of uninsulated wall or find that the window it letting in more than you thought.
Second, check your thermostat to see if it has a setting for how much the temperature will vary before it cuts on.  Mine is an odd key combination that's buried in the back of the manual.  If you're going well over an hour between AC cycles, you'll reduce hot spots by reducing this setting.
Comment: I have a big tree in front but it is not directly shading the wall. I already planted another tree but it'll take awhile. Attic has insulation.
Comment: The small fan at the doorway is a great idea, I use that with my office which has a similar set of problems in the summer.
Comment: Back when we had single pane windows, I hung bamboo type shades under the eave. No sunlight hitting the wall or coming through the window meant that wall heating and interior room heating were eliminated. The slat material and shape determine how much light can get through. Being able to place your hand on the western facing wall in late afternoon was a major step in the right direction.
Answer: There are several options.
One of the easiest ways is a shade or awning over the window. (This is why Australian outback homesteads have deep verandahs.)
Another method is an external shutter, but this will reduce the light a lot, as well.
You could also go for a window coating. There are a number to choose from, ranging from an aluminium film to a fine mesh. The goal is to reflect away the heat whilst not losing too much light.
Comment: The window is pretty small. I think most of the head is coming from the the whole wall exposed to the sun. Thanks for the shade/awning tip.
Answer: with a small room, it could be very efficient to use a small window A/C unit to localize the cooling and reduce the workload on your main A/C.
Comment: or if this is a dedicated office that's always going to have this kind of extra load, a small ductless AC unit just for that room might be the way to go. All the win of a window AC, without the ugly box in the window.
Answer: as far as i know, the best affordable result is passive solar shading that will use the warmth of the winter sun and rejects it in the summer. the specific design is dependent on your latitude and the method of construction, but it should look something like this, and this sketch can also clear the general idea.
solar passive techniques are the best way to handle this issue, and it will save you a great amount of money for the long run, & don't forget to mention the co2 emissions and environmental impact.
here you can find some reference to a bunch of ideas in this field, and i recommend you to read the passive solar energy book. it is a MUST.
edit:

i'm not talking about shading the windows, but really shading the walls.
and you can consider also covering the wall with a deciduous vine that grows fast (like passion fruit) - of course, it depend of your latitude, soil and etc.
Answer: My office in my old house was on the west side of a brick house.  The sun would shine on the bricks all day.  The bricks would heat up and make the room warm even when the sun had gone down.  I put a ceiling fan in the room. The slight circulation of air in the small room helped tremendously.
Answer: Consider window film.  There are ones on the market that are UV blocking that will help cut down the heat in the room without affecting how much visible light comes through.
As another strange answer -- consider adding thermal mass.  Some solar passive homes use stone or brick, but you can also use large containers of water so the room won't change temperature as fast.
Answer: Whatever it takes to shade the wall is the most effective solution. Also use blackout window drapes (when you close them the room is completely dark). Trellis panels with vines, trees or even consider relocating the office to another room.