text:
Q: How to include subdirectories to autoload for Grape API? I'm using Grape to build an API for a Rails project (I'm mounting the grape project in rails routes.rb something like mount Backend::Base => '/').
The files structure is something like:

├── app
│   ├── api
│   │   └── backend
│   │       ├── base.rb
│   │       └── v1
│   │           ├── alerts.rb
│   │           ├── test
│   │           │   └── index.rb

My application.rb includes:
config.paths.add "app/api", glob: "**/*.rb"

config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]

For base.rb:
module Backend
  class Base < Grape::API

    format :json
    prefix :api

    mount CanopyBackend::V1::Alerts
    mount CanopyBackend::V1::Test::Index

  end
end

My alerts.rb:
module Backend
  module V1
    class Alerts < Grape::API
      include Backend::V1::Defaults

      resource :alerts do
        get do
          "alerts"
        end
      end
    end
  end
end

And test/index.rb:
module Backend
  module V1
    module Test
      class Index < Grape::API
        include Backend::V1::Defaults

        resource :index do
          get do
            "index"
          end
        end
      end

    end
  end
end

Now it seems I can access GET api/v1/alerts but not api/v1/test/index somehow.
I tried to modify config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')] in application.rb to make it config.autoload_paths += Dir[Rails.root.join('app', 'api', '/**/')] but without any luck.
Any help?


text:
Q: Fastest way of creating a pair-wise matching matrix from a single numpy array I want to do quick pair-wise matchings of all elements in a numpy array, ignoring self-matching.
For example given a numpy array like
a = np.array(range(4))

I want to get a matrix like
array([[0, 1],
       [0, 2],
       [0, 3],
       [1, 0],
       [1, 2],
       [1, 3],
       [2, 0],
       [2, 1],
       [2, 3],
       [3, 0],
       [3, 1],
       [3, 2]])

In my real case, I have different sizes of arrays varying from 1 to 1000. I need to constantly call a function that does this pair-wise matching. I wrote the code below
import numpy as np
from itertools import permutations

a = np.array(range(1000))
xs, ys = zip(*[(x, y) for x, y in permutations(a, 2)])
res = np.vstack([np.array(xs), np.array(ys)]).T
print(res)

I want to know if there are faster ways (maybe more numpyic ways) to do this?
I would like to see some benchmarkings of runtime vs. array size.

A: Making a meshgrid and then filtering out the "matching" rows (e.g. 0,0 and 12,12) would likely be quite a bit faster at this scale.
import numpy as np
from itertools import permutations

%%time
n = 1000
a = np.array(np.arange(n))
xs, ys = zip(*[(x, y) for x, y in permutations(a, 2)])
res = np.vstack([np.array(xs), np.array(ys)]).T
res
CPU times: user 1.08 s, sys: 176 ms, total: 1.26 s
Wall time: 1.28 s

%%time
n = 1000
a = np.arange(n)
arr = np.array(np.meshgrid(a, a)).T.reshape(-1,2)
arr = arr[arr[:, 0] != arr[:, 1]]
CPU times: user 49.8 ms, sys: 33.2 ms, total: 83 ms
Wall time: 89.2 ms

%%time
n = 2000
a = np.array(np.arange(n))
xs, ys = zip(*[(x, y) for x, y in permutations(a, 2)])
res = np.vstack([np.array(xs), np.array(ys)]).T
res
CPU times: user 3.94 s, sys: 924 ms, total: 4.86 s
Wall time: 5.03 s

%%time
n = 2000
a = np.arange(n)
arr = np.array(np.meshgrid(a, a)).T.reshape(-1,2)
arr = arr[arr[:, 0] != arr[:, 1]]
CPU times: user 218 ms, sys: 105 ms, total: 323 ms
Wall time: 328 ms

np.testing.assert_array_equal(res, arr) # passes

redpajama_set_name: RedPajamaStackExchange


text:
Q: Can I detect physical vs virtual magnetic field sensor on Android? The 'Moto E' devices do not have magnetic field sensors.  Yet they seem to emulate it using GPS.  But of course that only really works if you are moving.  I would prefer to know that it is doing that, so I could disable some functions, or warn the user.
I can't seem to find a way of doing it like you can with many other devices, because the sensor 'exists' even if emulated.
For that matter, this model also has no gyroscope.  Yet FusedSensors seem to work pretty well (although maybe not as well as on other devices).
Thanks for any input!
Dave

A: The idea of using: <uses-feature android:name="android.hardware.sensor.compass" android:required="true" />
in the manifest did not seem to have any effect at all.
However the following code did in fact work!
PackageManager manager = getPackageManager();
boolean hasCompass = manager.hasSystemFeature(PackageManager.FEATURE_SENSOR_COMPASS);
if (!hasCompass)
{
    Toast toast = Toast.makeText(this, "WARNING: DEVICE HAS NO COMPASS", Toast.LENGTH_LONG);
    toast.show();
}

I want to give credit for this to pointtofuture in the post [question]: How to make sure an android device application supports hardware feature
I should note that I tried this on the 'Moto E 2nd Gen' (No compass), and a Samsung Galaxy S7 Edge (has compass) and it was consistent.  The AndroidStudio emulators all showed as having a compass, but the emulator setup does not allow selection or de-selection of that hardware feature (It does for GPS and some others).  It would be nice if the emulators had compass emulation.
Dave


text:
Q: google maps multi marker info window not working I'm using Google Maps API on my web page. I'm try to add multiple markers to the page with info windows. The markers get added ok, but the info windows all have the info for the last marker. any ideas?
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
            <asp:ServiceReference Path="http://testserver/se1/WebServices/ShelterWebService.asmx" />
        </Services>
    </asp:ScriptManager>

                <asp:LinkButton ID="BtnHome" runat="server" onclick="BtnHome_Click">Home</asp:LinkButton>


text:
Q: changing div css at a specific page location I have the following code which puts a button fixed to the top of the page which overlays the content/images as the page scrolls.
HTML

button

... images ...

... content ...

css
#btn {
  position: fixed;
  z-index: 999;
  color: #fff;
  top: 0; right: 0;
}

I want to put an 'anchor' or something when the button reaches that point the #btn css changes to color: #000;
so essentially

button

... images ...

anchor changing the css

... content ...

EDIT: the amount of content and images is not controlled by me so I don't know the distance from the top or bottom

A: I think i have a javascript based solution for you.
I hope this will help
https://jsfiddle.net/n9ssbL8h/1/

window.onscroll=function(){
 if(document.getElementById('btn').getBoundingClientRect().top>= document.getElementById('header').getBoundingClientRect().top){
  document.getElementById('btn').style.color = '#fff';
  }else{
  document.getElementById('btn').style.color = '#000';
  }
}
#btn {
  position: fixed;
  z-index: 999;
  top: 0; right: 0;
}
#header{
  margin-top: 100px;
  height: 400px;
  background-color: red;
}
#content{
  height: 400px;
  background-color: green;
}

Button

Header

Content


text:
Q: React component with no data : condition in ParentComponent or return null in ChildComponent? I have a question regarding the best pattern (performance, lisibility, etc.) to use when there is no data to display inside a React component. Could you tell me what you think is the best option and why ?
OPTION 1
Check if there's data inside ParentComponent before calling ChildComponent (with data props).
// Parent component

{data.length > 0 && (
    <ChildComponent data={data} />
)}

OPTION 2
No check inside ParenComponent, but return null inside ChildComponent if there's no data.
// Child component

if (!data.length) {
    return null;
}

return (

List

{data.map((item) =>
{item.name}
)}

)

