Manage workstations with Puppet and TheForeman

Question: I'm building an IT infrastructure for managing all the workstations in my company. I am interested in Puppet and a external node classifier as The Foreman, but I see all the time that Puppet and The Foreman is based for servers, is there any reason to not use Puppet and The Foreman for workstations? It is insane to manage about 1000 worksations or more with this configuration?
Thank you
Answer:
is there any reason to not use Puppet and The Foreman for
  workstations?

No

It is insane to manage about 1000 worksations or more with this
  configuration?

No


3D surface plot for least square & ridge regression

Question: I'm very impressed by this plot: Why does ridge estimate become better than OLS by adding a constant to the diagonal?
Does someone has any clue about how to plot this on R? I mean, how to get RSS values for differents parameter estimation? With lm function, I will have only one solution!
Thanks for your help!
Answer: It's a plot of the objective function (i.e. the sum of squares, the thing you're trying to minimize with OLS) as a function of the coefficients. One way to compute this is to generate a "grid" of possible coefficients and then compute the sum of squares at each point on the grid.
That is, we fit a regression by finding $\hat\beta \equiv \arg \min_\beta \{ y-x\beta \}$, i.e. the $\hat\beta$ that minimizes $SS_{reg}$. But we can compute $y-x\beta$ for any $\beta$ value. So we can generate a bunch of different $\beta$ values and just plug each one into that $SS_{reg}$ formula. In this case, $\beta$ has two components (i.e. the intercept and slope), so you can visualize all of the possible $SS_{reg}$s as a 3D surface.
As for generating the plot itself, look here for a complete example with R code.
Comment: PLOTZ - you choose a grid of values for the betas and evaluate $\text{SS}_\text{reg}$ at each grid point. Which values are on your grid depends on which parts of the function you want to look at, but to include the minimum it should include the least squares estimate, probably near the center of the grid. IIRC I used `outer` for this, but `expand.grid` would be another good choice.
Comment: In order to make the sum of squares have the long valley, I had the data in $(x_1,x_2)$ space lie scattered about a straight line. Because many planes pass through the line, there's not much information in the data about which plane it should be (hence the valley - there's many combinations of $(\hat{\beta_1},\hat{\beta_2})$ with nearly the same fit).
Comment: oh... I'm very sorry, I think I am completely lost... Let me try to figure out the simulation process: 1/ random generation of x's and y values 2/ random generation of betas values 3/ compute the residual sum of squares. But L1/L2 deal with betas computation, not RSS, doesn't it? So how taking L1/L2 into account if the values are simulated... Maybe I'm asking too much, but could you show me some pieces of R codes useful to get the data? Thank you very much, and sorry for asking this.
Comment: any help please?
Comment: Thanks for this answer, very clear! But I have a concern, how do I generate the different value of β? I cannot use the lm function, can I?
Comment: Thank you Glen. Let me try this, and maybe I'll get back to you if I am stuck. I am just à bit disapointed because if I understand well,  thetas do not come from a real solving of regression vs. Ridge regression. Because ideally, I would like to do the same kind of plot for the lasso (l1 norm), and I don't how the thetas should look like !
Comment: @PLOTZ it would be trivial to make a plot for LASSO instead of Ridge. What thetas are you talking about?
Comment: Sorry, I meant betas (model's parameter)
Comment: Question : why trivial ? Wouldn't we see truncated parameters' values with the lasso?
Comment: It should just yield a different shape around the origin.
Comment: Yes, and that's the shape I would like to visualize! :-)
Comment: That's my point. Plug the beta grid values into the formula for RSS and plot it. The only difference between lasso and ridge is the norm (L1 for lasso and L2 for ridge) used in RSS; the formula is otherwise identical


How to collect and consolidate application health across instances in aws

Question: We deploy several applications across EC2 instances. They are jar files, war files on Tomcat, npm based UI applications and python scripts.
Each has a different way of validation.
For war files under Tomcat webapps I can check the swagger UI.
For UI projects I can check the application link.
For standalone jar and python scripts I check the process, if running.
Is there a way I can place checks(on the vm or in AWS) that send status(up/running or down/offline) to AWS so it is viewable for all applications across all instances?
I thought about using monit i.e. write config to monitor processes and links of individual applications. But there is no way to send it to a "one place" dashboard in AWS
Monit has it's own dashboard but it is instance specific. So if I have 20 instances there's 20 dashboards like http://IP:2812/. It has a centralized dashboard offering which is not open source so I cannot use it
I checked the AWS resource health sub category within Cloudwatch. That is limited to cpu/memory/status checks and I don't see a way for customization to track individual jar/war files
I checked AWS X ray, and seeing that it requires changes to the application code makes me think it will extract too much data like number of 4XX and 5XX(which isn't the need since all I need to do is check links or processes and report it visually)
Is there a way to visualize resource health of all applications on all instances on a single dashboard/page either in AWS or some opensource tool?
Answer: I suggest you monitor the application rather than the infrastructure. Cloudwatch Synthetics acts like a web browser and can alert based on the results of the request.
If you want to monitor at the component level you will have to write some kind of script that sends data to CloudWatch Metrics or Cloudwatch Logs using the API, which isn't particularly difficult. From there you can alert on metrics, or use metric filters to alert on log contents.


edite content type style

Question: I clone content type by using bundle copy module, but the view of the content type never the same as the first one, how can I clone the style too
Comment: You should explain in detail how you have " tried to change css file and copy style p and edit p word to v". Is not clear what you've done.
Answer: Copy the template also. For example if you have a node--old-content-type.tpl.php file you'll need to copy it to node--new-content-type.tpl.php.
Comment: I did it now, I clone node--old-content-type.tpl.php and renamed it to the new one, have I to edit the file inside
Comment: It depends on what is in there. It also won't pick up the new tpl.php file until you have cleared the caches and possibly rebuilt the theme registry.
Comment: i cleared cash it working fine but rate module didn't work with the content type, how can I repute for your answer ?
Comment: It works fine thx alot

edite content type style


.NET WebBrowser Control in WindowForms

Question: I'm currently using a System.Windows.Forms.WebBrowser in my program. When I try to access some websites over https, the message "There is a problem with your websites security certificate" appears. Is there any way I can get WebBrowser to ignore these types of warnings?
I am using Visual Studio 2010.
Comment: possible duplicate: http://stackoverflow.com/questions/1301127/how-to-ignore-a-certificate-error-with-c-sharp-2-0-webclient-without-the-certi
Comment: http://stackoverflow.com/questions/14141303/display-html-containing-iframe-in-windows-form-c-sharp#comment19582540_14141303
Answer: The simplest way is:
System.Net.ServicePointManager.ServerCertificateValidationCallback =
  (sender, certificate, chain, errors) => true;

But that does leave the client vulnerable (i.e. cannot verify the server's identity).
A better approach would be to implement a method that actually validates the certificate, or if the certificate cannot be validated presents the user with a choice whether they should proceed or not.

.NET WebBrowser Control in WindowForms


How to use OLS or NLS on very small sample size?

Question: right now I am facing the problem of handling a very small sample size which consists of 8 observations with 24 variables.
I would like to do first just simple OLS with one dependent and 23 independent variables and use these coefficients to estimate NLS estimates. These estimates will be used for further studies.
The problem obviously is that I got more parameters than observations. I tried to bootstrap my observations and just do simple OLS with a handful of parameter with bootstrap repetitions between 50 and 50,000 to improve my results, however, in fact, the significance of some coefficients even decreased.
Is it even possible to derive somewhat significant coefficients here? What else can I do? I am new here, so I dont know yet how to include a table with exemplary data. Sorry.
Thanks for any help,
TheJoez
Comment: Bootstrapping often does not work as expected with small datasets, anyway: it is valid only asymptotically (for larger amounts of data). But more to the point, either model is worthless, because it will produce an absolutely perfect fit and its parameters will not be identifiable (assuming the independent variables don't have hugely reduced rank).
Comment: The bootstrap will probably not help you. You may want to look at regularisation techniques like the Lasso, Generalized Elastic Nets and so forth.
Comment: Is there a reason why bootstrap does not work here?
Comment: If you bootstrap your eight observations, you will end up with a bootstrapped dataset with again eight observations and 24 variables, and you still have the problem of $p>N$. Of course you can do (some kind of) OLS fitting and assess the variability of estimates with the bootstrap, but this will be determined more by how your software does fitting in this context, perhaps even by the order of your 24 variables.
Comment: Oh sure, $p>N$ remains. Thanks for opening my eyes. ;-)
Comment: Bayesian estimation naturally comes to mind. There, you could have 1 data point and 100 parameters, and it would still work. However, with a small sample the specification of the prior becomes quite important, and the estimates would be sensitive to it.
Answer: Your problem is not new and a whole chapter ("High-Dimensional Problems") of this book is dedicated to such cases where the number of variables $p$ is much bigger than the number of observations $N$. Numerous ways are possible.
In my opinion, the two simplest methods to regularize the problem are the Lasso and the Ridge Regression which consist in adding a penalty to the standard least-square term.
Comment: Thanks for the help. I'll have a look into that.
Sure, 8 observations are very poor. The alternative, i.e. 7 days of work, would be 10 observations. So I would like to see what I can do with the existing 8 ones.
Comment: +1, especially for recommending *Elements of Statistical Learning*. And even so, it will be hard to learn anything from only eight observations...


Will the new MCC 2017 laws apply on old cricket match stats?

Question: There are a whole lot of MCC 2017 changes coming up: MCC Laws of Cricket 2017
Summary: Law Summary Paper
Do these changes apply to old matches which would modify their stats slightly?
Comment: Other than the "handled the ball" to "obstructing the field" change, is there anything else which could affect a match's statistics?
Comment: There are some no ball changes. Trying to get my head around these changes atm.
Comment: Ah yes, you're right. No ball + (leg) byes would previously (old laws 26.1, 26.2(c)(ii)) be scored as more than one no ball, but in the new laws (18.10.2, 23.1, 23.2.3) it's one no ball + a separate count of (leg) byes.
Comment: I guess that would be a hard one to change for old matches :) I'm leaning that old matches won't be affected by these new changes.
Answer: There are potentially two changes in the new Laws which could affect match statistics:

The merging of the "handled the ball" dismissal into "obstructing the field". Given the small number of handled the ball dismissals which have happened in top-level cricket, it would be possible to re-write the score books to change all these into "obstructing the field". Frankly, all that's going to do is to change the answers to some trivia questions - e.g. "How many people have been given out obstructing the field in Test cricket?" would change from just Len Hutton to a set of eight people.
A change in scoring when byes or leg byes are scored off a no-ball. In the old Laws, this would be scored as multiple no-balls (and thus all debited to the bowler) whereas in the new Laws it would be one no ball and a separate account of byes or leg byes (thus leading to only one run being debited to the bowler). As even for international cricket, full ball-by-ball scores don't exist from before the mid-1990s, it's just not possible to do this for a lot of earlier matches. More generally, this change is similar to that made in the early 1980s when wides and no-balls were first debited to the bowler - while some analyses have been performed under the "new" way of doing things, the official scorecard stands as it was scored when the match was played.


Robo_feed rotina da verificação loop if dando pau em python

Question: Robo_Feed
Sou novo no python, tava querendo desenvolver um robo que pegasse a ultima postagem de alguns portais de noticias aqui da minha região, Com uma pesquisa cheguei a conclusão que seria mais fácil fazer com o modulo feedparser do python.
Então vou tentar explicar o código...

Fiz uma class que cuidasse das entradas de dados, nome do site e url, assim fazendo uma lista dos mesmos
Defini uma rotina em feed_parser() que extrai os dados das variáveis dando um print pra min na tela das ultimas postagens
Coloquei um while dentro do try para chamar as funções
O script roda lisinho nos 2 primeiros loops depois da pau

Como disse sou novo e sem experiência, mais com muita vontade de aprender
a programar direito em Python
codigo
import feedparser
import time
import base64
timeaut = 15

class Robo_Feed(object):
    def __init__(self):
        self.data = []
        self.sites= {}
        self.allheadlines = []
    def append_url(self, name, site):
        self.sites[name] = (site)
    def encrip(self, published):
        self.data.append(base64.b64encode(published))

def feed_parser():
    def parseRSS(rss_url):
        return feedparser.parse(rss_url)
    def getHeadlines(rss_url):
        robo.headlines = []
        feed = parseRSS(rss_url)
        if (base64.b64encode(feed.entries[0].published)) in str(robo.data):
            return robo.headlines
        else:
            POSTAGEN = '*'+feed['feed']['title']+'*' +"\n" + feed.entries[0].title + "\n" + feed.entries[0].link + "\n\r"
            print (POSTAGEN)
            robo.encrip(feed.entries[0].published)
            return robo.headlines
    for key, url in robo.sites.items():
        robo.allheadlines.extend(getHeadlines(url))

robo = Robo_Feed()
robo.append_url('Oglobo', 'http://oglobo.globo.com/rss.xml?secao=ece_frontpage')
robo.append_url('ZeroHora', 'http://zh.clicrbs.com.br/rs/ultimas-noticias-rss/')

try:
    while True:
        feed_parser()
        time.sleep(time)
except KeyboardInterrupt:
    print "Umteromped"

Erro
      File "/home/ubuntu/PycharmProjects/BotTelegran/testes.py", line 38, in <module>
    feed_parser()
  File "/home/ubuntu/PycharmProjects/BotTelegran/testes.py", line 30, in feed_parser
    robo.allheadlines.extend(getHeadlines(url))
  File "/home/ubuntu/PycharmProjects/BotTelegran/testes.py", line 22, in getHeadlines
    if (base64.b64encode(feed.entries[0].published)) in str(robo.data):
IndexError: list index out of range

Answer: Consegui fazer o código rodar, o problema que estava acontecendo era na codificação para base 64, que só funciona para caracteres ASCII, bastou converter para ASCII antes de converter.
Outro problema foi no time.sleep(timeaut) que estava chamando o modulo time ao invés da variável com o tempo de espera  .
Segue o código funcionando.
import feedparser
import time
import base64
timeaut = 15

class Robo_Feed(object):
    def __init__(self):
        self.data = []
        self.sites= {}
        self.allheadlines = []

    def append_url(self, name, site):
        self.sites[name] = (site)

    def encrip(self, published):
        self.data.append(base64.standard_b64encode(published.encode('ascii')))

def feed_parser():
    def parseRSS(rss_url):
        return feedparser.parse(rss_url)

    def getHeadlines(rss_url):
        robo.headlines = []
        feed = parseRSS(rss_url)

        if (base64.standard_b64encode(feed.entries[0].published.encode('ascii')) in robo.data):
            return robo.headlines
        else:
            POSTAGEN = '*'+feed['feed']['title']+'*' +"\n" + feed.entries[0].title + "\n" + feed.entries[0].link + "\n\r"
            print (POSTAGEN)
            robo.encrip(feed.entries[0].published)
            return robo.headlines

    for key, url in robo.sites.items():
        robo.allheadlines.extend(getHeadlines(url))

robo = Robo_Feed()
robo.append_url('Oglobo', 'http://oglobo.globo.com/rss.xml?secao=ece_frontpage')
robo.append_url('ZeroHora', 'http://zh.clicrbs.com.br/rs/ultimas-noticias-rss/')

try:
    while True:
        feed_parser()
        time.sleep(timeaut)
except KeyboardInterrupt:
    print ("Umteromped")


Is it possible to change the captain in the middle of the match?

Question: In Sachin's farewell's match, I saw a quote in Cricinfo that Dhoni can hand-over the captaincy to Sachin to honour him like he did that for Saurav.

I searched about that and yes, it's true that Ganguly had led the team in the last moments of his final match.    -Source.
What is the ICC rule about changing the captain in the middle of the match while the actual captain is on-field?
Is it permitted in all matches or just for farewell matches?
Comment: This question reminds me of ICC world T20 2014 final SL vs India. Malinga was the designated captain, but it was Sanga/Mahela who marshaled the troops during the match :D
Answer: The captain can be changed at any time during any game, provided he/she is one of the playing eleven (not a substitute player). The law doesn't recognise "farewell matches", so that is immaterial. Dhoni could have made Mohammad Shami the captain if he wanted to.
Quoting:

Law 1 (The players):
  3. Captain
If at any time the captain is not available, a deputy shall act for
  him.
  ...
  (b) At any time after the nomination of the players, only a nominated
  player can act as deputy in discharging the duties and
  responsibilities of the captain as stated in these Laws.

The other answer has a lot of misinformation. It is not necessary that the vice-captain should take over. It usually happens, but the law does not require it.
Also, the captain's job is not just changing the field, as the other answer seems to imply. The laws are not even concerned with who changes the field.
Specific laws require the captain's involvement. Some examples (there are a lot more):

Law 2 (Substitutes and runners; batsman or fielder leaving the field; batsman retiring; batsman commencing innings)
  9.Batsman retiring
  ...
  (b) If a batsman retires for any reason other than as in (a) above, he
  may resume his innings only with the consent of the opposing captain.
  If for any reason he does not resume his innings it is to be recorded
  as 'Retired - out'.

...

Law 3: The umpires
  2. Change of umpire
An umpire shall not be changed during the match, other than in
  exceptional circumstances, unless he is injured or ill. If there has
  to be a change of umpire, the replacement shall act only as striker's
  end umpire unless the captains agree that he should take full
  responsibility as an umpire.

...

Law 5: The ball
  4. New ball in match of more than one day's duration
In a match of more than one day's duration, the captain of the
  fielding side may demand a new ball when the number of overs,
  excluding any part overs, bowled with the old one is equal to or
  greater than the prescribed number of overs. The Governing Body
  responsible for the match concerned shall decide the number of overs
  applicable in that match. This number shall not be less than 75 overs.
Comment: Doesn't the law say **if the captain is not available**? While in the above situation Dhoni was available on the field.
Comment: @hims056 That doesn't really matter, for two reasons.
1. It doesn't define 'not available'. The captain could well stand at deep midwicket and claim that he is "not available", or he could say he is "not available" for captaining.
2. The law only talks about what happens when captain is not available, but doesn't explicitly state anything about when the captain *is* available. The law says 'if', not 'if and only if'.
It would indeed be bizarre if such loopholes are exploited in a senior level game, but there's nothing in the law to stop it.
Comment: The law of Cricket is very confusing on some points. They really need to be more specific at least for general people. Their terms need to be defined. Anyway +1 for this.
Answer: From what I know, you cannot literally swap the designated captain, but that doesn't stop the captain handing over temporary charge to another player, similar to if a captain goes off the field and the vice captain takes over. An umpire cannot say to a player 'no, you can't change the fielding positions cause you're not captain'. This happened in the BBL, when Faulkner, despite being the designated captain, let Warne and/or White do all the captaincy work, although Faulkner was still listed as captain. I believe the same thing would have happened with Ganguly.
Comment: +1, as this post is about icc rules, a reference is better than what you know. :)


Worklight adapters, Java Classpath

Question: The simple problem is: how do I make a Java Resource bundle available to code in Java JAR that is accessed from a Worklight adapter? I think that this amounts to: what is the classpath used by the Java beneath a Worklight adapter?
Reason: we use a third-party Java library that communicates with a particular enterprise service, it has it's own configuration mechanism to determine that service's location, that mechanism uses resource bundles.
We put the library JARs in the server/lib folder and successfully can invoke the library code from  the adapter:
    manager = com.third.party.manager.getInstance();
    // manager is correctly obtained
    token = manager.talkToServer();
    // this fails with an error indicating that the server location is unknown

We see that the third party code attempts to use exactly this pattern, in particular the3 varient of getBundle() is as shown here:
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("ThirdParty");
Enumeration<String> enumeration = bundle.getKeys();

while (enumeration.hasMoreElements()){
 String str = enumeration.nextElement();
 System.out.println("property " + str);
     //etc

Now, I was expecting to package my resource bundle in the base of a new JAR file and add it to the server/lib and have it picked up. I created that resource JAR file, containing
ThirdParty.properties

and as a test created a little Java application containing the above code, and added the resource JAR to that application's classpath; the bundle we loaded as expected.
I then converted that Java to adapter code:
var bundle = java.util.ResourceBundle.getBundle("ThirdParty");

var enumeration = bundle.getKeys();

while (enumeration.hasMoreElements())
{
  var str = enumeration.nextElement();
  var val = bundle.getString(str);
}

Add my property JAR file to server/lib and get an exception telling me the bundle cannot be found.
Suggestions for a better classpath?
Answer: I've just tried it and everything worked just fine. Steps I tried to recreate the issue:

Created new WL project with WL Studio 6.1
Added props.properties file with a single name=anton property
Right-clicked it in Eclipse, export -> Java -> JAR file. The only checkbox I had checked is Export generated class files and resources. I've named the file resources.jar
Deleted props.properties and copied resources.jar to server/lib folder
Created adapter, added following procedure
function test(){
    return {
         data: com.anton.PropGetter.getProp("name")
    };
}

Created PropGetter.java class under com.anton package with following code
package com.anton;

import java.util.ResourceBundle;

public class PropGetter {
    public static String getProp(String propName){
        ResourceBundle bundle = ResourceBundle.getBundle("props");
        return propName + " :: " + bundle.getString(propName);
    }
}

Tested adapter procedure, got following output:
{
   "data": "name :: anton",
   "isSuccessful": true
}

Comment: Thanks, that does indeed work. It's slightly different from my initial case in that equivalent of PropGetter is packaged in a JAR, but I've done that too and it still works just fine. The third-party case resolutely fails, as does my direct call to ResourceBundle from javascript. I'll keep digging, at least this answer confirms that the general case of resource loading behaves as expected.

Worklight adapters, Java Classpath


Piano pedagogy: lots of finger numbers? Best practice?

Question: I have a question about piano teaching / learning.
I am a beginner, older student, working through grade 1 ABRSM piano.  I know theory (key sigs, note letters, chords, intervals) from rhythm guitar and being a nerd, but I am not at all fluent with notation (lines and dots). When I stumble on a piece, my teacher wants to write all the finger numbers on the score, including very obvious intervals like a third with no hand position change.
I hate that because I stop reading the notes and just play to the finger numbers. He says it's better because I can learn how the piece should feel and sound first without tripping over notation issues. I think it's more important to learn to sightread, but I will never learn if I memorize pieces relying on basically tablature (yuck!).
What is the experience of other piano learners? Is there a standard approach?
Answer: If fingering is written down, what stops you from disregarding it if you want to sight read ?
I think your teacher's approach is good and common, and even invoked by Jean Fassina, who spread the Polish school teachings (Chopin, Liszt, Paderewsky). There are few videos about the benefits of this careful fingering:
Michel Beroff about Jean Fassina
Jacques Rouvier about Jean Fassina
Chopin believed that each finger has its own personality, and indeed there are medical and anatomical arguments to support that.
Therefore the fingering can be very important to be able to reach a better sound, and higher ease.
There is another argument for writing down the fingering: stability of movement ie., you use the same fingering each time. This increases your learning speed, and this helps you memorize a good movement, and this helps you to go back to what you were doing if you come back to the piece a long time later ie., enough to have you forget your fingering.
In Godowsky études, you'll see that the author wrote down at least one fingering for almost each note. This is part of Godowsky's way to play the piano, it's also very helpful to find faster the right movement, because indeed it is not obvious at all to do the "right" or the most optimized movement.
In Liszt's études transcendantes (eg., Wiener universal edition), you'll be able to see Liszt's fingering, but he did not write every finger on every note, rather when there is a need, maybe a requirement (eg., 42/42/24/24/42/42 in Mazeppa's theme) or a notable trick or finger technique.
In my professional practice, I write down the fingering for those reasons, and eventually at some point, I may change the fingering because the new one is really allowing something that was not comfortable before. I do/did that several times with Stravinsky's Petrouchka, Liszt's études transcendantes, or even Godowsky's études.
Hence I advise you to accept his fingering, and to focus on notes, and if you need to practice your sight reading, to find other scores or to focus on the notes and not the written fingering.
For memorizing, you should not ever rely on your fingers only, but notes and the result of your analysis (eg., tonality, degree, modulations, patterns, etc). In the end you'll have to memorize all of those aspects, despite the hierarchy of importance.
My pieces of advice are the same wether you are beginner or professional.
Answer: Teachers and students and anyone playing piano each differ, of course, in their approaches to learning pieces and learning sight-reading, with some teachers or students treating both the same, and some treating them differently. It sounds like your teacher might be overly rigid in this regard.
One approach you could take is to separate the music you learn with your teacher from the music you use for sight-reading practice. You can do things your teacher's way for your in-lesson music, and you can do things your way for sight-reading.
It's fine to write in cues, such as finger numbers or note names, to whatever degree is helpful to reach your goals. In general, whether they are present for every single note or just a few, simply writing them and repeatedly seeing them in conjunction with the notation will sink in over time to the point where you won't need them anymore, provided you exercise some minimum discipline in keeping an eye on the staff.
Comment: In my experience, sight reading practice material pretty much **has** to be separate from all other rep to be effective.
Answer: First thing to do is discuss this with teacher. Who may have always used this idea, or who feels that it's the best for you. Teaching and learning is a two way thing, and student ought to be able to talk candidly with teacher about any issues that are concerning.
I understand that with the numbers, it's similar to tab, but learning a piece is rather different from sight-reading.
Sight-reading is being able to look at the dots and translate them into music pretty quickly. Learning a piece is getting inside it, and, in your case, preparing it for performance in an exam. Very different. Practising the same piece time and time again, after establishing what the notes are. From the end point of this exercise, saving time and effort just mechanically learning the dots has its merits - and it's not sight-reading.
This is probably the goal teacher is aiming for - to get the pieces learned more quickly, so as to concentrate more on a polished delivery. Which, after all, is what's expected in an exam.
As long as teacher doesn't do the same when teaching sight-reading, which would be folly, then keep the two skills separate, because that's just what they are - separate skills!
Answer: I take the approach that fingering markings should be reserved for the places where you need it. I agree with you that you  want to be reading/looking at the notes, not the fingerings.  Use markings as a reminder where you'd be inclined to use another fingering--perhaps one that at first reading feels more natural for your current hand position--but where you need a different fingering because, for example, you are transitioning to a new hand position. Gradually, these "preparatory" fingerings will become more "natural" to you and you'll be able to omit most of them, too.
Marking the fingering for every note could be a good exercise for a beginner in a few pieces, but IMO it is redundant with the principle of five-finger hand positions, which form the basis of scales and piano playing in general.
Even when the composer or editor has indicated a fingering, it is more often than not omitted in repeat and analogous  passages. They assume you've gotten the idea, i.e., the reasoning or principle behind the fingering and you can apply it to the rest of the piece. Of course, you can also add it in yourself where you need reminders.


Add another Update for Merge Into PL SQL trigger

Question: I have to upsert table from another table.
Here is the table MST_LIST
NAME | VER | FLAG
-----+-----+-----
A    |201  |1
B    |101  |1

And TMP_LIST to update previous table
T_NAME | T_VER
-------+-------
A      |202
C      |101

And I used merge to upsert. This is the code that I created.
  create or replace TRIGGER MST_LIST_TRIG
     AFTER INSERT OR UPDATE ON TMP_LIST
     FOR EACH ROW
     BEGIN
     MERGE INTO MST_LIST USING DUAL ON ( NAME = :NEW.T_NAME )
     WHEN MATCHED THEN UPDATE SET
       VER = :NEW.T_VER
     WHEN NOT MATCHED THEN INSERT (NAME, VER, FLAG_ACTIVE)
         VALUES (:NEW.T_NAME, :NEW.T_VER, 1);
     END MST_LIST_TRIG;

But the problem is I need to add another update
    update MST_LIST set FLAG = 0 where NOT EXISTS
(SELECT TMP_LIST.T_NAME FROM TMP_LIST WHERE MST_LIST.NAME = TMP_LIST.T_NAME);

to get result like this
NAME | VER | FLAG
-----+-----+-----
A    |202  |1
B    |101  |0
C    |101  |1

I tried Loop and If but still can't get the excpected result. Please help me. Thanks.
Answer: You need to write a autonomous transaction in your trigger to achieve this. See below:
create or replace TRIGGER MST_LIST_TRIG
     AFTER INSERT OR UPDATE ON TMP_LIST
     FOR EACH ROW
     BEGIN
     MERGE INTO MST_LIST USING DUAL ON ( NAME = :NEW.T_NAME )
     WHEN MATCHED THEN UPDATE SET
       VER = :NEW.T_VER
     WHEN NOT MATCHED THEN INSERT (NAME, VER, FLAG_ACTIVE)
         VALUES (:NEW.T_NAME, :NEW.T_VER, 1);

  --Calling a autonomous proc here
   proc_upd();
 END MST_LIST_TRIG;

Autonomous transaction:
create or replace  procedure proc_upd
as
PRAGMA AUTONOMOUS_TRANSACTION;
begin

   UPDATE MST_LIST
   SET FLAG = 0
  WHERE NOT EXISTS
          (SELECT TMP_LIST.T_NAME
             FROM TMP_LIST
            WHERE MST_LIST.NAME = TMP_LIST.T_NAME);

    commit;

END;


I can't figure out how to reset a loop (see example)

Question: I need to write a method that accepts two ints as arguments, a min and a max. On the first line i need to print all numbers in that range (inclusive). On the next line I start with min+1, print all numbers up to max, and then go back to the front of the range and print min. Next line I start with min+2, and so on until I have repeated this starting with each number in the range.Very hard to explain, here's two examples: Say I pass 1 and 5 as the min and max arguments. I want the method to print this:
12345
23451
34512
45123
51234

Or if 3 and 9 were passed, I would expect this:
3456789
4567893
5678934
6789345
7893456
8934567
9345678

I've tried all kinds of things, I'm sure there is an easy way to do this that I am not realizing. I'm supposed to do this without arrays or arrayLists. I think I have a good base to work with, but I just can't figure out where to go from here. My base code prints this:
12345
2345
345
45
5

And this:
3456789
456789
56789
6789
789
89
9

I'm stumped. Here's my code:
public void printSquare(int min, int max){
   for (int i=min; i<=max; i++){
      for (int j=i; j<=max; j++){
         System.out.print(j);
      }
   System.out.println();
   }
}

Comment: Sounds like this could be recursive.
Comment: It's not homework it's from some java sample questions on a website that I've been reading.. I'm not in school, I'm just learning java for myself =) I'm going to think about Peter and Raskolnikov's answers, and see if I can come to the conclusion myself.
Answer: You should think about how many values you want on each row, and then determine what those values should be. Its hard to make it any clearer without giving you the solution.
Let us know how you go.
Comment: To be more precise: how do we determine what the values are, in terms of the value of the loop counter at that point?
Comment: It a very simple expression so I had thought you might be able to work it out. However if you can't you can look at @taxman's solution.
Answer: Peter is right, and IMO is answering a homework question in the right manner. You know how many elements you want on each line, so you need an outer loop that gives you that many elements, this will stop you from getting the cascading behavior you're seeing now.
At that point you need to think about your inner loop(s), and you'll probably find this easiest using the modulus operator (%). This will allow you to iterate without ever going over your target.
You should be able to figure it out from there, and you're much better off figuring out the algorithm yourself than copying it from someone else, at least at this level of development. Good Luck!
Answer: Think about a way to print the missing numbers. The answer is below, if you cannot come up with it you can check it.

This should also print the missing parts:
public void printSquare(int min, int max){
   for (int i=min; i<=max; i++){
      for (int j=i; j<=max; j++){
         System.out.print(j);
      }
      for (int k=0; k<i-min; k++){
         System.out.print(min+k);
      }
      System.out.println();
   }
}

Answer: I didn't run this one but it might work:
public void printSquare(int min, int max){

   int dif = max - min;
   for (int i=min; i<=max; i++){

      for (int j=i; j <= i+dif ; j++){
         int temp = j;
         if ( temp > max ) temp = temp  - max;
         System.out.print(temp);
      }

   System.out.println();
   }

}

Answer: try and just shift an array like so:
   static void Main(string[] args)
    {
        // this will work equally well with numbers letters or other types of characters
        int[] nums = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        String a = "hello";
        for (int i = 0; i < nums.Length; i++)
        {
            int j = 5;
            int num = i;
            while (j-- > 0)
            {
                if (num >= nums.Length)
                {
                    num = 0;
                }

                // shift the loop
                Console.Write(nums[num++]);
            }
            Console.WriteLine();
        }
    }

Answer: public class Test1{
    public void printSquare(int min, int max){
        for (int i=min; i<=max; i++){
            for (int j=i; j<=max; j++){
                System.out.print(j);
            }
            for(int k= min; k<i; k++){
                System.out.print(k);
            }
            //System.out.print(i-1);
            System.out.println();
        }
    }
    public static void main(String[] args){
        Test1 t = new Test1();
        t.printSquare(1,5);
    }
}

Comment: try to add an explanation for your answer.
Answer: This is a very simple implementation. Hope this helps!
   int n = max-min+1;
   for (int i=0 ; i<n; i++){
    for (int j=0; j<n; j++)
     cout<<min + (i+j)%n;
      cout<<"\n";
   }

Output:
min = 3 | max = 9

    3456789
    4567893
    5678934
    6789345
    7893456
    8934567
    9345678

Answer: Here's the code..
 for i = 0 to max-min
 for j = 0 to max-min
 print min + (i+j)%n


How to show the content on ajax or Jquery lightbox

Question: I have created views custom template file for one of my view and works fine. And how can i show fields content(second in the below code) on Lightbox popup box when the user clicks on title field.
 <?php dpm($fields); ?>
   <?php print $fields["title"]->content; ?>

   <?php print
 $fields["field_availability"]->content; ?>

Answer: You should describe the problem you are facing ...
What 'lightbox-meme' are you trying to implement ?
If you are using the lightbox module for drupal, you should read the README.txt, that is pretty self-explanatory.
Hope this helps.


WordPress get_template_part() breaking advanced custom forms repeater

Question: I'm building a page in WordPress which uses two Advanced Custom Forms repeaters and inserts a template part into the page in between them. If the get_template_part() call is after both repeater all the content loads fine but when it's in between the two repeaters the content after the get_template_part() does not load and I'm not sure why.
<?php get_header(); ?>

        <?php if(get_field('landing')):?>
            <?php while (have_rows('landing') ) : the_row(); ?>
                <section class="block row" id="landing" style="background-image: url('<?php the_sub_field('background'); ?>');">

                            <img src="<?php the_sub_field('image'); ?>" />

<?php echo the_sub_field('text'); ?>

                            <a class="" href="<?php the_sub_field('section_url');?>"><?php the_sub_field('url_text'); ?>
                            <img src="<?php bloginfo('template_directory');?>/images/more_icon.png">

            <?php endwhile; ?>
        <?php endif; ?>

    <?php get_template_part ('social');?>

        <?php if(get_field('section')):?>
            <?php while (have_rows('section') ) : the_row(); ?>
                <section class="block row" style="background-image: url('<?php the_sub_field('background'); ?>');">

                            <img src="<?php the_sub_field('image'); ?>" />

<?php echo the_sub_field('text'); ?>

                            <a class="" href="<?php the_sub_field('section_url');?>"><?php the_sub_field('url_text'); ?>
                            <img src="<?php bloginfo('template_directory');?>/images/more_icon.png">

            <?php endwhile; ?>
        <?php endif; ?>

Here is the code for the get_template_part() call:

Instagram

This is an instagram feed

On The Radio

Lorem Ipsum is simply dummy text of the printing and typesetting industry.
        Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
        when an unknown printer took a galley of type and scrambled it to make a type
        specimen book. It has survived not only five centuries, but also the leap

In The News

<?php
        global $post;
        $args = array( 'posts_per_page' => 3 );
        $myposts = get_posts( $args );

        foreach( $myposts as $post ) :  setup_postdata($post); ?>
        <a href="<?php the_permalink() ?>" class="pull-right" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>

        <?php echo get_the_date(); ?>
        <?php the_post_thumbnail( ); ?>
        <?php endforeach; ?>

<img src="<?php bloginfo('template_directory');?>/images/reclamation_road.png"/>

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
        Ipsum has been the industry's standard dummy text ever since the 1500s, when an
        unknown printer took a galley of type and scrambled it to make a type specimen
        book. It has survived not only five centuries, but also the leap

I'm not sure what the problem is.  Any help would be greatly appreciated.
Answer: This happens because in your template part social, you're using setup_postdata(), which overrides the current $post.
So you have to reset $post to the original one. To do that, after the endforeach, you should call wp_reset_postdata(). For more information and example usage, you can refer to: http://codex.wordpress.org/Function_Reference/setup_postdata
Comment: Glad it worked. Feel free to accept the answer if it was helpful for you.


How can I display the Excel Publish as PDF or XPS dialog using VBA?

Question: I know I can use the following VBA to display the regular Excel (2010) Save As dialog (which is close), but how do I display the specific "Publish as PDF or XPS" dialog? This dialog limits the file types to PDF and XPS and is the one I am after, but there doesn't seem to be an enumeration for it in the XlBuiltInDialog enumeration.
Application.Dialogs(xlDialogSaveAs).Show

This particular dialog is accessed through the GUI by going to File -> Save & Send -> Create PDF/XPS Document -> Create PDF/XPS.
Answer: I have a work-around which could work for you.
1) Create a userform which asks whether the user would like to save as XPS or PDF. Create 2 buttons on the userform, one showing text "XPS" and the other showing text "PDF".
2) Add code to each button, so that when pressed, it will save the document in the format specified by the user.
In module with code:
userform_save.Show

