Memorizing fret board intervals

Question: Fret board intervals;  When  playing and looking at the guitar fretboard, is it best to mentally use  pictorial patterns,
(chords, scales, modes, arpeggios) to help in the (my) solo direction, or counting intervals?
In other words what would be the proper or better way to look at the frets on the guitar neck fretboard with all of the options of cords and modes, scales and so forth, I have a hard time counting fret Intervals from string to string.
I know the tuning of standard 440 and I know string to string is tuned to the fourth except the B. It's the visual part I have problems with,and when I am soloing I forget all the other options,  is there a better way to memorize and reflect coherently to speed up my direction when soloing I mainly play old school and the 12 bar blues.
Answer: My students generally work on patterns. Once a scale shape is learned, the intervals are of academic value. And that third between G and B strings means you need to be aware that intervals there are different from those on other adjacent strings. So, patterns work best.
That apart, those patterns are moveable to play in other keys, so they work well.
The more you play, the more you'll hear the intervals and associate them with positions. Counting up frets and strings is too slow anyway when you're in the middle of a solo!
Comment: _Once a scale shape is learned, the intervals are of academic value_ - Respectfully disagree: When you think about the **music** and not just the patterns, you open yourself to all sorts of new possibilities. Patterns tend to lock you into a rut. I played with patterns for years - then I had a teacher who forced me not to use patterns but to always think about the intervals and the notes for that reason.
Comment: _patterns are moveable to play in other keys_ - notes and intervals are infinitely more "movable": they work **everywhere** - a pattern only works for certain playing positions on that instrument. On bass, for example, open and first positions are very important, and their fingerings are  different than when you play further up on the neck.  If you only learn the "portable" pattern and move up and down the fretboard, if you want/need to play open position you will be lost.
Comment: @Stinkfoot - I suppose if that's a problem for you, and others, you could always sort out patterns from open strings *not* using your index finger. In other words, play 1st fret with middle; then those patterns will be the same higher when you use the index in place of the nut. Personally, I rarely use open strings, can't see the point. And instead of bottom E, I'll probably play it on the B string, unless of course, I've a drink in my left hand...! But I tend to use my right for that. Thank heavens for hammer-ons.
Comment: _sort out patterns..._ That wouldn't solve the biggest challenge: play a note without fretting and no fret to orient you: Your patterns are built on a series of notes on the fretboard. Thanks to 'maestro', I use open strings a lot. If I can play in open or first position on the E or A string, I do-that means almost everything. D and Eb don't work well down there-end up with a lot of shifting/moving too far up on the G string - best reason to use a 5.  _I rarely use open strings, can't see the point_ - maybe it's the opposite: you don't see the point because you rarely use them. :)
Comment: @Stinkfoot - I understand what you say. You could sort of press the nut with index, to retain the pattern. What's 'maestro'? Have you come across 'slingshot', I think it's called. Special tuner that can drop a string down by one or two frets.
Comment: _press the nut with index.._ - could mess up the resonance of the open string with that - a big deal: the thing about open strings is that they have so much depth and sustain. I raise my finger a drop and let it **ring out** - very powerful. I mentioned playing _The Thrill is Gone_ (Bm) on a 4 off the low B( fret 2 of A string): Your IV root - E, b7 - A, and b3-D are all open strings right there in front of you - you'll see what I mean. ( I don't believe it's recorded that way...) "Maestro"- my teacher. Jazz pro-plays LOTS of upright, also a Pbass- showed me how he does some things on upright.
Comment: _'slingshot'_ - there are a few different gadgets - some up by the nut, some down by the bridge. I never used them- once the V came along electric players didn't need that. But in Orchestras a lot of upright players use something like that to get lower registers in some symphonic music. I prefer a 4, but when I used to gig, I always played a 5, mostly for the ease of playing in D, E and F without having to think. Now I mostly play jazz with friends and I play a 4 - not much material in D, F and Bb I've got down in open position. Eb I play almost completely downwards, from fret 6 on A string.
Answer: Learn visual patterns but also learn the notes and the theory behind those patterns.
One thing I'd be careful of is relying too much on visual patterns. The transposable nature of the fretboard makes it so easy for us to get quick results but it becomes a crutch in the long term.
It's certainly worth learning some visual patterns at first and the only answer is memorization. Sure count or use some cheatsheet or whatever to learn but eventually you'll have to memorize it. Maybe start with octaves and that will give you a bit of a marker. Then within those octaves start learning smaller intervals like 3rd or 5ths.
But don't only do that. I'd learn some scales and arpeggios and say the notes out loud (or at least think them) while you're playing. Also try saying the scale/chord degrees instead of just the note name. That will help your soloing, your knowledge of the fretboard, and your knowledge of what notes are in what keys/chords all at the same time.
A common problem is that it can be tough to truly learn the notes if you're already dependent or allow yourself to become dependent on visual patterns. And a practice technique to combat that is to purposely handicap yourself in a way that forces you to break out of those patterns. Try playing a scale only on one string or using one finger or using a fingering system that you don't normal use. It will force you to think about the notes a bit more.
Comment: You might not. I do. And many don't but I'd argue that they're missing out. For instance you mentioned "moving it all a couple frets". Shapes make you rely on movement up or down the neck but that's only one dimension. Why not use both? And, no, when I'm playing I'm not always thinking about note names. Ideally I'm not thinking about anything. My philosophy is that you learn things well enough in practice that it should just come out when improvising. But when I *do* think about something it's usually the notes especially in relation to the current/next chord tones.
Comment: And a long term crutch is a problem—in the metaphor—because it keeps what could be an otherwise healthy leg from getting stronger. In reality it's a problem because 1) It enables noodling on autopilot without truly learning the fretboard or the theory behind what you're playing. It doesn't *have* to prevent that learning but in practice it frequently does. 2)  People tend to play the same things over and over again when relying only on visual patterns. Again, I don't think visual patterns are all bad—they're even essential—but you shouldn't stop there.
Comment: Do we actually think in terms of note names when soloing? I don't believe we do. It's far more about next few notes, so patterns will sort out that. If I have to solo in a different key, I certainly won't be thinking note names, more likely moving it all a couple of frets. Why should a long term crutch be a problem?
Comment: _...try playing a scale only on one string or using one finger or using a fingering system..._ - great advice.

Memorizing fret board intervals


ACF of the errors

Question: For revision, I am working out a multiplicative model for sales data, and then conducting a simple error analysis (actual sales - forecasted). I understand the process but in my lecturer's mark scheme he has put 'You should mention the usefulness of the ACF of the errors'. How would I go about this? My error results are:
<code>Errors: -7.75 1.67 -2.26 0.776 3.88 4.61 6.024 3.112 -0.49 -1.44 -7.688 2.448
</code>
Answer: Presumably this is a time-series model.
What does the auto-correlation function show in general?

 The sample auto-correlation function of a variable shows the correlation of the variable with itself at various time lags. If you calculate it for the residuals it shows the correlation of the residuals with themselves at various lags. (It's not a correlation with the time period—that would be a trend.)

What assumption that you make about the errors in your model is relevant?

 That the errors are uncorrelated. The residuals from your model are estimates of these errors, so should be (more or less) uncorrelated—as you say in your comment, there should be no clear patterns in the ACF of the residuals.
Comment: Nifty use of hidden "spoiler-quote" formatting for a `self-study` question.
Comment: Yes, it's a time series. ACF compares real data with lagged data? So it shows the correlation between a variable (sales data) to the time period?? Then error analysis is done to ensure that there are no clear patterns left and then compared with the raw data, the relative errors are not large in magnitude. Just not sure how to do or show this??
Comment: @Michael: Are you also asking how to calculate the ACF of the residuals, as well as how it's useful?
Answer: In general, the residual autocorrelation function (acf) is a tool used at the diagnostic-checking stage of the Box-Jenkins methodology. The residual acf is just like any other estimated acf except for the fact that it's the residuals from an estimated model that are used to calculate the autocorrelation coefficients rather than observations from the time-series under investigation - sales data in this particular case.
The residual acf helps the model builder answer the following question: has the estimated model been properly formulated? If the model is said to be adequate then the estimated residuals should be uncorrelated on average. So, by inspecting the residual acf, the model builder can find out whether or not the autocorrelation coefficients are all statistically zero. If they are, the model has been properly constructed. If not, the residual acf signals that perhaps there exists a more appropriate model for the time-series.
The residual acf actually plays a dual role in this regard. Not only does the residual acf help with deciding whether or not the model has been properly built (that is, statistically adequate), but it can also be used to reformulate the model. Remember, the Box-Jenkin's methodology is an iterative process.
To reformulate the model based on information obtained from the residual acf, one adds the coefficient implied by the residual acf to the model from which the residuals have been derived. For example, let's say we build an AR(1) model and estimate the residual acf. If the residual acf contains a single significant spike at lag one, then this pattern suggests adding an MA(1) term to the model. This results in a reformulation of the model as an ARMA(1,1) instead of an AR(1).
In conclusion, the residual acf is a very useful tool for providing diagnostic checks, and, in addition, it can prove useful even at the identification stage (or reformulation stage) of the model building process.
Note: if you need it, the residual acf based on the errors provided is shown below. Maybe as an exercise you could try to calculate the residual autocorrelation coefficients and the confidence interval shown in the plot. Then, provide an interpretation of the graph bearing in mind what it allows you to infer about the model (that is, mention its usefulness).

ACF of the errors


Why do I need PrimeFaces Maven Repository to use a theme?

Question: Why do I need PrimeFaces Maven Repository, when using all-themes dependency from PrimeFaces?
When I just use one dependency I got no errors and can work.
But when I use all-themes I get missing artifact org.primefaces.themes:all-themes.jar:1.0.10, but why?
<repositories>
    <repository>
        <id>prime-repo</id>
        <name>PrimeFaces Maven Repository</name>
        <url>http://repository.primefaces.org</url>
        <layout>default</layout>
    </repository>
</repositories>
<dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>5.0</version>
</dependency>
<dependency>
        <groupId>org.primefaces.themes</groupId>
        <artifactId>all-themes</artifactId>
        <version>1.0.10</version>
</dependency>

Comment: May I know which version of `primefaces` you are using?
Comment: Could you please add your `maven` dependencies for primefaces in question? so that it will be more clear to understand
Comment: I am using Primefaces 5.0
Answer: Maven's default repository is "maven central". There are a lot of artifacts in there, but some vendors may not have put their artifacts there and primefaces is one of them. Maven will look for the jar in maven central and won't find it. If you don't specify that it should also look in the Primefaces Maven Repository (which does have the artifact), it can't find the artifact.
Comment: I think you don't need the primefaces repository. The primefaces artifacts are in maven central: http://search.maven.org/#search%7Cga%7C1%7Cprimefaces - it may be new the brand new versions are not or only a few days later.
Snapshot versions are probably never in maven central (if you plan do early adopt new releases). Then you'll need the additional repository.
Comment: You might be right about that. I think to use that version, he'd have to put org.primefaces.extensions as the groupId and he'd have to use version 1.0.8.
Comment: I honestly don't know, it's just that there's an artifact called all-themes in org.primefaces.extensions in maven central (ie, that wouldn't require adding the repository). If you've added the repository and it's working, it probably isn't worth investigating.
Comment: what is the deference between org.primefaces.themes and org.primefaces.extensions?
And when I need what?
Answer: The PrimeFaces people have decided not to deliver their packages into Maven central so that's the reason why you need to define the prime faces repository separately.
For such purposes it's a good idea to start using a repository manager which can be configured in a central location for your company to use PrimeFaces repository as well. This will make life easier.
Answer: Question:
But when I use all-themes I get missing artifact org.primefaces.themes:all-themes.jar:1.0.10, but why?
Answer:
Because the version of PrimeFaces all-theme you are using it does not exist in Maven repo. Currently Maven has 1.0.8 version as latest.
<dependency>
    <groupId>org.primefaces.extensions</groupId>
    <artifactId>all-themes</artifactId>
    <version>1.0.8</version>