A: I'd say 1 option will be more performant, because in that case we don't create a Node inside React VDOM tree - we create it only when it's needed. In the second case we create a node (function call createElement under the hood of React), and then render nothing.
But there are not very much difference in the performance between these 2 approaches to be honest: probably we can win more in the code readability and declarativeness in the 2 option (of course if you don't have some heavy calculations before return)


text:
Q: nodejs how I can find out how old a Domain is? I want to check how old a domain is.
With whois it works only with .com sites (npm install whois)
But German sites like test.de do not work.
const whois = require('whois');

const data = async domain => {
      const data = await whois(domain);

      return console.log(data);
  }

   console.log(data('web.de'));


text:
Q: Palavra quebrar linha na coluna do Bootstrap Estou tentando fazer uma quebra de linha em um span ou em qualquer outra tag.
A ideia é que se o usuário digitar apenas uma palavra e ocupar mais espaço que a coluna, essa palavra quebre pra próxima linha.
Abaixo um exemplo do que está acontecendo utilizando o span, se eu tenho uma palavra muito grande não quebra a linha e ultrapassa a coluna:

<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Exemplo</title>
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>

           TesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTe steTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTeste

Alguém sabe alguma solução?

A: Então Julio, neste caso podemos utilizar a propriedade e valor: word-wrap: break-word;, junto na sua classe que o span irá utilizar.
Essa propriedade irá fazer a quebra de linha em seu texto.
Por exemplo:
CSS
 span {
  word-wrap: break-word
 }

HTML

     TesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTe steTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTesteTeste


text:
Q: Excluding "provided" scope dependencies during "test" execution phase? I'm seeing a jar with provided scope in my classpath during test execution. Given the definition of the provided scope, I would not expect that jar to appear on the classpath during any execution phase.
I've confirmed that the scope is correct using the M2E "Dependency Hierarchy" view. I've already tried using the classpathDependencyScopeExclude option in maven-surefire-plugin to keep the dependency from showing up, and it hasn't worked:
<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.14.1</version>
        <configuration>
          <!--
            We always want to exclude provided deps. I'm not sure why this
            isn't the default.
          -->
          <classpathDependencyScopeExclude>provided</classpathDependencyScopeExclude>
        </configuration>
      </plugin>
    </plugins>
  </pluginManagement>
</build>

Here is the dependency definition in question:
Parent POM:
<dependency>
  <groupId>javax.ws.rs</groupId>
  <artifactId>jsr311-api</artifactId>
  <version>1.1.1</version>
</dependency>

Module POM:
<dependency>
  <groupId>javax.ws.rs</groupId>
  <artifactId>jsr311-api</artifactId>
  <scope>provided</scope>
</dependency>

Is it normal that the jar is there? What can I do to keep it from showing up?
EDIT: I've run mvn dependency:tree on the parent POM. Here's the output for the project in question:
[INFO] ------------------------------------------------------------------------
[INFO] Building sibyl.transport.impl.http.server 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ sibyl.transport.impl.http.server ---
[INFO] com.sigpwned.analytics:sibyl.transport.impl.http.server:jar:0.0.1-SNAPSHOT
[INFO] +- com.sigpwned.analytics:sibyl.transport:jar:0.0.1-SNAPSHOT:compile
[INFO] +- com.sigpwned.analytics:commons:jar:0.0.1-SNAPSHOT:compile
[INFO] +- javax.ws.rs:jsr311-api:jar:1.1.1:provided
[INFO] +- com.sun.jersey:jersey-server:jar:1.17.1:test (scope not updated to compile)
[INFO] |  +- asm:asm:jar:3.1:test
[INFO] |  \- com.sun.jersey:jersey-core:jar:1.17.1:test
[INFO] +- com.sun.jersey:jersey-servlet:jar:1.17.1:compile
[INFO] +- org.eclipse.jetty:jetty-servlet:jar:9.0.3.v20130506:test
[INFO] |  \- org.eclipse.jetty:jetty-security:jar:9.0.3.v20130506:test
[INFO] |     \- org.eclipse.jetty:jetty-server:jar:9.0.3.v20130506:test
[INFO] |        +- org.eclipse.jetty.orbit:javax.servlet:jar:3.0.0.v201112011016:test
[INFO] |        +- org.eclipse.jetty:jetty-http:jar:9.0.3.v20130506:test
[INFO] |        |  \- org.eclipse.jetty:jetty-util:jar:9.0.3.v20130506:test
[INFO] |        \- org.eclipse.jetty:jetty-io:jar:9.0.3.v20130506:test
[INFO] +- com.sigpwned.analytics:sibyl.transport.impl.http.client:jar:0.0.1-SNAPSHOT:test
[INFO] |  \- org.apache.httpcomponents:httpclient:jar:4.2.5:test
[INFO] |     +- org.apache.httpcomponents:httpcore:jar:4.2.4:test
[INFO] |     +- commons-logging:commons-logging:jar:1.1.1:test
[INFO] |     \- commons-codec:commons-codec:jar:1.6:test
[INFO] \- junit:junit:jar:4.11:test
[INFO]    \- org.hamcrest:hamcrest-core:jar:1.3:test

Again, the jar with provided scope that I expect not to show up on the classpath but does is the JAX-RS spec API, shown above as javax.ws.rs:jsr311-api:jar:1.1.1:provided. I believe this confirms that this dependency only appears in the provided scope.
EDIT: If I run the test, here is the command line that gets run (from ps):
sigpwned       11771   0.0  1.2  4019788 100240   ??  S    10:58PM   0:05.92 /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:59974 -Dfile.encoding=UTF-8 -classpath /Users/aboothe/Documents/workspaces/w2oanalytics/sibyl.transport.impl.http.server/target/test-classes:/Users/aboothe/Documents/workspaces/w2oanalytics/sibyl.transport.impl.http.server/target/classes:/Users/aboothe/Documents/workspaces/w2oanalytics/sibyl/sibyl.transport/target/classes:/Users/aboothe/Documents/workspaces/w2oanalytics/commons/target/classes:/Users/aboothe/.m2/repository/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar:/Users/aboothe/.m2/repository/com/sun/jersey/jersey-server/1.17.1/jersey-server-1.17.1.jar:/Users/aboothe/.m2/repository/asm/asm/3.1/asm-3.1.jar:/Users/aboothe/.m2/repository/com/sun/jersey/jersey-core/1.17.1/jersey-core-1.17.1.jar:/Users/aboothe/.m2/repository/com/sun/jersey/jersey-servlet/1.17.1/jersey-servlet-1.17.1.jar:/Users/aboothe/.m2/repository/org/eclipse/jetty/jetty-servlet/9.0.3.v20130506/jetty-servlet-9.0.3.v20130506.jar:/Users/aboothe/.m2/repository/org/eclipse/jetty/jetty-security/9.0.3.v20130506/jetty-security-9.0.3.v20130506.jar:/Users/aboothe/.m2/repository/org/eclipse/jetty/jetty-server/9.0.3.v20130506/jetty-server-9.0.3.v20130506.jar:/Users/aboothe/.m2/repository/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar:/Users/aboothe/.m2/repository/org/eclipse/jetty/jetty-http/9.0.3.v20130506/jetty-http-9.0.3.v20130506.jar:/Users/aboothe/.m2/repository/org/eclipse/jetty/jetty-util/9.0.3.v20130506/jetty-util-9.0.3.v20130506.jar:/Users/aboothe/.m2/repository/org/eclipse/jetty/jetty-io/9.0.3.v20130506/jetty-io-9.0.3.v20130506.jar:/Users/aboothe/Documents/workspaces/w2oanalytics/sibyl.transport.impl.http.client/target/classes:/Users/aboothe/.m2/repository/org/apache/httpcomponents/httpclient/4.2.5/httpclient-4.2.5.jar:/Users/aboothe/.m2/repository/org/apache/httpcomponents/httpcore/4.2.4/httpcore-4.2.4.jar:/Users/aboothe/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/aboothe/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar:/Users/aboothe/.m2/repository/junit/junit/4.11/junit-4.11.jar:/Users/aboothe/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/Users/aboothe/Downloads/eclipse/configuration/org.eclipse.osgi/bundles/350/1/.cp/:/Users/aboothe/Downloads/eclipse/configuration/org.eclipse.osgi/bundles/349/1/.cp/ org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 59973 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames com.sigpwned.analytics.sibyl.transport.impl.http.server.HttpServerTransportTests

If you pull out the classpath, here's what that looks like:
/Users/sigpwned/Documents/workspaces/siganalytics/sibyl.transport.impl.http.server/target/test-classes
/Users/sigpwned/Documents/workspaces/siganalytics/sibyl.transport.impl.http.server/target/classes
/Users/sigpwned/Documents/workspaces/siganalytics/sibyl/sibyl.transport/target/classes
/Users/sigpwned/Documents/workspaces/siganalytics/commons/target/classes
/Users/sigpwned/.m2/repository/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar
/Users/sigpwned/.m2/repository/com/sun/jersey/jersey-server/1.17.1/jersey-server-1.17.1.jar
/Users/sigpwned/.m2/repository/asm/asm/3.1/asm-3.1.jar
/Users/sigpwned/.m2/repository/com/sun/jersey/jersey-core/1.17.1/jersey-core-1.17.1.jar
/Users/sigpwned/.m2/repository/com/sun/jersey/jersey-servlet/1.17.1/jersey-servlet-1.17.1.jar
/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-servlet/9.0.3.v20130506/jetty-servlet-9.0.3.v20130506.jar
/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-security/9.0.3.v20130506/jetty-security-9.0.3.v20130506.jar
/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-server/9.0.3.v20130506/jetty-server-9.0.3.v20130506.jar
/Users/sigpwned/.m2/repository/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar
/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-http/9.0.3.v20130506/jetty-http-9.0.3.v20130506.jar
/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-util/9.0.3.v20130506/jetty-util-9.0.3.v20130506.jar
/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-io/9.0.3.v20130506/jetty-io-9.0.3.v20130506.jar
/Users/sigpwned/Documents/workspaces/siganalytics/sibyl.transport.impl.http.client/target/classes
/Users/sigpwned/.m2/repository/org/apache/httpcomponents/httpclient/4.2.5/httpclient-4.2.5.jar
/Users/sigpwned/.m2/repository/org/apache/httpcomponents/httpcore/4.2.4/httpcore-4.2.4.jar
/Users/sigpwned/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
/Users/sigpwned/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
/Users/sigpwned/.m2/repository/junit/junit/4.11/junit-4.11.jar
/Users/sigpwned/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
/Users/sigpwned/Downloads/eclipse/configuration/org.eclipse.osgi/bundles/350/1/.cp/
/Users/sigpwned/Downloads/eclipse/configuration/org.eclipse.osgi/bundles/349/1/.cp/

EDIT: After investigating the classpathDependencyScopeExclude documentation, I determined that you can only exclude compile, runtime, and test dependencies, not provided. This explains why that functionality doesn't work. After trying the suggestion from @hello below, I've determined that classpathDependencyExclude works when running directly with maven. Here's the classpath that I ripped out of the surefire jar's MANIFEST:
  file:/Users/sigpwned/.m2/repository/org/apache/maven/surefire/surefire-booter/2.14.1/surefire-booter-2.14.1.jar
  file:/Users/sigpwned/.m2/repository/org/apache/maven/surefire/surefire-api/2.14.1/surefire-api-2.14.1.jar
  file:/Users/sigpwned/Documents/workspaces/siganalytics/sibyl/sibyl.transport.impl.http.server/target/test-classes/
  file:/Users/sigpwned/Documents/workspaces/siganalytics/sibyl/sibyl.transport.impl.http.server/target/classes/
  file:/Users/sigpwned/.m2/repository/com/siggroup/analytics/sibyl.transport/0.0.1-SNAPSHOT/sibyl.transport-0.0.1-SNAPSHOT.jar
  file:/Users/sigpwned/.m2/repository/com/siggroup/analytics/commons/0.0.1-SNAPSHOT/commons-0.0.1-SNAPSHOT.jar
  file:/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-server/9.0.3.v20130506/jetty-server-9.0.3.v20130506.jar
  file:/Users/sigpwned/.m2/repository/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar
  file:/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-http/9.0.3.v20130506/jetty-http-9.0.3.v20130506.jar
  file:/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-util/9.0.3.v20130506/jetty-util-9.0.3.v20130506.jar
  file:/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-io/9.0.3.v20130506/jetty-io-9.0.3.v20130506.jar
  file:/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-servlet/9.0.3.v20130506/jetty-servlet-9.0.3.v20130506.jar
  file:/Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-security/9.0.3.v20130506/jetty-security-9.0.3.v20130506.jar
  file:/Users/sigpwned/.m2/repository/com/sun/jersey/jersey-server/1.17.1/jersey-server-1.17.1.jar
  file:/Users/sigpwned/.m2/repository/asm/asm/3.1/asm-3.1.jar
  file:/Users/sigpwned/.m2/repository/com/sun/jersey/jersey-core/1.17.1/jersey-core-1.17.1.jar
  file:/Users/sigpwned/.m2/repository/com/sun/jersey/jersey-servlet/1.17.1/jersey-servlet-1.17.1.jar
  file:/Users/sigpwned/.m2/repository/com/siggroup/analytics/sibyl.transport.impl.http.client/0.0.1-SNAPSHOT/sibyl.transport.impl.http.client-0.0.1-SNAPSHOT.jar
  file:/Users/sigpwned/.m2/repository/org/apache/httpcomponents/httpclient/4.2.4/httpclient-4.2.4.jar
  file:/Users/sigpwned/.m2/repository/org/apache/httpcomponents/httpcore/4.2.4/httpcore-4.2.4.jar
  file:/Users/sigpwned/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
  file:/Users/sigpwned/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
  file:/Users/sigpwned/.m2/repository/com/siggroup/analytics/sibyl.transport/0.0.1-SNAPSHOT/sibyl.transport-0.0.1-SNAPSHOT-tests.jar
  file:/Users/sigpwned/.m2/repository/junit/junit/4.11/junit-4.11.jar
  file:/Users/sigpwned/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar

Notice that jsr311-api.jar is not present. Success! Here's the configuration that worked:
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>${maven-surefire-plugin.version}</version>
  <configuration>
    <!--
      We never want to include these API deps on an execution classpath.
      I would think this is how the "provided" scope works - just
      compile against the jar, and then I'll bring it myself at
      execution time - but provided is only excluded during the runtime
      phase, not the testing phase. So, we have to exclude all our
      API JARs by hand.
    -->
    <classpathDependencyExcludes>
      <classpathDependencyExclude>javax.ws.rs:jsr311-api</classpathDependencyExclude>
    </classpathDependencyExcludes>
    <includes>
      <include>**/*Tests.*</include>
    </includes>
  </configuration>
</plugin>

However, this solution does not seem to work on M2E. Here's the classpath I've pulled out from a ps during test execution using M2E:
  /Users/sigpwned/Documents/workspaces/siganalytics/sibyl/sibyl.transport.impl.http.server/target/test-classes
  /Users/sigpwned/Documents/workspaces/siganalytics/sibyl/sibyl.transport.impl.http.server/target/classes
  /Users/sigpwned/Documents/workspaces/siganalytics/sibyl/sibyl.transport/target/classes
  /Users/sigpwned/Documents/workspaces/siganalytics/commons/target/classes
> /Users/sigpwned/.m2/repository/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar
  /Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-server/9.0.3.v20130506/jetty-server-9.0.3.v20130506.jar
  /Users/sigpwned/.m2/repository/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar
  /Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-http/9.0.3.v20130506/jetty-http-9.0.3.v20130506.jar
  /Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-util/9.0.3.v20130506/jetty-util-9.0.3.v20130506.jar
  /Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-io/9.0.3.v20130506/jetty-io-9.0.3.v20130506.jar
  /Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-servlet/9.0.3.v20130506/jetty-servlet-9.0.3.v20130506.jar
  /Users/sigpwned/.m2/repository/org/eclipse/jetty/jetty-security/9.0.3.v20130506/jetty-security-9.0.3.v20130506.jar
  /Users/sigpwned/.m2/repository/com/sun/jersey/jersey-server/1.17.1/jersey-server-1.17.1.jar
  /Users/sigpwned/.m2/repository/asm/asm/3.1/asm-3.1.jar
  /Users/sigpwned/.m2/repository/com/sun/jersey/jersey-core/1.17.1/jersey-core-1.17.1.jar
  /Users/sigpwned/.m2/repository/com/sun/jersey/jersey-servlet/1.17.1/jersey-servlet-1.17.1.jar
  /Users/sigpwned/Documents/workspaces/siganalytics/sibyl/sibyl.transport.impl.http.client/target/classes
  /Users/sigpwned/.m2/repository/org/apache/httpcomponents/httpclient/4.2.4/httpclient-4.2.4.jar
  /Users/sigpwned/.m2/repository/org/apache/httpcomponents/httpcore/4.2.4/httpcore-4.2.4.jar
  /Users/sigpwned/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
  /Users/sigpwned/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
  /Users/sigpwned/Documents/workspaces/siganalytics/sibyl/sibyl.transport/target/test-classes
  /Users/sigpwned/.m2/repository/junit/junit/4.11/junit-4.11.jar
  /Users/sigpwned/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
  /Users/sigpwned/Downloads/eclipse/configuration/org.eclipse.osgi/bundles/350/1/.cp/
  /Users/sigpwned/Downloads/eclipse/configuration/org.eclipse.osgi/bundles/349/1/.cp/

Unfortunately, jsr311-api.jar is still there. This leads me to believe that this question is answered (with that answer being "use classpathDependencyExcludes"), but there's a bug in M2E. I ran "Check for Updates" in Eclipse and found no update for M2E, so I should be running the latest stable release. I'll file a bug on M2E and update with the issue here so anyone who finds this issue can track.
EDIT: This issue was already raised with M2E, and the answer appears to be "Surefire integration is outside the scope of M2E at this time." Not encouraging. :/

A:
Given the definition of the provided scope, I would not expect that jar to appear on the classpath during any execution phase.

This is not quite the behaviour of provided scope; see Dependency Scope. provided scope, in common with compile, is for classes that are necessary to compile and test your classes. If they were missing during test then you would have a NoClassDefFoundError.
The difference comes during packaging and deployment, where these artifacts are omitted from wars under the assumption that your target environment (for example, a servlet container) will provide its own copy of the same classes.


text:
Q: How do I avoid "USING INDEX CONDITION" on MySQL query I have a MySQL query on which I believe I already have all the indexes and so I would expect the query to be processed instantly. However, the query takes several seconds to finish. Using EXPLAIN shows the query uses INDEX CONDITION:
+----+-------------+-------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------+-----------+---------+-------------------+------+----------------------------------------------+
| id | select_type | table | type     | possible_keys                        | key       | key_len | ref               | rows | Extra                                        |
+----+-------------+-------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------+-----------+---------+-------------------+------+----------------------------------------------+
|  1 | SIMPLE      | il    | fulltext | PRIMARY,FK32F0579FBAF38C6F,name_ftx  | name_ftx  | 0       | NULL              |    1 | Using where; Using temporary |
|  1 | SIMPLE      | i     | eq_ref   | PRIMARY,FK5C6729AF5D52323,...        | PRIMARY   | 8       | goout.il.thing_id |    1 | Using where                                  |
|  1 | SIMPLE      | s     | ref      | state,event_id,parent_id             | parent_id | 9       | const             |    5 | Using index condition; Using where; Distinct |
+----+-------------+-------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------+-----------+---------+-------------------+------+----------------------------------------------+

Please notice the third row which uses this INDEX CONDITION. Is there a way to find what causes it?
SELECT DISTINCT i.id
FROM event i
JOIN event_locale il ON i.id = il.thing_id
LEFT JOIN event_schedule s ON i.id = s.event_id
WHERE (i.parent_id IS NULL)
      AND (s.state = 2 OR s.state = 3)
      AND s.parent_id IS NULL
      AND (i.state = 2 OR i.state = 3)
      AND (MATCH(il.name) AGAINST ("jan"))
LIMIT 10;

I am positive I have indexes on all used columns and fulltext index on the match-against column.


text:
Q: Scanning a larger text with white spaces between lines I'm completely stuck having tried for hours.
Say I want to scan in a program, e.g.
 // my  program in C++

#include <iostream>
/** playing around in
a new programming language **/
using namespace std;

int main ()
{
  cout << "Hello World";
  cout << "I'm a C++ program"; //use cout
  return 0;
}

I want to go through this input and save it in an ArrayList<String>
Here is my code:
public static void main(String[] args) {
        ArrayList<String> testCase = new ArrayList<String>();
        int count = 0;
        Scanner s = new Scanner(System.in);
        testCase.add(s.nextLine());
        while (s.hasNext() && s.next().length() > 1) {
            testCase.add(s.nextLine());
        }

        System.out.println("\n\n\n\n----------------Output from loop------------------");
        for (String tc : testCase) {
            System.out.println(tc);
        }
    }

This outputs:
----------------Output from loop------------------
 // my  program in C++
 <iostream>
 playing around in

The scanning is supposed to stop if 2 blank lines occur in a row.
Any help is greatly appreciated.

A: The problem in your code is that you're using s.next() in your condition. This methods consumes the next token, which cannot be consumed anymore.
I don't know what s.next().length() > 1 is meant to check, but if you remove that part of the condition, you will consume every line without any issue.
The following code will scan every line, and stop whenever two consecutive empty lines are met :
public static void main(String[] args) throws Exception {
    System.setIn(new FileInputStream("C:\\Users\\Simon\\Desktop\\a.txt"));
    ArrayList<String> testCase = new ArrayList<String>();
    int emptyLines = 0;
    String line;
    Scanner s = new Scanner(System.in);
    testCase.add(s.nextLine());
    while (s.hasNext() && emptyLines < 2) {
        line = s.nextLine();
        if (line.isEmpty()) {
            emptyLines++;
        } else {
            emptyLines = 0;
        }
        testCase.add(line);
    }

    System.out.println("\n\n\n\n----------------Output from loop------------------");
    for (String tc : testCase) {
        System.out.println(tc);
    }
}


text:
Q: Euro symbol doesn't display in dompdf generated pdf I'm using the dompdf library to generate a pdf. I need to output an euro symbol (€) but it shows just a square. I tried using both directly the symbol or the code € and I'm using the font family like this:
    font-family: Arial, "Helvetica", Arial, "Liberation Sans", sans-serif;

And I put this in the :
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

It is working fine on a Mac, but not on Linux.

A: Based on your font family dompdf will use Helvetica as the font for the text in question. Currently dompdf (up to v0.6.0) only supports Windows ANSI encoding for the core PDF fonts (of which Helvetica is one). In Windows ANSI the euro symbol is at position 128, so you might try €. This is most relevant for v0.5.1 which does not handle characters outside the Windows ANSI character set very well.
Starting in v0.6.0 dompdf works natively using UTF8. It also does a lot more work to ensure that character encoding is handled carefully. This is particularly important to avoid problems when moving from one character set to another, such as from the internal UTF8 encoding to Windows ANSI for the core PDF fonts.

A: Try replacing the € symbol with
€  €  €


text:
Q: PowerShell Script Running as a Service Behaves Strangely PowerShell Script Running as a Service Behaves Strangely
The Project:
Create a background process that determines if the on board network card is connected. If it is connected, disable the wireless network card. When the onboard network card is not connected, re-enable the wireless card.
Why:
Users hot-dock all the time, getting funky routing tables OR get bound to the wrong DNS servers. When they attempt to access a local resource, say printers, they aren't able to and then are in my cube (they would file a ticket, but that too would be a local resource). Trying to convince users to disable their own wireless (via switch on laptop) or not hot dock has met with limited success.
The Problem:
The PowerShell script below does run, and does work under my testing conditions. Likely under most testing conditions as the code and wmi queries are pretty generic. Running the script manually yields the expected results, HOWEVER running the script as a service via the only method I could find, srvany.exe, yielded unexpected results and "broke stuff".
Details:
Running the script as a service, via srvany.exe, works ONCE. When the loop comes back around to test the network connection or tries the method to enable or disable it. The errors indicate that "get-wmiobject" is not a proper Cmdlet. Huh? It works, manually, it works once, but a second time after it disabled the wireless network card it does not. Worse yet MY shell , outside of the service, suddenly can't do a get-wmiobject, until…. until you go into Device Manager and re-enable the wireless network card yourself.
Debugging attempts:
I rewrote the script and cleaned it up a little to allow for it to get the objects outside of the Do While loop. Nothing changed, but I left the script that way as it seems cleaner anyhow. I enabled "Interact with Desktop" in the service properties and sure enough you can see the script trying to work and getting the before mentioned errors.
Please help. Again the object here is to run a background process, one with enough privileges in Vista or 7 to disable and enable the wireless network card.
#***********************************************************************
# "switch-wifi-srv.ps1"
# This script attempts  to identify if a wired network card is in use if
# one is, the Wireless network card is disabled, until the wired network
# card is no longer in use.
#
# Written by Aaron Wurthmann - aaron (AT) wurthmann (DOT) com
#
# 2010.02.10 ver 2 (Service Version)
# If you edit please keep my name or at the very least original author's.
# As of this writing I am unsure if script will work with all scenarios,
# however it has worked for me on Dell laptops running Windows 7 x64.
# -----------------------------------------------------------------------
# This script comes with ABSOLUTELY NO WARRANTY.
# You may redistribute copies of the script under
# the terms of the GNU General Public License.
# -----------------------------------------------------------------------
# Service Installation:
# Aquire and install the Windows 2003 Resource Kit OR the srvany.exe.
# Use sc.exe and srvany.exe to create a service....
#   sc create SwitchWifiAuto binPath= "C:\Program Files (x86)\Windows Resource Kits\Tools\srvany.exe" DisplayName= "Switch Wifi Automatically"
# Edit registry entry for SwitchWifiAuto, add a key and a string value...
#   HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SwitchWifiAuto\Parameters]
#   "Application"="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy RemoteSigned -File C:\\SwitchWifiAuto\\switch-wifi-srv.ps1"
#************************************************************************

$state=""
$wireStatus=""
$wifiStatus=""

# Get Wired and Wireless Card Objects
$objWire=get-wmiobject -class win32_networkadapter -namespace root\CIMV2 | Where-Object {$_.Name -notmatch "Wireless" -and $_.Name -notmatch "Virtual" -and $_.PhysicalAdapter -eq "True"}
$objWifi=get-wmiobject -class win32_networkadapter -namespace root\CIMV2 | where-object {$_.Name -match "Wireless"}

# Get Name of Service to be Used in totally useless Do While Loop
$objService=get-service -display "Switch Wifi Automatically"

# Begin Do While Loop
Do {
#   Get status of wired network card. If enabled and connected set $state to Disable (which will later Disable the Wifi network card)
    [string]$wireStatus=$objWire | % {$_.NetEnabled}
    if($wireStatus -eq "True") {
        $state="Disable"
    }
#   Get Status of wireless card.
    if($objWifi){
        [string]$wifiStatus=$objWifi | % {$_.NetEnabled}
#       If $state is not set to disable and if the wireless card is currently disabled, enable it.
        if($state -ne "Disable") {
            if($wifiStatus -eq "False") {
                Out-Null -InputOject ($objWifi | % {$_.Enable()})
            }
#       If $state is set to Disable and if wireless card is currently enabled, disable it.
        } else {
            if($wifiStatus -eq "True") {
                Out-Null -InputOject ($objWifi | % {$_.Disable()})
            }
        }
    }

# Reset Checked Variables for good measure
$state=""
$wireStatus=""
$wifiStatus=""

# Sleep for 120 seconds (two minutes)
Start-Sleep -s 120

# Continuing looping (do while) until the service is not running.
# This is of course technically useless as when the service is not running neither is the script to check if the service is not running.
# I made it this way however because I don't like infinite loops and I thought it would be funny to it this way instead of while $var=0
} while ($objService.Status -eq "Running")

A: Try to remove any output. Service don't have stdout stream. And when the buffer is full strange thing happens. Just a guess ( I never used powershell ).

A:
Debugging attempts: I rewrote the script and cleaned it up a little to
  allow for it to get the objects outside of the Do While loop.

You need to include these within the loop or you will not get updated values and the loop will do nothing.


text:
Q: How to use a loop to create an object with keys from a list in typescript without using `Partial`? Overview
Im trying to create an initialise an object with known keys, however the initial empty object {} that I need breaks my typing.
The problem:
I have a list of value, that I want to use as keys, and I want to initialise an object with those keys. In python i would do something like:
myDict = {key: value for (key, value) in zip(myKeys, [[]]*len(myKeys))}

This should give the myDict the type Record<myKeys, string[]>
In TS, i dont seem to be able to have the same luck, as i need to initialise the object to an empty list before i can populate it with my keys/values. I would rather not need to call it a partial, then coerce it into the correct type.
what ive tried:
I have tried:

    const allPlanFeatures: Partial<Record<ExtensivePlanHandle, string[]>> = {};
    for (const planId of extensivePlanList) {
        const features = getFeaturesForPlan(planHandleToMonthly[planId], is4kEnabled, exportFlow);
        allPlanFeatures[planId] = features;
    }
    return allPlanFeatures as Record<ExtensivePlanHandle, string[]>;

and
 const allPlanFeatures: Partial<Record<ExtensivePlanHandle, string[]>> =
        extensivePlanList.reduce(
            (a, planHandle) => ({
                ...a,
                [planHandle]: getFeaturesForPlan(
                    planHandleToMonthly[planHandle],
                    is4kEnabled,
                    exportFlow
                ),
            }),
            {}
        );
    return allPlanFeatures as Record<ExtensivePlanHandle, string[]>;

These do end up with the desired effect at the end of the day, but I'd rather be able to not have this partially working middle

A: You can try this:
const allPlanFeatures: Record<ExtensivePlanHandle, string[]> = {} as Record<ExtensivePlanHandle, string[]>;

this is not perfect, but sometimes you need to tell typescript compiler what is right.


text:
Q: Keyup not firing I have been working with the Keyup method of jQuery and it doesn't seem to work for me. I went to create this on Jfiddle and sure enough it works there. But when upload it to a website or run it locally it does not work. What am I doing wrong here?
<html>
  <head>
    <title>Untitled Document</title>
    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
    <script>
      $('#TAcomments').keyup(function() {
        var textCount = $(this).val().length;
        if(textCount <= 10) {
          $('#TAcomments').stop().animate({ fontSize : '22px' });
        }
        if(textCount > 10) {
          $('#TAcomments').stop().animate({ fontSize : '16px' });
        }
        if(textCount > 20) {
          $('#TAcomments').stop().animate({ fontSize : '14px' });
        }
        if(textCount > 30) {
          $('#TAcomments').stop().animate({ fontSize : '10px' });
        }
      });
    </script>
  </head>
  <body>
    <textarea id="TAcomments" style="width: 400px; height: 300px; font-size: 22px;"></textarea>
  </body>
</html>

A: You need to wait until the document is ready.
$(document).ready(function(){
    $('#TAcomments').keyup(function() {
        var textCount = $(this).val().length;
        if(textCount <= 10) {
            $('#TAcomments').stop().animate({ fontSize : '22px' });
        }
        if(textCount > 10) {
           $('#TAcomments').stop().animate({ fontSize : '16px' });
        }
        if(textCount > 20) {
           $('#TAcomments').stop().animate({ fontSize : '14px' });
        }
        if(textCount > 30) {
           $('#TAcomments').stop().animate({ fontSize : '10px' });
        }
    });
});

jsfiddle defaults to running code after the onload event.

A: You need to wrap the code in the script in $(function () { /* ... */ });  You can see that the code works here when it is ran in onDomReady.


text:
Q: What is the chronology of estimating OLS coefficients? In a simple linear regression, Deriving OLS estimators by maximum likelihood principle (shown in this link
Derivation of OLS Estimator) takes the form

Does this mean that coefficient estimates are dependant on other coefficients; therefore chronology matters?

*

*If no, how do I solve for b0 and b1 from the above equations?

*If yes, which coefficient gets estimated first?
(Is it the intercept first followed by predictor estimates? or other way round?
Also within the 'predictor coefficients' does order matter?,If yes: which one gets estimated first?)

(I believe the matrix form i.e. normal equation used in OLS suggests that any coefficient estimate is dependant on 'other predictors' but not their 'beta values'. So chronology shouldn't matter)

A: What you have here is a set of two simultaneous equations with two unknowns.  Assuming that the explanatory variable in the regression is not constant (so that the design matrix has linearly independent columns), these equations have unique explicit solutions.  (The solution for the slope coefficient is given in the linked notes you gave.)  The explicit forms for the coefficients are:
$$\begin{align}
\hat{\beta}_0 &= \bar{y} - \frac{\sum (x_i-\bar{x})(y_i-\bar{y})}{\sum (x_i-\bar{x})^2} \cdot \bar{x}, \\[10pt]
\hat{\beta}_1 &= \frac{\sum (x_i-\bar{x})(y_i-\bar{y})}{\sum (x_i-\bar{x})^2}. \\[6pt]
\end{align}$$
Since either coefficient can be computed directly from the underlying data, there is no particular need to compute one of these coefficients before the other.  Since the intercept coefficient has a simple form in terms of the slope coefficient, it is usually simpler to compute the slope coefficient first, but this is not a necessity.

A: Coefficient estimates depend on which independent variables (i.e. the $x_i$'s) you include in your regression (not the coefficients explicitly). Which independent variables you include impacts how the 'terrain' of the cost function (i.e. the error sum of squares) looks, and hence where the minimum of the cost function occurs.
The parameters are estimated jointly. This means you estimate them all at the same time. When you estimate a regression equation with software, a gradient based method traverses the terrain of the cost function, updating the estimates all at the same time while it looks for the minimum. One coefficient isn't estimated before another. It all happens at the same time.


text:
Q: How to dismis Viewcontroller (popup) by pressing button inside my popup viewcontroller and also touch any where outside of viewcontroller? I have one viewcontroler with one button.When i press that one pop up viewcontroller will show up.And when i touch anywhere outside it dismiss the viewcontroller .And return to my main viewcontroller.
Note
I used my popup through one viewcontroller and i use identifier name .Then i show pop up using that storyboard identifier and declared in my viewcontroller.m in btnSelectDatePressed
Needed
in that pop up view controller i have one button when user press also it should dismiss the viewcontroller and should return to my main viewcontroller.My example image is like this sample image
This is my viewcontroller.m file
#import "ViewController.h"
#import "UIViewController+ENPopUp.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

}
- (IBAction)btnSelectDatePressed:(id)sender
{

    UIViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"PopUp"];
    vc.view.frame = CGRectMake(0, 0, 309.0f, 531.0f);
    [self presentPopUpViewController:vc];

}

This is my popup method declared in #import "UIViewController+ENPopUp.h"
    #import <UIKit/UIKit.h>

    @interface UIViewController (ENPopUp)

    @property (nonatomic, retain) UIViewController *en_popupViewController;
    - (void)presentPopUpViewController:(UIViewController *)popupViewController;
    - (void)presentPopUpViewController:(UIViewController *)popupViewController completion:(void (^)(void))completionBlock;
    - (void)dismissPopUpViewController;
    - (void)dismissPopUpViewControllerWithcompletion:(void (^)(void))completionBlock;
    //- (IBAction)disMe:(id)sender;

    @end

This is my popup method declared in `#import "UIViewController+ENPopUp.m"`

#import "UIViewController+ENPopUp.h"
#import "JWBlurView.h"
#import <objc/runtime.h>

static void * ENPopupViewControllerPropertyKey = &ENPopupViewControllerPropertyKey;

static CGFloat const kAnimationDuration = .4f;
static CGFloat const kRotationAngle = 70.f;

static NSInteger const kENPopUpOverlayViewTag   = 351301;
static NSInteger const kENPopUpViewTag          = 351302;
static NSInteger const kENPopUpBluredViewTag    = 351303;

@implementation UIViewController (ENPopUp)

#pragma mark - Public Methods
- (void)presentPopUpViewController:(UIViewController *)popupViewController
{
    [self presentPopUpViewController:popupViewController completion:nil];
}

- (void)presentPopUpViewController:(UIViewController *)popupViewController completion:(void (^)(void))completionBlock
{
    self.en_popupViewController = popupViewController;
    [self presentPopUpView:popupViewController.view completion:completionBlock];
}

- (void)dismissPopUpViewController
{
    [self dismissPopUpViewControllerWithcompletion:nil];
}

- (void)dismissPopUpViewControllerWithcompletion:(void (^)(void))completionBlock
{
    UIView *sourceView = [self topView];
    JWBlurView *blurView = (JWBlurView *)[sourceView viewWithTag:kENPopUpBluredViewTag];
    UIView *popupView = [sourceView viewWithTag:kENPopUpViewTag];
    UIView *overlayView = [sourceView viewWithTag:kENPopUpOverlayViewTag];
    [self performDismissAnimationInSourceView:sourceView withBlurView:blurView popupView:popupView overlayView:overlayView completion:completionBlock];
}

//- (IBAction)disMe:(id)sender {
   // UIViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"Pop"];

  //  [self dismissViewControllerAnimated:YES completion:Nil];
//}

#pragma mark - Getters & Setters
- (UIViewController *)en_popupViewController
{
    return objc_getAssociatedObject(self, ENPopupViewControllerPropertyKey);
}

- (void)setEn_popupViewController:(UIViewController *)en_popupViewController
{
    objc_setAssociatedObject(self, ENPopupViewControllerPropertyKey, en_popupViewController, OBJC_ASSOCIATION_RETAIN_NONATOMIC);

}

#pragma mark - View Handling
- (void)presentPopUpView:(UIView *)popUpView completion:(void (^)(void))completionBlock
{
    UIView *sourceView = [self topView];
    // Check if source view controller is not in destination
    if ([sourceView.subviews containsObject:popUpView]) return;

    // Add overlay
    UIView *overlayView = [[UIView alloc] initWithFrame:sourceView.bounds];
    overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    overlayView.tag = kENPopUpOverlayViewTag;
    overlayView.backgroundColor = [UIColor clearColor];

    // Add Blured View
    JWBlurView *bluredView = [[JWBlurView alloc] initWithFrame:overlayView.bounds];
    bluredView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    bluredView.tag = kENPopUpBluredViewTag;
    [bluredView setBlurAlpha:.0f];
    [bluredView setAlpha:.0f];
    [bluredView setBlurColor:[UIColor clearColor]];
    bluredView.backgroundColor = [UIColor clearColor];
    [overlayView addSubview:bluredView];

    // Make the background clickable
    UIButton * dismissButton = [UIButton buttonWithType:UIButtonTypeCustom];
    dismissButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    dismissButton.backgroundColor = [UIColor clearColor];
    dismissButton.frame = sourceView.bounds;
    [overlayView addSubview:dismissButton];

    [dismissButton addTarget:self action:@selector(dismissPopUpViewController)
            forControlEvents:UIControlEventTouchUpInside];

    // Customize popUpView
    popUpView.layer.cornerRadius = 3.5f;
    popUpView.layer.masksToBounds = YES;
    popUpView.layer.zPosition = 99;
    popUpView.tag = kENPopUpViewTag;
    popUpView.center = overlayView.center;
    [popUpView setNeedsLayout];
    [popUpView setNeedsDisplay];

    [overlayView addSubview:popUpView];
    [sourceView addSubview:overlayView];

    [self setAnimationStateFrom:popUpView];
    [self performAppearAnimationWithBlurView:bluredView popupView:popUpView completion:completionBlock];
}

#pragma mark - Animation
- (void)setAnimationStateFrom:(UIView *)view
{
    CALayer *layer = view.layer;
    layer.transform = [self transform3d];
}

- (CATransform3D)transform3d
{
    CATransform3D transform = CATransform3DIdentity;
    transform = CATransform3DTranslate(transform, 0, 200.f, 0);
    transform.m34 = 1.0/800.0;
    transform = CATransform3DRotate(transform, kRotationAngle*M_PI/180.f, 1.f, .0f, .0f);
    CATransform3D scale = CATransform3DMakeScale(.7f, .7f, .7f);
    return CATransform3DConcat(transform, scale);
}

- (void)performAppearAnimationWithBlurView:(JWBlurView *)blurView popupView:(UIView *)popupView completion:(void (^)(void))completionBlock
{

    CATransform3D transform;
    transform = CATransform3DIdentity;
    [UIView animateWithDuration:kAnimationDuration
                     animations:^ {
                         [self.en_popupViewController viewWillAppear:NO];
                         [blurView setAlpha:1.f];
                         popupView.layer.transform = transform;
                     }
                     completion:^(BOOL finished) {
                         [self.en_popupViewController viewDidAppear:NO];
                         if (completionBlock != nil) {
                             completionBlock();
                         }
                     }];
}

- (void)performDismissAnimationInSourceView:(UIView *)sourceView
                               withBlurView:(JWBlurView *)blurView
                                  popupView:(UIView *)popupView
                                overlayView:(UIView *)overlayView
                                 completion:(void (^)(void))completionBlock
{
    CATransform3D transform = [self transform3d];
    [UIView animateWithDuration:kAnimationDuration
                     animations:^ {
                         [self.en_popupViewController viewWillDisappear:NO];
                         [blurView setAlpha:0.f];
                         popupView.layer.transform = transform;
                     }
                     completion:^(BOOL finished) {
                         [popupView removeFromSuperview];
                         [blurView  removeFromSuperview];
                         [overlayView  removeFromSuperview];
                         [self.en_popupViewController viewDidDisappear:NO];
                         self.en_popupViewController = nil;
                         if (completionBlock != nil) {
                             completionBlock();
                         }
                     }];
}

#pragma mark - Getters

- (UIView*)topView {
    UIViewController *recentView = self;
    while (recentView.parentViewController != nil) {
        recentView = recentView.parentViewController;
    }
    return recentView.view;
}

@end

I am beginner in ios.Some one please give some solution for my problem.Thanks in advance !

A: I changed the code of UIViewController+ENPopUp.m for have a visible button.
In code existe a button with screen size for dismiss view.  I changed this button and now he is visible.
In presentPopUpView UIViewController+ENPopUp.m where have this comment " // Make the background clickable" I change the code to this:
CGFloat buttonSize = 10;

UIButton * dismissButton = [[UIButton alloc] init];
dismissButton.backgroundColor = [UIColor redColor];
dismissButton.frame = CGRectMake((self.view.frame.size.width/2) - (buttonSize/2),(self.view.frame.size.height/2) + (self.view.frame.size.height/4) , buttonSize, buttonSize);

[overlayView addSubview:dismissButton];

[dismissButton addTarget:self action:@selector(dismissPopUpViewController)
            forControlEvents:UIControlEventTouchUpInside];

This create a red button 10x10 like in figure:

Now, you can change the color and the size of button for what you want.
I hope this can help you.


text:
Q: Kotlin visibility of nested members I have a class with a nested, private class. I have a Builder, standard Java builder pattern, that constructs instances of this class. I don't want anyone outside of my class to be able to see my hidden class.
In Java I could do this:
public class Example {
    private SneakyType doNotExposeThis;

    private Example(Builder builder) {
        // OK 'cause in Java you can access the private
        // members of a nested class
        doNotExposeThis = builder.doNotExposeThis;
    }

    private static class SneakyType {
        SneakyType(String x) {
            // stuff
        }
    }

    public static class Builder {
        private SneakyType doNotExposeThis;

        public void addFoo(String something) {
            doNotExposeThis = new SneakyType(something);
        }

        public Example build() { return new Example(this); }
    }
}

But I can't figure out how to do the same in Kotlin:
class Example(builder: Builder) {
    private lateinit var doNotExposeThis: SneakyType

    init {
        doNotExposeThis = builder.doNotExposeThis
    }

    class Builder {
        // If private or internal I can't access it in Example.init
        // and if public it gets exposed.
        val doNotExposeThis: SneakyType

        fun addFoo(something: String) {
            // actual construction is quite a bit more complex
            doNotExposeThis = SneakyType(something)
        }
    }
}

Note that for the sake of Java interop I want to keep my builder. I also want it because my object is complicated to construct and I want it to be immutable so I have a builder with lots of setters, adders, vals, etc. and then in init I construct a single immutable Example.
The only alternatives I see are:

*

*Instead of have a SneakyType in my builder save all the info necessary to construct one and then construct it in Example. Works but adds a ton of complexity.

*Give up on Example being immutable and allow the builder to call into it to set up a Sneaky

*Expose the Sneaky
Is there no way to mimic the Java version?

A: I see two viable options:

*

*Use the internal visibility modifier:
class Example private constructor(builder: Builder) {
    private val doNotExposeThis: SneakyType

    init {
        doNotExposeThis = builder.doNotExposeThis
    }

    internal class SneakyType(x: String)

    class Builder {
        internal lateinit var doNotExposeThis: SneakyType

        fun addFoo(something: String) {
            doNotExposeThis = SneakyType(something)
        }

        fun build(): Example {
            return Example(this)
        }
    }
}

This will make SneakyType only visible within your Kotlin compilation module.

*Make Example independent of its builder (this is what I recommend):
class Example private constructor(private val doNotExposeThis: SneakyType) {
    private class SneakyType(x: String)

    class Builder {
        private lateinit var doNotExposeThis: SneakyType

        fun addFoo(something: String) {
            doNotExposeThis = SneakyType(something)
        }

        fun build(): Example {
            return Example(doNotExposeThis)
        }
    }
}


text:
Q: Web Site Design Allowing XML Upload with Supporting XSD We are designing a web-site allowing business to upload data via XML.  We have the XSD for the XML upload.  What's the industry standard in supplying the XSD for the users?  Is it provided on the web-site as a download?
Thanks--

A: I would simply link to it off of the upload page and probably on a more detailed how to page.

A: There should be a documentation section of your site for the developers who are creating this XML, link to it from there. Also have a link in your upload site to the section in your documentation explaining the file, and the XSD.


text:
Q: How to grep to (not) match the special character "/" (no quotes) at the end each line I want to grep through a large file for lines not ending in "/" (no quotes). Here is a sample file:
Folder1/clicker7Mac/
Folder1/clicker7Mac/clicker7.17.0_Mac/Resources/
Folder2/
Folder2/file of interest1.pdf
Folder2/Grades/
Folder2/Grades/another file of interest.pdf
Folder2/Grades/other files with unknown but not-slash extension
Folder2/Final_exam/
Folder2/Final_exam/a 3rd file.pdf
Folder2/Grades/an excel file of interest.xlsx
Folder2/Grades/Package_for_someone/
Folder2/HW/
Folder2/HW/HW1/

I want only the lines ending in files, not the lines that are directory paths. I.e. here I want output:
Folder2/file of interest1.pdf
Folder2/Grades/another file of interest.pdf
Folder2/Grades/other files with unknown but not-slash extension
Folder2/Final_exam/a 3rd file.pdf
Folder2/Grades/an excel file of interest.xlsx

I've searched stack exchange and unix forums and have tried the following (note I have inverted the search because it's easier to test):
grep  '.*/' testfile
grep  '\w*/\b' testfile