In the xps button:
Private Sub cb_xps_Click()
    ActiveSheet.ExportAsFixedFormat Type:=xlTypeXPS, Filename:=filepath & xpsName
    Unload Me
End Sub

In the pdf button:
Private Sub cb_pdf_Click()
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=filepath & pdfName
    Unload Me
End Sub

Let me know your thoughts.
Comment: I'm aware of ExportAsFixedFormat, however this doesn't help because there are a whole host of options that you can specify (like which page to publish, the quality etc, and so I would have to end up recreating the whole Publish as PDF or XPS dialog, along with options. That being said, your workaround is worth noting and may help others who want a simplified interface.
Answer: After some investigation I still can't find any way of displaying this dialog using Application.Dialogs, however I can display it using this:
Application.CommandBars.ExecuteMso "FileSaveAsPdfOrXps"

Works in Excel 2007, 2010 and 2013.


Como mover um botão em CSS?

Question: Bom dia! Estou enfrentando problemas com o posicionamento de um botão em CSS.
Queria mudar cada um destes 4 botões para um lado em especifico, mas não sei como.

.button {
           background-color: #4CAF50; /* Green */
           border: none;
           color: white;
           padding: 16px 32px;
           text-align: center;
           text-decoration: none;
           display: inline-block;
           font-size: 60px;
           margin: 40px 2px;
           -webkit-transition-duration: 0.4s; /* Safari */
           transition-duration: 0.4s;
           cursor: pointer;
         }

         .button5 {
           background-color: white;
           color: black;
           border: 2px solid #555555;
         }

         #historia{

         }
         #cartazes{

         }
         #fotos{

         }
         #videos{

         }

         .button5:hover {
           background-color: #555555;
           color: white;
         }

         <button onclick="location.href='http://localhost/pap/historia.html'" type="button" class="button button5" id="historia">História</button>
         <button class="button button5" id="cartazes">Cartazes</button>
         <button class="button button5" id="fotos">Fotos</button>
         <button class="button button5" id="videos">Vídeos</button>