</dependency>

Maven Repo
Comment: Duplicate: http://stackoverflow.com/questions/21705509/primefaces-all-themes-v-1-0-10-installation
Answer: Alternatively, you can use single themes from Icefaces
<dependency>
    <groupId>org.icefaces.ace-themes</groupId>
    <artifactId>ace-sunny</artifactId>
    <version>4.1.0</version>
</dependency>

In your XHTML page include the style:
<h:outputStylesheet name="theme.css" library="ace-sunny"/>

Comment: Since the underlying technology is jQuery, it should be compatible in general. With Primefaces 5.3 it works fine, but there might be some limitations in detail.
Comment: PrimeFaces needs structural css to, that is NOT jquery based... The reason this (for now) works (or just with what you checked) is that the IceFaces components are to a certain extend a fork of the PrimeFaces components. https://www.google.com/search?q=icefaces+forks+primefaces. This compatibility will become less and less in the future, so consequently, this is not a good advice.
Comment: In fact, it works for now. Until Primefaces places their own themes in Central, I don't see any reasons against using it. Otherwise it's pure speculation.
Comment: So your actual problem is that theydid not put themes in maven central? So adding anadditional repository is the blocker? Ok…
Comment: Using an corporate nexus or uploading your own project to Central could prevent you from adding other repositories. Obviously, others also want that.
Comment: ??? We have a corporate  nexus and we simply requested the PF repo to be added. No problem... And if you use it as a proxy(!) you can still add the PrimeFaces repo in your pom, no problem, not even when you upload your project to central...
Answer: We can only guess why this solution was chosen back then. Currently there is no need to a custom repository for themes. They are simply built-in, or, in case of premium themes, you will need to add the resources to your project yourself.
See https://primefaces.github.io/primefaces/12_0_0/#/core/themes


JavaScript DOM - Using NodeLists and Converting to an Array

Question: so I will preface my question with letting you know that this is an assignment for school.  I have been working to solve this and I have tried to find the solution within the MDN documentation and I am at a loss.  I have to:

Grab a NodeList of bugs
Convert the NodeList to an Array

Here is my index.html file:
<!DOCTYPE html>

    <title>Bugs in the DOM</title>

Bugs in the DOM

Horse Flies

Bed bugs

Mosquito

Ants

Mites

Cricket

Woolly Bear Caterpillar

Fleas

Worms

Leeches

I have been able to grab the li elements, while using the DOM with the following code:
var list = document.getElementsByTagName("ul");

When i call list in the DOM, I am returned the ul, which contains all of the li elements.  Not sure if that is what I am supposed to do with respect to the NodeList.  I am also confused as to how I can convert the NodeList to an array.  Not sure if I need to use a for loop and append each element of the NodeList into a new array?  This is all still very new and confusing to me.
Any help is much appreciated, but if you are willing to share insight and an explanation, that would be ideal.  I am really trying to wrap my mind around this and I am falling short. Thank you in advance!
Comment: *use a for loop and append each element of the NodeList into a new array* - yes, exactly. You can get the `` elements with `.getElementsByTagName("li");`
Comment: to convert nodeList to array use `[].slice.call(nodeList);`
Comment: `document.getElementsByTagName('li')` will return an `HTMLCollection`. `document.querySelectorAll('li')` will return a `NodeList`. Note that NodeLists are immutable.
Comment: In ES6 you can use `var nodeArray = [...document.querySelectorAll("li")];`
Answer: You can iterate all the
 items in each
 in the page like this while able to separately tell which
 they are in:
var list = document.getElementsByTagName("ul");
for (var i = 0; i < list.length; i++) {
    var items = list[i].getElementsByTagName("li");
    for (var j = 0; j < items.length; j++) {
        console.log(items[j]);
    }
}

Or, if you just want all
 tags, not broken out by
:
var items = document.getElementsByTagName("li");
for (var i = 0; i < items.length; i++) {
    console.log(items[i]);
}

A nodeList or HTMLCollection can be iterated with a simple for loop as seen above.  These objects do not have array methods, but can be copied into an array if you really want to use array methods.

Note, it is probably simpler to use document.querySelectorAll() for listing all the
 elements and you may want to target a specific
 tag by putting an id on it in case there are other
 and
 elements in the page.

Horse Flies

Bed bugs

Mosquito

Ants

Mites

Cricket

Woolly Bear Caterpillar

Fleas

Worms

Leeches

var items = document.querySelectorAll("#buglist li");
for (var j = 0; j < items.length; j++) {
    console.log(items[j]);
}

A nodeList or HTMLCollection can be copied into an array like this:
var list = Array.prototype.slice.call(document.querySelectorAll("#buglist li"), 0);
list.forEach(function(item) {
    console.log(item);
});

Comment: Thank you for the quick reply!  So, I am trying to make sense of what you have going on here and I am not able to get this to run.  I am being hit with a syntax error.  I took your last section of code that converts a node list to an array and modified it to not require me to change the id of the ul in my html file:

var list = Array.prototype.slice.call(document.getElementsByTagName("li"), 0);
list.forEach(function(item) {
    console.log(item);
});
Comment: When I try to call list[1]; that is where I am hit with the syntax error.  I am not sure why
Comment: @DrewTuzson - make sure you have the latest code from my answer because I fixed a few typos.  And, I'm sure we could help you make your code work, but you'd have to show us exactly what code you were using.
Comment: @DrewTuzson - there is no `list[1]` in my code.  Did you mean `list[i]`?
Comment: Why not `Array.slice(`…`)`?
Comment: @Xufox - the Array object does not have a `.slice()` method.  It's on the `.prototype` or on an actual array instance.  You could do `[].slice.call(...)`, but that seems wasteful to me because it creates an empty array, just to call `.slice()` on it.
Comment: That's weird. In Firefox 37.0.1 I can execute `Array.slice(something)`.
Comment: Here is what I'm using and this is working:

`var list = document.getElementsByTagName("ul");
for (var i = 0; i < list.length; i++) {
    var items = list[i].getElementsByTagName("li");
    for (var j = 0; j < items.length; j++) {
        console.log(items[j]);
    }
}

var newList = Array.prototype.slice.call(document.getElementsByTagName("li"), 0);
newList.forEach(function(item) {
    console.log(item);
});`
Comment: @DrewTuzson - in the future, multiline code placed in comments is not readable at all.  You just can't do that and expect people to be able to read it.  You can sometimes edit it into your question and format it properly and then post a comment that tells people what you added to your question and why.  See http://jsfiddle.net/jfriend00/oo9jhL4y/ for a working version of what you put in your first comment here.
Comment: When I call items[1]; that is working.  Now I am trying to alphabetize the array.  When I use items.sort(); I am being met with an error and it isnt working.  I don't understand.  items is clearly an array storing each of the li's.  When can't I sort it using sort()?
Comment: Hm, I got the `Array.slice` thing: [Array generics](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#Array_generic_methods)…
Comment: @DrewTuzson - you can't sort DOM elements in that way.  If that's what you want to do, I'd suggest you ask a new question about how to sort a list of DOM elements as that involves a custom sort callback and is a different question than what you originally asked.  StackOverflow does not work well if you keep trying to add more things onto your question.  You ask what you want to ask in your question.  When that is answered, then you accept an answer to your original question (checking the checkmark to the left of the best answer) and then ask a new question for your next step.
Comment: @jfriend00 my apologies, let's try this again:
`var list = document.getElementsByTagName("ul");`
`for (var i = 0; i < list.length; i++) {`
`var items = list[i].getElementsByTagName("li");`
`for (var j = 0; j < items.length; j++) {`
`console.log(items[j]);}}`
`var newList = Array.prototype.slice.call(document.getElementsByTagName("li"), 0);`
`newList.forEach(function(item)`
`console.log(item);});`
Comment: @Xufox - `Array.slice()` is not a standard thing.  It does not exist in Chrome or IE, for example.
Comment: @jfriend00 Yep, now I know… damn, I need to change some of my code…
Comment: I hopped into the jsfiddle and that makes sense, however I am unable to call or sort the array?
Comment: @DrewTuzson - please read my prior comment about sorting.   `.sort()` by itself sorts an array of strings.  That is not what you have.  You would need a custom sort function to sort an array of DOM elements and then you would need to reinsert them into the DOM in the sorted order.  That should be the subject of a new question, not this question.
Comment: I am going to open a new question.  I am only able to post every 90 minutes, so I hope to chat with you then.  You have all be very helpful and I am very appreciative!
Comment: @DrewTuzson - I didn't know you had to wait to post a new answer.  Here's a sort solution: http://jsfiddle.net/jfriend00/0ao5spgu/.  FYI, please "accept" this answer by checking the green checkmark to the left of the answer.  This will earn both you and I some reputation points on StackOverflow which can lead to you earning more privileges here.


Training AUC below 0.5

Question: I've trained a logistic regression using a small number of predictors - pseudo R-squared is only 0.1 but I have significant terms and a nice low p value for the model. However, even on its own training data, the AUC for the model is only 0.28:

I thought this was impossible, and my only intuition for what's going on is that the class imbalance (only 5% of the observations are in the positive class) means that the no information rate is pretty high. I still think my model should beat random guessing, at least on its own training data.
I assumed this was a coding error but I think I've ruled that out now, so can anyone explain to me how this is possible?!
I've looked for other discussions on here, most seem to focus on AUC < 0.5 on the test set which I can can more easily understand (e.g. here and here). This one came the closest, demonstrating that a predictor that's really just noise can come out below 0.5 - but I think my model has found some real relationships in the data...
Comment: @usεr11852 you were totally right - the labels were still flipped in the final plotting command, the one bit of code I didn't check - silly me, thanks for your help
Comment: No worries Tom, it has happened to all of us in the past too. :) (I will write it as an answer so the question isn't unanswered)
Comment: Switch the labels. :)
Comment: Thanks @usεr11852 but I've tried flipping the labels, respecifying the target variables and other coding errors but I just keep reproducing this result.
Comment: Thanks @Sycorax, I'd get that if my terms were all insignificant, but given I've got significant terms and a decent p value for the model overall, seems like there's some signal in the features. I realise I haven't shared enough to rule out a code error, but I've satisfied myself it's unlikely.
Comment: That's a good clue but I'm not fully understanding. My expectation at least would be that significant terms should tend to rank order the observations correctly. Is there a link you could throw me on this @Sycorax?
Comment: Thanks but I know what the 2 concepts mean, and that they're different, but surely one leads to the other? I was actually referring to the p value of the whole model, but let's say it's a model with a single significant linear predictor. The fact that the model achieves a good fit with that variable, should mean that predictions based on that linear relationship tend to rank order the observations better than randomly too. And in any case, not worse! :-)
Answer: AUC-ROC can be below 0.5 but when it is substantially below 0.5 as in the case shown here (~0.28) there is a good chance that the labels are flipped/reversed at some point in our modelling pipeline. Such a low AUC-ROC score would suggest we are consistently bad, it can happen, but usually we are just bad!
Answer: It turned out this was a coding error, here's the correct ROC curve:

with AUC of 0.72.
Moral of the story: if you see this, triple- and quadruple-check your code, because it is impossible.

Training AUC below 0.5


Cause for Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: error

Question: Currently trying to port over a Contrib module and learn the new Drupal 8 architecture.
A google search revealed a possible issue related to this.
The cause could be that there's an underscore in the file name which violates psr-0 naming standards. Looks like i had that before and have renamed it just now and still have that issue after clearing the cache.
What would likely be the cause of the following error?

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
  You have requested a non-existent service
  "\drupal\form_example\forms\formexampleformone". in
  Symfony\Component\DependencyInjection\Container->get() (line 304 of
  /home/chris/workspace/d8/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php).

The error occurs when i visit /examples/form_example/tutorial/1
form_example.routing.yml
form_example:
  path: 'examples/form_example'
  defaults:
    # _form: '\Drupal\form_example\Forms\FormExampleForm'
    _content: '\Drupal\form_example\Controller\FormExampleController::description'
  requirements:
    _access: 'TRUE'
form_example_tutorial_1:
  path: 'examples/form_example/tutorial/1'
  defaults:
    _form: '\Drupal\form_example\Forms\FormExampleForm'
  requirements:
    _access: 'TRUE'

form_example.module
<?php
function form_example_menu() {
//   $items = array();
//   $items['examples/form_example'] = array(
//     'title' => 'Form Example',
//     'route_name' => 'form_example',
//     'access callback' => TRUE,
//     'expanded' => TRUE,
//   );
  $items['examples/form_example/tutorial'] = array(
    'title' => 'Form Tutorial',
    // 'page callback' => 'drupal_get_form',
    'route_name' => array('form_example_tutorial'),
    'access callback' => TRUE,
    'description' => 'A set of ten tutorials',
    // 'file' => 'form_example_tutorial.inc',
    // 'type' => MENU_NORMAL_ITEM,
  );
  $items['examples/form_example/tutorial/1'] = array(
    'title' => '#1',
    // 'page callback' => 'drupal_get_form',
    'route_name' => array('form_example_tutorial_1'),
    'access callback' => TRUE,
    'description' => 'Tutorial 1: Simplest form',
    // 'type' => MENU_DEFAULT_LOCAL_TASK,
    // 'file' => 'form_example_tutorial.inc',
  );
  return $items;
}

/lib/Drupal/form_example/Forms/FormExampleForm.php
<?php
/**
 * @file
 * Contains \Drupal\form_example\Form\FormExampleForm
 */
namespace Drupal\form_example;

use Drupal\Core\Form\FormInterface;

class FormExampleForm extends FormBase {
// form...
}

Comment: Can you provide your routing.yml file?
Comment: Sure thing updated @Berdir
Answer: Looks like the namespace defined in your class file does not match the one you put into the resource, there's a "Form" sub-namespace missing.
Also make sure that the class is placed in the right folder.
The reason for that error is apparently that for some reason, the specified class can't be found, so apparently the router then falls back to the service. So the _ thing is just one possible reason.
Also, there are some errors in your hook_menu(), route_name is a string, access callback can be removed and you still need the first entry for now so that you have a menu link to it.
Comment: I would like to add one more reference here. Definitely it is the issue with underscore. Here is the reference link for future visitors https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md#underscores-in-namespaces-and-class-names and https://drupal.org/node/1962876


Is the extension of the antiderivative differentiable at $0$?

Question: Let $f:(0,\infty)\rightarrow\mathbb{R}$ be a continuous function and let $F$ be its antiderivative. Suppose there exists a finite limit $\lim_{x\to 0} F(x)$. We can extend $F$ to a continuous function by defining $F(0):=\lim_{x\to 0} F(x)$. The question is: Is $F$ differentiable at $0$?
When $f$ has a limit $\alpha=\lim_{x\to 0}f(x)$ by l'Hospital' rule we have
$$\lim_{x\to 0}\frac{F(x)-F(0)}{x}=\lim_{x\to 0}F'(x)=\lim_{x\to 0}f(x)=\alpha$$
which means $F$ is differentiable when this limit is finite.
The problem is when $f$ does not have a limit as $x$ tends to $0$. In this case there are examples of functions when $F$ is differentiable (take $F$ which is differentiable but the derivative is not continuous at $0$), but I haven't found an example when it is not differentiable. That's why I'm looking for a proof or a counterexample.
Comment: $F(x) = \sqrt{x}$?
Comment: I'm looking for a counterexample when the limit of $f$ doesn't exist (neither finite nor infinite). I know that when it is infinite the antiderivative is not differentiable.
Comment: $f(x)=\frac{sin(x)}{x}$?
Comment: $\lim_{x\to 0}\frac{\sin x}{x}=1$. The antiderivative is clearly differentiable.
Answer: Not necessarily.
Take $f(x)= (-\frac{\cos(1/x)}{x})+\sin(1/x).$ Its antiderivative is $x \sin(\frac{1}{x})$, which can be continuously extended to $0$, but is not differentiable there.


Java 8 DateTimeFormatter for month in all CAPS not working