(greps all words and slashes, takes files as well; grep -v yeilds nothing)
grep  "[a-z.0-9]"'/\b' testfile

(last character before all slashes; grep -v yeilds nothing)
grep  '\l*/\b' testfile
grep  '\>/' testfile

(all slashes (not just the end slash); grep -v yeilds nothing)
grep -F  '/\b' testfile

(fgrep or grep -F treats as literal string and yeilds nothing; grep -v yeilds everything)
Any solutions please?

A: grep -v '/$' file

or
grep '[^/]$' file

Output:

Folder2/file of interest1.pdf
Folder2/Grades/another file of interest.pdf
Folder2/Grades/other files with unknown but not-slash extension
Folder2/Final_exam/a 3rd file.pdf
Folder2/Grades/an excel file of interest.xlsx

See: man grep and The Stack Overflow Regular Expressions FAQ

A: Use grep -v to exclude all lines that end with /:
$ grep -v '/$' testfile
Folder2/file of interest1.pdf
Folder2/Grades/another file of interest.pdf
Folder2/Grades/other files with unknown but not-slash extension
Folder2/Final_exam/a 3rd file.pdf
Folder2/Grades/an excel file of interest.xlsx

-v is portable and specified by POSIX.

A: If awk is an option:
awk -F'/' '$NF' file
Folder2/file of interest1.pdf
Folder2/Grades/another file of interest.pdf
Folder2/Grades/other files with unknown but not-slash extension
Folder2/Final_exam/a 3rd file.pdf
Folder2/Grades/an excel file of interest.xlsx

