Does code allow a main-lug-only panel connected to the meter lugs?

Question: We have a single family home with 200 amp service. One main breaker inside the house.
We needed a 220v 40amp power supply outside.   Instead of running a circuit from our main breaker, he connected a Main lug only panel w/ 6 breaker spaces to the the source power within the meter can.  He pulled the meter to do this, and it IS connected on the correct side of the meter. Can the main lugs in the meter can be double tapped like this and still be within code?
Additional information:  there is no main disconnect for the main panel (or the new MLO panel) outside at the meter.  There is no shutoff breaker at the MLO panel, but I believe that is standard.
No permit was pulled but part of the terms were that all work would be done within NEC & local code.
Comment: Can you give us the model of the meter base. My home has a meter with 2 lugs and I have a similar setup but only 3 breakers.
Comment: What's protecting the wire? Nothing, right? Bad news. A feeder like that requires a breaker at the downstream end, at least, and whether that's legal depends on the wire route. Please revise to add more detail on that subject.
Comment: How did "he" connect to the lugs in the meter can without shutting off the power?
Comment: Was he a licensed electrician? Did he pull a permit? What did the inspector say?
Comment: Did you have an understanding with him that the additional power use would not cost you any money / be billed by the power company?
Comment: OK, this is deeply WTF at multiple levels here...who's your electric utility, first off?
Answer:
Can the main lugs in the meter can be double tapped like this and
  still be within code?

The short answer is NO. NEC 110.14 States: Terminals for more than one conductor ... Shall be so identified. I have never found a 200A residential 120/240V meter base that had an identified multi-tap fitting, and the utility companies I have worked with forbid it.
That being said, it is allowed to have a maximum of 6 service disconnects at the meter. So it is not unusual to put a small panel beside an existing Main and add an extra breaker and leave space for additions. All that is wrong is that there must be something like a junction box added and tap the conductors there instead of at the lug.
If you electrician balks about it you can always get the AHJ or the utility company involved and see what they have to say. At least I would contact the owner (not the electrician in the field) of the contracting company and see if they want to get them involved as a tie breaker.
Hope this helps.
Comment: Milbank makes tap lug kits (K4977-INT, K4977-EXT, K5022-INT) available for their 200A meter bases...
Comment: @ThreePhaseEel   Yes but does he have that meter base?
Answer: NO, YOU CANNOT. In plain words... A home can only have ONE switch to disconnect ALL power. Now you have a bunch of switches which would all have to be switched off in order to disconnect all power. This is a serious code violation. The fireman, which is an ordinary person, needs to be able to easily disconnect ALL power with the throw of ONE switch labeled MAIN.
Further note slightly off subject for eduation: Commercial applications may have up to six switches to disconnect ALL power AND they must be clearly labeled in ONE location on the SAME SIDE of ONE wall and no connecting wire can be longer than six feet, which will force all the switches to be very closely packed. What you describe is not legal even in a commercial situation.
Comment: This answer is substantially incorrect on the facts. "Rule of six" panels (no "main" disconnect, up to six smaller disconnects for branch circuits or sub-panels allowed) were perfectly legal for residences from roughly 1933 until the NEC 2020 (still not adopted everywhere). Likewise, none of the disconnects were required to be outdoors.
Comment: I said nothing about inside xor outside. I am not breaking out an older code book. The "Rule of six" only applies only to commercial, and that has been true for a long time. Who has normal breakers in their residential home and multiple mains? Nobody -- that's who. The question was asked because he has never seen it. Do you have multiple mains in your residence? Your neighbor, friend, cousin? As an electrician, I have expierenced to many inspections, had to many inspector conversations, and read to many ECM magazines to consider my answer incorrect. One of us lives in an non-NEC area.
Comment: I do in fact have two mains in my house. 400A/CL320 service from one outdoor meter to two side-by-side 200A QO panels in the basement. No outside shutoff. Every house in the development has the same setup (all built shortly before NEC2020).


Can I test the construction of a LINQ query without actually executing it

Question: I have heard that when testing EF, you need to use integration testing against a live DB because of the differences between the LINQ to Objects and LINQ to Entities providers.
Why can't we unit test the construction of the query without actually executing it?  I would have thought you could just attach your IQueryable to the LINQ to Entities provider somehow and confirm the SQL is generated properly (using something like ToTraceString which does not execute the actual query).
I imagine code along these lines (this query would run fine in L2O but not in L2E):
    <Test()> _
    Public Sub Query_Should_Build_Against_L2E()
        Dim testQuery = From d In myDb
                        Where d.Status = CType(Status.Ready, Integer)

        testQuery.SetQueryProvider("L2E")

        Assert.DoesNotThrow(testQuery.ToTraceString())
    End Sub

EDIT
I tried implement GertArnold's solution as follows:
Dim context As New Context("Data Source=fakedbserver;Initial Catalog=fakedb;Persist Security Info=True;")
Dim result = context.myTable.Where(Function(d) d.Status=True)

That throws a ProviderIncompatibleException with the message "An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct."  Here's the full exception chain:

System.Data.ProviderIncompatibleException : An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.
System.Data.ProviderIncompatibleException : The provider did not return a ProviderManifestToken string.
System.InvalidOperationException : This operation requires a connection to the 'master' database. Unable to create a connection to the 'master' database because the original database connection has been opened and credentials have been removed from the connection string. Supply an unopened connection.
System.Data.SqlClient.SqlException : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Comment: To be honest, I didn't even look at the specific query; `CType` may or may not be supported *at all* (I honestly don't know), but I was thinking more generally; i.e. assume an expression *can work* - that doesn't mean it *will work* on every possible back-end.
Comment: Note it isn't as simple as "L2E"; the engine is free to have different SQL dialects for different versions of a single DB (i.e. "SQL Server 2008 r2" vs "SQL Server 2008" vs "SQL Server 2005" vs "SQL Server 2000"), and EF supports more than just SQL Server. Frankly, to me it makes a lot more sense to run it as an integration test.
Comment: I personally find because of delayed execution, these "invalid expression" errors can buried very deeply inside a query and be hard to ferret out (and they manifest with many different exceptions depending on the specific case).  If I saw an fail appear in my unit tests the minute I added the invalid L2E statement, it would make spotting and repairing the problem *much* quicker.  So, I can have integration tests as well on this for total verifiability, but if possible I would like the unit tests.
Comment: @MarcGravell There's no overall provider which handles creating a "convertible" expression tree?  I assume that all the L2E providers will fail on the CType example I gave in the question above.  Are there actual differences in what subset of expressions the different L2E providers support?
Comment: fair enough; it will be interesting to know if it is possible...
Answer:
attach your IQueryable to the LINQ to Entities provider

The question is: which IQueryable? An interface in itself is nothing. Working with EF, you're dealing with classes that implement IQueryable but besides that do a lot more. In fact, they are fully equipped to cooperate with the context and the query provider that already is attached below the hood. IQueryable.IQueryProvider is a read-only property, so it is set by the factory that creates the specific IQueryable implementation.
Thus, your testQuery would be an ObjectQuery because it is taken from myDb which could not be anything else than an EF context.

Why can't we unit test the construction of the query without actually executing it?

Isn't this your actual question? In fact, I even wonder if you would want a different query provider for that. I think you would want the EF query provider that act like this, otherwise there still is no guarantee that with EF it works the same.
Anyway, you can create a context with a phony database name in it's connection string (to make sure it does not connect) and check the validity of ((ObjectQuery)testQuery).ToTraceString(). It's OK as long as you don't iterate over testQuery. I can imagine that there is some value in such a test when queries are composed in complex execution paths. (But I'd prefer to avoid that).
Comment: Do you work code-first or database-first? I did this with an ObjectContext.
Comment: The project I'm working on atm is code-first.  (I mentioned ToTraceString because I have done work with db first/model first in other projects)
Comment: What if you use a DbContext with an empty connection string? BTW you can use `testQuery.ToString()` (it's a `DbQuery`). Are you sure the query is not actually running?
Comment: I am using ToString, thanks =D.  I just tried an empty connection string, it shows me the same exception trace without the first ProviderIncompatibleException.  The line which runs the query is throwing the exception...
Comment: I can do it with a code-first context against an existing database (not created by EF), when I try the same with code-first and a database created by EF I get your exception. Propably because an effort is made to get the metadata from the database. Looks like you'd still need a valid connection string, which more or less defeats the purpose of your unit test :(
Answer: The short answer
I was able to create a mock DbContext which "connects" to the right EF provider without any actual db connections.  This guarantees the LINQ under test will actually work in a integration scenario against your real database.  It's currently only implemented for MS SQL Server, but it should be very easy to expand to other EF providers.  I've posted the full code below, I'd be very happy to hear feedback on it.
EDIT I moved the code to a GPL CodePlex project.
The long answer
After looking at GertArnold's answer and rethinking the entire problem (and extensive reflection on the sources), I came up with what I think is a viable solution.  The problem is that the default configuration for a DbContext is to:

Use the default SqlConnectionFactory to create a connection to the database requested by the nameOrConnectionString property of the DbContext constructor
Create the database if it does not exist (because it uses CreateDatabaseIfNotExists as the default context initializer)
Open a connection to the database to confirm it is accessible (using DbConnection.Open and DbConnection.State)
Query the database to confirm the requested model exists in it (using System.Data.Entity.Internal.InternalContext.QueryForModel which in turn creates a command on the active connection to query the db for the model)
Build a System.Data.Common.DbProviderServices and a System.Data.Common.DbProviderManifest object which together provide support for translating Expressions into SQL.

The first four of those steps (which require actual db connectivity) can be creating a new IDatabaseInitializer which does nothing in the InitializeDatabase method, then registering for the context type under test with Database.SetInitializer.
Step 5, on the other hand, is the reason the we need a real DbContext for selection at all.  Without the DbProviderServices and DbProviderManifest, EF would have no idea how to translate the expressions.  I was able to use reflection to get the internal SqlProviderManifest and SqlProviderServices and pass the work off to them (I can even specify which SQL server version to use by year).


Get information out of sub-lists in main list elegantly

Question: Ok, so here's my issue. I have a list composed of N sub-lists composed of M elements (floats) each. So in a general form it looks like this:
a_list = [b_list_1, b_list_2, ..., b_list_N]

with:
b_list_i = [c_float_1, c_float_2, ..., c_float_M]

For this example assume N=9 ; M=3, so the list looks like this:
a = [[1.1, 0.5, 0.7], [0.3, 1.4, 0.2], [0.6, 0.2, 1.], [1.1, 0.5, 0.3], [0.2, 1.1, 0.8], [1.1, 0.5, 1.], [1.2, 0.3, 0.6], [0.6, 0.4, 0.9], [0.6, 0.2, 0.5]]

I need to loop through this list identifying those items that share the same first two floats as the same item where the third float should be averaged before storing. This means I should check if an item was already identified as being repeated previously, so I do not identify it again as a new item.
To give a more clear idea of what I mean, this is what the output of processing list a should look like:
a_processed = [[1.1, 0.5, 0.67], [0.3, 1.4, 0.2], [0.6, 0.2, 0.75], [0.2, 1.1, 0.8], [1.2, 0.3, 0.6], [0.6, 0.4, 0.9]]

Note that the first item in this new list was identified three times in a (a[0], a[3] and a[5]) and so it was stored with its third float averaged ((0.7+0.3+1.)/3. = 0.67). The second item was not repeated in a so it was stored as is. The third item was found twice in a (a[2] and a[8]) and stored with its third float averaged ((1.+0.5)/2.=0.75). The rest of the items in the new list were not found as repeated in a so they were also stored with no modifications.
Since I know updating/modifying a list while looping through it is not recommended, I opted to use several temporary lists. This is the code I came up with:
import numpy as np

a = [[1.1, 0.5, 0.7], [0.3, 1.4, 0.2], [0.6, 0.2, 1.], [1.1, 0.5, 0.3],
     [0.2, 1.1, 0.8], [1.1, 0.5, 1.], [1.2, 0.3, 0.6], [0.6, 0.4, 0.9],
[0.6, 0.2, 0.5]]

# Final list.
a_processed = []

# Holds indexes of elements to skip.
skip_elem = []

# Loop through all items in a.
for indx, elem in enumerate(a):
    temp_average = []
    temp_average.append(elem)
    # Only process if not found previously.
    if indx not in skip_elem:
        for indx2, elem2 in enumerate(a[(indx+1):]):
            if elem[0] == elem2[0] and elem[1] == elem2[1]:
                temp_average.append(elem2)
                skip_elem.append(indx2+indx+1)

        # Store 1st and 2nd floats and averaged 3rd float.
        a_processed.append([temp_average[0][0], temp_average[0][1],
                            round(np.mean([i[2] for i in temp_average]),2)])

This code works, but I'm wondering if there might be a more elegant/pythonic way of doing this. It just looks too convoluted (Fortran-esque I'd say) as is.
Comment: This might be better on codereview.stackexchange.com.
Comment: do you need a specific order in `a_processed`? Or any order of elements will do?
Comment: Any order will do, I can rearrange them later on.
Answer: I think you can certainly make your code more concise and easier to read by using defaultdict to create a dictionary from the first two elements in each sublist to all the third items:
from collections import defaultdict
nums = defaultdict(list)
for arr in a:
    key = tuple(arr[:2]) # make the first two floats the key
    nums[key].append( arr[2] ) # append the third float for the given key

