Seeking advice on how to rearrange existing breakers and add 2 circuits, including a 20A GFCI/AFCI breaker in a split-bus GE panel

Question: My panel is a GE TX1612RH split-bus 125A panel (photo below).  It is an outdoor panel, vintage 1980 when home was built.  I want to run two 20A circuits to a shed 60-ft away and would like to know if the following changes are advisable and in accordance with Code:  1) Move the 2-pole 30A (thin) breaker for A/C to the slot immediately above the 50A "Sub-Main" breaker, thereby consolidating all 240V loads in upper portion (I think the A/C contractor goofed on the electrical portion); 2) Install a 20A "thin" breaker in lower-left slot for a dedicated circuit for an in-wall 120V shed heater (blank-face GFCI will be upstream of in-wall heater); and 3) Install a "full-width" 20A GFCI/AFCI breaker for everything else in the shed, using the slots formerly used by the 2-pole 30A breaker.  Regarding #1: Is it OK to use "thin" breakers in the upper bus, or should I replace the 30A thin breakers with the full-width variety.  Many thanks!
Update #1:  Photo of panel interior has been added.  Unfortunately, there are no placards or labels on inside of panel door or on back side of cover, so I'm driving "blind."  Googling the "K849 *" reference (top of back of panel), I found nothing.
Update #2:  The A/C contractor (in 2008) used very MINIMAL wire to reach the 2-pole compact 30A breaker -- not enough wire to extend to the new and proper position of a full-width 2-pole 30A breaker above the existing 2-pole 50A breaker.  Any suggestions for a remedying this dilemma?  Rules for using red-head connectors wrapped in rubber and vinyl electrical tape?  Or must I pull a new run of #10 copper conductors?
Comment: Can you post a photo of the labeling on the inside of your panel's door please?
Comment: Yes, and the Eel is looking for the data label that includes model number, screw torques, accessories, and a diagram of the panel layout.
Comment: My panel is a similar GE split bus with 150 A service. If you want to reopen this post, I will give an answer. In my panel the ac is powered by a full sized 2 inch wide 40 A breaker in the upper section.
Comment: How are you running two 120V circuits to a shed without violating NEC 225.30?  Will one of them be on a switch?
Comment: Thanks.  I don't have the NEC text (I presume you have to purchase) but thought I could run separate neutrals for the 2 circuits (one dedicated, and one shared).  Now I know better.
 What kind of switch would make a 2nd circuit legal?  Would I need a subpanel for both circuits inside the shed?
Comment: @Marty -- can you get us photos of that label on the inside front cover? Why are you wanting to put the shed lighting on GFCI?
Comment: Hi, Eel:  Unfortunately no labels, placards, etc., anywhere in the panel, so I'm not even sure of the panel's amperage, but other posts suggest either 125A or 150A (determining the gauge of the service feed wires has been difficult). Shed lighting will share a circuit with all the receptacles, which include a weatherproof outlet where power first enters the shed. With our heavy snowfalls, I'd like GFCI protection either at that first outlet or at the breaker.  Hoping two 20A 120V circuits to shed will be legal if each is fed by a breaker in the "Rule-of-Six" panel area (see Monica's comment).
Answer: This is a split bus aka rule-of-six panel.  They were originally developed because breakers over 60A were cost prohibitive (no longer true).  They are outlawed now, and are dangerous because nothing prevents you from overloading the service.
They were allowed when a load calculation was done that showed the house would not overload the service; however, when people add circuits they don't bother to do another load calculation, and that's the danger. Normally a large load like  the A/C would be put in the Rule of Six area; putting it in the Lighting area makes me wonder if they did a load calc and it went badly. Any idea what came out of that space?
GE and their double-stuff rejection system
GE has a funny way of doing double-stuff breakers.  All their bus stabs look like normal bus stabs, a flat horizontal blade maybe 3/8" to 1/2" wide.  However, on spaces enabled for double-stuff breakers, they have a vertical rod - I call it a "cruciform" for the way it crosses the bus stab.  The double-stuff (1/2" wide single and 1" wide 2-pole) clip onto this cruciform.
In 1966 NEC added "CTL" rules limiting the number of double-stuffs in a panel. They required mechanical keying to reject double-stuffs where not allowed, so most builders notched their bus-bars and came out with "CTL" breakers which would reject in a normal space. (as well as non-CTL breakers to support pre-1966 panels, haha, guess what everyone did).  GE simply omits the cruciform.  Which means, there's no way to trick a double-stuff where GE doesn't allow it.
In a split-bus aka "Rule of Six" panel, there can only be six breaker throws to de-energize the whole panel.  So there would be no earthly reason for GE to install the double-stuff-enabling cruciform in those spaces.
Now, this panel only supports four full-size 2-pole breakers in the "Rule of Six" section. You might think GE intends you to use three 1" wide 2-pole breakers per side.  Looking closely, it appears the cruciforms are in exactly the right place to support just that - note there is no cruciform on the top half of the top space, so you can't put a 1/2" wide 1-pole there. You'd have to leave that empty.
You can't run 2 120V circuits out to a shed, anyway
Rule 225.30 says you can only run one circuit to an outbuilding. The rule intends that be a feeder to a subpanel.  However, there are certain exceptions:

A different-voltage circuit is OK, and this is where I'll introduce you to the multi-wire branch circuit. This is a 120/240V circuit with 120V loads placed between one of the two hots and the shared neutral. You can also power 240V loads between the two hots (but the breaker must be 2-pole if you do that).
If one of the circuits is switched from the supply end, then it's OK.  So if you are hellbound and determined to have 2 independent circuits, find a believable pretense to put a switch on one. (e.g. so you don't have to put your shoes back on to switch off the forgotten shed lights).

Breaker strategies
One option is to get a full-size 2-pole 30A breaker, place it in the open position, and use it for the A/C.  This will require extending the A/C cables, but you can do that with normal (well, large red or tan) wire nuts.
That frees up the 2 double-stuff spaces for 2 thin breakers (or a 20A 2-pole for an MWBC).
Another option is just get two full-size 1-pole 20A breakers and put them in the Rule of Six area and use them for your new circuits. You still only have five throws to turn everything off, so that's legit. Nowhere is it written that circuits in the Rule of Six area must be 240V.

You could also get one 1/2" and one full-size breaker in that Rule of Six area, if that matches the current knockouts that are removed from the panel cover.

For that matter, you could put three 1/2" breakers in the Rule of Six area, because that will be only six throws.  Keep in mind for future, heh, expansion in this very full and obsolete/dangerous panel.

Any now-empty breaker knockouts need to be filled with a blanking plate - you can't have curious fingers finding bus bars.  I find those blanking plates to be expensive, hard to find and very flimsy - so I prefer to arrange panels so all holes are full of real breakers. Which are not flimsy.
Comment: Monica:  Thank you!  If I understand the above, I could LEGALLY run two 20A 120V circuits to my shed, provided I feed them with two full-size 1-pole 20A (GFCI/AFCI) breakers in my Rule of Six Area.  If so, I'd leave my 2-pole 30A breaker for A/C where it's at and run five #12's (2 hots, 2 neutrals, and a ground wire) in 1/2" rigid conduit to a weatherproof receptacle on the outside of my shed, then go from there.  I would also have a 20A single-pole switch on the dedicated circuit (for powering the heater on/off) but INSIDE the shed. Heater is hard-wired; has a thermostat but no on/off switch.
Comment: But as I wrote my panel GE TX1615F FLUSH MOUNT 150 AMPERE the sticker indicates the left side will accept three compact 2-pole breakers and would leave two open 1/2 inch spaces. If the bus bar is the right shape then could it be that a 1-pole 20 A breaker would fit there to go to the shed? Or is the shape of the bus bar connection designed to exclude placing a 1-pole 1/2 inch breaker in the top and bottom? Right now I don't want to pull a breaker and see. Only one half slot could be filled to satisfy the rule of six.
Comment: In my case only one open half slot could be filled to satisfy the rule of six. Right now my my upper section if filled with four full size 2-pole breakers: 30 A, 40 A, 50 A, 60 A for dryer, a/c, range, main, respectively. I could replace the 50 A with a 40 A for our current range.
Comment: @Marty you're right on track, EXCEPT the switch must be at the house. See my two exceptions to 225.30.
Comment: OK, thanks, Harper.  I misinterpreted your "breaker" comments --thought putting the two 1-pole 20A breakers in the Rule-of-Six area would qualify both as "switches at the supply end."  The panel is outdoors on my patio and 60' from the shed, so the best place for the switch would be on the patio next to the panel.  Will give consideration to a Plan B: a subpanel in the shed, an MWBC, a main lug panel, or dropping the in-wall heater which would obviate the need for a dedicated circuit.
Comment: @Harper:  I'd like to go with the MWBC strategy you outlined above.  I'll reconnect my A/C to a full-size 2-pole 30A breaker in my Rule-of-Six area, and use the freed-up thin slots for a 2-pole 20A breaker.  I do not need 240V, so will "split" the hots at the shed into two 120V circuits -- one for my 1000W in-wall heater, and one for all else (lights and receptacles).  GFCI protection to be provided by a blank-face GFCI for the heater, and a GFCI receptacle for the other 120V brancht.  Question:  Will such a strategy satisfy the dedicated-circuit requirement for the heater?  Thanks much!
Comment: @Harper:  Can you confirm that the MWBC strategy above DOES need to be on a 2-pole 20A breaker (even though I'll never need or use 240V), and that this strategy obviates the requirement for a switch on the "supply" end?  Many thanks!
Comment: @Harper:  My understanding is that I am obligated to use a 2-pole 20A breaker in order to satisfy the "one-circuit-only" rule of NEC 225.30, but the only way I could possibly satisfy the dedicated-circuit requirement for my 120V in-wall heater is to never use both hots together for 240V.
Comment: @Marty "Switch on the supply end" is not what the requirement is: read the actual NEC 225.30 rule. The requirement is for different *characteristics*.  I plainly said that a "light switch" style switch at the house will satisfy that requirement.  You keep morphing that into "a switch at the shed" (nope) or "the breaker itself" (nope).  Stop doing that please :)  You need to have a plausible pretense, justifiable to the inspector, that your second circuit has a different characteristic. It could be "control the heater from the house so I don't forget and leave it on", works for me :)
Comment: As far as the MWBC, short version: **In this panel you must use a 2-pole breaker** either 2" or 1" wide.  You can't use two singles. Handle-ties don't work in a GE panel because of their weird approach to double-stuff breakers; a handle-tie won't enforce phasing like it would in any other panel.  The MWBC itself satisfies the "1 circuit" rule, *since an MWBC is one circuit*.
Comment: @Harper, thanks.  How about this then:  I'll install a weatherproof switch close to the panel to control one phase of the 2-pole 20 amp circuit (for the heater), and continue the always-on phase and the switched phase on to the shed.in conduit coming out of the weatherproof box used for the switch.  Would that be kosher?
Comment: @Marty yes, I think you're there.
Comment: @Harper:  Thanks very much.  I'd like (additionally) to put a switch on the heater circuit in the shed.  Not interested in making the two switches 3-way -- just want to get "legal" by having the weatherproof switch near the panel and having the option to turn the heater on/off while in the shed, as well.  Sound OK, or will that sound an alarm of some sorts for an inspector?
Comment: @Marty No, that'll be fine.
Comment: @Harper:  I decided to go with a 2-pole 20A GFCI breaker for the MWBC to my shed.  Must I pigtail all neutrals AND all hot wires to my receptacles?
Comment: @Marty As far as the MWBC is concerned, you only need to pigtail neutrals.  You can use the recep to splice hots.
Comment: @Harper:  Hello again!  I am striking out with my shed's MWBC; my 2-pole 20A GFCI breaker keeps tripping.  I have a switch at the panel controlling Phase B (dedicated to an in-wall heater) and have everything else in the shed (lights and receptacles) on Phase A.  Neutrals are all pigtailed. Hots are "spliced" through the receptacles.  Just 3 receptacles on Phase A thus far -- wanted to test early on. It's a head-scratcher.
 What would you recommend for a "next step" for troubleshooting?  Use a 1-pole 20A breaker to test each phase individually?  My 2-pole breaker is in the Rule-of-Six area.