It sets the Field Separator to / and then test if last field contains some thing and then do default action, print the line.
Another variation more like the grep solution, test if line does not end with /:
awk '!/[/]$/' file
Folder2/file of interest1.pdf
Folder2/Grades/another file of interest.pdf
Folder2/Grades/other files with unknown but not-slash extension
Folder2/Final_exam/a 3rd file.pdf
Folder2/Grades/an excel file of interest.xlsx


text:
Q: Java Code for permutations of a list of numbers I have written a program to find all the possible permutations of a given list of items. This precisely means that my program prints all possible P(n,r) values for r=0 to n
Below is the code:

package com.algorithm;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Permutations<T> {
    public static void main(String args[]) {
        Permutations<Integer> obj = new Permutations<Integer>();
        Collection<Integer> input = new ArrayList<Integer>();
        input.add(1);
        input.add(2);
        input.add(3);

        Collection<List<Integer>> output = obj.permute(input);
        int k = 0;
        Set<List<Integer>> pnr = null;
        for (int i = 0; i <= input.size(); i++) {
            pnr = new HashSet<List<Integer>>();
            for(List<Integer> integers : output){
            pnr.add(integers.subList(i, integers.size()));
            }
            k = input.size()- i;
            System.out.println("P("+input.size()+","+k+") :"+
            "Count ("+pnr.size()+") :- "+pnr);
        }
    }
    public Collection<List<T>> permute(Collection<T> input) {
        Collection<List<T>> output = new ArrayList<List<T>>();
        if (input.isEmpty()) {
            output.add(new ArrayList<T>());
            return output;
        }
        List<T> list = new ArrayList<T>(input);
        T head = list.get(0);
        List<T> rest = list.subList(1, list.size());
        for (List<T> permutations : permute(rest)) {
            List<List<T>> subLists = new ArrayList<List<T>>();
            for (int i = 0; i <= permutations.size(); i++) {
                List<T> subList = new ArrayList<T>();
                subList.addAll(permutations);
                subList.add(i, head);
                subLists.add(subList);
            }
            output.addAll(subLists);
        }
        return output;
    }
}