E aqui está o código do css e hmtl dos botões.
Eu sei que tenho que criar um id para cada botão mas não sei o que escrevo em cada um...
E aqui esta o menu onde estão os botões que quero mover.
Comment: Qual lado especifico você que mudar?
Comment: Como vc gostaria de deixa-los?
Comment: Sem falar o que você quer fazer só vai gerar chutes como respostas.
Answer: Existem várias formas de fazer isso, a mais fácil acredito ser com position:absolute. Primeiro vc coloca o pai e todos os elementos "pai" com altura de e largura de 100% para ocupar a tela inteira, depois vc coloca o pai do position:relative e os filhos com position:absolute. Dessa forma vc pode aliar os botões um em cada canto com top, left, bottom e right

Segue o código da imagem acima:

html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#cssmenu {
width: 100%;
height: 100%;
}
.button {
  background-color: #4CAF50; /* Green */
  border: none;
  color: white;
  padding: 16px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 60px;
  /* margin: 40px 2px; */
  -webkit-transition-duration: 0.4s; /* Safari */
  transition-duration: 0.4s;
  cursor: pointer;
  box-sizing: border-box;
}

.button5 {
  background-color: white;
  color: black;
  border: 2px solid #555555;
}

#historia{
  position: absolute;
  top: 0;
  left: 0;
}
#cartazes{
  position: absolute;
  top: 0;
  right: 0;
}
#fotos{
  position: absolute;
  bottom: 0;
  left: 0;

}
#videos{
  position: absolute;
  bottom: 0;
  right: 0;
}