a_processed = [[k[0], k[1], sum(vals)/len(vals)] for k, vals in nums.items()]

Using this, I get the same output as you (albeit in a different order):
[[0.2, 1.1, 0.8], [1.2, 0.3, 0.6], [0.3, 1.4, 0.2], [0.6, 0.4, 0.9], [1.1, 0.5, 0.6666666666666666], [0.6, 0.2, 0.75]]

If the order of a_processed is an issue, you can use an OrderedDict, as pointed out by @DSM.
Comment: Another way to preserve the order would be to use an `OrderedDict` instead of a `defaultdict`, and use `nums.setdefault(key, []).append(arr[2])`.  Then iterating over `nums.items()` would give the key, value pairs in order of first appearance.
Answer: For comparison, here's the pandas approach.  If this is really a data processing problem behind the scenes, then you can save yourself a lot of time that way.
>>> a
[[1.1, 0.5, 0.7], [0.3, 1.4, 0.2], [0.6, 0.2, 1.0], [1.1, 0.5, 0.3], [0.2, 1.1, 0.8], [1.1, 0.5, 1.0], [1.2, 0.3, 0.6], [0.6, 0.4, 0.9], [0.6, 0.2, 0.5]]
>>> df = pd.DataFrame(a)
>>> df.groupby([0,1]).mean()
                2
0   1
0.2 1.1  0.800000
0.3 1.4  0.200000
0.6 0.2  0.750000
    0.4  0.900000
1.1 0.5  0.666667
1.2 0.3  0.600000

This problem is common enough that it's a one-liner.  You can use named columns, compute a host of other useful statistics, handle missing data, etc.
Comment: This looks amazingly simple but unfortunately I can't make use of `pandas` currently (not installed in the cluster I use) I'll definitely check this package out though. Thank you!


How can I play a system sound at lower volume in Objective-C?

Question: I am making an iOS 8 Objective-C app (deployed on my iPhone 5) and I'm using this code to play a sound through the phone from the app:
@property (assign) SystemSoundID scanSoundID;

...

- (void)someFunction {

    ...

    //Play beep sound.
    NSString *scanSoundPath = [[NSBundle mainBundle]
                               pathForResource:@"beep" ofType:@"caf"];
    NSURL *scanSoundURL = [NSURL fileURLWithPath:scanSoundPath];
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)scanSoundURL, &_scanSoundID);
    AudioServicesPlaySystemSound(self.scanSoundID);

    ...

}

This code works fine, but the beep.caf sound is quite loud. I want to play the beep sound at 50% volume (without changing the volume of the iPhone). In other words, I don't want to touch the iPhone's actual volume, I just want to play the sound with less amplitude so to speak.
How can I accomplish this (preferably with Audio Services like I'm using now)?
UPDATE
After trying to implement the answer from Louis, this code is not playing any audio (even though my phone is not on silent and my volume is turned up):
NSString *scanSoundPath = [[NSBundle mainBundle] pathForResource:@"beep"
                                                          ofType:@"caf"];
NSURL *scanSoundURL = [NSURL fileURLWithPath:scanSoundPath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:scanSoundURL
                                                               error:nil];
player.volume = 0.5;
[player play];

Comment: hmm... try implementing the AVAudioPlayers delegate methods, specifically `audioPlayerDecodeErrorDidOccur:error` and see if you're getting an error when trying to play. Idk if it will matter, but also try sticking the call to play inside of an `[NSOperationQueue mainQueue] addOperationWithBlock{}];`
Comment: nevermind.. try a breakpoint and make sure that your URL isnt nil. And check your project settings under BuildPhases and make sure that your caf file is listed under Copy Bundle Resources
Answer: Your UPDATE code creates player as a local variable which will go out of scope when the method (in which you call this code) returns.
As soon as player goes out of scope, it is released and the audio does not even get a chance to start playing.
You need to retain player somewhere:
@property AVAudioPlayer* player;

...

- (void)initializePlayer
{
    NSString *scanSoundPath = [[NSBundle mainBundle] pathForResource:@"beep"
                                                      ofType:@"caf"];
    NSURL *scanSoundURL = [NSURL fileURLWithPath:scanSoundPath];
    self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:scanSoundURL
                                                           error:nil];
    self.player.volume = 0.5;
}

Then somewhere else you'd call:
[self.player play];

Comment: Good point...wow I did this a while ago...now I think I would have caught that.
Answer: From the Multimedia Programming Guide under "Playing UI Sound Effects or Invoking Vibration Using System Sound Services":

In addition, when you use the AudioServicesPlaySystemSound function:

Sounds play at the current system audio volume, with no programmatic volume control available

So, it doesn't appear to be possible according to the Apple Docs. But the AVAudioPlayer class lets you do it via its volume property.
In your current code, all you'd have to do is add
AVAudioPlayer *newPlayer =
        [[AVAudioPlayer alloc] initWithContentsOfURL: scanSoundURL
                                               error: nil];
[newPlayer play];

Comment: Thank you Louis. Do you know if changing the `volume` property will affect the actual volume of the iPhone.
Comment: not sure :(  give it a shot and let me know though @EthanG
Answer: Objective C
Play Sound With System Volume
@interface UIViewController () {
    AVAudioPlayer *audioPlayer;
}

-(void) PlayCoinSound {
//#import <AVFoundation/AVFoundation.h>
    NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"CoinSound" ofType:@"mp3"];
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:soundPath] error: nil];
    audioPlayer.volume = 1.0;
    [audioPlayer prepareToPlay];
    [audioPlayer play];
}

Play with Full Sound
- (void)PlayWithFullVolume {
    //#import <AudioToolbox/AudioToolbox.h>
    SystemSoundID soundID;
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
    AudioServicesPlaySystemSound (soundID);

}


Is it true that there aren't any three different numbers $x,y,z$ such that $x^3+x \equiv y^3+y \equiv z^3+z \pmod p $?