Output
P(3,3) : Count (6) :- [[1, 2, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2], [2, 1, 3], [1, 3, 2]]
P(3,2) : Count (6) :- [[3, 1], [2, 1], [3, 2], [1, 3], [2, 3], [1, 2]]
P(3,1) : Count (3) :- [[3], [1], [2]]
P(3,0) : Count (1) :- [[]]

My problem is, as I go increasing the numbers in the input list. Running time increases and after 11 numbers in the input list, the program almost dies. Takes around 2 GB memory to run.
I am running this on a machine having 8GB RAM and i5 processor, so the speed and space is not a problem.
I would appreciate, if anyone can help me writing a more efficient code.

A: If you want all permutations of 15-ish or more elements, write them to disk or a db or something, since they won't fit in memory.
Edit: Steinhaus–Johnson–Trotter algorithm.
This is probably what you're looking for.

A: Java library of Google (Guava) has a utility method for this: Collections2#permutations(Collection)

A: You do realize that you are generating very large lists, and that running time will increase as the list length does.  Have you determined how long the lists that are giving you trouble should be?
One thing that might help some would be to print each permutation as you find it, instead of gathering them all up into a list and THEN printing them.  Of course, if the point is to actually store the whole list, and not just print them, that won't help.

A: If you're not storing it -- if you're just iterating through it -- then consider using Heap's algorithm (#3 on http://www.cut-the-knot.org/do_you_know/AllPerm.shtml) -- or, just to make your life easier, use Guava's Collections2.permutations, which doesn't actually construct the whole list of permutations -- it walks through them on the fly.  (Disclosure: I contribute to Guava.)