Comment: @Marty Divide and conquer. Unplug everything plugged in - see if that clears it.  Then around the halfway point (in boxes not distance) disconnect the hots and neutral and see if that clears it.   You'll find the point where disconnecting at point X clears the problem but connecting the next bit causes it to fail. Your trouble lies in between.  Could be a ground wire touching a neutral terminal.
Comment: @Harper:  Thanks again -- problem was easy to isolate.  Had used bare copper pigtails (instead of greens) for grounding my receptacles and one had gotten too close to a receptacle's hot terminal when I'd closed up the switch box.  All is well now.  2-pole 20A GFCI breaker was ~$95 at Home Depot but far preferable to the alternative of installing multiple GFCI receptacles.
Answer: In my very similar GE panel the sticker diagram indicates that the upper section will NOT accept compact 2-pole breakers (1 inch wide) on the right side, but will accept them on the left side.
The simplest way to connect your ac in the upper section would be to use a full sized 30A 2-pole breaker in the upper right. These are very cheap, but you would have to work on the panel hot. I have changed breakers in the lower section of my panel without switching off the 60 A main breaker, but the upper section presents greatly increased risk if you would make a mistake or if the breaker was defective in a certain way (shorted internally) which I must assume never occurs in practice.
The diagram on the sticker in my panel shows that compact 2-pole breakers MUST be inserted in a way not immediately obvious to an inexperienced person, but clearly correct when you think about it. The compact 2-pole breaker must be ASTRIDE (bridging) two full slots. It cannot be placed in one full slot. It will not snap in and it would not work there because both contacts in a full slot are on the same leg.
In my panel if I wanted to increase the number of 2-pole breakers in the upper section from four to five, then the two full sized 2-pole breakers on the left would be removed and three compact breakers put in their place.
Note the compact 2-pole breakers will snap in ONLY astride two (full) slots and can only work if they are astride two full slots. Starting at the top left the top half slot (1/2 inch)is left open, then the three compact 2-pole breakers are placed, then the bottom half slot is left open.
Note that in your panel the compact 30 A 2-pole breaker in the lower section is astride two full (1 inch wide) slots. If you ever move it, it must be inserted that way.


In C++ how to find an int in a string

Question: I want to do this if its possible,

char buff[]="MA A8C : B12A : D14C: ... etc."
int myId=12;
if (myId exist in Buff){print i found it}else{it doesn't not exist}
so simply i want to indicate that this integer does exist in this string, i don't need position or where or how many time it is mentioned or anything complicated,,, all my searches lead to someone trying to find where this int is ... but in my case i just want to find IS IT THERE return 1 not there? return 0. and Thanks
Comment: Convert that int into a string, and from that point - simple textual search.
Comment: @AlgirdasPreidžius What if you want to find number 1 and the text contains the number 12?
Comment: @NeilKirk So, technically, the text contains the following numbers: '1', '2', '12'.
Answer: You can't do that directly. You can convert the number to a string first and search for the string in buff.
You can use a C approach:
char temp[10];
sprintf(temp, "%d", myId);
if ( strstr(buff, temp) != NULL )
{
   // Found it.
}
else
{
   // Did not find it.
}

If you want to use more of a C++ approach, you can use:
auto found = std::string(buff).find(std::to_string(myID));
if ( found != std::string::npos )
{
   // Found it.
}
else
{
   // Did not find it.
}

Comment: What if you want to find number 1 and the text contains the number 12?
Comment: @NeilKirk, that will be a problem. If that's a scenario that is likely to happen, the OP has to change strategies.
Comment: Thanks Allot, it worked like magic. no loops and no pain .... thanks god i didn't need to study python to solve this big problem, Thanks sir

In C++ how to find an int in a string


why this comparison's output is TRUE

Question: this is the code:
<code>class university {
  function hello($name){
    return $this->name;
  }

}

function compare1(&$obj1 , $obj2){
  if ($obj1 === $obj2) {
       return TRUE;
  }else {
    return FALSE;
  }
}

}

$uni1 = new university();
$uni2 = new university();
$uni3 =  $uni1;

 echo  compare1($uni1 , $uni3)  ?"SAME" : "DIFFERENT";
</code>
I want to know why the output is SAME ,although the compare function take the first parameter by refrence and the second by value, so the identity operator must gives us FALSE.
Also if we try to make this:
<code>$uni3 =  clone $uni1;

 echo  compare1($uni1 , $uni3)  ?"SAME" : "DIFFERENT";
</code>
the output is DIFFERENT .
knowing that both example are equal .right?
Answer: <code>$uni3 =  $uni1;
</code>
Here the value have been passed by reference, so of course when compare they are the same object.
<code>$uni3 =  clone $uni1;
</code>
Here you've made a shallow copy, so the references are different then the result will be not the same.

why this comparison's output is TRUE


Switch no longer controls outlet

Question: I replaced a switched outlet together with a switch, but now the outlet has permanent power no matter what position the switch is in. When I was replacing this single pole switch, I think I wasn't too carefull about attaching all the wires to the same connectors. One of the black wires was connected to the ground screw. I thought it was a mistake made by the previous owner, and I attached all the black wires together on the switch. Please take a look at the pictures that I am attaching, and please advise what I should try to change in my set up to make the outlet be controlled by the switch again.
P.S. At first I thought the problem was a defective switch and replaced it once again, but it didn't solve the issue. I did replace all other outlets in the same room without any issues, although none of them was switch controlled.
Comment: fyi, that's incredibly sloppy work with the black twisted around the screw on the switch. Poor connections arc and can cause fires.
Comment: Fundamentally, you need to figure out which of the black wires at the switch is always hot. The always hot feeds the always hot half of the receptacle. That same always hot also goes to the switch and sometimes feeds hot to the red wire. Since the switch box has 3 black wires, you need to figure out what the extra black wire is doing. For all this, you need a multimeter. I don't want to be insulting when I say this, but you might need a professional.
Comment: Can you supply a photo looking more squarely into the back of the switch box please?
Comment: Did you also change the outlet?  Was the outlet split - half switched half always-on?
Comment: Yes, the outlet that I replaced was a split one.
Comment: You were correct - no black wire should be connected to the ground screw. It _may_ have been used as a "proper" ground, but the black insulation on a ground cable violates code.
Answer: Are you testing the receptacle on the top half?
The end the red wire goes to of the receptacle?
It looks like you have it wired correctly the bottom receptacle will be always hot (the end with the 3 blacks) and the top will be controlled by the switch.
That is how you have it wired and that part of it is hot all the time I believe you are checking the wrong side because it is wired correctly.
Now for the critique, although a back and side may be listed for 3 wires the wrap is 2/3 to 3/4 around the screw. A better method would be to add a wire nut and short piece of wire so the 3 wires are connected securely and only 1 wire is under the screw
Comment: Yes, I expect the top half to be controlled by the switch, but it is always hot just like the bottom half.

Switch no longer controls outlet


SQLiteException while updating record with string comparision

Question: My record: (ID, name, count)
(1, 1, 2)
(2, t, 10)
It works: myDbHelper.updateCount("1", 100);
It didn't work: myDbHelper.updateCount("t", 100); It gave android.database.sqlite.SQLiteException:no such column: t: , while compiling: ...
Here is the code for updating records:
<code>public int updateCount(String name, int count) {
    ContentValues args = new ContentValues();
    args.put(KEY_COUNT, count);
    return mDb.update(DATABASE_TABLE, args, KEY_NAME + "=" + name, null);
}
</code>
Answer: In order to use Strings in WHERE clause ensure you enclose the value in Single quotes.
If your column name is "username" and value is "ABCD" & cv has the Content values, then the way to query is as follows -
<code>    String updateDBString = "username=" + "'ABCD'";
    mDB.update(TABLE_NAME, cv, updateBDString, null);
</code>


Are there any email discussion lists popular in cognitive science or psychology?

Question: In the world of the programming language, R, there is the R tag on stack overflow and there is the old-school r-help mailing list. From an infrastructure perspective Stack Overflow is so much better, but r-help has a really smart community.

Are there any popular email discussion lists in psychology or cognitive science?
Answer: There seems to be a whole host of APA student listservs.  I don't know how active any of them are, and they may be laden with spam and junk.


duplicate symbols for architecture libcordova.a

