Searching For Closest float values in an array

Question: I have a problem trying to pick the closest float value out of an array. Here is some example data;
The numbers that I will be dealing with always share this mirroring characteristic.
<code>{-9,-3,-1,0,1,3,9}
</code>
If I search for -8.8 I would expect to be returned  -9.
If I searched for 8.8 I would expect to be returned  9.
In the past when searching arrays for closest values I would go through the array keeping track of the absolute value for each array element minus the value I wanted. The Smallest value would win.
That method presents a problem here for me tho because at least 2 numbers in the array would be "closest" (in my above example 9 & -9)
Comment: that was indeed a typo. I have edited my question
Answer: your array will always be sorted, so binary search should be amenable to reduce the candidate set to 2 array values at max. i can only conceive of one challenge which will arise if the original array contains floats some of which differ by less than the machine precision.
how to deal best with this situation will depend on your application (if it isn't esoteric in the first place); note however that all the values indistinguishable from your test value will form a contiguous subsequence in your array, so as a heuristic you might just pick the middle element of this subsequence.
Answer: The fact that your array is mirrored makes this easy. You can initially ignore the sign of your search value and, as you mentioned, just find the closest absolute value. Then fix the sign.
This is Python, but it should be close enough to pseudocode that you can translate it to whatever you need.
<code>def find_closest(search_val):
    smallest_diff = float(inf)
    closest_val = 0
    # Search only positive half of array
    for val in [0, 1, 3, 9]:
        # Treat search_val as positive for now
        diff = abs(val - abs(search_val))
        if diff < smallest_diff:
            smallest_diff = diff
            closest_val = val
    # Correct sign of result
    if search_val < 0:
        closest_val = -closest_val
    return closest_val
</code>
Answer: Since, as you have mentioned, your numbers are always mirrored around zero, then only examine the negative numbers (assuming that you array is sorted). You will avoid the mentioned problem. What about 0.5? It too has two numbers that are at equal distance. How would you break the tie?
Comment: The array will always be sorted. So I guess if my search value is less that 0 search the first half of the array and if its greater than 0 search the second half of the array? This is what I will attempt now. In the 0.5 case...... Im not sure


adding on ?v=1 to urls

Question: As seen in the code from http://html5boilerplate.com/ (ctrl+f "?v=1")
What does ?v=1 do exactly? It's tacked on to the external css and js urls.
Answer: It's just a cache-breaking method, for example:
myScript.js?v=1

I can (via cache headers) tell you to cache it forever, then when I push a new version, it's:
myScript.js?v=2

And your browser sees it as a new file it much fetch, and it can be cached forever as well, so basically you get the max cache benefit, and still force the client to re-fetch when a new version's out there.  If possible, this version would be the result of a build process, automatically updated when the file changes (or at least a new build's, pushed, whatever the case may be).

As a real work example, look at the page you're viewing now:
http://sstatic.net/js/master.js?v=66ffcb6dcc55

It's a hash of the file...whenever it changes so does the hash on the end of the URL, and your browser will grab a new copy.
Comment: So presumably should only be done, if you regularly expect you js file to change ?
Comment: No. If you expect your JS to change **infrequently**, you combine it with long expire times in the cache control headers.
Comment: @spacemonkeys - Yep, or not regularly as well, when you want to get the maximum caching benefit you can take this route...the bigger you are the more bandwidth *not caching* eats, and the more important this becomes.
Comment: @David - There's no harm whether it changes frequently or not, this works in both scenarios equally well, minimizing the number of HTTP requests a client needs to make to ever get current or new files.
Comment: @All ... sorry I think I slightly miss read the answer, v1 = do it if you expect you file never to change, which has a performance benefit
Answer: This is done to circumvent browser caching. The idea is that when these files change, you would increment the version number, thus forcing the file to be fetched by the browser again.
Answer: It doesn't do anything, per se.
It is just part of a URL. It follows the usual pattern for a query string, so a server side process might pay some attention to it and modify the script.
Most likely, it is just a change in the URL which will still serve up a static file from exactly the same location … but as the URL is different to v=0, it will break any caching to ensure that the browser fetches a version that was at least as new as the newest when the page was updated to use that URL for the script.

adding on ?v=1 to urls


Customizing wordpress navigation header with woocommerce my account

Question: I am new to wordpress and I was creating a eCommerce website with woocommerce, then I have an idea to make an custom navigation header where when user is not log in it will show login/register and when login it will show to name of the customer.
Comment: For this you can use this plugin - https://wordpress.org/plugins/user-menus/
Answer: There are a few ways you can achieve this.
The easiest option is to use any one of the below plugins. Using these plugins, you can show/hide menu items based on their login status. These plugins also allow you to customize the menu based on User roles as well.
https://wordpress.org/plugins/nav-menu-roles/
https://wordpress.org/plugins/user-menus/
Or you can assign a custom class to the menu item and then you can hide/show them using CSS. "logged-in" class is added to the BODY tag when a user is logged in.


I am confused vs. I feel confused

Question:
I am confused vs. I feel confused

Since both are grammatically acceptable, I don't see any difference as a non-native English speaker.
Is there any particular difference?
Answer: The difference is subtle but fairly clear. To say, "I am confused", is to draw attention to your state of confusion. It would ordinarily be used if you want someone to clear up whatever issue confuses you. "I feel confused", on the other hand, is drawing attention to your feelings or emotional state, and you'd use it if you want sympathy more than clarification.
Answer:
I'm confused. In this sentence the speaker is stating a fact that he is confused.
I feel confused. In this sentence the speaker isn't sure whether he is actually confused or he just believes that he is confused.
Comment: While your interpretation of #2 is not incorrect, it's not the only valid interpretation of the three-word sentence. The verb _feel_ can be used as a synonym for "am" or "is". I can say, "I feel hungry," or, "he feels terrible," with absolute certainty about my hunger or his remorse.
Answer: There is little difference between "I am confused" and "I feel confused" - that's because if you didn't feel confused, you wouldn't know that you are confused, so you wouldn't say "I am confused".
For another person, there is a difference. "Joe is confused" states the fact that Joe is confused. Joe himself might not be aware of this. He might think that he knows exactly what his doing, when in fact his actions are all over the place.
Answer: The difference is about understanding the cause of the confusion.

I am confused: is it black or is it white?

In this case, it is a clear mental process, where a clear decision cannot be made because of insufficient or conflicting information.

I felt confuse after I woke up.

I have a strange feeling that something is wrong, that something is not understood, but I have no idea why.
Or:

I am tired after not sleeping for 30 hours.

I had some intense activity, or I did not sleep in a long time, and my body needs to rest literally.

I feel tired, although I just woke up.

I have no reason to be tired, but the feeling is there. Maybe I am sick?
I feel I am ...(X) sounds like an ostricho-camel with too many words..
Answer: There's really no difference. Yet, "feel" describes the state that is most probably true, but which in rare cases may differ from "is".

I am tired (A state when you are tired)
I feel tired (A feeling of being tired)

There's a third option which isn't any different from the other two:

I feel I am tired.

I am confused vs. I feel confused


How does static electricity produced in blizzards?

Question: I've read that in strong blizzards static electricity can occur and even produce lightning. How friction between snowflakes can create distribution of electrical charge?
Comment: http://earthscience.stackexchange.com/questions/6953/is-there-a-buildup-of-static-electricity-in-a-sandstorm
Answer: When two or more different substances rub off each other, depending on their atomic makeup, electrons that are loosely bound may often be exchanged between them. So you end up with an accumulation of electrons (negative charge) in one region and an opposing positively charge in another region.
In many ways, a blizzard resembles a thundercloud (in its composition and  wind speeds), so it's not really surprising that lighting can occur in blizzards.
The extreme conditions in a blizzard causes the molecules of water, oxygen, nitrogen, drops of water and the semi-solid ice crystals to rub together violently. Just like glass and silk rubbing together, this can cause a build up of two sets of opposite electrical charges. You then have two or more regions of opposite charge and a lighting strike will eventually result to equalise this electrostatic imbalance.
From: How Lighting Discharges Through Air

In order to get a conventional spark, the kind that a spark plug makes, the electric field needs to surpass the conventional breakdown field, the point at which air loses its insulating properties and becomes capable of conducting electricity. For air, this is about 70,000 volts per inch at sea level. A car accomplishes this by supplying a high voltage—say 20,000 volts—across the narrow gap of the spark plug.

Blizzards can also produce large voltages. They do this when ice and water particles carried by high winds collide with soft hail and snowflakes.
The cold that turns water into solid or semi-solid ice does not affect this exchange of electrons, any more than rubbing solid glass with solid silk affects the exchange of electrons.

Image Source: Water Molecule Structure

I wonder how exactly (by what reasons) electrons that happy in the water molecule, jump to another molecule of water when collide.

If you look at the diagram above, you can see the large oxygen  atom  and the two smaller hydrogen atoms that makeup the water molecule and are the basis for ice crystals. If the kinetic energy of another particle is high enough, because of strong winds, it is able to exceed the energy needed to remove an electron. This is called ionisation. That's why normally, the water molecules do not lose electrons , but in high winds, with particles hitting off each other, the high velocity particles  do have enough energy to remove the electrons.
This link tell you more about How Lightning Happens and this link Water Ionisation Wikipedia tells you more about how electrons are removed.
Comment: I have put your comment in the answer and my reply to it. If the particle that hits a water molecule has enough energy, ( from the high winds), it can overcome the force that holds the electron to the water molecule. Regards
Comment: I wonder how exactly (by what reasons) electrons that happy in the water molecule, jump to another molecule of water when collide. Can you explain it?


Loss of power when park lights switched on

Question: My Nissan Nv200  2012  right hand drive has this issue when ever i am driving then switch on the park light so as to illuminate the dashboard i immediately lose pedal power.Switch it off and vehicle picks up rev immediately again switch lights on again Throttle position drops and holds at 21% rev just up to 3000rpm no more.  Scratch my head auto electrician can't seem to figure it out at all help?
Comment: Has anyone fitted aftermarket stuff? If so, rip it out and start from standard...
Comment: No not that i know of altho vehicle was bought used it worked fine for over a year have it Sep 2017 to now Sep 2019
Comment: Whenever weird stuff starts happening with dash lights, I would (1) replace the rear brake light bulbs. I believe they are inexpensive 1157's. If that did not fix it, then (2) suspect the alternator. Alternators do weird things when they start breaking down. I've seen other bizarre problems on rare occasion, but by far the two listed are the most prevalent. If you want to chase a rare problem you need to get your multi-meter out and start measuring voltage drops across sensors.
Answer: Looks like you car has a throttle pedal sensor.
My guess would be that you have a bad earth connection somewhere, so that the sensor is having to find its earth through the lighting circuit.
I would check the resistance of the ground connection at the throttle pedal as a start.
Comment: Yes i thought of that .so i was thinking is it one of those relays that has a normal open normal close interchange relay that ive been trying to find it i can hear a relay inside a fuse and relay box with what looks like a module please i could get help locating this relay circuit diagram and for the pedal sensor Nissan Nv200 Vanette 2012 hr16 engine thanks
Comment: Tried exchanging it with another vehicle that works  pedal sensor same thing
Comment: I didn't suggest that it was a faulty pedal, I suggested that the earth to it may be faulty.  You need to check the power/earth feed.
Comment: If you have access to another vehicle, then you could compare the voltages on each of the throttle sensor connections.