text:
Q: How to install Apache Cordova extension in Visual studio 2015 Enterprise? I have recently installed VS 2015 Enterprise and while installing I didn't get any place where VS asked to select anything related to Apache Cordova extension. When I am trying to create a Apache Cordova Project it says that Tools for Apache Cordova are not installed and click ok to install. When I am clicking on "OK" Button after some time I am getting Setup page window. In short it's not installing the extension. How Can I install Apache Cordova if I have already installed VS 2015 Enterprise and haven't selected it while installing VS?

A: If you have Visual Studio 2015 installed already, go to control panel open add/remove software, select Visual Studio 2015 and choose modify, you will see an option for Cross Platform Mobile Development, select this and update.

If you don't have VS2015 installed already you can follow this guide to install Cordova tools for VS
http://taco.visualstudio.com/en-us/docs/install-vs-tools-apache-cordova/


text:
Q: Trouble with install redmine-hudson plugin on bitnami redmine 1.4.1 everyone.
I tried to install redmine-hudson plugin(1.0.8) on bitnami redmine 1.4.1.
I just follow the installation guide down here.
>Installing a plugin
>
>1. Copy your plugin directory into #{RAILS_ROOT}/vendor/plugins. If you are downloading the plugin directly from GitHub, you can do so by changing into your plugin directory and issuing a command like git clone git://github.com/user_name/name_of_the_plugin.git.
>
>2. If the plugin requires a migration, run the following command to upgrade your database (make a db backup before):
>>rake db:migrate_plugins RAILS_ENV=production
>
>3. Restart Redmine
>
>You should now be able to see the plugin list in Administration -> Plugins and configure the newly installed plugin (if the plugin requires to be configured).

when I execute "rake", it shows me an error like this.
>[root@localhost ~]# rake db:migrate RAILS_ENV=production
>
>Some gems may need to be installed or updated.
>
>Please run 'bundle install --without development test'.

and then....
>[root@localhost redmine]# bundle install --without development test
>
>Using rake (0.9.2.2)
>
>Using activesupport (2.3.14)
>
>Using rack (1.1.3)
>
>Using actionpack (2.3.14)
>
>Using actionmailer (2.3.14)
>
>Using activerecord (2.3.14)
>
>Using activeresource (2.3.14)
>
>Using cgi_multipart_eof_fix (2.5.0)
>
>Using coderay (1.0.6)
>
>Using daemons (1.0.10)
>
>Using fastercsv (1.5.4)
>
>Using fastthread (1.0.7)
>
>Using gem_plugin (0.2.3)
>
>Using i18n (0.4.2)
>
>Using mongrel (1.1.5)
>
>Using mysql (2.8.1)
>
>Using net-ldap (0.3.1)
>
>Installing pg (0.13.2) with native extensions
>
>Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
>
>> /usr/local/bin/ruby extconf.rb
>
>checking for pg_config... yes
>
>Using config values from /usr/bin/pg_config
>
>checking for libpq-fe.h... yes
>
>checking for libpq/libpq-fs.h... yes
>
>checking for pg_config_manual.h... yes
>
>checking for PQconnectdb() in -lpq... yes
>
>checking for PQconnectionUsedPassword()... no
>
>Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database.
>
>*** extconf.rb failed ***
>
>Could not create Makefile due to some reason, probably lack of
>
>necessary libraries and/or headers.  Check the mkmf.log file for more details. You may need configuration options.
>
>Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/pg-0.13.2 for inspection.
>
>Results logged to /usr/local/lib/ruby/gems/1.8/gems/pg-0.13.2/ext/gem_make.out
>
>An error occured while installing pg (0.13.2), and Bundler cannot continue.
>
>Make sure that 'gem install pg -v '0.13.2'' succeeds before bundling.
>