Question: Let $p$ be a prime number. Is it true that there aren't any three different numbers $x,y,z$ such that $$x^3+x \equiv y^3+y \equiv z^3+z \pmod p $$
with  $x -y, y-z, z-x$, each of them cannot be divided by $p$ ?
If not, what are the conditions of $p$ so that the statement is true for prime number $p$ ?
I tried with $p=3,7$ and both of them are correct, so I think that $p \equiv 3 \pmod 4$ may satisfy the statement.
My other attempt: Assume by contradiction, there exist $x,y,z$ such that $$x^3+x \equiv y^3+y \equiv z^3+z \pmod p$$
with  $x -y, y-z, z-x$, each of them cannot be divided by $p$. Then $$x^2+xy+y^2 \equiv y^2+yz+z^2 \equiv z^2+zx+x^2 \pmod p$$
thus $$x+y+z \equiv 0 \pmod p.$$
Here I am stuck. How can I solve this problem ?
(Sorry for my English)
Comment: @WillJagy There was a mistake in my own script.  I've been wondering how you and Jyrki could have gotten results diametrically opposed to mine, but I see now that I left out a pair of parentheses!
Comment: If $-1$ is a quadratic residue modulo the odd prime $p$ say $y^2\equiv-1\pmod{p}$ then $0, y$ and $-y$ are distinct solutions to $x^3+x=0$
Comment: All computations are in GF($p$).  If $(x-a)(x-b)(x-c)=x^3+x+C,$ then $a+b+c=0,ab+ac+bc=1$ so that $a^2+ab+b^2=-1.$  It would be enough to show that $a^2+ab+b^2=-1$ has no solutions for $a\ne b, p\equiv3\pmod{4}$  Computer experiments with small primes support this hypothesis, but I don't know how to prove it.
Comment: @saulspatz Thanks. However if $p \equiv 3 (mod\ 4)$ then $-1$ is not a quadratic residue modulo $p$. How can I progress ?
Comment: I was just confirming your intuition that it can't be done unless $p\equiv3\pmod{4}$  I don't know how to prove it can be done in this case.  We want to say there's a cubic of the form $x^3+x+C$ over GF($p$) with $3$ distinct roots whenever $p\equiv3\pmod{4}$.  I'm not sure how to proceed.
Comment: @saulspatz evidently, for any odd prime $p \neq 3,7,$ there is some $c = c(p)$ such that $x^3 + x + c \equiv 0 \pmod p$ has three distinct roots. Here we can demand $0 \leq c < p.$
Comment: @WillJagy As usual, what is evident to you is not at all clear to me.  Why is it true that such a $c$ exists?  I've been trying unsuccessfully to prove it doesn't. It seems that if such a $c$ exists, then the problem is solved.  Am I misunderstanding you?
Comment: @saulspatz I was just doing numerical experiments, I have posted that as a second answer. Meanwhile, it seems Jyrki has proved the thing and currently written up part of it. I should have indicated that this was computer output, sorry
Answer: Solutions exist for all primes $p\ge5,p\neq7$.
As the OP observed, we have the Vieta relation $x+y+z=0$ as $x,y,z$ are the zeros of the cubic
$$
P(T)=T^3+T+c=(T-x)(T-y)(T-z)
$$
in the field $\Bbb{F}_p$. Here $-c=-xyz$ is the shared value of $x^3+x,y^3+y$ and $z^3+z$ (treated as elements of $\Bbb{F}_p$ turning congruences into equalities).
The relation $z=-x-y$ takes care of the quadratic term, and
we are well placed to take advantage of the degree of freedom to select $c$ any which way we wish. Let's concentrate on the linear term! Expanding $(T-x)(T-y)(T+x+y)$ tells us that
$$
(T-x)(T-y)(T+x+y)=T^3-T(x^2+xy+y^2)-xyz,
$$
so we want to be able to choose distinct elements $x,y\in\Bbb{F}_p$ such that $x^2+xy+y^2=-1$.
This is possible whenever $p>3$.
Assume first that $p\equiv1\pmod3$. In this case there is a primitive cubic root of unity $\omega\in\Bbb{F}_p$. It satisfies the equation
$$
\omega^2+\omega+1=0.
$$
And that relation gives us the factorization
$$
a^2+ab+b^2=(a-\omega b)(a-\omega^2b).
$$
So we can select any two numbers $c,d\in\Bbb{F}_p$ such that $cd=-1$. Then the linear system
$$
\left\{\begin{array}{lcl}
a-\omega b&=&c\\
a-\omega^2b&=&d
\end{array}\right.
$$
has a unique solution $(a,b)$. After all, its determinant is $\omega-\omega^2\neq0$.
Then assume that $p\equiv-1\pmod3$. In this case $\omega$ only exists in the extension field $\Bbb{F}_{p^2}$. But, in that case we are dealing with the norm map
$$
N:\Bbb{F}_{p^2}\to\Bbb{F}_p, a-b\omega\mapsto (a-b\omega)(a-b\omega^2)=a^2+ab+b^2.
$$
By elementary properties of finite fields the norm is surjective, and takes each non-zero value in $\Bbb{F}_p$ exactly $p+1$ times. In particular, there are $p+1$ pairs $(a,b)$ such that $a^2+ab+b^2=-1$.

The above argument did not concern the possibility that some of $x,y,z$ may be equal (i.e. $P(T)$ has a multiple root for the resulting $c$). If $x=y$, then $x^2+xy+y^2=3x^2$. If $-1/3$ is a quadratic residue, we need to rule out two possible values of $x$. If $x=-y-x$ then $y=-2x$, and again $3x^2=-1$. Finally, if $y=-y-x$ then $x=-2y$ we need to rule the solutions of $3y^2=-1$.
At most six pairs $(x,y)$ were ruled out. If $p>7$ then in the first case the number of pairs $(c,d)$ such that $cd=-1$ is high enough to leave some solutions. All the cases where we had repetitions among $\{x,y,-x-y\}$ lead to the presence of a square root of $-3\in\Bbb{F}_p$, so the second case of $p\equiv-1\pmod 3$ is not affected.
The claim follows.

It may be worth noting that $p=7$ fails precisely because all the solutions of $a^2+ab+b^2=-1$, namely $(a,b)\in\{(1,3),(3,1),(3,3),(4,4),(4,6),(6,4)\}$ lead to repetitions among $\{a,b,-a-b\}$. None of the six solutions of $cd=-1$ work!
Comment: I will add the details about $x,y,z$ being distinct later. Sorry about the pause. Missus needs me now.
Comment: Looks good, I put a second answer that (numerically) supports exactly your conclusion.
Comment: Sorry about delay. I had to go do some last minute shopping before the grocery store closes. I will NOT spend another day without missus' freshly baked bread.
Comment: There's a typo in the factorization.  It should say $$a^2+ab+b^2=(a-\omega b)(a-\omega^2b).$$
Comment: Thanks @saulspatz!
Answer: well, if $p > 31$ and we can express
$$ p = u^2 + uv + 8 v^2  $$
with integers, then there are three distinct solutions to $t^3 + t \equiv -1 \pmod p$
<code>     31,     47,     67,    131,    149,    173,    227,    283,    293,    349,
    379,    431,    521,    577,    607,    617,    653,    811,    839,    853,
    857,    919,    937,    971,   1031,   1063,   1117,   1187,   1213,   1237,
   1259,   1303,   1327,   1451,   1493,   1523,   1559,   1583,   1619,   1663,
   1721,   1723,   1741,   1879,   1931,   1973,   1993,   2003,   2017,   2153,
   2273,   2333,   2341,
</code>
=============================================
<code>? p = 47
%5 = 47
? factormod( x^3 + x + 1, p)
%6 =
[Mod(1, 47)*x + Mod(12, 47) 1]

[Mod(1, 47)*x + Mod(13, 47) 1]

[Mod(1, 47)*x + Mod(22, 47) 1]

? p = 67
%7 = 67
? factormod( x^3 + x + 1, p)
%8 =
[ Mod(1, 67)*x + Mod(4, 67) 1]

[ Mod(1, 67)*x + Mod(9, 67) 1]

[Mod(1, 67)*x + Mod(54, 67) 1]

? p=131
%9 = 131
? factormod( x^3 + x + 1, p)
%10 =
[ Mod(1, 131)*x + Mod(56, 131) 1]

[ Mod(1, 131)*x + Mod(80, 131) 1]

[Mod(1, 131)*x + Mod(126, 131) 1]

? p=149
%11 = 149
? factormod( x^3 + x + 1, p)
%12 =
[Mod(1, 149)*x + Mod(11, 149) 1]

[Mod(1, 149)*x + Mod(56, 149) 1]

[Mod(1, 149)*x + Mod(82, 149) 1]

?
</code>
Comment: I was expecting you to show up :-)
Comment: @Jyrki, It seems that an odd prime $p$ has three distinct roots for some $x^3 + x + c \equiv 0 \pmod p,$ with some $c = c(p),$ unless $p = 3,7.$ I think that is what is being asked... will post separate answer with illustration
Answer: well, I checked pretty high for primes $p$ such that, for some fixed $c = c(p),$ the relation $x^3 + x + c \equiv 0 \pmod p$ has three distinct roots $\pmod p.$ As far as I can tell, this always happens unless $p = 3,7$
There are some patterns behind the scenes. When $p \equiv 1 \pmod 4$ we can use $c=0.$ When Legendre symbol $(p|7)=1$ we can use $c=2.$ When $p = u^2 + uv + 8 v^2$ we can use $c=1.$ When $p = u^2 + uv + 62 v^2$ or $p = 8u^2 + 3uv + 8 v^2$ we can use $c=3.$ When  $p = 2u^2 + 2uv + 55 v^2$ we can use $c=4.$
=====================
<code>3   WOW
5  c:  0   roots:  0   2   3
7   WOW
11  c:  2   roots:  5   7   10
13  c:  0   roots:  0   5   8
17  c:  0   roots:  0   4   13
19  c:  8   roots:  3   4   12
23  c:  2   roots:  10   14   22
29  c:  0   roots:  0   12   17
31  c:  6   roots:  9   26   27
37  c:  0   roots:  0   6   31
41  c:  0   roots:  0   9   32
43  c:  2   roots:  19   25   42
47  c:  1   roots:  25   34   35
53  c:  0   roots:  0   23   30
59  c:  4   roots:  7   20   32
61  c:  0   roots:  0   11   50
67  c:  1   roots:  13   58   63
71  c:  2   roots:  32   40   70
73  c:  0   roots:  0   27   46
79  c:  2   roots:  13   67   78
83  c:  11   roots:  19   23   41
89  c:  0   roots:  0   34   55
97  c:  0   roots:  0   22   75
101  c:  0   roots:  0   10   91
103  c:  8   roots:  16   34   53
107  c:  2   roots:  49   59   106
109  c:  0   roots:  0   33   76
113  c:  0   roots:  0   15   98
127  c:  2   roots:  23   105   126
131  c:  1   roots:  5   51   75
137  c:  0   roots:  0   37   100
139  c:  4   roots:  32   48   59
149  c:  0   roots:  0   44   105
151  c:  2   roots:  70   82   150
</code>
======================
Answer: This is not true. Consider $x=0$, $y=2$, and $z=3$ mod $5$ (this is a special case of saulspatz counterexample).
Comment: Thanks. However if $p \equiv 3 (mod\ 4)$ then $-1$ is not a quadratic residue modulo $p$. What are the conditions of $p$ so that the statement is true ?
Comment: Not sure I'll make any progress on that problem, but I'll post any that I make!
Answer: If $p=n^2+1$ (such as $5,17,37\dots$), then $x=0,\ y=n,\ z=(p-n)$ will solve your equivalence with all three terms congruent to $0$.
$x^3+x=0;\ y^3+y=n(n^2+1)=np\equiv 0 \mod{p}; z^3+z=(p-n)(p^2-2np+n^2+1)=(p-n)(p^2-2np+p)=p(p-n)(p-2n+1)\equiv 0\mod{p}$
$p$ cannot be of the form $n^2+1$ if $p\equiv 3\mod{4}$.
Comment: Yes, $p$ is not of the form $n^2+1$ if $p\equiv3\pmod{4},$ but that just shows your counterexample doesn't work in that case.  It doesn't show there isn't some other counterexample.
Comment: @saulspatz  I agree. I showed a class of counterexamples, and I made plain that $p\equiv 3\mod{4}$ will not give counterexamples in that class. There may be other isolated counterexamples, or perhaps even classes of counterexamples, that my answer has not identified.


Does a monster's size have any effect on resources?

Question: Every time I kill a big monster, the game reports its size and keeps track of the smallest and largest of that species.  Do these sizes have any effect besides just a statistic?
Answer: Size has no effect on what materials are gathered from the monster, but it does have an effect on monster stats. Larger monsters deal slightly more damage and a little bit more health and the opposite is true for small monsters. Certain event quests, however, are the exception to this rule. For example, there is an Uragaan hunting quest where the Uragaan in question is about the size of a Jaggi, yet has the exact same stats of an Uragaan of normal size.
Comment: I remember that event.  It was somewhat horrifying to attack something that tiny and having it murder me.


Alerting a player that a game has started in another browser window

Question: I have a web-based game for two players. When the first player enters, he/she has to wait for a second player to enter, which may take several minutes. I noticed that people get bored waiting, and just leave the game after several minutes. So, I thought maybe I should tell them they can do something else, and the game will notify them when the second player comes in. My question is, what type of alert to use?

A Javascript "alert" popup? This will work only if the browser window is in focus. But if the user switches to a word processor (for example), the alert will not bring the browser window to focus (at least with Firefox), so the user will miss it.
A beep? This will work only if the speakers of the user are on. Also, there might be compatibility problems between browsers and operating systems.

What would you do?
Answer: In the absence of something like the Web Notifications API, this will be difficult to implement in a 'nice' way. You could modify the window title, perhaps causing it to 'flash' with a notification, which might catch the user's eye if it were shown in the browser tab or taskbar.
Thinking outside the box, could you consider sending an alert through other channels that your user is likely to be monitoring? Could you perhaps offer to send a tweet, for example?
Answer: Here is a ready-made solution for you: http://adodson.com/notification.js/ :)
It alternates the document.title - other options are not cross-browser ones.
Answer: You could animate the browser tab so that it stands out and alerts the user. An example of a site which does it is Omegle which informs users by the tab animation that a chat is ready.

An alternate option is to show an update on the browser title like how facebook or gmail do it when you have a chat or a notification

This article gives has some interesting thoughts about how facebook uses tab updates to inform users alerts

Facebook's solution to this loss of potential clicks is to get users
  to view each alert as it happens, before more can stack up. These new
  browser tab notifications aid this, drawing attention to Facebook even
  amongst a sea of open tabs. Browser tab alerts facilitate Facebook's
  evolution from a visited destination like a web page, to a utility
  frequently left open in the browser, like email. The change also
  equalizes the three alert channels even though most users get many
  more notifications than messages or friend requests.