Question: I'm trying to parse date time string to LocalDateTime. However if I send month with all caps its thorwning an error, is there any workaround. Here is the below code
<code>@Test
public void testDateFormat(){
    DateTimeFormatter formatter= DateTimeFormatter.ofPattern("dd-MMM-yyyy HH:mm:ss");
    LocalDateTime dateTime = LocalDateTime.parse("04-NOV-2015 16:00:00", formatter); //if I send month Nov it works
    System.out.println(dateTime.getYear());
}
</code>
The Same works for simpleDateFormat
<code>@Test
public void testSimpleDateTime() throws ParseException{
    SimpleDateFormat format = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
    Date dateTime = format.parse("04-NOV-2015 16:00:00");
    System.out.println(dateTime.getTime());
}
</code>
Comment: maybe ResolverStyle.SMART (the default) doesn't handle this: https://docs.oracle.com/javase/8/docs/api/java/time/format/ResolverStyle.html
Answer: Answering this question because most of us might not know JSR 310. Hence would search for java 8 LocalDateTime ignore case.
<code>@Test
public void testDateFormat(){
    DateTimeFormatter formatter= new DateTimeFormatterBuilder().parseCaseInsensitive().appendPattern("dd-MMM-yyyy HH:mm:ss").toFormatter();
    LocalDateTime dateTime = LocalDateTime.parse("04-NOV-2015 16:00:00", formatter);
    System.out.println(dateTime.getYear());
}
</code>
**UPDATE*
To locale
<code>DateTimeFormatter parser = new DateTimeFormatterBuilder().parseCaseInsensitive() .appendPattern("dd-MMM-yyyy HH:mm:ss.SS").toFormatter(Locale.ENGLISH)
</code>
Comment: There's a java-8 tag on the linked question
Comment: And if you need to specify de locale: DateTimeFormatter parser = new DateTimeFormatterBuilder().parseCaseInsensitive()
    .appendPattern("dd-MMM-yyyy HH:mm:ss.SS").toFormatter(Locale.ENGLISH)'
Comment: @AgustíSánchez thanks for pointing, updated answer.


Ho to check the Model is locked using API

Question: For checking the package is locked we can use the API pacakge.Element.locked but for model which is also an package doesn't have an element .So how can we check whether the model is locked using automation in EA.
Comment: I'm afraid you'll have to look into the database to get that info.
Comment: You mean you want to know whether the root node is locked? If so, why?
Comment: yes from Database we can get it but from API we cant get it
Comment: yes how to check whether is root node is locked or not
Answer: The root package has no lock. You can see that on locking only the views below have the red exclamation mark.
I would not be astonished if you could rename the root package with the API in spite of the security being turned on.
P.S. Yes. Altering the root worked.
P.P.S.  Not only via API but also the GUI lets you rename the root package.


How are generalized frames related to biorthogonal bases?

Question: How are generalized frames related to biorthogonal bases? It seems like frames are a possible solution if neither orthonormal nor biorthogonal bases are available. I thought the generalized frames theory was what enabled the use of biorthogonal bases and the redundancy it gives.
Edit: It seems like biorthogonal bases might be a special case of frames and frames are even more general than I thought, frames are not only used with wavelets.
Answer: I found the answer in Jelena Kovacevic excellent article Life Beyond Bases: The Advent of Frames (Part 1), page 90-91, IEEE Signal Processing Magazine, July 2007. When you have more bases vectors than dimensions the resulting (redundant) set (of linearly dependent vectors) is called a frame instead of a basis. The frame has a dual frame and biorthogonal bases is a special (case) frame where the frame and the dual frame are interchangeable. x=FDx=DFx where F is the frame, D is the dual frame and * is the Hermitian transposition.
"Bi essentially just means two. In bilinear it means linear in two arguments. In biorthogonal it means two families of vectors are orthogonal in respect to one another (but neither must be orthogonal in respect to itself)." The inner product of the n:th position from each vector family is zero.
Does the "bi" in bilinear and biorthogonal mean different things?


How to save file in ASP.NET MVC from Chrome?

Question: i am trying to save a file from chrome using AjaxSubmit. i got the problem that Chrome send the file in octet format and i am unable to check that if it is really image or anything else.
when i try to call
HttpPostedFileBase file

file.InputStream

inputstream caused error in chrome that Parameter is not valid.
how i can save them in asp.net c#
Answer: I use this in my view: <input type="file" id="deploymentPackage" name="deploymentPackage" />
And in my controller, I do this:
public ActionResult AddRelease(ApplicationReleaseViewModel appRelease, HttpPostedFileBase deploymentPackage)
        {
            if (ModelState.IsValid)
            {
                ApplicationRelease dto = new ApplicationRelease();
                appRelease.UpdateDto(dto);

                using (StreamReader sr = new StreamReader(deploymentPackage.InputStream))
                {
                    dto.DeploymentPackage = new byte[deploymentPackage.InputStream.Length];
                    deploymentPackage.InputStream.Read(dto.DeploymentPackage, 0, dto.DeploymentPackage.Length);
                }

                this.ApplicationService.AddApplicationRelease(dto);

                return RedirectToAction("Index", new { ActionPerformed = "ApplicationReleaseAdded", Name = appRelease.Name.CutToMaxLength(50).UrlEncode() });
            }
            else
            {
                ViewBag.PostAction = "AddRelease";

                return View("EditRelease", appRelease);
            }
        }

UPDATE: Look at this link, if you can't abstract yourself from "my" code.
http://www.codeproject.com/KB/aspnet/Implementing_HTTP_File_Up.aspx
Comment: what is ApplicationReleaseViewModel  i see this first time. anything special
Comment: Yes, that is my own view model for that specific View/Action. Don't pay attention to that.
Comment: Use the link I just added instead.


z-index Drupal 7 Skeleton Boilerplate discriminating roles?