so, i tried to install 'pg' using gem. but...!
>[root@localhost redmine]# gem install pg -v '0.13.2'
>
>Building native extensions.  This could take a while...
>
>ERROR:  Error installing pg:
>
>>ERROR: Failed to build gem native extension.
>>
>>/usr/local/bin/ruby extconf.rb
>
>checking for pg_config... yes
>
>Using config values from /usr/bin/pg_config
>
>checking for libpq-fe.h... yes
>
>checking for libpq/libpq-fs.h... yes
>
>checking for pg_config_manual.h... yes
>
>checking for PQconnectdb() in -lpq... yes
>
>checking for PQconnectionUsedPassword()... no
>
>Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database.
>
>*** extconf.rb failed ***
>
>Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.
>
>Check the mkmf.log file for more details.  You may need configuration options.

after this, I couldn't figure it out how to setup.
anyone knows about this problem?
Bitnami Redmine package has Redmine(1.4.1), RubyGem(1.3.6), Ruby(1.8.7), Rails(2.3.5).
And these are installed on CentOS 5.5.
without redmine-hudson plugin, redmine, hudson are working normally.
what am i have to do to use it?

A: Uh, the error output says:
Your PostgreSQL is too old. Either install an older version of this gem
or upgrade your database.

You'll need to follow that advice.


text:
Q: How to check if the input is negative? The program receives an account number from the user and it cannot be negative.
Is there any other way to check if it is negative?
#include <stdio.h>

int main(int argc, char * argv[])
{
    int account = 0;

    printf("Enter your account number:\n");
    scanf("%d", &account);

    while(account<0)
    {
        printf("Error: Enter a valid account number.\n");
        scanf("%d", &account);
    }
}

A: Altough the question doesn't provide the example inputs causing the behavior you notice, you are probably experiencing overflow issues.
int type,  in most modern machine swhere it is stored using 4 bytes, can represent integers from -2,147,483,648 to 2,147,483,647. If you provide a value greater than the maximum positive number (INT_MAX) the value would require a bigger number of bytes to be stored, so in the one actually stored the information of the most significant bits is lost, and the resulting value might end up in the negative range. The same can happen also for big negative values.
What you can do is using long integers so that 8 bits are used and the range is bigger: from -9223372036854775808 to 9223372036854775807.
long num;
scanf ("%ld", &num);

What I would like to emphatize is that numbers representation in computers will always be limited whatever is the number of bytes you use. If these limits are not ok for your application requirements you will have to change your approach, either

*

*using strtol, which warns you with a proper return value if an overflow or underflow occurs

*acquiring the whole string and parsing it yourself

A: You can only read char from user input safely, so you need to read char * then convert them to an other type. For your problem you can do this:
char account_str[MAX_CHAR];
unsigned int account = 0;
bool check = false;

printf("Enter your account number:\n");
do
{
    fgets(account_str, MAX_CHAR, stdin); // read the account number (as string)
    check = isPosNumStr(account_str);
    // isPosNumStr is a personal function that determine if a string have only
    // digit and is positive
    if (!check) {
        printf("Error: Enter a valid account number.\n");
    }
} while (!check)
account = atoi(account_str); // convert string to int

A: #include <stdio.h>
/* For the account number you should use a "long" instead a "int",
And this happens because the account number needs a bigger allocation of memory.
I recomend you to look for "int" limits to understand this.*/

long NumbAccount;

void main(){
    printf("Enter your account number:\n");
scanf("%ld", &NumbAccount);

while(NumbAccount<0)
{
    printf("Error: Enter a valid account number.\n");
    scanf("%ld", &NumbAccount);
}
}


text:
Q: How can I sort a map with string key? like (1 foo , 2 foo) 'Im using hibernate, I was planing to use a LinkedHashMap to sort the elements,
 but it doesnt work because i couldn't initialize as that, so Im making the sort from the controller, so it works, but not as well,  this my method to sort.
public LinkedHashMap<String, Indicador> OrdenarMap(Map<String, Indicador> map) {

        LinkedHashMap<String, Indicador> sortedMap = new LinkedHashMap<>();

        map.entrySet()
                .stream()
                .sorted(Map.Entry.comparingByKey())
                .forEachOrdered(x -> sortedMap.put(x.getKey(), x.getValue()));

        return sortedMap;
    }

I want the order like this
{1 Objetivo General,
1.1 Objetivo Especifico,
2 Objetivo General}
etc....

A: Look at TreeMap. It sorts by the natural order of the keys

A Red-Black tree based NavigableMap implementation. The map is sorted
  according to the natural ordering of its keys, or by a Comparator
  provided at map creation time, depending on which constructor is used.

https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html
The constructor also can take in a comparator for the keys to do your own sorting.

A: Use a TreeMap with a custom Comparator.
By default, the String Comparator compares Strings lexicographically and this is the reason why you see an order like this {"1", "10", "11", ..., "2", "20"}.
Because I assume your key will always be a double, this Comparator should work:
TreeMap<String, Indicador> sortedMap = new TreeMap<>(new Comparator<String>() {
    public int compare(String string1, String string2) {
        return Double.parseDouble(string1) - Double.parseDouble(string2) < 0.0 ? -1 : 1;
    }
});


text:
Q: Is Map enough to be thread safe? I have a very simple class:
public class IdProvider {

    private Map<String,AtomicLong> idMap;

    public IdProvider(){
        idMap = new HashMap<>();
    }

    public long getAvailableId(String conversation){
        AtomicLong id = idMap.get(conversation);
        if(id == null){
            id = new AtomicLong(0);
            idMap.put(conversation,id);
        }
        return id.getAndIncrement();
    }

}

Different methods asynchronously may pass the same conversation identifier and call getAvailableId() where they will be returned a unique id.
Is this thread safe? I'm I guaranteed that the no two methods will receive the same id or do I need to opt for something else?

A: There's multiple ways to make this thread safe, but below is the simplest, I think.  First, you need to safely publish the initial Map.  Then you need to make each access of that map thread safe.
public class IdProvider {

    private final Map<String,AtomicLong> idMap;

    public IdProvider(){
        idMap = new HashMap<>();
    }

    public synchronized long getAvailableId(String conversation){
        AtomicLong id = idMap.get(conversation);
        if(id == null){
            id = new AtomicLong(0);
            idMap.put(conversation,id);
        }
        return id.getAndIncrement();
    }

}