Question: We're using Worklight (using cordova) we're building a hybrid project for android and iOS.
We recently upgraded the SDK to iOS8.3 and we started getting the following errors which prevent us from building.
I wonder if this is common to others and if anyone has a hint on how to solve this.
(We've been through a full delete of the iPhone environment and a recreation of the environment from scratch but the problem persists)
UPDATE: Attaching also the build settings and build phases screens.
Answer: Most likely you have libcordova linked twice, check the build phases tab, and/or the other linker flags setting in build settings, you'll likely find more than one reference to the problematic library.
Comment: I tried but it doesn't work: I can't remove it from the "link binary libraries" cause then it's missing. And removing it from the linker flags doesn't solve the issue...
Comment: Can you add to the question screenshots of your build settings and build phases, highlighting the cordova usage?
Comment: Not sure how to post an image in a comment so I'll post it to the question above...
Comment: Couldn't tell much from the two images, due to the scaling, however here's another suggestion: `build settings` and `build phases` each has a search box, write `cordova` there and see in how many places it appears.
Comment: The search didn't show any duplicates... So, finally we had to turn to "brute force"... seeing as a fresh new "helloWorld" project was working and building fine, we copied the original project's files, selectively, onto the working "helloWorld" and it's OK now... I can only regret that we didn't manage to get down to the bottom of it, but at least this time-sucking nightmare is over... Thanks for you help mate!
Comment: It might have been for other libraries to statically link to `libcordova`, however that harder to hunt :) Or perhaps some parts of the `cordova` source code were part of the project, thus also generating some of the `cordova` functions. Anyhow, glad you get rid of the problem, one way or another.


Furnace turns off power to the thermostat

Question: When my natural gas furnace is running for a while and it gets too hot, the limit switch turns off the burner.  When it does this, the power also gets cut to my thermostat. This causes the thermostat to run on the backup battery.  Is this normal, or is there a problem with the wiring?
The thermostat has been replaced more than once. Recently when the power got cut to it, it registered the house temperature at 1 degree. This caused the furnace to heat continuously until I reset the whole system.  This is dangerous.
I Had a tech in, and he says it is normal for the power to be cut, and he again wants me to replace the thermostat.  Why would it be normal for the furnace to cut power to the thermostat?
The furnace is a International Comfort Pro NTC6100GFA1, and the thermostat is White Rogers (Emerson) 1F85-0477.
Answer: Limits are only designed to open when there's a problem, so the first step here is to find out what the problem is and fix it.
The most common cause for a high limit to continually trip, is a dirty or improperly installed return air filter. Make sure you change the filter regularly, and that you're using one with a similar density to the one recommended by the manufacturer's documentation.
Restricted return and supply ducts can also reduce air flow through the system, which can lead to the furnace overheating. Make sure all return air vents are clean an unobstructed by furniture and other obstructions.  Also make sure that all supply registers are open, and unobstructed.
Check the blower compartment for dust/dirt/debris.  It's not common for the blower to get dirty, but it does happen from time to time. This is especially common, when a furnace is run without a filter, or with an improperly fitted filter.
A dirty blocked up evaporator coil, could also cause restrictions. If the unit has an evaporator coil fitted, you'll want to inspect it to insure it's not dirty.
If there's still trouble, you can check the blower motor and capacitor. Though this is only recommended if you have the proper tools and knowledge to do it. Otherwise you'll want to get an HVAC technician to handle it.
Unless you've recently changed the blower, there's not likely any problem with the way it's installed.