What is the intensity distribution behind the first beam splitter on an observation screen at the same distance like behind the second beam splitter?

Question: Mach-Zehnder interferometer has been used, among other things, to measure phase shifts between the two beams caused by a sample or a change in length of one of the paths. My simple question is: What is the intensity distribution behind the first beam splitter on an observation screen at the same distance like behind the second beam splitter?
Answer: If the beam splitters are all 50% reflectors and perfectly flat, etc.  then whatever spatial energy profile the incoming beam has will be seen in both paths behind the first splitter.  A typical interferometer is set up so that the paths are short enough that self-interference/diffraction does not happen.
Assuming your "second splitter" is the recombiner, then the intensity pattern there is the combination of the interference effects with the input spatial intensity pattern.  That is, if you had a "dim" region in the input beam,  you'd see the same fringe pattern as elsewehre in the beam but with lower peak intensity.
Comment: You won't see interference patterns in either "leg" of the interferometer between the two splitters.  And you won't see any self-diffraction effects unless you allow the beam to propagate a *looooong* way -- see Fresnell vs Fraunhofer zones at Wikipedia
Comment: Carl, wait. From your answer it is a little bit unclear to me (German native speaker :-( ), what happens behind the first beam splitter. I think, we see intensity patterns at some distance. And I have read this in your answer, but I'm not sure.
Comment: I'm not care about the distance. Amazing is the fact, that you get intensity distributions behind a beam splitter.


How do I purchase tickets for the Night Riviera sleeping compartment?

Question: How do I purchase tickets for the Night Riviera sleeping compartment? I
already have my train ticket. I would like to buy online as I live in the USA.
Answer: According to https://www.seat61.com/Cornwall-sleeper.htm the bookings can be bought at https://www.gwr.com and for pick-up at the station when you travel.
The Man In Seat 61 says that GWR doesn't accept foreign cards, but I had no problem buying an Advance ticket through their website with a Danish Visa card earlier this month. That may be because the card was at least European, or seat61's info may be out of date. They did require "Verified By Visa" authorization.
Unfortunately The Man In Seat 61 also says:

You cannot book berth supplements to go with existing tickets or BritRail passes other than in person at stations.

and indeed I can't get www.gwr.com to make a booking for just the cabin supplement when I try.  Similar experience on thetrainline.com. You could try calling GWR directly at +44 345 7000 125 and hope this is also outdated information, but I wouldn't be optimistic.
Comment: @skifans: See my very recent addition: I have firsthand experience to the contrary.
Comment: I've used an American credit card (MasterCard) on gwr within the past six months successfully. I've also failed to use an American Visa credit card, so your mileage may vary. :-/
Comment: Unfortunately, the man in seat 61 advises that gwr cannot accept cards issued outside of the uk
Answer: If you already have a train ticket and just want a berth supplement, you will need to telephone GWR I'm afraid. As far as I am aware, there is no other way of purchasing these from abroad for the Night Riviera (the Caledonian Sleeper website now sells them but only for the Scottish sleepers; not the Cornish one).
Telephone them on +44 345 7000 125, and tell them you already have a ticket and want to purchase a berth supplement. I believe you should be able to do this over the phone, at least if you manage to get through to the right people.
If this doesn't work for you, your only other option is to try to buy one at a station as early as possible when you arrive in the country. If you think you're not travelling at a busy period this may be feasible; otherwise the train might be sold out. In any case, it's risky for this reason. I also find that some ticket offices are better than others at knowing how to sell these!


SQL Server 2000: search through out database

Question: Some how some records in my table are getting updated with value of xyz in a certain column. Out of hundred of stored procedures, functions, triggers, how can I determine which code is doing this action. Is there a way to search through the database some how through each and every script of the code?
Please help.
Answer: One approach is to check syscomments

Contains entries for each view, rule,
  default, trigger, CHECK constraint,
  DEFAULT constraint, and stored
  procedure within the database. The
  text column contains the original SQL
  definition statements..

  e.g.  select text from syscomments

If you are having trouble finding that literal string, the values could be coming from a table, or they could be being concatenated within a routine.
Try this
Select text from syscomments
where CharIndex('x', text) > 0
and CharIndex('y', text) > 0
and CharIndex('z', text) > 0

That might help you either find the right routine, or further indicate that the values are coming from a table.
Comment: It finds some of the results but not all of the results. I am using it like this.
select text from syscomments where text like '%xyz%'
Comment: can you give an example of a result it is missing?
Answer: This is going to be nearly impossible to do in SQL Server 2000 because the update might very well be from a variable that has that value  or a join to another table that has that value and not hard-coded into the stored proc, trigger etc. The update could also be coming from a DTS package, a job, a piece of dynamic code run by the app or even from query analyzer, so the code itself may not be recorded inthe datbase anywhere.
Perhaps a better approach might be to create an audit table for the table in question and have it record the user and the code from the spid that generated the change as well as the old and new values. You'll have to wait until it happens again, but then you would know exactly what changed the value and what value to put it back to if need be.
Alternatively you could run profiler on the system until it happens but profiler tends to hurt performance and is not usually a good idea to run on a production system. If it is happening very often, it might be an acceptable alternative.
Here's a hint as to how you might get some of the info you want for the eventual trigger code you write:
create table #temp (eventtype nvarchar (1000), parameters int, eventinfo nvarchar   (4000), myspid int)

declare @myspid int
select @myspid =@@spid

insert #temp (eventtype,parameters, eventinfo)
exec ('dbcc inputbuffer (@@spid)')

update #temp
   set myspid =  @myspid
select hostname, program_name, eventinfo
   from #temp t
   join sysprocesses s on t.myspid = s.spid
   WHERE spid =  @myspid
Answer: You might use sql-profiler to trac the update of a given table / column.


Self-inductance of toroid of rectangular cross section (N=windings?)

Question: I have found a lot of answers about how to calculate the self-inductance of toroid of rectangular cross section, however my question says that "The winding are seen as a thin homogenuous currentlayer around the core" (excuse the translation). What does that mean for N? Does it mean N=1?
Comment: Yes. Or put 1000 windings on it and divide the current by 1000. Same result. I can only assume this odd phrase is used to deny the presence of any skin effect.
Comment: As @Janka is saying, you care about amps/meter and that N doesn't matter. Watch [Walter Lewin at MIT on Ampere's law](https://www.youtube.com/watch?v=1dCChkEGi_c); somewhere near the middle (around 17 minutes and later) he gets to the point you may care about.
Answer: It's just a (confusing) way of saying 'stick to the simple calculation of flux in the core, don't worry about flux in the air'.
The inductance of a wound toroid consists of the sums of two contributions ...
a) The inductance due to the field through the core
b) The inductance due to the field in the space round the wire
The inductance due to the core dominates the total, increasingly so as the core relative permeability increases. It's easy to calculate, the magnetic path length and cross section are sell defined. This inductance is what most people would stop at when they want to calculate the inductance of a wound toroid. This inductance is the same whether the wire is wound uniformly tightly to the core (closely approximating a thin homogeneous current layer), or is wound more loosely, or in a single bunch or bunches on just part of the circumference.
The inductance due to field through the air is small, and almost totally negligible compared to the core contribution for any reasonable relative permeability. It's difficult to even estimate its contribution, calculation of it would involve 3D integrals of Biot Savart. For windings in the form of a thin homogeneous current layer, its contribution is zero, as such a toroid has no external field.
Answer:
"The winding are seen as a thin homogenuous currentlayer around the
  core" (excuse the translation). What does that mean for N? Does it
  mean N=1?

Regarding the winding as a "thin homogenuous currentlayer" does not help understand what the inductance is when many turns are used. However it does help understand the H-field inside the core and whether the core is potentially saturating. Whether it's 0.1 amp and 1000 turns or 100 amps and 1 turn, the same H-field is produced.
So, amps x turns (aka ampere-turns) is referred to as the magneto motive force (MMF or sometimes \$F\$) and this is a useful quantity to know because: -
\$\Phi = \dfrac{F}{\Re}\$ i.e. total flux is MMF divided by core reluctance.
H is also MMF divided by mean core length and you can convert H to flux density (B) by knowing the permability of the core material hence, you can get to an understanding about core saturation limits for the material being used.
However, to know inductance you have to use the correct number of turns and so regarding the multitude of turns as one turn doesn't help at all.
Answer: Tehnically, \$n\$ windings with a current of \$I'\$ correspond to one winding with a current of
$$ I = n\cdot I' $$
In practical you get magnetic flux between your windings etc, that is not in your toroid core. This is called leakage flux.

The winding are seen as a thin homogenuous currentlayer around the core

This basically tells you that you don_t have to think about the leakage flux and other weird properties of physical coils. Just go with above definition.
Under these assumptions the inductance of a toroid is quite simple to calculate.


Using jsp:param / c:param in a Portlet Environment

Question: I'm trying to include JSP pages with jsp:param in a Portlet environment (using the Pluto portlet container).
for example,
<jsp:include page="test.jsp">
   <jsp:param name="foo" value="bar"/>
</jsp:include>

and in test.jsp,
<c:out value="${foo}"/> or <%= request.getParameter("foo") %>

The output is always null and i've also tried using c tags, but got the same result.
<c:import url="test.jsp">
   <c:param name="foo" value="bar"/>
</c:import>

I've searched through the net and many people have faced the same problem, except that there is no solution to it.
Is this a limitation or is there a different way to do it?
Answer: This works fine in a normal Servlet environment, but I see from a bit of googling that the portlet environment seems to break it. This is a shame, but indicative that the portlet spec is, to put it bluntly, broken.
If <jsp:param> won't work for you, the alternative is to use request attributes instead:
<c:set var="foo" value="bar" scope="request"/>
<jsp:include page="test.jsp"/>