The final keyword is one way to provide "safe publication".  (That's an actual term in Java, look it up.)
And without being tricky, just synchronizing the whole method is the easiest way to provide both synchronization and atomicity.  You shouldn't try to do more unless you can profile this code and determine that it is in fact a performance bottle-neck.  Keep It Simple.

A: This isn't thread safe.
public long getAvailableId(String conversation){
    AtomicLong id = idMap.get(conversation);
    // Thread could be paused here, causing bad interleavings
    // If now a similar call to "getAvailableId" is done you will have two times the same id
    if(id == null){
        id = new AtomicLong(0);
        idMap.put(conversation,id);
    }
    return id.getAndIncrement();
}

Make the method synchronized to avoid possible bad interleavings and data races.

A: When you need to use multiple providers working on same set of ids at the same time,
public class IdProvider {

    private static Map<String,Long> idMap;
    static
    {
        idMap = new HashMap<>();
    }
    public Object lock=new Object();

    public IdProvider(Object l){
        lock=l;
    }

    public long getAvailableId(String conversation){
        // do other work
        synchronized(lock)
        {
            Long id = idMap.get(conversation);
            if(id == null){
                id = new Long(0);
                idMap.put(conversation,id);
            }
            return idMap.put(conversation,id+1);
        }

    }
}

Object lock=new Object();

... in a thread:
IdProvider provider=new IdProvider(lock);  // providing from a thread

... in another thread:
IdProvider provider2=new IdProvider(lock); // providing from another


text:
Q: ArcGIS Pro's File Chooser not showing folders Why is ArcGIS Pro's file chooser not showing folders?
I have this weird issue that ArcGIS Pro's file chooser has no items. It's empty, i.e. no drives and no folders are shown. Also, there is no dialog title shown.

For reproducing reasons, in the Event Viewer, I have following error:

I discovered that when I click on an unavailable network drive in Windows's file explorer, the explorer is not responding. I have to kill and restart the explorer process in the Task Manager.
System: Windows 10 (21H1), ArcGIS Pro 2.7.3
Issue: Domain User Account, Unavailable Network Drive, VPN (see answer to reproduce)
(https://stackoverflow.com/help/self-answer)

A: So it turns out that the problem was an unavailable (not accessible) network drive because I was not connected to the VPN.
(When accessing the network drive in Windows's file explorer, the explorer was not responding and I had to kill and restart the explorer process in the Task Manager.)
It looks like ArcGIS Pro has the same issue as others (and me) have experienced before with QGIS. See QGIS 3 Installation fails - Windows 10 - Main Window not responding.
But I think the underlying and real issue is somewhere to be found in a Windows 10 issue (not responding as expected by the applications).
For now, make sure your shared drives are accessible.

Note: If there is a better answer, I'll change the accepted answer.


text:
Q: Angular 7 app is continuously crashing the browser when sign in with a particular google account. Does anyone know how to fix it? App is getting crashed when using a particular google account, the sync is on
when checked cpu usage in performance monitor its utilizing 100% cpu
its working when resetting the browser data, but after a week the page become unresponsive but working fine in incognito.
I have unsubscribed all the subs, local storage is being cleared, no console errors.


text:
Q: Integral of area of ellipsoid If we have interior of ellipsoid defined by
$$
\frac{x^2}{4}+y^2+z^2=1
$$
If we denote this domain by $S$. How can we calculate
$$
\int\int\int_S y^2dxdydz
$$

A: One can calculate the following using Fubini's theorem writing the interior as:
$$V=\left\{\begin{array}{c}-1< z< 1 \\ -\sqrt{1-z^2}< y< \sqrt{1-z^2} \\ -2\sqrt{1-z^2-y^2}<x<2\sqrt{1-z^2-y^2}\end{array}\right\}$$
So that:
$$\iiint\limits_Vy^2{\rm d}x{\rm d}y{\rm d}z=\int\limits_{-1}^1\left[\int\limits_{-\sqrt{1-z^2}}^{\sqrt{1-z^2}}\left[\int\limits_{-2\sqrt{1-z^2-y^2}}^{\sqrt{1-z^2-y^2}}y^2{\rm d}x\right]{\rm d}y\right]{\rm d}z$$
Which is solvable. Another way is using the variation on Spherical coordinates:
$$
\left\{\begin{array}{ccl}x & = & 2r\cos{(\theta)}\sin{(\varphi)} \\ y & = & r\sin{(\theta)}\sin{(\varphi)} \\ z &= & r\cos{(\varphi)}\end{array}\right.
$$
With Jacobian being $2r^2\sin{(\varphi)}$ and domain in the new coordinates:
$$
\tilde{V}=\left\{\begin{array}{c}0<r<1 \\ 0<\theta<2\pi \\ 0<\varphi<\pi\end{array}\right\}
$$
So using Fubini again we get:
$$
\int\limits_0^1\left[\int\limits_0^{2\pi}\left[\int\limits_0^{\pi}\left(r^2\sin^2{(\theta)}\right)\left(2r^2\sin{(\varphi)}\right){\rm d}\varphi\right]{\rm d}\theta\right]{\rm d}r
$$
Which is much nicer in my opinion :)

A: Let $x=2u$, $y=v$ and $z=w$. Then,
$
u^2+v^2+w^2=1
$ and
$$
I=\int_S y^2dxdydz =2\int_{u^2+v^2+w^2<1}v^2dudvdw\\
$$
Due to symmetry,
$$
I=\frac23\int_{u^2+v^2+w^2<1}(u^2+v^2+w^2) dudvdw
= \frac{8\pi}3\int_0^1r^4dr=\frac{8\pi}{15}
$$


text:
Q: Running script on system start as given user I have a small script on a dev/staging server that runs services inside tmux. The script just creates a few sessions with a few windows each in which various services are running.
How can I make this script run each time the system starts after reboot? I would like to have this script run as specified user.

A: The quickest way is to put a command like su - john -c "bla" in /etc/rc.local (or whatever variant your distro uses.

A: A more conventional way would be to add a line like this to /etc/crontab
@reboot USERNAME    COMMAND TO RUN

/etc/crontab is:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.


text:
Q: How can I draw the following plots: Straightening out the boundary and the balls, in tikz I would like to draw something like the following plots.
Thank you!

For the first draw, I tested the following code:
\begin{tikzpicture}
% Origin
\coordinate (O) at (0,0);
% Point z0
\coordinate (z0) at (0,0);
\node  at (z0) {$\bullet x_0$};
% Circle C0
\draw [name path=C0,pattern = crosshatch, pattern color = green ] (O) circle [radius=4];
\draw[red,looseness=1.5] (-6,0) to [out=-70,in=-110] (z0) to [out=75,in =110](6,0);
% Point z1
\coordinate (z1) at (-45:-2.5);
\fill[pattern = crosshatch] (z1) circle [radius = 0.5];
\node [] at (z1) {$\bullet x^\epsilon$};
%\node [below] at (z1) {$x_1$};
% Circle C1
\node [below right] at (-2,0.5) {$\bullet x$};\end{tikzpicture}

And I got the following image:

Also I used another code:
\begin{tikzpicture}\begin{scope}
\clip (0,0) circle (4cm);
\draw[pattern = crosshatch, pattern color = green]
  (current bounding box.north west) --
  (-4,-1)..controls(0.1,0.1)..(5,-1)
  -- (current bounding box.north east) -- cycle;
 \end{scope}
% Origin
\coordinate (O) at (0,0);
% Point z0
\coordinate (z0) at (0,-0.2);
\node  at (z0) {$\bullet x_0$};
% Circle C0
\draw (O) circle [radius=4];
% Point z1
\coordinate (z1) at (-45:-2.5);
\fill[pattern = crosshatch] (z1) circle [radius = 0.5];
\node [] at (z1) {$\bullet x^\epsilon$};
% Circle C1
\node [below right] at (-2,0.5) {$\bullet x$};\end{tikzpicture}

I got the following image and it looks more like what I want:

For the second image, I tried the following code (using the @SebGlav's answer):
\begin{tikzpicture}

        \def\r{1} % Circle radius
        \coordinate (x0) at (0,0); % Circle centre
        \coordinate (p1) at (190:\r); % First point on the circle
        \coordinate (p2) at (-10:\r); % Second point on the circle

        % First fill the circle portion
        \fill[pattern=north west lines,pattern color=olive] (p1) to[out=0,in=180] (x0) to[out=0,in=180] (p2) arc(-10:190:\r) -- cycle;

        % Then draw the circle (with the label)
        \draw[line width=1pt] (x0) circle(\r);

        % Then draw the line crossing the circle
        \draw[line width=1pt] (-2*\r,0.5*\r) to[out=-20,in=180] (p1) to[out=0,in=180] (x0) to[out=0,in=180] (p2) to[out=0,in=200] (2*\r,.3*\r);
        % The two dots and their labels
        \fill (x0) circle (2pt) node[below] {$x_0$};

         %Domaine 1
  \coordinate (c0) at (6, 0);
  \coordinate (c1) at (7.5, 0);
  \coordinate (c2) at (6.5, 1);
  \coordinate (c3) at (5.8, 0.8);
  \coordinate (c4) at (4.5, 0);
  \coordinate (c5) at (5.9, -0.8);
  \draw[black, thick] plot [smooth cycle] coordinates {(c1) (c2) (c3) (c4) (c5)};
  \draw[black, thick] (4.0,0) --(8,0);
  \fill [pattern=north west lines,pattern color=olive] plot [smooth cycle] coordinates {(c4)  (c0)  (c1)  (c2) };
  \fill (c0) circle (2pt) node[below] {$y_0$};
  \draw[->,line width=1pt] (6,-1) to[out=-90,in=-60]++ (-6,-0.25) node [xshift=3cm, yshift=-2.0cm] {$\varphi^{-1}$};
  \draw[<-,line width=1pt] (6,1.3) to[out=60,in=90]++ (-6,0.2) node [xshift=3cm, yshift=2.0cm] {$\varphi$};
  \end{tikzpicture}

I got the following image

A: You're on the right path. There are many ways to achieve this kind of drawings. I let you dig into this starting point, where you can find some explanation. I did not use any fancy tools like calc or intersections but something pretty simple.

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}
    \begin{tikzpicture}

        \def\r{2} % Circle radius
        \coordinate (x0) at (0,0); % Circle centre
        \coordinate (p1) at (190:\r); % First point on the circle
        \coordinate (p2) at (-10:\r); % Second point on the circle

        % First fill the circle portion
        \fill[pattern=north west lines,pattern color=olive] (p1) to[out=0,in=180] (x0) to[out=0,in=180] (p2) arc(-10:190:\r) -- cycle;

        % Then draw the circle (with the label)
        \draw[line width=1pt] (x0) circle(\r);
        \node[below right] at (-45:\r) {$B\left(x^0,r\right)$};

        % Then draw the line crossing the circle
        \draw[line width=1pt] (-2*\r,0.5*\r) to[out=-20,in=180] (p1) to[out=0,in=180] (x0) to[out=0,in=180] (p2) to[out=0,in=200] (2*\r,.3*\r);

        % This node is the dark circle in the patterned portion
        \node[minimum size=0.4*\r cm,circle,fill=olive!50!black,opacity=0.7,label=above right:{$\varepsilon$}] (B) at (120:0.65*\r) {};

        % The arrow and the label
        \draw[<-,line width=1pt] (B) to[out=170,in=-90]++ (-0.5*\r,0.5*\r) node [above] {$B\left(x^\varepsilon,\varepsilon\right)$};

        % The two dots and their labels
        \fill (x0) circle (2pt) node[below] {$x^0$};
        \fill (40:0.5*\r) circle (2pt) node[right] {$x$};

    \end{tikzpicture}
\end{document}


text:
Q: How to write this ffmpeg command in python I have a streaming m3u8 links (one for video and one for audio)that I want to merge.
I've been doing this command line to do so:
ffmpeg  -i <audio> -i <video? -async 1 -c copy output.mp4

and it works just like I want, the problem is I am trying to do this for 100 different link, and I would like to write a code instead of doing this manually for each link. I know that this can be done in python, but I don't know how to translate an ffmpeg command to a python code.

A: Run code without catching displayed text
import os
os.system("ffmpeg -i <audio> -i <video> -async 1 -c copy output.mp4")

subprocess has different methods
import subprocess

subprocess.run("ffmpeg -i <audio> -i <video> -async 1 -c copy output.mp4", shell=True)

subprocess.run( ["ffmpeg", "-i", "<audio>", "-i", "<video>", "-async", "1", "-c", "copy", "output.mp4"] )

Other methods can catch displayed text so you can check result.

A: I used the code furas suggested and it worked:
import os
import pandas as pd

D=pd.read_excel("links.xlsx");

for i in range(len(D.index)):
    video=D.iat[i,0]
    audio=D.iat[i,1]
    command='ffmpeg  -i '+audio+' -i '+video+' -async 1 -c copy '+str(i)+'.mp4'
    os.system(command)


text:
Q: Index.html in IIS In my code I want to thanks to the good path, open the file Index.html in my IIS server.
I am actually using this :
        string path = "C://inetpub//wwwroot//Files//Wireframes//" + ((LinkButton)sender).ID;
        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path);
        System.IO.FileInfo[] fiArr = di.GetFiles("*", SearchOption.TopDirectoryOnly);

        foreach (System.IO.FileInfo thefile in fiArr)
        {
            if (thefile.Name == "index.html")
            {
                System.Diagnostics.Process.Start(path + "/index.html");
            }

        }
    }

I am wondering why It is working in local, but when I put my project on my server, this is not doing anything.

A: Because:

*

*Your website is in different folder

*You don't have a default application assigned to .html extension

*Your web app runs under an account which cannot interact with the desktop (ie. NETWORK)

Also, instead of searching for * search for index.html in GetFiles.
Make sure that you understand that you are creating a new process on the machine which hosts your web site and not on machine that is running your browser. You want be able to navigate to a page on hosted on machine B from machine A and have a new browser window opened on machine A from machine B.


text:
Q: How to run load app configuration data asynchronously on application startup I have a .Net Core 3.1 application and at startup I need to read some secrets from KV. Since this operation is async this is the approach I have used.
    public void ConfigureServices(IServiceCollection services)
    {
        ...
        services.AddSingleton(Configuration);
        services.AddApplicationSettings(Configuration);
        ...
    }

    public static IServiceCollection AddApplicationSettings(this IServiceCollection services, IConfiguration configuration)
    {
        var applicationSettings = new ApplicationSettings(configuration);
        applicationSettings.ReadApplicationSettingsAsync().Wait();

        services.AddSingleton<IApplicationSettings>(applicationSettings);
        return services;
    }

Is there an option to obtain in an async way so I will not need to call .Wait();