How do I pass an organic groups GID to a view in a pane?

Question: I have a drupal 7 site using Organic Groups, for each group I have list pages - so for instance if i have the group mygroup I have a page which lists all posts - (www.mysite.com/groups/mygroup/posts). This page has a groups audiance field (og_group_ref) which has the correct gid..
I have the list page set up with panes one of which is a view showing all posts with the contextual filter set to GID.
The view works on its own if I pass in the GID of the group I want, however, I cannot get this to cooperate with the list page, probably something to do with the pane, or panels, or a relationship I need to add to the view?
I've tried inserting the view into the pane as a content pane and as a block, but I'm having no joy...
What do I need to do to get this to work?
I have since found this post:
How do you display a pane in an organic group?
this seems to be the answer to what I'm looking to do, however, the settings shown in that post are not available to me. Maybe because panels/views/og have been updated and the settings are a little different now? Either way I still don't have this working. Does anyone have any pointers?
Comment: Did you check the tutorials at nodeone.se ?
Comment: I've had a look - but nothing which has helped solve this for me..
Answer: Solved it like this:

Create a "Content pane" view mode of your view, and set "Argument input: Input on pane config".
Create a contextual filter in your view that expects a group ID value.
Enable the "Tokens" display mode for content type with the og_group_ref field. According to here:

Go to "Structure → Content Types → [your content type] → Manage Display".
Click "Custom Display Settings" below the field list, enable the "Token" option and save.
Go to the new "Token" display mode in the horizontal tabs on the top.
For yourog_group_ref field, set "Format: Entity id" and save.

In the Panels configuration of your list, insert your View pane.
In the View pane config form, there will be a single input field expecting a gid value and saying "You may use keywords for substitutions." below. Enter %node:og_group_ref.

How I think it works: Panels allows CTools context keywords when supplying arguments to panels. These context keywords are automatically available for all fields (%node:nid works out of the box) and all defined tokens (examples). But for fields, they evaluate to the formatted field value, such as your group's name. We could change this behavior by defining a token of the same name, and choosing a formatter that outputs the raw value (the number) when that token is evaluated.
References:

This Drupal SO question, providing the basic technique.
Comment: I do it the way that post you linked does it but instead, in my content pane settings, I pass the node:content id as the argument. The option only shows after you've added the contextual filter for group ID.
Comment: @NiallMurphy, that's where you can select the argument from a long select list, right? Nice, I know the technique but could not get it to work for group IDs. I guess it deserves its own answer, both for embedding the view on the group node and a group content node (as in the original question).
Answer: Simpler solution that works without Token display mode:

Create a "Content pane" view mode of your view, and set "Argument input: Input on pane config".
Create a contextual filter in your view that expects a group ID value.
In the Panels configuration of your list, insert your View pane.
In the View pane config form, there will be a single input field expecting a gid value and saying "You may use keywords for substitutions." below. Enter %node:og_group_ref:nid.

How it works: Panels allows CTools context keywords when supplying arguments to panels. They are automatically available for all fields, and they are chainable like Drupal [tokens]. This is not obvious, since it's not included in the context keywords list (shown after creating a Panel variant, in the panel's content section, after unfolding "Substitutions").
Since a group ID is the node ID of the node functioning as group, %node:og_group_ref:nid will supply the required ID. If your groups are not node entities, they might use a different field for the ID. For example, CiviCRM contact records use cid, so you would supply %node:og_group_ref:nid.


How to store values to field collection or paragraphs programmatically?

Question: How do I store values to either a field collection or a paragraphs field  programmatically?
Could somebody please provide a working code example of how you do this?
I would have a field holder containing the following three fields where I want to store down my data:

field_title - (1 value text field)
field_text - (1 value text field - long)
field_sources - (unlimited no of values text field)

Thanks for helping me out.
Answer: Paragraphs and field collections are both their own entity and the fields pointing to them are just entity referenced.
So if you want to create a node with a referenced paragraph, you first create the paragraph with all the values you want, save it, then create the node and point it to the paragraph you created.
The Paragraph demo module has example code that does exactly that in paragraphs_demo_install():
  use Drupal\node\Entity\Node;
  use Drupal\paragraphs\Entity\Paragraph;

  $paragraph3 = Paragraph::create([
    'type' => 'text',
    'field_text_demo' => 'Apart from the included Paragraph types, you can create your own simply by going to Structure -> Paragraphs types.',
  ]);
  $paragraph3->save();

  // Add demo content with two paragraphs.
  $node = Node::create(array(
    'type' => 'paragraphed_content_demo',
    'title' => 'Welcome to the Paragraphs Demo module!',
    'field_paragraphs_demo' => array(
      array(
        'target_id' => $paragraph3->id(),
        'target_revision_id' => $paragraph3->getRevisionId(),
      ),
    ),
  ));
  $node->save();

Comment: This was extremely helpful. Seems to be very few examples of this anywhere.
Comment: @Berdir Does the paragraph_demo module has example to import data from table? Also can you pls help with https://stackoverflow.com/questions/60156482/php-foreach-upload-data-into-drupal-paragraph-entity?
Answer: I'm on Drupal 8.3.4 with paragraphs 8.x-1.1. When I use the code in the other answer, the node gets created without any reported problem.
But when I go to view the node, I get this error: Error: Call to a member function displaySubmitted() on null in template_preprocess_node() (line 621 of core\modules\node\node.module).. When I try to edit it, I get this error: Error: Call to a member function getPreviewMode() on null in Drupal\node\NodeForm->actions() (line 182 of core\modules\node\src\NodeForm.php).
The code in this comment worked for me.
use Drupal\paragraphs\Entity\Paragraph;  // Don't forget to use a little Class...

/**
 * Create a New Paragraph and attach it to it's node
 * @param int $nid
 *  The node id this paragraph should be attached to
 * @param longtext $content
 *  The body text of the paragraph
 * @param int fid
 *  The file id if any, or FALSE
 *
 */
function CUSTOM_MODULE_create_paragraph($nid, $content, $fid = FALSE) {
  $node = entity_load('node', $nid);
  $paragraph = Paragraph::create(['type' => 'PARAGRAPH_TYPE',]);
  $paragraph->set('TEXT_FIELD_NAME', $content);
  if ($fid) {
    $file = file_load($fid);
    $paragraph->set('IMAGE_FIELD_NAME', $file);
  }
  $paragraph->isNew();
  $paragraph->save();

  // Grab any existing paragraphs from the node, and add this one
  $current = $node->get('NODE_FIELD_NAME')->getValue();
  $current[] = array(
      'target_id' => $paragraph->id(),
      'target_revision_id' => $paragraph->getRevisionId(),
    );
  $node->set('NODE_FIELD_NAME', $current);
  $node->save();
}


Watir::Element ole_object value when accessing object directly vs. using collection

Question: Let's say I have a single link with a class 'example'. a(class: 'example').ole_object returns nil, whereas as(class: 'example').first.ole_object returns a WIN32OLE object. Why?
Answer: The difference is that Watir::Element is lazily located, where as Watir::ElementCollections are located immediately.
The Watir::Element#ole_object method simply returns the value of @o:
def ole_object
  @o
end

@o is only set when the locate method is called:
def locate
  @o = @container.locator_for(TaggedElementLocator, @specifiers, self.class).locate
end

When you create a Watir::Element, but do not do anything with it, you can see that it is not yet located (ie lazy located):
p browser.link(id: 'an id that does not need to exist')
#~ #=> #<Watir::Link:0x..fc40fdd4a located=false specifiers={:tag_name=>["a"], :id=>"an id that does not need to exist"}>

Once the element gets located, typically when locate is called through another method such as text, the @o will get set with the Win32OLE object:
e = browser.link
p e.ole_object
#=> nil

e.locate # this is called internally by other methods such as text, click, etc.
p e.ole_object
#=> #<WIN32OLE:0x30de3c0>

In contrast, you will see that the element collection methods, such as links will immediately go and find all elements. As a result, those elements will already be located and have a @o specified.
p @browser.links(id: 'some id that exists')
#<Watir::LinkCollection:0x58b43284 length=1 container=#<Watir::Browser:0x40fa1c8c url="https://some.page.com" title="Test Page">>

Comment: Thanks. I've noticed this when I tried to pass the link to some function simulating a hardware click which required ole_object to exist.


Rotate object around a fixed coordinate axis

Question: I am trying to let the user of my app rotate a $3D$ object drawn in the center of the screen by dragging their finger on screen. A horizontal movement on screen means rotation around a fixed Y axis, and a vertical movement means rotation around the X axis. The problem I am having is that if I just allow rotation around one axis the object rotates fine, but as soon as I introduce a second rotation the object doesn't rotate as expected.
Here is a picture of what is happening:

The blue axis represents my fixed axis. Picture the screen having this fixed blue axis. This is what I want the object to rotate in relation to. What is happening is in red.
Here's what I know:
The first rotation around $Y (0,1,0)$ causes the model to move from the blue space (call this space $A$) into another space (call this space B)
Trying to rotate again using the vector $(0,1,0)$  rotates around the $x$ axis in space B NOT in space $A$ which is not what I mean to do.
Here's what I tried to fix this, given what I (think) I know (leaving out the W coord for brevity):

First rotate around $Y (0, 1, 0)$ using a Quaternion.
Convert the rotation Y Quaternion to a Matrix.
Multiply the inverse of the $Y$ rotation matrix by my fixed axis $x$ Vector $(1, 0, 0)$ to get the fixed $X$ axis in relation to the new space.
Rotate around this new X Vector using a Quaternion.

