text:
Q: wide sense stationary process Let $y_n$ be a wide sense stationary process (wss), i.e., where the mean is independent of $n$ and the correlation depends solely upon $|n_1 - n_2|$.
Let us define:

$u_n = a_1 y_{n−1} + \ldots + a_p y_{n-p}$

with $a_k \in \mathbb{R}$ and $k = 1, \ldots p$.
Is $u_n$ also a wide sense stationary process?  Why or why not?

A: $u_n$ is also a wide stationary process. Let $\mu=\mathsf{E}[y_n]$ and $B(k)=\mathsf{cov}(y_{n+k},y_n)$. Then
\begin{gather}
\mathsf{E}[u_n]=\mathsf{E}\Bigl[\sum_{i=1}^pa_iy_{n-i}\Bigr]=\Bigl(\sum_{i=1}^pa_i\Bigr)\mu\quad\text {(it doesn't depend $n$)},\\
\mathsf{cov}(u_{n+k},u_n)=\mathsf{cov}\Bigl(\sum_{i=1}^pa_iy_{n+k-i},\sum_{j=1}^pa_j{y_{n-j}}\Bigr)=\sum_{i=1}^p\sum_{j=1}^pa_ia_jB(k-i+j)\\
\text {(it doesn't depend $n$ also)}.
\end{gather}
Therefore, $u_n$ is a wide stationary process.


text:
Q: Why does collection->where() return index number? I'm sure this may be a simple solution, but I can't seem to work it out.
I am trying to use Laravel's where() clause to build an array of $courses that belong to each $student. I cycle through each $student and filter the $courseRecords to find matching courses based on their StudentCode.
Here is my sample code snippet:
// Cycle through the students and add their relevant course details
foreach( $students as $student ) {

    // Find matching courses to the student
    $courses = $courseRecords->where( 'StudentId', $student->StudentCode );

    // Add the course array to the student record
    $student->Courses = $courses;

}

However, the result I get, gives me each student's course, but with a leading index number (as shown below in random results):

I can't seem to work out why this is happening. The first entry (Id 0) is the result I am expecting, but for some reason, every other result seems to give me the matching index number of $courseRecord.
I have tried using $courses->all(); and $courses->toArray(); but this doesn't make any difference.  From the Laravel documentation (that I have read), it doesn't mention this behaviour which makes me think I have something incorrect.
$students and $courseRecords are both a collection.

A: Use values():
$courses = $courseRecords->where('StudentId', $student->StudentCode)->values();

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to use for-loop as argument in function class Diff:
    def __init__(self, f, h):
      self.f = f
      self.h = h

class Backward1(Diff):
    def __call__(self, x):
      f = self.f
      h = self.h
      return (f(x)-f(x-h))/h

from math import sin, pi
A = Backward1(sin,1E-5)
print A(pi)

Want to calculate for several h-values, like [h=2**(-k) for k in range(10)]. Any tips for how to do this? Thanks!

A: You can't assign variable in list comprehensions but I don't think you need to:
print([Backward1(sin, 2**(-k))(pi) for k in range(10)])

Would construct a list of results for different hs.
Or a 2-step process so you can use different args for the same set of functions:
fns = [Backward1(sin, 2**(-k)) for k in range(10)]
print([fn(pi) for fn in fns])
print([fn(2*pi) for fn in fns])


text:
Q: css background issue when running the app on ipad phonegap I am trying to develop an application via phonegap and there is a very strange issue.
I have a bootstrap modal on click of an option or virtual keypad of Ipad. The background overlaps my modal as the modal opens up.
Any solution?
    if (navigator.platform == 'iPad') {
    $(".ipadissue").css("position", "absolute");
    $('.ipadissue').css('top', window.innerHeight + window.scrollY - 130 + "px");}
$(".modal").live("click", function() {
    if ($(this).attr('aria-hidden') == "false")
    {
        $("#content").css("position", "fixed");
    }
    else
    {
        $("#content").css("position", "absolute");
        $("#modal-content").css("position", "absolute");
    }
});

if (navigator.platform == 'iPad') {
$(function() {

    $(document).on('focusin', 'input, textarea', function() {
        $('#header').css("position", "absolute");
        $('.searchbardiv').css("position", "absolute");
    })
    $(document).on('click', 'input[type=file], a', function() {
        $('#header').css("position", "absolute");
        $('.searchbardiv').css("position", "absolute");

    })
    $("input[type=file]").on('change', function() {
        $('#header').css("position", "absolute");
        $('.searchbardiv').css("position", "absolute");
    })
            .on('focusout', 'input, textarea', function() {
        $('#header').css("position", "fixed");
        $('.searchbardiv').css("position", "fixed");
    });
});
}


text:
Q: EF Nested/Un-nested Context Handling and Solution For the project I'm working on, I wanted to have methods that can handle both the presence or lack of an existing context to the database. This is because whenever I try to create a NEW context within an existing one it breaks. The obvious solution is to have 2 methods, one that takes in a context and one that doesn't, and just have one call the other, like so
public void Foo(int x){
    using(BarContext context = new BarContext()){
        Foo(context, x);
    }
}
public void Foo(BarContext context, int x){
    // Do whatever needs to be done with the db
}

However, it seems like a massive waste to write two entire methods for every thing I need to do.
I thought of a more elegant solution that only requires 1 method and still allows an existing context to be passed in if it exists, but creates a new one if it doesn't, seen here
public void Foo(int x, BarContext context = new BarContext()){
    using(context){
        // Do Stuff
    }
}

My concern is that I don't fully understand why the original issue, of creating a context within a context, happens. I don't know if its the context causing the problem or the 'using'. So I'm not sure if calling a 'using', on an existing context, within another 'using' will cause the same problem, seen here
public void FooBar(int x){
    using(BarContext context = new BarContext(){
        Foo(x, context);
        /* Within the Foo Method, where the same context is "used" a second time
            using(context){
                //Do Stuff
            }
        */
    }
}

So, my question is: will that work? Is it safe to use an existing context a second time within the original using statement? Or will everything break as before?


text:
Q: Why did a bead of sweat/tear suffice for Quaid to recognize that this is reality? There is one thing about the two Total Recall movies which I have wondered about all the time.
In the original film a doctor came to Quaid to try to persuade him that he is not in reality but stuck in a memory. The doctor had nearly succeeded, but when Quaid saw a bead of sweat, he immediately knew that this is reality. In the remake it was the same setting, but his best friend and tear.
How could he be sure that this was reality only because of a bead of sweat or tear? As far as he knows, the implanted memories are super-realistic, and seeing someone sweat or cry should be no proof that this is reality. So is there maybe an explanation in the book or somewhere else (or I missed it in the movies) why he is sure that this is reality only because of a bead of sweat/tear?

A: I haven't seen the remake, but I think the idea in the original was that the doctor from Rekall (Dr. Edgemar) should have no reason to sweat (indicating fear) when a gun was pointed at his head, since the gun was just part of Quaid's fantasy, and Edgemar told Quaid he was really "monitoring you from the psychoprobe console" and that he had been "artificially implanted" in Quaid's fantasy "as an emergency measure".
So, the fact that he did sweat led Quaid to conclude he must be lying when he said being shot "won't make a difference to me". Of course, Quaid's logic is not necessarily sound, so we in the audience needn't take this as proof--even if Edgemar was projecting his words and overall appearance into the fantasy, it could be that Quaid's own mind was capable of filling in details about what he looked like, including the drop of sweat.
Director Paul Verhoeven pointed out this possibility in the commentary on the DVD and blu ray (he is addressing Schwarzenegger, so when he says things like 'you invented yourself' he presumably means something Schwarzenegger's character invented):

Verhoeven: you could argue that in his dream, because he wants to stay within his dream, he cannot get out of his dream anymore, the one
  they sent in to help him, basically, that you invented yourself this
  transpiration [perspiration?] on the head, isn't it? To convince
  yourself that you had to kill him.

A: In the Arnie film, the Doctor character states that he doesn't care and that it's basically all the same to him whether Quaid shoots him or not. This is an especially unsettling claim given all that's happened in the past couple of days and given that he literally has a gun in his face:

QUAID: All right.  Let's say you're telling the truth, and this is all a dream.. Then I can pull this trigger, and it won't matter.
Edgemar remains preternaturally calm.  His eyes and voice express his
  unselfish concern for Quaid.
EDGEMAR: It won't make the slightest difference to me, Doug, but the consequences to you would be devastating. Total Recall: 1990 Script - Abridged

When Quaid sees the bead of sweat, he suddenly realises "Hey, this guy really is sweating, he must actually be scared [and hence, this is reality]" so he shoots him.


text:
Q: PostgreSQL cannot connect to database I'm on Ubuntu and trying to connect to postgresql by any means, i.e. running psql throws:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

sudo /etc/init.d/postgresql restart fixes the problem, however, once I restart the computer, I always have to type the line into terminal all over again. Is there any way to fix this problem, so I don't have to type the line?

A: Do you kill the server before restarting the computer? If you're just restarting the computer, or if the battery dies while your server is running, you more than likely will run into this issue.


text:
Q: Execute on node a equivalent request tested on Postman I'm having trouble to make a request on node that was tested and worked on Postman. Everything I tried return me a 302 status code.
This is the request I want to do, it works just fine executing on postman:

This is one of my attempts:
function ListaCidades(estado) {
    return new Promise((resolve, reject) => {

        request({
            url: "http://www1.caixa.gov.br/Simov/carregaListaCidades.asp",
            method: "POST",
            body:     "cmb_estado=MG&cmb_cidade=&cmb_tp_venda=0&cmb_tp_imovel=Selecione&cmb_area_util=Selecione&cmb_faixa_vlr=Selecione&cmb_quartos=Selecione&cmb_vg_garagem=Selecione"
        }, function callback(error, resp, body) {
            if (error)
            {
                reject(error);
                process.exit(1);
            }

            resolve(resp.statusCode);
        })
    });
}

I'm getting HTTP 302 as status code and a empty body.
What is wrong?

A: Taking the 302 error at face value, that means there is a (temporary) re-direct on the URL. The following stackoverflow topics discuss how to process this situation:
How do you follow an HTTP Redirect in Node.js?
Follow redirect with node.js request
As far as Postman is concerned, it will automatically follow a re-direct. Even though there is an option to stop it, it doesn't seem to work on the desktop version!

The re-direct processing can be seen below in the browser console. So you code needs to handle this situation.


text:
Q: jquery load external files with http in url parameter i've tried jquery .load() function. It is ok when i load files from my server, but i don't know how to load another file from www.
This is my code:
jQuery("#blog").load("/index.html");
jQuery("#blog").load("http://crocoweb.sk/");

The first one is working, the second not.
On documentations I can't find how to use http as url parameter here. Please help!

A: AJAX is subjected to the same origin policy as a security feature of the browser. So unfortunately the second option will not work by design.
Another option is to do the include on the server.

A: You can't load a page coming from another source (domain) via ajax, unless using methods like JSONP. You can check out the ajax jQuery documentation for more information on JSONP.

A: You can add a proxy between your application and the third party domain. This cross domain querying solution works because you're actually loading the content from your own domain.


text:
Q: How to identify is a blog post has been selected or not? I am working with a Tumblr blog template in which I need to differentiate between blog articles/posts in their collapsed and expanded state. Specifically, I am trying to apply a CSS property (for border) which must only apply to the blog posts when they are being shown in the grid in the collapsed state and must not apply when the visitor selects the blog to read it further.
This is the change I have made to the template:
    div.posts-holder article:hover
    {
        border: 1px #BDBDBD solid;
        box-shadow: 7px 7px 3px #D8D8D8;
    }

Also, this is how the div.posts-holder looks like (not the complete code, only a snippet to give an idea)

        {block:IndexPage}

{/block:IndexPage}

        {block:Posts}

Here's a link to a dummy blog I created to illustrate the problem:
Example Blog Link
Observe that on hover, each blog post gets a shadowed border. I don't need this once I am actually reading one of these posts.
How can I do this using JavaScript or any other technique? Is there a way I can look for the state of the post?

A: From looking at your example page, the posts-holder div also has a posts-grid class on the grid page, but it doesn't on the pages that only show one article. So you just have to change your CSS hover rule from
div.posts-holder article:hover

to
div.posts-holder.posts-grid article:hover

That way it will only be applied to the articles when they're in a grid.

A: here is a answer of the main heading of the question:

How to identify is a blog post has been selected or not?

this can be achieve by making an object... just look at this code:
HTML

Javascript
   var click= {};
    var selected = function(a){

          click[a] = "selected";
}

so when ever you want to know that if this div is selected then just check that in click object, is a property named article1 is present or not if true then do stuff else then dont


text:
Q: Rails: Get remote page via ajax I use Rails3 and I try to get remote page via ajax. (https://play.google.com/store/apps/details?id=).
$.ajax({
      url: app_url,
      type: 'GET',
      data: "id=<id>",
      crossDomain : true,
      dataType: 'jsonp',
      success: function ( code ) {
        alert("Good.");
      }
    });

When I run the script, the I see: "Uncaught SyntaxError: Unexpected token < " error message.
By the way, I tried do it as:
$.ajax({
      url: app_url,
      type: 'GET',
      data: "id=<id>",
      crossDomain : true,
      dataType: 'jsonp',
      success: function ( code ) {
        alert("Good.");
      }
    });

But I see "Origin http://example.com:3000 is not allowed by Access-Control-Allow-Origin." error message.
How can I fix the error and get the page ?
Thanks.

A: If you are trying to access remote pages via AJAX, that page may be blocking your request. The error message would suggest this: https://developer.mozilla.org/en-US/docs/HTTP_access_control
EDIT
For clarity, Access-Control-Allow-Origin is the server setting which "origins" are allowed to retrieve from it. You could possibly grab this page server-side, and depending on google's level of security, you may have to spoof a browser. PHP CURL comes to mind. You would then set up an ajax call to your server script, your server would go get the page for you, then return it to you ajax call.


text:
Q: Inserting the resolution of identity correctly In a text on path integrals, I find the following:
\begin{equation}
 \langle q_{j+1}|e^{-i(\hat{p}/2m)\delta t}|q_j\rangle = \int\frac{dp}{2\pi}\langle q_{j+1}|e^{-i(\hat{p}/2m)\delta t}|p\rangle\langle p|q_j\rangle\ .\tag{1}
\end{equation}
Shouldn't it be rather:
\begin{equation}
\langle q_{j+1}|e^{-i(\hat{p}/2m)\delta t}|q_j\rangle = \langle q_{j+1}|e^{-i(\hat{p}/2m)\delta t}\int\frac{dp}{2\pi}|p\rangle\langle p|q_j\rangle\ ?\tag{2}
\end{equation}
I would have inserted the resolution of identity as in (2), but then I wouldn't have dared to move the integral past the $e^{-i(\hat{p}/2m)\delta t}$ operator, because in (1), $e^{-i(\hat{p}/2m)\delta t}|p\rangle$ is a function of $p$, namely: $e^{-i(\hat{p}/2m)\delta t}|p\rangle=e^{-ip/2m\delta t}|p\rangle$ (no hat anymore). I am not sure about the interplay of that function of $p$ and the integral. Can someone shed some light on this?

A: Comments to the question (v1):

*

*The operator $f(\hat{p})$ and the identity operator ${\bf 1}= \int\!\frac{dp}{2\pi}|p\rangle\langle p|$ commute.

*The operator $f(\hat{p})$ and the integration $\int\!\frac{dp}{2\pi}$ are independent of each other.

*The $q$-ket and the $q$-bra are independent of the integration $\int\!\frac{dp}{2\pi}$.

*Of course, if one replaces $f(\hat{p})|p\rangle$ with $f(p)|p\rangle$, it does not make sense to move the function $f(p)$ [and, for that matter, the $p$-ket and the $p$-bra] outside of the $p$-integral.


text:
Q: SoundCloud created_at[from] query resolving in a 503 error Using the JavaScript SDK, I am trying to search for all tracks in a given genre from a given date going forward (using the 'created_at[from]' /tracks filter).
My JavaScript for this is:
SC.get('/tracks', { genres: 'metal', created_at: {from: '2014-02-26 00:00:01'} }, function(tracks) {
  console.log(tracks);
});

The request URL resolves as:
http://api.soundcloud.com/tracks?genres=metal&created_at[from]=2014-02-26%2000%3A00%3A01&client_id=MY_ID

and I get a 503. (I omitted posting my client_id here intentionally)
What am I doing wrong here?

A: Looks like they changed the filter or its a bug or they are working on it:
When i call:
http://api.soundcloud.com/tracks?limit=1&genres=metal&client_id=b45b1aa10f1ac2941910a7f0d10f8e28&created_at=2010-10-10

I am getting:
invalid filter.created_at=2010-10-10;
valid values are: last_year, last_two_weeks, last_week, last_day, last_hour

Then, when i call for last hour:
http://api.soundcloud.com/tracks?limit=1&genres=metal&client_id=b45b1aa10f1ac2941910a7f0d10f8e28&created_at=last_hour

I am getting a: 503 - Service Unavailable
When i change it to last_year, it works as expected,
and i get following xml (or json):
<tracks next-href="http://api.soundcloud.com/tracks?client_id=b45b1aa10f1ac2941910a7f0d10f8e28&created_at=last_year&genres=metal&limit=1&offset=1" type="array">
<track>
<kind>track</kind>
<id type="integer">103909859</id>
<created-at type="datetime">2013-08-04T01:30:44Z</created-at>
<user-id type="integer">29394873</user-id>
<duration type="integer">248917</duration>
<commentable type="boolean">true</commentable>
<state>finished</state>
<original-content-size type="integer">4696472</original-content-size>
<sharing>public</sharing>
<tag-list>
exotoxis metal femalevocals rock shredding army god double bass
</tag-list>
<permalink>army-of-god</permalink>
<streamable type="boolean">true</streamable>
<embeddable-by>all</embeddable-by>
<downloadable type="boolean">false</downloadable>
<purchase-url nil="true"/>
<label-id nil="true"/>
<purchase-title nil="true"/>
<genre>Metal</genre>
<title>Army Of God</title>
<description>
For more Information plea

EDIT:
I'd say you are right and SC Team should give an answer on that.


text:
Q: vb.net dispose of DB Connection after saving record I have a front end view of a backend Access DB.  I have a Save and an Update button.  Whenever i use the below Save Code, it works and adds the record to my database and displays it correctly in datagridview, if i hit the update button on that newly created record it seems like the record is still in "EDIT" mode in access thus giving me a concurrency error when i try to make an update to the record.  Do i have to dispose of the connection after i save below, if so can you show me how to dispose of that connection or close the record in the access db?  The only fix that has this working is to add application.restart() to the end of my save button, WHICH i really do not want to do.
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If tbAEU.Text = "" Or cbIA.Text = "" Or cbCI.Text = "" Or tbS.Text = "" Or tbD.Text = "" Then
            MessageBox.Show("Please do not leave any field blank", "Validation")
            Return
        End If
        cbAdded.Text = "No"
        If intInc <> -1 Then

            Dim cb As New OleDb.OleDbCommandBuilder(da)
            Dim dsNewRow As DataRow

            dsNewRow = ds.Tables("SDMDB").NewRow()

            dsNewRow.Item("AffectedEndUser") = tbAEU.Text
            dsNewRow.Item("IncidentArea") = cbIA.Text
            dsNewRow.Item("ConfigItem") = cbCI.Text
            dsNewRow.Item("Summary") = tbS.Text
            dsNewRow.Item("Description") = tbD.Text
            dsNewRow.Item("ActivityLog") = tbAL.Text
            dsNewRow.Item("AddedtoSDM") = cbAdded.Text

            ds.Tables("SDMDB").Rows.Add(dsNewRow)

            da.Update(ds, "SDMDB")

            MessageBox.Show("New Record added to the Database", "Save")

            btnSave.Enabled = False
            btnAdd.Enabled = True
            btnDelete.Enabled = False
            btnPWReset.Enabled = True
            btnUnlock.Enabled = True
            btnEdit.Enabled = True
            btnCancel.Enabled = False
            cbIA.Enabled = False
            cbCI.Enabled = False
            SetAllAsReadOnly()
            UpdateDatabase()
            Me.Refresh()
            moveforward()
            movebackward()
        End If
    End Sub

Connection Code:
strDbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
            Dim sDrive As String, sDrives() As String
            sDrives = ListAllDrives()
            For Each sDrive In sDrives
                Dim strTemp As String = sDrive & "\AppData\SDMDB\SDMDB.mdb"
                If File.Exists(strTemp) Then
                    strDbSource = "Data Source = " & strTemp
                End If
            Next
            con.ConnectionString = strDbProvider & strDbSource

            con.Open()

            strSQL = "SELECT * FROM SDM_Details"
            da = New OleDb.OleDbDataAdapter(strSQL, con)
            da.Fill(ds, "SDMDB")

            con.Close()

A: As Mr Codexer said, you would want to use a Using statement to dispose of your connection.
What I expect you actually want from your is to call ds.AcceptChanges() after a successful save. This lets the DataSet and the corresponding tables know that the records are no longer dirty.


text:
Q: using entity framework in classlibrary I am having problem in referencing entity framework 6 in my class library project. The project is registred for com interop. I have post build event like

SET GACUTIL="C:\Program Files (x86)\Microsoft
  SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe" SET
  REGASM="C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe"
%REGASM% /u  $(TargetFileName) /tlb:ClassLibrary1.tlb %GACUTIL% /u
  $(TargetFileName)
%REGASM% $(TargetFileName) /tlb:ClassLibrary1.tlb %GACUTIL% /i
  $(TargetFileName)
%REGASM% $(TargetFileName) /tlb:ClassLibrary1.tlb %GACUTIL% /i
  $(TargetFileName)

whenever I build I get error:
Cannot register assembly: "myassembly" Could not load file or assembly 'Entity Framework , Version 6.0.0.0

A: It looks like you didn't add entity framework assembly to your class library. Use the nuget console to install it:
PM> Install-Package EntityFramework -Version 6.0.0
https://www.nuget.org/packages/EntityFramework/6.0.0


text:
Q: REST API with SSIS (zappy) SmartFocus I've been tasked with learning how to use a REST API to send data via an automated process. My background is TSQL, SSRS and SSIS so this is a completely new avenue.
I'm looking at using the Zappy Add in and should be able to get a purchase signed off if I can get it functioning. However as this is a new avenue to me I am struggling to get it working.
I need to upload data via the API from a SQL select. I can create files in the required JSON or XML but interacting with the API is drawing a blank
The API is from SmartFocus - Smart focus API Guide
Does anyone here have experience with any of the above and can assist, or point me in the direction of good learning material. I'm keen to learn a solution and improve my skills.
I'm aware this is vague and hope it doesn't get down voted too much. I'm just trying to get some help!


text:
Q: ActiveMQ clean up old queues that seems to just hang around? So I have a jboss AMQ 6.3 cluster (3 pods in OpenShift) that keeps growing daily.
Looking in the Java Console, there are a Lot of Queues named clever things like
error-user006107e3-85ce-bdf1-f414-34fc448c1eb4

which I'm assuming is the reason KahaDB keeps growing in size (currently 120mb each split, up from 100 last week...)
Is there a way to clean these likely dead queues to stop us from running out of memory every 2 weeks?
Edit: Not so sure the error-user is the villain here.. But it does keep growing..
Edit2: Here's the activemq.xml
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
           http://activemq.apache.org/schema/core
           http://activemq.apache.org/schema/core/activemq-core.xsd">
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>file:${activemq.conf}/credentials.properties</value>
        </property>
    </bean>
    <bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"
          lazy-init="false" scope="singleton"
          init-method="start" destroy-method="stop">
    </bean>
    <broker xmlns="http://activemq.apache.org/schema/core"    brokerName="${HOSTNAME}" dataDirectory="${activemq.data}" schedulePeriodForDestinationPurge="10000">
        <destinationPolicy>
            <policyMap>
                <policyEntries>
                    <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb" maxBrowsePageSize="700" gcInactiveDestinations="true" inactiveTimoutBeforeGC="30000">

                        <networkBridgeFilterFactory>
                            <conditionalNetworkBridgeFilterFactory replayWhenNoConsumers="true" replayDelay="500" />
                        </networkBridgeFilterFactory>
                    </policyEntry>
                    <policyEntry topic=">" producerFlowControl="true" gcInactiveDestinations="true" inactiveTimoutBeforeGC="30000">
                        <pendingMessageLimitStrategy>
                            <constantPendingMessageLimitStrategy limit="1000" />
                        </pendingMessageLimitStrategy>
                    </policyEntry>
                </policyEntries>
            </policyMap>
        </destinationPolicy>
        <managementContext>
            <managementContext createConnector="false" />
        </managementContext>

        <ioExceptionHandler>
            <defaultIOExceptionHandler ignoreNoSpaceErrors="false"/>
        </ioExceptionHandler>

        <networkConnectors>
            <networkConnector userName="userName" password="password" uri="dns://amq-cluster:61616/?transportType=tcp&queryInterval=30" messageTTL="-1" consumerTTL="1" />
        </networkConnectors>
        <persistenceAdapter>
            <kahaDB directory="${activemq.data}/kahadb" />
        </persistenceAdapter>

        <plugins>
            <jaasAuthenticationPlugin configuration="activemq" />
        </plugins>
        <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage percentOfJvmHeap="70" />
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="100 gb" />
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="50 gb" />
                </tempUsage>
            </systemUsage>
        </systemUsage>
        <transportConnectors>
            <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600&transport.hbGracePeriodMultiplier=2.5" />
            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600" />
        </transportConnectors>
        <shutdownHooks>
            <bean xmlns="http://www.springframework.org/schema/beans"    class="org.apache.activemq.hooks.SpringContextHook" />
        </shutdownHooks>
    </broker>
    <!-- Do not expose the console or other webapps
    <import resource="jetty.xml" />
    -->
</beans>


text:
Q: WebGL2 - Can I query a shadowmap cubemap with non world position? I'm trying to implement shadow maps for point lights using Webgl2. To do so, I use a cubemap of depth buffers to which I render 6 axis aligned views from the light position.
In the fragment shader I use to render lighting, I query this cubemap using these lines:
vec3 lightToPos = lightPos-fragPos;
float closestDepth = texture(shadowMap, lightToPos).r;

Note that lightPos and fragPos are in 'view' referential, that is: viewMat * worldMat * objPos. In the tutorial I'm following this is supposed to be in World Position (http://ogldev.atspace.co.uk/www/tutorial43/tutorial43.html). Now, I don't see a reason why my way of doing it wouldn't work because the difference of two positions should be the same regardless of the point of view their coordinates are expressed in, right? The results I'm getting are not what I'm expecting, everything is in the shadow. I have probably made a mistake elsewhere but I would like to be sure I understood how that works and that the mistake is not from here.

A:
the difference of two positions should be the same regardless of the point of view their coordinates are expressed in, right?

No, they're not.
Consider a world where the light is straight above the origin of the world, and "above" means in the +Y direction. So that's the direction the shadow map was generated from. And it was generated from world-space.
Now, consider the camera at the origin of the world. It's looking down the -Z axis, with +Y in pointing straight up. In this case, there is no orientation difference between camera space and world space. Therefore, in both cases, the light direction is (0, 1, 0).
But what happens if you rotate the camera 90 degrees around its viewing axis? Well, the camera is lying on its side, relative to the world. That means the light direction is either (1, 0, 0) or (-1, 0, 0), depending on which way you rotated. And that direction is different from the world space direction, which is still (0, 1, 0).
Yes, the light did not move, relative to the world. But the camera did. Therefore, the value of the camera-space light direction is different from what its value would be for the world-space light direction.
If both the light position and the fragment position truly are in camera space, then subtracting them will give the direction to the light in camera space. If the shadow map was indeed built in world space, this direction will be utterly useless.


text:
Q: want different maven project structure Trying to understand maven flow.Need to create a folder called 'my-source' and copy multiple files in the same folder.
And  i want a maven build zip file which should contain 'my-source' folder and its contents.How do i do that?Where ever articles i refer  am seeing only java project/folder structure examples.
Also i have seen sourcedirectory/outputdirectory. Not sure where i can modify these values as i couldnot find location of effectivepom
So please give me the process to fulfil my requirement

A: In order to create a zip file with all your contents you will have to use the maven assembly plugin in your pom.xml. Apart from this, you will need one more file (say bin.xml) that will tell which all files you want to be packaged in the zip. The assembly plugin in the pom.xml will simply point to the bin.xml file.
See a sample code for pom.xml below.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.abc</groupId>
    <artifactId>xyz</artifactId>
    <version>3.1.3</version>

    <build>
        <plugins>
            <plugin> <!-- Create a zip file with the contents you want deployed -->
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.5</version>
                <configuration>
                    <descriptors>
                        <descriptor>src/assembly/bin.xml</descriptor>    // very important. This is where we will tell where our bin.xml is located
                    </descriptors>
                    <appendAssemblyId>false</appendAssemblyId>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>

Now create a folder structure like src/assembly and add a file with the name bin.xml.  See below for a sample code that should go inside bin.xml.
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    <id>distrib</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${project.basedir}/my-source</directory>    // the folder that you want to the packaged in the zip file
            <outputDirectory>/</outputDirectory>    // the location within the zip file where your folder should be copied. In this case it will place the my-source directory at the root level of the zip file.
            <useDefaultExcludes>true</useDefaultExcludes>
        </fileSet>
    </fileSets>
</assembly>


text:
Q: MySQL: How to select a column by number? I'm writing a program, and I have the need to SELECT column names by number, rather than by name.
That is, say the attributes to my table are:
SSN, FirstName, LastName, MiddleName, Address, City, State, Zip

How could I select the data just from columns 0 (SSN), 1 (FirstName), 2(LastName), 6 (State)
Is there a way to do this without delving into information schema?

A: You should reconsider your design. A table can be changed, it can evolve, column order is very fickle. You should NOT hardcode column numbers.

ADDENDUM
By "evolve" and "fickle", I don't mean that the database engine can move them around. That's pretty much fix. No, I mean that needs can change in the future and the table design can be updated. It will be easier in the future to adapt your old code if you list the actual column names rather than the column position order. Think of column position just like row position: don't expect a particular order in the result based on input order, but rather make your query give you the order you need.

A: Ok, so don't do this, but, if you really need to do this you can use COLUMNS.ORDINAL_POSITION in the information schema.

A: SELECT `0`,`1`,`2`,`6` FROM `table` ORDER BY `ssn`


text:
Q: Position: Absolute Causes Element To Disappear in Webpage position: absolute is Causing Element To Disappear
I am writing a navbar for my webpage and I wanted to center the ul element nested inside a nav element, so I used a technique written by Smash Magazine to center it (vertically, not horizontally). The result is that the background for the nav completely disappears, but when I hover over the li elements, their respective backgrounds appear. How do I fix this?
HTML:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>repl.it</title>
    <link href="https://fonts.googleapis.com/css?family=Open+Sans|Raleway" rel="stylesheet">
    <link href="index.css" rel="stylesheet" type="text/css" />

Support Us

Download

GitHub

Scriptura

Customizable note taking software

What Is Scriptura

Scriptura is a note-taking software that is meant to be super cuztomizable to fit the users needs. Most of the time, you are either spending money on either a paid software that takes you way over the top for stuff you don't need, and other times you are stuck with a limited-memory budget version of note-taking software. With Scriptura, you can add and remove features as you need them, and have unlimited cloud storage data with syncing across 5 devices!

CSS:
body {
  margin: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: Open Sans, sans-serif;
}

p {
  font-family: Raleway, sans-serif;
}

li {
  font-family: Raleway, sans-serif;
}

a {
  font-family: Raleway, sans-serif;
  text-decoration: none;
  color: black;
}

nav {
  background: whitesmoke;
  position: relative;
  height: 100%;
}

nav ul {
  position: absolute;
  margin: auto;
  top: 0; left: 0; bottom: 0; right: 0;
  list-style-type: none;
  text-align: right;
  margin-right: 30px;
}

nav li {
  display: inline;
  padding: 10px;
  transition: background-color 0.4s ease-in-out 0s;
}

nav li:hover {
  background-color: lightgrey;
}

A: Please check the fiddle,
Issue is that you've set 100% height for nav, browser can't understand 100% of what element. You can set 50px for example for menu,
and align "li" by line-height or just height.
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>repl.it</title>
    <link href="https://fonts.googleapis.com/css?family=Open+Sans|Raleway" rel="stylesheet">
    <link href="index.css" rel="stylesheet" type="text/css" />

Support Us

Download

GitHub

Scriptura

Customizable note taking software

What Is Scriptura

Scriptura is a note-taking software that is meant to be super cuztomizable to fit the users needs. Most of the time, you are either spending money on either a paid software that takes you way over the top for stuff you don't need, and other times you are stuck with a limited-memory budget version of note-taking software. With Scriptura, you can add and remove features as you need them, and have unlimited cloud storage data with syncing across 5 devices!

body {
  margin: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: Open Sans, sans-serif;
}

p {
  font-family: Raleway, sans-serif;
}

li {
  font-family: Raleway, sans-serif;
}

a {
  font-family: Raleway, sans-serif;
  text-decoration: none;
  color: black;
}

nav {
  background: whitesmoke;
  position: relative;
  height: 50px;
}

nav ul {
  position: absolute;
  margin: auto;
  top: 0; left: 0; bottom: 0; right: 0;
  list-style-type: none;
  text-align: right;
  margin-right: 30px;
}

nav li {
  display: inline;
  padding: 10px;
  transition: background-color 0.4s ease-in-out 0s;
  line-height: 50px;
}

nav li:hover {
  background-color: lightgrey;
}

http://jsfiddle.net/7gokv9py/5/


text:
Q: Overloading operator: Matrix Addition enter image description here
I'm trying to set up my functions and perform some overloading operations so that I can +,-,==,* two matrices. I have encountered a problem at the first operation overload: addition.
My program works until i try to add 2 matrices.
Thanks for help.
include<iostream>
using namespace std;

class matrixType
{
private:
    int rows,cols;
    int** matrix;
public:

    matrixType( int r, int c)
    {
        rows=r;
        cols=c;
        matrix = new int*[rows];
        for(int i = 0; i < rows; ++i)
            matrix[i] = new int[cols];
    }

    ~matrixType()
    {
        for(int i = 0; i < rows; ++i)
        {
            delete [] matrix[i];
        }
        delete [] matrix;
    }

    matrixType operator+( matrixType m2 )
    {
        if( rows==m2.rows && cols==m2.cols)
        {
            matrixType m3(rows, cols);
            for( int i=0; i<rows; i++)
            {
                for( int j=0; j<cols; j++)
                {
                    m3.matrix[i][j]=matrix[i][j]+m2.matrix[i][j];
                }
            }
            return m3;
        }
    }

    matrixType operator-(matrixType m2)
    {
        if( rows==m2.rows && cols==m2.cols)
        {
            matrixType m3(rows, cols);
            for( int i=0; i<rows; i++)
            {
                for( int j=0; j<cols; j++)
                {
                    m3.matrix[i][j]=matrix[i][j]-m2.matrix[i][j];
                }
            }
            return m3;
        }
    }

    friend istream& operator>> (istream& stream, matrixType m)
    {
        for ( int i=0; i<m.rows;i++)
        {
            for( int j=0; j<m.cols;j++)
            {
                cout<<"Matrix"<<"["<<i<<"]"<<"["<<j<<"]"<<"=";
                stream>>m.matrix[i][j];
                cout<<endl;
            }
        }
        return stream;
    }

    friend ostream& operator<<(ostream& out, matrixType m)
    {
        for ( int i=0; i<m.rows;i++)
        {
            for( int j=0; j<m.cols;j++)
            {
                cout<<"Matrix"<<"["<<i<<"]"<<"["<<j<<"]"<<"=";
                out<<m.matrix[i][j];
                cout<<endl;
            }
        }
        return out;
    }
};

A: Totally different approach as alternative - based on templates:
template <size_t Rows, size_t Columns>
class Matrix
{
    int matrix[Rows][Columns];

public:
    void operator+=(Matrix<Rows, Columns> const& other)
    {
        for(size_t i = 0; i < Rows; ++i)
        {
            for(size_t j = 0; j < Columns; ++j)
            {
                matrix[i][j] += other.matrix[i][j];
            }
        }
    }

    Matrix<Rows, Columns>
    operator+(Matrix<Rows, Columns> const& other) const
    {
        Matrix<Rows, Columns> result(*this);
        result += other;
        return result;
    }

    template<size_t C>
    Matrix<Rows, C> operator*(Matrix<Columns, C> const& other) const
    {
        // just exemplary, actual implementation missing:
        return Matrix<Rows, C>();
    }

    // rest of operators coming here
};

It might or might not fit your needs, but if it does, you get the rule of three for free. Additionally you are prevented automatically from adding or multiplying matrices of non-fitting sizes.
On the other hand -- well, benefits always come with some cost, too... -- you lose flexibility. Imagine you want to place arbitrary matrices into a vector - you'd need a base class then and would have to use (smart?) pointers, adding or multiplying arbitrary matrices requires casts, ...
Biggest drawback, though, is that you need to know your matrix sizes at compile time - if you don't, we are out.
By the way, adding/multiplying - in your original implementation, you do not return anything if matrix sizes do not match! You should return some kind of sentinel then, e. g. a 0x0 matrix - or possibly even better: throw some appropriate exception.

A: This sound like a case of rule of three violation.
You need to implement a copy constructor:
matrixType(const matrixType&)

And a copy assignment operator:
matrixType operator=(const matrixType&)

And for C++11 it might be a good idea to also implement the move constructor and move assignment operator.
matrixType(matrixType&&)
matrixType& operator=(matrixType&& other)


text:
Q: cant parse json from php I have a JSON like this:
{
  "avatar": [
    {
      "Trophies": 1022,
      "clanLevel": 1,
      "Attack K Factor": -1921682810,
      "Attacks Won": 1,
      "freeGems": -1916837036,
      "clanBadge": 0,
      "clanCaslteLevel": 5,
      "currentHomeId": 12888426248,
      "clanRole": 2,
      "exp": 5013,
      "homeId": 12888426248,
      "Attacks Lost": -1307141699,
      "clanId": 326417604098,
      "boughtGems": -1517098100,
      "userNameChange": false,
      "numOfNameChanges": 0,
      "level": 111,
      "league": 5,
      "userName": "King Shiv",
      "nameTag": 1440968203000,
      "clanName": "lol",
      "Defenses Won": 17,
      "maxCcTroops": 30,
      "gems": -1370568149,
      "Defenses Lost": -2055915376,
      "townHall": 9,
      "inWar": 1,
      "Attack Rating": -1000115629
    }
  ]
}

And I am trying to parse it like this:
$url = "http://185.112.249.77:9999/Api/Player?player=1;
$url = preg_replace("/ /", "%20", $url);
$jsondata = file_get_contents($url);
$data = json_decode($jsondata, true);
echo "IGN: ".$data['avatar']['userName'];
echo "
Town Hall: ".$data['avatar']['townHallLevel'];
echo "
Level: ".$data['avatar']['level'];
echo "
Trophies: ".$data['avatar']['trophies'];
echo "
".$data['avatar']['clanRole'];

It doesn't return any values. Why is this?
It just returns:
IGN:
Town Hall:
Level:
Trophies:

A: Use json_decode with second parameter setting to true will return Array
$data['avatar'] has sub array so you can access it whole sub array like
$data = json_decode($json,true);
$subarray = $data['avatar'][0];
echo $subarray['userName']; // King Shiv

See Demo

A: $url = "http://185.112.249.77:9999/Api/Player?player=1;
                                                     //^ you forgot to close with "
                                                 //That's why it cant parse your data

$url = preg_replace("/ /", "%20", $url);
$jsondata = file_get_contents($url);
$data = json_decode($jsondata, true);
echo "IGN: ".$data['avatar'][0]['userName']; // [0] here is the first index
echo "
Town Hall: ".$data['avatar'][0]['townHall'];
echo "
Level: ".$data['avatar'][0]['level'];
echo "
Trophies: ".$data['avatar'][0]['Trophies'];
echo "
".$data['avatar'][0]['clanRole'];

A: Seems like you having a problem with the url. Tried with cURL and it returns "couldn't connect to host", which can be a firewall that blocks or something with your configuration. Your json decoding is fine, fix the problem with the address and you'll get the content.


text:
Q: Slider/Images out of document flow I am trying to float my sidebar to the left and my slider to the right however, my images are out of the document flow.
Basically what I'm trying to do is when the user resizes the browser window, the images will shrink (which is why I am using max-width: 100%).
View in Chrome to see the issue

A: You can try using width : 100% for your main class like below.
.main {
position: relative;
float: right;
max-width: 600px;
margin: 0;
width: 100%;
}

EDIT:
You have edited your markup design. You have added a new content div to outside of your article div.
EDIT
#page-wrap {
max-width: 960px;
min-height: 100%;
height: auto !important;
padding-bottom: 40px;
margin: 0 auto;
position: relative;
}

#sidebar {
position: absolute;
width: 300px;
left: 0;
top: 130px;
}

.content {
max-width: 600px;
position: absolute;
left: 360px;
top: 130px;
right: 0;
}

If you change your classes this way, when the browser is resized, the image will be resized.
You can look at simple demo about this problem.
http://jsfiddle.net/qCQ9H/2/


text:
Q: Java Animation - There must be one duration per frame I'm new to programing and I have a problem. I followed TheNewBoston tutorial, added more animations and now the console says:

Exception in thread "main" java.lang.RuntimeException: There must be
  one duration per frame

Here's my code:
package javagame;

import org.newdawn.slick.*;
import org.newdawn.slick.state.*;

public class Play extends BasicGameState{

Animation player, movingUp, movingUp1, movingUp2, movingDown, movingDown1, movingDown2, movingLeft, movingLeft1, movingLeft2, movingRight, movingRight1, movingRight2;
Image playground;
boolean quit = false;
int[] duration = {200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200};
float playerPositionX = 0;
float playerPositionY = 0;
float shiftX = playerPositionX + 320;
float shiftY = playerPositionY + 160;

public Play(int State){
}

public void init(GameContainer gc, StateBasedGame sbg) throws SlickException{
    playground = new Image("res/playground.png");
    Image[] walkUp = {new Image("res/player11.png"), new Image("res/player12.png"), new Image("res/player10.png")};
    Image[] walkDown = {new Image("res/player2.png"), new Image("res/player3.png"), new Image("res/player1.png")};
    Image[] walkLeft = {new Image("res/player5.png"), new Image("res/player6.png"), new Image("res/player4.png")};
    Image[] walkRight = {new Image("res/player8.png"), new Image("res/player9.png"), new Image("res/player7.png")};

    movingUp = new Animation(walkUp, duration, false);

    movingDown = new Animation(walkDown, duration, false);

    movingLeft = new Animation(walkLeft, duration, false);

    movingRight = new Animation(walkRight, duration, false);

    player = movingDown;

}

public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{
    playground.draw(playerPositionX, playerPositionY);
    player.draw(shiftX, shiftY);
    g.drawString("Player's X: "+playerPositionX+"\nPlayer's Y: "+playerPositionY, 400, 20);

    if(quit==true){
        g.drawString("Resume (R)", 250, 100);
        g.drawString("Main Menu (M)", 250, 150);
        g.drawString("Quit Game (Q)", 250, 200);
        if(quit==false){
            g.clear();
        }
    }
}

public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{
    Input input = gc.getInput();

    //up
    if(input.isKeyDown(Input.KEY_UP)){
        player = movingUp;
        playerPositionY += delta * .1f;
        if(playerPositionY>162){
            playerPositionY -= delta * .1f;
        }
    }
    //down
    if(input.isKeyDown(Input.KEY_DOWN)){
        player = movingDown;
        playerPositionY -= delta * .1f;
        if(playerPositionY<-600){
            playerPositionY += delta * .1f;
        }
    }
    //left
    if(input.isKeyDown(Input.KEY_LEFT)){
        player = movingLeft;
        playerPositionX += delta * .1f;
        if(playerPositionX>324){
            playerPositionX -= delta * .1f;
    }
    //right
    if(input.isKeyDown(Input.KEY_RIGHT)){
        player = movingRight;
        playerPositionX -= delta * .1f;
        if(playerPositionX<-840){
            playerPositionX += delta * .1f;}
        }
    }
}

public int getID(){
    return 1;
}

}

Thanks!

A: The first Google result for "there must be one duration per frame" leads to an identical question on this same site:
Slick Animation - There must be one duration per frame
Your duration array needs to be the same size as your image array. Change to:
int[] duration = {200, 200, 200};


text:
Q: How to interrupt a thread/process by making a correct "Stop" button in Tkinter (Python)? I want some basics on the problem of making some sort of "Stop" button that in my case terminates the series of beeps:
from tkinter import *
import winsound
from random import randint

class App(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.widgets()

    def widgets(self):
        self.beep = Button(self, text = "Beep", command = play_beep)
        self.beep.pack()
        self.stop = Button(self, text = "Stop", command = stop_beep)
        self.stop.pack()

go_on = True
def play_beep():
    count = 10
    while go_on == True and count != 0:
        winsound.Beep(randint(100, 2500), 200)
        count -= 1

def stop_beep():
    go_on = False

root = Tk()
app = App(root)
root.mainloop()

When I press the "Beep" button it gets stuck as well as all the GUI until the beeps end. Could anyone tell me how to fix it?

A: First off, your question has nothing to do about threads or processes. Tkinter is single-threaded.
If you want to run some function periodically in a tkinter program, you must give the event loop a chance to process events. The typical solution is to do it like this:
def play_beep(count=10):
    if go_on and count != 0:
        winsound.Beep(randint(100, 2500), 200)
        root.after(1000, play_beep, count=1)

This will cause the beep to play every second (1000ms) for ten iterations. In between each call, the event loop will have a chance to process other events.
Now, if the code you are running takes a long time, you're going to have to run that code in a separate thread or process. I know nothing about winsound.Beep so I don't know if that's necessary or not.
Second, to be able to interrupt it, you need to make go_on global, otherwise you're simply setting a local variable that never gets used.
def stop_beek():
    global go_on
    go_on = False

A: I don't use TKinter, but I believe your button press is not creating a separate thread or process. The reason why your button gets stuck is because your play_beep loop is blocking your GUI execution loop. So we use threading. The thread executes at the same time as your GUI, so you can basically do two things at once (listen for GUI events and play beep noises).
import threading

class App(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.is_playing = False
        self.pack()
        self.widgets()

    def widgets(self):
        self.beep = Button(self, text = "Beep", command = self.play_beep)
        self.beep.pack()
        self.stop = Button(self, text = "Stop", command = self.stop_beep)
        self.stop.pack()

    def play_beep(self):
        self.is_running = True
        self.beep_th = threading.Thread(target=self.run)
        self.beep_th.start()

    def run(self):
        count = 10
        while self.is_running == True and count != 0:
            winsound.Beep(randint(100, 2500), 200)
            count -= 1

    def stop_beep(self):
        try:
            self.is_running = False
            self.beep_th.join(0)
            self.beep_th = None
        except (AttributeError, RuntimeError): # beep thread could be None
            pass

    def closeEvent(self, event): # This is a pyside method look for a TKinter equivalent.
        """When you close the App clean up the thread and close the thread properly."""
        self.stop_beep()
        super().closeEvent(event)


text:
Q: Enable NTLM SSO in Firefox via Group Policy I would like to enable NTLM for a specific intranet site. For that I need to configure the following parameter:
network.automatic-ntlm-auth.trusted-uris to add x.xyz.com
How can I achieve this via group policy for Firefox Users?
I've come across this script (below) but unsure if this is the best solution
https://www.felixrr.pro/wp-content/uploads/2012/05/FirefoxSSO.txt

A: Start with the Enterprise deployment article.
First write the following to \Program Files\Mozilla Firefox\defaults\prefs\autoconfig.js:
pref("general.config.filename", "mozilla.cfg.js");
pref("general.config.obscure_value", 0);

Then put your actual settings in \Program Files\Mozilla Firefox\mozilla.cfg.js:
// the first line must be a comment
pref("network.negotiate-auth.trusted-uris", "domain.test");
pref("network.automatic-ntlm-auth.trusted-uris", "domain.test");

In the second file you can use defaultPref(key, value), clearPref(key), pref(key, value), or lockPref(key, value); the last three will override user settings.

It's possible to make Firefox download the configuration over HTTPS, but this doesn't give many advantages over plain Group Policy; it can be useful though where AD is not available:
lockPref("autoadmin.global_config_url", "https://example.com/firefox/lockdown.js");

The 3rd-level .js file works the same way as the 2nd-level one.


text:
Q: How to find the executable file of an app if 'whereis' is not showing it? This basically to do with cuttlefish(The app from showdown) in this case.
I cant find the location of the executable file for it.
The command whereis did not give any results!
I want to add it to my start up applications and thus i need the path!
P.S: the preferences of the app are not showing up and ticking against the start automatically thing when the settings for the 1st time showed up is not working!.
So i need to find out the executable/bin file...
How do i do this?

A: You can use apt-file search <package-name> or dpkg -S <package-name>, where <package-name> is the package you want to search.
Note that these commands will output many results. To find the required package use grep:
apt-file search package | grep -E "(bin/)?package$"
OR
dpkg -S package | grep -E "(bin/)?package$"
This searches the lines whose last word is package and may or may not be preceded by bin/, for example it will result both /usr/bin/package and /usr/anydirectory/package.

A: Another quick way to find executable programs is to use locate, which will only show those programs present on your computer. It relies on a database that is automatically updated by cron every day. (Use sudo updatedb to refresh it manually if you have just installed some programs and cannot find them when using locate.)
If, for example, you wanted to find where the dosbox executable is, simply type:
locate dosbox | grep bin

Which returns,
/usr/bin/dosbox

Apart from using whereis, this is the quickest way to find executables. It can also be used to find readme documents extremely quickly by substituting bin for README.
Locate is a very useful program and you can even use regex with it if you want to conduct more complex searches. See man locate for more details.

A: Some other commands which (similar to the whereis) can tell you where the executable is (all of them detailed in answers to this question) are summarized here:

*

*type: type <name> (shell builtin)

*command: command -v <name> (shell builtin)

*find


text:
Q: How to pass parameters with jquery animate i have the following code:
     function openme() {
        $('#wrapper').addClass('primary-nav-opened');
        topbar.animate({
            left: "265px"
        }, {
            duration: 'fast',
            easing: 'swing'
        });
        pagebody.animate({
            left: "265px"
        }, {
            duration: 'fast',
            easing: 'swing'
        });

        $('body').addClass('ov-hidden');
    }

my issue is: I have to change the attribute left to right, but i have to do it dynamically.
I have tried the following, but it does not work:
var direction = {'right' : pos};

Then i changed all 'left' values to direction. This doesn't work. What is wrong with my code, and how to get it working?
Any help would much be appreciated.
Thanks
updated code:
     function openme() {
        $('#wrapper').addClass('primary-nav-opened');
        topbar.animate({
            direction: "265px"
        }, {
            duration: 'fast',
            easing: 'swing'
        });
        pagebody.animate({
            direction: "265px"
        }, {
            duration: 'fast',
            easing: 'swing'
        });

        $('body').addClass('ov-hidden');
    }

A: If you want to animate dynamically right or left you need to set 1 of the two to the desired amount of pixels and the other one to 'auto'. Otherwise they go in conflict and won't animate.
So you could do something like this:
function openme(dir, amount) {
    $('#wrapper').addClass('primary-nav-opened');
    var movement = {};
    if (dir === 'left') {
        movement.left = amount;
        movement.right = 'auto';
    }
    if (dir === 'right') {
        movement.right = amount;
        movement.left = 'auto';
    }

    topbar.animate(
        movement, {
            duration: 'fast',
            easing: 'swing'
        });
    pagebody.animate(
        movement, {
            duration: 'fast',
            easing: 'swing'
        });

    $('body').addClass('ov-hidden');
}

openme('left','265px');

A:  function openme(properties) {
    $('#wrapper').addClass('primary-nav-opened');
    var properties =
    topbar.animate(properties, {
        duration: 'fast',
        easing: 'swing'
    });
    pagebody.animate(properties, {
        duration: 'fast',
        easing: 'swing'
    });

    $('body').addClass('ov-hidden');
}
openme({right: "auto", left: "265px"});
// ... sometime later
openme({right: "265px", left: "auto"});


text:
Q: Prove Bernoulli inequality if $h>-1$ Qi) Prove Bernoulli's inequality If $h> -1$,
then $ (1+h)^n \geq 1+nh$
Qii) why is this Trivial is $h>0 $
Something i have always been lucky with is having a lot of intuition to go on with most theorems and lemmas that i see stated but this one is a bit different. For one looking at the Equality sign makes my head hurt i would like to hope that there is only equality when $h=0$ or when $n=1$ or when n=2 and $h = - \dfrac {1} {2}$ but it really makes my head hurt thinking about greater values of n where h is negative. i feel like there should be one value h that makes it true for each $ n \in \mathbb{N} $ Can anyone tell if i am missing values for n and h that result in an equality occurring? Perhaps it wouldn't even be all that difficult to prove there existence using contraction and induction; it may even be possible to define them using the binomial theorem.
As for Qii) This is fairly obvious expanding the left side we get crap $+nh +1 $ but unlike when h<0 the sum of crap $> 0$ so subtracting 1+nh from both side we get crap $>0 \geq 0$ which is obviously true.
Im not a big fan of approaching things inductively unless i absolutely have to especially on an inequality.
Although i wouldn't mind someone pointing out why my induction proof went a little wrong; i only made an attempt at proving it inductively below so you guys won't think i am lazy/ so someone won't write down a proof by induction.
If its possible could someone show me how to prove  Qi) without using induction.
Proving Qi) inductively is fairly easy base case $n=1$ we have $ (1+h) \geq (1+h) $ thus base case is true assume true for all k want to show true for all $ (k+1) $
Now we want to show that $ (1+h) (1+h)^k  \geq 1+(k+1)h$ is true.
This reduces to $ (1+h) (1+h)^k  \geq (1+hk) +h$ using the k case we can reduce this to be true whenever the inequality $ (1+h) \geq +h$ which is always true for all h this implies that the inequality holds for all $n\in \mathbb{N} $ and $ \forall h \in \mathbb{R} $ but that's actually not true and would only be true if n were even since n can be odd the left side can be bigger in magnitude but actually be negative if $(1+h) <0$  luckily for me $ h> -1 $ is a condition.

A: I'll assume you mean $n$ is an integer.
Here's how one can easily go about a proof by induction. The proof for $n=1$ is obvious.
Assume the case is established for $n$ then, $(1+h)^{n+1}=(1+h)^n(1+h)\geq(1+nh)(1+h)=1+(n+1)h+nh^2\geq 1+(n+1)h$
The part where $h\geq-1$ is in using the $\geq$ where we assume that $(1+h)$ is positive.
There is a way I know to prove it without induction that extends to real numbers instead of only integers.
Let $f(x)=x^\alpha-\alpha x+\alpha-1$.
$f'(x)=\alpha*(x^{\alpha-1}-1)$
$f'(x)=0$ at $x=1$ and it is obvious that $f(x)$ has a local minimum when $\alpha<0$ or  $1<\alpha$ and $x>0$
At $x=1$, $f(x)=0$ so $f(x)\geq0$
Set $x=(1+h)$
Now, you have:
$(1+h)^\alpha-\alpha-\alpha h+\alpha-1=(1+h)^\alpha-\alpha h-1\geq 0$ and we can deduce Bernoulli's Inequality as a special case.


text:
Q: What does 'stale file handle' in Linux mean? Say I have a terminal open, and through that terminal I have cd'ed to some directory. Through another terminal, I delete that directory and restore it back from an identical backup. When I try to vim a file from the first terminal, in the same directory, why do I get an error about a stale file handle? What does it mean? (On a side note, I have found that it is possible to bypass this issue through cd $(pwd).)

A: When the directory is deleted, the inode for that directory (and the inodes for its contents) are recycled.  The pointer your shell has to that directory's inode (and its contents's inodes) are now no longer valid.  When the directory is restored from backup, the old inodes are not (necessarily) reused; the directory and its contents are stored on random inodes.  The only thing that stays the same is that the parent directory reuses the same name for the restored directory (because you told it to).
Now if you attempt to access the contents of the directory that your original shell is still pointing to, it communicates that request to the file system as a request for the original inode, which has since been recycled (and may even be in use for something entirely different now).  So you get a stale file handle message because you asked for some nonexistent data.
When you perform a cd operation, the shell reevaluates the inode location of whatever destination you give it.  Now that your shell knows the new inode for the directory (and the new inodes for its contents), future requests for its contents will be valid.


text:
Q: Can I post a string-array over HTTP-POST without using a serializer-function? How can I post a string-array over HTTP-POST without serializing (Edit: without using a serializer function)? E.g.:
 $d1 = array ("2","5","1","3");

A: You can't.
Before serializing, the data is just a bunch of bytes in memory which won't make any sense if copied wholesale to another computer and which can't be expressed in HTTP.
This is what serializing is for.
It is much like why we use spoken language (serialization) like English (JSON) or German (WWW URL Form Encoding) to communicate between people (computers) through the air (HTTP), instead of copying the electric impulses from one brain to another (i.e. we don't have a means to do it, and impulses that work in one brain probably won't work in another).

A: Yes, You can..
It works within a multiple select box. Array elements are the option-values.


text:
Q: PNRP - How does it work? Sorry if this seems like a stupid question but im actually having a hard time finding a straight answer.  I know PNRP is MS's technology for implementing peer-to-peer but how does it actually work - i mean im assuming when you register your address in the global cloud that it is actually contacting a Microsoft server to find a peer address then handing back the peer endpoint info.
Im a little confused still as to how addresses are found in the cloud when say there are only 2 peers located across the globe.
... From what i understand there has to be a peer resolver to maintain a list of registrations (assuming a brand new node comes online) it then hands addresses of its closest neighbors to connect to.  This can be a central server that I own if i choose to use an address the services/apps know about or the global cloud which i assume uses a peer resolver that microsoft operates.
Thanks

A: From the Wikipedia page:

Internally, PNRP uses an architecture
  similar to distributed hash table
  systems such as Chord or Pastry. The
  peer name is hashed to produce a
  128-bit peer identifier, and a
  DHT-like algorithm is used to retrieve
  the location of the host publishing
  that identifier.

This means their infrastructure is not centralized; there isn't "a Microsoft server" to ask. Metaphorically, you're asking the cloud for routing information, and it collaboratively answers.
If there were only two computers in the cloud, they would both know about each-other.

A: Here's the goods
http://msdn.microsoft.com/en-us/library/ms731061.aspx
It covers the basics:
Meshes, Nodes, Channel Security, Resolvers.
And the answer to your question is the resolver.  Your programs can collaborate on a peer to peer level but they need central servers to find each other instantly.  You would publish a resolver to your server and all the clients would use it.


text:
Q: Get website url that calls API I have an API, and we would like to see who uses it (well actually for the moment we just would like to see what python notebooks on github calls it).
I guess I could log the IP addresses, but I would prefer the url it self, so I can backlink to all that useses the API.
Is this possible at all? The language is of less importance.
I already naively tried to use the request.referrer in Python flask, but when i call api2 it doesnt seem to work.
import requests
@app.route('/api')
def api():
    return unicode(request.referrer)

@app.route('/api2')
def api2():
    r = requests.get('http://omicsdriven.pythonanywhere.com/api')
    return str(r.text)


text:
Q: Python - Lambda function invalid syntax error I have the following code, and getting the SyntaxError: invalid syntax for lambda (v, p): v == p:
predictions = tree_model.predict(test_data.map(lambda p: p.features))
labels_and_preds = test_data.map(lambda p: p.label).zip(predictions)

t0 = time()
test_accuracy = labels_and_preds.filter(lambda (v, p): v == p).count() / float(test_data.count())
tt = time() - t0

What's the correct syntax?


text:
Q: cannot creat a domain using Rackspace Cloud DNS with openstack.net I'm currently trying to create a domain on Rackspace Cloud DNS service using openstack.net sdk, but nothings happening.
i got my rackspace account, its activated and i got my API key as well.
I wrote a console app to test my code but the results are always "WaitingForActivation" and i cant find any documentation for cloudsDNS using openstack.net sdk.
Would anyone be able to take a look at my code and tell me what im doing wrong please.
private static string RackSpaceUserName
        {
            get { return "username"; }
        }
    private static string RackSpaceUserApiKey
    {
        get { return "apikey"; }
    }

    private UserAccess RackSpaceUser
    {
        get
        {

            IIdentityProvider identityProvider = new CloudIdentityProvider();

            var userAccess = identityProvider.Authenticate(Cloudidentity);

            return userAccess;
        }

    }

    private static CloudIdentity Cloudidentity
    {
        get
        {
            var ci = new CloudIdentity
            {
                APIKey = RackSpaceUserApiKey,
                Username = RackSpaceUserName
            };

            return ci;
        }
    }

    static void Main(string[] args)
    {
        var ParkedDomain = new CloudDnsProvider(Cloudidentity, null, true, null);

        List<DnsDomainRecordConfiguration> dnsrecords = new List<DnsDomainRecordConfiguration>();

        dnsrecords.Add(new DnsDomainRecordConfiguration(DnsRecordType.Ns, "testdomain.com", "dns1.stabletransit.com", TimeSpan.FromMinutes(20), null, null));

        dnsrecords.Add(new DnsDomainRecordConfiguration(DnsRecordType.Ns, "testdomain.com", "dns2.stabletransit.com", TimeSpan.FromMinutes(20), null, null));

        List<DnsSubdomainConfiguration> subdomains = new List<DnsSubdomainConfiguration>();

        subdomains.Add(new DnsSubdomainConfiguration("info@testdomain.com", "test", ""));

        DnsDomainConfiguration dnsd = new DnsDomainConfiguration("testdomain.com", TimeSpan.FromMinutes(20), "info@testdomain.com", "", dnsrecords, subdomains);

        DnsConfiguration dnsconfig = new DnsConfiguration(dnsd);

        var result = ParkedDomain.CreateDomainsAsync(dnsconfig, AsyncCompletionOption.RequestCompleted, CancellationToken.None, null);

        Console.Write(result.Status);

        Console.ReadLine();
    }

the value for result.Status always returns "WaitingForActivation", and when i check my rackspace cloud dns dashboard, no domains are created.
Any help would be greatly appreciated.

A: The DNS service uses asynchronous methods. The object returned by CreateDomainsAsync is a Task which represents the asynchronous operation, but that operation may not complete prior to the call returning. You can wait for the request to be complete in your code by any of the following methods:

*

*Await the result (only allowed in an async method, which Main cannot be).
await result;

*Access the Task<TResult>.Result property.
var completedResult = result.Result;

*Call the Task.Wait method.
result.Wait();


text:
Q: obj.count = 8 or setattr(obj, 'count', 8) In python. What is the difference between using the setattr(object, 'var', value and the object.var = value method. They both seem to do the same thing
class Something(object):
    pass

x = Something()

setattr(x, 'count', 2) #sets count to be 2
x.count = 3            #sets count to be 3

A: They indeed do the same thing, but you cannot use a variable with the attribute setting syntax, while you can do that with setattr().
In other words, this works:
foo = 'count'
setattr(x, foo, 2)

but this doesn't:
foo = 'count'
x.foo = 2

Use setattr() for dynamic attribute setting, where the name of the attribute is taken from a variable. Use object.attributename = value for static attributes, where you know the name beforehand.
In addition, the attribute access syntax is limited to proper Python identifiers, while setattr() can use any string. This means that you can use:
setattr(x, '3 little piggies', 42)

where attempting that with static attributes will not work because Python identifiers do not allow for spaces, and cannot start with digits.

A: As others have mentioned, they are essentially the same. However, setattr(obj, 'attr', value) is more general, in that it allows you to do things that you can't do via the syntactic construct obj.attr = value:
>>> class A(object):
...    pass
>>> a = A()
>>> setattr(a, 'foo bar', 5)  # space in the attribute name???
>>> print getattr(a, 'foo bar')
5
>>> a.'foo bar' = 7
  File "<stdin>", line 1
    a.'foo bar' = 7
          ^

SyntaxError: invalid syntax
Whether you should take advantage of this "feature" of Python (hint: you probably shouldn't) is another question.

A: Accessing x.count directly yields more efficient code, I suspect that's because the property access can be resolved at parse/byte-compiling time. This would probably be especially noticeable in a loop.
Given
def f(): setattr(x, 'count', 2)
def g(): x.count = 3

Here's what dis says on Python 2.7:
>>> dis.dis(f)
  1           0 LOAD_GLOBAL              0 (setattr)
              3 LOAD_GLOBAL              1 (x)
              6 LOAD_CONST               1 ('count')
              9 LOAD_CONST               2 (2)
             12 CALL_FUNCTION            3
             15 POP_TOP
             16 LOAD_CONST               0 (None)
             19 RETURN_VALUE
>>> dis.dis(g)
  1           0 LOAD_CONST               1 (3)
              3 LOAD_GLOBAL              0 (x)
              6 STORE_ATTR               1 (count)
              9 LOAD_CONST               0 (None)
             12 RETURN_VALUE

So g yields less bytecode, and I suspect it's faster as well.


text:
Q: Sphinx query/settings similar to Like '%string%' SQL query I want to search for a string in Sphinx and get all documents that contains that string
Example: search for "bot" and get the documents that contain "xbot", "robot", "botanic", etc
Basically I want my search to have same effects as running a

SELECT * FROM table WHERE column_name LIKE '%bot%'

How can I do that?
Note:
I tried to use min_infix_len but it seems that is only extends the search a little bit but not fully. So if I set conf-min-prefix-len = 2 it will match 'xbot' but not "botanic"

A: Try using wildcard in Extended Query Syntax and min_infix_len enabled
SELECT * FROM myindex WHERE MATCH("bot | bot* | *bot*")


text:
Q: How can i import and read bookmarks of MS word in to Java It's a very hard question and I searched for it and I didn't find any good answer!
I want to read (key) Bookmarks of Ms Word and set the vlaue in Word with Java program language! how can I do it?
with Apache POI didn't work! :(
thanks

A: Ok I've found the solution, and wrote the program.
this link maybe help you! http://apache-poi.1045710.n5.nabble.com/How-to-read-the-value-of-bookmarks-docx-td5710184.html
but it's just for new Ms Word (.docx)
For old version (.doc) I wrote a method by my self but it didn't work correctly.
for old version we should use org.apache.poi.hwpf but for new version org.apache.poi.xwpf!
and for controlling Ms Word or MS Office we should use Jacob Project.
If you have questions you can ask me again

A: You could do this with docx4j.
The challenge is that bookmarks are point tags which surround arbitrary content.
So if your intent is to replace the content of a bookmark, you'd be better off considering an alternative approach.
See this presentation for suggestions.


text:
Q: Laravel and Vue.js put method using fetch I'm encountering an error with the put method [![enter image description here][1]][1]
I'm using axios for post and fetch for put. I don't know how a put method will work on axios so if anyone could help I would really appreciate it.
Component.vue script
editItem (item) {
        this.dialog = true
        this.editedIndex = this.departments.indexOf(item)
        this.id = item.id;
        this.department = item.department_name;

      },
  save() {
    const { department } = this
    if (this.editedIndex > -1) {
      fetch('/api/department', {
        method: 'put',
        body: JSON.stringify(this.department),
        headers: {
          'content-type': 'application/json'
        }
      })
    } else {
      axios
      .post('/api/department', { department })
      .then(response => this.initialize())
      .catch(error => console.log(error))
    }
    this.close()
  },

Controller
public function store(Request $request) {
    $department = $request->isMethod('put') ? Department::findOrFail($request->id) : new Department;

    $department->id = $request->input('id');
    $department->department_name = $request->input('department');

    if($department->save()) {
      return response()->json($department);;
    }
  }

API
Route::get('departments', 'DepartmentController@index');
Route::get('department/{id}', 'DepartmentController@show');
Route::post('department', 'DepartmentController@store');
Route::put('department', 'DepartmentController@store');
Route::delete('department/{id}', 'DepartmentController@destroy');

The post method works but not for put as seen with the error posted above.

A: It's because you didn't implement a put method in the backend. The exception indicates that the put request is made, so the problem is probably not related to Axios.
Route::put('foo/bar', function()
{
    //
});

Edit:
If you make a PUT request, it's supposed to be sent to an endpoint that concerns a resource (to either create or update). It is an idempotent request, meaning that if you send the request, it will cause the same result regardless whether you sent it once or multiple times.
Please try something like this:
Route::put('department/{id}', 'DepartmentController@update')

public function update(Request $request, $id)  {

And make sure that the request method adds the id as path parameter in the request.

A: UPDATE:
I have now successfully make it work. I'll share it to everyone in case other people new to laravel and vue might encounter the same problem.
This is now the working code, using axios.
save() {
    const { department, id } = this
    if (this.editedIndex > -1) {
      axios
      .put('/api/department', { department, id })
      .then(response => this.initialize())
      .catch(error => console.log(error))
    } else {
      axios
      .post('/api/department', { department })
      .then(response => this.initialize())
      .catch(error => console.log(error))
    }
    this.close()

I think sleep helps a lot when you're stuck in a problem.


text:
Q: Is there a connection between the euclidean topology and the Zariski Topology on algebraic varieties over $\mathbb{C}$? Recently I was thinking about the following:
When talking about the sphere $\mathbb{S}^1$ we can topologize it in two different ways. Either as a subspace of the euclidean space $\mathbb{R}^2$ or as a closed (real) algebraic subvariety of $\mathbb{A}^2_\mathbb{R}$. In either case we think about it as the same "thing", namely the points $(x,y)\in\mathbb{R}^2$ such that $x^2+y^2=1$.
As algebraic geometry loves algebraically closed sets we can also consider the setup in $\mathbb{C}^2$ and note, that $\lbrace(x,y)\in\mathbb{C}^2\vert x^2+y^2=1\rbrace$ can topologized either with the euclidean topology or the Zariski topology, and although these two versions are different as topological spaces, they are the same "thing". Of course we don't need to restrict ourselves to this example, but can consider any affine algebraic variety over $\mathbb{C}$ (or even any subset of $\mathbb{C}^n$) with either the Zariski topology or the euclidean topology and feel that they are the same "thing".
Is there any way to make this idea formal? Or is it maybe even possible to reconstruct the euclidean topology directly from the Zariski topology?

A: They are certainly not the same thing, but they are related. There is an analytification functor $X \mapsto X^{an}$ sending complex varieties to complex analytic spaces, a generalization of complex manifolds; these have the Euclidean / analytic topology but are also equipped with a sheaf of holomorphic functions. The study of the relationship between $X$ and $X^{an}$ goes by the name "GAGA".


text:
Q: How to handle hidden folders on deployed website Our security team at work did a security scan of our soon-to-be-deployed website and one of the items that was found was "Hidden Directory Detected". It shows up for 3 different folders, aspnet_client, scripts, and content.
The software recommends to throw a 404 instead of a 403, or to remove the folders completely. First, are the folders actually needed? How can I determine which folders in my visual studio project are actually needed in order for the site to actually run (without removing folders one-at-a-time and trying to access the site)?
What is the proper way to handle this/resolve the security scan alert? Do I need to add special routing rules in the routeconfig.cs for when these paths are accessed?
Edit, I should note that this is WebApi/REST service, not a regular MVC site. (Therefore, using the CustomErrors configuration section will not work)

A: After much googling, here's the solution that I have implemented. I'm not sure if it's the best practice for this sort of thing, but it's working in my scenario.
Scroll down to the answer about implementing the NoAccessHandler : IHttpHandler
http://forums.asp.net/t/1478217.aspx?Make+IIS+return+a+404+status+code+instead+of+403
Config section needed:
<httpHandlers>
      <add verb="*" path="docs/*" validate="false" type="MyNameSpace.NoAccessHandler"/>
</httpHandlers>

<system.webServer>
        <handlers>
      <add name="NoAccess" verb="*" path="docs/*"  preCondition="integratedMode" type="MyNameSpace.NoAccessHandler"/>
    </handlers>
</system.webServer>

And the Handler code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyNameSpace
{
    public class NoAccessHandler: IHttpHandler
    {

        #region IHttpHandler Members

        public bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            context.Response.StatusCode = 404;
        }

        #endregion
    }
}


text:
Q: Enable Compatibility View (IE8) from code-behind? is there a way that i can add tag in my .aspx page to Enable Compatibility View for Web sites by using Internet Explorer 8 ? without using click on "compatibility" icon on the browser?

A: Include as the first thing inside <head>:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>

I'd strongly recommend fixing whatever site problems you have so the site works properly in IE8-native Standards Mode though. You will get a performance increase from running native in IE8, and even more so in IE9.

A: You can't actually enable "Compatibility View", but you can use various mechanisms to control the compatibility mode that IE uses to render the page (bobince's suggestion is one).  I'd recommend reading: http://msdn.microsoft.com/en-us/library/cc288325%28v=VS.85%29.aspx


text:
Q: Bootstrap render each page as tabs I have created admin panel using bootstrap controls, lets take example as products module. So when the user click on product menu item it opens the products list, and when the user clicks on edit / details i wanted the product list page to stay as it is, but open the edit page as a new tab inside the same window. I have referred the image below, can you please let me know how to acheive this using bootsrap? I don't want to use bootstrap tabs and bootstrap tabs with Ajax, because for which I have to enter the code for listing and details in the same page, this will cause performance issue, instead the code will remain in different pages but just they will render as tabs in the same window, and user can switch between tabs and perform their actions.

A: To achieve such a user experience you want you must rely on AJAX or the new Fetch API,   otherwise you should send requests to the server, wait for server response and based on that render the desired page.
The UX you want to achieve is a SPA, Single Page Application,  which relies on AJAX calls to the server and modifies and/or shows the DOM based on both user requests and server responses.
You can use just one page,  and hide/show sections of it,  using navigation anchors #, and each section fetches data form the server.  Better than AJAX there is the new Fetch API,  which improves old XmlHttpRequest.
I strongly recommend to fetch data from a RestFul API, that way each call is just an URL to an API endpoint which returns JSON formatted data,  light, safe, flexible.


text:
Q: Can't force urxvt load font, no matter what (unable to load base fontset) I want to urxvt load DejaVu Sans Mono for Powerline font, but it doesn't work with xft no matter what.
Excerpt from ~/.Xresources from my dotfiles
! this work
! URxvt.font: -*-dejavu sans mono-medium-r-*-*-0-*-*-*-*-*-koi8-u

! none of these - dont
! URxvt.font: xft:DejaVu Sans Mono for Powerline:style=Book:size=12
! URxvt*font: xft:DejaVu Sans Mono for Powerline:style=Book:size=12
! URxvt*font: xft:DejaVu Sans Mono for Powerline:size=12
! URxvt*font: xft:DejaVu Sans Mono:size=12

I use rxvt-unicode-patched version from aur
Let's check if all right
$ urxvt --help 2>&1 | grep options
options: perl,styles,combining,blink,iso14755,unicode3,encodings=eu+vn+jp+jp-ext+kr+zh+zh-ext,fade,transparent,tint,pixbuf,XIM,frills,selectionscrolling,wheel,slipwheel,smart-resize,cursorBlink,pointerBlank,scrollbars=plain+rxvt+NeXT+xterm

$ fc-match "DejaVu Sans Mono for Powerline"
DejaVu Sans Mono for Powerline.ttf: "DejaVu Sans Mono for Powerline" "Book"

$ fc-list G "DejaVu Sans Mono"
/usr/share/fonts/TTF/DejaVuSansMono.ttf: DejaVu Sans Mono:style=Book
/usr/share/fonts/TTF/DejaVu Sans Mono Bold for Powerline.ttf: DejaVu Sans Mono for Powerline:style=Bold
/usr/share/fonts/TTF/DejaVuSansMono-Oblique.ttf: DejaVu Sans Mono:style=Oblique
/usr/share/fonts/TTF/DejaVu Sans Mono Oblique for Powerline.ttf: DejaVu Sans Mono for Powerline:style=Oblique
/usr/share/fonts/TTF/DejaVu Sans Mono for Powerline.ttf: DejaVu Sans Mono for Powerline:style=Book
/usr/share/fonts/TTF/DejaVu Sans Mono Bold Oblique for Powerline.ttf: DejaVu Sans Mono for Powerline:style=Bold Oblique
/usr/share/fonts/TTF/DejaVuSansMono-Bold.ttf: DejaVu Sans Mono:style=Bold
/usr/share/fonts/TTF/DejaVuSansMono-BoldOblique.ttf: DejaVu Sans Mono:style=Bold Oblique

what I get
$ xrdb -merge -I$HOME ~/.Xresources && urxvt
urxvt: unable to load base fontset, please specify a valid one using -fn, aborting.

xrdb -query -all at that time here
Why?!

A: The real problem might be that your copy of urxvt might have been compiled without "frills" which would allow it to work.
http://powerline.readthedocs.io/en/master/troubleshooting.html#urxvt-unicode3-and-frills


text:
Q: How to insert text to an existing Powerpoint Slide using Powershell I have tried three different approaches, to no avail.
First is:
$s = $presentation.Slides[$targetslide]

$tb = $s.Shapes.AddTextbox($horiz,$left,$top,$width,$height)
$tb.TextFrame.TextRange.Text = $fla

the second is:
$f0a = ''
#$f1a is text to insert
$presentation.Slides[$targetslide].Shapes[1].TextFrame.TextRange.Replace($f0a, $f1a)

and the third is:
$s = $presentation.Slides[$targetslide]

$s.Shape[1].TextFrame.TextRange.Text = $fla

Neither seem to work. Do you have any suggestions as to what I should try?

A: Apparently,
$f0a=$s.Shapes[5].TextFrame.TextRange.Text

$test = $s.Shapes[5].TextFrame.TextRange.Replace($f0a, $f1a)

works perfectly.


text:
Q: Using two different measures in a having statement I am including the code I am trying to use.  What I want is to get a count of encounter id's for each doctor.  I want to capture patients who have had at least 2 visits or who have had one preventive visit.  I don't know how to make this work using the having statement.  thanks for any assistance.
SELECT  e.doctorID, COUNT(DISTINCT e.encounterID) AS VisitCount

FROM enc e

JOIN users u ON e.patientID = u.uid
Left JOIN diagnosis d ON e.encounterID = d.encounterID
LEFT JOIN items it ON d.itemID = it.itemID
LEFT JOIN itemdetail id ON it.itemID = id.itemID

WHERE e.encType = 1 AND e.status = 'CHK' AND e.deleteFlag = 0 AND
e.date BETWEEN DATE_ADD((LAST_DAY(DATE_ADD(CURDATE(),INTERVAL -2 MONTH))), INTERVAL 1 DAY) AND LAST_DAY(DATE_ADD(CURDATE(),INTERVAL -1 MONTH))
    AND FLOOR(DATEDIFF(NOW(),u.ptdob)/365.25) >= 18 AND e.doctorID = e.resourceID

        GROUP BY e.doctorID, id.value
        HAVING
        COUNT(e.patientid)>=2 OR
        id.value in ('Z00.00', 'Z00.01')

A: You dont need to include id.value in grp by clause. Try to give valid condition in having clause with id.value
select e.doctorID,
COUNT(distinct e.encounterID) as VisitCount from enc e join users u on e.patientID = u.uid
left join diagnosis d on e.encounterID = d.encounterID left join items it on
d.itemID = it.itemID left join itemdetail id on
it.itemID = id.itemID where e.encType = 1 and e.status ='CHK' and e.deleteFlag = 0 and
 e.date between DATE_ADD((LAST_DAY(DATE_ADD(CURDATE(), INTERVAL - 2 MONTH))), INTERVAL 1 DAY)
and LAST_DAY(DATE_ADD(CURDATE(), INTERVAL - 1 MONTH))
and
FLOOR(DATEDIFF(NOW(), u.ptdob) / 365.25) >= 18
and e.doctorID = e.resourceID group by e.doctorID
having COUNT(e.patientid) >= 2
or sum(case when id.value in ('Z00.00','Z00.01') then 1
else 0 end)>=1


text:
Q: how to implement sigma in haskell? i'm learning haskell and i'm trying to solve http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1098
i solved this problem using other language so i know the solution
answerTo(n, d) = func(n, d) - func(n, d - 1)

func(n, d) = Σ(func(k - 2, d -1) * func(n - k, d)) | 2 <= k <= n, k is even
func(0, d) = 1

and i need to implement func in haskell. i don't know how to.
func n d
    | n < 0 || d < 0 = 0
    | n == 0 && d >= 0 = 1
    | otherwise = --need to implement Σ(func (k - 2) (d -1)) * (func (n - k) d) | 2 <= k <= n, k is even

i solved in this way
func (n, d)
    | n == 0 && d >= 0 = 1
    | n < 0 || d < 0 = 0
    | otherwise = sum (zipWith (*) (map func arg1) (map func arg2))
    where
        arg1 = [(k - 2, d - 1) | k <- filter even [2..n]]
        arg2 = [(n - k, d) | k <- filter even [2..n]]

there are other solutions more graceful?

A: The Math.NumberTheory.Primes.Factorization module in the arithmoi package includes a σ function that may be the one you need, along with other related functions. You can click through to the source code for that function if you like.
Edit
Now that you've clarified what you mean, the answer is simple. You need to enumerate the values you need and then sum them. The easiest way to do this is using the sum function to sum a list that you create using a list comprehension:
func n d
    | n < 0 || d < 0 = 0
    | n == 0 && d >= 0 = 1
    | otherwise = sum [func (k - 2) (d - 1) * func (n - k) d | k <- [2,4..n]]


text:
Q: how to off Rotation in Nokia device N82? I want to lock Rotation functionality of Nokia N82 Device for my application.
Is there any attribute available for doing so?
How can i achieve this?
I have tried out Nokia-MIDlet-App-Orientation : portrait attribute. but cant get success.


text:
Q: How to open the latest downloaded file This is the code immediately before I get stuck:
#Start a new post
driver.find_element_by_xpath("//span[normalize-space()='Start a post']").click()
time.sleep(2)
driver.find_element_by_xpath("//li-icon[@type='image-icon']//*[name()='svg']").click()
time.sleep(2)

The above code works well. The next step though has me puzzled.
I would like to upload the latest image file from my downloads folder. When I click on the link above in LinkedIn it navigates to my user folder (Melissa). (see image)
So... I'm looking for the next lines of code to navigate from the default folder to the Downloads folder (C:\Users\Melissa\Downloads), then, select the newest file, then click 'open' so it attaches to the LinkedIn post.

A: You can upload the image using this method:
import getpass, glob, os

# Replace this with the code to get the upload input tag
upload_button = driver.find_element_by_xpath("//input[@type='file']")

# Get downloads
downloads = glob.glob("C:\\Users\\{}\\Downloads\\*".format(getpass.getuser()))

# Find the latest downloaded file
latest_download = max(downloads, key=os.path.getctime)

# Enter it into the upload input tag
upload_button.send_keys(latest_download)


text:
Q: Why udisks is not in the system In Ubuntu manual regarding AutomaticallyMountPartitions is described that Nautilus is using udisks to mount partitions. But when I type udisks in terminal system tells that I need to install it. So, do Nautilus really uses udisks?
"When you mount a disc normally with the file browser (nautilus etc) it mounts disks by interacting with udisks behind the scenes."

A: In Trusty udisks2 is installed by default and used by nautilus.
The binary is in
/usr/bin/udisksctl

found via dpkg -L udisks2 | grep bin/

from man udisksctl
NAME
       udisksctl - The udisks command line tool

SYNOPSIS
       udisksctl status

       udisksctl info {--object-path OBJECT | --block-device DEVICE}

       udisksctl mount {--object-path OBJECT | --block-device DEVICE} [--filesystem-type TYPE] [--options OPTIONS...] [--no-user-interaction]

       udisksctl unmount {--object-path OBJECT | --block-device DEVICE} [--force] [--no-user-interaction]

       udisksctl unlock {--object-path OBJECT | --block-device DEVICE} [--no-user-interaction]

       udisksctl lock {--object-path OBJECT | --block-device DEVICE} [--no-user-interaction]

       udisksctl loop-setup --file PATH [--read-only] [--offset OFFSET] [--size SIZE] [--no-user-interaction]

       udisksctl loop-delete {--object-path OBJECT | --block-device DEVICE} [--no-user-interaction]

       udisksctl power-off {--object-path OBJECT | --block-device DEVICE} [--no-user-interaction]

       udisksctl smart-simulate --file PATH {--object-path OBJECT | --block-device DEVICE} [--no-user-interaction]

       udisksctl monitor

       udisksctl dump

       udisksctl help

Here is a short test
% sudo apt-get remove udisks2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  arronax arronax-nautilus brasero deja-dup-backend-gvfs gnome-disk-utility
  gnome-shell-extensions gnome-sushi gvfs gvfs-backends gvfs-backends-goa
  gvfs-daemons gvfs-fuse nautilus nautilus-sendto nautilus-share software-center
  ubuntu-gnome-desktop udisks2 usb-creator-common usb-creator-gtk
0 upgraded, 0 newly installed, 20 to remove and 0 not upgraded.
After this operation, 20,9 MB disk space will be freed.
Do you want to continue? [Y/n]
% sudo apt-get remove udisks
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  udisks
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 1.043 kB disk space will be freed.
Do you want to continue? [Y/n]

A: I was using udisks to mount an NTFS partition on the same disk as the Operating System.  My command looked like this
/usr/bin/udisks --mount /dev/disk/by-uuid/

I used this command in 16.04 (mint 18):
udisksctl mount --block-device /dev/disk/by-uuid/