Question: I'm building a website using Drupal 7 for the first time. I have always built them on Drupal 6 using the basic theme to build my own custom themes from. This time I decided to change, because I thought it was time to move onto Drupal 7 and I wanted responsive design for this project.
I have a custom front---page template, and on that front page I have views slideshow (cycle) and wanted to place text on it. So i made a block with such text, and gave it a z-index 999 and an absolute position, when the slider has a z-index -999. Everything looks just as I want it and expect it to, until.... I log out! Is it possible that the css is discriminating roles?
How can it possibly be that logged in as admin I see the slider on the bottom and the block on top as expected, and as an anonymous user the text block is hidden underneath the slider? (And I know it is because when I resize, I can partially see it, as it moves down.... ) I'm lost.
Edit for more info: this is happening in IE9, Chrome, Safari mac, Safari Win, and Firefox is displacing the Slider onto the right....GRRRR. HELP!
Thank you in advance for your help.
Comment: Have you cleared the drupal cache?
Comment: Volker. Thanks for asking. I cleared the caché, but also I added position: relative; to both items. Apparently that was the issue as well. Although the cache clearing might have helped as well.
Comment: However, Firefox is still displacing the slider to what would be the "one_half_last" position (the block has the class "one_half" and I added a "clear" class right after. Any ideas how to fix this?
Answer: I was too quick to post the question and I apologize, since the answer is all over the internet, and for those going through the same issue:
YOU MUST add position relative or absolute to all items involved in the z-indexing. Ot the z-index won't work.
Also why was Firefox not rendering things right? I had added a skeleton class to the search box template, but had not added a clear right after.
As to why it was rendering things right when i was logged in as an admin, but not when I was anonymous, remains a mystery.
Hope this is useful for those having identical issues.


char pointer, Access violation writing location

Question: void cpy(char *s, char *t)  {
while((*s = *t) != '\0') {
    s++;
    t++;
  }
}
void main() {
char *x;
char *y;
x="abc";
y="zzz";
cpy(x,y);

}

what it wrong with this function? is the part *s=*t wrong? always says "Access violation writing location"...
Comment: You asked a similar question few minutes back:- http://stackoverflow.com/questions/18670912/assign-value-to-char-pointer-but-say-access-violation-writing-location
Comment: It's about don't modify string literals, as I answered in the other question of yours:  http://stackoverflow.com/a/18670947/1009479
Comment: Dont modify the string literal as they are read only!!!
Answer: The strings that you specify in quotas is constant strings and stores in read only memory. So after
x = "abc"

x points to read only memory area. And when you try to write there with cpy you get the exception.
Comment: is that means we means we cannot change any single char of the string by pointer?
Comment: If pointer points to read only data you cannot. You can make r/w copy with strdup("abc"). And don't forget about free it after use.


JavaScript: How to access the n-th result from an xpath search?

Question: Problem Description
I am trying to use xpath to locate the "Messi" node from the HTML below.  To minimize coding efforts, I am hoping for a solution that uses an array index, instead of looping through an iterator.
My assumption is that the most standard and simplest API is XPathExpression.evaluate().  If there are better APIs, please kindly share.
By the way, I need to make changes to the DOM Node from the returned result.  So, XPathResult.resultType will be set to ORDERED_NODE_ITERATOR_TYPE, and therefore XPathResult.snapshotItem() cannot be used.
HTML Example

NumberOne

NumberTwo_Mbappe

NumberOne

NumberTwo_Ronaldo

NumberTwo_Messi

Code to get the XPath Results
Running the code below will return an iterator from the above html.
let xpathIterator = new XPathEvaluator()
                        .createExpression("//*[starts-with(text(), 'NumberTwo')]")
                        .evaluate(
                            document,
                            XPathResult.ORDERED_NODE_ITERATOR_TYPE
                        );

Existing iterator solution for extracting the n-th item
The existing XPathResult interface only has an iterateNext() method, so it will take six lines of code to extract the n-th item:
let n = 3;
while (n > 0) {
    xpathIterator.iterateNext();
    n--;
}
xpathIterator.iterateNext();

Ideal array solution for extracting the n-th item
Since XPath and Chrome are used by millions of people everyday, ideally, there should be a way to obtain the n-th item directly using an array index (as the following code shows).  I would be surprised if such an API doesn't already exist.
let v = xpathResult[2];

The ideal solution doesn't necessarily need to use XPathExpression.evaluate().  I am open to any solutions that use standard JavaScript functions supported by Chrome.
(Hopefully, we don't need to use a function. If a function must be used, it would be good to have no more than 2 to 3 lines of ESLint-linted codes.)
Thanks!
Related Posts
Since XPathResult.resultType is not an iterable, the following posts don't apply:

Convert ES6 Iterable to Array

Transforming a Javascript iterable into an array

How to use Array.from with a XPathResult?
Comment: Hi @Mike'Pomax'Kamermans `Why would you use XPath` I have updated my post to perform a text-based XPath search.  It will work if you paste the codes into Chrome.  Thanks!
Comment: Does this answer your question? [How to use Array.from with a XPathResult?](https://stackoverflow.com/questions/47017441/how-to-use-array-from-with-a-xpathresult)
Comment: Why would you use XPath when working with HTML pages, instead of just using the normal query selector approach, e.g. ```document.querySelectorAll(`.wikitable tr`)```? No reason to treat the page as XML when it isn't XML?
Comment: Hi @Earlee, `Does this answer your question? How to use Array.from with a XPathResult?` Array.from() doesn't work, because it requires an iterable, or an array-like object.  Array-like objects need to have the "length" property.
Comment: @Emma yes they have a discussion there as to how you could convert it to array by creating your own function. then you can finally array indexing.
Comment: Hi @Mike'Pomax'Kamermans , `Why would you use XPath when working with HTML pages, instead of just using the normal query selector approach, e.g. document.querySelectorAll`, the purpose of my question is to perform the search via XPath, because, for my industry (QA Selenium Development), we often do not have the luxury of using CSS selectors.  Sometimes, the frontend develoeprs produced a website with huge tables and no attributes (no class and no id).  The only way to search for something is by using xpath to locate the desired texts in the table row.  CSS selectors don't work on text nodes.
Comment: Hi @Earlee `yes they have a discussion there as to how you could convert it to array by creating your own function. then you can finally array indexing.` They did the conversion with 6 lines of codes, which is no shorter than the "existing" solution that I provided above.  The purpose of this question is to help people who need to manually do xpath search thousands of times a day, and cannot afford 6 lines of codes.
Comment: Hi @Earlee `yes they have a discussion there as to how you could convert it to array by creating your own function.` I am hoping to avoid the need to create a function, because the codes will be run in the Chrome console, and the Chrome window will be closed and re-opened hundreds of times a day, which means the function will need to be manually re-created hundreds of times a day.
Comment: @Emma thanks. Although of course, this is still really easy to do with "not xpath" by using ```Array.from(document.querySelector(`....`)).filter(e => e.textContent.contains(`be`))```, so I'm still not sure xpath makes more sense than query selecting and then mapping/filtering as needed =) It might help to explain what you're actually trying to achieve, concretely, just in case there's some easy "normal" JS that can just as easily achieve that goal.
Comment: Hi @Mike'Pomax'Kamermans, thanks for the Array.filter() suggestion.  I have added an HTML example.  Please review.  How would you use CssSelector to get the three "NumberTwo" nodes?  After getting the three nodes, how would you access the 3rd node (the "Messi" node) directly?  By the way, the five text nodes aren't necessarily located in ; they are equally likely to be wrapped by  or .  Also, the "NumberTwo" nodes aren't necessarily the 2nd, 4th, and 5th nodes; they are equally likely to be at the 1-2-5 or 1-4-5 or 3-4-5 positions. Thanks!
Comment: There are certainly libraries that expose the console functions like `$` or `$x` to "normal" script, e.g. https://github.com/WebReflection/basic-devtools/blob/main/esm/index.js does that. Also, XPath has undergone quite a development from XPath 1 which is all that browser support to XPath 3.1 which is what modern libaries like SaxonJS or FontoXPath support. `SaxonJS.XPath.evaluate` can be used to return an array, for instance.
Comment: Hi @MartinHonnen, thanks for the suggestion.  How do we install SaxonJS in the Google Chrome console?  Would "npm install SaxonJS" work?
Answer: This will get the third item in your example:
let v = [...new Array(3)].map( () => xpathIterator.iterateNext() );
v[2];

Answer: inject this into the console:
document.querySelector(".wikitable >  tbody").children[6];

Comment: Thanks! The purpose of my question is to perform the search via XPath, because, for my industry (QA Selenium Development), we often do not have the luxury of using CSS selectors. Sometimes, the frontend develoeprs produced a website with huge tables and no attributes (no class and no id). The only way to search for something is by using xpath to locate the desired texts in the table row. CSS selectors don't work on text nodes.
Comment: I have updated my post to perform a text-based XPath search. It will work if you paste the codes into Chrome. Thanks!
Answer:
How would you use CssSelector to get the three "NumberTwo" nodes? After getting the three nodes, how would you access the 3rd node (the "Messi" node) directly? By the way, the five text nodes aren't necessarily located in

 they are equally likely to be wrapped by

 or

.

Given the HTML you're showing in your edits, like this:

const allNodes = Array.from(document.querySelectorAll(`ul li, ol li, table tr`))
const allNumberTwoNodes = allNodes.filter(e =>
                              e.textContent.includes(`NumberTwo`)
                          );
console.log(allNumberTwoNodes);

NumberOne

NumberTwo_Mbappe

NumberOne

NumberTwo_Ronaldo

NumberTwo_Messi

NumberOne

NumberTwo_Mbappe

NumberOne

NumberTwo_Ronaldo

NumberTwo_Messi

NumberOne

NumberTwo_Mbappe

NumberOne

NumberTwo_Ronaldo

NumberTwo_Messi

Here, we're relying on textContent, which gives us (unsurprisingly) the text content of a node ignoring tags, which is why even though those table rows have table data cells, the
's textContent gives us a string as if the  markup isn't there.

Also, the "NumberTwo" nodes aren't necessarily the 2nd, 4th, and 5th nodes; they are equally likely to be at the 1-2-5 or 1-4-5 or 3-4-5 positions.

Query selectors, just like XPath, doesn't care what order the HTML is in, it's going to find "the things that match", not "the thing at the xth position" (unless you bake child position into the selector, just like XPath).
Comment: Thanks Mike. I have updated my HTML example.  How would you use CssSelector to find the three "NumberTwo" in "SectionTwo", skipping the ones in "SectionOne"? Thanks.
Comment: By first fixing that HTML, because `` only allows `` as children, not text. Also, can you please edit your post to just show examples of real data you're working with? The html you're showing has no classes, even though the page you were asking about does: using query selectors is one of the backbones of modern web work so asking "how do I select X from HTML Y" is almost certainly met with "by just looking up how to query-select for that" with millions of posts on SO already and tons of tutorials on the web. So your post should be about your _specific_ problem, not only sort of =)
Comment: Fixed with 's.
Comment: Hi Mike, I was using real data.  For internal company websites, the web developers don't care about class's or id's or attributes.  They try to deliver a working website within the shortest amount of time.  (Ask any Selenium developer how often they encountered this kind of website.)  We cannot ask the web developers to change the websites, because they don't have time.
Comment: Hi Mike, even for multi-billion production websites, there are frequently elements that can only be distinguished by text only.  Try this website: https://www.quora.com/What-is-the-average-cost-of-a-laptop .  Quora added the new "Sage" node recently at the top.  How would you use CSS to locate that?  Sure, you can get all the nodes, and then Array.filter().  But what if I am building my XPath (or Css) in the "Element" tab, and I don't want to switch back and forth between "Element" and "Console"?  Can we run JavaScript in the "Element" tab?
Comment: Trying to simplify the Question's HTML example by reverting it... if you need the original HTML, here you go: `   SectionOne NumberOne NumberTwo_MbappeSectionOne NumberOne NumberTwo_RonaldoSectionOne NumberTwo_MessiSectionOne   SectionTwo NumberOne NumberTwo_MbappeSectionTwo NumberOne NumberTwo_RonaldoSectionTwo NumberTwo_MessiSectionTwo   `
Comment: Please do not use comment threads for post details: just put those details in your post. Because you're not really talking to "me" when you supply details, you're talking to everyone who can help answer your post, and they won't see what you said if you say it in comments. (Remember the [posting guidelines](/help/how-to-ask)).


animate div position on page scroll

Question: I have a div that appears when a user scrolls down a page (you click it and it sends you back to the top of the page). Currently it just fades in and out, but I want it to slide in from the right hand side of the page.
Here is my current code:
Jquery:

Back to the top

CSS:
.toTop {
    padding: 10px;
    background: rgb(55,161,222);
    color: #fff;
    position: fixed;
    bottom: 50%;
    right: 0px;
    display: none;
    z-index:1000;
    text-transform:uppercase;
    font-weight:600;
}

You can also see what I'm doing here:
http://www.samskirrow.com/client-hope
Answer: Get rid of the display:none.
Set right:-200px and use .animate({ right: 0px }) instead of .fadeIn() and .animate({ right: -200px }) instead of fadeOut().
Change your if statement to if ($(this).scrollTop() > 100). This is because the scrollTop() function returns the current scroll position as a number of pixels from the top.
Comment: works perfectly when scrolling down, but doesn't when scrolling back up again. Any thoughts?
Comment: Sorry for the delay. Edited the answer for the new problem.
Comment: Thanks @Toast only final issue is that there is a random delay on the div moving back in (literally random - sometimes it's less than 5 seconds, sometimes it's more than 20 seconds)
Answer: replace the $('.toTop').fadeIn(); with .animate({"right":"-50px"}, "slow");
Comment: thanks @user1106295 how do I make it disappear again when I'm at the top??
Comment: did you add else { $('.toTop').animate({ right: -200px })} instead of the else....fadeout?

animate div position on page scroll


How to export all feature components with drush?

Question: With drush feature-export you can easily create a feature from a component. But is there a way to easily export ALL components into a feature? In the ui you can easily check all content types or all views. I tried drush fe newfeature views_view but it only exports one view not all of them.
Answer: Hmm ... did you try drush's built in Help topics?
I am running drush --version:
Drush Version   :  6.2.0
The help output for features-export is:
drush help fe

Export a feature from your site into a module. If called with no arguments, display a list of available components. If called with
a single argument, attempt to create a feature including the given component with the same name. The option '--destination=foo'
may be used to specify the path (from Drupal root) where the feature should be created. The default destination is
'sites/all/modules'. The option '--version-set=foo' may be used to specify a version number for the feature or the option
'--version-increment' may also to increment the feature's version number.

Arguments:
 feature                                   Feature name to export.
 components                                Patterns of components to include, see features-components for the format of patterns.

Options:
 --destination                             Destination path (from Drupal root) of the exported feature. Defaults to
                                           'sites/all/modules'
 --version-increment                       Increment the feature's version number.
 --version-set                             Specify a version number for the feature.

Aliases: fe

And drush help fc:

List feature components matching patterns. The listing may be limited to exported/not-exported components.

A component pattern consists of a source, a colon and a component. Both source and component may be a full name (as in
"dependencies"), a shorthand (for instance "dep") or a pattern (like "%denci%").

Shorthands are unique shortenings of a name. They will only match if exactly one option contains the shorthand. So in a standard
installation, "dep" will work for dependencies, but "user" wont, as it matches both user_permission and user_role.

Patterns uses * or % for matching multiple sources/components. Unlike shorthands, patterns must match the whole name, so
"field:%article%" should be used to select all fields containing "article" (which could both be those on the node type article, as
well as those fields named article). * and % are equivalent, but the latter doesn't have to be escaped in UNIX shells.

Lastly, a pattern without a colon is interpreted as having ":%" appended, for easy listing of all components of a source.

Arguments:
 patterns                                  The features components type to list. Omit this argument to list all components.

Options:
 --exported                                Show only components that have been exported.
 --not-exported                            Show only components that have not been exported.

Aliases: fc

So you should be able to use wildcards like % or * to select all types of a component. Eg, drush fe newfeature views_*. Your mileage may vary ...
Comment: That was it! Thanks, still new to drush but that will help me explore its capabilities. Thanks again!


Pathauto , Using Body Value for URL Alias

Question: I am trying to use the use the node body value for URL alias using Pathauto . I am trying the below path pattern : content/[node:body:?]
But this doesn't seem to have any effect .
I have tried this also : content/[node:body:Text] ..yet no result .
Any pointers to resolve this is highly appreciated .
Thanks
Answer: Without questioning why you would want body text in a URL alias you should be able to access this by using:
<code>[node:body:value] for the value
[node:body:summary] for the summary
</code>
Comment: Hi , I tried [node:body:value] still does'nt create alias. My  node title doesnt have relevant information ..it has numbers. So , I am tryin g to get body value for alias.


Using PVLANs with normal VLANs in a trunked environment

Question: Assume a trunked environment with two switches, S1 and S2.  The swtiches are connected with a trunk port designed to pass VLAN 26.  What would happen if VLAN 26 on S2 is configured as a private-vlan with the default gateway and DHCP server and default gateway as promisc ports.  What if S1's VLAN 26 is configured as a standard VLAN.  Would the hosts on S1 be able to communicate with the promisc ports on S2?  Would they be able to communicate with the hosts on S2?
To further complicate things what if the DHCP server were to reside on S1 and I wanted S2 to have private VLANS with promisc ports as the gateway and DHCP server while still leaving S1 in a standard vlan configuration.
Answer:
What would happen [...]

The world is not going to explode, if this is what you mean. You should have done some basic research beforehand - there even is a Wikipedia article explaining your exact scenario:
<code>The following table shows the traffic which can flow between all these ports.
            I-Port  P-Port  C1-Port C2-Port Uplink
I-Port      Deny    Permit  Deny    Deny    Permit
P-Port      Permit  Permit  Permit  Permit  Permit
C1-Port     Deny    Permit  Permit  Deny    Permit
C2-Port     Deny    Permit  Deny    Permit  Permit
Uplink      Per/Den Permit  Permit  Permit  Permit
</code>

Traffic from an Uplink port to an Isolated port will be denied if it is in the Isolated VLAN. Traffic from an Uplink port to an isolated port will be permitted if it is in the primary VLAN.

[...]

Would the hosts on S1 be able to communicate with the promisc ports on S2?

Obviously, as the trunk would be part of the private VLAN.

Would they be able to communicate with the hosts on S2?

Obviously not - for the same reason. Unless VLAN 26 is the default VLAN for the trunk

what if the DHCP server were to reside on S1

In this case, in order for the DHCP server to communicate with the I-Ports on S2 your trunk needs to be a promiscuous member of the PVLAN.
Comment: Somewhat rude.... but thanks for the help.  Upvote!


Natural vs tempered semi-tones

Question: I am reading "Fundamentals of Musical Composition" by Arnold Schoenberg. Chapter XI, page 99, states:

Chromaticism is difficult partly because the natural semi-tones differ in size from the tempered (a fact which causes choirs to get off pitch)

I do not understand this sentence. What is the difference between natural and tempered semi-tones? What does this have to do with chromaticism, or choirs getting off pitch?
Comment: Maybe this can help http://music.stackexchange.com/questions/11815/what-is-the-difference-between-sharp-note-flat-note/11816#11816, and this http://music.stackexchange.com/questions/7986/why-is-just-intonation-impractical/8022#8022
Answer: Schoenberg is talking about the difference between just intonation (which he refers to as "natural semi-tones") and 12-tone equal temperament (which he refers to as "tempered" semi-tones). This is a complicated subject. You can find several long posts about this subject on this site, or you can find a lot of references elsewhere on the Internet.
The gist of the matter is that in the modern era, a piano has 12 notes in an octave, and each of them are exactly 100 cents apart. This is the 12-tone equal temperament system. It is is an artificial compromise; it is not natural and it is not in keeping with the physics and mathematics of sound.
Singers in an a capella choir or string players in a string quartet are not limited to 12 equally-spaced half-steps. Choirs can sing in just intonation, which is pure, natural intonation. With pure, natural intonation, the size of the half-steps (and the difference in the frequencies between two pitches in a chord) will vary, depending on the chords and intervals being sung at the particular moment.
Here is a chart I created in answer to a previous question on this site.

As you can see, in pure intonation, some half-steps should be larger than 100 cents, and some half-steps should be smaller.
When singers or string players play with a modern piano, however, everybody must constrain themselves to the 12 equally-spaced half-steps that the piano can play.
This may surprise you, but the bottom line is that if you and your choir sing exactly the same pitches found on the piano, you are in fact singing out-of-tune to some degree. A choir can only sing perfectly in tune if they are singing a capella and they do not automatically adjust each pitch to be the same as the pitches on the piano, which are artificial.
Further observations:
Schoenberg observes that if the music is highly chromatic, a choir will make so many adjustments of semi-tones to produce pure intonation that they will not be able to avoid drifting off of the base pitch or frequency of the key or tonic note in which they started the piece, and they will finish the piece on a different tonic pitch (meaning they will "get off pitch"). In decades of singing in a choir, I have observed this many times. Generally we choral singers don't regard it as a problem, as long as we were internally consistent throughout the piece. By this, we mean that while we were singing it, each chord in the music sounded in-tune and there were no obvious wrong notes.
Frequently in a rehearsal of an a capella piece, the accompanist will play a chord on the piano at the beginning to give each section their pitch. When the piece is completed, the accompanist might play the same chord to show the choir how far off the base pitch they have drifted in the course of singing the piece -- at which point the choir often groans in chagrin. Sometimes it can be as much or more than a whole step sharp or flat from the starting pitch. Yet I contend that this is not a disaster as long as the piece sounds internally consistent. However, in a good choir, all the members strive to keep as near to the original base pitch as possible throughout the piece, and to finish there as well.
As a singer with perfect pitch, when I am in this situation, particularly in performance, it presents a dilemma: if I perceive the other choral singers around me drifting away from the starting pitch, tonic and key (taking into account the modulations that may be written into the piece), do I fight against the other singers by keeping my pitches up, relative to the starting pitch and tonic and key, or do I "go with it" and follow the gradual shift in tonic that everyone else is making? In most cases, it's better to "go with it" rather than "fight it", because it produces a more internally consistent sound. While I have perfect pitch, I must concede that if a choir were only to sing the 12 pitches on the piano, that would not be a good choir, because that is not really what choirs are supposed to do.

Natural vs tempered semi-tones


Using selenium rc java for checking json respose

Question: I want to test my json response using selenium rc (java) and to print all the response which has  garbage value
My json response is as follows :
<code>{"date":"2012-03-02","data":[{"id":17,"Level":4,"Status":1},{"id":128,"Level":4,"Status":0},{"id":13,"Level":5,"Status":1},
</code>
So i would like to know how i can use selenium id to check the above mention scenario
Answer: Well, some pointers to help you gt the answers..there was a captureNetworkTraffic flag in RC that needs to be set while starting selenium instance. Then use a selenium function to capture the traffic.  Then use a JSON library to parse the JSON and do string comparison for garbage value (depending on what you consider as garbage value :)  )
You can search for captureNetworkTraffic usage and then a json library for the language that you plan to use.


sdist and bdist_wheel freezes at build

Question: I am trying to build a wheel and source distribution on windows 10 for a project of mine, but the build freezes at removing 'release-exporter-1.0' (and everything under it) for sdist and creating build\bdist.win-amd64\wheel\release_exporter-1.0.dist-info\WHEEL for bdist_wheel.
Following is my setup.py
setup(
    name='release-exporter',
    version=version(),
    install_requires=get_requirements('requirements.txt'),
    packages=find_packages(),
    url='https://github.com/akshaybabloo/release-exporter',
    license='MIT',
    author='Akshay Raj Gollahalli',
    firstname.lastname@example.com',
    description='Release exporter for GitHub and GitLab.',
    keywords="changelog releases",
    classifiers=[
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python :: 3 :: Only',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',
        'Intended Audience :: Developers',
        'Environment :: Console',
        'Development Status :: 5 - Production/Stable',
        'Topic :: Utilities'
    ],
    entry_points={
        'console_scripts': [
            'rex = release_exporter:main'
        ]
    },
)

I have tried to manually give the package name from ['release_exporter'] to using find_packages() of setup tools. I also thought the keyword should be a string, so I changed it from ['changelog', 'releases'] to "changelog releases". But still no luck.
Also, I have tried to set --verbose flag by doing python setup.py sdist --verbose, but it doesn't work. I think the bug is not rectified yet -> https://bugs.python.org/issue7202
Any help would be appreciated.
Update
I am using Python 3.6.3
Answer: Its a bug in Python 3.6.3 -> https://docs.python.org/3.6/whatsnew/changelog.html#build. Just in case if anyone has a problem, update your Python to Python 3.4.4.

sdist and bdist_wheel freezes at build


Kubernetes annotation for vault not mounting secret file to pod when entry point script is used

Question: I want to read certificates from vault and install it in the kubernetes pod.
I stored the certificates in the vault along with other secret. To filter out the certificate from the vault written an entry point script. So in the script before start up of pod trying to install the certificate.
But found while entry point script starts running vault has not mounted the file in the location. I am using spinnaker deployment pipeline and used annotation for vault to read and mount the file.
Please suggest how this can be achieved.
Answer: Resolved, vault was running as init container and before start of pod it is mounting the secret.
 I was pointing to wrong file.


SSL certificates with password encrypted key at hosting provider

Question: We are a software company and offer hosting to our clients. We have a VPS at a large Dutch datacenter. For some of the applications, we need an SSL certificate which we'd like to encrypt with a password protected keyfile.
Our VPS reboots now and then because of updates whatsoever, but that means our apache doesn't start right away because the passwords are needed. This results in downtime and is of course a real big problem.
We can give the passwords to our VPS datacenter, or create certificates based on keyfiles without passwords. Both solutions seem not the best one, because they compromise the security of our certificates. What's the best solution for this issue?
Answer: Whatever happens, you'll need to decrypt the keyfile in order to use it. There are a few options.

Decrypt the keyfile and use that. This offers permanent graceful restart of your services which is what you are after. But the key then is unprotected, unencrypted stored on your server.
Give the service provider passwords to your certificates. This might be ideal however you need a level of guarantee that the service will be restarted with the prompt on startup. Be that they may have their monitoring software alert them for this event, however you should under these circumstances be open to situations where the key password is not entered, either at all or with a delay in the password being entered by the service provider. It will be down to you to negotiate what terms the service provider will offer you this service and what guarantees of success they will provide. If they will provide it at all.
Some http servers, such as apache provide a option called SSLPassPhraseDialog which will attempt to decrypt the key using an written program that will pass the correct passphrase out when executed. This can be a shell script or program of your choosing that will do this. This has the benefit of giving you option no 1, but acts merely as a weak barrier to all the problems described in option number 1. In addition, depending how careful you are (or not) supplying a password executable this might provide a mechanism for someone to get something other than the passphrase executable to run at startup.
Have your hosting provider require they supply with with a scheduled downtime (if its them doing the rebooting) so you can be ready to insert the password in yourself, or alter the updates to run at time where you can be ready to enter the pass phrase to the certificate promptly.

My first suggestion is ask yourself why you need to encrypt the SSL certificate for, and what losses this produces on your operation if service is down for, say - 2 hours until it is discovered. What are the potential losses to you if the certificate is breached, and how much time would it take to rectify? If it costs more than your SSL certificate itself and the time to recover in the event of a breach is too high, then perhaps it is right to keep it encrypted.
To be blunt, you cant have your cake and eat it. If you want to encrypt the SSL key, then you do so at the cost of non-graceful restarts and delays to your operation. If you encrypt it but provide a way to automate decryption, its probably just as worthless, or potentially more dangerous than having the key decrypted in the first place. If you make it your VPS providers responsibility, then your just shifting the problem onto them and it will likely either cost you a lot to give you the guarantees you want, or you'll have to accept that there will be times where the VPS provider doesnt meet your expectations when they reboot the VPS.
My suggestion, is to make reboots timely and with forewarning, I dont think it would be unreasonable to ask your VPS provider for this. That way there shouldn't be an incident you cannot at least put under some control.
*The problem of using SSLPassPhraseDialog is a similar, more common and problematic mistake people do with cron jobs. That is, deploy cronjob to run as root, then make the files ownership of whats run a non-root (say FTP) user who can potentially modify the application to escalate privileges. If you write a program to spit out the passphrase, make steps to ensure that the file is not readily readable nor is the file modifyable with anything but root (this includes making sure its parent directory its kept in is not owned by someone else).


detect if the user switched to NO in location services

Question: I have a code which redirects to settings if GPS or network is not enabled.The problem is that I want to either programmatically enforce location service when the alert dialog detects that GPS is not enabled or detect the option user has selected in location services and then redirect back to the calling activity.Also I want the location to be checked every 10 seconds until the particular activity is on.please help me
My GPS Checking method
 public void setGPSLocation()
{
    GPSTracker gps = new GPSTracker(FormBuilderActivity.this);
    // check if GPS enabled
    if(gps.canGetLocation()){
        latitude_loc = gps.getLatitude();
        longitude_loc = gps.getLongitude();

        // \n is for new line
        // Toast.makeText(getApplicationContext(), "Your Location is - \nLat: " + latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show();
    }else{
        latitude_loc = 0.00;
        longitude_loc = 0.00;
        // can't get location
        // GPS or Network is not enabled
        // Ask user to enable GPS/network in settings
        gps.showSettingsAlert();

    }
}

GPSTracker.class
public class GPSTracker extends Service implements LocationListener {
private final Context mContext;
// flag for GPS status
boolean isGPSEnabled = false;
// flag for network status
boolean isNetworkEnabled = false;
// flag for GPS status
boolean canGetLocation = false;
Location location; // location
double latitude; // latitude
double longitude; // longitude
// The minimum distance to change Updates in meters
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
// The minimum time between updates in milliseconds
private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute
// Declaring a Location Manager
protected LocationManager locationManager;
public GPSTracker(Context context) {
    this.mContext = context;
    getLocation();
}
public Location getLocation() {
    try {
        locationManager = (LocationManager) mContext
                .getSystemService(LOCATION_SERVICE);

        // getting GPS status
        isGPSEnabled = locationManager
                .isProviderEnabled(LocationManager.GPS_PROVIDER);
        // getting network status
        isNetworkEnabled = locationManager
                .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        if (!isGPSEnabled && !isNetworkEnabled) {
            // no network provider is enabled
        } else {
            this.canGetLocation = true;
            if (isNetworkEnabled) {
                locationManager.requestLocationUpdates(
                        LocationManager.NETWORK_PROVIDER,
                        MIN_TIME_BW_UPDATES,
                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                Log.d("Network", "Network");
                if (locationManager != null) {
                    location = locationManager                                .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    if (location != null) {
                        latitude = location.getLatitude();
                        longitude = location.getLongitude();
                    }
                }
            }
            // if GPS Enabled get lat/long using GPS Services
            if (isGPSEnabled) {
                if (location == null) {
                    locationManager.requestLocationUpdates(
                            LocationManager.GPS_PROVIDER,
                            MIN_TIME_BW_UPDATES,
                            MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                    Log.d("GPS Enabled", "GPS Enabled");
                    if (locationManager != null) {
                        location = locationManager                                   .getLastKnownLocation(LocationManager.GPS_PROVIDER);
                        if (location != null) {
                            latitude = location.getLatitude();
                            longitude = location.getLongitude();
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return location;
}
/**
 * Stop using GPS listener
 * Calling this function will stop using GPS in your app
 * */
public void stopUsingGPS(){
    if(locationManager != null){
        locationManager.removeUpdates(GPSTracker.this);
    }
}
/**
 * Function to get latitude
 * */
public double getLatitude(){
    if(location != null){
        latitude = location.getLatitude();
    }
    // return latitude
    return latitude;
}
/**
 * Function to get longitude
 * */
public double getLongitude(){
    if(location != null){
        longitude = location.getLongitude();
    }
    // return longitude
    return longitude;
}
/**
 * Function to check GPS/wifi enabled
 * @return boolean
 * */
public boolean canGetLocation() {
    return this.canGetLocation;
}
/**
 * Function to show settings alert dialog
 * On pressing Settings button will lauch Settings Options
 * */
public void showSettingsAlert(){
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
    // Setting Dialog Title
    alertDialog.setTitle("GPS settings");
    // Setting Dialog Message
    alertDialog.setMessage("GPS is not enabled. Please go to settings and switch on the location fetching service");
    // On pressing Settings button
    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog,int which) {

            //turnGPSOn();

            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            mContext.startActivity(intent);
        }
    });
    // on pressing cancel button
    // Showing Alert Message
    alertDialog.show();
}
@Override
public void onLocationChanged(Location location) {
 // TODO Auto-generated method stub
}
@Override
public void onProviderDisabled(String provider) {
  // TODO Auto-generated method stub
}

@Override
public void onProviderEnabled(String provider) {
  // TODO Auto-generated method stub

}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
@Override
public IBinder onBind(Intent intent) {
  // TODO Auto-generated method stub
    return null;
}

}

Comment: Why not use the 'onLocationChanged()' method instead of checking location every 10 seconds, in your GPSTracker class.
Comment: i dont want to detect change in location.I just want to detect if the location service is turned off in settings when the user opens settings and selects no.
Comment: For that you can use other methods, onProviderDisabled, onProviderEnabled. They will serve your pupose.
Answer: Try below code:
@Override
public void onProviderDisabled(String provider) {

    Toast.makeText(context, "Turn On GPS!", Toast.LENGTH_SHORT).show();
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    startActivityForResult(intent, TURN_ON_GPS_ACTIVITY);
}

In your onActivityResult :
case TURN_ON_GPS_ACTIVITY:
            //check gps state
            if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                //Here : when user comes back from settings without switching on GPS
                // Do as you please, either take them again to settings or show some warning message.

            }

I hope this will serve your purpose.
Comment: how do I handle OnActivityResult in service
Comment: Then onProviderDisabled() you can ask user to turn on gps!


StopWatch and 0 milliseconds via c#

Question: I try to calculate time between operations.
So,write two methods with equal code ,but use different ways.
At first way i do like that:
private static void calcAverageTimeUid(ISomeObject someObj, int N,ISnapshot _Snapshot)
    {
        Stopwatch stopWatch = new Stopwatch();
        int averageTime = 0;
        var uid = someObj.Uid;

        for (int i = 0; i < N; i++)
        {
            stopWatch.Start();
            var coll = _Snapshot.GetObject(uid);
            stopWatch.Stop();
            TimeSpan ts = stopWatch.Elapsed;
            averageTime = averageTime + ts.Milliseconds;
        }
        averageTime = averageTime / N;

    }

And i have result averageTime such as 500 milliseconds. N=1000000 and more.
But , i rewrite this method to two methods: mainCalc ,wich should contains come other methods,f.e.
to get average time of uid,id,name and so on.
mainCalc:
private static void mainCalc(ISomeObject someObj,int N,ISnapshot _Snapshot)
    {

        int averageTimeUID = 0;
        for (int i = 0; i < N; i++)
        {
            var tmp=calcAverageTimeUid2(someObj,N,_Snapshot);
            averageTimeUID+=tmp;
        }
        averageTimeUID = averageTimeUID / N;
    }

And other method:
private static int calcAverageTimeUid2(ISomeObject someObj,int N,ISnapshot _Snapshot)
    {
        Stopwatch stopWatch = new Stopwatch();
        var prop = someObj.Uid;
        stopWatch.Start();
        var obj = _Snapshot.GetObject(prop);
        stopWatch.Stop();
        TimeSpan ts = stopWatch.Elapsed;
        return ts.Milliseconds;
    }

So, i run mainCalc and run calcAcerageTimeUid2 in this method.And result of stopWatch=0 milliseconds!
It is wrong result or not? I dont understand-what way of use stopWatch right?
P.S. delete one of excess StopWatch.
P.P.S. Thank all of you!
Comment: You aren't starting the stopwatch in one of those methods.. (Hint: The middle one).
Comment: The first snippet has a bug, it doesn't reset the stopwatch.  The second snippet gets that right but then uses milliseconds when the timed operation takes less than a millisecond.
Comment: @SimonWhitehead: he is using the stopwatch in the `calcAverageTimeUid2` and returning the result. MainCalc is summing up the total time.
Comment: I don't quite understand your point, but you should restart or reset the stopwatch if you want it to show the amount of time on each operation.
Comment: Ah yes I see that now! Silly me :)
Answer: Your first routine should be
    for (int i = 0; i < N; i++)
    {
        stopWatch.Start();
        var coll = _Snapshot.GetObject(uid);
        stopWatch.Stop();
    }
    averageTime = stopWatch.Elapsed / N;

Note, stopWatch.Start() does not reset the stopwatch back to zero.
Comment: First will not give meaningful result because the operation is less than a millisecond. Second is solid.
Answer: The reason you get different results is because you are rounding the number of milliseconds in different places. In your first method, you use one stopwatch and continuously Start() and Stop() it. Your operation must take less than 1 ms, but when you repeatedly start and stop the same stopwatch, the total number of ticks will still increase. That is why with N=1000000 you got only 500 ms.
In the second method, you start and stop a new stopwatch each time, and return the milliseconds. Since each operation is averaging 500/1000000 = 0.00005 ms, the ticks of the stopwatch will accumulate some small value, but the ElapsedMilliseconds (or Milliseconds of the TimeSpan) will still be 0.
EDIT: To solve your problems, the first loop should use the final Elapsed value of the stopwatch once the loop is complete (like the 2nd example in sgmoore's answer). The second method should return the ticks from the method rather than milliseconds and then calculate the milliseconds from the tick frequency of the stopwatch.
In summary, the first operation you are summing a bunch of values like 0.00005, in the second you are summing a bunch of 0s.
Answer: Milliseconds is not TotalMilliseconds.
Milliseconds is the entire number of milliseconds of the TimeSpan. Not the total milliseconds which is a double, so you are losing the precision under 1ms.
And why do you return an int, instead of the TimeSpan?
Try this code :
private static void mainCalc(ISomeObject someObj, int N, ISnapshot _Snapshot)
{
    var averageTimeUID = TimeSpan.Zero;
    for (int i = 0; i < N; i++)
    {
        averageTimeUID += calcAverageTimeUid2(someObj,N,_Snapshot);
    }
    averageTimeUID = new TimeSpan( averageTimeUID.Ticks / N );
}

The other method:
private static TimeSpan calcAverageTimeUid2(ISomeObject someObj, int N, ISnapshot _Snapshot)
{
    var stopWatch = new Stopwatch();
    var prop = someObj.Uid;
    stopWatch.Start();
    var obj = _Snapshot.GetObject(prop);
    stopWatch.Stop();
    return stopWatch.Elapsed;
}

Comment: Maybe averageTimeUID = new TimeSpan(averageTimeUID.Ticks/N); ?
Comment: @user2545071 : you are right, the constructor of TimeSpan takes Ticks and not Milliseconds, I have made the edit.

StopWatch and 0 milliseconds via c#


Is this the right way to go about proving this? $\lim_{x\to-3}((x+3)/(x^2-9))=1/6$

Question: $$\lim_{x \to -3} \frac{x+3}{x^2-9}$$
Suppose the limit is $\frac{1}{6}$.
Given $\epsilon>0$, choose $\delta=min(1,-7(\frac{1}{6}-\epsilon),(7(\frac{1}{6}+\epsilon))$
Then $7(\frac{1}{6}-\epsilon)<x+3<7(\frac{1}{6}+\epsilon)$.
So $\frac{1}{6}-\epsilon<\frac{x+3}{7}<\frac{1}{6}+\epsilon$
Then $-\epsilon<\frac{x+3}{7}-\frac{1}{6}<\epsilon$
Which is equivalent to $|\frac{x+3}{7}-\frac{1}{6}|<\epsilon$
Since $\delta<1$, $|x+3|<1$ means $|x^2-9|<7$,
so $|\frac{x+3}{x^2-9}-\frac{1}{6}|<\epsilon$.
Comment: Minor note: I think the limit is actually $-\frac16$.
Comment: The last step is a little confusing to me: it seems that if the thing inside the absolute value bars is very very close to $\varepsilon$, you might screw things up by making it larger (which is what happens when you replace a denominator in a positive term with something smaller). On the other hand, it might be fine, but you'd need to convince me.
Comment: You need a few steps between 2 and three.  You use an epsilon without declaring it.  You define a delta and then never use it.  Then you make a claim about x+3 that isn't true for all x.  (What if epsilon = 0 and x= .... say 53,876?)
Comment: What if $x^2  < 9$ then you have $|x+3/x^2-9 + 1/6 | < e $.
Comment: If you are trying to prove the limit is $1/6$, then it is absolutely wrong to start with "Suppose the limit is $1/6$."
Answer: Firstly, $$\lim_{x\to -3}\frac{x+3}{x^2-9} = \frac{-1}{6}$$
To see how to arrive at this we use the algebra of limits of functions.
$$\lim_{x\to -3}\frac{x+3}{x^2-9} = \lim_{x\to -3}\frac{x+3}{(x-3)(x+3)} $$
We can cancel because it is not in the indeterminate form. (x is approaching -3, but not reaching it).
Therefore, $$\lim_{x\to -3}\frac{x+3}{(x-3)(x+3)} = \lim_{x\to -3}\frac{1}{x-3} = \frac{-1}{6}$$
Secondly, how can you guarantee the validity of the third line? Also, $a<c$ and $b<d$ doesn't imply $\frac{a}{b}<\frac{c}{d}$.
P.S. My humble apologies if I have misinterpreted anything.


Python Boolean returning empty

Question: why is this code not doing what i want it to do?
i want a simple True\False output but it keeps returning empty no matter how i write it.
what am i doing wrong here??
tried:
yes = "True"
no = "False"

def check_up(num):
  if num == 2:
    return f"yes {yes}"
  else:
    return f"something {no}"

num = int(input("please enter a number: "))

and also:
def check_up(num):
  if num == 2:
    return True
  else:
    return False

num = int(input("please enter a number: "))

simple True\False output.
Comment: where do you call `check_up`? Where do you output anything?
Comment: What is the function `check_up(num)`? You have defined it, but never call it.
Comment: You'll need to call *check_up()* and do something with its return value. *print()* maybe?
Answer: Make sure you call the check_up method and print the result.
You can also simplify the check_up method.
def check_up(num):
    return num == 2

num = int(input("Please enter a number:\n")
result = check_up(num)
print(result).

Or even simpler:
num = int(input("Please enter a number:\n"))
print(num == 2)

This code will print True if the user inputs 2 and False if any other integer is inputted. If the input cannot be parsed as an integer an except will be thrown.
Edit
Like DarkNight said; an exception will be thrown if the inputted string cannot be parsed as an integer.
Comment: And if the user enters BANANA you'll get an Exception. Probably ought to deal with that

Python Boolean returning empty