.button5:hover {
  background-color: #555555;
  color: white;
}

ul {
  padding: 0;
  margin: 0;
  position: relative;
  width: 100%;
  height: 100%;
}

    <button onclick="location.href='http://localhost/pap/historia.html'" type="button" class="button button5" id="historia">História</button>
    <button class="button button5" id="cartazes">Cartazes</button>
    <button class="button button5" id="fotos">Fotos</button>
    <button class="button button5" id="videos">Vídeos</button>

Como mover um botão em CSS?


Reconstructing space curves from its curvature and torsion

Question: I have to write a program which gets two functions (curvature and torsion) and 3 vectors of the Frenet-Serret "frame" at the starting point - and I have to reconstruct the space curve from this given input data.
So I've written some Octave code, which works fine, for example on the curve
 Phi(t) = (cos(t/sqrt(2)), sin(t/sqrt(2)), t/sqrt(2))  % natural parametrization

(it's some kind of spiral) and I was happy because when I plotted results, the original curve was almost the same as the reconstructed one. But when I tried out some other parametrization, there was huge difference between the reconstructed and the original one:
 Phi(t) = (cos(t), sin(t), t)  % other parametrization of the same curve

I can't really find what I did wrong in my code... Maybe my idea was completely wrong, and I can only reconstruct curves which is naturally parametrized?
% note: this returns a vector
% K : curvature
% T : torsion
function equation = f(s, gvect, K, T, velocity)
    gs = toStruct(gvect);
    e_v = velocity(s)*K(s).* gs.n;
    n_v = -velocity(s)*K(s).* gs.e + velocity(s)*T(s).* gs.b;
    b_v = -velocity(s)*T(s).* gs.n;
    equation = [e_v; n_v; b_v];
    return;
endfunction

% returns a struct
function str = toStruct(vect)
    str.e = vect(1:3);
    str.n = vect(4:6);
    str.b = vect(7:9);
endfunction

% returns a vector
function vect = toVect(str)
    vect = [str.e; str.n; str.b];
endfunction

% numerical integration
function p = nintegrate(x, fx)
    acc = 0;
    for i = [1:length(x)-1]
            p(i) = acc;
            delta_x = x(i+1) - x(i);
            acc += delta_x * fx(i);
    endfor
endfunction

% K : curvature
% T : torsion
function gvals = RungeKutta4(S, g, K, T, velocity, delta)
    for i = [1:length(S)-1]
            g_i = toVect(g(i));
            k1 = f(S(i), g_i, K, T, velocity);
            k2 = f(S(i)+delta/2, g_i+delta/2*k1, K, T, velocity);
            k3 = f(S(i)+delta/2, g_i+delta/2*k2, K, T, velocity);
            k4 = f(S(i)+delta, g_i+delta*k3, K, T, velocity);
            g(i+1) = toStruct( g_i + delta/6*(k1+2*k2+2*k3+k4) );
    endfor
    gvals = g;
endfunction

function drawPlots(xs, ys, zs, orig_xs, orig_ys, orig_zs)
    plot3(xs, ys, zs, ";reconstructed;", orig_xs, orig_ys, orig_zs, ";original;");
endfunction

function Phi = reconstruct(K, T, e0, n0, b0, alpha, beta, start, delta = 0.1, velocity = @()1)
    S = [alpha:delta:beta];
    g(1).e = e0;    % unit tangent vector
    g(1).n = n0;    % principal normal vector
    g(1).b = b0;    % binormal vector
    g = RungeKutta4(S, g, K, T, velocity, delta);

    e_x = cellfun(@(v)v(1), {g.e});
    e_y = cellfun(@(v)v(2), {g.e});
    e_z = cellfun(@(v)v(3), {g.e});

    Phi.x = nintegrate(S, e_x) + start(1);
    Phi.y = nintegrate(S, e_y) + start(2);
    Phi.z = nintegrate(S, e_z) + start(3);
    return;
endfunction

% works OK for this
function spiralNaturalParametrized()
    L = sqrt(2)*4*pi;
    e0 = [ 0,  1/sqrt(2), 1/sqrt(2)]';  % unit tangent vector
    n0 = [-1,          0,         0]';  % principal normal vector
    b0 = [ 0, -1/sqrt(2), 1/sqrt(2)]';  % binormal vector
    Phi = reconstruct(@()1/2, @()1/2, e0, n0, b0, 0, L, [1 0 0], 0.05);

    t = [0:0.05:L];

    drawPlots(Phi.x, Phi.y, Phi.z,
          cos(t./sqrt(2)), sin(t./sqrt(2)), t./sqrt(2));
endfunction

% another parametrization: huge error
function spiralAnother()
    L = 4*pi;
    e0 = [ 0,  1/sqrt(2), 1/sqrt(2)]';
    n0 = [-1,          0,         0]';
    b0 = [ 0, -1/sqrt(2), 1/sqrt(2)]';
    Phi = reconstruct(@()1/2, @()1/2, e0, n0, b0, 0, L, [1 0 0], 0.05, @(v)sqrt(2));

    t = [0:0.05:L];
    drawPlots(Phi.x, Phi.y, Phi.z, cos(t), sin(t), t);
endfunction

I included my code.
Any help is appreciated!
Update:
I have created another test which reveals the fact that the algorithm has some bug inside even when it deals with the natural parametric case:
function YetAnotherTest()
    L = 10*pi;
    e0 = [       0,    2/sqrt(13),   3/sqrt(13)]';
    n0 = [      -1,             0,            0]';
    b0 = [       0,   -3/sqrt(13),   2/sqrt(13)]';
    Phi = reconstruct(@()(2/13),        % curvature
                      @()sqrt(3/13),    % torsion
                      e0, n0, b0,       % initial frame
                      0, L,             % interval
                      [2 0 0], 0.05);   % start point and step size

    t = [0:0.05:L];

    drawPlots(Phi.x, Phi.y, Phi.z,
              2*cos(t./sqrt(13)), 2*sin(t./sqrt(13)), t*(3/sqrt(13)));
endfunction

Note: this is a test for $$Phi(t) = ( 2*\cos(t/sqrt(13)),  2*\sin(t/sqrt(13)),  3t/sqrt(13) )$$
which is a natural parametric curve.
If you take a look at this plot, you can see that the reconstructed curve is totally different than the original one.
Update2:
I have a suspicion that maybe I solve the differential equations wrong, and that causes the error. I have the differential equation system (my solver can be found in the RungeKutta4 and the f functions above):
Frenet–Serret formulas:
e'(t) =  K(t)*velocity(t)*n(t)
n'(t) = -K(t)*velocity(t)*e(t) + T(t)*velocity(t)*b(t)
b'(t) = -T(t)*velocity(t)*n(t)

given the initial values:
  e(0) = e0
  n(0) = n0
  b(0) = b0

where
K : curvature
T : torsion

Maybe I misuse Runge-Kutta...
Update3:
If I change my own Runge-Kutta algorithm to the built-in Octave function lsode and I rewrite the numerical integration code to use trapz (trapezoid rule), nothing changes. So I think the bug is not in these functions...But where?
Answer: Your TNB frame for the second parametrization is not going to be the same as it is for the first, but it looks like you are assuming that it will be.
Compute the Tangent, Normal and Binormal vectors for the parametrization of the helix given by $$X(t) = ( \cos(t), \sin(t), t )$$ and then set the values of L, e0, n0, b0 accordingly in your spiralAnother() function.
Comment: If my computations are right, these vectors are the same...
Answer: The Frenet-Serret formulas assume that the curve is parametrised by arc length. In part, this is easy to fix up. If you have a parameter p, then, for example
dT/dp = ds/dp * dT/ds

and
ds/dp = sqrt( de/dp * de/dp + dn/dp * dn/dp + db/dp * db/dp)

However the tricky part will be reparametrising the curvature and torsion functions. That is, if you have these functions as a function of arc-length, you will need to changethem to be functions of your new parameter p.


findall/3 incorrectly evaluating to false

Question: I'm creating a program which should allow search through a graph, but the function which should return a list of successor nodes is failing when a call to findall/3 evaluates to false. When I try the findall function on its own outside of the find_successors function it works perfectly, but for some reason inside the find_successors function it simply reads false. Stepping through with the graphical debugger I can even see it finding all the solutions. Here's the code:
find_successors(Start, Out) :-
    entity(Start),
    (findall(X, is_a(Start, X), O), append([], O, OL1); OL1 = []),
    (findall(X, is_a(X, Start), O), OL2 = O; OL2 = []),

    (findall(X, has(Start, X), O), append([], O, OL3); OL3 = []),
    (findall(X, has(X, Start), O), append([], O, OL4); OL4 = []),

    (findall(X, able_to(Start, X), O), append([], O, OL5); OL5 =[]),
    (findall(X, able_to(X, Start), O), append([], O, OL6); OL6 = []),

    (findall(X, used_to(Start, X), O), append([], O, OL7); OL7 = []),
    (findall(X, used_to(X, Start), O), append([], O, OL8); OL8 = []),

    append([OL1, OL2, OL3, OL4, OL5, OL6, OL7, OL8], Out).

entity(wings).
entity(fly).
entity(bird).
entity(legs).
entity(feathers).
entity('body covering').
entity(animal).
entity(dog).
entity(fur).
entity(aves).
entity(reptile).
entity(snake).
entity(scales).

f_is_a(bird, aves).
f_is_a(bird, animal).
f_is_a(snake, reptile).
f_is_a(snake, animal).
f_is_a(dog, mammal).
f_is_a(dog, animal).
f_is_a(feathers, 'body covering').
f_is_a(fur, 'body covering').
f_is_a(mammal, animal).
f_is_a(reptile, animal).
f_is_a(aves, animal).
is_a(X, H) :- !, f_is_a(X, H).
is_a(X, H) :- !, \+f_is_a(X, P), H = X.
is_a(X, H) :- !, is_a(X, P), is_a(P, H).

f_has(bird, wings).
f_has(bird, feathers).
f_has(bird, legs).
f_has(aves, wings).
f_has(aves, feathers).
f_has(aves, legs).
f_has(dog, legs).
f_has(dog, fur).
f_has(mammal, legs).
f_has(mammal, fur).
f_has(snake, scales).
f_has(reptile, scales).
has(X, H) :- !, f_has(X, H).
has(X, H) :- !, \+f_has(X, P), H = X.
has(X, H) :- !, has(X, P), has(P, H).

used_to(wings, fly).
used_to(legs, walk).

able_to(bird, fly).
able_to(bird, walk).
able_to(dog, walk).
able_to(X, Y) :- used_to(X1, Y), has(X, X1).

Answer: You keep on trying to reuse the same variable, but once a variable is bound, you can't use it again. So all these:
        here              here
         |                  |
         v                  v
(findall(X, is_a(Start, X), O), append([], O, OL1); OL1 = []),
(findall(X, is_a(X, Start), O), OL2 = O; OL2 = []),

(findall(X, has(Start, X), O), append([], O, OL3); OL3 = []),
(findall(X, has(X, Start), O), append([], O, OL4); OL4 = []),

(findall(X, able_to(Start, X), O), append([], O, OL5); OL5 =[]),
(findall(X, able_to(X, Start), O), append([], O, OL6); OL6 = []),

(findall(X, used_to(Start, X), O), append([], O, OL7); OL7 = []),
(findall(X, used_to(X, Start), O), append([], O, OL8); OL8 = []),

And every single one of these lines is very, very strange. I need to break it down to actually figure out what is going on. Taking just one of these:
(   findall(X, used_to(Start, X), O),
    append([], O, OL7)
;   OL7 = []
)

(this, btw, is how you should try to write disjunctions, otherwise they are easy to misread)
append([], A, B) is just the same as A = B.
Then, findall/3 always succeeds, even if there are no solutions; it just gives you an empty list!
?- findall(X, between(2, 1, X), Xs).
Xs = [].

So the whole thing is completely unnecessary, you can just as well throw away everything but the call to findall/3.
Note on the side: the disjunction you are using does not do what you think it does. Here is a small example:
?- ( A = 1 ; A = 2 ).

What do you think happens?
Comment: Per usual it's always the stupidest mistakes that I'm stuck on for long enough to embarrass myself on stack over flow... But I'm confused about your side note... After running that example it gave me exactly the answer I had expected it to, that is
`A=1;
A=2`
Answer: You should propose us a call to find_successors(Start, Out) and say the expected values.
Without it its difficult to say where your code is wrong but... some point in no particular order...
(1) append/3 concatenate unify the third argument with a list obtained concatenating the elements from the first and from the second list; so
append([], O, OL1)

with the first argument without elements in it, unify O with OL1 so is unuseful; you can write all the rows in the form
(findall(X, is_a(Start, X), O), append([], O, OL1); OL1 = []),

as
(findall(X, is_a(Start, X), OL1) ; OL1 = []),

(2) findall/3 return true also when unify the third argument with an empty list (when doesn't find value), so I don't see why do you write
(findall(X, is_a(Start, X), OL1) ; OL1 = []),

when the second part (OL1 = []) is never executed (if I'm not wrong) and when OL1 is unified with [] when findall/3 find nothing; I think you can simply write
findall(X, is_a(Start, X), OL1),

(3) I know only an append with three arguments; so I don't understand the meaning of
append([OL1, OL2, OL3, OL4, OL5, OL6, OL7, OL8], Out)

Your intention was to write
append([], [OL1, OL2, OL3, OL4, OL5, OL6, OL7, OL8], Out)

?
In this case, taking in count (1) and (2), you can write find_successors/2 simply as
find_successors(Start, [OL1, OL2, OL3, OL4, OL5, OL6, OL7, OL8]) :-
    entity(Start),
    findall(X, is_a(Start, X), OL1),
    findall(X, is_a(X, Start), OL2),
    findall(X, has(Start, X), OL3),
    findall(X, has(X, Start), OL4),
    findall(X, able_to(Start, X), OL5),
    findall(X, able_to(X, Start), OL6),
    findall(X, used_to(Start, X), OL7),
    findall(X, used_to(X, Start), OL8).

(4) I don't like cuts (!) so maybe I'm wrong but... why do you put ! as first element in is_a/2 ?
is_a(X, H) :- !, f_is_a(X, H).
is_a(X, H) :- !, \+f_is_a(X, P), H = X.
is_a(X, H) :- !, is_a(X, P), is_a(P, H).

If I'm not wrong, the cut in first clause (!, f_is_a(X, H)) disable the second and the third clause so, if f_is_a(X, H) fail, the second and the third clauses are never verified.
You're sure that your intention wasn't
is_a(X, H) :- f_is_a(X, H), !.
is_a(X, H) :- \+f_is_a(X, P), H = X, !.
is_a(X, H) :- is_a(X, P), is_a(P, H), !.

or better
is_a(X, H) :- f_is_a(X, H), !.
is_a(X, X) :- \+f_is_a(X, _), !.
is_a(X, H) :- is_a(X, P), is_a(P, H), !.

?
Or not cut at all?
(5) same cut problem with has/3; I suspect that
has(X, H) :- !, f_has(X, H).
has(X, H) :- !, \+f_has(X, P), H = X.
has(X, H) :- !, has(X, P), has(P, H).

is wrong and that your intention was
has(X, H) :- f_has(X, H), !.
has(X, H) :- \+f_has(X, P), H = X, !.
has(X, H) :- has(X, P), has(P, H), !.

or better
has(X, H) :- f_has(X, H), !.
has(X, X) :- \+f_has(X, _), !.
has(X, H) :- has(X, P), has(P, H), !.

Or not cut at all?


Alternative way to disable cron writing to /var/log/syslog

Question: There are answers that suggest changing this:
*.*;auth,authpriv.none           -/var/log/syslog
#cron.*                          -/var/log/cron.log

Into this:
*.*;cron,auth,authpriv.none      -/var/log/syslog
cron.*                           -/var/log/cron.log

This works, but it needs editing first line in rather precise manner, making complications when you want to automate configuration.
Yes, it is doable using sed or Salt file.replace state, but I would like to implement by appending/prepending rsyslog.conf file, or even better - by creating /etc/rsyslog.d/(00|99)-my-cron-log.conf to make it more robust and distribution-agnostic, though I do not follow rsyslog.conf configuration logic enough to make it working. I can't get "CRON" lines removed from syslog.log, except when using example above.
Is it even possible to disable cron to log into syslog.log without modifying package maintainer config lines?
Answer:
Is it even possible to disable cron to log into syslog.log without modifying package maintainer config lines?

No. The cron(8) from Debian based systems does provide a -L option that sets The log level a value of 0 disables logging but thg same is not available in EL based distros.
There is no real reason not to edit the files. I would probably just create a standard file and have my CM solution deploy it.
Comment: I do not want to disable cron logging completely, only from syslog.log (log to cron.log instead). Could I create "standard file" to be placed to /etc/rsyslog.d/(00|99)-cron.log? I just would prefer avoiding merging config files on system upgrade, for example.
Answer: As of 2021 at least, creating a conf file in /etc/rsyslog.d/ that is loaded before the default (in Debian derived systems) conf file /etc/rsyslog.d/50-default.conf does work. The name should be anything like (00-49)-name.conf.
For example, I created a file /etc/rsyslog.d/00-custom.conf:
# Don't overflow logs, suppress cron logs for tasks running every minute
# (needs to append "#minutely" as a comment at the end of such commands)
if $programname == 'CRON' and $msg contains '#minutely' then stop

# Put info level cron logs in a separated file.
cron.=info      /var/log/cron.log  # redirect if level is exactly 'info'
cron.notice     -/var/log/syslog   # keep sending to syslog if level is 'notice' or higher
cron.*          stop               # drop messages here to avoid default redirections

For changes to take effect immediately:
# systemctl restart rsyslog.service


Best span size for 12 x 2TB drives in RAID10

Question: We have just taken delivery of a new JBOD chassis, with 14 x 2TB NL-SAS drives - 2 have already been earmarked for enclosure spares, so we have 12 drives available.
I have several options for setting up the RAID10 array (unfortunately the head unit won't allow odd-numbered spans):

6 x 2-disk spans (12TB raw)
3 x 4-disk spans (6TB raw)
2 x 6-disk spans (4TB raw)

I would like to get the most usable space so 6x2 is looking favourable and 2x6 doesn't give anywhere near enough space, but I'm wondering if there's any performance or risk hit with going with 6x2 over 3x4.
I think that 6x2 is more risky because each span can only lose one drive - but are the two hot-spares enough to mitigate this?
Can someone sanity-check my reasoning or give me any pointers?
Head unit is an FC Infortrend ES-DS 3024 SAN, and workload will be Veeam backup storage if it makes any difference.
Comment: RAID 5 is dead.
Comment: Why would you not run these in a RAID5 if you are looking for space and redundancy
Comment: @Matt the disks will be under heavy bursted load, so the parity calculations will make RAID5 a non-starter, plus the rebuild time for a 2TB disk in RAID5 is way longer than I'd like :)
Comment: RAID 5 is only dead if you buy cheap and nasty drives.
Answer: I would use straight RAID 1+0 mirrors... e.g. 6 mirrored pairs striped together.
Keep your spares handy and be sure to monitor the array. Nothing more to it.


Commerce doesn't handle Sagepay Form Integration return

Question: So I'm using SagePay Form Integration on my site, but it has ceased to function correctly.
So on the Payment Stage of Checkout it says 'Use the button below to proceed to the payment server.'. Now I successfully complete a payment on the Sage Pay Testing Server and it comes back to the site URL checkout/order_id/payment/return attached with some GET vars.
The issue is that when it returns, checkout just displays 'Use the button below to proceed to the payment server.' again. The status of the order hasn't been updated and the user isn't ushered to the complete stage. Any idea why this is?
After further inspection it also seems that under Store > Orders it isn't logging the payment as it had previous. The order just remains at the payment stage in 'Shopping Carts'
tab of Admin > Store > Orders.
I'm having this exact same issue with all of the following versions:

7.x-1.0-beta2
7.x-1.0-beta1
7.x-1.x-dev

Your help would be greatly appreciated!
Answer: Turns out that Firebug Lite script in html.tpl.php was causing the issue:

Swiftly removed.


Joint distribution of least square estimates $(\hat\alpha,\hat\beta)$ in a simple linear regression model

Question:
Let $Y_1,Y_2,\ldots,Y_n$ be independently distributed random variables such that $Y_i\sim\mathcal N(\alpha+\beta x_i,\sigma^2)$ for all $i=1,\ldots,n$. If $\hat\alpha$ and $\hat\beta$ be the least square estimates of $\alpha$ and $\beta$ respectively, then what is the joint distribution of $(\hat\alpha,\hat\beta)$?

We consider the model $y=\alpha+\beta x+\epsilon$ where $y$ is stochastic and $x$ is non-stochastic.
We have the paired observations $(x_i,y_i)$ and we assume that the errors $\epsilon_i\stackrel{\text{i.i.d}}{\sim}\mathcal{N}(0,\sigma^2)$ for all $i$.
Define $s_{xx}=\sum (x_i-\bar x)^2,\,s_{yy}=\sum(y_i-\bar y)^2$ and $s_{xy}=\sum(x_i-\bar x)(y_i-\bar y)$.
From the normal equations we have $\hat\alpha=\bar y-\hat\beta\bar x$ and $\hat\beta=\dfrac{s_{xy}}{s_{xx}}$.
Transforming $\mathbf Y=(Y_1,\ldots,Y_n)\to(Z_1,\ldots,Z_n)=\mathbf Z$ such that $\mathbf Y=\mathbf{A\,Z}$ where $\mathbf A$ is an orthogonal matrix with its first two rows $\left(\frac{1}{\sqrt n},\ldots,\frac{1}{\sqrt n}\right)$ and $\left(\frac{x_1-\bar x}{\sqrt{s_{xx}}},\ldots,\frac{x_n-\bar x}{\sqrt{s_{xx}}}\right)$.
From the distribution of the $Z_i$'s, one can show that $\bar y\sim\mathcal N\left(\alpha+\beta\bar x,\frac{\sigma^2}{n}\right)$ and $\hat\beta\sim\mathcal N\left(\beta,\frac{\sigma^2}{s_{xx}}\right)$, both independently distributed of each other.
From this, one gets $\hat\alpha\sim\mathcal{N}\left(\alpha,\sigma^2\left(\frac{1}{n}+\frac{\bar x^2}{s_{xx}}\right)\right)$.
So we have the two least square estimates each having a univariate normal distribution. They are definitely not independent; I have found they have correlation $\text{Corr}(\hat\alpha,\hat\beta)=-\frac{\sqrt{n}\bar x}{\sqrt{\sum x_i^2}}$.
But how can I find the joint distribution of $(\hat\alpha,\hat\beta)$ from this? I cannot simply conclude that they are jointly normal. They are probably jointly normal but how does it follow?
The following related posts came up during a search, but don't quite get the answer I am looking for:

Are estimates of regression coefficients uncorrelated?

Are the estimates of the intercept and slope in simple linear regression independent?

Sampling distribution of regression coefficients

Edit.
The joint distribution of $(\hat\alpha,\hat\beta)=(\bar y-\hat\beta\bar x,\hat\beta)$ is bivariate normal simply because $\bar y$ and $\hat\beta$ are independent normal variables (details here). This follows from the property that different linear combinations of independent normal variables (and hence jointly normal variables) are themselves jointly normal.
Comment: I don't think that is a duplicate. This question seems to be actually asking how to derive the sampling distribution, especially, how to show that it's multivariate normal (if it is).   The duplicate, despite the title, seems to be more about conceptual differences between the sampling distribution and Bayesian posterior distributions of the coefficients
Comment: Since the estimates are *explicitly* a linear transformation of the responses, and it is well-known (and quoted extensively on this site) that linear transformations of multivariate Normal variables are Normal, the result follows from *any* multivariate normality assumption of the response.  I'm sure this point has been made in many threads, although it would be hard to search for a specific answer given the ubiquity of references to normality and regression.
Comment: In a linear regression you get the covariance matrix of all parameters, did you look at it?
Comment: [Here](https://en.wikipedia.org/wiki/Ordinary_least_squares#Assuming_normality) is the answer to your question. Do you understand it or need explanation?
Comment: A generalization of your question is asked and answered at https://stats.stackexchange.com/questions/133312.
Comment: @StubbornAtom Can you please answer it then? Because I am stuck in the same problem, I cannot get it how to conclude that $\hat{\alpha}$ and $\hat{\beta}$ are bivariate normal. I cannot understand the matrix notations used here.
Comment: @user587389 See edit.
Comment: @StubbornAtom "Different linear combinations of independent normal variables are themselves jointly normal"... Is there any proof or derivation?
Comment: @user587389 Easy to verify using moment generating functions or characteristic functions. This is a standard result concerning multivariate normal distribution, so I guess no proof should be required in this particular context.
Answer: In matrix notation, the least square estimates are given by
\begin{equation}
\hat{\theta} = \theta + (X^\prime X)^{-1} X^\prime U
\end{equation}
where $U \sim N_n(0, \sigma^2 \mathbf{I_n})$ with $I_n$ is an identity matrix of size $n$ (number of observations).
For the sake of argument, suppose that $X$ is known, then is follows that
\begin{equation}
E[\hat{\theta}] =  \theta + (X^\prime X)^{-1}X^\prime E[U] = \theta
\end{equation}
and
\begin{equation}
Var[\hat{\theta}] =  (X^\prime X)^{-1}X^\prime Var[U] X(X^\prime X)^{-1} =
\sigma^2 (X^\prime X)^{-1}
\end{equation}
Since $\hat{\theta}$ is a linear function of $U$, then it follows that
\begin{equation}
\hat{\theta} \mid X \sim N(\theta, \sigma^2 (X^\prime X)^{-1})
\end{equation}
In the univariate case, it follows that
\begin{equation}
\theta=\left[\begin{array}{c}
\alpha\\
\beta
\end{array}\right]
\end{equation}
and
\begin{equation}
X=\left[\begin{array}{cc}
1 & x_{1}\\
\vdots & \vdots\\
1 & x_{n}
\end{array}\right]
\end{equation}
If you solve $(X^\prime X)^{-1}$ then you know the covariance matrix for $\hat{\theta}$ and, hence, the covariance between $\hat{\alpha}$ and $\hat{\beta}$, which is the off-diagonal element of $\sigma^2 (X^\prime X)^{-1}$.
Answer: The joint distribution of model parameters in ordinary least squares (OLS) regression is described here and here. The formula is:
$$(\hat\beta - \beta)\ \xrightarrow{d}\ \mathcal{N}\big(0,\;\sigma^2Q_{xx}^{-1}\big)$$
where $$Q_{xx} = X ^T X$$, and $X$ is the design matrix.
Note, that in this case we do not assume that errors are Gaussian. In a large sample CLT kicks in, and we don't need the normality to obtain the distribution.
In your case $\hat\alpha=\hat\beta_0$ and $\hat\beta=\hat\beta_1$, and the design matrix $X$ has two columns: ones (intercept) and variable $x$, i.e. row $i$ is $X_{i0}=1,X_{i1}=x_i$
Comment: I am rather looking for this bivariate normal distribution stated in this post:https://stats.stackexchange.com/questions/61235/sampling-distribution-of-regression-coefficients?noredirect=1&lq=1. Is this the same as what you have written? Don't know if this is the answer I *should* be looking for though.
Comment: It's the same thing


Apache can't be restarted after changes to the configuration file

Question: I can't successfully configure the apache and php configuration files, can anybody help me in this way?

Apache 2.2.16 (win32-x86-no_ssl.msi) was installed into "C:\Apache2.2 "location.
Then PHP 5.3.3 (VC9 x86 Thread Safe) zip file was downloaded and extracted on "C:\php" location.
From "C:\php" I renamed the "php.ini-development" file into "php.ini"
"php.ini" file was opened with notepad, and modified as:
<code>  doc_root = "C:\Apache2.2\htdocs"
  extension_dir = "C:\php\ext"
</code>
The following lines were added to the Apache's configuration file "httpd.conf":
<code>  LoadModule php5_module "C:/php/php5apache2_2.dll"
  AddType application/x-httpd-php .php
  PHPIniDir "C:/php"
</code>
N.B.: Thanks all for comments and answer, but I can't reply none your comments, I don't know why. May be I'm not privileged to put any comment as I'm new here (is it the case?)! That's why I'm to edit my post to reply you all. Tell me what can I do?

@ jer.salamon: do you want me to post full httpd.conf file? It'll be longer then!
@ davr: the server started first, but when I configured those files, its never started again
@jer.salamon: did you mean keeping this way:
<code>          doc_root =
          extension_dir = "ext"
</code>
It not yet restared!
Comment: Do you have any more info you can give? What does the apache error log say?
Comment: can you post in a script window the whole httpd.conf file
Comment: @Sharifhs
You told us what you have done, but you haven't said anything at all what went wrong. Does the server start? It serving pages? Are PHP files being run or just returned as source code? Is it giving any errors? etc etc etc. Without more info, no real help can be given besides wild guesses.
Comment: Please post the relevant contents of your apache error log file.
It is most probaly located at C:\Apache2.2\logs\YOUR_HOST_NAME-error_log
Answer: try leaving your doc_root blank and putting ./etc for your extensions.
Answer: I had this problem for ages until I spotted something on apachelounge http://www.apachelounge.com/viewtopic.php?t=3180
A couple of posts mention disabling certain extensions, so I had a go.  For me it was postgre, commenting out this line in php.ini worked:
extension=php_pgsql.dll
Hope it does for you too.
Answer: Can you give a better explanationof what you mean by by "can't be restarted" ? Do you get any error messages? Have you checked the error log file?
Try starting a shell (cmd.exe) and running 'httpd -t' (tests config file - any messages? What about 'httpd -X' (NB unless the bin dir is on your path you'll need to chdir to where httpd.exe is located first.


Do I need to have a running ipfs node to be able to store and retrieve files?

Question: I have a basic flask application that stores and retrieves images. I want to store those images on ipfs by simply posting a request to the application which is probably going to be hosted on Heroku. So, I wouldn't have a running ipfs node. Is this possible ?
Answer: You can use an IPFS Gateway to access files without running your own node.
When you pin an IPFS file to your own node and shut it down, your files will not be accessible anymore by yourself or others unless another node pins them as well and stays online.
You can pay IPFS file hosters to pin your file on their nodes, Cloudflare and Eternum are two of them.
Here is a list of more: https://www.reddit.com/r/ipfs/comments/9pb5pf/are_there_any_ipfs_file_hosting_services/
Answer: There's pinata as a pin service - with a free tier to get started. :)
Files can be accessed via a public gateway, like ipfs.io or the Cloudflare one.


Comando exit em PL/SQL

Question: Eu reparei que o comando exit funciona igual a um break, ele para de executar o bloco atual e passa para o próximo, mas qual comando pode parar todo o procedimento em PL/SQL?
Answer: De acordo com a documentação, para encerrar a execução da rotina você deve usar o comando RETURN.
Retificando uma coisa que você mencionou, o comando Exit seria para encerrar execução de laços.

The EXIT statement forces a loop to complete unconditionally. When an EXIT statement is encountered, the loop completes immediately and control passes to the next statement

Em tradução livre:

O comando EXIT força um laço a ser concluído incondicionalmente. Quando a declaração EXIT é econtrada, o laço é concluido imediatamente e o controle é passado para a linha de comando posterior ao laço

Espero que isso ajude.

Comando exit em PL/SQL


How to create custom buttons with clickable area defined by coordinates ? (Ionic)

Question: I want to build an application where you need to click on a body composed by muscles like this one :
.
I don't know if it's possible to click on each muscles with a shape defined by coordinates.
Answer: Yes, it's possible to set an event on parts of the image using coordinates.
Just look into this live ionic project developed by @Crackroach
https://stackblitz.com/edit/ionic-dqzfse
Note: solar-system image takes little time to load


How to prove the following inequality? (related to no-arbitrage conditions)

Question: I'm working through a practice book on mathematical finance, but struggling to prove part of a question on no-arbitrage conditions.
In the problem, I'm first given $K_1 < K_2 < K_3 $. Then, the book claims that the following relationship: $x_1 (S - K_1) - x_2 (S - K_2) + x_3 (S- K_3) \geq 0, \forall S \geq 0$,
holds if and only if the two conditions are satisfied:
$x_1 - x_2 + x_3 \geq 0$ and $x_1 (K_3 - K_1) - x_2 (K_3 - K_2) \geq 0$.
For the life of me I can't seem to prove why this is the case! I know it should be basic algebra but I'm really struggling for some reason. Anyone have any tips?
Comment: @JohnOmielan: Nonsense means there is no such arbitrage condition for forward contracts with nonnegative forward price.  The question itself is not nonsense.  It still takes some effort to prove the conditions. Others may find this useful -- although it is entirely up you. Undelete and I will give it an upvote.
Comment: @RRL I tried to answer the question as it's stated, but was only able to prove the "if" part always holding in the case where $K_3 \le 0$. Now I understand why I wasn't able to succeed as I know nothing about arbitrage so I didn't realize the correct form of using $\left(S - K_j\right)^{+}$ instead. Since I didn't answer the intended question, and I don't think there's much value for anybody to read my solution (as you say, "this is nonsense"), I am deleting it.
Comment: @RRL Thanks for the comment & support. I only proved part of it, but perhaps it might be of some use for a few people. As you requested, I have undeleted my solution. Also, I am going to add a comment at the top that it's trying to answer the question as stated, not as it was intended.
Comment: @JohnOmielan: I would not get too concerned. There are relatively few questions here with the finance tag and many are elementary (compound interest, etc.) QuantitativeFinance.SE is usually the best place to ask, but I am always happy when something interesting comes up here.
Answer: This will make sense for a portfolio of three call options with common expiry and with strike prices $0 < K_1 < K_2 < K_3$, where we are long $x_1 > 0$ options struck at $K_1$, short $x_2 > 0$ options struck at $K_2$ and long $x_3> 0$ options struck at $K_3$.
The payoff of this option portfolio at expiration for underlying price $S$ is
$$V(S) = x_1(S-K_1)^+ - x_2(S - K_2)^+ + x_3(S - K_3)^+$$
where $(S-K_j)^+ = \max(S-K_j,0)$ the payoff of a standard European call option.
For $0 \leqslant S \leqslant K_1$ we have $V(s) = 0$.
For $K_1 \leqslant S \leqslant K_2$ we have $V(S) = x_1(S - K_1) \geqslant 0$.
For $K_2 \leqslant S \leqslant K_3$ we have $V(S) = x_1(S - K_1) - x_2(S- K_2)$. This is a linear function joining the points $(\,K_2,\,x_1(K_2 - K_1)\,)$ and $(\,K_3,\,x_1(K_3-K_1)- x_2(K_3-K_2)\,)$.
Consequently we have $V(S) \geqslant 0$ for $K_2 \leqslant S \leqslant K_3$ if and only if
$$\tag{*}x_1(K_3-K_1)- x_2(K_3-K_2) \geqslant 0$$
For $S \geqslant K_3$ we have
$$V(S) = x_1(S- K_1) - x_2(X- K_2) + x_3(S- K_3) \\ = x_1(K_3-K_1)- x_2(K_3-K_2) +(x_1 - x_2 + x_3)(S - K_3),$$
and assuming that inequality (*) holds we have $V(S) \geqslant 0$ for all $S \geqslant K_3$ if and only if
$$\tag{**} x_1 - x_2 + x_3 \geqslant 0$$
Comment: Yes!!!!!!!!! This all makes sense now! You're certainly right about the payoffs, it's obvious now to me that it's a typo. Thank you!
Comment: @DavidLoungani: You're very welcome. Glad it is clear now.
Answer: Note what you state seems to require that $K_3 \le 0$. I later found that this is due to the question statement not quite being correct. Please read RRL's answer for a solution to the question as intended. Nonetheless, the following does prove part of the conditions for options, but not arbitrage.
Using this, note that
$$x_1\left(S - K_1\right) - x_2\left(S - K_2\right) + x_3\left(S - K_3\right) \ge 0 \tag{1}\label{eq1}$$
becomes after expanding the terms, collecting all those using $S$ and factoring it out to get that
$$S\left(x_1 - x_2 + x_3\right) - x_1 K_1 + x_2 K_2 - x_3 K_3 \ge 0 \tag{2}\label{eq2}$$
To show the "if" part, if
$$x_1 - x_2 + x_3 \ge 0 \tag{3}\label{eq3}$$
then
$$S\left(x_1 - x_2 + x_3\right) \ge 0 \tag{4}\label{eq4}$$
based on $S \ge 0$. With the second condition,
$$x_1\left(K_3 - K_1\right) - x_2\left(K_3 - K_2\right) \ge 0 \tag{5}\label{eq5}$$
expanding it, collecting the terms using $K_3$ and then factoring out $K_3$, gives
$$-x_1 K_1 + x_2 K_2 + K_3\left(x_1 - x_2\right) \ge 0 \tag{6}\label{eq6}$$
From \eqref{eq3}, and assuming that $K_3 \le 0$, we get
$$x_1 - x_2 \ge -x_3 \Rightarrow K_3\left(x_1 - x_2\right) \le -K_3 x_3 \tag{7}\label{eq7}$$
Reversing the inequality shows this can be substituted into \eqref{eq6} to give that
$$-x_1 K_1 + x_2 K_2 - x_3 K_3 \ge 0 \tag{8}\label{eq8}$$
Putting \eqref{eq4} and \eqref{eq8} together gives \eqref{eq2}. Note I didn't use anything regarding the relationship of $K_1$ or $K_2$ in terms of $K_3$ here. As for the requirement for $K_3 \le 0$, note that if $x_1 = x_2 = 0$, then \eqref{eq3} requires that $x_3 \ge 0$. Setting $S = 0$ causes \eqref{eq2} to become
$$0 - 0 + 0 - x_3 K_3 \ge 0 \tag{9}\label{eq9}$$
but if $x_3 \gt 0$, then $K_3 \leq 0$. As the OP has stated in a comment to this answer that

the $K$'s represent different "strike prices" which would in fact generally be greater than $0$

there must be some other conditions or restrictions I'm not aware of, or possibly one of the statements is not presented correctly. For now, this is the best I can do here.
For the "only if" part, I believe the easiest way to show it would possibly be to provide an example where one of \eqref{eq3} or \eqref{eq5} don't hold, then \eqref{eq2} doesn't hold either.
Comment: @DavidLoungani I see now why my work didn't solve your problem appropriately. With the appropriate additional conditions that RRL states, everything will work then, as shown in RRL's answer.
Comment: Thank you for your response! Unfortunately, I don't think we can assume the K's are less than 0. It's not explicitly stated in the problem, but the K's represent different "strike prices" which would in fact generally be greater than 0.
Comment: @DavidLoungani Thanks for the additional information. I edited the answer to give an explicit example that shows what you're asking only works in general if $K_3 \leq 0$. Thus, as I stated, there must be some other conditions or restrictions, or something is wrong. Please check to see if that is the case. Regardless, you could likely use similar techniques to what I've shown to solve this, so perhaps you can do it on your own. Good luck with it.
Comment: Thanks John, I follow your argument and I think I'm going to actually reach out to the textbook authors to see what they have to say. As you mentioned, I'm guessing there is some implicit assumption which is being left unstated.
Comment: @DavidLoungani You are welcome. Note that nothing is stated about the $x_1$, $x_2$ and $x_3$, so it seems strange that they are used unless they have some specific meaning. I have a feeling that there are some additional conditions on these values which will cause everything to work properly.


What's the algebraic property where you can flip the fractions in an equation?

Question: Earlier in algebra, we spent over 20 minutes trying to figure out
$$ \frac{1}{R_1} + \frac{1}{R_2} = \frac{1}{R_e} \,\,\,\, \text{solve for }R_2 $$
when the teacher said "What you start out with is the same as what you learned in pre-algebra
$$
\frac{1}{R_1} + \frac{1}{R_2} = \frac{1}{R_e}
$$
subtract $\frac{1}{R_1}$ from both sides:
$$\frac{1}{R_2} = \frac{1}{R_e} - \frac{1}{R_1}$$
and then the math gods said 'you may flip as long as all are flipped'"
$$R_2 = R_e - R_1$$
What is the name of this algebraic property?
(Sorry, I couldn't find any good tags for use here.)
Comment: I'm afraid it's not true. That's probably why you couldn't remember it
Comment: Whatever math God told you that is wrong =]
Comment: The property is named "error".  Sometimes called a variation of the freshman's dream.  In general $\frac{1}{\frac{1}{R_1}-\frac{1}{R_2}} = \frac{R_1-R_2}{R_1 R_2}.$
Comment: @David Mitra Be careful, sometimes students misinterpret the instructors =P
Comment: @Nick - I think the "generalized freshman's dream" would be: All operations are linear. This certainly fits into that.
Comment: There is no such algebraic property. Now both sides of an equation can be reciprocated (for values of variables such that the sides of the equation are not zero). However, that is not an algebraic property, but simply the consequence that both sides of an equation denote the same number, and the same operation is done to that number on both sides. Algebraic properties usually tell us that certain *apparently different* patterns of operations are actually equivalent.
Comment: @deinst: I thought freshman's dream was $(a+b)^n = a^n + b^n$ . How is this a variation to it?
Answer: This is not an algebraic property, because it is not true.
For example, let $R_2=R_1=2$ and $R_e =1$. Then, $$\frac{1}{2} = \frac{1}{1} - \frac{1}{2}$$
but
$$2 \neq 1 - 2$$
Answer: You can flip if you flip correctly. Flipping both sides of
$$\frac{1}{R_2} = \frac{1}{R_e} - \frac{1}{R_1}$$
gives you
$$ R_2 = \frac{1}{\frac{1}{R_e} - \frac{1}{R_1}}$$
Well, that's not quite right: more pedantically, flipping both sides gives
$$ \frac{1}{\frac{1}{R_2}} = \frac{1}{\frac{1}{R_e} - \frac{1}{R_1}}$$
but we know that the left hand side of this is the same thing as $R_2$. (at least in the current setting, where $R_2$ is known to be nonzero)
Answer: Yes, you can "flip", so long as the two sides are single fractions: from
$$
\frac{1}{R_2}=\frac{R_1-R_e}{R_1R_e}
$$
you can rightly deduce
$$
R_2=\frac{R_1R_e}{R_1-R_e}
$$
Note that, in general,
$$
\frac{R_1R_e}{R_1-R_e}\ne R_e-R_1
$$
Indeed the equality would imply
$$
R_1R_e=-R_e^2+2R_1R_e-R_1^2
$$
or
$$
R_1^2-R_1R_e+R_e^2=0
$$
Since your numbers are by hypothesis non zero, this would imply
$$
\left(\frac{R_1}{R_e}\right)^2-\frac{R_1}{R_e}+1=0
$$
or, setting $t=R_1/R_e$, $t^2-t+1=0$. This equality is not true for every real $t$. So your conclusion is really wrong.
Answer: You can't just flip all willy-nilly.
If what you said was true, then the resistance of electrical circuits in series and parallel connections would be the same! That just isn't true.
$$\frac{1}{R_1} + \frac{1}{R_2} + \frac{1}{R_3} + \dots + \frac{1}{R_n}\mathbf{\neq} \frac{1}{R_1 + R_2 + R_3 + \dots + R_n}$$
Fastest way to see this is by setting $R_1 = R_ 2 = \dots = R_n = R$ (say)
Does it feel like $\frac{n}{R} $ and $\frac{1}{nR}$ are the same?
Now, you see. You must either change your math gods or listen to them more carefully.
The flipping property is called the Invertendo:
$$\frac{a}{b} = \frac{c}{d} \iff \frac{b}{a} = \frac{d}{c} $$
There are many ways you can realize it and I leave it as an exercise to you to try.
The simplest way is by raising both sides of the equation to $-1$ :
$$\frac{a}{b} = \frac{c}{d}
\implies \left(\frac{a}{b}\right)^{-1} = \left(\frac{c}{d}\right)^{-1}
\implies \frac{a^{-1}}{b^{-1}} = \frac{c^{-1}}{d^{-1}}
\implies \frac{1}{a} \cdot \frac{b}{1} = \frac{1}{c} \cdot \frac{d}{1} \implies \frac{b}{a} = \frac{d}{c}$$

The following is the best approach to your question:
$$
\frac{1}{R_1} + \frac{1}{R_2} = \frac{1}{R_e}\\
\implies \frac{1}{R_2} = \frac{1}{R_e} - \frac{1}{R_1}
= \overbrace{\frac{R_1 - R_e}{R_1 R_e}}^{\text{Taking LCM}} \\
\implies \underbrace{R_2 = \frac{R_1 R_e}{R_1 - R_e}}_{\text{Applying Invertendo}}$$


Simple websocket server in Python for publishing

Question: I have a running CLI application in Python that uses threads to execute some workers. Now I am writing a GUI using electron for this application. For simple requests/responses I am using gRPC to communicate between the Python application and the GUI.
I am, however, struggling to find a proper publishing mechanism to push data to the GUI: gRPCs integrated streaming won't work since it uses generators; as already mentioned my longer, blocking tasks are executed using threads (subclasses of threading.Thread). Also I'd like to emit certain events (e.g., the progress) from within those threads.
Then I've found the Flasks SocketIO implementation, which is, however, a blocking execution and thus not really suited for what I have in mind - I'd have to again execute two processes (Flask and my CLI application)...
Another package I've found is websockets but I can't get my head around how I could implement this producer() function that they mention in the patterns.
My last idea would be to deploy a broker-based message system like Redis or simply fall back to the brokerless zmq, which is a bit of a hassle to setup for the GUI application.
So the simple question:
Is there any easy framework that allows to create a server-"task" in a Python that I can pass messages to publish to?
Answer: For anyone struggling with concurrency in python:
No, there isn't any simple framework. IMHO pythons' concurrency handling is a bit of a mess (compared to other languages like golang, where concurrency is built in). There's multiple major packages implementing this, one of them asyncio, but most of them are incompatible. I've ended up using a similar solution like proposed in this question.


7/6 no 3 or 13 no 3, 9, 11; which chord name is more correct (if any)?

Question: Which name is better, more correct?
C13 is C E G Bb D F A.
If we remove the third, ninth, and eleventh, we get C G A Bb.
Would C13 no 3, 9, 11 be an correct name? I've found that same chord named as C7/6 no 3 (dominant seventh, added sixth, no third).
Which one makes more sense?
Answer: I wouldn't go with either of the names you suggested. When you use "no" chord notation typically you are changing the intended harmony of a chord to something the chord symbol was not ment to represent.
Let's look at what we have:
 C G A Bb
I'm assuming the C is the bass note. It would  be a stretch to call this any type of C chord because not only is there no 3rd, but there is also no 2nd or 4th. There is very rarely a chord with an omitted 3rd that is not suspend.(Besides a power chord which this is not.)
If we look at this chord as some kind of A chord it makes much more sense because we can stack the chord in thirds now and have it make sense:
A C _ G Bb
We still have no 5th, but the 5th is commonly omitted in larger chords.  A to C makes a minor 3rd, the G is a minor 7th and the Bb is a b9. Because the C is in the bass, we will have to notate the chord in slash notation so we get:
Am7b9/C
Still a lengthy name, but it describes the function of the chord better than C13 no 3, 9, 11 where it is very odd to omit 3 notes in a chord.
Another thing to note is it is typical in a 13th chord to omit the 9th and 11th as they are optional. So the suggested name could be reduced to C13 no 3, but still it is odd to omit a 3rd without some kind of sus.
Answer: If we remove the third, ninth and eleventh from C13 we get C G Bb A,
so I guess the most correct term would be  C13 no 3, 9, 11 or just C13 no 3(I think that a C13 chord doesn't necessarily have a 9th or 11th,but I'm not sure).
But C G A Bb would be C6/7 no 3, because the A here is the 6th, not the 13th. It would have to be one octave higher in order to be the 13th.
Answer: Given the notes C G A Bb, I would think of it as a Gmadd2 (no5)/C
or taking the notes in the order which would come from C13 removing the third, ninth, and eleventh [C G Bb A] I would think of it as a Gm add9 (no 5)/C.
Answer: There's no "correct" way to exactly name this chord using the standard nomenclature.
Comment: Did you mean there's no single correct way, or that the chord cannot be named? A bit more explaining would make the answer more valuable.
Comment: Must disagree that dom7 chords don't need a 3. 5 can be dispensed with, but not 3 - that tells if it's maj. or min.
Comment: I meant that there's no nomenclature (as far as I know) that names this chord in any useful way, other than simply spelling it out as C G A Bb.  But if I had to name what it sounds like to me, I'd say Cb7 plus 6.  The feeling of b7th chords doesn't really need a third, and the A just sounds to me to be the sixth degree thrown in for a bit of dissonance.  I don't think you can get away with calling that "C 13".  But of course that's just my personal take.  I don't see any point in trying to define the "best" way of describing this chord in a very oversimplified system.
Comment: "*I don't see any point in trying to define the "best" way of describing this chord in a very oversimplified system.*" The asker probably sees a point to it, since they went to the trouble to ask. It seems like this answer is really saying, "I don't want to answer this question and I don't think anyone else should either".
Comment: @Tim- we'll just have to agree to disagree.  Whether the third of a chord is major or minor is almost always implied by the scale.  If you have the chord progression, spelled out from below in C major, of cge'g'/Ggd'f'/cgc'e', doesn't the second chord sound like a dom7 to you?
Comment: @ToddWilcox- not at all.  I'm just saying that standard nomenclature doesn't have a really useful name for this chord.  If you think it does, what is it?
Comment: @ScottWallace a third is never implied. Ever hear of a Picardy third? Also how many songs written in C use both Dm7 and D7. It's quite a lot.
Comment: @Dom- I disagree.  Of course there are Picardy thirds and other accidentals, but If a melody is in C major you expect E and not Eb.
Comment: @ScottWallace it's not implied which is my point. The only note that can be implied is a perfect 5th due to its place in the harmonic series. You can't assume notes are there that aren't. There are always the possibility of the harmony drastically changing. In fact, going or borrowing from a parallel key or mode is extremely common. Also remember the harmony dictates what set of notes make the most sense to play at that time regardless of what key you are in.
Comment: @Dom- I suspect we're thinking about different kinds of music.  Sure, in many modern forms of music, there are lots of notes outside the key signature (if there is a key signature), and what you say is true, but for most folk and popular music, you don't expect accidentals.
Comment: I'd just like to add to my answer, which was perhaps not clear: I have nothing against people trying to find a useful notation for this chord.  I just wanted to point out that it's not something where we should agonize about the "correct" notation, because any standard abbreviation such as C 13 is going to have to be ambiguous.
Comment: @ScottWallace, Maybe incorporate your comments into the answer?