And in test.jsp:
<c:out value="${requestScope.foo}"/>

or maybe just:
<c:out value="${foo}"/>

It's not as neat and contained as using params, but it should work for portlets.
Comment: That's correct. I would however add that the portlet API's offers builtin ways/taglibs to go around this. I have never done portlets so don't pin me on it, but quickly scanning the docs learns me that under each `` would be the way to go.
Answer: I had the same problem. My solution was to work with Portlet's renderRequest object (which is accessible from included jsp files). In my portlet I set the attribute on the RenderRequest object then in my JSP (included via jsp:include). I use Portlet API to access the implicit renderRequest object. Here is a sample:
MyPortlet:
public void doView(RenderRequest request, RenderResponse response) {
  request.setAttribute("myBean", new MyBean());
  getPortletContext().getRequestDispatcher("myMainJSP.jsp").include(request, response);
}

myMainJSP.jsp:
<jsp:include page="header.jsp"/>

header.jsp:
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<% page import="sample.MyBean" %>
<portlet:defineObjects/>
<%
  MyBean myBean = (MyBean)renderRequest.getAttribute("myBean");
%>
... html code...


Transistor with 2 voltage sources (power supplies)

Question: Is it possible to use a transistor to act as an relay? What I mean by that is using a 3V battery to control the gate so that a separate 12V battery can let its current flow to other parts of the circuit. Or must a transistor use only a single power supply? Some examples would be great.
Comment: A transistor only has three pins because the lower and higher voltage parts have the same ground reference. A relay consists of two seperate circuits, each having + and -.
Comment: Using a low voltage to switch or control a higher voltage is exactly what a transistor is there for. Though, a major property of a relay is that it provides galvanic insulation which a transistor does not. When switching 12V, galvanic insolation probably isn't required.
Comment: Thank you. I was confused because the transistor only has 3 pins and a relay has 4. Still not 100% sure how and why that is but the main point is solved. Cheers!
Answer: Yes it is, but there are some differences.

In a relay, generally the actuation coil and the switching contacts are electrically isolated from each other -- so (for example) the coil can be driven from a safe-to-touch circuit, while the contacts may be switching the mains voltage.
In a transistor, you'll need the supplies to have a common point -- typically this would be the negative supply of each.
Transistors are generally much more delicate than relays. Small overloads or overvoltage will destroy them, and they might fail short-circuited
A MOSFET will be easier to drive than a bipolar (e.g. NPN) device. In a bipolar device you'll need provide sufficient base current to saturate the device. This will require knowing the maximum load current (and dividing by the worst-case beta). In a MOSFET, you can just apply sufficient gate voltage -- 3 V will usually work, but the FET will work better with a higher voltage.
Relays work as well with AC loads as DC loads; transistors don't. A MOSFET has an internal body diode which will always conduct if the drain voltage is lower than the source voltage. A bipolar device will also conduct in this case (it's a little more complex and depends on the voltages involved).
Relays may have normally-open and normally-closed contacts -- a transistor is closer to a normally-open switch.
Answer:

simulate this circuit – Schematic created using CircuitLab
Your load is R1. You could also use a PNP transistor.
Comment: Note: R2 is important, don't leave it out, unless you are using a MOSFET transistor which doesn't need it.


Anyone have any impressions, hints, tutorials from developing for Google Android devices?

Question: I have a T-Mobile G1 and I'm going to download the developer SDK and see if I can create a few simple apps for my phone.  If you've done similar development, please answer below and tell me about your experience.  Please share any links you found especially useful.
Answer: I didn't find the SDK documents to be all that helpful, at least at first.  What really got be started was looking through the example chapters of The Busy Coder's Guide to Android from CommonsWare.  You can find this on the book's website.  The code examples for the book are also provided at that link.
The example code provided in those examples, plus the example code included in the SDK gave me a good idea of where to start.  I'm still not totally solid on a lot of things, but development is going a lot faster than it was beforehand.
One thing you definitely want to be sure you do is watch the videos provided by Google.  The application life cycle for Android is much different than a traditional application, so you want to make sure you understand was Intents, Views, and Content Providers are.  These videos can all be seen on YouTube in this playlist.
The last helpful resource I can point you to is the blogging community.  Every now and then, Planet Android and Hello Android have code excerpts from the blogs they aggregate. Jeffrey Sharkey is big into Android development and has released some useful code on his blog.
Android development currently is much like shooting in the dark, but it will hopefully take off soon and provide us with more valuable resources!  I know there are a few books out there.  Good luck!
Answer: The biggest thing I recommend is to make sure you really understand the lifecycle of android apps. Many apps are put out there which crash or perform badly (or make the entire phone run poorly) because they are not designed to follow the application lifecycle properly.
For simple apps it's nothing to worry about but soon you might want to run something in the background (play music, etc), or need to save your state if the user switches apps. It's tricky but makes sense once you see some examples.
You might also check out some of the Android sessions from the Google I/O developer conference in May:

An Introduction to Android
Building an Android Application 101
Anatomy & Physiology of an Android
Answer: I started from here
http://code.google.com/android/kb/commontasks.html
I got my environment and emulator up and running within about 15 minutes.
First impressions are its fun to work with.
Paul
Answer: I found the notepad tutorial extremely helpful in understanding the basics.
Answer: I'm also beginning to get my feet wet with android development. Honestly, I think some of the books out there do a pretty good job of explaining the development framework and getting you started with using the tools quickly. Some of the books I'm reading include "Teach Yourself Android Application Development in 24 Hours" (obviously the title is an exaggeration; the book is just organized into hours. Each hour will take some time for a beginner), "Hello, Android: Introducing Google's Mobile Development Platform (3rd edition)", and "Beginning Android 2." From my, so far, limited experience, developing using the SDK is accessible and enjoyable. That being said, you really need to commit the time/energy to get up to speed.


Prove that the class of regular languages is closed under three operation

