Extend JQueryStatic with typescript

Question: So far i have added extension methods to JQuery like this:
module JQueryExtensions {
    export function foo() {
        ...
    }
}
interface JQuery {
    foo(): JQuery;
}
(function ($) {
    $.fn.foo = function (): JQuery {
    ...
    return this;
    };
})(jQuery);

It was good as an extension method to a JQuery instance like $('selector').foo().
But now i need to add a static function to be able to call it like $.foo();
I Have tried replacing "JQuery" with "JQueryStatic" like this:
module JQueryExtensions {
    export function foo() {
        ...
    }
}
interface JQueryStatic{
    foo(): JQuery;
}
(function ($) {
    $.fn.foo = function (): JQuery {
    ...
    return this;
    };
})(JQueryStatic);

But it gives me the following error: "Cannot find name 'JQueryStatic'."
Comment: just pass `jQuery` instead of `JQueryStatic` and use `$.foo = ` instead of `$.fn.foo = `
Comment: Thank you @Aleksey, That Worked. Post it as an answer please.
Answer: Just pass jQuery (function / type definition) instead of JQueryStatic (interface) and use $.foo = (static method) instead of $.fn.foo = (instance method)
(function ($:JQueryStatic) {
    $.foo = function (): JQuery {
        ...
    };
})(jQuery);

Extend JQueryStatic with typescript


How does the "Obsidian Ring of the Zodiac" work in Diablo 3?

Question: In Diablo 3, the legendary ring Obsidian Ring of the Zodiac has the following legendary power since patch 2.2 (patch notes):

Reduce the remaining cooldown of one of your skills by 1 seconds when you hit with a resource-spending attack.

This can potentially allow for permanent uptime of certain skills (Champion of Akarat, Wrath of the Berserker, Epiphany, etc). However, it does not appear to scale as expected in situations with high density.
How does the ring's legendary power really work?
Answer: The description is slightly misleading, as the cooldown reduction is only triggered on the first hit by each spender cast. This means a multishot or blessed hammer can only reduce a cooldown by one second, no matter how many enemies are hit.
The legendary effect does not appear to be affected by proc coefficients (source, source), and conflicting reports are likely due to people expecting the ring to be able to reduce the cooldown every time a spender hits, not just the first (as per the first paragraph).
The cooldown that is reduced is randomly picked among your current remaining cooldowns (source).
This leads to a few conclusions:

As long as you're hitting at least one monster, further increasing mob density will not help you reduce your cooldowns.
Attack speed translates directly to cooldown reduction provided enough resources are available (given that at least one monster is being hit). The maximum cooldown achievable is directly tied to how many spenders you can put out in the given time frame. If you have a skill on a 90s cooldown, with a 30s duration, you need to hit with 60 spenders during that 30s duration to sustain permanent uptime.
If resources are abundant, casting extra spenders instead of letting present ones finish mobs can be beneficial (for example, casting a second Blessed Hammer to kill a mob that would otherwise die from a previously cast one).
To efficiently reduce the cooldown of a specific skill, one should avoid casting other cooldown-dependent skills unless necessary. The other skills will "steal" some of the random reductions and may prevent you from reaching permanent uptime  on the specific skill.

All in all, a better (or at least more accurate) description could be:

Reduce a randomly chosen remaining cooldown of one of your skills by 1 seconds the first time you hit with a resource-spending attack.

Also note that it is triggered when hitting debris or breakable containers, which can be useful for fast-moving builds.
Comment: Can confirm. I am a crusader hammerdin in season 4. Cubed the ring. Density does not matter, but I still use it as it really helps with cooldowns anyway.
Comment: @pfayze I provided three separate sources in the answer. Two of them are testimonial sources from _reddit_ (my own experience seems to confirm what they say). The conclusions are just consequences from the statements made in these sources. I have played with the ring for quite a bit and haven't (yet) seen anything to contradict the statements made, although there may be additional mechanics built in (some of my friends seem convinced there is some hidden internal cooldown built in, but I haven't been able to confirm this).
Comment: Did you test this all yourself? If not, please provide sources, I'd like to read more and see more confirmation of the first-enemy-hit mechanic.


phpunit - How to test property as object

Question: I have two classes.
class Posts {

  public function retrieve(): array {
   // Do something
  }

}

And
class PostsGateway {

 public $entity;

 function __construct() {
  $this->entity = new Posts();
 }

 public function retrieve(): array {
  return $this->entity->retrieve();
 }

}

I want to test the behaviour of PostsGateway class' retrieve method.
entity property is an object, so I am assigning this property an another mock which is for Posts class.
I am setting expectation on Posts mock which I have assigned to entity property in PostsGateway mock.

use PHPUnit\Framework\TestCase;

class PostsGatewayTest extends TestCase {

    /**
     * Test `retrieve` behavior.
     */
    public function testRetrieve() {
        $postsMock                = $this->createMock( Posts::class );
        $postsGatewayMock         = $this->createMock( PostsGateway::class );
        $postsGatewayMock->entity = $postsMock;

        $postsGatewayMock->entity->expects( $this->once() )->method( 'retrieve' );

        $data = $postsGatewayMock->retrieve();
    }

}

When I am running the test it is failing with following error.
PostsGatewayTest::testRetrieve

Expectation failed for method name is equal to 'retrieve' when invoked 1 time(s).
Method was expected to be called 1 times, actually called 0 times.

Answer: Well mocking a class it's not enough, you need to bind the mocked class to the real class so PostsGateway could understand about it. In this case, you can use constructor injection to pass the mocked class.
$mockPosts = $this->createMock(Posts::class);
$mockPosts->expects($this->once())->method('retrieve')->withAnyParameters();

$postsGateway = new PostsGateway($mockPosts);
$postsGateway->retrieve();

And the PostsGateway class should change to
class PostsGateway {

    public $entity;

    function __construct($posts) {
        $this->entity = $posts;
    }

    public function retrieve(): array {
        return $this->entity->retrieve();
    }

}


create a slider using your mouse with jquery from scratch

Question: I'm trying to create a slider similar to:
http://jqueryui.com/demos/slider/
Basically the idea is something very similar to the basic slider in the demo, except that in the handle that you grab with the mouse to slide will be numbers that change when you get to certain points. I think I can figure out the numbers part, but I'm completely stuck on how to start.
I want to do it from scratch with jquery... so no plugins. If anyone knows of any tutorials, or somewhere I could start that would be awesome.
Thanks
Answer: Depends. If you want to do it for the knowledge, I'd recommend having a look at the jQuery UI source code ;)
If you want to do it because jQuery UI is too "heavy" then FYI, you can customise which parts of it you download/use.
EDIT
Try: https://developer.mozilla.org/en/DragDrop/Drag_and_Drop
Comment: I still don't want to use a plugin, so option 2 is out. I do want the knowledge, but there is a lot of code that is not needed for option 1. I think if I figure out the drag and drop I could get most of it... didn't know if there were any tutorials that aren't using plugins of any kind
Answer: This is what I have, and it works.
<code>//sets the current position and offset variables
    var currentPosition;
    var offset;
    var rightOffset

    //looks for the mousedown event on the slider
    $("#slider").mousedown(function(e){
        //sets the offset = to the mouse coordinate of the page - the offset of the slider
        offset = e.pageX - this.offsetLeft;
        console.log("offset: " + offset);
        $(document).bind('mousemove', mmHandler);
    });

    var mmHandler = function (e) {

            currentPosition = e.pageX - offset;

            //takes the mouse current position (minues the offset) and sets an absolute position
            $('#slider').css('left', currentPosition + "px");
            console.log("CURRENT POSITION: " + currentPosition);

            //checks to make sure it's within the box
            if(currentPosition <= 0){
                $('#slider').css('left', 0 + "px");
            }else if(currentPosition >= 380){
                $('#slider').css('left', 400-20 + "px");
            }

            $("#slider").text($("#slider").css('left'));

        };

    $(document).mouseup(function(e) {
      $(document).unbind('mousemove', mmHandler);
    });
</code>


Remove number delimeters with regex

Question: I'm looking for a simple stupid solution, to remove delimiters from numbers within strings.
This function replaces 2.000 BC with 2000 BC:
$text preg_replace("/^[0-9.]+$/", "", $text);

Example:
$text = 'Lorem ipsum dolor. Consetetur elitr 2.000 BC sed diam nonumy 300.'

// Current behaviour (the delimeter at the end ot the line disappears):
// Lorem ipsum dolor. Consetetur elitr 2000 BC sed diam nonumy 300

// Expected behaviour:
// Lorem ipsum dolor. Consetetur elitr 2000 BC sed diam nonumy 300.

Comment: What if there is a number like `.45`, do you want to remove dot there too?
Answer: You can replace (?<=\d)\.(?=\d) with nothing:
<?php

$text = 'Lorem ipsum dolor. Consetetur elitr 2.000 BC sed diam nonumy 300.';

$text = preg_replace('/(?<=\d)\.(?=\d)/', '', $text);

var_dump($text);

//string(64) "Lorem ipsum dolor. Consetetur elitr 2000 BC sed diam nonumy 300."

DEMO
Regex autopsy:

(?<=\d) - a positive lookbehind matching a digit (this will not be replaced) - essentially this requires the . to be preceeded by a digit
\. - a literal . character, escaped as . means "any character" in regex
(?<=\d) - a positive lookahead matching a digit (this will not be replaced) - essentially this requires the . to be followed by a digit
Answer: To match the delimiter present only inside a number,
\d+\K\.(?=\d+)

DEMO
IDEONE
Your PHP code should be,
<?php
$string = 'Lorem ipsum dolor. Consetetur elitr 2.000 BC sed diam nonumy 300.';
$pattern = "~\d+\K\.(?=\d+)~";
$replacement = "";
echo preg_replace($pattern, $replacement, $string);
?>

Output:
Lorem ipsum dolor. Consetetur elitr 2000 BC sed diam nonumy 300.

Explanation:

\d+ One or more digits.
\K Discards the previously matched characters.
.(?=\d+) Matches a literal dot which should be followed by one or more digits.

Remove number delimeters with regex


Showing $\sin(1/x)$ is not a rectifiable curve