This isn't working how I expect. The rotation seems to work, but at some point horizontal movement doesn't rotate about the $Y$ axis, it appears to rotate about the $Z$ axis.
I'm not sure if my understanding is wrong, or if something else is causing a problem. I have some other transformations I'm doing to the object besides rotation. I move the object to the center before applying rotation. I rotate it using the matrix returned from my function above, then I translate it -2 in the Z direction so I can see the object.
Comment: Your nice animation shows 3 rotations, with 9 vectors. Which are X and Y?  You should be able to just keep multiplying the object's current quaternion by the new finger-swipe quaternion, and it should work.  The problem is unlikely to be in your other transformations.  It looks like using a quaternion for step 1 is a waste of time since you could directly get the result of step 2 with a sin and cos.  Then steps 3 and 4 seem to be the source of your problem -- rotating around the **rotated X axis** (red) is exactly what you don't like. Just rotate around the standard X axis (blue).
Comment: Can you be more specific about how you approach the problem? What exactly are you using?
Comment: @Olivier I posted a more detailed version of the question [here](http://bit.ly/1xkOFJo)
Comment: Has it not been answered?
Comment: Nope. I've asked on Reddit, Unity Answers, Game Dev stack, and here. No answer, at least not an acceptable one that actually answers my question.
Comment: I don't think your question is clear enough. What *exactly* is your input information and what do you want to achieve? What *exactly* have you done so far? A rotation is done about an axis and with a given angle. How do you calculate those two things given the user input?
Comment: I'm trying to apply multiple rotations to an object in 3D space relative to a fixed coordinate axis. The problem is applying the first rotation moves the local coordinate space, so a second rotation is about that space and not the fixed space I intend. See the pic (blue is fixed space, red is first rotation, yellow is second etc.).
Comment: Have no idea what your problem is, but I know for sure that user interaction with rotating objects has been implemented correctly within the Advanced Visual Systems company: [AVS Express](http://www.avs.com/solutions/express/) . Maybe ask them for a demo or free trial, just to see how it works.
Comment: Why not rotate (infinitesimally) around a _fixed axis_ instead of a fixed _coordinate_ axis?
Comment: It sounds like you're trying to implement a virtual trackball. Perhaps take a look at [existing formulations that people have studied](http://www.diku.dk/~kash/papers/DSAGM2002_henriksen.pdf)?
Comment: I like you animation+1
Answer: I think your problem is related to frame of reference. Your global frame is A and other frames obtained after rotation in A are local frames (such as B). So u want all your rotations in global frame but they are taking place in local frame. For rotation in global frame of reference you need to pre-multiply the transformation matrix and for rotation in local frame, post-multiply. For eg, if u want rotation by $\theta_1$ in A for which transformation matrix is $R_{\theta_1}$ and then rotation by $\theta_2$ in A (rotation matrix $R_{\theta_2}$), then:
$$V_f = R_{\theta_2}*R_{\theta_1}*V_i$$
where $V_i$ is initial position of the point(or object) and $V_f$ is final.
for further reference, check this link:
Maths - frame-of-reference for combining rotations


Computer and electronic softwares for professional musicians and composers

Question: What I want to know is specific.
I want to start experimenting and developing skills and knowledge in music production and composition by computers.
I have read that Digital Audio Workstations like FL Studio require no compositional and technical musical skill and knowledge.
I am a composer and musician. I've been composing and playing the piano and the guitar for almost a decade now. I was wondering if there were any range of softwares that would take advantage of someone's technical knowledge of music in theory, composition,etc. who wishes to start experimenting with computer music in general.
My experience with computer (music-wise) is using score writers like Sibelius for composition.
And my technical knowledge of computers is in programming(Java, Python, PHP, etc.)
Thank You.
Comment: A) I don't think it's really true that you don't need any knowledge of music to use a DAW and 2) even if it **is** true, all DAWs will take advantage of whatever musical knowledge you already have. It's like a word processor. If you don't know a lot about writing, you can still use a word processor, but if you are an excellent writer, then what you write with your word processor will be consummate with your writing skills.
Comment: So, let me specify my question even more. Now I get that DAWs can also be used by people with technical knowledge of music. But is there any variety of music softwares specifically designed to take advantage of technical knowledge to produce music??
Comment: Well, there are [musical scripting languages](https://nosuch.com/plum/cgi/showlist.cgi?sort=name&concise=yes) and construction tools like [Max](https://cycling74.com/products/max). Is that what you mean? Frankly, any DAW that supports MIDI can lead you deep into the weeds of different types of MIDI messages and MTC and stuff like that. And customizable control software like Lemur get pretty technical. Most DAWs are actually fairly complicated. There's a lot to do in music that is also challenging technically.
Comment: Just building and using a set of [Mi.Mu gloves](https://mimugloves.com/) would be a significant technical and musical challenge, and would open up all kinds of interesting composition and performance possibilities.
Comment: @ToddWilcox Actually your mentioning the musical scripting language and the link you that you added is interesting. I need to check it out. Thanks!
Comment: The answers altogether gave me a general idea to start exploring and experimenting with computer music. There are people who know how to ask questions perfectly and also answer, perhaps they hang out a lot in here. I'm a musician/composer and just wanted to start learning computer music and I wasn't sure where to start; that's why my question may have seemed "not appropriately articulated". But still, what I wanted to know wasn't precise for me to raise a question inside a context. Anyway, thank you guys, your answers helped me get an idea how to start.
Answer: People generally use computers to make music in two main ways.
You can construct a musical collage from pre-packed 'loops' and 'beats' without any musical knowledge (beyond 'this sounds good!) at all.  FL Studio is aimed at this end of the market. I believe the leading producers of a genre called 'Grime' favour FL, and it seems to be making them a great deal of money!
Then there's the people who COULD score for an orchestra, play in a rock band, whatever... but use a computer to emulate these expensive and sometimes unavailable resources! They use programs such as Cubase, Sibelius etc.
And, of course, there's a whole LOT of people between these two extremes, who trial-and-error their way to a result.
Then there's a few people who experiment with composition algorithms, pure 'computer music'.  Here's some starter information:
http://donyaquick.com/algorithmic-composing-advice/
Answer: If you have even a basic understanding of music composition, you'd benefit from using a DAW in order to compose music. What is said about DAWs not requiring any prior musical knowledge is correct in that it is easy to make a sound and it is easy to layer it on top of other sounds, and it is easy to sequence them together until you have something that's track-worthy. However, this doesn't mean that they are so abstracted that someone as a musician or composer would not be able to utilize them.
In my experience with FL Studio (as it is my DAW of choice), I find that my prior musical knowledge, of rhythms, notes, harmonies, and so on, make it easier to navigate and get accomplished what I'm hoping to do. This is also augmented if you have a MIDI keyboard and are able to record your playing into the DAW to lay down a sequence. I spend a lot of time in the Piano Roll in FL Studio getting melodies and harmonies assigned to individual instruments, then I layer them on top of each other and set automation values to get my desired results.
One big important thing to keep in mind is that you'll need to venture into the world of VSTs a good amount to be able to make music solely out of a DAW install.  FL Studio comes prepackaged with some simple VSTs that will allow you to get your feet wet, but depending on the style of composition you'd like to develop, you'll want to hunt around for the VSTs that give you the sound you want (for example, if your aim is EDM, z3ta+ is common, as is reFX's Nexus. You could look at Miroslav's Philharmonik as a good starter for orchestral instruments, as well, though there are probably better.)
Lastly, the fast way to bridge the gap between a DAW and engraving software like Sibelius is to understand the corollaries. For example, a track in a DAW is like an individual instrument in the score. You assign a VST or Sample to this track, and then use the piano roll to decide at what time (which measure, beat, etc.), for how long, and which note. That's sort of like putting down the notation. You can then map these tracks to mixer i/o tracks, in order to control their gain, panning, and other effects, and apply effects to them. This is sort of like applying dynamics and other style markings in written notation.
EDIT: Forgot to mention: FL Studio comes as a demo (in which you can't save your work), but should give you full enough functionality to try out and see if it works for you. There are different DAWs for different ways of conceptualizing the idea of music composition in software. Check a few of them out this way before committing and see if you can find one that matches your style.
Answer: I was in the same position as the OP twenty years ago: plenty of experience with guitar and piano, along with music theory. I started off with a MIDI sequencer, playing back through the sequencer and computer's sound card. After several changes of computer with different sound cards, I started work with Reason, which is a DAW. I never did get to grips with the sequencer in Reason, so I still work on the notes in the sequencer, outputting MIDI files which I then import into Reason, where I work on the sounds.


Matching HERE Maps items with Wikipedia content using REST APIs

Question: Using the V7 version of the HERE Maps REST api, I'm trying to get match the data I'm getting from the /browse and /discover endpoints and match them unambiguously with data obtained from the Wikimedia Action APIs for a tourists guide app.
For example, by calling the the following endpoint:
curl "https://discover.search.hereapi.com/v1/browse?in=circle%3A45.4627338,9.1777323%3Br%3D300&limit=30&apiKey={API KEY REDACTED}&categories=300-3000-0025&at=45.4627338,9.1777323&lang=en-US" \
     -H 'Accept: application/json' \
     -H 'Accept-Encoding: gzip'

we get an JSON Formatted array of Points Of Interest around the center of Milan, here's a single element from it:
{
  "title":"Basilica di Sant'Ambrogio",
  "id":"here:pds:place:380u0nd8-2d259709e0aa42908182e1a03a8d9aca",
  "language":"en",
  "resultType":"place",
  "address":{
    "label":"Basilica di Sant'Ambrogio, Piazza Sant'Ambrogio, 15, 20123 Milan MI, Italy",
    "countryCode":"ITA",
    "countryName":"Italy",
    "state":"Lombardy",
    "countyCode":"MI",
    "county":"Milan",
    "city":"Milan",
    "district":"Duomo",
    "street":"Piazza Sant'Ambrogio",
    "postalCode":"20123",
    "houseNumber":"15"
  },
  "position":{
    "lat":45.4624,
    "lng":9.1757
  },
  "access":[
    {
      "lat":45.46219,
      "lng":9.17481
    }
  ],
  "distance":163,
  "categories":[
    {
      "id":"300-3200-0030",
      "name":"Church",
      "primary":true
    },
    {
      "id":"300-3000-0023",
      "name":"Tourist Attraction"
    },
    {
      "id":"300-3000-0025",
      "name":"Historical Monument"
    },
    {
      "id":"300-3100-0028",
      "name":"History Museum"
    },
    {
      "id":"300-3100-0029",
      "name":"Art Museum"
    },
    {
      "id":"900-9300-0221",
      "name":"Residential Area\/Building"
    }
  ],
  "references":[
    {
      "supplier":{
        "id":"core"
      },
      "id":"1175957532"
    },
    {
      "supplier":{
        "id":"core"
      },
      "id":"1175957749"
    },
    {
      "supplier":{
        "id":"core"
      },
      "id":"50930489"
    },
    {
      "supplier":{
        "id":"core"
      },
      "id":"800801056"
    },
    {
      "supplier":{
        "id":"tripadvisor"
      },
      "id":"591187"
    },
    {
      "supplier":{
        "id":"yelp"
      },
      "id":"QIqHOCwwIy1kFTPiPIeGnQ"
    }
  ],
  "contacts":[
    {
      "phone":[
        {
          "value":"+39028057310"
        },
        {
          "value":"+390286450895",
          "categories":[
            {
              "id":"300-3100-0028"
            },
            {
              "id":"300-3200-0030"
            }
          ]
        }
      ],
      "www":[
        {
          "value":"http:\/\/www.basilicasantambrogio.it",
          "categories":[
            {
              "id":"300-3100-0028"
            },
            {
              "id":"300-3200-0030"
            }
          ]
        }
      ]
    }
  ]
}

I can see HERE maps returning a series of entities IDs matching both Tripadvisor and Yelp, but nothing explicitly pointing to wikipedia.
It seems that this information was available on a deprecated version of the API using the show_content parameter, but I can't find anything equivalent for the currently available revision.
Has anyone been able to translate between the two systems? I guess I could go for a less precise approach and roughly match between latitude, longitude and place name, but it feels way too 'hacky' and I'd rather avoid multiple query requests to wikipedia for every single location.
Has anyone faced anything similar? I feel like I'm missing something obvious but I can't figure out which parameters should I actually be using.
Answer: First you need to query Wikipedia using normal wording, like the City name etc. And refine it until you know the resulting page will most likely be the page you need each time.
Then the Wikipedia API will return you huge arrays that are hard to work with, but there is one key value which is the ID of each Wikipedia page. It is hidden in a huge array, and this is what determines if you get the correct page or not.
Sorry for the very unpolished code but this is very old and the Wikipedia API is very complex. I hope it serves as an example.
You can imagine what the missing values are, and it should give you a place to start.
Here I am extracting the title of an article and the page ID, and then the contents of the article with a normal query by the name that the short description. So I am effectively using 2 distinct Wikipedia APIs and feeding them the data I get from the HERE APIs. So you can see both functions as separate examples.
 //wikipedia title
  wikiQueryBaseUrl="https://en.wikipedia.org/w/api.php?format=json&origin=*&action=query&titles=";
  if(typeof city !== 'undefined'){
  wikiQueryUrl=wikiQueryBaseUrl+city;}
  else{wikiQueryUrl=wikiQueryBaseUrl+inputValue};
  fetch(wikiQueryUrl)
  .then((response) => response.json())
  .then((data) => {
  preWikiData = data;
  pageId = Object.keys(preWikiData.query.pages)[0];
  if(preWikiData.query.pages[pageId] !== 'undefined'){
  wikiLink="http://en.wikipedia.org/?curid="+pageId}
  if(pageId == '-1'){
    wikiLink="https://en.wikipedia.org/";
  };

  //wikipedia data
  wikiQueryBaseUrl="https://en.wikipedia.org/w/api.php?format=json&origin=*&action=query&prop=extracts&exintro&explaintext=true&titles=";
  wikiQueryUrl=wikiQueryBaseUrl+country.replace(' ', '')+"&redirects=1";
  fetch(wikiQueryUrl)
  .then((response) => response.json())
  .then((data) => {
  preWikiData = data;
  pageId = Object.keys(preWikiData.query.pages)[0];
  if(typeof preWikiData.query.pages[pageId].title !== 'undefined'){
  wikiData=preWikiData.query.pages[pageId].extract;}
  });


Regular Representation of infinite groups

Question: I am aware of the importance of the regular representation of finite groups, but I am curios if there is an analogous notion for infinite groups. How is the regular representation of a infinite group defined? Does it decompose as the sum of all irreducible representations? Can we generalise this to a regular module of an algebra?
Answer: For an abstract infinite group $G$ the definition is the same as in the finite case; over a field $k$ you can always consider the action of the group algebra $k[G]$ on itself by left multiplication (and this generalizes to any ring whatsoever). It is never completely reducible if $G$ is infinite; see this math.SE answer. Every irreducible representation is (cyclic, hence) a quotient of $k[G]$ but the surjection $k[G] \to V$ need not split; it never splits, for example, if $G = \mathbb{Z}$.
In a positive direction, if $G$ is a compact (Hausdorff) topological group it has a regular representation on $L^2(G)$ where $G$ is equipped with Haar measure. By the Peter-Weyl theorem this representation decomposes as a (Hilbert space) direct sum of all the irreducible representations of $G$, and as in the finite group case a given representation $V_i$ occurs with multiplicity $\dim V_i$. For example when $G = S^1$ this recovers the (bare bones of the) theory of Fourier series.


Deep NNs, backpropagation and error calculation

Question: I was following the backpropagation tutorial by Michael Nielsen on http://neuralnetworksanddeeplearning.com/chap2.html, one of the very few places where the backprop algorithm is nicely explained both in theory and practice with an actual implementation in python.
Now, something is not clear when he explains how to calculate the error on a specific layer in terms of error in the next layer (I will provide a screenshot because I don't want to mess with notation):

Here, $\delta^l$ is the error in layer l, $\odot$ is the elementwise product betweeen vectors, $w$ is a weight matrix, and $\sigma'$ indicates the derivative of an activation function.
Now, observe he points out that by applying the transpose of $w$ to the next-layer-error vector (which is the previous layer during backprop), one is "sending back" the error across the network, and then, multiplying by the derivative of sigma, one applies (I presume) the chain rule which completes the backprop step.
I have troubles understanding what does he really mean by saying that the traspose "sends back" the error. Why should it?
Perhaps he wants to apply the inverse trasformation? But unless the matrix happens to be orthogonal, which is not the case AFAIK, the transpose does NOT equal the inverse..
What is the algebraic significance of the transpose operator in this specific context?
In any case, I would have thought, reasoning about the chain rule, of applying some kind of differential operator to matrix $w$, instead of transposing it.
Before asking that question, I researched the topic for a long time, but I was unable to find whatever information about that particular point.
Opinions?
Answer: Short answer: the transpose is needed because you're looking at the inputs of all neurons in the next layer accepting outputs of neurons in this layer to calculate an error as a derivative. The original (untransposed) weight matrix expresses how outputs from previous layer are combined to make an input to the neurons in this layer.
Example: Say, you have two fully connected two neuron layers. Hence,

the weights that are involved when calculating the input into the
first neuron of the second layer are: $w_{11},w_{21}$,
while the
weights with which the output of the first neuron of the first layer
gets into the inputs of neurons of the second layer are:
$w_{11},w_{12}$. This is why transpose comes up.

One more thing. Why are we interested in #2? Because we're using them in the full derivative of $C$. We're looking at $\partial C/\partial a^l$, but we want to link it to the same thing in the next layer, so that the back propagation would be invoked. When we look at the derivative with respect to the output of a particular neuron $k$ in this layer, we use the full derivative trick: we express C as a function of inputs of all the neurons $i$ in the next layer that are accepting the output of our neuron $k$ as an input. When we do this the full derivative will be a sum:
$$\frac{\partial C}{\partial a^l_k}=\sum_i\frac{\partial C}{\partial z^{l+1}_i}\frac{\partial z^{l+1}_i}{\partial a_k^l}$$
where obviously $z^{l+1}_i/\partial a_k^l=w^{l+1}_{ki}$ - the transposed weights.
Comment: I think I understand now. The algebra involved is certainly clear, but if you want to expand a little bit conceptually, feel free to do it. I'll accept your answer within 24h.
Comment: which concept is unclear? there's a bunch of them used here.
Comment: I crunched the second part (the most interesting) of your answer for a while, and I think it's all clear now. Thanks again, accepted!


Erro de compilação ao usar string.Join

Question: Estou escrevendo um código de exemplo de busca binária que encontrei em um livro e recebo o seguinte erro do compilador:

CSI 503 Argument 1: cannot convert from 'char' to 'string'
CSI 503 Argument 2: cannot convert from 'int[l' to 'string'

Imagem com os erros do compilador
O erro ocorre nesta linha:
 Console.WriteLine(string.Join(',', sortedArr));

Ao alterar essa linha para:
Console.WriteLine("," + sortedArr);

O compilador não aponta erro, mas não tenho a saída esperada. A saída dele deveria ser null mas é:

,System.Int32[]

Como posso corrigir isso?
Código completo:
using System;
using System.Collections.Generic;
using System.Linq;

namespace SelectionSort
{
    class Program
    {
        static void Main(string[] args)
        {
            var numbers = new int[] { 4, 5, 1, 3, 10, 9, 6, 8, 7, 2 };
            var sortedArr = SelectionSort(numbers);

            Console.WriteLine(string.Join(',', sortedArr));
        }

        private static int[] SelectionSort(int[] array)
            => SelectionSort(new LinkedList<int>(array)).ToArray();

        private static IEnumerable<int> SelectionSort(LinkedList<int> list)
        {
            var minList = new LinkedList<int>();
            var maxList = new LinkedList<int>();

            while (list.Count != 0)
            {
                var min = list.Min();
                list.Remove(min);
                minList.AddLast(min);

                var max = list.Max();
                list.Remove(max);
                maxList.AddFirst(max);
            }

            return minList.Union(maxList);
        }
    }
}

Minha tentativa de corrigir:
using System;
using System.Collections.Generic;
using System.Linq;

namespace SelectionSort
{
    class Program
    {
        static void Main(string[] args)
        {
            var numbers = new int[] { 4, 5, 1, 3, 10, 9, 6, 8, 7, 2 };
            var sortedArr = SelectionSort(numbers);

            Console.WriteLine(string.Join(',', sortedArr));
        }

        private static int[] SelectionSort(int[] array)
            => SelectionSort(new LinkedList<int>(array)).ToArray();

        private static IEnumerable<int> SelectionSort(LinkedList<int> list)
        {
            var minList = new LinkedList<int>();
            var maxList = new LinkedList<int>();

            while (list.Count != 0)
            {
                var min = list.Min();
                list.Remove(min);
                minList.AddLast(min);

                var max = list.Max();
                list.Remove(max);
                maxList.AddFirst(max);
            }

            return minList.Union(maxList);
        }
    }
}

Comment: OP, o @AugustoVasques tem razão no comentário. Seu problema não tem nenhuma relação com o algoritmo de busca binária. Eu tomei a liberdade de editar a sua pergunta pra focar no real problema, criei um título que faz sentido no contexto do problema e alterei as tags. Use isso como base para a escrita de novas perguntas, isso ajuda as pessoas que querem responder a focar no que realmente é importante.
Answer: Até o .NET Core 1.1 (isso inclui todas as versões de .NET Framework) o método String.Join não tem uma sobrecarga onde o primeiro parâmetro é um char, por isso você vê este erro de compilação.
Pra resolver, use o método Join que espera uma string como primeiro parâmetro.
string.Join(",", sortedArr);

Documentação do método Join no .NET Framework 4.8.1
Documentação do método Join no .NET Core 2.0

Erro de compilação ao usar string.Join


Branch of math studying relations

Question: There are many branches of mathematics (analysis, algebra, group theory, logic, ...). Now, I'm interested in relations and their special kinds (like equivalence relation) and their properties. I'd like to find out more about them.
Where should I search to learn everything from the origin of the concept of relation to the knowledge about them of today? Which branch of math studies them carefully?
Comment: This question strikes me as slightly misguided. It is analogous to asking "what branch of math studies functions carefully?" Every branch of mathematics makes use of the notion of function, just as every branch of mathematics makes use of the notion of relation (even just equivalence relations). Can you be more specific about what you're interested in?
Comment: There are lots of areas that would touch on this; you can represent relations with (directed) graphs, and you can address questions about relations in terms of questions about graphs, placing you in graph theory. For large sets, you will probably end up having to deal with Set Theory; there is also the study of Relational Algebras within Universal Algebra, but that will be more along the lines of understanding maps between sets-with-relations that respect the relations. The basics are covered in elementary set theory. The history of todays presentation can be found in the essays in Bourbaki.
Comment: Another way of expressing my concerns is that I would say that relations are not so much a thing you study as a language you use to study other things. But there is room for disagreement on this point, I suppose.
Comment: @QiaochuYuan `analysis` studies functions but in a little different way. I'm aware that function is a special kind of relation. But relations are really interesting, they create various patterns - you can draw them as hasse diagrams (relations that create orderings), graphs are relations between vertices. It's interesting to study the properties of these patterns and structures. Maybe relations are only formalism for other branches of math, but maybe more care was devoted to them and this is what interests me.
Comment: I was talking about the historical essays; they can be found in "Elements of the History of Mathematics"; otherwise, they are covered in the "Set Theory" volumes.
Comment: @ArturoMagidin Thanks, do you know some title of Bourbaki that deals with relations?
Answer: This is probably too advanced, but there is Roland Fraïssé's book (which I'm surprised no one has mentioned yet):
Roland Fraïssé, Theory of Relations, Studies in Logic and The Foundations of Mathematics #118 [Revised Edition is #145], North Holland, 1986, xii + 397 pages [Revised Edition is 2000, ii + 451 pages].
Review of 1986 edition by Arnold William Miller, Bulletin of the American Mathematical Society (N.S.) 23 #1 (July 1990), pp. 206-209.
Review of 2000 edition by Peter van Emde Boas, Nieuw Archief voor Wiskunde (5) 5 #3 (September 2004), p. 251. [Boas's review is in English.]
(added the next day)
More useful, I think, would be to gather up a lot of undergraduate level set theory texts (Enderton, Schaum's outline, Dalen/Doets/De Swart, Devlin, Hrbacek/Jech, Monk, Roitman, Vaught, etc.) and compile a list of basic results about relations from the text material and the exercises (most will probably be in the exercises). I've often used this method to learn something new. In the U.S. you can find many such books in most any college library under the Library of Congress headings QA 9 and QA 248. As you compile and organize the results, you'll become better acquainted with subject, and sometimes you'll even come up with some new results on your own by extending ideas in the results you have. (In my case, I almost always later come across my "original result" published somewhere, usually as an exercise in a book or as an aside in a research paper.)
(ADDED 10 YEARS 3 MONTHS AFTER ORIGINAL ANSWER)
I recently came across a book that provides a nice contrast to Fraïssé's very advanced book. Indeed, probably anyone with the background for Fraïssé's would already know about it. The book below is suitable for undergraduates, even strong high school students, and is freely available on the internet at archive.org. I suspect most people reaching this web page from an internet search would find the book below much more helpful than Fraïssé's book.
Yuli (Julius) Anatolʹevich Schreider, Equality, Resemblance, and Order, translation of 1971 Russian edition by Martin Greendlinger, MIR Publishers, 1975, 279 pages.
Review of 1975 English edition by José Antonio Robles, Revista Hispanoamericana de Filosofía 11 #31 (April 1979), pp. 135-138 (review in Spanish).
Comment: It seems to me that relations are branch of math for itself and because they are more general are used often as a formalism to describe other topics of math.
Comment: Now, I see that this book is under `mathematical logic`
Answer: While it is not a systematic study of relations, there is a paper by Smullyan which may be of interest to you, "Equivalence Relations and Groups ". Abstract:

Our purpose is to show how the logic of relations can be uitilized in the study of group theory. There are some striking similarities in certain theorems in group theory and certain results about equivalence relations, and we show how the former can be derived as consequences of the latter. This transition is accomplished by means of certain ismorphism theorems, proved in considerable generality in section 2, and applied to groups in section 3. In section 1 we give several miscellaneous theorems on equivalence relations, which later turn out to have their analogues in the theory of groups.
Comment: Google Books link to the Smullyan article: http://books.google.com/books?id=JIpK7Jb9s8IC&lpg=PA261&ots=_MSYXqqfdN&dq=Equivalence%20Relations%20and%20Groups%20Smullyan&pg=PA261#v=onepage&q=Equivalence%20Relations%20and%20Groups%20Smullyan&f=false
Answer: The theory of binary relations over a set is in a sense the same as the theory of (non-weighted) directed graphs. The theory of symmetric relations is in a sense the same as the theory of (non-weighted) undirected graphs. Indeed, every graph can be seen as the set of vertices and the adjacency relation (which is symmetric in the case of undirected graphs).
Since relations can be composed, and the composition is associative, they are of interest in semigroup theory. If you google "semigroup of binary relations", you will find many hits. These semigroups were studied quite intensively in the 1960s.
There are connections between semigroup-theoretic properties of relations and standard notions such as transitivity or being an equivalence relation. One simple example is that every equivalence relation is idempotent with respect to composition. Indeed, every preorder is. A relation $R$ is transitive iff $R\circ R\subseteq R.$ A relation $R$ over a set $X$ is interpolative, that is $(\forall a,b\in x) ((a,b)\in R \Longrightarrow (\exists c\in X) ((a,c)\in R\wedge (c,b)\in R))$, iff $R\circ R\supseteq R.$
Answer: At least in the undergraduate curriculum, relations are usually studied on the way to something else. Many textbooks on combinatorics and on abstract algebra will devote a chapter to relations. Have you mastered all of the information on relations in those books?
Comment: It depends which books do you have on mind. Please, post here some title. Thanks.
Comment: Sorry, I'm out of my office the next few days and have no access to books. But really it shouldn't be that hard for you to find a few introductory textbooks with titles mentioning Abstract Algebra, or Combinatorics, or Discrete Mathematics, and have a look to see if there's a chapter on relations.
Answer: A book on the transition to advanced mathematics will give you a thorough (50 page) introduction to relations (as opposed to a 5 page introduction as is done in Munkres' Topology).
I liked How to Prove It by Daniel Velleman.  It covered equivalence relations, ordering relations, closures, etc.
Comment: Thanks. Which `transition to advanced mathematics` do you have on mind? There are more such titles.
Comment: `How to prove it` is the title that I wanted to read (it was in the library) but never found time, maybe I should find it.
Comment: "How to Prove It" is the one I had in mind.  I just wanted to point out that there are quite a few books in that category.  You might find a different one that you like better, I don't know.
Answer: On the Calculus of Relations by Tarski
The paper contains a nice introduction to the elementary theory of binary relations (unfortunately restricted access).
Answer: Towards algebraic abstraction of relations, I also suggest Allegories and Relation Algebras..

Branch of math studying relations


What's the official term for the part(s) of instrument(s) playing the exact same score?

Question: 'Part' refers to instrument(s) (families) that play(s) the exact same bars and have the exact same score, e.g. what is played by the second violins in Fresco.
Answer: Your question is kind of unclear without the actual score, but it sound like it is just a part doubling. When multiple instruments (or instrument groups) play the same thing at the same time the part is considered doubled. Think of it as everyone singing the same melody at the same time and it gives the peice a certain texture.


Handling Dynamic Errors In Go (Specifically database/sql Package)

Question: Using the database/sql package in go for things like sql.Exec will return dynamically generated, unreferenced errors such as
"Error 1062: Duplicate entry '192' for key 'id'"

The problem is that it can also return errors such as
"Error 1146: Table 'tbl' doesn't exist"

From the same call to sql.Exec
How can I tell the difference between these two errors without

String comparison, or
Pattern matching for error code

Or are those idiomatic viable solutions for this problem?
Answer: database/sql package does not solve this problem. It's driver specific. For example, for mysql you can use:
if mysqlError, ok := err.(*mysql.MySQLError); ok {
    if mysqlError.Number == 1146 {
        //handling
    }
}

Also, you can find some error constant package, like mysqlerr from VividCortex, and use it:
if mysqlError, ok := err.(*mysql.MySQLError); ok {
    if mysqlError.Number == mysqlerr.ER_NO_SUCH_TABLE {
        //handling
    }
}

It's not much better than pattern matching, but seems to be more idiomatic.
Comment: Thanks! I should have realized to check the driver. I checked for a solution using type assertion but only read the `sql` package.
Comment: For future users struggling, make sure you import "github.com/go-sql-driver/mysql" also.
Answer: I think there's no idiomatic solution, but I wrote a simple function for getting the error number, so you can easily compare them.
In this solution I assume that the construction of the error message is always the same: "Error -some number here-: Error description".
If there's no number in the error or something went wrong it returns 0.
func ErrorCode(e error) int {
    err := e.Error() //the description of the error

    if len(err) < 6 { //if its too small return 0
        return 0
    }
    i := 6 //Skip the part "Error "

    for ; len(err) > i && unicode.IsDigit(rune(err[i])); i++ {
    } // Raising i until we reach the end of err or we reach the end of error code

    n, e := strconv.Atoi(string(err[6:i])) //convert it to int
    if e != nil {
        return 0 //something went wrong
    }
    return n //return the error code
}

Go playground link: http://play.golang.org/p/xqhVycsuyI
Comment: I think the authors of Go need to address the problems in the `errors` type/package!
Comment: @BlinkyTop What do they need to address? You do realize that the error you get does not come from the `errors.New()` function?
Comment: Well obviously in this case the error type wasn't suitable or descriptive enough for the author of Go's most popular mysql driver. He had to hack out his own version over the error type and now I have to do a type assert on it to even know what it is.


function template won't compile in VS2019 express

Question: I have a project with quite a lot of function templates that I wrote back in Visual Studio 2017, and it always worked fine. Now I have to build it in VS2019, because I need to include the lib in another project that is written in VS2019, and the thing won't build.
There is one function template it seems to take issue with, although it doesn't actually complain about the function itself. The compiler just says "identifier not found" when I invoke it in the code. The thing is there in the namespace, however, even InteliSense sees it and links to it without complaining. Just the compiler won't.
Here's the code in question:
// declaration

namespace Oparse
{
    // lots of other functions, many of them templates
    template <typename T> OpModel<T> *_ModelPtr(T *receiver) { return new OpModel<T>(receiver); };
}

// Invocation

namespace Oparse
{

        template <class T, class U>
    class OpModelFactory
        : public OpNestable
    {
        public:
        OpModelFactory<T, U>(vector &receiver) : OpNestable(OP_MODELFACTORY), receiver(receiver) {};
        // other stuff

        void Serialize(string key, stringstream &stream, unsigned int indents)
        {

            for (unsigned int i = 0; i < receiver.size(); ++i)
            {
                // check if the instances are really of the type of this OpModel, otherwise there may be duplicates between polymorphic factories populating the same receiver.
                T *currentModel = dynamic_cast<T*>(receiver[i]);
                if (currentModel != NULL)
                {
                    OpModel<T> *parser = _ModelPtr<T>(currentModel);    // <-- identifier not found
                    parser->Serialize(key, stream, indents);
                    delete parser;
                }
            }
        };

        private:
        vector &receiver;
    }
}

If I comment that invocation, the project builds, despite there being a whole lot more function templates declared right where this one is. I have no clue what to do to make the linker find it. Are there any Visual Studio wizzards who could give me a hint? I must honestly confess that I haven't used the IDE in years, and it's my first time in Visual Studio 2019...
Here's the complete output of the error.  There's a second message to it, but I found it perfectly unhelpful:
1>D:\Orbiter_installs\Orbiter2016\Orbitersdk\Oparse\include\OpModel.h(138,27): error C3861: '_ModelPtr': identifier not found
1>D:\Orbiter_installs\Orbiter2016\Orbitersdk\Oparse\include\OpModel.h(152): message : see reference to class template instantiation 'Oparse::OpModelFactory<T,U>' being compiled

And no, there's not further message attached. I have seen similar messages that usually go on with "with ... $further information", but this is all I get.
Comment: Probably not the source of your error, but identifiers that start with an underscore followed by an uppercase are reserved for the compiler.
Comment: I'm also going to venture a wild guess and suspect that you have a circular header dependency.
Comment: What you can do is copy the project to a fresh place, do a full rebuild, and if the problem persists, start throwing away code, and replacing code you cannot just cut and throw away by simpler code, until you arrive at a [mcve].
Comment: Expanding on the above (might as well learn all of the related rules): [What are the rules about using an underscore in a C++ identifier?](https://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier).
Comment: Linker error codes start with capital L. Compiler error codes start with capital C. I wonder why is that. Some weird arbitrary kinda rule.
Comment: The include strategy of that project is extremely fragile (`OpModel.h` doesn't `#include`  anything despite having clear dependencies). Headers requiring that other headers are included before them is the true problem here. Any fix that doesn't address that is just a delay until the next hard-to-track error pops up.
Comment: @Frank Good guess! It is indeed a problem of circular dependency, that can be solved using forward declaration.
Comment: embarassingly, I have never even noticed that... but then I don't write that much C++.
Comment: I don't think we can offer much help. The code is not enough for us to remotely debug.
Comment: Well, the entire project is here: https://github.com/TheNewBob/Oparse but there's another dependency required, so I don't expect anyone to go through the trouble. I was hoping that somebody more experienced would spot what was wrong with it, resp. why VS2019 might have a problem where VS2017 didn't.
Comment: @Frank yeah, I have a really difficult time managing includes when I *need* to put logic in the header files, which I have to when using templates. As long as I can keep all the actual code in the cpp files, it's a lot easier.
Answer: There is a circular dependency problem.
In Oparse.h, you first include OpModel.h that requires_ModelPtr in implementation of Serialize , but_ModelPtr is only defined later in the header.
You need to forward declare the template method.
In OpModel.h, write this instead:
namespace Oparse
{
    template<typename T> class OpModel;
    template <typename T> OpModel<T>* _ModelPtr(T* receiver);
    // Remaining of OpModel.h...
    typedef map<string, pair<Oparse::OpValue*, vector<Oparse::OpValidator*>>> OpModelDef;
    typedef vector<pair<Oparse::OpValue*, vector<Oparse::OpValidator*>>> OpValues;
    ...

Comment: Small remark: I noticed that your project builds around 3 times faster if you use `OpStdLibs.h` as a precompiled header.
Comment: Oh wow... just... wow. Thank you so much! How on earth was that *not* a problem when I built in VS 2017??


Optimal data structure for 2-way repeated measures ANOVA

Question: This must be a very basic question, but I'm trying to do a 2-way repeated measures ANOVA (in Statistica and/or SPSS), and was wondering:

in what way to (re)structure my data so it is most flexible for further analyses?
what way to go in Statistica or SPSS? (univariate GLM?)

In my case:

Subjects obtain a score (1-100) in describing (30!!) animals
They do this 3 times, using only conceptual (C), visual (V), or auditory (A)
information.
The resulting data is currently formatted as follows, with one subject a case:

           dog        cat      ...
Sbj  C  V  A    C  V  A    ...
s1   64 78 34   61 63 39   ...
s2   78 89 31   68 77 45   ...
...  .. .. ..   .. .. ..   ...

So factors are animal {dog,cat,...} and source {C,V,A}.
I have tried a 4 variable format as well: Sbj Animal Source Value
s1 dog C 64
...

but:

This breaks the one-subject-per-case rule that the repeated measures ANOVA procedures in SPSS and Statistica rely on.

In either case, SPSS requires me to specify all factor-levels manually which does not work as they are not variables, and moreover involves 20 levels! (in case of animal).
Answer: Both your repeated-measures factors are fixed factors, so it make no difference whether you you use wide structure of the data (your 1st table) with Repeated-measures GLM procedure or long structure of the data (your 2nd table) with Univariate GLM procedure (speaking of SPSS now).
For 1st structure
GLM
  dog_c dog_v dog_a cat_c cat_v cat_a
  /WSFACTOR = animal 2 source 3
  /METHOD = SSTYPE(3)
  /WSDESIGN = animal source animal*source.

For 2nd structure
GLM
  value BY animal source sbj
  /RANDOM = sbj
  /METHOD = SSTYPE(3)
  /DESIGN = animal source sbj animal*source animal*sbj source*sbj animal*source*sbj.

will yield identical significances for factors ANIMAL, SOURCE, ANIMAL*SOURCE (interaction).


Probability of getting at least 2 multiple choice questions answered correctly

Question: I'm currently stuck on this question:
A multiple choice test consists of 8 questions each with 4 choices. A student guesses the answers by choosing an answer at random. We can't use binomcdf or anything like that to find the answer
a) Compute the probability that the student answers 2 or more correctly.
b) If the student is able to eliminate one answer in each question as incorrect and chooses randomly from the other three choices, what is the probability the student answers 2 or more correctly?
Answer: The simplest way to do (a) is to find the probability of answering 0 or only 1 correctly, then subtracting that from 1.  With four possible answer to each problem, the probability of answering one correctly by choosing at random is 1/4 and the probability of answering incorrectly is 3/4.  So the probability of answering all 8 questions incorrectly (0 correctly) is $(3/4)^8= 0.31640625$.  The probability of answering a specific question correctly and the other seven incorrectly is $(1/4)(3/4)^7= 0.033370971679685$.  The probability any one of the seven is correct and the other 3 incorrect is that times 8, 0.2669677734375.  The probability that either all 8 are incorrect or one is correct and the other 7 are incorrect is 0.31640625+ 0.2669677734375= 0.5833740234375.  The probability of answer 2 or more correctly is 1- 0.5833740234375= 0.4166259765625.


How get Drupal Alias from given node NID inside a module function?

Question: I am trying to get the Alias from a given system path node NID (node/nid), inside of a node_insert function in a custom module.
I already tryied:
drupal_get_path_alias('node/866'); // return node/866 in watchdog dblog

and
url('node/866'); // return node/866 in watchdog dblog

and
drupal_lookup_path('alias', 'node/866'); // return NOTHING in watchdog dblog

and
drupal_get_normal_path('node/866'); // return node/866 in watchdog dblog

It should return seo/preparedUrl, but I can´t find a way to do this.
I need this to change a path before the node is saved.
In URL alias (admin/config/search/path) the Alias(seo/preparedUrl) and System (node/866) are there!
THE ANSWER
First of all, Thanks to @arpitr with the help with devel/php path sugestion! Really fast  debug this way!
The answer in my case is that is two languages. The path was in language, but my user was in another so, when I use dpm it continues to print the node/nid, but when I changed my user language to be equals to content language it began to work the way I want!
(I can´t answer my own question or vote up nothing here because I am a new user, so I putted here!)
Answer: It looks like you are debugging through watch dog table, you should better use devel module it provides you several debugging options few are

dpm()
example in your case : dpm(drupal_get_normal_path('node/866'));
devel/php path
which allows you to test your php codes.
example in your case : simply log in as admin visit sitename/devel/php and execute  dpm(drupal_get_normal_path('node/866')); and see what it shows

About the problem

Make sure node/866 exists
If node exists make sure when you are able to access the node-866 by node/866 and alias which you have configured.
As as an option you can delete the existing alias and create the same alias again. And check again.


Prove that $3(a^5b+b^5c+c^5a)\geq(a^2c+b^2a+c^2b)^2$

Question:
Let $\sqrt{a}$, $\sqrt{b}$ and $\sqrt{c}$ be sides-lengths of a triangle. Prove that:
$$3(a^5b+b^5c+c^5a)\geq(a^2c+b^2a+c^2b)^2$$

I tried to apply the  way like the proof of the following inequality, but without success.
Let $\sqrt{a}$, $\sqrt{b}$ and $\sqrt{c}$ be sides-lengths of a triangle. Prove that:
$$2\left(\frac{a}{b}+\frac{b}{c}+\frac{c}{a}\right)\geq3+\frac{a}{c}+\frac{b}{a}+\frac{c}{b}.$$
Proof.
We need to prove that
$$\sum_{cyc}(2a^2c-a^2b-abc)\geq0$$ or
$$\sum_{cyc}(a^3-abc)-\sum_{cyc}(b^3-2ab^2+a^2b)\geq0$$ or
$$\frac{a+b+c}{2}\sum_{cyc}(a-b)^2-\sum_{cyc}b(a-b)^2\geq0$$ or
$$\sum_{cyc}(a-b)^2(a+c-b)\geq0.$$
Lemma.
Let $x+y+z\geq0$ and $xy+xz+yz\geq0$. Prove that:
$$(b-c)^2x+(a-c)^2y+(b-c)^2z\geq0.$$
Proof of the lemma.
Let $x+y\geq0$.
If $x+y=0$ then $xy+xz+yz=-x^2\geq0$,
which gives $x=y=0$ and $z\geq0$, which says that
$(b-c)^2x+(a-c)^2y+(a-b)^2z\geq0$ is true.
Thus, we can assume that $x+y>0$ and we need to prove that
$$(b-c)^2x+(a-b+b-c)^2y+(a-b)^2z\geq0$$ or
$$(x+y)(b-c)^2+2y(a-b)(b-c)+(y+z)(a-b)^2\geq0,$$
for which it's enough to prove that
$$y^2-(x+y)(y+z)\leq0$$ or
$$xy+xz+yz\geq0,$$
which ends a proof of the lemma.
Now, $\sum\limits_{cyc}(a+c-b)=a+b+c>0$ and
$$\sum_{cyc}(a+b-c)(a+c-b)=\sum_{cyc}(2ab-a^2)=$$
$$=(\sqrt{a}+\sqrt{b}+\sqrt{c})(\sqrt{a}+\sqrt{b}-\sqrt{c})(\sqrt{a}-\sqrt{b}+\sqrt{c})(\sqrt{b}+\sqrt{c}-\sqrt{a})>0,$$
which ends the proof by the lemma.
Thank you!
Answer: $$3(a^5b + b^5c + c^5a) \ge (a^2b + b^2c + c^2a)^2$$
$$\iff 3(abc)^2\left[\left(\frac{a}{b}\right)^3 \cdot \left(\frac{b}{c}\right)^2 + \left(\frac{b}{c}\right)^3 \cdot \left(\frac{c}{a}\right)^2 + \left(\frac{c}{a}\right)^3 \cdot \left(\frac{a}{b}\right)^2\right] \ge (abc)^2\left(\frac{a}{b} + \frac{b}{c} + \frac{c}{a}\right)^2$$
Let $\dfrac{a}{b} = x, \dfrac{b}{c} = y, \dfrac{c}{a} = z \implies xyz = 1$.
$$\iff 3\left(\frac{x^2y}{z} + \frac{y^2z}{x} + \frac{z^2x}{y}\right) \ge (x + y + z)^2$$
, which can be proven by using the Chebyshev inequality, the AM-GM inequality and the Cauchy inequality (which applications can be used in the order listed).
Comment: If your solution is true, so the starting inequality is true for all positives $a$, $b$ and $c$, which is not so. Try $c\rightarrow0^+$.
Comment: I used the Chebyshev inequality, which only works when supposed $x^2 \ge y^2 \ge z^2$ and $\dfrac{y}{z} \ge \dfrac{z}{x} \ge \dfrac{x}{y} \implies \dfrac{a^2}{b^2} \ge \dfrac{b^2}{c^2} \ge \dfrac{c^2}{a^2}$ and $\dfrac{ab}{c^2} \ge \dfrac{bc}{a^2} \ge \dfrac{ca}{b^2}$.
Comment: Mr. @MichaelRozenberg , how about your solution ?
Answer: Remark: Since no complete solution is available, I give the solution by the Buffalo Way. Hope to see nice solutions.
Let $a = (u+v)^2, b = (v+w)^2, c = (w+u)^2$ for $u, v, w > 0$ (Ravi Substitution). It suffices to prove that
$g(u,v,w) \ge 0$ where $g(u,v,w)$ is a homogeneous polynomial of degree $12$.
WLOG, assume that $w = \min(u, v, w)$. Let $v = w + s$ and $u = w + t$ for $s, t\ge 0$.
It suffices to prove that
$$q_{10}w^{10} + q_9w^9 + q_8w^8 + q_7w^7 + q_6w^6 + q_5w^5 + q_4w^4 + q_3w^3 + q_2w^2 + q_1w + q_0 \ge 0.$$
It is not hard to prove that $q_{10}, q_9, \cdots, q_0\ge 0$.
I do not give the expressions of $q_i, \forall i$. If someone uses the Computer Algebra Systems (CAS), it is an easy job.
Comment: @GiangNguyễnĐặngThanh  Mathematica, Maple, Matlab, etc. https://en.wikipedia.org/wiki/List_of_computer_algebra_systems
Comment: Where can I find CAS ?
Answer: Too long for a comment.
The River Li's solution we can rewrite so.
Let $c=\max\{a,b,c\}$, $a=(x+u)^2,$ $b=(x+v)^2$ and $c=(x+u+v)^2,$ where $x>0$,$u\geq0$ and $v\geq0.$
Thus, $$3(a^5b+b^5c+c^5a)-(a^2c+b^2a+c^2b)^2=$$
$$=60(u^2-uv+v^2)x^{10}+6(58u^3+37u^2v-11uv^2+58v^3)x^9+$$
$$+(959u^4+2078u^3v+1149u^2v^2+350uv^3+959u^4)x^8+$$
$$+8(207u^5+750u^4v+922u^3v^2+428u^2v^3+133uv^4+207u^5)x^7+$$
$$+4(493u^6+2500u^5v+4514u^4v^2+3866u^3v^3+1281u^2v^4+338uv^5+493v^6)x^6+$$
$$+16(105u^7+687u^6v+1602u^5v^2+1936u^4v^3+1183u^3v^4+249u^2v^5+57uv^6+105v^7)x^5+$$
$$+8(129u^8+1035u^7v+2943u^6v^2+4478u^5v^3+3925u^4v^4+1705u^3v^5+150u^2v^6+33uv^7+129v^8)x^4+$$
$$+2(229u^9+2130u^8v+7152u^7v^2+12968u^6v^3+14432u^5v^4+9422u^4v^5+2748u^3v^6-252u^2v^7-27uv^8+225v^9)x^3+$$
$$+(133u^{10}+1438u^9v+5586u^8v^2+11696u^7v^3+15552u^6v^4+13164u^5v^5+6410u^4v^6+928u^3v^7-529u^2v^8-68uv^9+133v^{10})x^2+$$
$$+4(u^2+uv+v^2)(6u^9+66u^8v+247u^7v^2+443u^6v^3+470u^5v^4+271u^4v^5+37u^3v^6-44u^2v^7-11uv^8+6v^9)x+$$
$$+2(u^2+uv+v^2)^3(u^3+5u^2v+2uv^2-v^3)^2\geq0.$$
The inequality in my open post by the same way gives:
$$2(a^2c+b^2a+c^2b)-3abc-a^2b-b^2c-c^2a=$$
$$=4(u^2-uv+v^2)x^4+2(6u^3-7u^2v+5uv^2+6v^3)x^3+$$
$$+(13u^4-14u^3v-9u^2v^2+34uv^3+13v^4)x^2+$$
$$+2(3u^5-2u^4v-10u^3v^2+8u^2v^3+13uv^4+3v^5)x+(u^3-3uv^2-v^3)^2\geq0.$$
I think, from the expression $2(u^2+uv+v^2)^3(u^3+5u^2v+2uv^2-v^3)^2$ we can learn that maybe there is a solution for the starting inequality by the lemma.
Comment: Still a complicated proof.


Search API Solr: Correct Field Data Type?

Question: I'm running Drupal core 10.2.1, Search API Solr 4.3.1, and Solr server 9.4.0. I've noticed that some searches aren't finding indexed content and I'm wondering if the field type definition is correct. The data types can be set at /admin/config/search/search-api/index/myindex/fields.
The field in question is a string that includes hyphens, such as "2B257-Kit-1". A search for "2B257" will find content, but searches for "2B257-Kit" and "2B257-Kit-1" return no results. I've tried multiple data types without success. How can I match these values to return appropriate search results?
Comment: I'm not an expert but this may have more to do with the solr core configuration (maybe stemming?) than than with Drupal. But take this with a grain of salt.
Answer: This seems relevant and could be the cause of your issue: Products containing a hyphen or numbers not shown or wrong relevance
In my experience we have needed to use the type "Fulltext ngram" for partial matching. Make sure you are reindexing your content after each field type change as well.
Comment: Thanks for the suggestion. I made that change, reindexed, and tried the search again. Same result, no match. I should mention that I'm also using Search API Views, and the filter criteria could be the issue. Again, though, I've tried multiple settings for the parse mode and haven't yet found a solution.
Comment: This feels like a Solr config issue. What kind of logging can you enable / access in order to debug this further? I would setup a dummy content type, with one node, and a search index devoted to it. Isolate the problem in that one place and review logs. Alternatively you might add some debug / breakpoints to the search api code but not sure that would get you visibility into what Solr processing. I don't have a lot of Solr logging experience but that would be my next step.
Comment: I can use the solr admin web interface to analyze queries, but I'm not familiar enough with it to really understand what I'm seeing. It does appear, however, that solr searches are matching. This makes me think that the issue is with the filter settings available in this view, where it doesn't appear that substring matching is an available setting.
Comment: Can you implement one of these hooks to see if the result you expect is included and can be "forced" into the result set? https://api.druphelp.com/api/search_api_solr/search_api_solr.api.php/8.3
Comment: Possibly. It looks like hook_search_api_solr_search_results_alter would be the right hook to experiment with.
Comment: I've added both hook_search_api_solr_query_alter and hook_search_api_solr_search_results_alter to a custom module and added devel_debug_log ddl function calls inside the functions. It doesn't look like the hooks are being called, though, because I'm not seeing any debug messages or logged errors associated with the hooks in the code. Strange...
Comment: Hm - might need to drop in some breakpoints or "die()" calls just to be sure those are being triggered. I see this notice in search_api_solr 4.2.x "hook_search_api_solr_query_alter is deprecated will be removed in Search API Solr 4.3.0. Handle the PreQueryEvent instead" - check search_api_solr.api.php for relevant hooks available
Comment: Thanks for that clue! After adding an event subscriber I'm able to see query results. Unfortunately, I'm not seeing any results returned for these queries. As described above, searching for "2B257-Kit" returns no results. Is there anything in the Drupal\search_api\Query\ResultSet that's worth looking at?
Answer: I found a working combination of settings: after setting the Search API Solr field type to "fulltext ngramstring" and the views fulltext search parse mode in the views filter to "multiple words" I'm able to return results for a substring-matching query as described above.
Comment: Glad you got this working!


Getting "TypeError: undefined is not a function!" when running Karma test suite

Question: When I try to run my the karma test suite (using npm test or karma start) of a project I get this output:
> email@example.com test /home/kent/dev/html5/game-engine
> karma start karma.conf.js --browsers PhantomJS

16 11 2015 16:50:11.910:INFO [karma]: Karma v0.13.15 server started at http://localhost:9876/
16 11 2015 16:50:11.921:INFO [launcher]: Starting browser PhantomJS
16 11 2015 16:50:12.109:INFO [PhantomJS 1.9.8 (Linux 0.0.0)]: Connected on socket opYF2pU3Qw-7rkdeAAAA with id 45780972
PhantomJS 1.9.8 (Linux 0.0.0) ERROR
  TypeError: undefined is not a function!
  at /home/kent/dev/html5/game-engine/node_modules/karma-babel-preprocessor/node_modules/babel-core/browser-polyfill.js:16

Finished in 0.12 secs / 0 secs

SUMMARY:
✔ 0 tests completed
npm ERR! Test failed.  See above for more details.

If I look at line 16 of the above mentioned file it looks like it has something to do with modules:
module.exports = function(it){ //// Line 16
  if(typeof it != 'function')throw TypeError(it + ' is not a function!');
  return it;
};

The file as a whole can be found here: http://pastebin.com/quHaY4NN
I use these versions:
$ node --version
v4.2.2
$ npm --version
2.14.7
$ karma --version
Karma version: 0.13.15

I've been banging my head against this for several hours. What kind of problem could it be? How should I go about debugging it?
Comment: did you add/load your test framework library in PhantomJS ?
Comment: Same here.  Previously working with `email@example.com` and `email@example.com`  (and using `node_modules/babel-core/browser-polyfill.min.js`).  Upgraded to `firstname.lastname@example.com`, `firstname.lastname@example.com`, `email@example.com` and `firstname.lastname@example.com`; changed the polyfill path to `node_modules/babel-polyfill/browser.js` and added `presets: ['es2015']` to the preprocessor options; and I get the same `undefined is not a function` error.  Tracing back through the call stack, the `undefined` appears to be `window.setImmediate`.
Comment: Do you happen to use `sinon` and/or `sinon-chai` in your karma tests?  I found that when I commented out sinon-chai from my `frameworks` array, the error went away (unfortunately I need sinon-chai for my tests, though).  I also noticed [this issue](https://github.com/sinonjs/sinon/issues/821) in the `sinon` project, that suggests a bug that was causing `setImmediate` polyfills to break.
Answer: For me, the solution was to switch from karma-sinon-chai to the alternative karma-chai-sinon module.
The difference between the two is that the latter has chai, sinon and sinon-chai as peerDependencies (allowing the user to choose what versions of these to use); where as the former has them as dependencies (and in particular it wants sinon ~1.16.0, which has a bug that leaks setImmediate into the global scope, breaking any setImmediate polyfills).
It wasn't clear from your question if you are using any of these frameworks; but if you are, this may be a fix for you too.
Comment: thank you so much, I believe that was it, I've spent around 5 hours on this, damn it


How to get facebook events via event id?

Question: How to get Facebook events via event id?
i wanted to enter a event id to get all of the data, is there any API for this?
or please tell me how to get the events via graph api.
Comment: Please consult the docs _before asking_ … https://developers.facebook.com/docs/reference/api/event/
Answer: You need the permission: user_events
API : /EVENT_ID
You can test the same here: Graph API Explorer
Comment: At present, I am using the graph API version 2.11, and calling the following URL *https://graph.facebook.com/v2.11/188812701672584* where the last parameter is my *eventFbId*. I am getting the following error. ```{
  "error": {
    "message": "(#12) events management API is deprecated for versions v2.0 and higher",
    "type": "OAuthException",
    "code": 12,
    "fbtrace_id": "ECVXFuhf1S+"
  }
}```   any idea what's doing wrong here?
Comment: You need to use Access Token for this...
Check my screenshots:
[Screenshot 1](http://prntscr.com/ikfxfx/direct)
[& Screenshot 2](http://prntscr.com/ikfxo8/direct)
Comment: Followed the screenshots, same event ID, and the answer is:

"Unsupported get request. Object with ID '188812701672584' does not exist, cannot be loaded due to missing permissions, or does not support this operation."

GraphMethodException "code": 100, "error_subcode": 33

I can't get any info about public group / page events for a few days now via Graph API, even can't see the public groups own events with my personal account if I'm not member!

This event is exists and is visible for the public group members. For non-members:

https://imgur.com/a/s7MB9

Any idea?


A newbie question on the basics concerning Hausdorff space, topology and definitions.

Question: I'm learning about topological spaces and note that they come in flavours with more or less restrictions and structure. A Hausdorff space is defined as a topological space where there's some open domain separating each of the elements.
What I fail to understand concerning this definition is if the separating sets of elements in an Hausdorff space (set X,topology T) are part of the same Hausdorff space topology T, or is it enough that they just belong to a neighbourhood to X with some other topology K?

Is the property of separation in a Hausdorff space a property of T? Ie is the restriction of elements in X expressed as a topology? If not, how can I think of this specialisation (?) of a topological space, ie what is it I do when I construct a Hausdorff from a lesser Topological space?
Comment: I would say, that it a property of the **pair** $(X,T)$: For all **$x,y\in X$** with $x\neq y$ there are **$A,B\in T$** disjoint with $x\in A$ and $y\in B$. However, the underlying set $X$ can be recovered from $T$, e.g., as the union of all sets which are elements of $T$.
Answer: Those "open domains" that you are mentioning in the definition depend on the topology you are working. As an illustration, take a two elements set $X=\{ a,b\}.$ Then the discrete space (the discrete topology is $\tau_1=\{ X,\emptyset , \{ a\},\{ b\} \}$) is Hausdorff, but the indiscrete space(the indiscrete topology is $\tau_1=\{ X,\emptyset \}$) is not.


Zero byte files after power failure - ext4 centos 6.4

Question: Files written within a minute of a power failure are zero bytes when the system comes back.  Testing for a system that we can not guarantee will have ups backup.
Centos 6.4
kernel 2.6.32-358.14.1.el6.x86_64
ext4 mounted with defaults
See this occurring on 2 different systems (the only two that I have tried it on)
1st with PERC h710 controller RAID 6 with 4 3TB drives.
It happens with and without lvm
It happens in both write through and write back cache.
2nd with no RAID controller 2TB disk
only tested without lvm
Suggestions on how to prevent this?
Comment: And the question is?
Comment: Is the cache battery-backed? If not, there's your reason.
Comment: Why RAID 6 with 4 drives? Is your goal to extend the array later?  (Most people seem to go for [RAID 10](http://serverfault.com/questions/339128/what-are-the-different-widely-used-raid-levels-and-when-should-i-consider-them) when using four drives.)
Comment: cache has battery.  Also occurs in write through mode.  2nd system does not have controller with disk cache disabled.
Comment: raid 10 can still lose data when 2 drives fail.  raid 6 should be able to recover no matter which 2 drives fail.
Comment: yeah but raid6 rebuilt time is huge on the big disks and it is its major weakness. While RAID6 rebuilding i would not suggest use that storage for intensive reads/writes while in rebuild, + advantage of Raid6 on 4 drive array almost none vs RAID10, 8 or more disks.
Comment: Did you also disable the write cache on the drives themselves?
Comment: yes disabled cache on the drives.  My initial statement may be incorrect.  I stated that writes within the last minute would be affected but it looks like it is closer to the last 5-10 seconds.  commit=5 is the default
Comment: Your *drives* are not losing data. Your *file system* is [losing the data](http://www.h-online.com/open/news/item/Ext4-data-loss-explanations-and-workarounds-740671.html) in an acceptable manner.
Answer: Going by your description, this sounds like the OS hasn't flushed your data to disk, given that you do have the file-metadata, just without any content/length.
write(2) doesn't by any means guarantee that your data have hit disk (unless you open(2) your files with O_DIRECT), you're at the behest of the OS/filesystem and when it decides to flush data/metadata to disk. In order to guarantee that your data is safely tucked away, you have two options:

fsync(2)/fdatasync(2) and check that it returns successfully
close(2) and check that it returns successfully

The big caveat in this is caches (which may or may not) be battery backed on both the drives and the raid-controllers, notably there are some drives which will put your writes on their internal ram cache and state they've written it, in which there exists some window of time where a power-loss would make you loose data.


Como fazer para uma DIV ocupar o espaço correto?

Question: Boa noite, estou montando o layout de um projeto de aprendizado meu, preciso fazer com que a div ocupe o espaço igual a imagem azul abaixo

O meu código é o seguinte:
Meu HTML e meu CSS estão abaixo:

@import 'https://fonts.googleapis.com/css?family=Roboto';
.left-menu {
  font-family: 'Roboto', sans-serif;
  position: fixed;
  top: 50px;
  left: 0;
  margin: 0;
  padding: 0;
  height: 100%;
  width: 300px;
  list-style-type: none;
  background: #f32c52;
  overflow: hidden;
  transition: width .5s;
}

.left-menu:hover {
  width: 300px;
}

.left-menu li {
  width: 300px;
}

.left-menu li span {
  font-size: 1rem;
  margin: 20px 30px 0 22px;
}

.left-menu li a {
  display: block;
  font-size: .9rem;
  text-decoration: none;
  color: #FFF;
  height: 60px;
}

.left-menu li a:hover {
  background: #ffff;
}

.left-menu li:first-child a {
  background: #14081d;
  display: block;
  height: 150px;
}

.up-menu {
  background:#14081d;
  position: fixed;
  top: 0px;
  left: 0;
  width: 100%;
  height: 50px;
  color: white;
  text-align: right;
}

.content {
  border: solid 1px green;
  color: green;
  margin-top: 56px;
  width: 100%;
  height: 100%
}
<link rel="stylesheet" type="text/css"
 href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />

      Imagem

Menu1

      Menu2

  up-menu

  div-content

Não consigo fazer com o que a minha "div-content" fique como o desenho que fiz com o quadrado azul pois nenhum tipo de margem ou tamanho que aplique na div content funciona :(
Answer: Você precisaria utilizar o calc para ajustar as dimensões da div, descontando a largura da coluna lateral no width e a altura da barra superior no height, mas é preciso também ajustar a altura do html, body em 100% e retirar o margin natural do body. Logo, acrescente no seu CSS:
html, body{
   height: 100%;
   margin: 0;
}

E altere o width e o height da div.content, acrescentando também um margin-left para que a div não fique por baixo da coluna, que é fixa:
.content {
  border: solid 1px green;
  color: green;
  margin-top: 60px;
  margin-left: 310px;
  width: calc(100% - 320px);
  height: calc(100% - 70px);
}

Assim a div terá um espaçamento externo de 10px (que você ajustar alterando os valores 320px e 70px.
Veja:

@import 'https://fonts.googleapis.com/css?family=Roboto';

html, body{
   height: 100%;
   margin: 0;
}

.left-menu {
  font-family: 'Roboto', sans-serif;
  position: fixed;
  top: 50px;
  left: 0;
  margin: 0;
  padding: 0;
  height: 100%;
  width: 300px;
  list-style-type: none;
  background: #f32c52;
  overflow: hidden;
  transition: width .5s;
}

.left-menu:hover {
  width: 300px;
}

.left-menu li {
  width: 300px;
}

.left-menu li span {
  font-size: 1rem;
  margin: 20px 30px 0 22px;
}

.left-menu li a {
  display: block;
  font-size: .9rem;
  text-decoration: none;
  color: #FFF;
  height: 60px;
}

.left-menu li a:hover {
  background: #ffff;
}

.left-menu li:first-child a {
  background: #14081d;
  display: block;
  height: 150px;
}

.up-menu {
  background:#14081d;
  position: fixed;
  top: 0px;
  left: 0;
  width: 100%;
  height: 50px;
  color: white;
  text-align: right;
}

.content {
  border: solid 1px green;
  color: green;
  margin-top: 60px;
  margin-left: 310px;
  width: calc(100% - 320px);
  height: calc(100% - 70px);
}
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />

      Imagem

Menu1

      Menu2

  up-menu

  div-content

Comment: Obrigado sam!
Esses posts com explicações são essenciais pra quem ta iniciando.
Comment: Estranho que no seu exemplo funciona, o meu no ctrl c + ctrl v não funciona
Comment: Então talvez deve ser outra coisa no CSS
Comment: tem relação ao uso de bootstrap ???
Comment: Sim, com certeza. O Bootstrap tem sistema de grid próprio.
Comment: Existe algo que eu possa fazer pra eliminar o bootstrap e aplicar o css?
Comment: Ué, é só não usar o bootstrap.
Comment: O problema é que perderia todos os meus outros estilos nas outras páginas kk
Comment: É só não carregar o bootstrap apenas nessa página.


Calculating sample size in R

Question: I'm trying to calculate sample size and I have a Cohen F of .25, and I want to use power of .8. Is there a function in R that will let me calculate sample size based on these values?
THANKS!!!!
Answer: The function pwr.anova.test () in the pwr package.

Calculating sample size in R


Give Radon-measures $\mu$ and $\nu$ such that $\mu\ll\nu$ holds but $\nu\ll\mu$ fails

Question: I'm supposed to find Radon-measures $\mu$ and $\nu$ such that $\mu\ll\nu$ holds but $\nu\ll\mu$ fails. This seems too easy because I can take $\mu\equiv0$ and $\nu$ to be any non-zero Radon-measure (for example Lebesgue measure or Dirac measure). Then $\mu\ll \nu$ but $\nu\ll\mu$ is not true. Am I right or have I messed up something?
Comment: It's correct. Maybe you can try to give an example without using the zero measure.
Comment: @Rigel okay, can I do this without restricting the surrounding space $X$ or its topology, because all Radon measures I have in mind are Lebesgue, Dirac, counting (restricted), 0-1 -measure (restricted)?
Comment: Yes, sure. Your example is, in fact, the only one that is valid in general. (Consider the case of $X$ a singleton.)
Answer: Your example is correct. To have an example with two nonzero measures $\mu$ and $\nu$, we should assume that the space has at least two points $a,b$; then $\mu=\delta_a$ and $\nu=\delta_a+\delta_b$ works.


What software/hardware can I use for "testing" a wireless network?

Question: I'm setting up a wireless network with multiple access points in a large area with multiple buildings. What software/hardware can I use to test the wireless service? Basically I want a quicker and more "scientific" way of measuring the performance of the wireless in different areas besides just walking around with a laptop and seeing how fast some site loads while in different areas.
Any ideas?
Answer: One tool that is somewhat useful is a Spectrum Analyzer.  The Wi-Spy is is a inexpensive device that is somewhat useful.  There are more expensive and more accurate alternatives as well provide more tools.

Wi-Spy 2.4i http://www.thinkgeek.com/gadgets/electronic/c240/
Wi-Spy 2.4x http://www.thinkgeek.com/gadgets/electronic/9558/
AnalyzeAir http://www.flukenetworks.com/fnet/en-us/products/AnalyzeAir/Overview.htm
Comment: WiSpy's products are great little pieces of hardware that are relatively cheap and they will expose a range of issues that scanning via WiFi adapter will generally miss (or at best will just indicate as noise). A professional RF survey will give you a lot more but in terms of bang for your buck you can't go wrong with the WiSpy. And it's great being able to watch the Microwave in the kitchen start up and trash a chunk of 2.4Ghz WiFi channels.
Comment: This is a very good suggestion. I will probably buy a Wi-Spy before long.
Answer: You need Wireless Site Survey software. Some wireless cards provide Site Survey functionality in their driver package. Ekahau HeatMapper has a free version but you need to provide your own building maps.
http://www.ekahau.com/products.html
Answer: What operating system are you looking to use?
Netstumbler would give you what you wanted on Windows.
Comment: Any operating system is fine.
Comment: What type of price range are you looking at? How accurate do you need it to be?
Comment: Well, any of the somewhat standard operating systems Windows/Linux
Comment: We don't want to spend a lot. It doesn't have to be insanely accurate, I just want a good way to test and make sure we're getting decent/good signal in all necessary locations
Comment: And by not a lot I mean <$100 if possible... but that's not a hard limit... i figured there would probably be a good software solution that just used a normal wireless card
Comment: Here is what I would do:

1. I'd download netstumbler, I've inserted a link in the ansewer and see if that works for you.  Its free and I think it will do the trick.  It will give you a good idea of where you're at.  If you had a map of the building you could even make notes on it and get a pretty good idea of signal degredation.


Ajuda na estilização do CSS que não estou conseguindo resolver!

Question: Queria uma ajuda de vocês, estou fazendo este formulário de login, estou estilizando ele, mas daí quando fui tentar colocar o animation: btn-anim1 1s linear infinite;
Simplesmente o "btn-anim1" não está sendo reconhecido.

    <!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
    <title>Aprendendo .dev</title>
    <link rel="stylesheet" href="/css/tela-de-login.css">
    <link rel="stylesheet" media="screen and (max-width: 768px)" href="/css/mobile.css">

            teste 01

Início

Login

Modelos

Tops 10

Sobre

Registra-se

login

    <form>

            <input type="text" name="" required="">
            E-mail

            <input type="password" name="" required>
            SENHA

            ENTRAR

    </form>

    /* CUSTUMIZAÇÃO GERAL */

* {
    margin: 0;
    padding: 0;
}

  /* BACKGROUND DA PÁGINA(IMG) */

  body {

    background: url("/img/principal.jpg") no-repeat center center;
    background-attachment: fixed;
    position: relative;
    overflow: scroll;
    background-size: cover;
    height: 90vh;
    }

a {
    color: white;
    text-decoration: none;
    transition: 0.3s;
}

a:hover {
    opacity: 0.7;
}

body::-webkit-scrollbar {
    width: 15px;
}

  body::-webkit-scrollbar-track {
    background: #323232;
  }

  body::-webkit-scrollbar-thumb {
    background-color: #323232;
    border-radius: 6px;
    border: 3px solid
  }

/* PARTE DA NAV */

.logo {
font-size: 24px;
text-transform: uppercase;
letter-spacing: 4px;
}

nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background: #23232e;
    height: 12vh;
    overflow: hidden;
}

.nav-list {
    list-style: none;
    display: flex;
}

.nav-list li {
    letter-spacing: 5px;
    margin-left: 35px;
}

/* PARTE DE CONTEÚDOS DA PÁGINA */

h3 {
    color: rgb(180, 180, 180);
    background: url("/img/principal.jpg");
    display: flex;
    justify-content: center;
    font-family: helvetica;
    font-size: 8vh;
}

/* PARTE DO FORMULARIO DE LOGIN */

html {
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: helvetica;
    background: linear-gradient(#000000, #434343);
}

.login-box {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,.5);
    box-sizing: border-box;
    box-shadow: 0 15px rgba(0,0,0,.6);
    border-radius: 10px;
}

.login-box h3 {
    margin: 0 0 30px;
    padding: 0;
    color: white;
    text-align: center;
}

.login-box .user-box {
    position: relative;
}

.login-box .user-box input {
    width: 100%;
    padding: 10px 0;
    font-size: 16px;
    color: white;
    margin-bottom: 30px;
    border: none;
    border-bottom: 1px solid #fff;
    outline: none;
    background: transparent;
}

.login-box .user-box label {
    position: absolute;
    top: 0;
    left: 0;
    padding: 10px 0;
    font-size: 16px;
    color: #fff;
    pointer-events: none;
    transition: .5s;
}

.login-box .user-box input:focus ~ label,
.login-box .user-box input:valid ~ label {
    top: -20px;
    left: 0;
    color: #ff0043;
    font-size: 12px;
}

.login-box form a {
    position: relative;
    display: inline-block;
    padding: 10px 20px;
    color: #ff0043;
    font-size: 16px;
    text-decoration: none;
    text-transform: uppercase;
    overflow: hidden;
    transition: .5s;
    margin-top: 40px;
    letter-spacing: 4px;
}

.login-box a:hover {
    background: #ff0043;
    color: #fff;
    border-radius: 5px;
    box-shadow: 0 0 5px #ff0043,
                0 0 25px #ff0043,
                0 0 50px #ff0043,
                0 0 100px #ff0043;
}

.login-box a span {
    position: absolute;
    display: block;
}

.login-box a span:nth-child(1) {
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #ff0043);
    animation: btn-anim1 1s linear infinite;
}

@keyframes btn-anim1 {
    0%
}

Answer: tudo bem?
tenho um código aqui referente a criação de um button, da uma olhada

Animated Button

<button class="button" style="vertical-align:middle">Hover </button>

Acredito que está faltando algo pra se codar no seu HTML
Answer: Tudo bem?
Em relação ao seu seletor: .login-box a span:nth-child(1), já verificou se trecho está realmente selecionando o elemento span html.
Outra observação sobre o seu keyframe:
@keyframes btn-anim1 {
0%
}
Ele não faz nada com somente esse 0%, tenta adicionar alguma função para a sua animação, tipo (width entre outras...)


Upload de imagem

Question: como posso fazer o upload de uma imagem, e depois exibir em outra pagina, sem banco de dados, por exemplo
tenho um formulário na minha pagina "inicial", a pessoa faz o upload da imagem, quando fizer a imagem aparece na pagina "imagens"
Answer: Wender, você precisará armazenar esta imagem em questão.
Abaixo segue uma simples rotina para o upload:
index.html
<form action="exibir.php" method="POST" enctype="multipart/form-data">
 <input type="file" name="img">
 <input type="submit" name="img_ok" value="Enviar">
</form>

exibir.php
<?php
 if($_POST["img_ok"]) {
  $tempname = $_FILES["img"]["tmp_name"];
  $name = uniqid();
  $extension = strtolower(pathinfo($_FILES["img"]["name"], PATHINFO_EXTENSION)); // Pega extensão de arquivo e converte em caracteres minúsculos.

  $url_exibir = "/img/".$name.".".$extension; // Caminho para exibição da imagem.

  $url = "./img"; // Pasta onde será armazenada a imagem.
  if(!file_exists($url)) { // Verifica se a pasta já existe.
   mkdir($url, 0777, TRUE); // Cria a pasta.
   chmod($url, 0777); // Seta a pasta como modo de escrita.
  }

  move_uploaded_file($tempname, $url."/".$name.".".$extension); // Move arquivo para a pasta em questão.
 }
?>

<img alt="" title="" src="<?php echo $url_exibir; ?>">

ADICIONADO - Para mais de uma imagem segue base para implementação:
index.html
<form action="exibir.php" method="POST" enctype="multipart/form-data">
 <input type="file" name="img[]" multiple>

 <input type="submit" name="img_ok" value="Enviar">
</form>

exibir.php
<?php
    if($_POST["img_ok"]) {

    for($i = 0; $i < count($_FILES["img"]); $i++) {
        $tempname = $_FILES["img"]["tmp_name"][$i];
        $name = uniqid();
        $extension = strtolower(pathinfo($_FILES["img"]["name"][$i], PATHINFO_EXTENSION)); // Pega extensão de arquivo e converte em caracteres minúsculos.

        $url_exibir[$i] = "/img/".$name.".".$extension; // Caminho para exibição da imagem.

        $url = "./img"; // Pasta onde será armazenada a imagem.

        if(!file_exists($url)) { // Verifica se a pasta já existe.
            mkdir($url, 0777, TRUE); // Cria a pasta.
            chmod($url, 0777); // Seta a pasta como modo de escrita.
        }

        move_uploaded_file($tempname, $url."/".$name.".".$extension); // Move arquivo para a pasta em questão.
    }

 }
?>

<?php for($i = 0; $i < count($url_exibir); $i++) { ?>

    <img alt="" title="" src="<?php echo $url_exibir[$i]; ?>">
<?php } ?>

Comment: Olá Thyago obrigado por me ajudar, a imagem esta sendo enviada corretamente porem não esta sendo exibida, usei o inspecionar elemento, e me parece que esta duplicando a extensão.
por exemplo

jpg.jpg

outra coisa,  é possível enviar mais de uma imagem? tipo

na pagina exibir.php mostrar uma lista

IMAGEM-1
IMAGEM-2
IMAGEM-3
Comment: @Wender, testei o código que postei na resposta e funcionou sem duplicação da extensão, ideal seria você analisar o código novamente.
Comment: analisei novamente e esta funcionando certinho Thyago, Muito obrigado!

como faço pra enviar mais de uma imagem? tentei modificar aqui mais sem sucesso.
Comment: Editei a resposta e inclui a outra situação que pediu no caso de mais de uma imagem, espero que ajude, lembrando que o código pode ser melhorado.
Comment: Muito obrigado! me ajudou muito.

Upload de imagem


Modeling integers in NLP

Question: I was wondering why it is not OK to model binary (integer) variables of an optimization problem, in the following form
<code>x(x-1) = 0
</code>
What are the consequences for an NLP (solved with IP)?
Isn't it better to avoid converting an NLP problem to an MINLP?
What are the other modeling options available (not decomposition)?
Comment: It would be great if you could share your experience on this approach.
Answer: In practice that does not work very well. The problem is that this introduces a nasty non-convexity. Also if this would really be a good idea then we would not need MINLP solvers (or even MIP solvers) at all. All the effort to develop those solvers would have been wasted.
Comment: But as equality constraint it is non-convex. Any nonlinear equality constraint is non-convex. You can also argue $x=0$ or $x=1$ is non-convex as all values in between are not allowed.
Comment: No. That is also non-convex.
Comment: Erwin, I agree with you. I am not in favor of this approach as I have tried it and it didn't work the way it should. But, the function f(x) = x^2 - x is a convex function. Isn't it? Could you please explain more on the introduction of a "nasty non-convexity"?
Comment: Thanks for following up Erwin. Would it mean that converting this equality constraint to an inequality constraint, i.e. -ε<x(x-1)<ε and minimize ε with a penalty factor will lead to avoiding the non-convexity?

Modeling integers in NLP


how to un-register one jquery event from an object

Question: i have a global object
e.g
   var globalVar ={};
   function handlerGlobalVar (input) {/* do something */}

in multiple place i will try to listen an event from this globalVar
e.g
     $(globalVar).on("my-event", handlerGlobalVar);

To keep my code clean, and avoid registering too many event, i want to un-register the event when i finished using. so will try to do
$(globalVar).off("my-event", handlerGlobalVar );

however, when i perform "off" from one place, it will off all the "my-event" handler, none of them would work if one of them perform "off"
any suggestion how to fix my issue?
Thanks!
Comment: What globalVar will store? An array of selectors? Where in your code do you perform you off?
Answer: .off() has room for one more argument. The selector
var _selector = <my_class_or_id_element>
$(globalVar).off("my-event", _selector, handlerGlobalVar );

Example: Fiddle
 $('#my-id').on('my-event', function() {
     alert("nonce");
     $('#my-id').off('my-event');
  });

Answer: I think what you are looking for is namespaced event handler registration, so try
$(globalVar).on("my-event.mynamepsace1", handlerGlobalVar);
$(globalVar).on("my-event.mynamepsace2", handlerGlobalVar);

then
$(globalVar).off("my-event.mynamepsace1", handlerGlobalVar);

now this will remove only the first registration because of the namespace used
Demo: Fiddle, Problem

But if you want to fire an handler only once then use .one()
Demo: Fiddle