Validating request parameter before controller

Question: I want to validate the request parameter which is just a string value. Most of the examples on the net talks about validating a domain object with custom validator. But I want to write a validator just for String value. How to achieve that?
@Controller
@RequestMapping("/base")
class MyController{

   //value needs to be validated.
   @RequestMapping("/sub")
   public String someMethod(@RequestParam String value, BindingResult result){
       if(result.hasErrors()){
          return "error";
       }

       //do operation
       return "view";

   }
}

I want to use the Validator interface that is already available in Spring, not AOP or any IF conditions
Comment: You could use AOP and intercept the method call, validate the parameter and if it's not valid modify manually the binding result or throw an exception and handle it in the controller.
Comment: I don't think I need AOP here. I want to use the Validator interface that is already available in Spring
Comment: How about creating a wrapper object over the String, and add JSR 303 annotations for validation, or creating a validator for the respective object?
Answer: Your controller cannot validate the param, because BindingResult shall follow a ModelAttribute, not a RequestParam.
So if you want to use the Spring MVC automatic validation, you should use a class containing your string as a ModelAttribute :
class MyController {
   @RequestMapping("/sub")
   public String someMethod(@ModelAttribute Params params, BindingResult result){
       if(result.hasErrors()){
          return "error";
       }

       //do operation with params.value
       return "view";

   }

    public static class Params {
        // add eventual JSR-303 annotations here
        String value;

       // getter and setter ommited for brievety
    }

}

Of course, this assumes you put a validator into the WebBinder for example through an @InitBinder annotated method of your controller.
Answer:    //value needs to be validated.
   @RequestMapping("/sub")
   public String someMethod(@RequestParam String value, BindingResult result) throws SomeException {

        if (!ValidationUtils.isValid(value)) {
            throw new SomeException("Some text");
        }

Comment: Could you please elaborate more your answer adding a little more description about the solution you provide?


Dog door in a glass french door?

Question: We'd like to put in a doggie door (22" high) into or back patio door so our dog can go out to the fenced in patio when she wants to. The door is a French door like this one, the door on the right opens, the door on the left is fixed in place:

Is there any way to put a doggie door in this style of door? We'd be ok with putting in a platform or step up to the level of the glass in the door, but is it possible (and cost effective) to have a door shop remove the bottom portion of the glass and to install some kind of bracing to support the door?
This is a Condo, and we'd rather not put the door through the wall since that requires HOA approval (and is more permanent than a french door that we could replace upon moving out). We'd also rather not replace the left door with a solid wood door since we like the light from the window.
Any other options? Depending on how costly it is to put a door into that glass french door, we've thought about putting in a sliding door and using a sliding door style pet door.
Answer: This is possible, but its not going to be cost effective unless you can do a majority of the work yourself.  The door pictured (and any door sold in the last decade) will have two layers of insulated glass.  This means that for what you want, you'll need a custom insulated panel made to fit on top of a wooden panel containing the doggie door.
There are companies that make door-glass-replacement packages for pets such as these:

From petdoors.com.
A more cost effective solution might be to use a single layer of thick glass as a replacement panel, but you would loose some insulation properties, and you'd need a wooden frame to hold it into the door (because its not as thick as the original).  Smaller pet doors are made to fit into a round hole cut into a glass door, providing a very clean install.  Larger 22" tall doors might not be an option for this method, but great for people with "cat flaps".

Last option I can think of is replacing the large panel of glass with a custom made divided-light panel made up of several small windows.  You may be able to find off-the-shelf insulated glass panels or have single pane glass cut more economically.  The doggie door would simply be framed in place of a lower glass panel.
Comment: Great answer, I'll see if I can either find multipane replacement glass, or just a multipane door to replace the fixed door.
Answer: I'm not a professional, but I think that if you cut out part of the glass in the process, it wouldn't be very possible. However, if you only cut out a section of the wood on the bottom it would work just fine.
Comment: I think cutting a big hole in the wood would compromise the structural integrity of the door.

Dog door in a glass french door?


How to disable strict MySql?

Question: I have my own portals developed using PHP and MySql. It was working well for some months. But now it throws some kind of mysql errors like "Incorrect datetime value : '' for appointment", "Set default value for" etc. Because of these I'm unable to process.
Is there any settings to overcome this issue?
Comment: Did your host (or you) upgrade your version of MYSQL to 5.7?
Comment: Can you post the exact error messages and the code that displaying the errors? Thank you
Comment: Have you recently upgraded your MySQL version to 5.7? They recently got stricter with accepting bad values by default.
Maybe have a look at the [NO_ZERO_DATE mode](https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_no_zero_in_date) setting.
Comment: If you did upgrade to 5.7 then you should read all [the upgrade notes here](https://dev.mysql.com/doc/refman/5.7/en/upgrading-from-previous-series.html)
Comment: This is the current MYSQL Server version: 5.6.31 - MySQL Community Server (GPL). I didn't upgrade also I asked the hosting provider about this. They said, so far nothing have been updated
Answer: You are using different version of PHP. Remove default value (current time stamp) of that column and set it explicitly from the application.
Comment: I've set default value as None. But it says me to set as NULL.
Comment: Yes. It's working fine. But I have many internal portals so find difficult to change in all DBs.

How to disable strict MySql?


Objective-c: presentViewController from UIView

Question: Im trying to use presentViewController inside a UIView.
http://img145.imageshack.us/img145/6334/appt.png
When I click he "+" button at the top/right, I want to replacer the tableview at the right (in the grey part of the image) by a UIViewController.
- (void)add:(id)sender
{
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"testview"];
[self presentViewController:controller animated:YES completion:NULL];
}

Of course by doing this, the whole screen is replaced..
I want something like this:
[contentView addSubview:controller];

or
[contentView presentViewController:controller animated:YES completion:NULL];

where contentView is an UIView containing the tableview
I found this addChildViewController and presentViewController but I don't think that can help me out
Thanks
EDIT:
Use ContainerView in storyboard solved my problem
Answer: You can add the controller's view as a subview of your contentView.  Be sure to keep a strong reference to the controller when you do that though.
Another approach would be to make the new view owned by the presenting controller instead of a second controller and simply hide/show views as needed.
Comment: By doing this way, I don't have the "animation" effect :/ Moreover, the controller.view is a way bigger than it mustt be ? Weird, I've put exactly the same width/heigh in interface builder. Anyway, thank you a lot :)
Comment: If you want complete control, then you may need to create a "container view controller" to be the detail view and have `controller` as its child.  In the end, there's a view hierarchy and a controller hierarchy and they don't substitute for each other well.
Comment: Try a Google search on `"container view controller" site:apple.com`.  There are some good references.
Answer: edit your statement:
[self.navigationController presentViewController:controller animated:YES completion:NULL];

try this and then let me know if it worked!
Comment: It does not work :/ by doing this the controller takes the whole screen, i just want it to take the same position that the tableview
Comment: why dont you do something like this:
[contentview addSubvie:controller];

and then presentViewController:contentview animated:YES completion:NULL];
Comment: because contentview is not a ViewController :/
Answer: I am not sure if I understand you right. From your picture I believe you are programming for an iPad, and you want to cover the whole view partly by another view. If so, you could use a UIPopoverController, which does exactly this.
Comment: I just want to replace the tableview at the right by a new view controller (at the same position with the same dimensions)
Answer: If I understand clearly. This would help you out
SomeViewController *viewController=[[SomeViewController alloc]init];

[viewController setFrame:CGRectMake(x,y,width,height)];

[self.view addsubview:viewController.view];

Sorry if Iam wrong...
Answer: A PopoverController seems to be what you need. Here is some boilerplate code:
UIPopoverController* aPopover = [[UIPopoverController alloc]
                                     initWithContentViewController:navigation];

self.aPopoverController = aPopover;