Question: Intuitively it looks like near $0$, $\sin(1/x)$ oscillates wildly so that two points will be very far apart, but how can I properly formulate this?
Comment: Probably it is intuitively obvious, and we can leave it at that! But if you want to be more formal, look at the arclength from $0$ to $1$. Set up the integral and show it does not converge. Or even more properly, look at arclength from $\epsilon>0$ to $1$, and show it blows up as $\epsilon$ approaches $0$.  So we calculate $\sqrt{1+(f'(x))^2}$. You will see this is real big near $0$.
Comment: Hint: Remember that the supremum is taken over all partitions of an interval, and notice that as $x$ approaches 0, the function will go from +1 to -1 and back an unbounded number of times, so the supremum must also be unbounded.
Answer: Let $x_n = \frac{1}{\pi(\frac{1}{2}+n)}$, $n=0,1,...$. Note that $\sin \frac{1}{x_n} = (-1)^n$. Note that $x_n$ monotonically decreases to $0$.
Consider the function on the interval $[x_n,x_0]$, using the partition $t_k = x_{n-k}$. Then the variation is exactly $2n$. Hence the variation is unbounded on the interval $(0,1)$ (or any open interval with $0$ as the left most point).


Ubuntu 20.04 top bar weird display calendar

Question: A picture speaks a thousand words: why is the calendar transparent and generally weird display? If the background isn't white, the calendar is unreadable

I'm using Ubuntu 20.04
Comment: Did you tried changing gnome-shell theme?
Comment: Is it always like that or happens after some specific trigger?
Comment: @RishabhKumar its always like that
Comment: It may be useful to know what exact version of GNOME Shell You're using and if You use Wayland or not. Could You provide that information?

I think I would also start from trying to change a theme as @jaga-matrix already suggested. You can also try changing from Wayland or to a Wayland session to see if it changes anything and - possibly obviously - updating a GNOME Shell if it's not in a newest available version.
Comment: @kcpr Ubuntu 20.04.2, Gnome 3.36.8. I notice this problem is mainly when any window is present. i.e. on normal desktop its fine, but once theres a program filling the screen this happens
Answer: Upgrading to Ubuntu 21.04 seems to fix the issue for me


Move files to folders with same name in Windows

Question: I use following command to copy files to folders with same name.
for /f %x in ('dir /ad /b') do move %x*.* %x\

I use move %x*.* %x\ to move the files to given directory. It doesn't work for files, which has spaces in their filenames, but not sure what to change.
Comment: I tried for /f %x in ('dir /ad /b') do move "%x*.* %x"\ , but I got syntax error message and files are not moved.
Answer: This command uses "DELIMS=" to prevent split.
for /f "DELIMS=" %x in ('dir /ad /b') do move "%x*.*" "%x\"


Multiple Collapse buttons in navbar with Bootstrap 3.0

Question: I'm using Bootstrap 3.0 to show a navbar with some links and a search field.
When I go to "mobile version" I have a button that collapses the navbar and show all the content: the links and the search field. Now I need two buttons, one to collapse only the links of the navbar and the other button to collapse only the search field. How can I make this?
Answer: Separate the links and the search form into two navbar-collapse elements and have each button target the corresponding one:
Sample markup:

        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#search">Toggle search</button>
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#links">Toggle links</button>
        Brand

        <form class="navbar-form navbar-left" role="search">

                <input type="text" class="form-control" placeholder="Search">

            <button type="submit" class="btn btn-default">Submit</button>
        </form>

You would then just need to fix some conflicting styles between .navbar-nav and .navbar-collapse by adding this to your CSS:
@media (max-width:767px) {
    .navbar-nav.navbar-collapse {
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
    }
}

Here's a demo fiddle
Comment: Thanks for this solution. I also found that it was necessary to add `margin-top:0;` and `margin-bottom:0;` to the `.navbar-nav.navbar-collapse` styles above, otherwise the default vertical margins cause a slight jump when the .navbar-nav slides shut.  Here is an [amended fiddle](http://jsfiddle.net/4Cc3p/1/)
Comment: I was looking at a jQuery solution to implement the Search, and didn't realize that you can just replicate Bootstrap's menu button.  Come to think of it, this should be part of the Bootstrap docs as collapsible Search is a common responsive pattern too. Thanks for the clever solution!


Angle between $\vec a$ and $\vec b $.

Question: We got the same size vector $\vec a$ and $\vec b $.
We know that the vector $\vec a +2\vec  b$ and $5\vec a-4\vec b$ are perpendicular?
$(\vec a +2\vec b) \perp (5 \vec a-4\vec b)$
What is angle between $\vec a$ and $\vec b $?
Answer: $$
(\vec{a} + 2 \vec{b})\cdot(5\vec a-4\vec b) = 0\\
5 \|\vec a\|^2-4(\vec a\cdot\vec b)+10(\vec a\cdot\vec b)-8\|\vec b\|^2 = 0\\
6(\vec a\cdot\vec b)=3\|\vec a\|^2 \\
\frac{(\vec a\cdot\vec b)}{\|\vec a\|\|\vec b\|} = \frac{1}{2} \\
\cos \theta = \frac{1}{2} \\
$$
So angle between the vectors is $\frac{\pi}{3}$. (Note that I have used the fact that they are of same size twice.)
Answer: since $\vec a+2\vec b$ is perpendicular to $5\vec a-4\vec b $
we have  $(\vec a+2\vec b)$.$(5\vec a-4\vec b )=0$,
$=5 \vec |a|^2-4 \vec a.\vec b+10\vec a.\vec b+-8|\vec b|^2=-3|\vec a|^2+6\vec a.\vec b=0$
$\text{   }$  $($since $|\vec a|=|\vec b|)$
which gives $3|\vec a|^2=6|\vec a|^2\cos\theta$
or, $\cos\theta=\frac12\implies\theta=\frac{\pi}3$
Answer: Note that
$$(\vec{a} + 2\vec{b})\cdot (5\vec{a}-4\vec{b}) = 5\|\vec{a}\|^2 +6\vec{a}\cdot\vec{b}-8\|\vec{b}\|^2 = 6\vec{a}\cdot\vec{b}-3\|\vec{a}\|^2$$
Thus, if those two vectors are perpendicular, then $6\vec{a}\cdot\vec{b}-3\|\vec{a}\|^2 = 0\implies \vec{a}\cdot\vec{b}=\frac{\|\vec{a}\|^2}{2}$.
Computing the angle between $\vec{a}$ and $\vec{b}$ should be straightforward from here.
Answer: Denote what you call the size of $a$ and $b$ by $r$. Then $0=(a+2b,5a-4b)=5(a,a)+6(a,b)-8(b,b)=5r^{2}+6r^2\cos (\alpha )-8r^{2}$ showing that $\cos (\alpha )=1/2$.

Angle between $\vec a$ and $\vec b $.


Is there an optimal dungeon order?

Question: I'm wondering, is there an optimal dungeon/mythical beast order, where each zone around that dungeon scales in difficulty, or is every zone around the beasts pretty much the same difficulty, making the dungeons be truly doable in any order?
Answer: Since the game is entirely open world, they're all fairly balanced. The order I did was Zora, Gerudo, Rito, and lastly Goron.
Doing Gerudo first may have some benefits because of the jeweler who gives elemental resist circlets, but this is not necessary as Rito and Goron gear are much better (and have a set bonus).
Doing the Zora one first could have advantages because the power you get is an auto-revive, which can help quite a bit.
Doing the Rito one first would help you travel a bit more, given that the power you get helps a bit with exploration.
In particular, the Goron one I would save for last. You'll need money or patience to get around Death Mountain (given the heat that sets you literally on fire), and it would probably be the toughest of all of them to do first. But, you certainly could.
Comment: I've found that the power you get from the Rito almost trivializes exploration to the point where it's not as exciting any more

Is there an optimal dungeon order?


What is the correct programming terminology for what I am calling interface?

Question: I am finishing up my first semester of Programming Fundamentals. We have a final project of creating a software package using programs either that are in the textbook, previously created assignment programs, etc. I am using C++ Visual Studios 2013. I want to broaden my reach and create an application with, what I call a user interface (designed page that pops up after double clicking the desktop icon, that has a basic button named "Play"). Upon the user pressing "Play" button with the left mouse click, I'd like it to advance to another screen and execute the program. My question, what is the correct programming terminology to browse the web for what I want to do?
I saw this link that made me realize I was searching for the wrong thing.
Explaining Interfaces to Students
Comment: GUI? Graphic User Interface?
Comment: Sounds like a "window".  A window is part of your program's User Interface (that is the correct term), but not all interfaces in software are with the user.  There are also interfaces between software components, or with the hardware, etc.
Comment: But I don't want a dos window that normally pops up when double clicking the .exe (application) file. Do I need to find different software? I saw this one that is C++ Builder by http://www.embarcadero.com/products/cbuilder
Comment: @ user3528438 - Hmmm..that would be fun. I did a search on that, and I think I'll see if I can incorporate my C++ program into something like that.
Answer: A graphical user interface, or GUI: http://en.wikipedia.org/wiki/Graphical_user_interface
An interface class in C++ typically refers to an abstract class that acts as an interface for derived classes. Typically it has no data members or constructors and contains mostly pure virtual functions (as it cannot be instantiated alone).
Comment: Thank you for your help. You answered my question. I hope you all have a wonderful evening.


Trying to bind submit and save to localStorage

Question: Here my App.js code, I am trying to bind and capture the "handlesubmit" function, and then append to an empty list which will be populated. Thanks.
import React from 'react';

const App = () => {
  const [songs, setSongs] = React.useState([]);

  React.useEffect(() => {
    const data = localStorage.getItem('songs');
    if (!data) { }
    setSongs(JSON.parse(data));
  }, []);

  React.useEffect(() => {
    localStorage.setItem('songs', JSON.stringify(songs));
  });

  const handleSubmit = data => {
    setSongs([data]);
  }

  return (

Music Editor

    <form onSubmit={this.props.handleSubmit(this.handleSubmit.bind(this))} autoComplete="false">
      Title:
      <input type="text" id="title" name="title" placeholder="Type title/name of song" value="" />
      <input type="submit" value="Add song" />
    </form>

  );
}

export default App;

Comment: Can you provide more information about the problem you're having? What isn't working as expected?
Answer: The explanation is commented in the code itself.
Here is the codesandbox link to see the App working.
import React from 'react';

const App = () => {
  const [songs, setSongs] = React.useState([]);

  // use another state for song title
  const [songTitle, setSongTitle] = React.useState('');

  React.useEffect(() => {
    const data = localStorage.getItem('songs');
    // only update the state when the data persists
    if (data) setSongs(JSON.parse(data));
  }, []);

  // update the localStorage whenever the songs array changes
  React.useEffect(() => {
    localStorage.setItem('songs', JSON.stringify(songs));
  }, [songs]);

  // inside the functional component, there is no "this" keyword
  const handleSubmit = (event) => {
    event.preventDefault();
    // append the new song title with the old one
    setSongs([
      ...songs,
      songTitle
    ]);
  }

  return (

Music Editor

    <form onSubmit={handleSubmit} autoComplete="false">
      Title:
      <input
        type="text"
        id="title"
        name="title"
        placeholder="Type title/name of song"
        value={songTitle}
        onChange={e => setSongTitle(e.target.value)}
      />
      <input type="submit" value="Add song" />
    </form>

  );
}

export default App;

Comment: @JohnSmith While submitting the song title, we should append the new `songTitle` to the previous ones in `songs`. So, in order to do that, we could simply do **setSongs([ ...songs, songTitle ])** which means we are updating the songs array with the new song title. For convenience, you should clear our the localStorage and check again.
Comment: ["C","o","l","d","P","l","a","y"," ","-"," ","L","o","s","t"] ??
Comment: @JohnSmith My bad. You need not spread the songTitle since it is a string here in line while updating the state.

    **setSongs([ ...songs, songTitle ])**

I have made change the code also.
Comment: Please explain, I do not understand.


Clash of clans linking problem

Question: I have two Google accounts, and I play coc on my iPad. I linked my new phone using my first Google account through the iPad, but now I want to cancel the link with my first account and instead add the link to the second gmail account because I use that account more.
I have written several emails to the Supercell community, but there has been no reply from their side.
Can I instead transfer my achievements or something from my first gmail account to the second?
Comment: There appears to be some confusion here. Google+ accounts cannot be linked on an iPad. Either you're linking to a Game Center account, or you're using an Android device instead.
Comment: @Thebluefish Thats what i am saying i linked my coc account first to my ipad then my new phone but with the wrong account on my new phone i wanted it to be linked with another gmail account which i use more.
Comment: You can create an appleid with the same email address as your google account.  On android the "google id" you sign into for the game can be different from the one you are using for e.g. gmail. The same is true on the  iPad... the "itunes" or "primary" appleid can be different from the one you use in GameCenter.
Answer: Linking a Clash of Clans village with your Google+ account is a permanent process. You cannot unlink an account from the Google+ account, and you cannot transfer it to a different Google+ account.
The best suggestion I can offer is to use the in-game support to request that SuperCell transfer it for you or unlink it from the unwanted Google+ account. With Clash of Clans open, go to Settings -> "Help and Support" at the bottom -> "Report an issue" at the bottom-right -> "Other Problem". This will open up an email to SuperCell with important info about your village, you can ask them about your issue there.
Other than that, there is no way to accomplish what you're asking for.
Comment: The OP stated he was using his Google account with an iPad which implies he has actually created an AppleID using his Gmail account for the  email.  This is perfectly possible... and guess what, you can change your AppleID email to point somewhere completely different.

Clash of clans linking problem


facial expressions classification (emotions) in real time

Question: I am currently working on a project where I have to extract the facial expression of a user (only one user at a time from a webcam) like sad or happy.
The best possibility I found so far:
I used OpenCV for face detection.
Some user on a OpenCV board suggested looking for AAM (active apereance models) and ASM (active shape models), but all I found were papers.
-So i'm Using Active Shape Models with Stasm, which will give me access to 77 different points within the face like on the picture

now i want to know the best way to do :

the best learning method to use on cohn and kanade database  to classify the emotions (happy,....) ?
the best method to classify the facial expressions on a video in real time ?
Answer: Look here for similar solution video and description of algorithm: http://www2.isr.uc.pt/~pedromartins/ in "Identity and Expression Recognition on Low Dimensional Manifolds" 2009 year.


Postfix sends from localhost using mail but does not relay mails from local clients

Question: For a couple of days I am trying to configure Postfix/Dovecot, I did my best to follow the guides, I can receive mail but cannot send mail from other mail clients than localhost.
Here is a syslog line regarding to a try from a mail-client from the LAN:
Mar 28 12:37:38 mail postfix/smtpd[12524]: NOQUEUE: reject: RCPT from ***.ru[***.***.64.243]: 454 4.7.1 <***@gmail.com>: Relay access denied; from=<***@mymail.server> to=<***@gmail.com> proto=ESMTP helo=<[***.16.98.44]>

Sending mail from the localhost via mail command:

mail ***@gmail.com

This works as expected.
I don't know where to go further, any suggestions/help would be very appreciated.
My main.cf file looks like:
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package     for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mail.myserver.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = myserver.com
mydestination = myserver.com, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8, 22.214.171.124/32
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
home_mailbox = Maildir/
mailbox_command =
smtpd_sasl_type = dovecot
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions =  permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_sasl_path = private/auth

Comment: Try separating the options in `smtpd_relay_restrictions` with commas.
Comment: Tried - no luck. Actually I got some feedback from postfix while I played with the options - postfix recognizes them...
Answer: Postfix allows relaying emails from the localhost via mail command because of:
mynetworks = 127.0.0.0/8, 188.8.131.52/32
smtpd_recipient_restrictions = permit_mynetworks

Because your other email-clients are from the LAN, but these LAN IP addresses are not part of mynetworks, postfix prohibits relaying email. You need to add all local IP addresses, you wish to permit sending emails using your mail server as a relay, to mynetworks. I.e. if your LAN is 192.168.1.x you need to add
mynetworks = 127.0.0.0/8, 220.127.116.11/32 192.168.1.0/24

With this configuraion all clients with IP addresses like 192.168.1.x may relay emails using your server.


Use just Sharepoint 2010 foundation

Question: am an ASP.NET developer new to Sharepoint.
Having installed Sharepoint Server 2010, SQL and VStudio on Server 2008 I'm trying find out if there is a way to disable all the extra features that come with SP Server.
I wish to develop SP foundation apps only.
Do I need to uninstall SP server and just install SP foundation or is there some other way of turning the extra stuff off?
For example, I can create Surveys but I don't want them if they're not in foundation.
Comment: You have asked 10 questions, but you have not accepted any answers. You should accept answers that help you, if you want people to continue to answer your questions
Answer: If you really only want SP Foundation stuff on your development machine, the best way is indeed to remove SharePoint Server and install SharePoint Foundation instead.
I suppose the reason behind this is to not accidently use things that are not available in Foundation ?
btw: Surveys exist in Foundation as well ;)
Comment: Yes, the client wants to resist spending $$ on Server 2010. Can't blame them can you. Thanks very much Tom, a new VM in order I think :)
Comment: It's not that much work... just copy the existing VM (so that you also have a version with SP Server for future projects), remove SP Server from it and install SP Foundation instead. If the answer was useful, please mark it as the accepted answer. Of course you're free to wait a couple of days to see what others think about the matter.
Answer: You can just deactivate all the server features under farm/web app/site collection/site. we've been developing on MOSS machine for WSS for years, and it works well. Just pay attention if you use any graphics that come with sharepoint, as they might be installed by the server and not WSS.

Use just Sharepoint 2010 foundation


modify my navbar in media queries. Bootstrap 3

Question: i´m  trying to modify my navbar across media queries, for medium and large screens my logo it´s into a jumbotron div, but i want to change where it appears when the screens is less than 768px, i want to put it on my navbar. Can I make it on my css or not.
Thanx.
This is my code for md and lg screens.

                <form class="form-inline" role="form">

                        Email address
                        <input type="email" class="form-control" id="exampleInputEmail" placeholder="Email">

                        Password
                        <input type="password" class="form-control" id="exampleInputPassword" placeholder="Password">

                        <button type="button" id="btnlogin" class="btn btn-primary btn-md btn-block">Entrar</button>

                </form>

        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
            Toggle navigation

        </button>

INICIO

WORKSHOPS

MAESTROS

BLOG

ESCAPADAS

EQUIPAMIENTO

Comment: But you didnt told us how do you like to look??
Comment: My navbar is under the jumbotron, and the logo for md and lg screens its in jumbotro. I want to put the logo img in the navbar (collapse) for the small screens
Comment: Have you look my solution?
Answer: If you want to use CSS3 to design different layouts for different screen widths, use media queries.
In order to achieve what you are asking, consider hiding the logo from the Jumbotron by default, and only showing it when the min-width of the screen exceeds a certain amount. For example, your CSS might look like this:
.my-logo {
    display: none;
}

@media (min-width: 992px) {
    .my-logo {
        display: block;
    }
}

You can then use this same logic to show/hide the logo from the navbar.
Comment: In Bootsrap 3 there is class for hide and show element :) You dont need to add new media queries just add class
Comment: Fair enough. They may need to write their own CSS if they want more flexibility than Bootstrap's helper classes provide, but if they simply need to hide/show at the pre-defined widths, your suggestion works well.
Answer: Try like this

<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                Toggle navigation

            </button>

INICIO

WORKSHOPS

MAESTROS

BLOG

ESCAPADAS

EQUIPAMIENTO

Comment: Thank you, it works. i´ve just to fit the logo now in the nav because it move the collapse icon. But this solution it´s so good, thank you again.


Azure Authentication error

Question: I am trying to implement azure authentication in my app. While loggin i am getting the following error on callback.
I/BasicWebViewClient: 2016-09-09 11:05:36-861ccdea-817d-46ac-8a5e-167baaa2d327-Sending intent to cancel authentication activity ver:1.1.1
09-09 16:35:37.586 2318-2318/com.example.demoazure E/exc: User cancelled the flow RequestId:241649731 CorrelationId: da49e002-edaa-4e9d-8571-09eb2a714b79
Here's my code:
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try {
            mContext = new AuthenticationContext(MainActivity.this, authority, true);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (NoSuchPaddingException e) {
            e.printStackTrace();
        }

        mContext.acquireToken(MainActivity.this, resource, clientId, redirect, user_loginhint, PromptBehavior.Auto, "",
                callback);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (mContext != null) {
            mContext.onActivityResult(requestCode, resultCode, data);
        }
    }

    private AuthenticationCallback<AuthenticationResult> callback = new AuthenticationCallback<AuthenticationResult>() {

        @Override
        public void onError(Exception exc) {
            if (exc instanceof AuthenticationException) {

                Log.e("exc",exc.getMessage());
                //textViewStatus.setText("Cancelled");
                Log.d(TAG, "Cancelled");
            } else {
                //textViewStatus.setText("Authentication error:" + exc.getMessage());
                Log.d(TAG, "Authentication error:" + exc.getMessage());
            }
        }

        @Override
        public void onSuccess(AuthenticationResult result) {
            mResult = result;

            Log.e("success","success");

            if (result == null || result.getAccessToken() == null
                    || result.getAccessToken().isEmpty()) {
                //textViewStatus.setText("Token is empty");
                Log.d(TAG, "Token is empty");
            } else {
                // request is successful
                Log.d(TAG, "Status:" + result.getStatus() + " Expired:"
                        + result.getExpiresOn().toString());
               // textViewStatus.setText(PASSED);
            }
        }
    };

Any help will be appreciated.
LogCat:
09-09 17:10:18.853 23883-23883/com.example.demoazure I/art: Late-enabling -Xcheck:jni
09-09 17:10:18.928 23883-23883/com.example.demoazure W/System: ClassLoader referenced unknown path: /data/app/com.example.demoazure-1/lib/arm
09-09 17:10:20.781 23883-23883/com.example.demoazure W/System: ClassLoader referenced unknown path: /data/app/com.example.demoazure-1/lib/arm
09-09 17:10:21.564 23883-23883/com.example.demoazure V/PRNGFixes: 2016-09-09 11:40:21-null-No need to apply the fix ver:1.1.1
09-09 17:10:21.565 23883-23883/com.example.demoazure V/PRNGFixes: 2016-09-09 11:40:21-null-No need to apply the fix ver:1.1.1
09-09 17:10:21.632 23883-23883/com.example.demoazure V/DefaultTokenCacheStore: 2016-09-09 11:40:21-null-Started to initialize storage helper ver:1.1.1
09-09 17:10:21.633 23883-23883/com.example.demoazure V/DefaultTokenCacheStore: 2016-09-09 11:40:21-null-Finished to initialize storage helper ver:1.1.1
09-09 17:10:21.645 23883-23883/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Sending async task from thread:23883 ver:1.1.1
09-09 17:10:21.650 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Running task in thread:24066 ver:1.1.1
09-09 17:10:21.655 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Start validating authority ver:1.1.1
09-09 17:10:21.660 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Finish validating authority:https://login.microsoftonline.com/common result:true ver:1.1.1
09-09 17:10:21.661 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Authority is validated: https://login.microsoftonline.com/common ver:1.1.1
09-09 17:10:21.662 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Token request started ver:1.1.1
09-09 17:10:21.670 23883-24066/com.example.demoazure W/BrokerProxy: DEVELOPER_BROKER_PERMISSIONS_MISSING:2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Broker related permissions are missing for GET_ACCOUNTS, MANAGE_ACCOUNTS, USE_CREDENTIALS ver:1.1.1
09-09 17:10:21.672 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Checking refresh tokens ver:1.1.1
09-09 17:10:21.673 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Looking for regular refresh token ver:1.1.1
09-09 17:10:21.674 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Looking for Multi Resource Refresh token ver:1.1.1
09-09 17:10:21.675 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Refresh token is not available ver:1.1.1
09-09 17:10:21.677 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Starting Authentication Activity with callback:128920197 ver:1.1.1
09-09 17:10:21.679 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Put waiting request: 128920197 CorrelationId: a8fbdb87-7fbb-4db8-b14c-05b5da575930 ver:1.1.1
09-09 17:10:21.698 23883-24067/com.example.demoazure D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
09-09 17:10:21.743 23883-23883/com.example.demoazure I/WebViewFactory: Loading com.google.android.webview version 53.0.2785.97 (code 278509700)
09-09 17:10:21.963 23883-23883/com.example.demoazure I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
09-09 17:10:21.963 23883-23883/com.example.demoazure I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
09-09 17:10:21.967 23883-23883/com.example.demoazure I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
09-09 17:10:21.967 23883-23883/com.example.demoazure I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
09-09 17:10:22.029 23883-23883/com.example.demoazure I/cr_LibraryLoader: Time to load native libraries: 20 ms (timestamps 9402-9422)
09-09 17:10:22.032 23883-23883/com.example.demoazure I/cr_LibraryLoader: Expected native library version number "53.0.2785.97", actual native library version number "53.0.2785.97"
09-09 17:10:22.112 23883-23883/com.example.demoazure V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {ce28790}
09-09 17:10:22.113 23883-23883/com.example.demoazure I/cr_LibraryLoader: Expected native library version number "53.0.2785.97", actual native library version number "53.0.2785.97"
09-09 17:10:22.139 23883-23883/com.example.demoazure I/chromium: [INFO:library_loader_hooks.cc(151)] Chromium logging enabled: level = 0, default verbosity = 0
09-09 17:10:22.179 23883-23883/com.example.demoazure I/cr_BrowserStartup: Initializing chromium process, singleProcess=true
09-09 17:10:22.392 23883-23883/com.example.demoazure I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 10/09/15, 6cbbf7d, I3193f6e94a
09-09 17:10:22.590 23883-24115/com.example.demoazure W/cr_media: Requires BLUETOOTH permission
09-09 17:10:22.756 23883-24150/com.example.demoazure D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524290
09-09 17:10:22.815 23883-23883/com.example.demoazure W/cr_AwContents: onDetachedFromWindow called when already detached. Ignoring
09-09 17:10:22.822 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:22-7be16668-be3d-4554-8d94-f9968015fd22-Packagename:com.example.demoazure Broker packagename:com.microsoft.windowsintune.companyportal Calling packagename:com.example.demoazure ver:1.1.1
09-09 17:10:22.850 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:22-7be16668-be3d-4554-8d94-f9968015fd22-OnCreate redirectUrl:http://a14idt ver:1.1.1
09-09 17:10:22.854 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:22-7be16668-be3d-4554-8d94-f9968015fd22-User agent:Mozilla/5.0 (Linux; Android 6.0; XT1068 Build/MPB24.65-34; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.97 Mobile Safari/537.36 ver:1.1.1
09-09 17:10:22.865 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:22-7be16668-be3d-4554-8d94-f9968015fd22-Init broadcastReceiver with requestId:128920197 Request authority:https://login.microsoftonline.com/common resource:http://win8webapp.azurewebsites.net/  clientid:da2310c5-97b4-44f8-8b03-29fd0424895a ver:1.1.1
09-09 17:10:22.869 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:22-7be16668-be3d-4554-8d94-f9968015fd22-UserAgent:Mozilla/5.0 (Linux; Android 6.0; XT1068 Build/MPB24.65-34; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.97 Mobile Safari/537.36 PKeyAuth/1.0 ver:1.1.1
09-09 17:10:22.870 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:22-7be16668-be3d-4554-8d94-f9968015fd22-Packagename:com.example.demoazure Broker packagename:com.microsoft.windowsintune.companyportal Calling packagename:com.example.demoazure ver:1.1.1
09-09 17:10:22.872 23883-23883/com.example.demoazure I/AuthenticationActivity: 2016-09-09 11:40:22-7be16668-be3d-4554-8d94-f9968015fd22-OnCreate startUrl:https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=da2310c5-97b4-44f8-8b03-29fd0424895a&resource=http%3A%2F%2Fwin8webapp.azurewebsites.net%2F+&redirect_uri=http%3A%2F%2Fa14idt&state=YT1odHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vY29tbW9uJnI9aHR0cDovL3dpbjh3
                                                                               ZWJhcHAuYXp1cmV3ZWJzaXRlcy5uZXQvIA
                                                                               &x-client-SKU=Android&x-client-Ver=1.1.1&x-client-OS=23&x-client-DM=XT1068&client-request-id=a8fbdb87-7fbb-4db8-b14c-05b5da575930 calling package:null ver:1.1.1  device:6.0 motorolaXT1068
09-09 17:10:22.881 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:22-7be16668-be3d-4554-8d94-f9968015fd22-onResume ver:1.1.1
09-09 17:10:22.915 23883-23889/com.example.demoazure I/art: Debugger is no longer active
09-09 17:10:22.984 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:22-7be16668-be3d-4554-8d94-f9968015fd22-AuthenticationActivity onPause unregister receiver ver:1.1.1
09-09 17:10:22.985 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:22-7be16668-be3d-4554-8d94-f9968015fd22-Spinner at onPause will dismiss ver:1.1.1
09-09 17:10:22.986 23883-23883/com.example.demoazure I/Choreographer: Skipped 74 frames!  The application may be doing too much work on its main thread.
09-09 17:10:23.049 23883-24067/com.example.demoazure I/OpenGLRenderer: Initialized EGL, version 1.4
09-09 17:10:23.203 23883-24150/com.example.demoazure D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524290
09-09 17:10:23.338 23883-23883/com.example.demoazure I/cr_Ime: ImeThread is not enabled.
09-09 17:10:23.798 23883-23883/com.example.demoazure W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 23883
09-09 17:10:23.809 23883-23883/com.example.demoazure V/BasicWebViewClient: 2016-09-09 11:40:23-7be16668-be3d-4554-8d94-f9968015fd22-Page finished:about:blank ver:1.1.1
09-09 17:10:23.824 23883-24183/com.example.demoazure E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
09-09 17:10:23.843 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:23-7be16668-be3d-4554-8d94-f9968015fd22-displaySpinner:true showing:false ver:1.1.1
09-09 17:10:24.164 23883-24183/com.example.demoazure W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
09-09 17:10:24.185 23883-24183/com.example.demoazure W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2
09-09 17:10:24.226 23883-24183/com.example.demoazure I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
09-09 17:10:24.324 23883-23894/com.example.demoazure I/art: Background partial concurrent mark sweep GC freed 17951(2MB) AllocSpace objects, 6(120KB) LOS objects, 40% free, 8MB/14MB, paused 16.551ms total 214.577ms
09-09 17:10:24.339 23883-23894/com.example.demoazure W/art: Suspending all threads took: 15.470ms
09-09 17:10:26.452 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:26-7be16668-be3d-4554-8d94-f9968015fd22-AuthenticationActivity onRestart ver:1.1.1
09-09 17:10:26.478 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:26-7be16668-be3d-4554-8d94-f9968015fd22-onResume ver:1.1.1
09-09 17:10:26.480 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:26-7be16668-be3d-4554-8d94-f9968015fd22-Webview onResume will register receiver:https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=da2310c5-97b4-44f8-8b03-29fd0424895a&resource=http%3A%2F%2Fwin8webapp.azurewebsites.net%2F+&redirect_uri=http%3A%2F%2Fa14idt&state=YT1odHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vY29tbW9uJnI9aHR0cDovL3dpbjh3
                                                                               ZWJhcHAuYXp1cmV3ZWJzaXRlcy5uZXQvIA
                                                                               &x-client-SKU=Android&x-client-Ver=1.1.1&x-client-OS=23&x-client-DM=XT1068&client-request-id=a8fbdb87-7fbb-4db8-b14c-05b5da575930 ver:1.1.1
09-09 17:10:26.481 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:26-7be16668-be3d-4554-8d94-f9968015fd22-Webview onResume register broadcast receiver for requestId128920197 ver:1.1.1
09-09 17:10:29.439 23883-23883/com.example.demoazure W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 23883
09-09 17:10:31.185 23883-23883/com.example.demoazure V/BasicWebViewClient: 2016-09-09 11:40:31-7be16668-be3d-4554-8d94-f9968015fd22-Page finished:https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=da2310c5-97b4-44f8-8b03-29fd0424895a&resource=http%3A%2F%2Fwin8webapp.azurewebsites.net%2F+&redirect_uri=http%3A%2F%2Fa14idt&state=YT1odHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vY29tbW9uJnI9aHR0cDovL3dpbjh3ZWJhcHAuYXp1cmV3ZWJzaXRlcy5uZXQvIA&x-client-SKU=Android&x-client-Ver=1.1.1&x-client-OS=23&x-client-DM=XT1068&client-request-id=a8fbdb87-7fbb-4db8-b14c-05b5da575930 ver:1.1.1
09-09 17:10:31.186 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:31-7be16668-be3d-4554-8d94-f9968015fd22-displaySpinner:false showing:false ver:1.1.1
09-09 17:10:56.604 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:56-7be16668-be3d-4554-8d94-f9968015fd22-AuthenticationActivity onPause unregister receiver ver:1.1.1
09-09 17:10:56.605 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:56-7be16668-be3d-4554-8d94-f9968015fd22-Spinner at onPause will dismiss ver:1.1.1
09-09 17:10:57.178 23883-23889/com.example.demoazure I/art: Debugger is no longer active
09-09 17:10:57.304 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:57-7be16668-be3d-4554-8d94-f9968015fd22-AuthenticationActivity onRestart ver:1.1.1
09-09 17:10:57.434 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:57-7be16668-be3d-4554-8d94-f9968015fd22-onResume ver:1.1.1
09-09 17:10:57.438 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:57-7be16668-be3d-4554-8d94-f9968015fd22-Webview onResume will register receiver:https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=da2310c5-97b4-44f8-8b03-29fd0424895a&resource=http%3A%2F%2Fwin8webapp.azurewebsites.net%2F+&redirect_uri=http%3A%2F%2Fa14idt&state=YT1odHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vY29tbW9uJnI9aHR0cDovL3dpbjh3
                                                                               ZWJhcHAuYXp1cmV3ZWJzaXRlcy5uZXQvIA
                                                                               &x-client-SKU=Android&x-client-Ver=1.1.1&x-client-OS=23&x-client-DM=XT1068&client-request-id=a8fbdb87-7fbb-4db8-b14c-05b5da575930 ver:1.1.1
09-09 17:10:57.439 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:40:57-7be16668-be3d-4554-8d94-f9968015fd22-Webview onResume register broadcast receiver for requestId128920197 ver:1.1.1
09-09 17:11:27.821 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:41:27-7be16668-be3d-4554-8d94-f9968015fd22-AuthenticationActivity onPause unregister receiver ver:1.1.1
09-09 17:11:27.823 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:41:27-7be16668-be3d-4554-8d94-f9968015fd22-Spinner at onPause will dismiss ver:1.1.1
09-09 17:11:40.729 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:41:40-7be16668-be3d-4554-8d94-f9968015fd22-AuthenticationActivity onRestart ver:1.1.1
09-09 17:11:40.732 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:41:40-7be16668-be3d-4554-8d94-f9968015fd22-onResume ver:1.1.1
09-09 17:11:40.733 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:41:40-7be16668-be3d-4554-8d94-f9968015fd22-Webview onResume will register receiver:https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=da2310c5-97b4-44f8-8b03-29fd0424895a&resource=http%3A%2F%2Fwin8webapp.azurewebsites.net%2F+&redirect_uri=http%3A%2F%2Fa14idt&state=YT1odHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vY29tbW9uJnI9aHR0cDovL3dpbjh3
                                                                               ZWJhcHAuYXp1cmV3ZWJzaXRlcy5uZXQvIA
                                                                               &x-client-SKU=Android&x-client-Ver=1.1.1&x-client-OS=23&x-client-DM=XT1068&client-request-id=a8fbdb87-7fbb-4db8-b14c-05b5da575930 ver:1.1.1
09-09 17:11:40.734 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:41:40-7be16668-be3d-4554-8d94-f9968015fd22-Webview onResume register broadcast receiver for requestId128920197 ver:1.1.1
09-09 17:11:45.666 23883-24067/com.example.demoazure E/Surface: getSlotFromBufferLocked: unknown buffer: 0xba1ced10
09-09 17:11:45.682 23883-23883/com.example.demoazure W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
09-09 17:11:53.291 23883-23883/com.example.demoazure E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
09-09 17:11:53.291 23883-23883/com.example.demoazure E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
09-09 17:12:33.255 23883-24150/com.example.demoazure D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524294
09-09 17:12:33.271 23883-24150/com.example.demoazure D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524294
09-09 17:12:34.728 23883-24150/com.example.demoazure D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524294
09-09 17:12:34.729 23883-24150/com.example.demoazure D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524294
09-09 17:12:37.908 23883-24150/com.example.demoazure D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524294
09-09 17:12:37.910 23883-24150/com.example.demoazure D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524294
09-09 17:12:38.903 23883-24150/com.example.demoazure D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524294
09-09 17:12:38.908 23883-24150/com.example.demoazure D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524294
09-09 17:12:42.883 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:42:42-7be16668-be3d-4554-8d94-f9968015fd22-displaySpinner:true showing:false ver:1.1.1
09-09 17:12:45.938 23883-23883/com.example.demoazure W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 23883
09-09 17:12:46.472 23883-23883/com.example.demoazure V/BasicWebViewClient: 2016-09-09 11:42:46-7be16668-be3d-4554-8d94-f9968015fd22-Page finished:https://login.microsoftonline.com/common/login ver:1.1.1
09-09 17:12:46.473 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:42:46-7be16668-be3d-4554-8d94-f9968015fd22-displaySpinner:false showing:true ver:1.1.1
09-09 17:12:46.482 23883-24067/com.example.demoazure E/Surface: getSlotFromBufferLocked: unknown buffer: 0xba68b340
09-09 17:12:53.558 23883-23883/com.example.demoazure W/IInputConnectionWrapper: beginBatchEdit on inactive InputConnection
09-09 17:12:53.558 23883-23883/com.example.demoazure W/IInputConnectionWrapper: getSelectedText on inactive InputConnection
09-09 17:12:53.559 23883-23883/com.example.demoazure W/IInputConnectionWrapper: endBatchEdit on inactive InputConnection
09-09 17:12:53.559 23883-23883/com.example.demoazure W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
09-09 17:12:53.559 23883-23883/com.example.demoazure W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
09-09 17:12:53.562 23883-23883/com.example.demoazure W/IInputConnectionWrapper: beginBatchEdit on inactive InputConnection
09-09 17:12:53.563 23883-23883/com.example.demoazure W/IInputConnectionWrapper: getSelectedText on inactive InputConnection
09-09 17:12:53.563 23883-23883/com.example.demoazure W/IInputConnectionWrapper: endBatchEdit on inactive InputConnection
09-09 17:12:53.564 23883-23883/com.example.demoazure W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
09-09 17:12:53.564 23883-23883/com.example.demoazure W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
09-09 17:13:29.819 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:43:29-7be16668-be3d-4554-8d94-f9968015fd22-displaySpinner:true showing:false ver:1.1.1
09-09 17:13:33.273 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-displaySpinner:true showing:true ver:1.1.1
09-09 17:13:33.282 23883-23883/com.example.demoazure V/BasicWebViewClient: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-Navigation is detected ver:1.1.1
                                                                           Timestamp: 2016-09-09 11:43:32Z ver:1.1.1
09-09 17:13:33.306 23883-23883/com.example.demoazure I/BasicWebViewClient: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-Sending intent to cancel authentication activity ver:1.1.1
09-09 17:13:33.309 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-Sending intent to cancel authentication activity ver:1.1.1
09-09 17:13:33.313 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-Return To Caller:2001 ver:1.1.1
09-09 17:13:33.314 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-displaySpinner:false showing:true ver:1.1.1
09-09 17:13:33.319 23883-24067/com.example.demoazure E/Surface: getSlotFromBufferLocked: unknown buffer: 0xba3e41a8
09-09 17:13:33.325 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-Return To Caller REQUEST_ID:128920197 ver:1.1.1
09-09 17:13:33.329 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-Packagename:com.example.demoazure Broker packagename:com.microsoft.windowsintune.companyportal Calling packagename:com.example.demoazure ver:1.1.1
09-09 17:13:33.346 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-AuthenticationActivity onPause unregister receiver ver:1.1.1
09-09 17:13:33.349 23883-23883/com.example.demoazure V/AuthenticationActivity: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-Spinner at onPause will dismiss ver:1.1.1
09-09 17:13:33.359 23883-23883/com.example.demoazure W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 23883
09-09 17:13:33.382 23883-23883/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-Get waiting request: 128920197 ver:1.1.1
09-09 17:13:33.383 23883-23883/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-onActivityResult RequestId:128920197 ver:1.1.1
09-09 17:13:33.385 23883-23883/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-User cancelled the flow RequestId:128920197 CorrelationId: a8fbdb87-7fbb-4db8-b14c-05b5da575930 ver:1.1.1
09-09 17:13:33.400 23883-23883/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-Sending error to callback CorrelationId: a8fbdb87-7fbb-4db8-b14c-05b5da575930 ver:1.1.1
09-09 17:13:33.400 23883-23883/com.example.demoazure E/exc: User cancelled the flow RequestId:128920197 CorrelationId: a8fbdb87-7fbb-4db8-b14c-05b5da575930
09-09 17:13:33.401 23883-23883/com.example.demoazure D/tag: Cancelled
09-09 17:13:33.412 23883-23883/com.example.demoazure V/BasicWebViewClient: 2016-09-09 11:43:33-7be16668-be3d-4554-8d94-f9968015fd22-Page finished:http://a14idt/?error=invalid_resource&error_description=AADSTS50001%3a+The+application+named+http%3a%2f%2fwin8webapp.azurewebsites.net%2f+was+not+found+in+the+tenant+named+thea14.com.++This+can+happen+if+the+application+has+not+been+installed+by+the+administrator+of+the+tenant+or+consented+to+by+any+user+in+the+tenant.++You+might+have+sent+your+authentication+request+to+the+wrong+tenant.%0d%0aTrace+ID%3a+49c97d40-e05e-491f-b601-f349d4fed8e8%0d%0aCorrelation+ID%3a+a8fbdb87-7fbb-4db8-b14c-05b5da575930%0d%0aTimestamp%3a+2016-09-09+11%3a43%3a32Z&state=YT1odHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vY29tbW9uJnI9aHR0cDovL3dpbjh3ZWJhcHAuYXp1cmV3ZWJzaXRlcy5uZXQvIA ver:1.1.1

Comment: can you post full logcat.
Comment: please check logcat @VishalThakkar
Comment: hey  i have checked you log cat see my answer and check it.
Answer: I think you missed DEVELOPER_BROKER_PERMISSIONS.
You could try integrating your Android Application with Azure Active Directory by referring the following article:
http://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-store-dotnet-adal-sso-authentication/
For further information, you could also refer:
http://azure.microsoft.com/blog/2014/07/28/azure-mobile-services-net-updates/
Comment: could u tell me what is resource id in this??
Comment: https://github.com/Azure/azure-content/blob/master/articles/resource-group-template-functions.md#resourceid
Comment: developer broker permissions were not for azure..i solved the problem :)
Comment: i have seen in your logcat  this W/BrokerProxy: DEVELOPER_BROKER_PERMISSIONS_MISSING:2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Broker related permissions are missing for GET_ACCOUNTS, MANAGE_ACCOUNTS, USE_CREDENTIALS ver:1.1.1
09-09 17:10:21.672 23883-24066/com.example.demoazure V/AuthenticationContext: 2016-09-09 11:40:21-7be16668-be3d-4554-8d94-f9968015fd22-Checking refresh tokens ver:1.1.1
Comment: so i guess may be its caused of your problem.
Comment: no the problem was with the permisions and the resource url
Comment: @NehaTyagi ohk. mam.
Answer: Looks like you try use AD from android and found similar problems to me;
see my coment here https://stackoverflow.com/a/43203464/1005462
should be helpfull as start point of proper configs, etc;

Azure Authentication error


How to redirect my website with the URL with www?

Question: Currently misitoweb.es works with https://misitoweb.es
It also works when I put misitoweb.es in the browser bar
However, when I use www.misitoweb.es it does not work. The browser says the following:
This page does not work.
The page www.misitioweb.es has redirected you too many times.
How can I make the www format. Also direct me to my website?
What should I do so that all formats redirect me to https://mysiteweb.es?
The URL I have in WordPress is https://mysiteweb.es I have tried adding a code fragment to the project's .htaccess file, but it doesn't work:
# Redirect to the version without "www"
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.mywebsite\.es [NC]
RewriteRule ^(.*)$ https://mysiteweb.es/$1 [L,R=301]

I have also tried some of the proposals offered on Stackoverflow, like the following, but for some reason Redirect web domain in with wordpress does not work
force redirect with https and with www
https://es.stackoverflow.com/questions/197912/redireccionar-dominio-web-en-con-wordpress
Answer: Depending on the type of redirection you want, you will need to exclude either the WWW or the non-WWW version to avoid ending up in a loop.
Here is an example that forces SSL and non-WWW. It also meets the conditions for HSTS preload.
The code must be inserted before the WordPress directives.
It's good practice to use R=302 for testing to avoid potential caching issues. So, after testing and if everything works as expected, change R=302 to R=301.
If you want to use it within a subfolder, e.g. myfolder, change:
RewriteBase / to RewriteBase /myfolder/
If you still get a loop error, check for other redirecting directives in your .htaccess file.
# FORCE SSL AND NON-WWW

RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,R=302,L]

EDIT: I've updated my answer regarding the OP's comment.
Basically, you have the option to choose between 2 variants of how your website should be addressed. The WWW variant or the non-WWW variant. However, you have to choose one as your canonical domain and stick with it. In the htaccess file, redirect the unselected variant to the selected one. That's also what my code above does, where https://mywebsite.es is your canonical URL:
http://mywebsite.es is redirected to https://mywebsite.es
http://www.mywebsite.es is redirected to https://mywebsite.es
https://www.mywebsite.es is redirected to https://mywebsite.es
http://www.mywebsite.es/something/ is redirected to https://mywebsite.es/something/
and so on ...
The opposite would be, as already mentioned, to choose the WWW version using https://www.mywebsite.es as canonical URL. To do this you would have to use the following (again, after testing change R=302 to R=301):
# FORCE SSL AND WWW

RewriteEngine On
RewriteBase /
# FORCE SSL
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
# FORCE WWW
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

http://mywebsite.es is redirected to https://www.mywebsite.es
http://www.mywebsite.es is redirected to https://www.mywebsite.es
https://mywebsite.es is redirected to https://www.mywebsite.es
and so on ...
You can read more about choosing between www and non-www URLs here:
https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Choosing_between_www_and_non-www_URLs
Another question the OP asked was:

I really don't know what the WordPress directives code snippet is
Answer:
Open your .htaccess file and search for the following line, this is where the WordPress rules start:
# BEGIN WordPress

Whereas the following line indicates the end of the WP directives:
# END WordPress

So everything between these two lines is WordPress related. The default code added by WordPress should look something like this (it looks a little different for multisite or non-english installations).
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

As mentioned, my rules from above must be inserted before these specific WordPress rules.
Comment: Thanks for your reply. I need that all types of `URLs` can be used and that they always redirect to SSL: with `www`, without `www`, with `https`, mywebsite.es, etc. I really don't know what the WordPress directives code snippet is, I don't know if it would be an error to show my `.htaccess` file, what do you think about it? Would it be a security problem for my website to show that file here?
Comment: Sorry for the bad or misleading explanation. I've updated my answer with some more details.


Storing class instance in new variable causes weird behavior (Arduino Serial)

Question: I was just trying to create a new variable to store the Serial object in that the Arduino provides by default.
Now here is what I don't understand:
Why is the output of this first code only 334
HardwareSerial SerialB = Serial;

void setup() {
  SerialB.begin(115200);
  SerialB.print(0x33, HEX);
  SerialB.print(0x44, HEX);
  SerialB.print(0x55, HEX);
}

void loop() {
  //do nothing
}

And the output of this second code is 334455
void setup() {
  Serial.begin(115200);
  Serial.print(0x33, HEX);
  Serial.print(0x44, HEX);
  Serial.print(0x55, HEX);
}

void loop() {
  //do nothing
}

Why does the first code stop while printing the second byte? What am I misunderstanding here? Shouldn't both codes result in the same output?
Comment: The [following thread](http://forum.arduino.cc/index.php?topic=68229.0) describes that it makes no sense to create a new instance of `HardwareSerial` (_"In any case, you should not be trying to CREATE a new instance of the HardwareSerial class"_). Are you perhaps looking to create a pointer to the existing `Serial` instance?
Answer: As dfri said, you were making another HardwareSerial instance, with disastrous results.
Just use a reference.  It's like a pointer, except the dot notation is used instead of having to use the arrow notation:
HardwareSerial & SerialB = Serial; // an alias, not a new instance

void setup() {
  SerialB.begin(115200);
  SerialB.print(0x33, HEX);

Note the ampersand.


Will a locksmith prefer to install a handle on a door that is hung or laying flat on horses?

Question: I have several hardwood doors that will need to have door handles and latches installed. Currently the doors are unhung and laying on saw horses (for sanding and painting).
Will the locksmith prefer to install the handles with the doors laying horizontal like this, or will he prefer that the doors be hung?
Answer: I would vastly prefer to do them hung.
As far as just attaching the hardware, that job is a cakewalk when the door is hung.  Doing it while the door is on sawhorses only creates a handling problem; the doorknob will be awkward.
If holes need to be drilled for the knob, latch and strike, then trying to do that separately using measurements would be insane. 95% chance you'd mount the carefully measured door, and by golly, they'd be misaligned.
Doing the work hung doesn't add enough difficulty to be worth the trouble it will cause for fitment.


Topological minor

Question: What is the method of proof to show that a graph has a certain topological minor? I am in a rigorous second discrete math class where we were given this question:
Prove or disprove: If G is bipartite and does not have K3,3 as
a topological minor, then G is planar.
My idea was to show that G does not have K5 as a topological minor, then invoke Kuratowski's Theorem. The problem was I could not 100% think of a way to show that G has the K5 topological minor since we never went over a way of proof in lecture. Any help would be great!
Comment: If a graph is bipartite, then it does not have an odd cycle. If a graph has a $K_5$ as topological minor, does this imply that this graph has an odd cycle?
Comment: We were given in class the idea of a TH which my professor defined this way: Given H, a TH is a copy of H where edges have been replaced by independent paths. Then he went on to say that G has H as a topological minor if G has a TH as a subgraph. So I was thinking we could have a TH of K5 that does not have an odd cycle. Is that wrong?
Answer: The idea to invoke Kuratowski after showing that $K_5$ is not a topological minor (TM) of $G$ would work, but there are bipartite graphs without $K_{3,3}$ as TM but with $K_5$ as TM.
Consider $K_5$ with once subdivided edges: bipartite and only having 5 branching vertices (that is of deg $\geq 3$) implies no $K_{3,3}$ as TM. And certainly not planar.
Comment: Thinking of [this debate](http://meta.math.stackexchange.com/questions/13374/abuse-of-site-with-homework-assignments), the question was more than a month old already. Hope it is still useful :-)

Topological minor


Collect the data returned by a group of post requests and post another single request

Question: I have a hash in jQuery. Its called dict.
To populate that hash, I call the createDict() function which will return something like below,
{"12|345" => "http://www.one.com",
"67|890" => "http://www.two.com"}
var dict = createDict();

Now for each elements of the hash I execute "grabData" method which is nothing but a post request,
    $.each(dict, function( key, value ) {

      data = key.split("|")[0];

      var a = "";

      //Calling the function that is a post request.
      grabData(data,"/url",function(returned) {

          alert(returned); //=> Positive

          a = returned;

      });

      alert(returned); // => negative

      alert(a); // => negative

    });

//Definition grabData
function grabData(input,url,callback){

    $.post(url,input,function(data){

          $("div#answer").html(data);

          callback(data);
     });

}

Questions:

For each elements in the dict hash, Im executing a group post
request and getting the returned value and updating the
"div#answer".
I want to collect the returned value in another array or hash and
    run another single post request whose input will be this array or
    hash.
Note:

The second single post request will update the database, so I
      dont want this to happen during the first group of post requests.
Comment: Your questions aren't actually questions. What have you tried so far and what problems are you having?
Comment: Thanks for your prompt response. You see the access to the variable "returned" is not available outside the grabData function. But I want to collect all the returned variables and do another post outside the $.each. How do I do it?
Comment: See answer below, hope that helps
Comment: I will try your solution and let you know. Please wait!
Answer: First find the total number of request you are going to fire(ie No of elements in dict). So that you can set a counter and keep on increasing for each request and on final request you can collect the data and make a single post request.
var total = dict.length;

Set a counter
var counter = 0;
var returnedData = [];

Then run your each loop
$.each(dict, function( key, value ) {
//your loop settings

...
   //Calling the function that is a post request.
      grabData(data,"/url",function(returned) {

          alert(returned); //=> Positive

          a = returned;
      returnedData .push(returned);
      counter++;
      if(counter == total ){
        //Collect the returned value, which will be in `returnedData` array.
        //make post request with collected data
      }
 });
});

Comment: alert(dict.length); returns "undefined"..why?..dict = {}.
Comment: I used this to get the length of a hash, var total = 0;

   for (var i in dict){

    total++;

   } ,otherwise, it properly worked your approach. Thanks man!
Answer: You will need to put the code which runs the POST inside your call back function, and check whether you have all the data you need each time the callback function runs. Something like:
function grabData(input,url,callback){
    var allDataSoFar = [];
    $.post(url,input,function(data){
        $("div#answer").html(data);
        allDataSoFar.push(data);
        if (haveGotAllDataYet(allDataSoFar){
             $.post(...)
        }
    });
}

Comment: More or less your approach is same as that of Ashwins but he was very clear about the "haveGotAllDataYet" you were talking about. He helped to use the length of the hash and figure out when to trigger the final post. But thanks for your contribution.


What type of water pipe and bushing is this called?

Question:
Anyone know what kind of pipe this would be to mount to wall for permanent water line? Also trying to find the rubber bushing where it mounts.
Comment: The pic you provided is great as an overview. A closer pic of the pipe and bracket in question may help get you answers instead of educated guesses.
Comment: looks like a pneumatic fitting
Comment: That elbow looks like same as what I have for my hydraulic hoses/pipes.  Is this picture from more of rural/farm area?
Comment: Looks like compression-fittings on stainless-steel tubing. Possibly Swagelok® possibly some other brand. Thus, not threaded pipe.
Answer: Since the pipe and bracket are not included with the hose reel, we can only speculate. It's a custom installation. My guess is the pipe is stainless steel. It could be aluminum but aluminum but aluminum isn't usually used for potable water supplies. The bracket would be a cushion bracket made of stainless steel for wall mounting.
Comment: @LawnMavrik  Probably having the exact part is not as important than having one that fits.  Drill two holes in a steel plate, wrap pipe in some rubber, and mount to a wall, will do the same job.  Looks like the person who did this, used some parts he had handy.
Comment: I did some more digging and the clamps appear to be maybe beta clamps used in hydraulic applications but I can't find the exact part. The pipe must be custom length threaded stainless


Regression and percentile

Question:
On a midterm exam, the average is $50$ points (out of $100$) with an SD of $10$ points.  On the final exam, the average was $100$ points (out of $200$) with an SD of 30 points.  The correlation between the two is 0.6.
What percent of the people who got a 40 on the midterm improved their percentile on the final?

The solution given in this case is 31% but it doesn't seem right to me .
I started the question by first standardize the score of 40 on midterm:
$\frac{40-50}{10}=-1$
Thus the same percentile of score on final would be $-1*30+100=70$
I then solve for the new average for the final score of the people who got 40 in the midterm, I get: $-1*0.6*30+100=82$
Finally I solve for the z score of the people who were 1 standard deviation below the new average and use normal approximation to get the percentage of people who improved on their final grade:
$\frac{70-82}{\sqrt{1-0.6^2}*30} = -0.5$
-0.5 corresponds to 30.85% under the curve, we are interested in people who improved in their final score therefore we get: 100%-30.85%=69.15%
Is my solution correct in this case??
Answer: I will solve this according to the least-squares regression line equation.
The linear relation between $2$ variables $x$ & $y$ is given by the equation for the regression line,$$ Y= \beta_o+\beta_1Χ+e.....(1)$$
Where $Y$ is the dependent variable
$Χ$ is the independent variabl
$\beta_o$ is the y-intercept.It is the value of Υ for Χ=0
$\beta_1$ is the slope of the line.It gives the amount of change in $Y$ for every unit change in $Χ$.
$e$ is the random error.
The predicted value of $Y$ for a given value of $Χ$ is denoted by $Y^{\prime}$
$$Y^{\prime}=a+bx.....(2)$$where $a= \beta_0^{\prime}=$ the estimated $y$-intercept of the regression line
and $b=\beta_1^{\prime}=$ the estimated slope of the regression line.
Regression line of $y$ on $x$ is $y-\overline{y}=byx(x-\overline{x}).....\overline{y}$ is the mean of $y,\overline{x}$ is the mean of $x.....(3)$
we consider $x$ is the midterm exam score
$y$ is the final exam score
Given midterm mean $=50=\overline{x},\overline{y}=100$
and the standard deviation for $x=10$ and $y=30$ $$byx=r\times\dfrac{\sigma}{\sigma x}=0.6\times\dfrac{30}{10}=1.8$$
Plug in these values in $(3)$, we get
$$y-50=1.8(x-50)$$
$$y=1.8x+10$$$\beta_0$ is the $y$-intercept $=10$
$\beta_1$ is the slope of the line $=1.8$
Now, plug these in $(1)$, we get
If $X=40$ then
$Y^{\prime}(40)=82$
Therefore, the predicted final exam score is $82$
Comment: should not the adjusted SD for $y$ be $30\cdot \frac{100}{200}=15$?
Comment: @farruhota I didn't get where you pointed the mistake, but thanks, I corrected few things where I took wrong mean and SD of final.
Comment: in that case, note $0.6\cdot \frac{30}{10}=1.8$ and $y=1.8x+10$, so $y(40)=82$ just like the OP found.
Comment: @farruhota Thanks, for correcting me.
Comment: you are welcome. Originally, when you used $\bar{x}=50, \bar{y}=50$, I thought you were converting to percentage mark (adjusting to 100), nevermind.
Comment: @KeyFlex I get the predicted final score part but what about the question "What percent of the people who got a 40 on the midterm improved their percentile on the final?" the solution I got is 69% whereas the solution shows 31 %
Comment: @KeyFlex thank you for confirming that
Comment: @pino231 $31$ % under the curve resembles the percentage of students who improved their score in the final
Comment: @KeyFlex why would it be 31% and not 69%? The average final score of people who got 40 on the midterm is 82 and if they had scored the same percentile as their midterm the final score would have been 70, then shouldn't it be 69% of them all improved?

Regression and percentile


Deploying a desktop application with SQL Server Express

Question: I have developed a C# 4.0 desktop application that uses a SQL Server Express 2005 database.  I have built a Setup and Deployment (msi) package that installs the application and all it's depenedencies, including the mdb database file, into a working folder under the Program Files directory.
The connection string is like this:
<code>Server=.\SQLExpress;AttachDbFilename=|DataDirectory|MyDB.mdf;Database=MyDB;integrated security=true;user instance=true;
</code>
The first time a database call is made, the database gets connected to the local SQL Server Express instance.
The installer works as expected on XP computers, however, when tested on Windows 7 machines an exception is thrown the first time a database call is made, which states that there are insufficient permissions on the folder containing the mdb file.
Between Windows XP and Windows 7, windows seems to have locked down permissions on Program Files subfolders.
I can solve the problem by setting full permissions to the installation directory, but that seems like cheating.
So my question is this:
How should I be configuring the setup and deployment package for this application?
Am I doing it right?  Do I just need to grant full permissions to all users on the applications directory? If so, how do I achieve this with a VS2010 setup and deployment package?
Or should I place the mdb file somehwere else?  Or am I totally going about things the wrong way?
Comment: check out: http://stackoverflow.com/questions/8322341/how-to-genenerate-database-backend-during-software-installation/8322599#8322599
Comment: Thanks for the suggestion, bryanmac.  I agree that would be a good solution in most cases.  In my case the database I'm deploying is preloaded with hundreds of thousands of records, so I'd rather deploy it prefabricated.
Answer: Here is the complete solution I ended up implementing.

In the Setup and Deployment project, in the File System section, I added the SQL Server database file (MDF) to the Common Application Data folder.  This is not one of the selectable options from the [Right Click]File System On Target Machine\Add Special Folder menu (for some reason), so I had to select Custom Folder from that menu then in the Default Location property, put "[CommonAppDataFolder][Manufacturer][ProductName]".  This made a folder in the Common Application Data Folder, wherever it may be on the target machine (C:\Program Data\ for Win 7) for my product.
I needed all users to be able to have full access to this folder for the SQL Server database file to successfully attach and work properly, so the next step was to change permissions on this folder.
The only way I could find to do that was to write a Custom Action for the Setup and Deployment project.  This link gives a good rundown of how to create and add a Custom Action: http://thedotnetway.blogspot.com.au/2008/10/creating-setup-project-in-vs-2008-w.html
This link provides the code that needs to be put into the Custom Actions overridden Install method:
C# - Set Directory Permissions for All Users in Windows 7
I used System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData) in the Custom Action code to specify the Common Application Data folder.

Hopefully that makes life easier for any developers in the future with similar requirements.
Answer: There are several options to remedy this situation.

If your application is only perform reading files from the program files. You would just need to run the setup package under Administrator right ( Right click on it , and then select Run as Administrator). Your Db will be written to the expected location.
If you need to perform IO operation (read/write) on files, then you need to put all your files to either Program Data folder
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

or the current user's data folder
<code>**Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)**
</code>
Cheers.
Comment: Thanks!  I have moved the location of the database to the Common Applications Data folder.  It works fine for Win7 users with Admin privileges, though each time the program is launched Windows pops up a User Account Control window asking if it's ok for the program to make changes to the computer.
When a non-admin user tries to launch it, a similar form pops up, but they need to provide an admin account password to run it.
Is there a way to have it so all users can run the application?
Comment: If you have moved all of your files to the Common application data folder, then you don't need to run your program under the Administrator's role anymore. In order to let non-admin users run your program, you have  to grant permissions to anyone who access the program data folder when installing the application. Since at that moment you would expect the administration rights to the software. The following link explains how to grant permissions to all users http://stackoverflow.com/questions/8944765/c-sharp-set-directory-permissions-for-all-users-in-windows-7  ( see the accepted answer)
Comment: OK, so I need to grant permissions to all users on the folder I created in the Common Applications Data folder so that any user will be able to run my program.  Do you happen to know if the Visual Studio (2010) Setup and Deployment Package project will allow me to easily set those permissions?  Or will I need to create a Custom Actions module that features the code you referred me to above?

Thank you for taking the time to help.
Comment: Unfortunately, you have to create a custom installer yourself in order to grant permissions to users.
Comment: Done.  Tested.  Works!  Cheers DrakeVN!


Example of compact whose open subspace is not locally compact

Question: I just read the fact that open subspace of compact Hausdorff space is locally compact.
I wanted to know that is this true or false if we relax Haudroff condition?
I followed following defination of locally compact space at a.
A is locally compact space at a if there is compact subspace of A which contain non-empty nbhd of a.If space is locally compact at every point then A is locally compact space
Please Help me to construct counterexample or proof
Any Help will be appreciated
Comment: What is your definition of locally compact? Several definitions are often given but they are equivalent for Hausdorff spaces.
Comment: @Will Dear Sir ,I had updated definition.Please have a look
Answer: Let us call a space $Z$ locally compact if for each $z \in Z$ and each open neighborhood $U$ of $z$ in $Z$ there exists a compact neighborhood $C$ of $z$ in $Z$ such that $C \subset U$. Call $Z$ weakly locally compact if each $z \in Z$ has a compact neighborhood.
It seems that you ask for "weakly locally compact".
For non-Hausdorff spaces the answer is no. Take any not weakly locally compact space $X$ (for example $X = \mathbb  Q$ with the subspace topology inherited from $\mathbb R$). Let $Y = X \cup \{*\}$ with a point $*$ not belonging to $X$. Define a topology on $Y$ as follows: $U \subset Y$ is open if either $U = Y$ or $U$ is an open subset of $X$. The verification that this is a topology on $Y$ is easy. Clearly $X$ is open in $Y$. Moreover, $Y$ is compact because each open cover of $Y$ must contain $Y$.


An Improper Integral

Question: I need help with this integral:
$\Large {\int_0^\infty \frac{dx}{x\sqrt{1+x}}} $
What I did: Substitute $\sqrt {1+x} = t$. Then the integral turns into $ \int_1^\infty 2dt/(t^2-1) $. Now I replaced $\infty$ by a variable $m$ and took the limit as $m \rightarrow \infty$.
However I don't get a proper answer.
Comment: $\Large {\int_0^\infty \frac{dx}{x\sqrt{1+x}}} $ is not converghent at lower bound.
Answer: The improper integral diverges. For if $x\le 1$ then $\frac{1}{x\sqrt{x+1}}\gt \frac{1}{2x}$. And it is easy to show that $\int_0^1 \frac{1}{2x}\,dx$ diverges.
Answer: Your work is correct as long as we consider the antiderivative $$\int\frac{dx}{x\sqrt{1+x}}=2\int\frac{dt}{t^2-1}=\int \Big(\frac{1}{t-1}-\frac{1}{t+1} \Big){dt}=\log \Big(\frac{1-t}{1+t}\Big)$$ Now, the problem starts with the integral because of the lower bound and not with the upper bound. What you could show is that, if $a \gt 0$, $${\int_a^\infty \frac{dx}{x\sqrt{1+x}}}=2 \sinh ^{-1}\left(\frac{1}{\sqrt{a}}\right)$$ For small positive values of $a$, a Taylor expansion is $$2 \sinh ^{-1}\left(\frac{1}{\sqrt{a}}\right) \simeq \log (4)-\log (a)+\frac{a}{2}-\frac{3 a^2}{16}$$

An Improper Integral


How to create global variables using Provider Package in Flutter?

Question: My Flutter app needs a global variable that is not displayed(so no UI changes) but it needs to run a function everytime it is changed. I've been looking through tutorials etc. but they all seem to be for much more complicated uses than what I need and I'd prefer to use the simplest approach that is still considered "good practice".
Roughly what I am trying to do:
//inside main.dart
int anInteger = 0;

int changeInteger (int i) = {
  anInteger = i;
  callThisFunction();
}

//inside another file
changeInteger(9);

Comment: Where is `callThisFunction()`? Is it in another widget or it's not related to a widget at all? Can you provide an example of what this function would be?
Comment: The call function would work anywhere, it is just playing a sound through the flutter audioplayer plugin
Comment: Ok then my answer would definitely work for you.
Comment: yep I just tried it and it works great thank you!
Answer: You can make a new Class in a new file to store the global variable and its related methods. Whenever you want to use this variable, you need to import this file. The global variable and its related methods need to be static. Pay attention to the callThisFunction that you mentioned in your question, it needs to be static as well (since it would be called in a static context). e.g.
file: globals.dart
class Globals {
  static var anInteger = 0;
  static printInteger() {
    print(anInteger);
  }
  static changeInteger(int a) {
    anInteger = a;
    printInteger(); // this can be replaced with any static method
  }
}

file: main.dart
import 'globals.dart';
...
FlatButton(
  onPressed: () {
     Globals.changeInteger(9);
  },
...


How to pass variable as input in pxssh

Question: I am using pxssh to connect with another host and read a file using python.I am able to successfully connect and pass simple commands.How to read a file using cat command where filepath is stored in a variable
<code>s = pxssh.pxssh()
s.login(hostname,username,pwd)
path = "mydir/mysubdir/a.txt"
s.sendline('cat ') # How to pass the path variable here
</code>
Also I want to read the file in line by line manner.Is there any way to do it using cat or any other command or how to do it using python commands.
Answer: you can create string and pass like s.sendline(variable)
<code>    cmd1 = 'cat '
    path = 'mydir/mysubdir/a.txt'
    cmd = cmd1 + path
    s.sendline(cmd)
    s.prompt()
    file = s.before
    print file.splitlines()[no of line]
</code>

How to pass variable as input in pxssh


Next.js - Broken listeners after static export

Question: I tried this approach:
    import React, { Component } from 'react'

    export default class AlertHey extends Component {

        constructor(props) {
            super(props)
            this.handleClick = this.handleClick.bind(this)
        }

        handleClick(){
            alert("hey")
        }

        render(){
            return(

                    Click me

            )
        }
    }

And this approach:
import React, { Component } from 'react'

    export default class AlertHey extends Component {

        render(){
            return(

 alert("Hey")}>
                    Click me

            )
        }
    }

And both don't work. In develpment mode (npm run dev) all works well, while when I export, all listeners seems broken. I don't get it. Maybe I lost any babel or webpack setting?
Answer: Does this work in production? I noticed you don't have a return () tags in your render method. You also have to bind this.handleClick to your instance rather than handleClick1.
Comment: Yes, it works. Missing return and handleclick1 are typos


How do connect a water supply to a 3/4-14 NPS faucet connector on my vintage tub?

Question: I just bought a new Kingston CC8T1 faucet for my vintage tub which has been a mess for years. I bought the faucet on Amazon and now realize that it's really unclear how to actually connect this thing.
Here are the docs that come with it:
https://media.kingstonbrass.com/pdf/technical/install/kingston-brass-CC8T1-install.pdf
https://media.kingstonbrass.com/pdf/technical/parts/kingston-brass-CC8T1-parts-diagram.pdf
https://media.kingstonbrass.com/pdf/technical/specs/kingston-brass-CC8T1-spec-sheet.pdf
So I have a 3/4-14 NPS pipe that I need to connect to my old water supply. I have new supply lines, but they don't match up. How do I connect a 3/8" COMP supply connector to a 3/4-14 NPS?
Comment: The 3/8" compression fitting attaches to your shutoff valves. But you need a different fitting than the 1/2" FIP to connect to your faucet. Take your faucet to a plumbing store and they'll fix you up.
Comment: A hardware store may also have a rack of random parts, including thread adapters, at the back of the plumbing section. Bringing in the piece(s) you are trying to adapt is definitely a good way to be sure you get the right thing. (Without doing so I would never have realized that one part was sized and tapped to match the compression fitting thread despite not being a compression fitting...)
Answer: It looks like you probably need a 3/4 inch compression fitting to attach to your tub faucet.  Not sure what diameter supply pipe you have upstream; to fill a tub, having 1/2 inch would be better than 3/8 inch. In any case, to have a flexible supply line connecting to your tub faucet, you might look at water heater flexible supply hoses, then replace your existing shutoff valves to match the size of those, or put in an adapter just downstream of your shutoffs.


Brouwer Fixed Point Theorem via the Jordan Curve Theorem

Question: There is a  proof of the Brouwer Fixed Point Theorem
via the Jordan Curve Theorem ?
The Brouwer Fixed Point Theorem. Let $B=\{x\in \mathbb R^2 :∥x∥≤1\}$  be the closed unit ball in $\mathbb R^2$  . Any continuous function $f:B\rightarrow B$  has a fixed point.
The Jordan curve theorem. The image of a
continuous injective mapping  $J:S^1\rightarrow \mathbb R^2$ divides the plane into exactly two components, one of which is unbounded and
the other bounded. Moreover, both of these components have the image of the
mapping $J$ as their boundary.
The Jordan Curve Theorem via the Brouwer Fixed Point Theorem
$\partial B=S^{1}$
Any hints would be appreciated.
Answer: You might enjoy David Gale's paper The Game of Hex and the Brouwer Fixed-Point Theorem, The Monthly, Dec 1979,  pp. 818-827.  He gives direct proofs in both directions between the Brouwer Theorem and the:
Hex Theorem: The game of Hex cannot end in a tie.
As Gale explains, the Hex Theorem is completely elementary (Gale gives an algorithm that takes in a completed Hex board and finds a win for one of the two players).  But the Hex Theorem  can be thought of as a sort of "finite" or "discrete" version of the Jordan theorem (the weak form, needed for Brouwer, only says that at least one player wins; the strong form, that both cannot win, is closer to Jordan), and the former does follow from the latter (Beck, Bleicher, and Crow, Excursion into Mathematics, 1969, pp. 327-339).  For further discussion relationing the Hex and Jordan Theorems, see the three or so paragraphs after "Hex Theorem" in op. cit., p. 820.
Comment: As a side-note: The Jan 2014 AMM has an article with the following abstract: "A short, inductive proof is presented of the fact that a Hex board cannot be colored such that winning conditions are satisfied for both players." Appropriately titled, the article has as its citation: Huneke, S. C. An Inductive Proof of Hex Uniqueness. *The American Mathematical Monthly, 121*(1), 78-80.