Question: We define an operation three on strings as three(c1c2c3c4c5c6...) = c3c6... then the above-described definition is extended to languages. Prove that the class of regular languages is closed under this operation.
Comment: If $R$ is regular, there is a DFA which recognises it. Given a DFA $D$, how can you make a finite automaton which recognises $\mathit{three}(L(D))$? ($D$ doesn't really have to be deterministic. But it might help your thinking.)
Answer: Let $Q$ be a $DFA$ recognizing $L$. To show that $\mathrm{three}(L)$ is regular, you only need to construct a $NFA$ deciding $\mathrm{three}(L)$ (this suffices, since any $NFA$ can be transformed to an equivalent $DFA$). Now, the key idea is that if the $NFA$ is reading, say, the first character $c_3$, then it can guess what two characters $c_1,c_2$ occurred before it.
More formally, suppose that $Q = (\Sigma,S,s_0,\delta,F)$. Given a string $\overline{x} \in \Sigma^*$ and states $s,s' \in S$ we will use $s,\overline{x} \to s'$ to denote the fact that $Q$, starting from state $s$ while reading the first character of $\overline{x}$, ends up in state $s'$ after reading the entire string $\overline{x}$. Consider now the following non-deterministic finite automata $Q' = (\Sigma,S\cup \{s_0'\},s_0',\delta',F)$, where $s_0' \notin S$ and the transition function $\delta$ is defined as follows:

For every $s\in S$ and $z\in \Sigma$ we define $$\delta(s,z) := \{s' \in S \mid \exists x,y \in \Sigma : s,xyz \to s'\}$$
For every $z\in \Sigma$ we define
$$\delta(s_0',z) := \{s'\in S \mid \exists x,y \in \Sigma:s_0,xyz \to s'\}$$

It is straightforward to verify that $L(Q') = \mathrm{three}(L)$.
Answer: You might use closure properties of the regular languages: (inverse) homomorphisms and intersection (by regular languages).
Assuming the language is over the alphabet $\Sigma$, make two copies $\Sigma_i = \{ \sigma_i\mid \sigma\in\Sigma \}$ of that alphabet, $i=0,1$.
The homomorfism $h$ maps elements from $\Sigma_0\cup\Sigma_1$ onto their original $h:\sigma_i\mapsto\sigma$. The inverse morphism $h^{-1}: \Sigma^* \to (\Sigma_0\cup\Sigma_1)^*$ nondeterministically chooses a $0$ or $1$ copy for each symbol.
Now let $g$ be the homomorfism on $\Sigma_0\cup\Sigma_1$ that deletes symbols from $\Sigma_0$ and maps symbols from $\Sigma_1$ onto their original.
Now the following composition keeps every third symbol, while deleting the other symbols
$w\mapsto g(\;h^{-1}(w) \cap (\Sigma_0\Sigma_0\Sigma_1)^*(\Sigma_0^0\cup\Sigma_0^1\cup\Sigma_0^2)\;)$.
This method has the advantage that it also works for context-free languages.


How can I remove these Hep20 tees?

Question: can anyone tell me how to remove these Hep20 Tees please? I want to replace with elbows and cut the lower leg off.  (I know how to seal those off thanks).  Can't upload a picture but they were fitted in 2007. They have a screw off cap and are grey, fitted to plastic and copper
Answer: Google tells me you need a HepKey or HepKey Plus. That's the blue part in this cutaway image.

Looking at how it works, it looks like you just need a round collar that can get between the tubing and the rim of that outer ring. I would try rolling a plastic card with a heat gun and see if I could push the release ring without hunting down the tool.

How can I remove these Hep20 tees?


i want to know the mac address of my stolen system having windows 10 installed in it?

Question: My dell laptop has been stolen and i want to know the mac address of the device to track it. the system is sync with google and windows 10 OS is installed.
Comment: Wasn't sure what category to close this one - a) mac address is irrelevant. b) it's not a security question - it relies entirely on the applications you have installed. If you have ones that can help you track it, brilliant - otherwise you can't.
Comment: Have you researched MAC addresses. How do you think a MAC address will help you track your PC?
Comment: i think when it gets connected to a network it can be tracked down
Answer: Why won't MAC tracking work?
Although MAC addresses ought to be unique, there is no convenient way of tracking a MAC address. You would need to have access to lower-level network layers to find out if a device with a specific MAC address is currently connected to a Gateway/Router/etc.
Higher Layers such as IP, TCP/UDP don't include references to the MAC address. But only these information (From layers above the Ethernet layer, which uses MAC for addressing) are forwarded for packet routing outside the local network the device is currently in.
So only having the MAC address of a device is practically of no use for tracking it if you don't have access to the network it can be connected to.
How to find out your MAC address without the device:
If you still have the information on or package of the Laptop, there might be a label with the MAC address written on it. But as said above, this would not be helpful for tracking.
How to still track your device:
Your best possible option would be using Googles login history to find out the last login locations (of which it warns you about if there are unreasonable logins from e.g. different countries, unusual invalid login tries).
Comment: Also if he connects that laptop directly to the internet you might be able to track him using tools such as furn wifi cracker. Furn wifi has a feature to do a geo-location mac address lookup. Another good project is http://oco-carbon.com/coding/wifi-location-api/ This allows you to search for mac address locations based off wiggle wifi database
Comment: Wigle only tracks WiFi Access Points, not clients connected to the network -as far as I understood - so this does not apply for this case. You need the APs log files or similar information to get connected MAC addresses for a lookup, and this database would be HUGE.
Answer: Unfortunately, MAC addresses are not (usually) routed over the internet.
So unless you have a cached information on your network (internet router, appliance, internal service) or on a paper (original NIC/laptop boxes, ...) you can't find it.
To track your laptop, if you don't have any specific service installed on it for this purpose, you can try to track your connections on online services, like your emails accounts. Some providers allows you to know from where you have an open connection to their service. Should the thief open a web browser that auto-connects to your email account, you might be able to get their IP address.
If you meet legal requirement, you might be able to get ISP to release information on this particular IP address (you probably will have to see the authorities for this)


Find local max min or saddle points for $f(x,y)=3y-y^3-3(x^2)y$

Question: Find local max min or saddle points for $f(x,y)=3y-y^3-3(x^2)y$
I know how to solve this problem, just having trouble finding critical pts when i set $f_x = 0$ and $f_y =0$. We have:
$$f_x=-6xy = 0$$
$$f_y=3-3y^2-3x^2 = 0$$
Answer: So, we have $f(x,y)=3y-y^3-3yx^2$. Hence, for critical points $(x,y)$, we have,
$$\begin{cases}\dfrac{\partial f}{\partial x}=-6xy=0\\ \dfrac{\partial f}{\partial y}=3-3y^2-3x^2=0\end{cases}$$
First equation implies that either $x=0$ or $y=0$ or both $x,y=0$.
Now, if $x=y=0$, then the second equation is not satisfied, so $(0,0)$ is not a critical point. Then,
$$x=0\implies 3=3y^2\implies y^2=1\implies y=\pm 1\\ y=0\implies 3=3x^2\implies x^2=1\implies x=\pm 1$$
So, we have our required critical points as $(0,1),(0,-1),(1,0),(-1,0)$.
Comment: @Charlene, I'm getting $D(x,y)=36y^2-36x^2$ which gives me $D(1,0)=-36\lt 0$ which implies that $(1,0)$ is a saddle point of $f$.
Comment: For (1,0) D>0 but fxx=0 so would that make it not a critcal point?
Comment: @Charlene, I didn't understand what you meant! Can you please elaborate?
Comment: To find out if 1,0 is a local min max or saddle point you find out what D equals and if its negative its a saddle and if positive then depends on whether fxx is pos or neg. but if fxx =0 then idk if its max min saddle of none


Why didn't Kane suffocate before he got back to the Nostromo?

Question: Right after Kane discovered the Xenomorph egg cluster things went downhill. First of all, his suit was ruptured. Next, he was embraced for a long time in an oxygen poor environment before he was dragged and hauled back to a breathable atmosphere. How did Kane breath after the facehugger breached his environmental suit?
Comment: Ehm, didn't it feed him oxygen?
Answer: From Wikipedia (emphasis mine)

Upon making contact, the facehugger tightens its tail around the
  host's neck in order to render it unconscious through oxygen
  deprivation. The facehugger then inserts a proboscis down the host's
  throat, supplying it with oxygen while simultaneously implanting
  an embryo
Comment: @MajorStackings As to the how, the only conclusion based on what we see in the films is that the facehugger somehow absorbs oxygen from the air around it, filters it out and passes it into the proboscis/ovipositor. The more relevant question is how did it know to supply him with oxygen instead of, say, nitrogen. And I don't think there's a clear answer to that in the current evidence (but I think you could come up with a working theory based on what's in Prometheus).
Comment: How does it supply him with oxygen? That it could would imply the Xenomorph understood enviromental suits.
Answer: The how part is not covered in the film but it is definitively explained by ash when he was talking to Dallas that the face hugger was keeping Kane alive.


SubSonic CreatedBy

Question: I have a CreatedBy column in a table which datatype is a int. SubSonic crashes on this because apperently it uses CreatedBy, CreatedOn, ModifiedBy and ModifiedOn. The By columns need to be strings.
Is there a way to let SubSonic know that it has to ignore these columns?
Answer: No, you probably are going to have to rename the column to CreateByUser or something.
You can also change it to a nvarchar(50) and create a column ModifiedBy nvarchar(50) and have it work just fine too.
Answer: Yes... this is totally doable.  First of all show us the code that makes it crash.  I probably know what it is.  You are probably trying to do something like this
MyRecord.Save();

Where as you need to do pass in the id of the person that is creating the record aka.
MyRecord.Save(55);

SubSonic knows what datatype your columns are so you don't need to tell it what datatype it is.  Also if you look there are overloads of the Save method namely Save(int id), Save(string id), and Save(Guid id).  So as long as you use an int,string or guid for your CreateBy column you are good to go,  you just need to remember to pass in the ID as SubSonic expects it if you use those columns.

SubSonic CreatedBy


Rapidshare and Megaupload traffic shaping by ISP

Question: I think my ISP is shaping Rapidshare and Mega Upload traffic, the download speed goes down to 30 kb/s every time and only on those sites, I've tried with different programs for downloading and the same happens, is there anyway I could prove they are shaping the traffic?
Answer: Are you using the free versions of these sites? If so, it's possible that the sites themselves are  limiting your download bandwidth if you are downloading lots of of data (in order to increase sales of premium accounts). There is a Rapidshare "accelerator" which automates the tedious process of downloading multiple files from Rapidshare, so it's not surprising that Rapidshare would find other ways to persuade users to pay for the premium service.
Answer: If you want to test if your ISP shape your bandwidth when you download at rapidshare or megaupoad. Try to put Sock on your download manager and see if there's difference ;)


How to load a user's friends list?

Question: I am trying to create a structure that allows People to log into my app, and create a profile for them. They will also have the ability to look-up, and add friends. They will also have the ability to see there list of current friends, and then see their friends profile.
So, i realized i could utilize googles AppEgnine Data store system for alot of this. https://developers.google.com/appengine/docs/java/datastore/entities#Kinds_and_Identifiers
i had a few questions though. What would be the best way to go about storing users friends list, and managing photo icons of these friends, etc?
The Google Datastore has a option to query with VERY specific options so this would be easy to implement during the search function, or even when a user clicks a friends name to pull up there profile.
I am just wondering what would be the best way to manage the list of friends, and then loading a photo icon for each user? I'm not sure if any of you have seen the facebook app but when you look at your friends list it pulls it up pretty fast and loads the images in the background(probably using an asynctask for this).
Any suggestions or answers?
Thank you!
EDIT: My main question is how do i keep track of a users friends list and allow to load the users profile once there name is clicked from the friends list? Any suggestions?
Answer: Serving images done with app engine app engine hight performance image serving is almost free and very fast.
Here is an article: http://ikaisays.com/2010/09/08/gwt-blobstore-the-new-high-performance-image-serving-api-and-cute-dogs-on-office-chairs/

How to load a user's friends list?


Handlebars for an upright seated position

Question: After injuring my neck, shoulder and arm on a fall from my bike I need the type of handlebar that you see more commonly on a cruiser bike.  ie that is one that gives you anupright sitting position.  My bikes are a Merida 100d and a Specialized Ariel.  Does anyone know of a handlebar the can fit these bikes.
Erin
Comment: Considering your injury, you might need a new bike. Most MTB/road bikes are designed with the idea you are going to be hunched forward, definitely not ideal for an injury like yours. If you only need a few inches, you might be able to just get new bars. For the most part they are standardized in size so it shouldn't be much of a problem finding one that fits your neck. But if not, consider getting a new neck as well! Don't risk damaging your neck (on your shoulders) any further!
Comment: First thing to do is to raise the bar.  This will likely require changing out the stem and/or adding extensions.  Try to find a new stem with less forward extension.  (Personal peeve: Cycle designs make this hard, and most non-"comfort" bikes are sold with the bar too low, because it looks "mean" and "sexy" on the showroom floor.  But the bike doesn't get ridden because it's too uncomfortable.)
Comment: (Since January of last year I'm missing two of the three tendons of my rotator cuff, but manage my touring bike with drop bars just fine.  But I changed the stem for a taller one with less extension a long time ago.)
Answer: You can likely find bars the will fit, but keep in mind that you still want the bike to function which means moving over your shifters and brake levers. While you could probably do this as a DIY project, I'd really recommend going to a bike shop and at least getting some advice first.
The can help you select a bar that is the right diameter to fit with your current stem and talk you through issues like re-cabling (longer bars probably mean longer cables) and where/how to mount shifters and brake levers. You might end up wanting to change brake levers to a different type depending on bars.
Don't forget the you still need to be able to get on and handle the bike. You will be doing some strange things with the center of rotation for the bars. At low speed (...i.e. the speed cruiser bikes that normally have these bars), this is probably not an issue. But you get up to high speed on a decent and you might find yourself in trouble. Start slow and see how it handles.
Happy riding.
Answer: The simplest thing to do would be swap the stem for one that gets your handlebar taller, say some 5 inches taller at least, perhaps preferrably more. This would allow you to keep your current "cockpit", with grips and levers and shifters etc.
If you don't find the taller stem (I've had a hard time finding really tall stems at the shops), I would suggest a BMX handlebar, since they get your hands much higher.
One thing to note is: when you raise your hands and torso, the body weight gets shifted so that there's less weight on the front wheel, which might affect handling making the bike a bit more unstable and prone to unwanted wheelies uphill. In this case, a BMX handlebar can be more adjustable because by rotating it in the stem you can adjust reach to get a good weight-balance and steering behaviour. The downside is the torque BMX handlebars apply on the stem, which usually is not a problem if you don't ride aggressively.
A final note on the BMX handlebar: some shifters don't fit well around the curves of the handlebar, test it before buying, if you will.
And, of course, cable and router lengths will most probably need to be replaced for longer ones.
Hope that helps!
Answer: I think using a stem raiser may bring your handlebars to a position where you can ride upright. I used the  a stem raiser on my cycle with road-style drop bars. This helped me achieve more upright position.
This is applicable to the cycles that you have, just make sure the stem diameters match the fittings.
An alternative solution would be to use an adjustable stem, here is an example.
These options are cheaper than getting a new handle bar setup, unless you are specifically looking to change the handle bar style. The links above are used as example only, I am not affiliated to mentioned organizations.
Comment: An alternate name for te component may be "steerer extender".


How to create a virtual interface from a socks proxy?

Question: I am wanting to create a network interface from a SOCKS 5 proxy on localhost.  This will eventually be bridged with a wireless interface that I have which will be operating in AdHoc mode.  This will allow all the clients on this interface to use the socks proxy even though they don't have support for SOCKS.  This will support my iDevices, PSP, etc, when I am on the go.  It will be ran off of my laptop.  Can anyone provide some useful resources in which will help me get a SOCKS proxy interface setup on my Ubuntu machine?  Thanks in advance!
Answer: You need tun2socks, it is part of BadVPN project (https://github.com/ambrop72/badvpn). There is already an answer here recommending tun2socks, but it lacks examples.
You can either build tun2socks from source or install precompiled package. For example, in Ubuntu:
sudo add-apt-repository ppa:hda-me/badvpn-tun2socks
sudo apt-get update
sudo apt-get install badvpn-tun2socks

ip tuntap add dev tun1 mode tun user nobody
ifconfig tun1 up 10.0.0.1/24

# --netif-ipaddr 10.0.0.2 is not a typo.
# It specifies the IP address of the virtual router inside the TUN device,
# and must be different than the IP of the TUN interface itself.
# This command assumes you have tor up and running on 127.0.0.1:9050.
# Of course, you can use any other SOCKS proxy instead.
badvpn-tun2socks --tundev tun1 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:9050

Next, you need to decide if you want to route all traffic via proxy, or just traffic to some specific IPs or hosts. If you have such a list (or can create one with reasonable amount of effort), this is the most efficient solution.
# Here list of hosts or IPs to route through proxy is just an example.
# You need to specify your own list.
list_of_IPs_to_route_via_proxy="example.com 203.0.113.5"
for IP in $(echo $list_of_IPs_to_route_via_proxy); do
  route add $IP gw 10.0.0.2; done

If you need to route all traffic via proxy, it will be a bit more complicated. In this case I suggest to carefully read https://github.com/ambrop72/badvpn/wiki/Tun2socks. Official documentation assumes you want to use localhost:1080 as your proxy, and gives instructions how to create local SOCKS server with SSH dynamic forwarding. Most important part of the documentation:

Connect to the SSH server, passing -D localhost:1080 to the ssh
  command to enable dynamic forwarding. This will make ssh open a local
  SOCKS server which badvpn-tun2socks will use. If you use Putty, go to
  Connection->SSH->Tunnels, type 1080 in Source port, choose Dynamic and
  click Add.
All that remains is to route connections through the TUN device
  instead of the existing default gateway. This is done as follows:
Add a route to the SSH server through your existing gateway, with a lower metric than the original default route.
  If your DNS servers are in the Internet (rather than your local network), also add routes for them (like for the SSH server). This is
  needed because tun2socks does not forward UDP by default (see below).
  Add default route through the virtual router in the TUN device, with a lower metric than the original default route, but higher than
  the SSH and DNS routes.
This will make all external connections go through the TUN device,
  except for the SSH connection (else SSH would go through the TUN
  device, which would go through... SSH).
For example (assuming there are no existing default routes with metric
  <=6; otherwise remove them or change their metrics), in Linux:
route add <IP_of_SSH_server> gw <IP_of_original_gateway> metric 5 <same for DNS>
route add default gw 10.0.0.2 metric 6

The documentation also have examples for using tun2socks for UDP forwarding, how to route all traffic through Tor, how to get IPv6 support.
Answer: Of course it's possible! Check the following link:
https://code.google.com/p/badvpn/wiki/tun2socks
Comment: Please quote the essential parts of the answer from the reference link, as the answer can become invalid if the linked page changes or the target site is unreachable/permanently offline.
Answer: You can't do this, because SOCKS doesn't operate at a low enough layer – it can only proxy TCP connections, not raw IP packets. This would be required to set up routing, with or without NAT; but bridging (as in brctl) requires even more – the ability to send raw Ethernet frames.
You should look into VPNs instead – OpenVPN is fairly simple to set up.


How to flash the gapps package after installing CyanogenMod

Question: I have recently installed the CyanogenMod in my Samsung N700.
Issues now i want to install Google apps like play store, maps etc. Learning from here i have download the .zip package and it is in my sdcard now.
Issue is now i don't know how to use it, if i try to open it its says no application to handle such(zip) files.
Can anyone please guide me through this?
Answer: The Gapps zip file is in the same format as the CyanogenMod ROM, and as such needs to be installed in a similar way. However, unlike the ROM installation, Installing Gapps won't remove anything (other than currently installed Gapps, if any) from your phone.
You need to boot into your Recovery (Based on your previous question, this will be ClockWorkMod Recovery) and install that zip file in the same way you installed the ROM. Booting into recovery mode will be easier now that you have CM installed. I believe you should just be able to long-press the power button to get the reboot menu, and select "Recovery".
Edits may be helpful, but if I'm remembering CWM's process correctly, it'll be:

Install from zip
Choose file
(Find and select the gapps.zip file to install)

Also go to Advanced and clear your cache and dalvik cache afterward.
Comment: I have TWRP custom recovery instead. Does it matter?  I flash gapps the same time I flashed CyanogenMod, but gapps don't show.  Do I need to wipe the system first before reattempting (both), or can I just reattempt gapps only?
Comment: CM recovery is not suited for the task. Also, why do I need to clear dalvik cache afterwards? Will this remove my already installed app data, since I am updating CM?
Comment: @RahulParashar CWM Recovery is perfectly suited for this. TWRP is also a popular option. CM and CWM are not the same thing. The dalvik cache is only a cache; clearing it does not remove any data. You should clear it because it may still contain cache data that is incompatible with the newly installed Gapps. Whether or not your apps will be removed depends on whether you perform a Factory Reset while upgrading CyanogenMod.
Comment: Okay, I understand, good for avoiding bugs.

Also, I am saying CM(CyanogenMod) not CWM, CM is not suited to flash Open-Gapps. I have encoutered errors, as in ERROR suggests to install using TWRP, after failing many times. Then, I went on and flashed CWM, after that I could install Gapps flawlessly.
Comment: @RahulParashar, you'll notice that I never suggested using CM to flash Gapps. Such a suggestion wouldn't even make sense.
Comment: Yes, That is what I am saying. Actually, we are both saying the same thing.
Comment: @RahulParashar Then why is your first comment, "CM recovery is not suited for the task."?
Comment: CM(CyanogenMod) is not suited for the task of flashing open-gapps. Isn't it correct?


Laptop wont Switch on.. Power button LED Blinks when I press power button

Question: My Laptop is Lenovo T430. Tried following steps with No luck.
Refer to my Video here.

Try charging the Battery to Full
Remove Battery and tried booting it with Power directly.
Changed the Keyboard.
Removed the Bios Battery and tried to switch on.
Removed the RAM and tried to switch On.
Answer: 1. Have you tried pressing and holding the power button?
2. Does the CPU fan turn on at all?
3. Any ideas what caused this problem?
I had a similar problem on a Toshiba laptop after water damage. I had to totally disassemble it and clean up the corrosion everywhere. I had to replace the keyboard and power button which was on a separate PCB board with media buttons.
Comment: Yeah I did. CPU fan wont turn. Still a mystery,
Answer: Looks like the issue is with the motherboard.
First, you need to check if the required +19V voltage is supplied to the MB power jack. So, you need to use multimeter to measure DC voltage between the + contact and the ground.
If it is fine and doesn't drop below when you press power button, then to need to check the other power circuits supplied from the main power source.
+19V is converted into several stand-by voltages required (+3.3, +5) to the other lower VSB voltages (+1.25, +2.5) supplied to SIO/MIO, south bridge, keyboard controller and battery charger.
If you are not familiar with digital design and electronics, you'd better pass it to the service center.
From you can you - make sure that there are no remaining of the liquids, decayed elements. May be you'll find some spots of another color on the places of the lost elements (resistors, capacitors, transistors). Clean the board with Flux-off, isopropyl alcohol or similar.


Suzuki GZ125 2003 - what size fuel line?

Question: I need to buy a new tank for my gz125 k3 and I need to get some new fuel cable for the tank to the carb. Does anyone know what size the line needs to be to fit snug?
Answer: The easiest way to be sure is to look at the hose you are replacing but it should be a 4mm inner diameter 6mm outer diameter. Suzuki P/N: 0935240703600


How do we translate a French master in English (UK)?

Question: I would like to know how the UK equivalent/translation for a French student who is BAC+5 and going to get his engineering degree. Is it under/post/graduate?
Comment: do you have any further questions on this topic?
Answer: According to Wikipedia the BAC + 5 is seen as equivalent to a Masters in Science, also known as 'MSc.' in the UK.  A Master's degree qualification is a postgraduate qualification.
A potentially useful article for you would be the Wikipedia page for National Qualifications Framework. The UK education system categorizes qualifications in 8 'levels'.  The BAC + 5 is level 7.  If you have a Masters in the UK is it assumed you completed previous study and attained at a bachelor's degree (or equivalent) so it is offered as a postgraduate degree.  Masters programs are also known as 'graduate' degrees which is an import from US English.
Comment: Please note, that that the National Qualifications Framework (NQF) was replaced by the Qualifications and Credit Framework (QCF) in 2010.  However, the article for NQF has a more helpful table in it which will be the same as QCF.  The fourth link is to a diagram describing QCF.
Answer: Whether or not a student is an undergraduate or postgraduate depends on whether they have already got a degree.  Someone working towards their first degree is an undergraduate.  Someone who already has a degree and is working towards a higher degree is a postgraduate.
I don't know if 'is BAC+5' means this person already has a degree or not but presumably you can work out the right word from the above.
Comment: _"...depends on whether they have already got a degree"_ ...from a college or university. (Non high-school)  In the U.S. at least.
Answer: For what it's worth: In America we normally talk about four "levels" of degree: associate, bachelor, master, and doctor. When you don't yet have a bachelors, you are said to be "undergraduate". An associates degree typically requires 2 years of study, and each higher level degree 2 more years over the previous.
Comment: @Adam Yes, excellent point. Common tracks are AA and done; BS and done; BS -> MS and done; BS -> MS -> PhD. Some do AA -> BS, then maybe go further or maybe not, but I think that's relatively rare.
Comment: One tag onto this is that many (most?) people who get a bachelor's degree do so without getting an associate's degree first - they complete a single four year program for the bachelor's degree.  This happens at the post-graduate level also, but getting a master's before the PhD (doctorate) is more common than getting an associate's degree before going for a bachelor's.


compiling fftw3 in android ndk

Question: hi i am new to android-ndk so far i worked with all sample applications in android-ndk,now i am trying to port fftw3 library in android, can you plz suggest me any  tutorial for this.
Thanks.
Answer: The FFTW3 build system makes use of Autotools, so that you can not use it directly with the Android NDK.
A good blog post dealing with this issue is here.
The idea is to generate a proper config.h file offline and to create Android Makefiles, which replace the missing ones normally generated by the Autotools.
To achieve a modular layout for the different native modules you might use, I'd recommend the following:
In your top jni/ directory put these two files:
Application.mk:
    APP_OPTIM        := release
    APP_ABI          := armeabi armeabi-v7a
    APP_MODULES      := fftw3

Android.mk:
    TOP_DIR := $(call my-dir)
    include $(TOP_DIR)/fftw3/project/jni/Android.mk

This way you can easily add a new module by creating a jni/new_module_name directory and then adding new_module_name to the APP_MODULES list.
Then create a new jni/fftw3 directory and put another Application.mk there:
Application.mk:
    APP_PROJECT_PATH := $(call my-dir)/project
    APP_MODULES      += fftw3
    APP_OPTIM        := release
    APP_ABI          := armeabi armeabi-v7a

Then put the original FFTW3 package under jni/fftw3/project/jni.
At this point you need to generate a config.h. You can do this by using a small shell script like this.
The last step is to create the needed Android Makefile. In jni/fftw3/project/jni put a top Android.mk:
    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)

    include $(LOCAL_PATH)/api/sources.mk
    include $(LOCAL_PATH)/dft/sources.mk
    include $(LOCAL_PATH)/dft/scalar/sources.mk
    include $(LOCAL_PATH)/dft/scalar/codelets/sources.mk
    include $(LOCAL_PATH)/kernel/sources.mk
    include $(LOCAL_PATH)/rdft/sources.mk
    include $(LOCAL_PATH)/rdft/scalar/sources.mk
    include $(LOCAL_PATH)/rdft/scalar/r2cb/sources.mk
    include $(LOCAL_PATH)/rdft/scalar/r2cf/sources.mk
    include $(LOCAL_PATH)/rdft/scalar/r2r/sources.mk
    include $(LOCAL_PATH)/reodft/sources.mk

    LOCAL_MODULE := fftw3
    LOCAL_C_INCLUDES := $(LOCAL_PATH) \
        $(LOCAL_PATH)/api \
        $(LOCAL_PATH)/dft \
        $(LOCAL_PATH)/dft/scalar \
        $(LOCAL_PATH)/dft/scalar/codelets \
        $(LOCAL_PATH)/kernel \
        $(LOCAL_PATH)/rdft \
        $(LOCAL_PATH)/rdft/scalar \
        $(LOCAL_PATH)/rdft/scalar/r2cb \
        $(LOCAL_PATH)/rdft/scalar/r2cf \
        $(LOCAL_PATH)/rdft/scalar/r2r \
        $(LOCAL_PATH)/reodft

    # Use APP_OPTIM in Application.mk
    LOCAL_CFLAGS := -g

    include $(BUILD_SHARED_LIBRARY)

Frow now on you have to create all these sources.mk files.
E.g. a typical sources.mk looks like this:
rdft/sources.mk:
    sources = buffered2.c \
              buffered.c \
              <....>
              vrank-geq1.c \
              vrank-geq1-rdft2.c

    LOCAL_SRC_FILES += $(sources:%=rdft/%)

Call the ndk-build script in the top directory of your app and you should end up with two ready-to-use FFTW3 libraries:

libs/armeabi-v7a/libfftw3.so
libs/armeabi/libfftw3.so
Comment: I tried this but it seems to map some files to the wrong place in the heirarchy - I must be doing something wrong - any ideas? I uploaded my source tree here: https://www.dropbox.com/s/7ql1miwvsq8lqyg/fftw-android.tar.gz?n=125533085
Answer: I currently solving similar problem, but without significant results.
As I can recommend use anther well tested library like JTransforms (java pretty fast) or find Badlogic KissFFT implementation (JNI, about 2 times faster, numerical unstable).
Answer: After noticing, that there's a ton of new directories in recent fftw version, containing .c and not listed in the original Android.mk, I got too lazy to write source.mk-generating script, and googled this instead:
include $(LOCAL_PATH)/api/sources.mk

Thanks to Sudhakar Fomra (sfomra at github), got my build done in few minutes.
https://github.com/sfomra/FFTW3_MOD-for-Android
Answer: The best way to compile fftw3 for Android armeabi-v7a is:
export SYSROOT="$NDK_ROOT/platforms/$TARGET/arch-arm"
export CFLAGS="-I$NDK_ROOT/platforms/$TARGET/arch-arm/usr/include --sysroot=$SYSROOT"
export CPPFLAGS="-I$NDK_ROOT/platforms/$TARGET/arch-arm/usr/include --sysroot=$SYSROOT"
export CC=$($NDK_ROOT/ndk-which gcc)
export LD=$($NDK_ROOT/ndk-which ld)
export CPP=$($NDK_ROOT/ndk-which cpp)
export CXX=$($NDK_ROOT/ndk-which g++)
export AS=$($NDK_ROOT/ndk-which as)
export AR=$($NDK_ROOT/ndk-which ar)
export RANLIB=$($NDK_ROOT/ndk-which ranlib)
./configure --host=arm-linux-androideabi --target=arm-linux-androideabi
make OS=android NDKROOT=$NDK_ROOT TARGET=android-9 ARCH=arm NDKLEVEL=9

Answer: Quite painlessly, FFTW can be built for Android with its official CMake script in http://fftw.org/fftw-3.3.8.tar.gz:
externalNativeBuild {
    cmake {
        arguments "-DANDROID_ARM_NEON=TRUE"
        arguments "-DCMAKE_BUILD_TYPE=Release"
        arguments "-DBUILD_SHARED_LIBS=OFF"
        arguments "-DBUILD_TESTS=OFF"
        arguments "-DDISABLE_FORTRAN=ON"
        arguments "-DENABLE_FLOAT=ON"
        targets "fftw3f"
    }
}

compiling fftw3 in android ndk


css Problem on positioning IE

Question: i have a problem for my layout... it should be simple but i just won't get it right. It works on firefox but not on IE .... :'(
please do not write some pages of tutorials... its an unique problem ;).
Problem: the div leftBar and rightBar should be resizing to the content. If there is a lot of text, they should have the same height (therefor i used top and bottom on an absolute positioning) the content is all right and it works just the leftBar and the rightBar won't resize... thx for responding, regards marius

Answer: you could use a background-image on the div#container to give it the appearance of both leftBar and rightBar having equal heights
The other way I can think of is to use javascript and set the heights.
Comment: i thought about that too, but its not the way it should be solved ;)
Comment: have a look at this method: http://woorkup.com/2009/10/11/really-simple-css-trick-for-equal-height-columns/

css Problem on positioning IE


How were blacks excluded from juries in the US southern states in the 1930s?

Question: As I am in the process of re-reading Harper Lee's To Kill a Mocking Bird, I did a bit of elementary research on the subject of jury selection in Alabama. I discovered that in the Scottsboro boys case (1932 to 1936) the Supreme Court eventually ruled that the absence of African Americans from the jury pool denied the defendants due process. What interests me is in what techniques were employed to exclude people of African descent.
Answer: Traditionally most municipalities in the USA select their jury pool based on their state's voter rolls. That is in fact how Alabama does it today.
This is probably chiefly for convenience sake. A state's voter registrations is about the only convenient database of "of age" residents and where they live that the state (and everyone in it) has access to. Particularly back before the computer age. However, it does have the side effect that if your voter rolls are skewed, your jury pools will be as well.
Alabama of course had very skewed voter rolls in the early 20th Century. From about 1890 to 1965, Jim Crow was the rule in the South, including Alabama. Almost no black Americans could vote.

Those who could not vote were not eligible to serve on juries and
  could not run for local offices. They effectively disappeared from
  political life, as they could not influence the state legislatures,
  and their interests were overlooked.

*emphasis mine
The typical methods used were poll taxes and literacy tests. Both tended to include grandfather clauses that gave a free pass if you were related to someone eligible to vote the year before slavery was abolished (a clever, if transparent, bit of legal trickery). In practice, both tended to be selectively applied to only black applicants. It didn't stop there though, in addition to numerous other onerous requirements, in Alabama you got "doxed" as well:

Your name was published in the local newspaper listing of those who
  had applied to register. That was to make sure that all of your
  employers, landlords, mortgage-holders, bank loan officers,
  business-suppliers, and so on, were kept informed of this important
  event. And, of course, all of the information on your application was
  quietly passed under the table to the White Citizens Council and KKK
  for appropriate action. Their job was to encourage you to withdraw
  your application — or withdraw yourself out of the county — by
  whatever means they deemed necessary.

So southern blacks were effectively living in a terrorist state.
This is of course the essential backdrop to Harper Lee's To Kill a Mockingbird.
Comment: Here's a link to an [actual Alabama literacy test](http://www.selmamovie.com/selmaliteracytest/). See how well you'd do. I failed on the 4th question. 30.6K rep here, but apparently if my skin were a few shades darker I'd not be "literate" enough to vote in 1950 Alabama.
Answer: Your statement is incorrect on two counts. First of all, it is not true that the "absence" from the pool denies due process. Secondly, the violation is not of the Due Process clause of the Constitution, it was held to be a violation of the 14th Ammendment. The violation itself occurs when potential jurors are deliberately excluded from the pool. If by chance they are not present, it is not a violation. This is what it says in a contemporary legal handbook:

While a negro charged with crime is not entitled to a negro jury or to
  a mixed jury, the federal Constitution guarantees him against any
  discrimination against the negro race in the selection of a jury by
  whom he is to be tried.

The problem was that it was a common practice in some places for jury commissioners to exclude so-called "negroes" from jury pools on the grounds that they were unfit to serve as jurors. In places where this was occurring, courts routinely overturned verdicts as violations of the 14th Ammendment.
The mechanism of this exclusion is that the jury commissioner would send summonses only to citizens in well off neighborhoods and if a black showed up accidentally the commissioner would just excuse them immediately.
Comment: "Courts routinely overturned verdicts as violations of the 14th Ammendment." No, they did not. It's only after the civil rights movement that you might say "routinely" overruled. Silent racism let those verdicts stands for decades.
Comment: Thank you very much for your answer and for correcting and elaborating on my misunderstanding (I was, after all, only quoting from Wikipedia). Since asking the question, however, I have read the links provided by @T.E.D. which seem to point out all kinds of ways in which blacks were excluded from the voting rolls, and hence jury selection. It does appear from your answer that a great deal of power was in the hands of Jury Commissioners.


Does the president get the final say on a declaration of war like he does with normal bills?

Question: Would the USA congress need the presidents signature to enact a declaration of war? Or is it different from other bills in this respect?
Comment: I wouldn't call it the "final say". Congress can over-ride the President's veto.
Comment: Wait, Congress has something to do with starting a war?
Comment: I can't think of any time in history that this issue has ever presented itself.
Answer: The United States Constitution grants Congress the authority to declare war (Article I, Section 8):

[Congress has the power] To declare War, grant Letters of Marque and Reprisal, and make Rules concerning Captures on Land and Water;

This is a normal legislative authority. There are no special rules for a declaration of war. Just like all the other powers listed in this section, it is a legislative act and requires the president's signature (or Congress to over-ride a veto) before becoming law.
Additionally, if reading the Constitution doesn't convince you, here's a picture of FDR signing the declaration of war against Germany. You can read more about this picture on the Library of Congress website.
Answer: Article I Section 7 of the Constitution contains this clause:

Every Order, Resolution, or Vote to which the Concurrence of the Senate and House of Representatives may be necessary (except on a question of Adjournment) shall be presented to the President of the United States; and before the Same shall take Effect, shall be approved by him, or being disapproved by him, shall be repassed by two thirds of the Senate and House of Representatives, according to the Rules and Limitations prescribed in the Case of a Bill.

So, it follows the same rules as an ordinary bill. The President can sign it or veto it, and Congress can override the veto.
Answer: It's not entirely explicit in the constitution, but declarations of war have been enacted as laws and signed by the president.
See United States declaration of war on Japan on Wikipedia for a photograph of Roosevelt signing Public Law 77-328, 55 STAT 795, declaring war on Japan.
Comment: It is extremely explicit in the constitution; Congress has the power to declare war, just like it has the power to establish a post office or establish tarrifs. When figuring out what congress can do, Article 1 is your friend
Answer: Although the power to declare war is exclusively held by the Congress, and does not require the president's agreement, it is also true that the president is the commander-in-chief of the military.
If he/she does not agree with the declaration he/she can simply ignore the declaration entirely, and issue no commands whatsoever to prosecute the war. That is admittedly an extreme position for him/her to take, but it is within his/her constitutional authority.
Congress would then have the option to impeach him/her (perhaps on the grounds that failing to prosecute the war gave aid and comfort to America's enemies). What comes after this is a bit far from the original question.


Writing Image to ALAssetsLibrary Results in a Different File Hash

Question: I have an application that is downloading images from a server and inserting them into the iPhone's ALAssetsLibrary so that the user can see those images in their saved album. I am trying to do a confirmation by comparing file hashes to ensure the image was downloaded successfully. I have the file hash as the file exists on the server. Once I finish writing the image to the ALAssetsLibrary, I generate a file hash on the client. I'm observing that the file hashes are different but the files appear to be the same. I'm curious as to whether or not the client is altering these images somehow that I may not know about (aspect ratio, scale, metadata, etc). Any guidance, opinions, or advice would be helpful.
Answer: The image-data itself is not altered during import into the Assets-Library. However, I observed that JPEG files get about 10KB bigger, after they have been imported into the Assets-Library. The Assets-Library seems to add a JFIF-Metadata-Dictionary to the file, if not already present.


Which suitable buffer distance to choose for a kernel density analysis to deal with edge effects?

Question: I would like to run a Kernel density analysis on point features in ArcGIS 10.2 for hotspot detection, and to do it is recommended to apply a buffer zone to the study area in order to reduce the edge effects during the kernel analysis.
I would like to know how to do to figure out the most suitable buffer distance, knowing that my study area is about 331 000 km², my output cell size will be 130 m, and  my search radius will be about 150 km (distance of the first statistically significant peak z-scores given by an incremental spatial autocorrelation analysis).
Answer: If your search radius is 150km then try that as a buffer distance. The inclusion of a buffer distance is to ensure your densities are not cut off at the boundaries so your suitable boundary will depend on where your hotspots are / how many points there are in those clusters and how dense they are. There's more explanation of kernel densities at geospatial modelling environments here:
http://www.spatialecology.com/gme/kde.htm
And an example of applying bandwidth as the buffer distance can be found in the Journal of Modern Transport:
Identification of crash hotspots using kernel density estimation and kriging methods: a comparison. Authors: Lalita Thakali, Tae J. Kwon, Liping Fu, 2015
Comment: Ok thank you very much! The second link you posted is unfortunately not working: could you give me the name of the article and its authors please? I will try to find it that way , thanks!
Comment: There you go Marie. Updated.


Making thousands of microservice/dockers with different IPs

Question: I need to simulate many connections. Currently using curl.
What is the best way to deploy thousands of such requests with different IPs using some script?
Comment: What did you try?
Comment: I don't know much about microservices and dockers. currently only one machine starting many requests but all requests are with the same IP.
Comment: Have you looked at Kubernetes?
Comment: @dwjohnston  why Kubernetes should be better compared with the other suggestions?
Comment: Could you clarify what you're trying to achieve? Is this for a load balancing/stress test?
Comment: Yes, for stress testing load balancer/server
Answer: Linux, without docker
In Linux, you can create arbitrarily many IP address for each interface. A comment in https://serverfault.com/questions/328146/max-number-virtual-ip-addresses-per-nic reports success with 2000, and hearsay of 5000 successful IPs.
So. Pick any Linux box on your intranet, which could of course be a VM, and create as many IPs on its single ethernet interface (MAC address) as you wish.
Say you're using the 10.0.0.0/8 private network, then you can execute lots of these:
ifconfig eth0:1 10.0.0.2 netmask 255.0.0.0
ifconfig eth0:2 10.0.0.3 netmask 255.0.0.0
...
ifconfig eth0:260 10.0.1.6 netmask 255.0.0.0
...

You should be able to use curl --interface eth0:3 (or maybe --interface 10.0.0.3) to use a specific source address. For wget, it's --bind-address=10.0.0.3 etc. Start the curls in the background ("&") and they will run more or less concurrently - or look for some test driver (different question) to run them for you.
This will give you lots of requests from separate IP addresses, but all conveniently running on one machine.
Docker, trivially
With docker: just make an image, as small as humanly possible, which connects to your server. You can use curl without any special options.
Then fire up your 1000 docker containers, just like you usually would. Each will automatically get an IP address on the internal docker network (172.x.0.0/16 by default).
https://stackoverflow.com/questions/21799382/is-there-a-maximum-number-of-containers-running-on-a-docker-host indicates that it is possible with hardware that is not too uncommon today; a naive 1000 docker containers used roughly 3 GB of RAM for them. That question also has some hints on options you can use to decrease the memory needs. Aside from memory, there won't be too much overhead, i.e. CPU wise it should comparable.
Docker, with special networking
docker network opens up manually created networking for you. You should be able to cobble something together (just check the individual --help pages, it's all pretty self explanatory), and combine that with the ifconfig approach explained above. This would mean that you only need one container for your curls, and start 1000's of them inside that container.
I would try to just run your 1000 containers, first, though, unless you are limited in the RAM department, for ease of use.
About the curl...
Whatever you do, don't just start a single curl in each instance, but have each runner be an endless loop of back-to-back curl calls. This way, you avoid long gaps inbetween where your individual jobs are being started and stopped; this is obviously especially important for the "1000 docker containers" variation. In the answer linked above, they note that it took them some good amount of minutes to start up those thousands of containers, so you do not want to do that over and over again.
And you might as well get rid of curl altogether and create small networking app in the language of your choice (Perl, Ruby, C, Java...) to avoid process startup overhead.
Comment: To get a better distribution in case 1, gatling could be a solution also. Beware that a single machine will hardly make more simultaneous requests than its number of core, deferring network io to the ethernet card may help a little but I doubt the 1k request will be simultaneous (probably not a problem but it worth being said I think)
Comment: @Tensibai, I assume the question is not so much about having traffic comparable to 1000 real users, but literally about testing the capability of some special program to keep track of 1000 IPs... whatever that may be good for. But I'll put in a note about doing loops instead of one-offs for the `curl` processes so it's more likely to get a lot of concurrent requests by avoid the setup overhead.
Comment: @AnoE Thanks! Just to add to the disscusion: It is both about traffic and about IPs. servers (TCP stacks) behave different when there are 1000 requests from one IP or 1000 IP each making 1 request.


Does leaving the car on use up fuel?

Question: In Pacific Drive, when I put the car in park I can exit the car without turning off the engine. Does leaving the engine turned on use up fuel if the car isn't moving?
Comment: I'm getting the feeling this is interesting for people with *real* cars, as well.
Answer: From this article:

Leaving the engine running will drain the fuel, and leaving the lights on (internal and external) will drain the battery.

This makes a lot of sense in a game where decisions like these increase the suspense and demand planning and strategy.
That is, unless you turn on Infinite Fuel in Easy Mode, of course :)

Does leaving the car on use up fuel?


How to tell if a transferred consciousness is authentic

Question: In star trek when people get on the transporter they pop out somewhere. But how do we know if they are not just clones. Is there a test that actually exist in real life that can actually tell if a transferred concusiness is genuine and not a clone?
Comment: Define _genuine_. Your consciousness has inevitably evolved, ergo, it is different, since yesterday. Given that there's a clear difference between today's and yesterday's, is yesterday's one _genuine_?
Comment: Given that we have no idea whether this is possible, and if possible, how to accomplish this. I don't see this as a well-posed question.
Comment: @RodolfoAP i should of commented a long time ago. But you know how you cant read peoples minds and see the world in there perspective. Well how can we tell that in the star trek or any other instance that you would continue to only see the world with your eyes and not stop seeing at all? I'm sorry if this doesn't clear things up this topic is very complicated.
Answer: Have a look at the page on Teletransportation paradoxes. These are best approached not having definitive final or universal answers, but as thought-experiments to explore the implications of our ideas about identity.
From a logic perspective, by the law of identity, once a version of you stops having continuity with your world-line, it becomes a different 'thing' - if a teleported version existed and the initial being continued, they would be diverging in similarity from the moment of splitting. The Ship of Theseus and the Fading Qualia thought experiments or other ways to push our ideas.
We accept substrate independence, say of programs run on different hardware, so you could shift the concept of identity from matter following a world-line to an organisational structure. I make the case in this answer, who is 'identical' becomes about who is asking, for what purposes:
What makes consciousness different for two different people?
Buddhist thought is rooted in challenging our intuitions that we have something unchanging about us. In the Buddhist view we are all enmeshed with each other. There are only causes and conditions, no essences. Hume's Bundle Theory of identity comes to a similar perspective.


XML New Version - New Features

Question: Is there a new version of XML out?
If so when was it released and what are the new features?
Comment: Wikipedia has a good summary: http://en.wikipedia.org/wiki/XML#Versions
Comment: Its surprising that this question was not closed.
Answer: New features in the basic XML specification are extremely unlikely at this point. Of course there will continue to be developments in other standards in the XML family, but XML itself is very much stable. There are 'editions' of the standard (up to Fifth Edition so far) but these are merely corrections and clarifications to the document, not new functionality.
XML 1.1 was launched some years ago but the differences between it and XML 1.0 are small and unlikely to be noticeable to the regular user. Most people still use 1.0 (either explicitly or by simply omitting an XML declaration).
Answer: You can get the latest XML 1.0 spec from http://www.w3.org/TR/xml/
You can get the latest XML 1.1 spec from http://www.w3.org/TR/xml11/
They have had had minor updates to incorporate errata, the last for 1.0 being in Nov 2008 and the last for 1.1 in Aug 2006.

XML New Version - New Features


Calculate the shadow on earth of a large orbital disk

Question: How to calculate the shadow on earth of a large orbital disk (low orbit)?
Comment: For someone who wishes to explain the mathematics, I've done the approximate calculations for half of the problem: the umbra on the Earth's surface should be ~9.25 km in diameter, assuming the curvature of the Earth is negligible (which is an assumption I really shouldn't be making.)
Answer:
It might be easier to use similar triangles.
$$\frac{Rd}{b} = \frac{Rs}{a}$$
$Rs$ is 696,000 km and $Rd$ is 5 km. $a$ is about 150,000,000 km and c is 80 km.
The the smallest triangle is used next:
$$\frac{r}{b-c} = \frac{Rs}{a}$$
Solve for r and you get
$$r = Rd - Rs \frac{c}{a} = \text{4.63 km}.$$
Extra digits are not helpful because the exact diameter of the Sun depends on how you define it and the distance from the Sun to the Earth varies by almost +/-2 percent.
$Rs/a$ is about 0.00464 and that's also the half-angle of the Sun in radians. Convert it to degrees my multiplying by 180/pi and you get 0.266 degrees, or a quarter of a degree. The full diameter of the Sun is double that, or about a half degree.
Comment: That's a different question, but things at 80 km will not stay in orbit very long due to atmospheric drag. If you'd like to explore that, please ask a separate question.
Comment: This is linear optics, which should be fine.  It would be interesting to calculate the Spot of Arago for various   $R_d$  .
Comment: I considered this, but it doesn't generalize quite as nicely. The one that breaks down first is that c is not going to stay at 80km for larger discs. It also doesn't work close to the Sun, but for this specific case this is indeed all you need.
Comment: A priori, you cannot know that $a$ is about 150 million km - for example, what if the disk had the same diameter as the Sun? Instead, $(R_d-r) : (R_s-R_d)  = c : (a-b)$ and $a-b$ is the distance from Sun to disk (so *that* is approximately 150 million km)
Comment: Thank you very much for your reply. Your information was very useful to me. They confirmed my hypothesis.

Do you think an orbit of less than 80 km could be used to place such a disk? What could be the lowest orbit, in your opinion,  low altitude circular view, on which such a disk could be placed?
Comment: To keep such a disk in orbit would be two solutions:

1. The disk has an orbital speed of about 21,000 km / hour. That is, it rotates around the Earth in about 90 minutes. Possible solution but that does not interest me.
Comment: 2. To have propellants (thermochemical, electrical, electromagnetic, ionic. Photonic) that would be the force required to keep such a disk in orbit (80 km) above a fixed point. To counteract gravitational force. And to prevent the disc from falling into orbit and its disintegration. The specific weight of such a disc could be about 10kg / m2
Answer: Playing around with a computer algebra system, the problem actually has an exact solution, but it is ugly enough that a much more simple numerical approximation is more practical.
First, we need to find the angle of the shadow cone peak.
The peak, the centre of the Sun, and the tangent point on the Sun form a triangle with a right angle. Therefore, half the peak angle can be expressed as:
$$v = \sin^{-1}\left(\frac{r_{sun}}{r_{peak}}\right)$$
We don't have $r_{peak}$, but we have the distance from the Sun to the Earth, which is very close. This can give us a first estimate for the angle.
To correct the angle, we can calculate a new $r_{peak}$:
$$r_{peak} = r_{earth-orbit} - r_{LEO} + \frac{r_{disk}}{\tan(v)}$$
Using the new $r_{peak}$ to calculate a new $v$ should converge very quickly to the new angle.
I get $v = 0.004651$
Now, we need to find how this shadow cone projects on the Earth.
To calculate the radius of the projected disk, which has its centre slightly below the surface, we simply have to scale the disk by the cone steepness and distance between the disk, $d$.
$$r_{umbra} = r_{disk} - d\tan(v)$$
Again, we don't exactly have $d$, but the orbital altitude is very close. But we can use the $r_{umbra}$ estimate we obtained to get a better $d$:
$$d = r_{LEO} - \sqrt{r_{earth}^2 - r_{umbra}^2}$$
And yet again, the values should converge very quickly.
I get $r_{umbra} = 4.628 km$
To get the radius on the curve of the Earth instead, you can calculate the central angle and multiply with the circumference of the earth, but at 4 significant figures, the result is still $4.628 km$
Comment: This appears to assume that the Sun and the disk are directly  overhead. When this is not true, which will be most of the time, the shadow will be something more like an ellipse, but, because the shadow will be further from the disk, the region of full shadow may be smaller or non-existent.
Comment: It does indeed assume that, as that's what the OP appears to assume in their diagram.
Comment: Thank you very much for your reply. Your information was very useful to me. They confirmed my hypothesis.

Do you think an orbit of less than 80 km could be used to place such a disk? What could be the lowest orbit, in your opinion,  low altitude circular view, on which such a disk could be placed?
Comment: To keep such a disk in orbit would be two solutions:

1. The disk has an orbital speed of about 21,000 km / hour. That is, it rotates around the Earth in about 90 minutes. Possible solution but that does not interest me.
Comment: 2. To have propellants (thermochemical, electrical, electromagnetic, ionic. Photonic) that would be the force required to keep such a disk in orbit (80 km) above a fixed point. To counteract gravitational force. And to prevent the disc from falling into orbit and its disintegration. The specific weight of such a disc could be about 10kg / m2
Answer: Let's see how far we get without a calculator (so possibly only approximately).
Approximating the Sun as a point source and infinitely far away and the ground as flat, the shadow of the disk is a sharp disk of diameter $10\,\text{km}$.
But the Sun is not a point source. From the top of our head, we may recall that the Sun (and the Moon) have an angular diameter of about half a degree. Converted to radians: $\frac12^\circ\cdot\frac\pi{180^\circ}\approx 0.009$. Multiply with the $80\,\text{km}$ altitude to arrive at $\approx 700\,\text{m}$ as the thickness of the penumbra annulus, which has the original disk boundary in its middle, i.e., the central shadow is $\approx 10\,\text{km}-700\,\text{m}$ wide and the penumbra to its outer edge is $\approx 10\,\text{km}+700\,\text{m}$ wide.


Dynamically add a servlet to the servletConfig

Question: I have a Java web application that uses a plugin architecture. I would like to know if anyone has a solution where by one could add a servlet, with serlvet mapping to the servletconfig while the web app is running? The idea being that a class could be added to the /WEB-INF/classes folder and be made active as a servlet without restarting the web app. By the same nature, if the user chooses to remove the "plugin" then have the code remove the class from the the servletconfig.
Answer: There is no standard Servlet API to accomplish this.
You can do this in Tomcat. In your webapp, your master servlet (the one creates others) must implements ContainerServlet so you can get hold of the Wrapper object. Once you have your class file installed, you can make following calls,
Context context = (Context) wrapper.getParent();
Wrapper newWrapper = context.createWrapper();
newWrapper.setName(name);
newWrapper.setLoadOnStartup(1);
newWrapper.setServletClass(servletClass);
context.addChild(newWrapper);
context.addServletMapping(pattern, name);

These calls create a servlet on the fly. You need to find way to persist this information. You can do this by updating web.xml or write to your own file.
Answer: Adding and removing classes to/from a running application is hard. You may want to look at JRebel for a commercial solution.
If your users don't have very long running conversations/sessions, possibly a restart of your Web app can be quick enough that they won't notice. If this will do it for you, then the problem becomes pretty easy.
Assuming you're running Tomcat, you can configure your server with reloadable=true and it will restart your app whenever you throw a new web.xml into the webapps directory. You can add new classes to the WEB-INF/classes directory and then update web.xml, that should work fine. Removing classes may be harder if those classes are in use. You may want to do a 2 step process where you first deploy a web.xml that no longer routes to a given servlet class, then wait a bit for class users to go away, and then delete the class and redeploy an updated web.xml again.
Answer: I don't think you can do that dynamically, but you might try making the servlet active or inactive using a filter that's preconfigured.  Make the filter check for a value that you can alter dynamically, in either a database or the file system, and tell it how to reroute the request if the servlet is "turned off."
I think it'd be rude to simply turn off a servlet without giving users some kind of feedback.


Apple ID's -- I have apple id's on two devices

Question: I have the same apple id on two devices can i delete one app on one device without deleting it on the other device. There are lots of apps which I would like to have and lots of apps which I wouldn't like to have. Also like games with levels etc. do you start from THAT level or from the beginning? E.G simsfreeplay I use icloud to back up this game can I download it on another device (same app) but with the same id?!
Answer: Yes, you can absolutely have multiple devices using the same Apple ID and have different apps and the same apps installed on them. What apps are installed on each device is managed by the individual device and/or by iTunes when you sync.
There are not many games or apps that allow for sync'ng across multiple devices though, so for most apps the content will be unique to each device. Hopefully the developers will catch on that many of us are using their apps on iPhones and iPads and get them to sync.