[self.aPopoverController presentPopoverFromRect:nil inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

aPopoverController is a property of the class.
@property UIPopoverController* aPopoverController;


Const std::filesystem::path reference constness is not respected, is this something I did wrong?

Question: I'm working on a file traversal project, and I want to keep track of the current item that's being examined, so I have an external filesystem::path CurrentItem value that I change on each level/step of traversal to keep up to date.
I'm using a recursive function that takes a const filesystem::path& to traverse through the files, the const path reference rather than a path itself so I can avoid the string copy overheads. I know in the scale of things, it's probably not the most heavy of operations in this program, but it's what I chose to do.
When traversing beyond the entry-depth of the loop, when I update the CurrentItem path with the loop's directory_entry's path, the function parameter path also somehow gets set. It's baffling to me especially considering that adding a watch it showed me that even the underlying wstring is marked as const, so I'm at a loss.
Bottom line, I want to know if I somehow did something wrong enough to break const, or if it's actually a bug that I just need to work around. I can just create a secondary path that I assign the input value to, and that doesn't have the same problem as the const parameter, or I can change the parameter to a plain const path, but both of these solutions reintroduce the additional unnecessary copies that I wanted to avoid.
I separated the code from my project in a completely clean environment, and it exhibits the same exact behavior.
I reproduced all external variables as they would be, minus class encapsulation. I'm running in VS19 on windows 10, tested on both 32 and 64 bit and the same happens. Here it is:
#include <iostream>
#include <filesystem>

using namespace std::filesystem;

std::error_code ec;

path StartDirectory = L"D:/Camera Import/Animals/RAW";
path CurrentItem;
bool Recursive = true;
bool DoFiles = false;
bool DoFolders = true;

void HandleFilesInDirectory(const path& thisPath);

int main()
{
    std::cout << "Hello World!\n";

    StartDirectory.make_preferred();
    CurrentItem = StartDirectory;

    if (is_directory(StartDirectory, ec))
    {
        HandleFilesInDirectory(StartDirectory);
    }

}

void HandleFilesInDirectory(const path& thisPath)
{
    for (const directory_entry& entry : directory_iterator(thisPath))
    {
        auto type = entry.status().type();

        // This assignment operation causes the const path& thisPath to be reassigned somehow,
        // despite it being const and also being unrelated to the items in the assignment
        CurrentItem = entry.path();

        if (entry.is_directory(ec))
        {
            if (Recursive)
            {
                HandleFilesInDirectory(CurrentItem);
            }

            if (DoFolders)
            {
                // Do project-specific operations
            }
        }
        else if (DoFiles && entry.is_regular_file(ec))
        {
            // Do project-specific operations
        }
    }

    CurrentItem = thisPath;

    if (!thisPath.compare(StartDirectory))
    {
        // Do project-specific operations
    }
}

Comment: Looking for a duplicate.  Short answer: your `const` reference applies to the _variable_, not the _object_.
Answer: This is what happens when you use modifiable global variables.
The object referenced by thisPath cannot be modified by the thisPath variable, but if there is another way to access that object, then it can take on different values. For example, if it is a reference to a global variable, if you modify that global variable, then the referenced object has been changed.
Of course, your HandleFilesInDirectory function calls itself with CurrentItem. This means that the recursive call to this function will be given a reference to a modifiable global variable. A global variable you then modify within the function.
const& is only a safeguard to modifications through that variable. If the object is modifiable in some other way, the const& will see those modifications.
Comment: Ahh thank you very much! I forgot to consider that I was using CurrentItem as the reference I passed in
Comment: Easily reworked now with passing the entry.path() instead and works flawlessly


How do I increase the pressure in my sprinkler system that runs off a well?

Question: I'm trying to build a sprinkler system for my large yard.  I've set up 2 zones each one with 8 heads being supplied by a 2HP well pump.
I'm using 1" pipe everywhere.
The first zone works fine and the well maintains about 70PSI; the second zone, which is about 20 yards longer than the first and also has 8 heads, works but the well pump is cycling.
I'm guessing that the problem is that with the longer line, I don't have enough pressure to push enough water through.
If I split the 2nd zone line into two with 4 heads on each line, would that work?  Each line would be shorter but I'm not sure that would make any difference.
Any advice?
Comment: How is the pump being controlled (is there a pressure switch)? How is the irrigation system controlled? Is there anything else the pump is connected to besides irrigation? Is there a pressure tank in the system, and if so, how big is it? Is the well drilled (how deep?) or dug?
Comment: the pump is attached to an 'small building' and is attached to a tank (150 gal) and a pressure switch.  I have the switch set to on at 45PSI and off at 75PSI.  I'm not sure how deep the well is.
Comment: Can you more clearly define how it is 'cycling'? How long is it on for, and how long is it off for, both when it's working "normally", and when you're experiencing the problem?
Comment: I turn on the water, the water pressure starts goes down from 75 PSI down to 45, the pump kicks on and stays on until the pressure goes back to 75 PSI at which point the the pump kicks off.
Answer: "Cycling" in a pressure system is generally when the pump is turning on and off too quickly. Pressure systems are specifically designed so that the pump runs up to its maximum pressure, then you use water from the pressure tank, until it reaches the minimum pressure, at which point the pump turns back on and runs until it reaches the maximum.
The recommended minimum run-time for a 1-2HP pump is usually 2 minutes. How you get to that is based on the flow rate of the pump, and the size of the tank.
Based on your 150gallon tank, and not knowing your flow (in gallons per minute, GPM), based on this tool here's some example flows/times:

16GPM: 3 minutes
20GPM: 2.5 minutes
24GPM: 2 minutes

As you can see, the higher the flow rate, the shorter the pump will run.
In your case, it sounds like one zone is basically matching the flow rate of the pump (you could verify this by watching the pressure gauge while it's running, it should be fairly steady). While this may reduce pump starts, if you use water elsewhere at the same time, your pressure will drop and the pump will not be able to keep the pressure as high.
Now, the flow rate the pump puts out depends on a couple things, most importantly: the pump itself (and now many stages it has), and the depth to the water level. Each submersible pump will have a chart showing the flow rates at different depths, so you'll need to find your model and the water level to figure this out. Here's an example though, using a 2HP pump I found while running at 60psi (depth to water: flow rate):

20ft: 23.9 GPM
60ft: 22.7 GPM
100ft: 21.3 GPM

At first glance, this seems fine. My guess right now is that your first zone matches the flow rate of the pump, while the second zone is simply a lower flow rate than the pump. It's no problem, things are designed to work this way.
If you really want to reduce the cycling, you can hook up a bigger or a second pressure tank. This will give you more capacity, and so the pump will run longer, but it will also stay off longer while you use water stored in the tanks.

Now, if you had fast cycling (eg, <2 minutes run time) or "rapid cycling" (a couple seconds of runtime), then that would indicate a problem with the pressure tank. Normally the tank should be pre-pressurized at 2psi below your cut-off (low) pressure point - so in your case 43psi. To check this, you'll have to turn off your pump and let the water drain out (open a tap somewhere). You can top it up with a normal air compressor.
Comment: My goal is to not have the pump cycle at all. I'm trying to reduce wear and tear on the pump and save money. :)
Answer: Thank you everyone for all the help.
Since I couldn't get my mind around how adding another line would help without increasing the size of the main pipe; I decided to read the manual for the sprinkler head and found out that I could change the nozzle sizes.
So, I replaced the nozzles with highest flow ones I could find and after 3 sprinklers, the well stayed at 70PSI and didn't cycle.
Answer: Here's a good step-by-step tutorial on how to calculate losses in an irrigation system. It's targeted toward wastewater dispersion, but the principles should hold true for regular lawn irrigation.
And here's more lookup tables for losses through pipe and fittings.
EDIT:
If you look at the values in the second reference, you'll see that reducing the flowrate greatly reduces the pressure loss per length of pipe. If you have 200 ft of pipe with eight 2.5 GPM sprinkler heads, you'll need a 20GPM flowrate initially. The pressure loss per 100 ft for that flowrate is 8.66 psi.
On the other hand, if you use two branches of 4 sprinklers each, you only need 10GPM per branch. The pressure loss per 100 ft for that flowrate is 2.40 psi.
This ignores losses due to additional fittings required for the two branches, but it should be negligible.
So in short, splitting your lines should increase your pressure at the end of the lines, but won't give you any advantage in overall flowrate.
DISCLAIMER: I've never done irrigation work before, I'm just using lookup tables - you may want to wait for someone with actual experience to answer and back me up on this one. (Or trash my answer if it's wrong.)
Comment: I'm more trying to salvage what I've done already.  Would splitting an existing line into 2 separate lines allow me to push more water
Comment: Yes, but you'll need to do some calculation of the number of gallons per min over each length of pipe to determine how much of a psi loss you'll experience.  Then you'll have to see what the requirements are for your sprinkler heads.  This requires research and math on your part, preferably before you try to change things around.  If you take the measure 0 times approach, be surprised if you only have to cut twice.
Comment: @B Mitch: You're absolutely right. Each sprinkler head will reduce the pressure by it's GPM rating at that pressure. So when calculating losses, the pressure and losses on runs of pipe between sprinkler heads will be different for each one. That's why I could only give an example 'answer' - I didn't have the sprinkler head specs or the specific layout.
Comment: It's my understanding that the problem isn't PSI at each head but that I'm not moving enough water thru the line.  Right now, everything sprays fine with good distance (about 40' radius) and I'm just trying to keep the pump from cycling.  I know I'm close since the line is only a little be longer than one that works correctly with the same number of heads.
Comment: This [article](http://www.johndeerelandscapes.com/_products/irrg_wellpump.asp) identifies excess pump flowrate as a possible cause for pump cycling. If you're running one zone at 70 psi, and your cutoff is 75 psi, this could be your problem. If your sprinklers don't need the flowrate you're putting out, then you'd build up excess pressure. Is there any grade difference between the two zones?
Comment: This is Texas so no grade difference to speak of...
Comment: I'm not running both zones at the same time...honestly I didn't think I could so I can't see how I could have a build of pressure from Zone 1.
Comment: I wasn't suggesting running both zones at once - I was pointing out that if your operating pressure was within 5 psi of cutoff for one zone, the other zone could be reaching it and causing pump cycling during sprinkler operation.
Comment: I could change the setting on the well to 80 to test that.
Comment: as a test, I was able to turn on another faucet while Zone 2 was one and prevent the pump from cycling, if the faucet was producing about 5 gals a minute.
Answer: Pressure drops 65. To 35 when zone kicks on. Replace check valve, will give you 100% at steady 65 psi. Replace mine every three years. Brass unit under 60.00 cut into line rise from ground
Comment: Hello, and welcome to Stack Exchange. Although there's good information here, it's hard to understand due to the overly abbreviated presentation. You might want to expand your answer a bit.


all site content suddenly left-justified

Question: When I edited the HTML for one page, all of the site pages were left-justified such that there's a huge space to the right. When I checked the CSS code, all div tags are positioned using 'auto'. Importantly, this happened to html/css that I didn't even edit. Here's my CSS:
/* CSS Document  - this does formatting for you*/

/* Erice Myer's Reset, which resets the browser's innate styles to a baseline */

html, body { margin: 0; padding: 0; border 0: background: transparent; font-size: 12px;}

div, span, article, aside, footer, header, hgroup, nav, section, h1, h2, h3, h4, h5, h6, p, blockquote, a, ol, ul, li, table, tr, th, td, tbody, tfoot, thead {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
background: transparent;
    }

img {margin: 0; padding; 0; border: 0; }

table, tr, th, td, tbody, tfoot, thead {
    margin: 0; padding: 0; border: 0;
    vertical-align: baseline;
    background: transparent;
    }

table { border-collapse: collapse; border-spacing: 0 }

input, select, textarea, form, fieldset {
    margin: 0; padding: 0; border 0;
    }

article, aside, dialog, figure, footer, header, hgroup, nav, section { display:block; }

h1, h2, h3, h4, h5, h6, p, li, blockquote, td, th, a, caption, em, strong, strike {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 100%;
    font-weight: normal;
    font-style: normal;
    line-height: 100%;
    text-indent: 0;
    text-decoration: none;
    text-align: left;
    color: #000;
    }

ol, ul { list-style: none; }
/* Reset ends and my style starts below */

/* Global - specify properties for the whole page*/
html    { }
body    { background-color:#666}

/* Headings - specify properties for headers*/
h1, h2, h3, h4, h5, h6, hbar1, hbar2, hbar3, hbar4, hbar5, hbar6 {font-family:Arial, Helvetica, sans-serif; }
/* Headers with gray bars */
hbar1 {font-size:24px; color:#F60; padding-bottom:10px; border-bottom:2px #CCC solid; margin-top: 15px; margin-bottom:15px;}
hbar2 {font-size:24px; color:#000; padding-bottom:10px; border-bottom:2px #CCC solid; margin-top: 15px; margin-bottom:15px;}
hbar3 {font-size:20px; color:#F60; padding-bottom:5px; border-bottom:2px #CCC solid; margin-top: 15px; margin-bottom:15px;}
hbar4 {font-size:20px; color:#000; padding-bottom:5px; border-bottom:2px #CCC solid; margin-top: 15px; margin-bottom:15px;}
hbar5 {font-size:16px; color:#F60; padding-bottom:0px; border-bottom:2px #CCC solid; margin-top: 15px; margin-bottom:15px;}
hbar6 {font-size:16px; color:#000; padding-bottom:0px; border-bottom:2px #CCC solid; margin-top: 15px; margin-bottom:15px;}
/* Headers without bars */
h1 {font-size:24px; color:#F60; padding-bottom:10px;}
h2 {font-size:24px; color:#000; padding-bottom:10px;}
h3 {font-size:20px; color:#F60; padding-bottom:5px;}
h4 {font-size:20px; color:#000; padding-bottom:5px;}
h5 {font-size:16px; color:#F60; padding-bottom:0px;}
h6 {font-size:16px; color:#000; padding-bottom:0px;}

/* Text Elements - specify properties for inner content text */
/* normal text */
p           { font-family:Arial, Helvetica, sans-serif; color:#000; font-size: 12px; line-height:150%; margin:5px 0; margin-top:15px}
p .left     { float:left;}
p .right    { float:right;}

/*anchors for links*/
a           {font-family:Arial, Helvetica, sans-serif; font-size:16px}
a:link      { color:#000; }
a:visited   { color:#000; }
a:active    { color:#000; }
a:focus     { color:#F60; }
a:hover     { color:#F60; }

a12             {font-family:Arial, Helvetica, sans-serif; font-size:12px;}
a12:link        { color:#000;}
a12:visited     { color:#666;}
a12:active      { color:#000;}
a12:focus       { color:#F60;}
a12:hover       { color:#F60;}

/* Image */
img         { }
.image_people       {float:left; margin-top:25px; margin-left:150px}

/* Containers - set size of stuff
    margin: 2 values (top,left) (top, right) (bottom, right)
    (bottom, left) going clockwise.  auto sets it to be
    centered
    float: allows things to be floated and justified
    clear: says don't allow something float up in somewhere else
    margin/padding: margin spaces outside and padding spaces inside
    */
/* Formatting for header/banner for each page */
#outer { width: 960px; margin-top:30px; margin-bottom:30px; margin-left:30px; margin-right:30px; background-color:#FFF; }
#wrapper { width: 900px; margin: 0 auto; background-color:#FFF; }
#lab_logo { margin: 30px 0px; float:left; background-color:#FFF; }
#icons { margin: 35px 0px; float:right; }
#top_nav            { clear:both; } /* below are descendent selectors for top nav */
#top_nav ul         { border-top:2px #000 solid; border-bottom:2px #000 solid; margin:10px 0; padding:5px 0;}
#top_nav ul li      { display:inline; }
#top_nav ul li a    { padding:0 10px;   }
#banner { margin-bottom:-10px; }

/* Formatting for top */
#content_top                { margin: 30px 0px; width:900px;    float:left; }
#content_top p              { } /* paragraph style */
#content_top a              { line-height:150%;  margin-top:15px} /* anchor link style */
#content_top a:link         { color:#000; font-size:12px; }
#content_top a:visited      { color:#000; font-size:12px; }
#content_top a:active       { color:#000; font-size:12px; }
#content_top a:focus        { color:#F60; font-size:12px; }
#content_top a:hover        { color:#F60; font-size:12px; }
#content ul li              { margin-left: 30px;}
#content_top h1             { font-size:24px; color:#F60; }
#content_top h2             { font-size:24px; color:#000; }
#content_top h3             { font-size:20px; color:#F60; }
#content_top h4             { font-size:20px; color:#000; }
#content_top h5             { font-size:16px; color:#F60; }
#content_top h6             { font-size:16px; color:#000; }
#content_top hbar1      {font-size:24px; color:#F60; }
#content_top hbar2      {font-size:24px; color:#000; }
#content_top hbar3      {font-size:20px; color:#F60; }
#content_top hbar4      {font-size:20px; color:#000; }
#content_top hbar3      {font-size:16px; color:#F60; }
#content_top hbar4      {font-size:16px; color:#000; }

/* Formatting for middle left justified*/
#content                { margin: 30px 0 ; width:900px; float:left; }
#content p              { } /* paragraph style */
#content p_right        {float:left}
#content a              { float:left} /* anchor link style */
#content a:link         { color:#000; font-size:24px; margin-top:120px; margin-left:50px}
#content a:visited      { color:#000; font-size:24px; }
#content a:active       { color:#000; font-size:24px; }
#content a:focus        { color:#F60; font-size:24px; }
#content a:hover        { color:#F60; font-size:24px; }
#content h1             { font-size:24px; color:#F60; }
#content h2             { font-size:24px; color:#000; }
#content h3             { font-size:20px; color:#F60; }
#content h4             { font-size:20px; color:#000; }
#content h5             { font-size:16px; color:#F60; }
#content h6             { font-size:16px; color:#000; }
#content hbar1      {font-size:24px; color:#F60; }
#content hbar2      {font-size:24px; color:#000; }
#content hbar3      {font-size:20px; color:#F60; }
#content hbar4      {font-size:20px; color:#000; }
#content hbar3      {font-size:16px; color:#F60; }
#content hbar4      {font-size:16px; color:#000; }

/* Formatting for bottom */
#content_bottom                 { margin: 30px 0 ; width:900px; float:left; }
#content_bottom p               { } /* paragraph style */
#content_bottom a               { } /* anchor link style */
#content_bottom a:link          { color:#000; font-size:12px; }
#content_bottom a:visited       { color:#000; font-size:12px; }
#content_bottom a:active        { color:#000; font-size:12px; }
#content_bottom a:focus     { color:#F60; font-size:12px; }
#content_bottom a:hover     { color:#F60; font-size:12px; }
#content_bottom h1          { font-size:24px; color:#F60; }
#content_bottom h2          { font-size:24px; color:#000; }
#content_bottom h3          { font-size:20px; color:#F60; }
#content_bottom h4          { font-size:20px; color:#000; }
#content_bottom h5          { font-size:16px; color:#F60; }
#content_bottom h6          { font-size:16px; color:#000; }
#content_bottom hbar1       {font-size:24px; color:#F60; }
#content_bottom hbar2       {font-size:24px; color:#000; }
#content_bottom hbar3       {font-size:20px; color:#F60; }
#content_bottom hbar4       {font-size:20px; color:#000; }
#content_bottom hbar3       {font-size:16px; color:#F60; }
#content_bottom hbar4       {font-size:16px; color:#000; }

/* Formatting for bottom */
#footer {clear: both; margin:30px 0; margin-top: 30px; margin-bottom: 10px; padding-top:10px; padding-bottom:10px; border-top: 2px #000 solid; border-top: 2px #000 solid; background-color:#FFF}
#footer p { text-align:center; }
/* Micellaneous */
.date       {color:#F60; margin-bottom:1px; margin-top:15px}

REVISION: Please go here to access HTML as well: https://jsfiddle.net/9m4umcrc/
Comment: What does your html look like?  Can you add a fiddle that demomstrates the problem?
Comment: Use your developer tools in the browser, it will tell you exactly what CSS rules are being applied.
Comment: Welcome to Stack Overflow, Krista. Unfortunately, we need to see the HTML as well, otherwise we can only provide pure speculation. Without the HTML added to your question, it risks being closed as Off-Topic with the reason "Questions asking to solve a problem must include enough code to verify and reproduce the problem".
Comment: Keep an eye out for missing HTML tag (maybe closing tag).
Comment: Is the problem that the white area isn't centered in the grey area?
Answer: I am not sure if that is a typo or not. But by any chance while you were fiddling with the css did u happen to change this line ?
html, body { margin: 0; padding: 0; border 0: background: transparent; font-size: 12px;}

because if you look closely, the part where it says
 border 0: background: transparent;
 seems wrong it should be border: 0; background: transparent;
Hope this helps
Comment: Thanks for noticing that! I'm sure that it's useful to correct, but it doesn't seem to fix my problem...
Answer: The outer div is set to a margin of 30px.  Perhaps you needed this on another page and changing it changed the layout of this page.
https://jsfiddle.net/9m4umcrc/2/
Change:
#outer { width: 960px; margin-top:30px; margin-bottom:30px; margin-left:30px; margin-right:30px; background-color:#FFF; }

To:
#outer { width: 960px; margin:30px auto; background-color:#FFF; }

But, I suspect you'll have issues on other pages if you do this, so check your shared css.
Comment: Thank you! I appreciate your patience with my naïveté. That was a workable solution.


Gnuplot: Using a string variable to define columns

Question: For various reasons it seems that the easiest way to perform a certain plot is for me to store the column numbers I need in a variable, and then perform a plot command calling that variable.
Is this even possible?
I want to achieve something like:
plot '< paste '.filesString.'' u 1:(columnsString)

Also, the variable 'columnsString' will have a value like
(\$2*\$5+\$(6*2-4)*\$(6*2-1))

for instance, so it needs to be able to evaluate all the (6*2-4) style sums that are in the string. I want to emphasize that this question is only regarding the evaluation of the 'columnsString', the 'filesString' variable is working fine. How can I manage this?
Answer: For this you can use set macro. With this setting, you can use a string variable columnString, and put its content somewhere in a command, before this is evaluated:
set macros
columnString = 'column(2)*column(5) + column(6*2-4)*column(6*2-1)'
plot '< paste '.filesString using 1:(@columnString)

I used column() instead of the shorthand $.. to prevent possible problems with escaping (seems like you are calling this from some script).


Change InlineShape (image) shadow color

Question: I am developing a Word AddIn and want to set the shadow color of an image with C#. The shadow remains black and I do not know how to change the shadow color.
My code:
ShadowFormat shadow = Range.InlineShape[1].Shadow;

shadow.ForeColor.RGB = Color.FromArgb(230, 50, 15).ToArgb(); // not working !!
shadow.Type = Microsoft.Office.Core.MsoShadowType.msoShadow9;
shadow.Style = Microsoft.Office.Core.MsoShadowStyle.msoShadowStyleOuterShadow;
shadow.Transparency = 0.0f;

Does anybody know how to change the shadow color?
Comment: I just tried with VBA and it works for me. I did not use `FromArgb` though but the `WdColor` enumeration, e.g. `inl.Shadow.ForeColor = WdColor.wdColorBrightGreen` - that worked just fine.
Comment: but `ForeColor` is read only
Comment: I see. OK, try this then: `.Shadow.ForeColor.SetCMYK(0,78,93,10);`
These CMYK values correspond to your RGB, courtesy of https://www.rapidtables.com/convert/color/rgb-to-cmyk.html
Comment: I tried but got `System.NotImplementedException`
Answer: Interop seems to be rather tricky on this side. Both set_Ink and SetCMYK throw NotImplementedException.
I found that this works though:
shadow.ForeColor.RGB = Word.XlRgbColor.xlAquamarine.GetHashCode();

Comment: Sadly it doesn't work for me. I have still just a black shadow.
Comment: Move it to after `MsoShadowType` then. Best: move it to the end of your shadow manipulation. My shadow color did change just fine.

Change InlineShape (image) shadow color


Role of gl.vertexAttrib

Question: I'm re-learning WebGL, and I stumbled upon gl.vertexAttribPointer and gl.vertexAttrib. To my knowledge, gl.vertexAttribPointer tells the GPU how the data in the currently binded buffer relates to the vertex attributes. But, I'm confused on what gl.vertexAttrib does. It seems like it also sends data to the GPU, but without the use of a buffer. Can anybody explain it's role to me?
Comment: See [What is glVertexAttrib (vs. glVertexAttribPointer) used for?](https://stackoverflow.com/questions/7718976/what-is-glvertexattrib-versus-glvertexattribpointer-used-for#7719060). Essentially, they're the same thing, but `glVertexAttrib` is for the older immediate mode.
Comment: Thanks for the response! I think I understand the difference now. One sets a constant value, and the other links the values to a buffer.
Answer: gl.vertexAttribPointer is used when different vertices should have different values, and gl.vertexAttrib is used when all vertices should have the same values, and you don't want to use a special shader with a uniform.

Role of gl.vertexAttrib


Perl, (easier) access to hash variables

Question: I have created a subfunction that returns a reference to a hash of attributes containing 7-8 variables. Whenever I want to access an element I either redefine it my $n_players = $ref_attr->{'n_players'} or I call it directly $ref_attr->{'n_players'}. I would prefer to use all the variables redefined (the first case) however this takes 7-8 lines of initializations and clutters my code up.
Is there a module (that I can't seem to find) or a nice method of exporting the hash keys for use as variables?
Answer: You can use hash slices to reduce the repetition involved in getting several entries from a hash.  You can use this when initializing your copies, for example (assuming you also have a n_teams entry):
my ($n_players, $n_teams) = @$ref_attr{qw( n_players n_teams )};

As Eric Strom suggested, you can also use indentation to help ensure you have the keys in the right order:
my ($n_players, $n_teams) = @$ref_attr{
 qw( n_players   n_teams)
};

As the others have said, it's possible to manipulate the symbol table to create a variable corresponding to each key, but it's not a good idea.
Answer: You can do this easily with references and hash slices:
sub takes_hashref {
    my $hashref = shift;

    my ($one, $two, $three, $four, $five) = \@$hashref{
      qw(one   two   three   four   five)
    };

    print "one: $$one, two: $$two, three: $$three, ",
          "four: $$four, five: $$five\n";

    $_++ for $$one, $$three, $$five;
}

my %hash = qw(one 1 two 2 three 3 four 4 five 5);

takes_hashref \%hash; # one: 1, two: 2, three: 3, four: 4, five: 5
takes_hashref \%hash; # one: 2, two: 2, three: 4, four: 4, five: 6
takes_hashref \%hash; # one: 3, two: 2, three: 5, four: 4, five: 7

The @$hashref{qw(x y z)} is a hash slice, which returns a list of the values.  Prepending \ takes a reference to each value and returns the list of references.  This is then assigned to your lexical variables.  When you use each variable, double the sigil to dereference it: $$var.  Since these variables contain references to the hash fields, you can assign to them: $$var = 'new val', and the assignment will change the original hash.  If you don't care about changes to the variables propagating back to the hash, you can omit the \ on the hash slice, and the double sigil on all the variables.
If you just want to create a shorter alias to work with, you can localize %_ in your sub:
sub takes_hashref2 {
    my $hashref = shift;

    local *_ = \%$hashref;

    print "one: $_{one}, two: $_{two}, three: $_{three}, ",
          "four: $_{four}, five: $_{five}\n";

    $_++ for @_{qw(one three five)};
}

my %hash = qw(one 1 two 2 three 3 four 4 five 5);

takes_hashref2 \%hash; # one: 1, two: 2, three: 3, four: 4, five: 5
takes_hashref2 \%hash; # one: 2, two: 2, three: 4, four: 4, five: 6
takes_hashref2 \%hash; # one: 3, two: 2, three: 5, four: 4, five: 7

The line local *_ = \%$hashref aliases %_ to the hash in $hashref.  The \% portion is not necessary, but will throw an error if the value in $hashref is not a hash.  Its just a shorter way of writing:
die 'not a hash' unless ref $hashref eq 'HASH';
local *_ = $hashref;

And you can write it in one line as:
local *_ = \%{shift @_};

Answer: Don't. Either copy them explicitly (your first option), or just use the hash (your second option). That is so much clearer in the long run.
...
but if you really want to, the hash %:: is your current package variable hash (yes, perl internals). You can play with it.
perl -e'print %::';

Answer: I second Harmen's suggestion (don't), but in case you want it badly:
my %vars = ( a => 1, b => 2 );

while (my ($k,$v) = each %vars) {
    $::{$k} = \$v;
}

print "a=$a, b=$b\n";

Comment: for `$a` and `$b` you are ok, but for other names, you will need them predeclared with `our ($n_players, $score, ...);` to keep `use strict;` happy
Comment: @Eric: good catch, I didn't realize how lucky I was in my choice of example variable names! (To those who don't understand what's going on: `$a` and `$b` are special global variables; the purpose they are made so is to write sorting functions, see `perldoc -f sort`)
Answer: Another option would be to create a class for your collection of data and have the subfunction return an instance (object) of that class instead of a plain hashref.  You would then access the values as $returned_object->n_players.  In this particular case, it doesn't really buy you much in terms of saved typing or cleaner appearance vs. $ref_attr->{n_players}, but going OOP opens up a lot of possibilities (e.g., read-only or calculated attributes) which may or may not prove useful in the future as your program continues to evolve.

Perl, (easier) access to hash variables


SAS Proc REPORT: How to hide/eliminate repeated values for multiple columns

Question: <code>proc report data=DATA nowd headline out=test2
    style(summary)=[color=cx3e3d73 backgroundcolor=cxaeadd9
    Fontfamily=helvetica Fontsize=3 textalign=r];
    column Company_code pid gl Balance Descr Amt Value difference;
    define company_code/group 'Company Code';
    define PID/group;
    define gl/display 'GL Code';
    define balance/analysis sum FORMAT=DOLLAR20. 'Blalance';
    define descr/ display 'Description';
    define amt/analysis max FORMAT=DOLLAR20.2;
    define value/analysis max FORMAT=DOLLAR20.2 'Market Value';
    define difference/ analysis max FORMAT=DOLLAR20.2 'Difference';
    break after PID/summarize OL skip;
    title 'TEST';
    compute after PID;
    line ' ';
    endcomp;
run;
</code>
This is the code have, the results report in columns Amt, value and difference have repeaded value.So basically, I only need the value at the header, but I calculated the header by the values abpve it. I don't if there's a way for me to hide them. Like in the image.
this is the partial results report, I don't need the values above the header, how can I hide them?
Comment: Please add some sample data to the question, be sure to include both cases of company_code/PID having one detail row and multiple detail rows.
Answer: You are coding Proc REPORT to do a mix of detail and summary.   From Cynthia Zender post on SAS Community

The bottom line is that PROC REPORT does not allow you to delete report rows. If report is doing a detail report, with summary lines, you can either have summary lines or not --- but you cannot delete the detail lines and only show the summary lines. To collapse the detail lines, you would move into the world of summary report, but given your data, you are generating a detail report that contains summary lines.

Cynthia is a SAS author and has taught and presented numerous times on REPORT topics


AST from PDB (e.g. via DIA)

Question: I'm currently using the DIA SDK to get some very useful information from a PDB file... Now, the basic question is: how deep can I go with that? The optimum would be to able to get everything right down to the abstract syntax tree... Is that even remotely possible? If not, how far can I go using the analysis of debug data?
Answer: DIA SDK gives you access only to the debug information available in the PDB through the COM interface.  To give you a general idea, this is similar to whatever available to the visual studio debugger (symbols, line numbers, etc).  That means, in general, if the debugger appears to know about something, then that information should be available through the DIA SDK.  For the specific details, you need to refer to the online documentation in msdn.
To be specific, the abstract syntax tree intenal to Visual Studio is NOT available through any api - not just DIA SDK.  Even local variable type symbols cannot be enumerated through the DIA SDK.
Getting a List of Symbols Used by My VC++ Code

AST from PDB (e.g. via DIA)


Miragejs: Unable to load the ionic icons - data:image/svg+xml

Question: Getting below error in the browser console and the icons are not getting rendered.
Object { description: "Mirage: undefined", fileName: "http://localhost:8100/js/chunk-vendors.js line 2021 > eval", lineNumber: 806,
message: "Mirage: Your app tried to GET 'data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><title>Person</title><path d='M332.64 64.58C313.18 43.57 286 32 256 32c-30.16 0-57.43 11.5-76.8 32.38-19.58 21.11-29.12 49.8-26.88 80.78C156.76 206.28 203.27 256 256 256s99.16-49.71 103.67-110.82c2.27-30.7-7.33-59.33-27.03-80.6zM432 480H80a31 31 0 01-24.2-11.13c-6.5-7.77-9.12-18.38-7.18-29.11C57.06 392.94 83.4 353.61 124.8 326c36.78-24.51 83.37-38 131.2-38s94.42 13.5 131.2 38c41.4 27.6 67.74 66.93 76.18 113.75 1.94 10.73-.68 21.34-7.18 29.11A31 31 0 01432 480z'/></svg>',
but there was no route defined to handle this request.
Define a route for this endpoint in your routes() config.
Did you forget to define a namespace?", name: "Error", number: undefined, stack: "Mirage: MirageError@webpack-internal:///.

Tried to add this.passthrough(); and combination of it, couldn't help any of those. It's working for API calls but not for this particular case, I meant the icons not getting rendered.
How can we ignore/passthrough the requests for data:image/svg+xml;utf8,...?
Comment: Please let me know if my comment solve your issue and mark it as the solution :)
Answer: I was getting the same issue. You can solve that error if you add this configuration to allow loading base64 images like svgs:
new Server({
  routes() {

    this.pretender.get('data:image/*', this.pretender.passthrough);
  }
});

Hope this works for you too.
Comment: Thank you for this! I ran into the same issue with the "system" icons from [Shoelace](https://shoelace.style/components/icon/) which use embedded SVG data URLs as well.


Buchones with more UNIDAD action

Question: Which Buchons provide more missions where you'd have to deal with UNIDAD, rather than the cartel ?
I'm replaying the game and would like to play against UNIDAD more, rather than the Cartel.
Answer: There was only one Buchone for either LaPlaga or Ramon Feliz that was pure UNIDAD. The rest was all Cartel.
What gave me what I was looking for and was quite a lot more difficult, was the Fallen Ghosts DLC. Almost entirely UNIDAD and harder

Buchones with more UNIDAD action


An explanation as to why U equals the indiscrete topology on A.

Question: Let $A\subset X$, and assume that $X$ has the indiscrete topology. If $U$ is the induced subspace topology on $A$, explain why $U$ is equal to the indiscrete topology on $A$.
So far I understand that the indiscrete topology has the fewest open sets: the empty set and the set itself. So i am assuming that i have to show that $U$ has these properties.
Also, considering the definition of subspace topology, wouldnt the set $U$ have the same topological properties as the set $X$, since $A\subset X$ and $U$ is induced on $A$.
Am I on the right track?
Answer: By definition, a set $V\subset A$ is open in the induced topology if there exists a set $W$ which is open in $X$ such that $V=A\cap W$. Now, the only open sets in $X$ in your case are $X$ itself and the empty set. So what are the open sets in $A$?
Answer: $U$ just contains the subsets of $A$ of the form $A \cap V$ where $V$ is an open set of $X$. Now the proof is easy.


Paradox: Is the derivative of this function continuous at $x=0$?

Question: \begin{equation}
h(x)=
\begin{cases}
x^2 \sin(\frac{1}{x})&\text{ if } x\neq 0\\
0&\text{ if } x=0
\end{cases}
\end{equation}
Is the derivative of $h(x)$ continuous at $x = 0$?
How about the derivative of $k(x) = xh(x)$?

When I tried to differentiate it directly, the $\cos(1/x)$ in the result suggests that the limit of $h'(x)$ when $x\rightarrow 0$ does not exist.
However, when I use the definition to calculate the derivative, it shows that the derivative is $0$ when $x\rightarrow0$.
Which one is correct?
Comment: This means that the function is differentiable but not continuous differentiable.
Answer: Both are. For $x \ne 0$, we have
$$ h'(x) = 2x \sin\frac 1x - \cos \frac 1x $$
so $\lim_{x\to0} h'(x)$ does not exist. On the other hand
$$ \lim_{x\to 0}\frac{h(x) - h(0)}x = \lim_{x\to 0 } x\sin \frac 1x = 0 $$
that is $h'(0) = 0$. So $h$ is differentiable with
$$ h'(x) = \begin{cases} 2x \sin \frac 1x - \cos \frac 1x, & x \ne 0\\ 0 & x =0 \end{cases}
 $$
which is not continuous at $0$.
Comment: Thanks for clarifying concepts


What tools and techniques are required to bend wood?

Question: I am trying to achieve this curved wood look as pictured below. I am interested in knowing what tools I need or if I need a particular kind of wood. (I am referring to the white curved section)
Comment: for the white painted parts, vinyl trim has a useful lack of stiffness.
Comment: it isn't; it's cut with a curve. the individual pieces are straight.
Comment: it's often just segmented (multiple pieces) and glued
Comment: Thank you ratchet freak. How is each piece bent to achieve the curved look?
Comment: Gotcha. So what would you recommend using to cut it? Jigsaw? Also, wouldn't it have to be a pretty thick piece of wood? I doubt you can use a piece of 1x8 pine board
Comment: If you take this approach,  remember that the shape can be built up in layers
Comment: Jigsaw would work; bandsaw might do a cleaner job...
Comment: @Ecnerwal, We have used a lot of PVC trim to make bends in trim, much easier that ripping and planing 1/8" strips and cold bending them with glue between the layers, done that too. With painted material, even cold bending gets simpler.
Comment: @ratchet freak, stack laminating is truly a lot of work, needs a band saw, and some good finishing skills for curves. If the band saw marks are not removed so the surface still has a fair curve, the finished surface could look rippled. this technique would be good for the experienced hand, not so for the beginner.
Answer: That is a very expensive podium, probably has a cost in the 20K range.  You can do laminated wood and then cut into the curve (very expensive as it takes a large amount of high quality wood) or you can try some cheaper options using plywood.
If you only need to do a slight curve, thin plywood has a lot of flex in it.  Just nail/screw it onto a frame.  If you need a tighter curve than what the plywood will allow there are a couple of options.  If only one face will show, you can in essence thin the plywood further by using kerfs.  Look up a guide on google and find one you are comfortable with.  Another option is using steam to soften the glue in the plywood which then will allow a tighter bend.
Comment: That's a very good idea. I never thought of that. Thanks for the helpful info. I have tried to think of something for weeks. The plywood seems like it is the best option. A co-worker of mine suggested synboard ("PVC board") since it is flexible, but this option seems more structural
Comment: @diceless Is "kefs" a typo for "kerfs"?  I would definitively use a kerf bending/cutting technique for this with a miter saw or table saw.
Comment: @MaximeMorin - thank you, just fixed the typo.
Comment: You're going to have problems cutting kerfs with a miter saw. A table saw, radial arm saw, or circular saw would work though.
Answer: There's a fair amount of detail work there, but I don't see anything hugely difficult.
Curves: others have mentioned the standard approaches, eithr build up a blank from segments and then cut to shape or use wood-bending techniques. Correction yo my first thought:  flat painted ring with bent/stained/varnished molding would achieve most of the effect at less cost. The columns are stacked blocks at bottom and top  with an octagonal "barrel" glue-up between them, 22.5 degree miters, pared round and with coves cut into appropriate pieces.
Plus the platform and lectern surface and similar details...
Making it look good will take care and patience and some skill and time. At least it's mostly painted; paint can hide many sins.
Comment: What would be the best way to bend the wood properly?
Comment: I'd probably go with bending plywood, with appropriate supports behind it since it isn't structural.
Comment: Thanks for the help. I've done a few podiums, but nothing as involved as this. Also would you recommend a jigsaw or a band saw to cut the rounded area above the white section?
Comment: @JamesAlexander - Personally I would use a jigsaw because of the size of the material I would have to work with.  Unless you have a bandsaw with a large work area you will probably find it easier to move the saw than the material.
Answer: I don't know where you live, but in large areas there will be a plywood supplier and he almost certainly has pre-kerfed MDF and such.
Answer: When you set out to make curved sections by bending thin flexible material (whether that be plywood or kerf cut solid wood) it is almost essential that you pre-make a form to bend around and allow for clamping of the material. This form can be made using low cost 1/2 inch plywood cut in the flat with the edge fitted to the inside dimension of the target piece.
Multiple patterns are cut all the same shape/size and stacked and fastened to low cost 2x4 lumber sandwiched in between the layers. The 2x4 lumber is kept in from the edge so it does not need to be contoured. Create the stack thickness up toward the width of your curved piece.
Then you can glue up layers of the flexible material one by one as they are fitted and clamped to the form.
If you build up a reasonable thickness of the curved pieces that go around the podium top (or I see one at the base too) you do not need to make them all in one piece. Multiple parts can be joined end to end. One joinery scheme could even use counter top clamp bolt assemblies to cinch the parts together although that would work far better in laminated plywood layers than it would with kerf cut layers.
Comment: Tage Frid's [veneer book](http://www.amazon.com/Tage-Frid-Teaches-Woodworking-Book/dp/0918804116/ref=la_B000APR1UM_1_3?s=books&ie=UTF8&qid=1424792516&sr=1-3) is a great resource too:


Why do we consider the third quadrant to decide the sign of sin$(180^° + \theta)$?

Question: sin$(300^°)$ $=$ sin$(180^°+120^°)$ $=$ – sin$(120^°)$

In the above example, we have given a negative sign as it is of the form sin$(180^° + \theta)$ and it lies in the third quadrant where sin is negative. So we write -sin$(\theta)$. But the angle 180° + 120° lies in the fourth quadrant. So why are we considering the third quadrant to decide the sign? Shouldn't we consider the fourth quadrant?
Comment: Welcome to Maths SX! Probably some *lapsus calami*.
Comment: Who told you to consider the third quadrant? I never heard of such a thing.
Comment: @Bernard Where?
Comment: When they wrote  'third quadrant'. We all commit lapsus from time to time.
Comment: @Bernard they? — What do you mean by "they"? That reference to the third quadrant is not a lapsus.
Comment: Maybe. I suppose you're quoting some text. I meant a lapsus from those who wrote the text. Anyway, it should be better formulated as 'it lies on the lower semi-unit circle, where the sine is negative', in my opinion
Answer: One of the identities that holds for the sine function is
$$\sin(180° + x) = -\sin(x)$$
which does not require to consider quadrants or anything like that to be used!
Comment: This doesn't help. I know that I can prove it by using sin$(A+B)$. My point was specifically about the quadrants. As sin$(180^° + \theta)$ = $-$sin$(\theta)$, the negative sign comes because $180^° + \theta$ (even if the $\theta$ is not lesser than $90^°$) lies in the third quadrant where sin is negative.
Comment: Well, no. $\sin(200°+180°)=\sin(380°)=\sin(20°)>0$, and yet the formula still holds. Also... note that the sine is also negative in the fourth quadrant?
Comment: I am not sure about your first point. I know that sin is negative in the fourth quadrant. That cannot justify the rule. For example sin$(270^° - 120^°)$, the sign will be **negative** as it is in the third quadrant. My point is why shouldn't I consider the second quadrant to consider the sign of the second quadrant as $270° - 120°$ should ideally lie in the second quadrant?
Comment: Because $\sin(x)$ is a quantity that carries a sign with it, and you are not deciding the sign of $\sin(300°)$ when you put the minus in front of $\sin(120°)$. You are simply applying an algebraic identity. In general, as I showed you, you can get stuff like $-\sin(200°)$ that simplifies to a *positive* quantity.
Comment: I don't think I am applying algebraic identity. To decide the sign, $180^∘+θ$ is taken to be in the third quadrant (as if $θ$ is lesser than $90^∘$), even though $180^∘+120^∘$ does not lie in the third quadrant, but lies in the fourth quadrant. This is consistent with all trigonometric functions. Similarly, $270^∘−θ$ is taken in the third quadrant (to decide the sign), no matter what $θ$ is. My question was "Why this works?"
Comment: It doesn't work. Take $\theta=200°$ and you'll see that it doesn't work.
Comment: Nope, it works perfectly fine. In sin$(180^°+200^°)$, $\theta$ = $200^°$. It's of the form sin$(180^° + \theta)$, so as I told you earlier we will take it in the third quadrant to decide the sign; sin is negative in the third quadrant. So sin$(180^°+200^°)$ $=$ –sin$(200^°)$. You can simplify it further.
Comment: Oh, I get it now. Basically you take $\theta=1°$ or something like that, check the sign of $\sin(\Omega + \theta)$ and then you put it in front of $\sin(\theta)$ on the right?
I guess that it only works when $\Omega \in \{0°, 90°, 180°, 270°,...\}$, and ultimately the answer is symmetry. What you call "getting the third quadrant" means that you reflected across the $Y$ axis (sign $+$) and then across the $X$ axis (sign $-$). Basically, to check what a symmetry does you take a point in the "first quadrant" and check where it ends up.
It's... not the best way to think about it.
Comment: Yes, you got it. Put this in your answer with gruesome details.
Comment: I'd rather not, as I really don't think that this language is the best way to deliver the concept. In fact, it is a very bad way to think about it!
Comment: I think I couldn't explain it simply due to the lack of eloquence. If you feel that you can put the question in better words, feel free to do it. Could you answer this [question](https://math.stackexchange.com/q/3830835/826417)?
Answer: By definition $\forall \theta$
$$\sin(\pi + \theta) = -\sin(\theta)=\sin(-\theta)$$
as we can check drawing the unitary circle to see that $\sin (\pi + \theta)$ has the same magnitude of $\sin \theta$ but with the reversed sign.
This is a straightforward check for $\theta$ in the first quadrant. For $\theta$ in the second quadrant just consider
$$\alpha=\theta -\frac \pi 2  \implies \theta = \frac \pi 2+\alpha$$
then
$$\sin(\pi + \theta)=\sin\left(\pi +  \frac \pi 2+\alpha\right)=\sin\left( \frac {3\pi} 2+\alpha\right)=-\cos (\alpha)=-\cos\left( \theta -\frac \pi 2\right)=$$
$$=\cos\left( \frac \pi 2-\theta \right)=\sin(\theta)$$
and similarly for all other cases, just using symmetry.
Comment: Do you mean $\theta = 180^\circ$?
Comment: @cansomeonehelpmeout Opsss yes of course! I fix that
Comment: This doesn't help. I know that I can prove it by using sin$(A+B)$. My point was specifically about the quadrants. As sin$(180^° + \theta)$ = $-$sin$(\theta)$, the negative sign comes because $180^° + \theta$ lies in the third quadrant where sin is negative.
Comment: @Cognoscenti Indeed the best way is by definition. Draw the unitary circle and you can easily see that $\sin (\pi + x)$ has the same magnitude of $\sin x$ but with an opposite sign.
Comment: @user Yup, there are many ways to think about it, but I want to know why it works with the quadrant one.
Comment: @Cognoscenti You can prove all this kind of identities by symmetry argument. Just consider the definition on the unitary circle.
Answer: For any real $x$ we have $$\sin(\pi+x)=\sin\pi\cos{x}+\cos\pi\sin{x}=-\sin{x}.$$
Id est, $x$ may be ended in any quadrant.
Answer: Although I would express the idea somewhat differently, I completely agree with
the OP's analysis.
That is, it is geometrically clear that $\sin(300^{\circ}) = \pm \sin(120^{\circ}).$
Further, $120^{\circ}$ is in the second quadrant while $300^{\circ}$ is in the fourth quadrant.
Therefore, $\sin(300^{\circ})$ must be $< 0$, while
$\sin(120^{\circ})$ must be $> 0.$
It could be that reference to the third quadrant was an unnoticed error, re all angles in the third quadrant (also) have a negative value for their sine.
Comment: @Cognoscenti all I can say is that if you are examining the sine or cosine of a specific angle, and you want to base the sign of the trignometric function (positive or negative) on the quadrant that the angle is located in, you have to be totally accurate in identifying the quadrant.  Otherwise, you are asking for trouble.
Comment: Nope, I don't think that the reference to the third quadrant was an error. To decide the sign, $180^° + \theta$ is taken to be in the third quadrant (as if $\theta$ is lesser than $90^°$), even though $180^°+120^°$ does not lie in the third quadrant, but lies in the fourth quadrant. This is consistent with all trigonometric functions. My question was "Why it works?" *(logically, it doesn't make sense to me)*.
Comment: Similarly, $270^° - \theta$ is taken in the third quadrant (**to decide the sign**), no matter what $\theta$ is.