With all that being said.  Some furnaces are actually designed to remove power from the thermostat, in the case that a limit opens.  Obviously this design predates fancy WiFi thermostats, which require constant power to operate.  Back in the olden days, when a thermostat simply acted as a temperature switch, interrupting the signal to the thermostat was an effective solution.
Based on the schematic, it looks like the unit is controlled by the integrated furnace control module (IFC). It looks like the IFC has a separate limit circuit that it monitors, so I'm not sure that it would cut power to the thermostat if there was a problem.  In any case, the thermostat should not be damaged by losing power. I suspect there's more to this, and I haven't been able to find any service bulletins that describe this behavior.
I'd likely start by contacting the manufacturer directly. If that doesn't provide any clues, I'd contact a different local HVAC company to come have a look.  If there's an installers sticker on the unit (or you know who installed it), and the installation company is different than the company you've been dealing with. I'd contact the company that installed the unit, as they should be quite familiar with the equipment.
Unfortunately it's difficult to troubleshoot these types of problems through the internet, especially when I'm not familiar with the equipment.
Answer: Ok first and formost the limit should not be tripping so finding why the fan is not keeping the temperature of the furnace constant while the burner is running is number one priority. So make sure the fan is turning in the proper direction. If it's a belt drive fan, chances are the motor was replaced but is turning in the wrong direction. If this is not it then it could be the fan blades are clogged up and needs cleaning with a pressure washer. The other option is either the air filter is completely clogged or the return grille or grilles have been covered during reno of some sort but it's obvious air is not moving over the heat exchanger. Now to your question, this must be an older furnace with a combination fan/limit control either in the plenum or inside the furnace. When the high limit is reached it shuts off the burner only supposedly but by the sounds of it, it has been wired wrong and is shutting off the control transformer as well. You need a compitent service man to go over the furnace wiring and get it done right. Sorry for the long winded answer. Find out why not enough air is going over the heat exchanger. One more thing, with the furnce constantly doing this you need to make sure no cracks in the heat exchanger has occurred and dumping all kinds of deadly CO2 into your house. Please have this furnace completely checked out!! Pictures of the fan limit would be helpful as well for referance as well as the fan setup.
Comment: I agree.  This is a service contract with a large retailer and they keep telling me the same thing.  I've been asking them about it for years and they keep blaming the thermostat and keep changing it.  My next call will be to the manufacturer of the furnace.  The furnace is kept clean and the filters are changed monthly.  the blower is direct and is turning the right way.  Ducts clean. Had the gas people in and tested for CO2 during the fall when they did some pipe work outside so I have that covered.  My guess is bad wiring or maybe faulty control board?  I'll try to post some pictures asap.
Comment: Now there is a diagram, this answers things that make my first comment useless but that's alright.
Comment: It's unlikely the manufacturer is going to help much, they are most likely just going to tell you to get a competent technician in to go over the furnace and find the issues going on. The trouble today is most people have too much going on and not enough time to really go over the system but definitely try another company in order to get this fixed before something more serious happens.
Answer: I had the same problem when I turned the temperature up more than 4 degrees on the thermostat. The Honeywell programmable thermostat uses no batteries, just the furnace supplied 24 volts. When the Hi limit tripped the thermostat lost all power and the blower would just run until the limit reset. The thermostat would power up again and turn the burners back on.
Later on I found out that the furnace was double the size needed for my small apartment. Simply increasing the heat blower speed has cured the problem but it also created more noise. The existing heat ducts could not transfer the heat fast enough on the slower speed.
Thermostats with batteries may not indicate the problem. The furnace needed better air flow as already indicated in previous replies.
Answer: Not a real wiring issue, is it possible for you to give me the make and model number of this furnace? Also if it's a direct drive motor, it could be the motor speed is on low when it should be high once the temperature is high enough. Do you leave the fan run continuously, if not you should, it saves about 10% on your gas bill and once you get used to the air moving all the time, you will love it but this has nothing whatsoever to do with your thermostat. Here's an experiment to try. Depending on it's age there could be a door switch on the fan compartment door. Take the door off and tape the swich down just for this experiment, then put the door nack on. turn the thermostat up and when the fan starts, lift the door about an inch to unhook it, then pull the bottom out towards you about three inches then while holding the top in this position, let go of the bottom. If the door get sucked back with a good force, it means your returns are not open upstairs or they are way too small for the size of the furnace. If you've been having this issue for years, there's a good chance you have heat exchanger problems but one step at a time, lets find out why this furnace keeps tripping the limit. In the end though I'll give you the answer you need. One other thing, are you using Natural Gas or Propane.
Comment: This is not a forum, it's a question and answer site. If you want to request more information from the OP, please use comments.  Answers are reserved for **answers**.
Comment: Also, the blower cabinet door should get "sucked" shut. The blower is creating a negative pressure zone inside the blower cabinet, which is why air is pushed through the returns in the first place.  The air coming through the returns is restricted by a filter, so it's easier for the air to move through the unrestricted open door.
Comment: I'm unsure what your issue is Tester101 since your answer reads right out of a book  and not from service knowledge but no matter, when there's a dangerous situation someone is living in and the information isn't there to give the proper information, the questions are needed just like the ones everyone else asks. Finding out why there's a lack of airflow and a limit is triping is serious. To the poster, first find a different company to check it out. It seems Tester101 feels I'm stepping on his toes!
Comment: I'm just trying to point out the proper etiquette of the site.  This is not a forum, and so follows a different flow.  If you want to request information from the asker, you do so in comments.  If you want to answer the specific question the asker asked, you post it as an answer.  That's just the way the site works. It's nothing personal against you, I'm just trying to teach you how the site works.
Comment: You gave an obvious answer for the fan door but missed the reason for the question. If a fan is drawing 2000 cfm of air in a system that was designed and installed correctly, yes the door gets sucked in but not with a great force but if it gets snapped back really hard  and you will most likely hear a whisltling sound, then returns are blocked or non existant and a really common reason limits trip. Just not enough air over the heat exchanger, do you see or understand the difference instead of just stating the obvious.
Comment: It's with what force the door gets sucked back, if the return air is not blocked someplace the force to which the return door get sucked back is quite gentle. If it's blocked off then the door will get snapped back with a vengeance.
Comment: There's no need to be nasty, I'm simply trying to point out that you should be posting **comments** not answers, if you're looking to get more info from the OP.  This is **not** a forum.
Comment: Take a look at the [help], specifically the ["be nice"](http://diy.stackexchange.com/help/be-nice) policy. It's possible to disagree with someone without resorting to insults.
Comment: I can *empathize* with you OP, having newly arrived, but please understand these moderators are only trying to inform you of how this site works and that neither of them are ever likely to offer their personal opinion (about how SE works).
Comment: Personally, I'm a fan of incorporating *if this then that, if that then this* into my answer but make-and-model need to be asked in a comment.


Is the ground wire connection grounding all switches in this box?

Question: I am installing a Z-wave switch (I have done others), but this one is different.  There are three switches in this junction box.  However, only one switch is grounded (not one I am installing), and the switch I am adding needs to be grounded.
The switch that is grounded appears to go into a 6 slot wire port with other copper wires.  Does anyone know if this is grounding the entire box?  The other wires are painted, but if scratched they are copper.
Worst case scenario I can jump the ground over to make switch work, but was hoping to understand the wiring a bit more if possible.  Here is picture (top left is the ground coming from switch.
Hopefully this is enough info, but if not please let me know.
Thank You
Comment: I think that is the end all be all question I want answered.  When I install my zwave switch, do I need to ground it?  Or is the setup currently grounding all the switches.
Comment: Can you include another picture or two of the rest of the box? Hard to see what's going on with just the one picture
Comment: Hopefully, this will help you a bit more.  Left switch is the one that is grounded.  Middle switch is one I am replacing with z-wave.  The first yellow clip is what I assume is grounding the box or switches?  The ground from the left goes into the yellow box.  The yellow in the back is the neutral wires.
Comment: Sorry, not first yellow clip.  It is the white clip underneath it.  First yellow is definitely not ground :)
Answer: Looks like the left switch is grounded, the middle switch is not grounded but should be and the right switch may be grounded (can't tell from the pictures). Since the box is plastic, there is no way that they are all grounded. Run a wire to pigtail the middle switch (and possibly right switch) to the ground wire.
Answer: No, it is not, the middle switch clearly shows a green ground screw that is unconnected. This is wrong and would be a code violation.
A solution would be to pigtail the ground connection to all the switch grounds.
Comment: Thank you Jon and Glen for the answers.  That is what I was wondering.  Looks like I will just pigtail the ground wires.  The left switch was only one grounded in the switch, which I had called the electrician and question why it wasn't done.  Question if anyone has opinion?  Should I cut the ground wire and split it with wire nut, or just wrap copper around the ground.   Again, thank you everyone.
Comment: @JasonNielsen Get more ground wire, and use a wire nut which is more secure than just wrapping around the copper.


Cannot set IPv4 address

Question: I am trying to install Ubuntu 14.04 in HP EliteDesk 800 G2 SFF, in which Windows 7 is also installed. While wired network connection works well on Windows, it doesn't on DVD-booted Ubuntu. Then I noticed that only IPv6 address is set:
<code>$ ifconfig
eth0      Link encap:Ethernet  HWaddr 48:0f:cf:41:c7:83
          inet6 addr: fe80::4a0f:cfff:fe41:c783/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:972 errors:0 dropped:0 overruns:0 frame:0
          TX packets:576 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:140475 (140.4 KB)  TX bytes:113164 (113.1 KB)
          Interrupt:16 Memory:e1000000-e1020000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:49 errors:0 dropped:0 overruns:0 frame:0
          TX packets:49 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:4880 (4.8 KB)  TX bytes:4880 (4.8 KB)
</code>
I followed this instruction, but still cannot connect to wired network.
<code>$ sudo cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
 iface eth0 inet dhcp
$ sudo service network-manager start
start: Job is already running: network-maneger
$ sudo /etc/init.d/networking restart
$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 48:0f:cf:41:c7:83
          inet6 addr: fe80::4a0f:cfff:fe41:c783/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1776 errors:0 dropped:0 overruns:0 frame:0
          TX packets:954 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:262483 (262.4 KB)  TX bytes:187146 (187.1 KB)
          Interrupt:16 Memory:e1000000-e1020000
</code>
What should I do to connect to the network so that I can move on to the Ubuntu installation?
Comment: Probably your network doesn't use DHCP and you'll need to enter the settings manually (IP address, subnet mask, gateway and DNS servers). Please boot into Windows 7 and look at the network settings there.
Comment: Are there any clues here? `sudo ifdown eth0 && sudo ifup -v eth0`
Comment: @user300458 Exactly right. I don't know much about network settings, but found that DHCP is not available with my network (actually, it's not mine but my lab's). I was manually able to set up the Ethernet connection via Network Connections app. Could you post your comment as an answer when you have time so that I can accept it?
Comment: @yudai-nkt, done :-)
Answer: (Probably) your network doesn't use DHCP and you need to enter the settings manually (IP address, subnet mask, gateway and DNS servers).
Please boot into Windows 7 and look at the network settings there.

Cannot set IPv4 address


Fool-proof algorithm for uniformly distributing points on a sphere's surface?

Question: I've been trying to generate points on the surface of a sphere of radius "inner_radius", such that they're uniformly spread out. The algorithm works as expected for a radius of 1, but generates lesser than expected points for greater radii.
I have looked through similar questions on here, but they seem to be for generating points throughout the volume and not just on the surface of the sphere.
import numpy as np
PI=np.pi

def spherical_to_cartesian(pol_ang,azim_ang,radius): #This function converts given spherical coordinates (theta, phi and radius) to cartesian coordinates.
    return np.array((radius*np.sin(pol_ang) * np.cos(azim_ang),
                        radius*np.sin(pol_ang) * np.sin(azim_ang),
                        radius*np.cos(pol_ang))
                        )

def get_electron_coordinates_list(inner_radius,electron_count):
    #Algorithm used was mostly  taken from https://www.cmu.edu/biolphys/deserno/pdf/sphere_equi.pdf . Explanations in code added by me.
    electron_coordinate_list=[]
    inner_area=4*(PI*inner_radius**2)
    area_per_electron=inner_area/electron_count
    pseudo_length_per_electron=np.sqrt(area_per_electron) #This is the side length of a square where the area of it is the area per electron on the sphere.
    #Now, we need to get a value of angular space, such that angular space between electrons on latitude and longitude per electron is equal
    #As a first step to obtaining this, we must make another value holding a whole number approximation of the ratio between PI and the pseudo_length. This will give the number of
    #possible latitudes.

    possible_count_of_lats=np.round(PI/pseudo_length_per_electron)

    approx_length_per_electron_lat=PI/possible_count_of_lats #This is the length between electrons on a latitude
    approx_length_per_electron_long=area_per_electron/approx_length_per_electron_lat #This is the length between electrons on a longitude

    for electron_num_lat in range(int(possible_count_of_lats.item())): #The int(somenumpyvalue.item()) is used because Python cannot iterate over a numpy integer and it must be converted to normal int.
        pol_ang=PI*(electron_num_lat+0.5)/possible_count_of_lats #The original algorithm recommended pol_ang=PI*(electron_num_lat+0.5)/possible_count_of_lats. The 0.5 appears to be added in order to get a larger number of coordinates.
        #not sure if removing the 0.5 affects results. It didnt do so drastically, so what gives? Anyway, this gets the polar angle as PI*(latitudenumber)/totalnumberoflatitudes.

        possible_count_of_longs=np.round(2*PI*np.sin(pol_ang)/approx_length_per_electron_long)

        for electron_num_long in range(int(possible_count_of_longs.item())):

            azim_ang=(2*PI)*(electron_num_long)/possible_count_of_longs #This gets the azimuthal angle as 2PI*longitudenumber/totalnumberoflongitudes

            electron_coordinate=spherical_to_cartesian(pol_ang, azim_ang,inner_radius) #Converts the recieved spherical coordinates to cartesian so Manim can easily handle them.
            electron_coordinate_list.append(electron_coordinate) #Add this coordinate to the electron_coordinate_list

            print("Got coordinates: ",electron_coordinate) #Print the coordinate recieved.
    print(len(electron_coordinate_list)," points generated.") #Print the amount of electrons will exist. Comment these two lines out if you don't need the data.

    return electron_coordinate_list
get_electron_coordinates_list(1,100)
get_electron_coordinates_list(2,100)

Spherical_to_Cartesian() does nothing other than convert the spherical points to Cartesian.
For 100 points and radius 1, it generates 99 points.
But, only 26 points are made if the radius is 2 and 100 points are requested.
Answer: If you can generate points uniformly in the sphere's volume, then to get a uniform distribution on the sphere's surface, you can simply normalize the vectors so their radius equals the sphere's radius.
Alternatively, you can use the fact that independent identically-distributed normal distributions are rotationally-invariant. If you sample from 3 normal distributions with mean 1 and standard deviation 0, and then likewise normalize the vector, it will be uniform on the sphere's surface. Here's an example:
import random

def sample_sphere_surface(radius=1):
    x, y, z = (random.normalvariate(0, 1) for i in range(3))
    scalar = radius / (x**2 + y**2 + z**2) ** 0.5
    return (x * scalar, y * scalar, z * scalar)

To be absolutely foolproof, we can handle the astronomically unlikely case of a division-by-zero error when x, y and z all happen to be zero:
def sample_sphere_surface(radius=1):
    while True:
        try:
            x, y, z = (random.normalvariate(0, 1) for i in range(3))
            scalar = radius / (x**2 + y**2 + z**2) ** 0.5
            return (x * scalar, y * scalar, z * scalar)
        except ZeroDivisionError:
            pass

Answer: The element of area is, in polar coordinates, sinΘ dΘ dφ. Hence the azimuth angle can be uniformly distributed, while the inclination must be redistributed. Using the inverse transform sampling trick, Θ=arccos(u) where u is drawn uniformly will do.
Hence in Cartesian coordinates, (√(1-u²) cos v, √(1-u²) sin v, u) where u is drawn from [-1,1) and v from [0,2π).


How to make custom spawners in 1.9?

Question: The command /setblock ~ ~ ~ mob_spawner 0 replace {EntityID:} doesn't work anymore in 1.9. What is the alternative now?
Comment: If you have an empty spawner click it with a mob egg and it will start spawning that mob
Comment: I know but you can't do that with iron golem spawners for example.
Comment: Oh.  I see. There is a mod called _TooManyItems_ you could get all spawners from there. I don't know if it's upgraded to 1.9 though.
Answer: The EntityId tag has been removed. Instead, an id string inside the SpawnData compound specifies the entity ID.
/setblock ~ ~1 ~ minecraft:mob_spawner 0 replace {SpawnData:{id:"Creeper"}}

For the SpawnPotentials list, the Properties compound has been renamed to Entity, and the Type string tag has been removed in favor of an id tag within Entity.
/setblock ~ ~1 ~ minecraft:mob_spawner 0 replace {SpawnPotentials:[{Weight:1,Entity:{id:"Creeper"}}]}

How to make custom spawners in 1.9?


How to make a QML Canvas visible?

Question: I'm trying to draw something on the screen in an Ubuntu phone application.
I created a new "QML App with Simple UI (qmlproject)" in Ubuntu SDK, and replaced the content of Main.qml with the following:
import QtQuick 2.0
import Ubuntu.Components 1.1

MainView {
    objectName: "mainView"

    applicationName: "canvasexample.cos64"

    useDeprecatedToolbar: false

    width: units.gu(50)
    height: units.gu(50)

    Page {
        title: i18n.tr("Canvas Example")

        Canvas {
            anchors {
                margins: units.gu(2)
                fill: parent
            }
            id: canvas
            width: 100
            height: 200
            onPaint: {
                console.log("on paint");
                var ctx = canvas.getContext('2d');
                ctx.save();
                ctx.clearRect(0, 0, canvas.width, canvas.height);
                ctx.beginPath();
                ctx.lineTo(75,70);
                ctx.closePath();
                ctx.stroke();
                ctx.restore();
            }

            onPainted: {
                console.log("painted");
            }

            MouseArea {
                id: buttonMouseArea
                anchors.fill: parent
                onClicked: {
                    console.log("clicked");
                    canvas.requestPaint();
                }
            }

            Component.onCompleted: {
                console.log("completed")
            }

            onScaleChanged: {
                console.log("scale changed")
            }

            onRotationChanged: {
                console.log("rotated");
            }
        }
    }
}

I get no errors, but the canvas is not visible, although I can click on it, as the console output shows:
Starting /usr/lib/x86_64-linux-gnu/qt5/bin/qmlscene...
qml: completed
qml: on paint
qml: painted
qml: clicked
qml: on paint
qml: painted
/usr/lib/x86_64-linux-gnu/qt5/bin/qmlscene exited with code 0

Here's what the running app looks like:

What am I doing wrong?
Answer: ctx.save();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.beginPath();
ctx.moveTo(75,90);
ctx.lineTo(75,70);
ctx.closePath();
ctx.stroke();
ctx.restore();

edit
If someone is looking for an academic explanation, the problem is that you need two points to draw a line and apparently the library doesn't supply you with a starting point. You should set it with the moveTo method. Setting starting point with lineTo happens to work, but it is not clearly documented as such (so it may and will break).
Comment: You are right, Velkan, this way it works. Looks like I wasn't using the drawing API correctly.

How to make a QML Canvas visible?


How to get this data in a list?

Question: I am new to Python and got the following data to work with:
https://dl.dropboxusercontent.com/u/86876232/6358.csv
The linked file is only a fraction of the entire data (the data should contain a bit over 15000 lists). First of all in what format is this data? And how do I get it from that format into lists so I can slice the volume data out.
When I use a module to read the csv data, I get not every list as separate list, but one big list, with every list as a value.
And this is how the data looks like: 4;"false";"null";"null";"Osebni avto";"20";"PoboÄje";"5.0";"3-9m3  (velikost osebnega avtomobila)";"3.0";"null";"30";"10";"10";"null";"null";"null";"50";"false";"
And if it is better to have it in a dictionary how am I going to do this? There is no key in the data which I can assign to the value. The information consist purely of different values.
Answer: https://docs.python.org/3/library/csv.html#module-csv
I'm not quite sure why this is downvoted so much?
Your best bet is to avoid manually reading in csv files and just use one of the default modules python has for reading them in. There's quite a lot of code snippets for using csv around the net so you should have any issues. Also I think you'll be better off with dictionaries than lists.
Comment: @Robin The reasons why you're having problems were obvious to me the second I opened that csv file. Usually csv files.
They usually look like this:

#name, age (this line is optional)
"Name","Age"
"David","48"
"Don","46"
"Sue","39"

Yours looks like

data;data;data;
 Some weird p tag
data;data;data
Something just randomly written in

The csv file is a mess and therefore csv.DictReader has problems reading through it.
Comment: So what should I do then?
Comment: @Robin: I don't know, this is just a collection of random data basically. Someone just automatically clicked "make csv" or "export as csv" and now you have all your data in the 1st field and then just  a bunch of commas stringed to end of it so it "looks" like a csv file with n fields. Take a look at your file in a notepad, and make sure you have line wrap turned off.

You will notice that you have lines like foobar,,,, and lines with some actual data "4"";""null"";",,,, The separators of this file are the commas, because the ; are commented out. Contact whoever sent you that csv file.
Comment: Thanks for your answer, I will then now contact the person, and see if this time a proper csv file can be send.

How to get this data in a list?


jquery page loading delay

Question: I want to load a div from external source after page has loaded with some delay.
Here is the jquery script I have. What is happening is content is loading first and then loader.gif later. How can I show content from an external source after some xx time..? I have an idea about .load() function but not sure how to implement.
$(window).load(function() {
$('

')
.css('opacity', '0.5')
.insertAfter('body');

window.setTimeout(function() {
$(document).ready(function() {
$('#overlay').remove();
});}, 1000);
$('.body').show();
});

navigation

Body

footer

#overlay {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: gray;
}

.body{display:none;}

#overlay img {
 display: block;
 width: 32px;
 height: 32px;
 position: absolute;
 top: 50%;
 left: 50%;
 margin: -26px 0 0 -26px;
 padding: 10px;
 background: #fff;
 -moz-border-radius: 6px;
 border-radius: 6px;
}

Answer: You said that the gif is being loaded after you ajax pull. If that is your problem, you can call your ajax pull after the gif is loaded, by doing:
yourimg = new Image();
yourimg.src = "loading.gif";

yourimg.loadEvent = function(url, image){
    var overlay = $('
');
    overlay.append(image).css('opacity', '0.5').insertAfter('body');
    //call whatever you want here. your image is loaded.
}

yourimg.load();

Answer: From the jquery website
The load event is sent to an element when it and all sub-elements have been
completely loaded. This event can be sent to any element associated with a URL:
images scripts, frames, iframes, and the window object.

You need to show your div while the body is loading and hide it onload. I'm not sure if that is what you're asking though. If it's not the setTimeout function might be what you want.
Comment: Yes, actually that is not what i am looking here. The content which is loading in the body div will be heavy. So, i want to load the main page first and then body div content using .load() function.
Answer: There's a small problem in your code:
window.setTimeout(function() {
$(document).ready(function() {
...

In this code you set the timeout, to the function that does this:
function() {
    $(document).ready(function() {
        $('#overlay').remove();
    });
}

Basically it waits a second, and then adds a listener to document's ready event and in that listener it performs the actual work. So in case if ready event was fired during the first second - the function will not execute at all.
Your code should look like this:
$(window).load(function() {
    setTimeout(function() {
        // Do the dom manipulations remove the placeholder
    }, 1000);
});

The placeholder will be removed in a second after the load event. Note that "load" and "ready" events are different. And "load" doesn't guarantee that DOM will be parsed or rendered.
Comment: @Juiry UPDATE sorry, if i have confused, Actually this what i am looking here. The content which is loading in the body div will be very heavy. So, i want to load the main page first and then body div content using .load() function.

jquery page loading delay


The continued fraction $[2;4,6,8,\ldots,p_{n}-3,\overline{p_n-1}];$ where $p_{n}$ is the $n-$th prime number.

Question:
Question: If $n>2$ let $p_n$ be the $n-$th prime number. I write $\xi_{n}$ for the simple periodic continued fraction:
  $$
\xi_n:=[2;4,6,8,\ldots,p_{n}-3,\overline{p_n-1}].
$$
  How can I find the numbers $P,D$ and $Q$ such that $\xi_{n}$ can be rewritten as
  $$
\frac{P+\sqrt{D}}{Q}
$$ ?

Per Wikipedia $\xi_n$ is a quadratic irrational number and so is an algebraic number of degrees 2. In particular $\xi_n$ is the root of the real quadratic equation
$
\alpha_{0}x^2+\alpha_{1}x+\alpha_{2}
$
from which it follows that $\xi_n$ can be rewritten as
$
\frac{P+\sqrt{D}}{Q}.
$
Below are some examples:

If $n$ is equal to 2 then $p_2=3$ and so $\xi_2:=[2;\overline{2}];$ which can be rewritten as $1+\sqrt{2}.$
If $n$ is equal to 3 then $p_3=5$ and so $\xi_3:=[2;\overline{4}];$ which can be rewritten as $\sqrt{5}.$
If $n$ is equal to 4 then $p_4=7$ and so $\xi_4:=[2;4,\overline{6}];$ which can be rewritten as $\frac{17+\sqrt{10}}{9}.$
If $n$ is equal to 5 then $p_5=11$ and so $\xi_5:=[2;4,6,8,\overline{10}];$ which can be rewritten as ?
If $n$ is equal to 6 then $p_6=13$ and so $\xi_6:=[2;4,6,8,10,\overline{12}];$ which can be rewritten as ?
If $n$ is equal to 7 then $p_7=17$ and so $\xi_7:=[2;4,6,8,10,12,14,\overline{16}];$ which can be rewritten as ?

One trick I was shown is to substitute
$$
x=\cfrac{1}{(p_{n}-1)+\cfrac{1}{(p_{n}-1)+\cfrac{1}{(p_{n}-1)+...}}}=[\overline{p_{n}-1}];
$$
so that
$$
\frac{1}{x}=p_{n}-1+x
$$
I could then multpily the LHS and RHS by $x$ to get the quadratic equation
$$
x^2+xp_{n}-x-1=0
$$
Another substitution yields:
$$
\xi_{n}=2+\cfrac{1}{4+\cfrac{1}{6+\cfrac{1}{\ddots\frac{1}{p_{n}-3+x}}}}
$$
This approach seemed reasonable when $n$ was small say less than 4. But it proved difficult as $n$ became larger.
Comment: In Wolfram `FromContinuedFraction[{2,4,6,8,{10}}]`$=\frac{\sqrt{26}+22417}{10009}$,  `FromContinuedFraction[{2,4,6,8,10,{12}}]`$=\frac{1864992-\sqrt{37}}{832511}$, `FromContinuedFraction[{2,4,6,8,10,12,14,{16}}]`$=\frac{39155090880-\sqrt{65}}{17478439679}$.
Comment: Incidentally, why are you particularly interested in the prime-sized 'stacks' in this structure?
Answer: The almost purely periodic $[n;\overline{2 n}]$ is the continued fraction for $\sqrt{n^2 + 1},$ so the purely periodic $[2n;\overline{2 n}]$ is the continued fraction for $n+\sqrt{n^2 + 1} \; .$
The effect of preceding that with some "digits" is to apply a certain Moebius transformation to the indicated number.
Comment: What's more, a recursion relation for that Moebius transformation can be derived by using the 2x2 matrix representation of these transformations.
Comment: @StevenStadnicki  right. That is how they came up with the cycle method (Gauss, Lagrange, Legendre) for quadratic irrationals. Here we go, found it in  H. E. Rose, A Course in Number Theory, Theorem 1.1(i) in first edition
Comment: I am not sure I follow. Am I to make a relation between $[2n;\overline{2n}]$ and say $[p_{n}-1;\overline{p_{n}-1]}$  and conclude this is the continued fraction for $p_{n}-1+\sqrt{p_{n}^2-2p_{n}+2}$ ?
Answer: First of all, your usage of primes is a bit of a red herring; since your continued fraction $\xi_n$ only uses $p_n$ but not any previous primes, you might as well look at $\zeta_n=[2;4,6,8,\ldots,\overline{2n}]$; your $\xi_n$ is then just $\xi_n=\zeta_{(p_n-1)/2}$.
Next, as you've already noted and as Will Jagy notes in his answer, the purely periodic CF at the bottom of your fraction is easy to evaluate: if $x=[\overline{2n}]$ then $x=2n+1/x$, so $x^2=2nx+1$ and $x^2-2nx-1=0$, and the quadratic equation quickly gives $x=n+\sqrt{n^2+1}$.
The last piece of the puzzle is the representation of the Moebius transformations that Will Jagy mentions.  First, let's consider the affine space $\mathbb{A}$ over $\mathbb{R}$ where elements are equivalence classes of vectors $\left[\begin{smallmatrix}s\\t\end{smallmatrix}\right]$ (with $s$ and $t$ not both zero) and two vectors $\left[\begin{smallmatrix}s\\t\end{smallmatrix}\right]$ and $\left[\begin{smallmatrix}u\\v\end{smallmatrix}\right]$ are equivalent if $sv=tu$ (or, equivalently, there's some $\lambda$ with $s=\lambda u$ and $t=\lambda v$).  This space looks a lot like $\mathbb{R}$: every element except for those of the form $\left[\begin{smallmatrix}c\\0\end{smallmatrix}\right]$ is equivalent to a unique element of the form $\left[\begin{smallmatrix}\alpha\\1\end{smallmatrix}\right]$ (where $\alpha=s/t$), and we can define arithmetic operations on equivalence classes of elements in ways that are compatible with this.  (I'm being a bit sloppy here, but details shouldn't be too hard to find if you're interested.)
Now, we can define an action of 2x2 matrices on the affine space in the most natural way possible, matrix multiplication: if $M=\left(\begin{smallmatrix}a&b\\c&d\end{smallmatrix}\right)$ is a nonsingular 2x2 matrix and $\sigma=\left[\begin{smallmatrix}s\\t\end{smallmatrix}\right]$, then $\tau=M\sigma=\left[\begin{smallmatrix}as+bt\\cs+dt\end{smallmatrix}\right]$ is also a member of the affine space. (Convince yourself that if $\sigma\equiv\zeta$ in the affine space then $M\sigma\equiv M\zeta$, so this is really an operation on the equivalence classes.)  Because this is just a matrix multiplication, it has all the correct behaviors with respect to associativity etc.; $M(N\sigma)=(MN)\sigma$, so it forms a proper group action.  This is (essentially) the projective linear group or Moebius group over the (affine) real line.  (Note that really the elements of the group are equivalence classes of matrices, since if $M=\alpha N$ for some $\alpha\in\mathbb{R}$ then $M\sigma=N\sigma$ for all $\sigma\in\mathbb{A}$; I'm glossing over this a bit here.)
What does this have to do with continued fractions? Well, if $x$ is some real number, then $[a;x]$ is $a+1/x = (xa+1)/x$, and this can be represented as the matrix $M_a=\left(\begin{smallmatrix}a&1\\1&0\end{smallmatrix}\right)$ acting on the element $\xi=\left[\begin{smallmatrix}x\\1\end{smallmatrix}\right]$ of $\mathbb{A}$.  Extending this out, the continued fraction $[a_0;a_1,a_2,\ldots,a_n,x]$ can be represented as $M_{a_0}M_{a_1}\ldots M_{a_n}\left[\begin{smallmatrix}x\\1\end{smallmatrix}\right]$.  This should give you a recurrence formula that you can use to determine the coefficients of your quadratic number; whether you can get anything 'cleaner' than that recurrence relation, though, seems dubious.
Comment: I think I can follow the last paragraph. I believe you are saying I should consider $\left(\begin{smallmatrix}2&1\\1&0\end{smallmatrix}\right)\left(\begin{smallmatrix}4&1\\1&0\end{smallmatrix}\right)\left(\begin{smallmatrix}6&1\\1&0\end{smallmatrix}\right)\cdots\left(\begin{smallmatrix}p_{n}-3&1\\1&0\end{smallmatrix}\right)\left[\begin{smallmatrix}x\\1\end{smallmatrix}\right]$ to get the recurrence relationship?
Comment: @AntonioHernandezMaquivar exactly that (though as I say in the first, I think the use of $p_n$ is basically unnecessary here); but keep in mind that $x$ itself will be different a bit.  So you won't directly have a recurrence relation for the coefficients in $A+B\sqrt{s}$, but you should have equations for those coefficients in terms of sequences that you _do_ have a recurrence relation for.


Remove N first rows of a column from a DataFrame

Question: if I have a DataFrame of length 3, with 3 columns
a b c
1 2 3
4 5 6
7 8 9

Is there a smart way to replace the first 2 rows of column b with NaN?
Answer: pd.Series.mask.
df['b'] = df.b.mask(df.index < 2)
df

   a    b  c
0  1  NaN  3
1  4  NaN  6
2  7  8.0  9

If your df.index is not a monotonically increasing integer index, then you can replace df.index with np.arange(len(df)) -
df.b.mask(np.arange(len(df)) < 2)

0    NaN
1    NaN
2    8.0
Name: b, dtype: float64

np.where
df['b'] = np.where(df.index < 2, np.nan, df.b)
df

   a    b  c
0  1  NaN  3
1  4  NaN  6
2  7  8.0  9

np.ndarray.__getitem__
Similar to Wen's iloc, indexing on numpy arrays -
i = df.b.values
i[:2] = np.nan

df['b'] = i
df

   a    b  c
0  1  NaN  3
1  4  NaN  6
2  7  8.0  9

Comment: @vandelay No problem. I kinda figured that could happen. The first two solutions are still valid if you substitute with `arange`. Anyway, the 3rd option should be extremely fast for large data too. Cheers.
Comment: @COLDSPEED Thanks for the help, I went with option 3, since it was probably best to mention I were using Datetime as index
Answer: df.b.iloc[:2]=np.nan
df
Out[481]:
   a    b  c
0  1  NaN  3
1  4  NaN  6
2  7  8.0  9

Comment: The :-1 should be n=2; n+1 looking at the question, right? Anyway +1


Up-/downsampling with One vs. rest classifier

Question: I have a data set (tf-idf weighted words) with multiple classes that I try to predict. My classes are imbalanced. I would like to use the One vs. rest classification approach with some classifiers (eg. Multinomial Naive Bayes) using the OneVsRestClassifier from sklearn.
Additionally, I would like to use the imbalanced-learn package (most likely one of the combinations of up- and downsampling) to enhance my data. The normal approach of using imbalanced-learn is:
from imblearn.combine import SMOTEENN
smote_enn = SMOTEENN(random_state=0)
X_resampled, y_resampled = smote_enn.fit_resample(X, y)

I now have a data set with roughly the same number of cases for every label. I then would use the classifier on the resampled data.
from sklearn.multiclass import OneVsRestClassifier
from sklearn.naive_bayes import MultinomialNB
ovr = OneVsRestClassifier(MultinomialNB())
ovr.fit(X_resampled, y_resampled)

But: now there is a huge imbalance for every label when it's fitted, because I have in total more than 50 labels. Right? I imagine that I need to apply the up-/downsampling method for every label instead of doing it once at the beginning. How can I use the resampling for every label?
Comment: Not able to understand. Why is there label imbalance:-  `"now there is a huge imbalance for every label when it's fitted"` after you have resampled the data?
Comment: Because as far as I understand, for n labels the one vs. rest classifiers fits n models. Every model predicts one label and takes all the other labels as negative examples. Therefore, if I have 50 labels, each say with 1000 examples, for every model that is fitted there would be 1000 positive examples and 49000 negative examples. That's the huge imbalance.
Comment: So do you want the up/down-sampling to happen after the data in divided into n-models?
Comment: I want the resamplung happen for every model that is fitted, so that the number of positive and negative examples is roughly equal for all of the n models
Answer: As per the discussion in comments, what you want can be done like this:
from sklearn.naive_bayes import MultinomialNB
from imblearn.combine import SMOTEENN

# Observe how I imported Pipeline from IMBLEARN and not SKLEARN
from imblearn.pipeline import Pipeline
from sklearn.multiclass import OneVsRestClassifier

# This pipeline will resample the data and
# pass the output to MultinomialNB
pipe = Pipeline([('sampl', SMOTEENN()),
                 ('clf', MultinomialNB())])

# OVR will transform the `y` as you know and
# then pass single label data to different copies of pipe
# multiple times (as many labels in data)
ovr = OneVsRestClassifier(pipe)
ovr.fit(X, y)

Explanation of code:

Step 1: OneVsRestClassifier will create multiple columns of y. One for each label, where that label is positive and all other are negative.
Step 2: For each label, OneVsRestClassifier will clone the supplied pipe estimator and pass the individual data to it.
Step 3:
a. Each copy of pipe will get a different version of y, which is passed to SMOTEENN inside it and so will do a different sampling to balance the classes there.
b. The second part of pipe (clf) will get that balanced dataset for each label as you wanted.
Step 4: During prediction time, the sampling part will be turned off, so the data will reach the clf as it is. The sklearn pipeline doesnt handle that part so thats why I used imblearn.pipeline.

Hope this helps.


Is it possible to install pandoc on windows using an R command?

Question: I would like to download and install pandoc on a windows 7 machine, by running a command in R.  Is that possible?
(I know I can do this manually, but when I'd show this to students - the more steps I can organize within an R code chunk - the better)
Answer: What about simply downloading the most recent version of the installer and starting that from R:

a) Identify the most recent version of Pandoc and grab the URL with the help of the XML package:
library(XML)
page     <- readLines('http://code.google.com/p/pandoc/downloads/list', warn = FALSE)
pagetree <- htmlTreeParse(page, error=function(...){}, useInternalNodes = TRUE, encoding='UTF-8')
url      <- xpathSApply(pagetree, '//tr[2]//td[1]//a ', xmlAttrs)[1]
url      <- paste('http', url, sep = ':')

b) Or apply some regexp magic thanks to @G.Grothendieck instead (no need for the XML package this way):
page <- readLines('http://code.google.com/p/pandoc/downloads/list', warn = FALSE)
pat  <- "//pandoc.googlecode.com/files/pandoc-[0-9.]+-setup.exe"
line <- grep(pat, page, value = TRUE); m <- regexpr(pat, line)
url  <- paste('http', regmatches(line, m), sep = ':')

c) Or simply check the most recent version manually if you'd feel like that:
url <- 'http://pandoc.googlecode.com/files/pandoc-1.10.1-setup.exe'

Download the file as binary:
t <- tempfile(fileext = '.exe')
download.file(url, t, mode = 'wb')

And simply run it from R:
system(t)

Remove the needless file after installation:
unlink(t)

PS: sorry, only tested on Windows XP
Comment: To get rid of XML but still extract the exact file name try this: `pat <- "//pandoc.googlecode.com/files/pandoc-[0-9.]+-setup.exe";
target.line <- grep(pat, page, value = TRUE);
m <- regexpr(pat, target.line);
regmatches(target.line, m)`  (The `http` still needs to be prepended.)
Comment: Hi Daroczig and Grothendieck.  Based on this thread, I've decided to create an R package with install.x type functions.  I've published it here: https://github.com/talgalili/installr/  And would appreciate any comments (including if you'd like credit somewhere, which you think you deserve.  I gave some in some of the functions already.  But I might have missed something).  Again, thank you very much.  Tal
Comment: @TalGalili: sure, I've added a hopefully working way to recognize the latest version.
Comment: @G.Grothendieck: that's right, thanks (and sorry), I've just fixed that.
Comment: Great!
Any way to recognize the latest version automatically?
Comment: Ah, and sorry for frequent edits, I won't touch this post any more. I promise :)
Comment: Great solution guys!
Thanks daroczig - it's fun to learn new stuff like this.  Also, thank you Grothendieck for the extra solution
Comment: Thank you @G.Grothendieck, I have update the answer based on your really cool regexp wizardry.
Comment: I think the `target.line<-` got dropped


How do I cancel a shot?

Question: I order a shot on the enemy weapons, but then their shield goes back up and suddenly I'd rather wait until the rocket can get through to take it out. Or maybe their cloaking device suddenly comes on. Anyway, I want to cancel the shot right away. How do I do this?
I tried right clicking on the target, but the only solution I can see is to turn the weapon off and on again (wasting the charge).
Answer: First Pause the game using spacebar. Then click the weapon icon you intend to cancel the shot from as if to target it to another system, then right click somewhere in empty space to cancel the shot entirely.
Comment: Got it - just right click on the background. Thanks.
Comment: Right click on the weapon icon, you mean?
Answer: For the record, you can turn the weapon off/on without losing the charged weapon state if the game is in paused mode, so this is another way to cancel shots.

How do I cancel a shot?


Appending text to a JTextArea on button press?

Question: I've got a simple Swing GUI and I want to add a new line of text to a JTextArea after a button is pressed, simple right?
The Button and it's ActionListener function correctly (printing stuff to the console works fine), but when I use .append()or .setText() to add text to the textarea, I get a nullpointer exception.
As always, code it below. Any input would be greatly appreciated, thanks!!!
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.LineBorder;

public class GUI extends JFrame implements ActionListener {

private JFrame frame;
private JLabel paneHeader;
public JTextArea ipArea, portArea, outputLog, orderLog, cookLog;
private JButton newServer;

public String ipAddress, portNumber, cashierName, cookName;

public GUI() {
    initGUI();
}

public void initGUI() {

    frame  = new JFrame("Restaurant Overview");
    Container contentPane = frame.getContentPane();

    JLabel paneHeader = new JLabel("Restaurant Monitoring System");
    paneHeader.setBounds(200, 0, 200, 25);
    paneHeader.setFont(new Font("Calibri", Font.BOLD, 14));

    JLabel ipLabel = new JLabel("IP Address: ");
    ipLabel.setBounds(25, 30, 75, 20);
    ipLabel.setFont(new Font("Calibri", Font.PLAIN, 12));

    final JTextArea ipArea = new JTextArea();
    ipArea.setBorder(new LineBorder(Color.GRAY));
    ipArea.setBounds(105, 30, 100, 20);

    JLabel portLabel = new JLabel("Port Number: ");
    portLabel.setBounds(25, 55, 75, 20);
    portLabel.setFont(new Font("Calibri", Font.PLAIN, 12));

    final JTextArea portArea = new JTextArea();
    portArea.setBorder(new LineBorder(Color.GRAY));
    portArea.setBounds(105, 55, 100, 20);

    JButton newServer = new JButton("Create new Server");
    newServer.setBorder(new LineBorder(Color.GRAY));
    newServer.setBounds(250, 30, 150, 40);
    newServer.setActionCommand("createserver");
    newServer.addActionListener(this);

    JTextArea outputLog = new JTextArea(" ");
    outputLog.setBorder(new LineBorder(Color.GRAY));
    outputLog.setBounds(25, 90, 150, 150);
    //outputLog.setEditable(false);

    JTextArea cashierLog = new JTextArea();
    cashierLog.setBorder(new LineBorder(Color.GRAY));
    cashierLog.setBounds(185, 90, 150, 150);
    //cashierLog.setEditable(false);

    JTextArea cookLog = new JTextArea();
    cookLog.setBorder(new LineBorder(Color.GRAY));
    cookLog.setBounds(345, 90, 150, 150);
    //cookLog.setEditable(false);

    contentPane.add(paneHeader);
    contentPane.add(ipLabel);
    contentPane.add(ipArea);
    contentPane.add(portLabel);
    contentPane.add(portArea);
    contentPane.add(outputLog);
    contentPane.add(cashierLog);
    contentPane.add(cookLog);

    contentPane.add(newServer);

    frame.setLayout(null);
    frame.pack();
    frame.setSize(600,400);
    frame.setVisible(true);
}

public void test() {
    //ipAddress = ipArea.getText() + "\n";
    //portNumber = portArea.getText() + "\n";
    String text = "lemons";
    //System.out.println(text);
    outputLog.append(text);
    //outputLog.append(portNumber);
}

public void actionPerformed(ActionEvent e) {
    if ("createserver".equals(e.getActionCommand())) {
        //test();
        outputLog.append("lemons");
    } else {
        //Do Nothing
    }
}
}

Comment: You should also post your stack trace
Answer: You are likely shadowing a variable -- declaring it more than once, but initializing a local variable not the class field, and so the class field remains null.
Edit:
Yep, sure enough you do. In your constructor you have
JTextArea outputLog = new JTextArea(" ");

This re-declares the outputLog variable, and so you are initializing only the variable local to the constructor. The solution is not to redeclare the variable but instead initialize the class field.   So change the above to
outputLog = new JTextArea(" ");

You will need to do this for every variable that needs to be accessed in the class scope. For those that are OK to declare locally, do so, but in the sake of safety, get rid of their corresponding class declaration so as not to risk causing the same error in the future.
Comment: How could I have been so blind! Thanks HFoE!
Answer: Your error is that the instance variable outputLog is not initialized.
Answer: your code not done on EDT, you have to wrap tht into invokeLater()
EventQueue.invokeLater(new Runnable() {

    @Override
    public void run() {
       outputLog.setText(outputLog.getText()
          + System.getProperty("line.separator") + text);
    }
});

Comment: The OP doesn't need to use EDT with `JTextArea.append()` which **is thread-safe**. And anyway, `actionPerformed()` is always called from the EDT!


Android Room Not Recognizing Column Name From Schema (using an alias for column name)

Question: I am relatively new to Android Development and using its Room persistence library. The problem I am currently facing is the following error:
error: There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (no such column: s_abb)
However my table schema (that this column is being referenced by) does contain this column by this name. Here is how I defined my entity in Android
@Entity
public class stops {

@PrimaryKey
@NonNull
@ColumnInfo(name = "s_name")
private String s_name;
@Ignore
@ColumnInfo(name = "s_abb")
private String s_abb;
@Ignore
@ColumnInfo(name = "Comments")
private String Comments;

public String getS_abb() {
    return s_abb;
}

public void setS_abb(String s_abb) {
    this.s_abb = s_abb;
}

public String getS_name() {
    return s_name;
}

public void setS_name(String s_name) {
    this.s_name = s_name;
}

public String getComments() {
    return Comments;
}

public void setComments(String comments) {
    Comments = comments;
}

}

I have tested the query in SQLite Studio and it does return expected data. Here is a screen shot of query written within DAO Interface: Query. I personally think the main problem is that Room may not recognize the aliases I am using with my subqueries and the column names. Am I correct in thinking this? I hope my screenshot helps. I did make sure to add proper spacing between SQL statements, as many solutions here have pointed out. If any of you need me to provide more information, I am happy to oblige! Thank you
Comment: Your column is marked with the Ignore annotation and... Ignored by Room! Please see https://developer.android.com/reference/android/arch/persistence/room/Ignore
Comment: You should only use @Ignore for the fields you're not going to save in the persistence store. I.e. helper fields like received date and other stuff you might need, while the object is being used in memory.
Comment: Oh wow, that flew right passed me. Thanks! I just read the documentation you sent me (thanks btw). Just to confirm, @Ignore should just be used for columns that will not be used throughout the application? Now I am getting an error that the columns returned by my query does not have fields s_name. But when I run it on SQLite it does return s_name values. Could this be an aliasing issue?
Comment: Remove all your Ignore annotations and try to clean/rebuild (or even invalidate android studio cache, then clean rebuild). Also you'd rather not using underscores in your column name aliases, try to use names like stopName, stopAdd and getters/setters like getStopAdd etc.
Comment: Thank you sir, I took out the ignore statements and I also realized that my query was returning two column values that are strings, however my method was expecting an Entity type. I'll make sure to place both as an answer as soon as I get out of class! Thanks again!
Answer: As Vladimir Gladun pointed out, the column s_abb that I was querying for was set with an @Ignore annotation over it. Which as Android's documentation on @Ignore annotations states that "Ignores the marked element from Room's processing logic":
https://developer.android.com/reference/android/arch/persistence/room/Ignore.
Which basically means Room disregards it completely.
However this was not the only problem, My method was expecting Entity type values
whereas the SELECT statement from my outermost query was returning String type values. Fixing those two errors solved my problem.


ephemeral disk noted listed on created ami Amazon EC2

Question: Why ephemeral disk isn't listed on (fdisk -l) when i create a instance on amazon ec2 from my previously created (AMI)?
Comment: What instance size are you using?
Comment: I am having the same problem. I have launched 3 m1.medium instances from the EC2 web console, each with added ephemeral disks, but 1 instance does not have the ephemeral disk. I have terminated it and retried twice with no success
Answer: You have two options to enable ephemeral storage on an instance.

Enable it at launch. Can be done in the console or command line tools.
Enable it with you register a snapshot as an AMI. By default it will not map ephemeral storage, this is something you have to explicitly enable.
Comment: when i launch a custom (AMI) the ephemeral disk is enabled in "Instance Store Volumes" Tab from "Request Instances Wizard", but when the instance start and i put (fdisk -l) in the console the ephemeral disk isn't listed.
Answer: In my case, I confused the ephemeral disk instance ID with the disk quantity, and added ephemeral disk instance 1, rather than ephemeral disk instance 0. m1.medium instances only support 1 ephemeral disk, and it MUST be ephemeral disk instance 0.


Is the set compact?

Question: I have $Y=(\mathbb{R},\tau)$. The open sets in this topology are $(-\infty, h), h \in \mathbb{R}$.
Then I have $S=(0,2) \cup [3,5]$. Is it compact?
Sol.:?
If I consider the subspace topology, I got that the open sets are the intersections of semirette with $S$.
If I take a open cover { $U_i$ }, I can always find a finite sub-cover by taking $U_1=(0,2) \cup [3,5)$, which is $S \cap (-\infty,5)$... but how can I take also $5$, to get $S$ compact?
Thanks
Comment: I think your title is wrong, you mean "Is it compact?"
Comment: yes, thank you:)
Comment: If I'm not mistaken it's worth noting that the Heine Borel Theorem does not apply to this topology.  Your set is not closed.
Answer: If you take an open cover $U_{\alpha}$ then there must be some index $\alpha$ for which $5\in  U_{\alpha}$.  But then the entire set $(0,2)\cup[3,5]\subset U_{\alpha}$ so there is always a finite subcover (in fact you can always do it with one single element of the cover so definitely finite).
Comment: thanks for the answer.
Let me see if I got it.
If I take a open cover, I have to cover (of course) also $5$. But then I have  already got a finite subcover because it is $S \cup (-\infty,5+\epsilon)$. Is it right?
Comment: Exactly, you got it!
Comment: Almost.  As the only open sets are of the form $(-\infty, h)$ then $5 \in (-\infty, h) \implies h > 5$ so $(0,2) \cup [3,5] \subset (\infty, 5] \subset (-\infty, h)$.  So $(-\infty, h)$ is a finite subcover.
Comment: A non-empty subset of $\mathbb R$ is compact in this topology iff it has a largest member.
Comment: @DanielWainfleet Yes that is also true.

Is the set compact?


Why is ggplotly's argument tooltip not ordering?

Question: The tooltip argument is a vector specifying which aesthetic mappings to display in the tooltip, and it was supposed to display and order the variables in the same way you wrote them on your code, but it doesn't, for me at least.
I've seen the same problem on the github's plotly issues page:
https://github.com/ropensci/plotly/issues/849
But it wasn't solved yet.
p <- ggplot(data = iris, aes(x = Petal.Width, y = Sepal.Length, color = Species)) +
  geom_point()

ggplotly(p, tooltip = c("y", "colour", "x"))

The order appeared on the tooltip is ("x","y","colour")
and not the one on the code ("y","colour","x")
Comment: If it is a known issue on github not sure I can offer a solution, but a workaround is to define a 'text' aesthetic i.e. `ggplot(data = iris, aes(x = Petal.Width, y = Sepal.Length, color = Species, text = paste(Sepal.Length, Species, Petal.Width))) ` then call `ggplotly(p, tooltip = "text")`.  Hope this helps somewhat.
Comment: Thanks @Dean ! It didn't occour to me to do that way, it is a workaround but it works haha.
Comment: that's great @Gustavo Utpott. Feel free to upvote if you found it useful, hopefully others may also benefit.
Comment: I'm sorry I don't have the reputation needed, this is my first question lol.
Answer: I know this is an old post, but in case someone else comes across this like I did. Have you tried this masking method with tooltip?
#ordering
p <- ggplot(data = iris, aes(x = Petal.Width, y = Sepal.Length, color = Species,
text = paste("y: ",y,"
colour: ",colour,"
x: ",x)) ) +
geom_point()

#mask everything else and only show what's in "text" variable
ggplotly(p, tooltip = c("text"))

Comment: Yes. I ended up doing just like Dean said on the comments, which is pretty much just like you did. Except that your code didn't work for me. There is no object "y" or "colour" or "x", but I think that if you refer to their real names on the dataset, it works.
``text = paste("y: ",Sepal.Length,"colour: ",Species,"x: ",Petal.Width))``


Trying to do a spotlight effect in android canvas

Question: I have a canvas and a simple bitmap for background image, fills the whole screen. I created a rect painted black and set it's alpha to 250 in order to make a "dark" effect on the background image. My aim to make a simple circle object that reveals the place it's hovering above. I tried thinking in many ways how to excecute it and failed.
I think the best way is to create a simple circle that manages to decrease the darkness alpha on the position it hovers above, but I have no idea how to do it.
The relevant part of my code:
<code>private ColorFilter filter = new LightingColorFilter(Color.BLACK, 1);
private Paint darkPaint = new Paint(Color.BLACK), paint = new Paint(), paint2 = new Paint();//The style of the text and dark.

public DarkRoomView(Context context) {
        super(context);
        myChild = this;
        darkPaint.setColorFilter(filter);
                darkPaint.setAlpha(250);
        paint2.setAlpha(10);
        paint.setAlpha(50);
    }

private void loadGFX() {//Loads all of this view GFX file.
        backgroundImage = BitmapFactory.decodeResource(getResources(),                R.drawable.darkroomscreen);

        lightImage = BitmapFactory.decodeResource(getResources(), R.drawable.light);

    }

private void drawGFX(Canvas canvas) {
      canvas.drawBitmap(backgroundImage, 0, 0, paint2);//The backgeound image.
      canvas.drawRect(0, 0, WIDTH, HEIGHT, darkPaint);//The darkness.
      canvas.drawBitmap(lightImage, 50, 50, paint);//A spotlight.
}
</code>
Any ideas how I should get it done?
Thanks!
Answer: For the spotlight, you could draw a circle of the original image over the darkness. You'd simply need to find the correct rectangle of the original image (based on where your finger is), and then draw a circle of that particular rectangle over the darkness. Trying to look "through" the darkness won't really get you anywhere; you need to place something over it.
Comment: Yeah, but it means I need to draw the part of the background image where the spotlight is. How do I draw only part of a bitmap?
Comment: Use drawBitmap (Bitmap bitmap, Rect src, RectF dst, Paint paint). src is the rectangle you're cropping from the original image, and dst is the rectangle you're drawing it into the canvas.
Answer: By the time you draw the "spotlight", you've already darkened the image with the rectangle. It would be difficult to recover information lost during that draw.
A more flexible approach would be to draw a dark rectangle with a spotlight in a separate image (that is, compose the "darkness" and spotlight alpha and color mask image first), and then draw that mask image on top of the background as a separate step. This would also let you easily do things like e.g. give the spotlight fuzzy borders.


How to convert a image url into base64 image source usign javascript

Question: Hi please suggest me a code for converting a image url into base64 image source
Comment: Please take the [tour](http://stackoverflow.com/tour), have a look around, and read through the [help center](http://stackoverflow.com/help), in particular [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) Make an effort to solve the problem. If you run into a specific issue doing so, post a question with your attempt (including all the relevant code), saying what isn't working, and explaining your research so far.
Answer: check this https://stackoverflow.com/a/22172860/7979057
seems that it's you want. maybe will need change some part of function only
Comment: thanks for response but it's not resolve  my problem however when i run example code it's gives only data; as output


Sum a unique/distinct value in a Pivot Table - possible?

Question: I am trying to make my pivot table sum a unique/distinct count of a score instead of every instance. Does anyone know of a way this might be possible? I basically only want to sum the first instance of a open and not all of them.

Thanks!
Comment: why not dedupe the source data?
Comment: How would you dedupe the source data Fabricator? Some records might have 1 open so they should remain untouched, but others might have 2 - multiple opens. I have about 10 thousand rows and im not really keen to do that by hand.
Comment: http://datapigtechnologies.com/blog/index.php/distinct-count-in-pivot-tables-finally-in-excel-2013/
Comment: Thanks mate! - No exactly what i wanted but it will do :)
Answer: You can create a flag for first entry for each open using a if then statement and put a filter for that flag to count unique opens


I want to create a Confusion Matrix

Question: The Code for the model architecture
#CNN Based Model in Keras

model = Sequential()
model.add(Conv2D(32,kernel_size=(3,3),activation='relu',input_shape=(224,224,3)))
model.add(Conv2D(64,(3,3),activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Dropout(0.25))

model.add(Conv2D(64,(3,3),activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Dropout(0.25))

model.add(Conv2D(128,(3,3),activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Dropout(0.25))

model.add(Flatten())
model.add(Dense(64,activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1,activation='sigmoid'))

Prediction
path = "/content/CovidDataSet/Val/Covid/0a7faa2a.jpg"
img = image.load_img(path, target_size=(224,224))

img = image.img_to_array(img)/255
img = np.array([img])
img.shape

(model.predict(img) > 0.5).astype("int32")

Now I want to create a confusion matrix and have no idea what to code since I am a beginner and will be grateful if anyone can provide
Answer: You can get the confusion matrix with this function and change the variables that you are using wrt:
from sklearn.metrics import confusion_matrix
import itertools

def plot_confusion_matrix(cm, classes,
                          normalize=False,
                          title='Confusion matrix',
                          cmap=plt.cm.Blues):

    if normalize:
        cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
        print("Normalized confusion matrix")
    else:
        print('Confusion matrix, without normalization')

    print(cm)

    plt.imshow(cm, interpolation='nearest', cmap=cmap)
    plt.title(title)
    plt.colorbar()
    tick_marks = np.arange(len(classes))
    plt.xticks(tick_marks, classes, rotation=45)
    plt.yticks(tick_marks, classes)

    fmt = '.2f' if normalize else 'd'
    thresh = cm.max() / 2.
    for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
        plt.text(j, i, format(cm[i, j], fmt),
               horizontalalignment="center",
               color="white" if cm[i, j] > thresh else "black")

    plt.tight_layout()
    plt.ylabel('True label')
    plt.xlabel('Predicted label')
    plt.show()

p_test = model.predict(X_test).argmax(axis=1)
cm = confusion_matrix(y_test, p_test)
plot_confusion_matrix(cm, list(range(10)))

Comment: which vairables to create I didnt create any variables hence i changed the x_test and y_test to the img but getting an error Classification metrics can't handle a mix of unknown and binary targets
Comment: When i Created X_test [] and y_test [] it gave me this error
KeyError: 'pop from an empty set'

I want to create a Confusion Matrix