text:
Q: After moving my site from a dev subdomain, to root, all my custom meta data is gone I just movde my site from a dev subdomain, to the root.  I have extensive amounts of data saved in custom meta fields which I created with the WpAlchemy class.  All of this data is not appearing in the site (back or front end), although it appears to be in the database.
This happened right after attempting to use the search replace plugin to change any lingering urls.  This attempt ended in Fatal error: Out of memory.  I noticed everything was gone, so I swapped out the db for my backup (after doing a manual search-replace for my subdomain).  This produced the same result.
I think I've read somewhere that data serialization (am I getting this right?) can mess up this kind of thing.  Is that whats happening to me here?
What steps should I take to get the site up and running ASAP.  Currently it is live, and terribly broken :-(

A: Been there done that. Try this:
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Its a search and replace tool that you put in your WordPress root and just run it from mydomain.dev/searchreplacedb2.php
It fixes the serialization problem when you want to change the url:s to the live one.


text:
Q: Asp.net delegation I am making a .Net Web API that gets data by calling an SQL server. The user is authenticated via Windows Authentication (Kerberos). I would like the user credentials to be passed to the SQL server via delegation, but the SQL server sees an anonymous user.
This is what I have done:

*

*IIS application:
Windows Authentication and asp.net impersonation enabled. Anonymous and forms authentication disabled.
Enable kernel mode authentication is checked.
Providers: Negotiate, Kerberos.
Use app pool credentials: True.

*Application pool:
Managed pipeline mode: Classic.
Identity: Network service.

*In AD, the computer the web server runs on is set to "Trust this computer for delegation to any specific service (Kerberos only)"

*The connection string to the SQL server contains Integrated Security=SSPI;

*Edit: In my web.config I have

 <system.web>
    <authentication mode="Windows" />
    <identity impersonate="true" />
  </system.web>

and

<security>
  <authentication>
    <windowsAuthentication enabled="true">
      <providers>
        <clear />
        <add value="Negotiate" />
        <add value="Kerberos" />
      </providers>
      <extendedProtection tokenChecking="None" />
    </windowsAuthentication>
   <anonymousAuthentication enabled="false" />
  </authentication>
</security>

*

*The generic HOST spn is set for the machine.

From the browser I access the web application via http://machinename.domain.net.
I would expect in this setup that my IIS application is run under the machine account?
When I catch a request in the debugger on the web server, I can see that WindowsIdentity.GetCurrent().Name is the account of the user browsing the web application and WindowsIdentity.GetCurrent().AuthenticationType is set to "Kerberos". So that should be good.
However WindowsIdentity.GetCurrent().ImpersonationLevel is only set to "Impersonate". I would have expected it to be set to "Delegate"?
When I make a request to the SQL server, I get "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'" so obviously the user credentials are not passed to the SQL server.
I hope someone can see what I am doing wrong. I really need a push in the right direction.

A: For future reference if someone runs into the same issue:
The issue was that we tried from Chrome. It works in IE, but on Chrome the registry change mentioned in this post was needed: Kerberos delegation doesn't work in chrome

A: You should be able to set the Authentication to ASP.NET Impersonation within IIS.  You will probably be required to set the following in your web.config file too, as part of  < system.web> section.
    <identity impersonate="true" />

This may be required in the < system.webServer> section to, although not always recommended due to security concerns.
<validation validateIntegratedModeConfiguration="false" />

redpajama_set_name: RedPajamaStackExchange


text:
Q: Unable to open Outlook 2010 on Windows 7 I am unable to open Outlook 2010 on my Windows 7 computer. Outlook displays the splash screen but hangs at "Loading profile".  I have tried running it in Safe Mode, but it still won't work.
Any suggestions?

A: I've come across similar problems in the past. You may be able to repair the Microsoft Office installation files:

*

*Click Start, type 'Programs and Features' and hit Enter

*Find the entry for Microsoft Office. it should look something like this:

*Right-click the entry, and click 'Change'

*On the first window that pops up, select 'Repair' and click 'Continue'

*Follow any other prompts

*Restart your PC


text:
Q: Empirically estimating big-oh time efficiency Background
I'd like to estimate the big-oh performance of some methods in a library through benchmarks. I don't need precision -- it suffices to show that something is O(1), O(logn), O(n), O(nlogn), O(n^2) or worse than that. Since big-oh means upper-bound, estimating O(logn) for something that is O(log logn) is not a problem.
Right now, I'm thinking of finding the constant multiplier k that best fits data for each big-oh (but will top all results), and then choosing the big-oh with the best fit.
Questions

*

*Are there better ways of doing it than what I'm thiking of? If so, what are they?

*Otherwise, can anyone point me to the algorithms to estimate k for best fitting, and comparing how well each curve fits the data?

Notes & Constraints
Given the comments so far, I need to make a few things clear:

*

*This needs to be automated. I can't "look" at data and make a judgment call.

*I'm going to benchmark the methods with multiple n sizes. For each size n, I'm going to use a proven benchmark framework that provides reliable statistical results.

*I actually know beforehand the big-oh of most of the methods that will be tested. My main intention is to provide performance regression testing for them.

*The code will be written in Scala, and any free Java library can be used.

Example
Here's one example of the kind of stuff I want to measure. I have a method with this signature:
def apply(n: Int): A

Given an n, it will return the nth element of a sequence. This method can have O(1), O(logn) or O(n) given the existing implementations, and small changes can get it to use a suboptimal implementation by mistake. Or, more easily, could get some other method that depends on it to use a suboptimal version of it.

A: If you are happy to estimate this empirically, you can measure how long it takes to do exponentially increasing numbers of operations.  Using the ratio you can get which function you estimate it to be.
e.g. if the ratio of 1000 operations to 10000 operations (10x) is (test the longer one first)  You need to do a realistic number of operations to see what the order is for the range you have.

*

*1x => O(1)

*1.2x => O(ln ln n)

*~ 2-5x => O(ln n)

*10x => O(n)

*20-50x => O(n ln n)

*100x => O(n ^ 2)

Its is just an estimate as time complexity is intended for an ideal machine and something should can be mathematically proven rather than measures.
e.g. Many people tried to prove empirically that PI is a fraction. When they measured the ratio of circumference to diameter for circles they had made it was always a fraction. Eventually, it was generally accepted that PI is not a fraction.

A: We have lately implemented a tool that does semi-automated average runtime analysis for JVM code. You do not even have to have access to the sources. It is not published yet (still ironing out some usability flaws) but will be soon, I hope.
It is based on maximum-likelihood models of program execution [1]. In short, byte code is augmented with cost counters. The target algorithm is then run (distributed, if you want) on a bunch of inputs whose distribution you control. The aggregated counters are extrapolated to functions using involved heuristics (method of least squares on crack, sort of). From those, more science leads to an estimate for the average runtime asymptotics (3.576n - 1.23log(n) + 1.7, for instance). For example, the method is able to reproduce rigorous classic analyses done by Knuth and Sedgewick with high precision.
The big advantage of this method compared to what others post is that you are independent of time estimates, that is in particular independent of machine, virtual machine and even programming language. You really get information about your algorithm, without all the noise.
And---probably the killer feature---it comes with a complete GUI that guides you through the whole process.
See my answer on cs.SE for a little more detail and further references.
You can find a preliminary website (including a beta version of the tool and the papers published) here.
(Note that average runtime can be estimated that way while worst case runtime can never be, except in case you know the worst case. If you do, you can use the average case for worst case analysis; just feed the tool only worst case instances. In general, runtime bounds can not be decided, though.)

*

*Maximum likelihood analysis of algorithms and data structures by U. Laube and M.E. Nebel (2010). [preprint]

A: What you are looking to achieve is impossible in general. Even the fact that an algorithm will ever stop cannot be proven in general case (see Halting Problem). And even if it does stop on your data you still cannot deduce the complexity by running it. For instance, bubble sort has complexity O(n^2), while on already sorted data it performs as if it was O(n). There is no way to select "appropriate" data for an unknow algorithm to estimate its worst case.

A: In order to get started, you have to make a couple of assumptions.

*

*n is large compared to any constant terms.

*You can effectively randomize your input data

*You can sample with sufficient density to get a good handle on the distribution of runtimes

In particular, (3) is difficult to achieve in concert with (1).  So you may get something with an exponential worst case, but never run into that worst case, and thus think your algorithm is much better than it is on average.
With that said, all you need is any standard curve fitting library.  Apache Commons Math has a fully adequate one.  You then either create a function with all the common terms that you want to test (e.g. constant, log n, n, n log n, nn, nn*n, e^n), or you take the log of your data and fit the exponent, and then if you get an exponent not close to an integer, see if throwing in a log n gives a better fit.
(In more detail, if you fit C*x^a for C and a, or more easily log C + a log x, you can get the exponent a; in the all-common-terms-at-once scheme, you'll get weights for each term, so if you have n*n + C*n*log(n) where C is large, you'll pick up that term also.)
You'll want to vary the size by enough so that you can tell the different cases apart (might be hard with log terms, if you care about those), and safely more different sizes than you have parameters (probably 3x excess would start being okay, as long as you do at least a dozen or so runs total).

Edit: Here is Scala code that does all this for you.  Rather than explain each little piece, I'll leave it to you to investigate; it implements the scheme above using the C*x^a fit, and returns ((a,C),(lower bound for a, upper bound for a)).  The bounds are quite conservative, as you can see from running the thing a few times.  The units of C are seconds (a is unitless), but don't trust that too much as there is some looping overhead (and also some noise).
class TimeLord[A: ClassManifest,B: ClassManifest](setup: Int => A, static: Boolean = true)(run: A => B) {
  @annotation.tailrec final def exceed(time: Double, size: Int, step: Int => Int = _*2, first: Int = 1): (Int,Double) = {
    var i = 0
    val elapsed = 1e-9 * {
      if (static) {
        val a = setup(size)
        var b: B = null.asInstanceOf[B]
        val t0 = System.nanoTime
        var i = 0
        while (i < first) {
          b = run(a)
          i += 1
        }
        System.nanoTime - t0
      }
      else {
        val starts = if (static) { val a = setup(size); Array.fill(first)(a) } else Array.fill(first)(setup(size))
        val answers = new Array[B](first)
        val t0 = System.nanoTime
        var i = 0
        while (i < first) {
          answers(i) = run(starts(i))
          i += 1
        }
        System.nanoTime - t0
      }
    }
    if (time > elapsed) {
      val second = step(first)
      if (second <= first) throw new IllegalArgumentException("Iteration size increase failed: %d to %d".format(first,second))
      else exceed(time, size, step, second)
    }
    else (first, elapsed)
  }

  def multibench(smallest: Int, largest: Int, time: Double, n: Int, m: Int = 1) = {
    if (m < 1 || n < 1 || largest < smallest || (n>1 && largest==smallest)) throw new IllegalArgumentException("Poor choice of sizes")
    val frac = (largest.toDouble)/smallest
    (0 until n).map(x => (smallest*math.pow(frac,x/((n-1).toDouble))).toInt).map{ i =>
      val (k,dt) = exceed(time,i)
      if (m==1) i -> Array(dt/k) else {
        i -> ( (dt/k) +: (1 until m).map(_ => exceed(time,i,first=k)).map{ case (j,dt2) => dt2/j }.toArray )
      }
    }.foldLeft(Vector[(Int,Array[Double])]()){ (acc,x) =>
      if (acc.length==0 || acc.last._1 != x._1) acc :+ x
      else acc.dropRight(1) :+ (x._1, acc.last._2 ++ x._2)
    }
  }

  def alpha(data: Seq[(Int,Array[Double])]) = {
    // Use Theil-Sen estimator for calculation of straight-line fit for exponent
    // Assume timing relationship is t(n) = A*n^alpha
    val dat = data.map{ case (i,ad) => math.log(i) -> ad.map(x => math.log(i) -> math.log(x)) }
    val slopes = (for {
      i <- dat.indices
      j <- ((i+1) until dat.length)
      (pi,px) <- dat(i)._2
      (qi,qx) <- dat(j)._2
    } yield (qx - px)/(qi - pi)).sorted
    val mbest = slopes(slopes.length/2)
    val mp05 = slopes(slopes.length/20)
    val mp95 = slopes(slopes.length-(1+slopes.length/20))
    val intercepts = dat.flatMap{ case (i,a) => a.map{ case (li,lx) => lx - li*mbest } }.sorted
    val bbest = intercepts(intercepts.length/2)
    ((mbest,math.exp(bbest)),(mp05,mp95))
  }
}

Note that the multibench method is expected to take about sqrt(2)nm*time to run, assuming that static initialization data is used and is relatively cheap compared to whatever you're running.  Here are some examples with parameters chosen to take ~15s to run:
val tl1 = new TimeLord(x => List.range(0,x))(_.sum)  // Should be linear
// Try list sizes 100 to 10000, with each run taking at least 0.1s;
// use 10 different sizes and 10 repeats of each size
scala> tl1.alpha( tl1.multibench(100,10000,0.1,10,10) )
res0: ((Double, Double), (Double, Double)) = ((1.0075537890632216,7.061397125245351E-9),(0.8763463348353099,1.102663784225697))

val longList = List.range(0,100000)
val tl2 = new TimeLord(x=>x)(longList.apply)    // Again, should be linear
scala> tl2.alpha( tl2.multibench(100,10000,0.1,10,10) )
res1: ((Double, Double), (Double, Double)) = ((1.4534378213477026,1.1325696181862922E-10),(0.969955396265306,1.8294175293676322))

// 1.45?!  That's not linear.  Maybe the short ones are cached?
scala> tl2.alpha( tl2.multibench(9000,90000,0.1,100,1) )
res2: ((Double, Double), (Double, Double)) = ((0.9973235607566956,1.9214696731124573E-9),(0.9486294398193154,1.0365312207345019))

// Let's try some sorting
val tl3 = new TimeLord(x=>Vector.fill(x)(util.Random.nextInt))(_.sorted)
scala> tl3.alpha( tl3.multibench(100,10000,0.1,10,10) )
res3: ((Double, Double), (Double, Double)) = ((1.1713142886974603,3.882658025586512E-8),(1.0521099621639414,1.3392622111121666))
// Note the log(n) term comes out as a fractional power
// (which will decrease as the sizes increase)

// Maybe sort some arrays?
// This may take longer to run because we have to recreate the (mutable) array each time
val tl4 = new TimeLord(x=>Array.fill(x)(util.Random.nextInt), false)(java.util.Arrays.sort)
scala> tl4.alpha( tl4.multibench(100,10000,0.1,10,10) )
res4: ((Double, Double), (Double, Double)) = ((1.1216172965292541,2.2206198821180513E-8),(1.0929414090177318,1.1543697719880128))

// Let's time something slow
def kube(n: Int) = (for (i <- 1 to n; j <- 1 to n; k <- 1 to n) yield 1).sum
val tl5 = new TimeLord(x=>x)(kube)
scala> tl5.alpha( tl5.multibench(10,100,0.1,10,10) )
res5: ((Double, Double), (Double, Double)) = ((2.8456382116915484,1.0433534274508799E-7),(2.6416659356198617,2.999094292838751))
// Okay, we're a little short of 3; there's constant overhead on the small sizes

Anyway, for the stated use case--where you are checking to make sure the order doesn't change--this is probably adequate, since you can play with the values a bit when setting up the test to make sure they give something sensible.  One could also create heuristics that search for stability, but that's probably overkill.
(Incidentally, there is no explicit warmup step here; the robust fitting of the Theil-Sen estimator should make it unnecessary for sensibly large benchmarks.  This also is why I don't use any other benching framework; any statistics that it does just loses power from this test.)

Edit again: if you replace the alpha method with the following:
  // We'll need this math
  @inline private[this] def sq(x: Double) = x*x
  final private[this] val inv_log_of_2 = 1/math.log(2)
  @inline private[this] def log2(x: Double) = math.log(x)*inv_log_of_2
  import math.{log,exp,pow}

  // All the info you need to calculate a y value, e.g. y = x*m+b
  case class Yp(x: Double, m: Double, b: Double) {}

  // Estimators for data order
  //   fx = transformation to apply to x-data before linear fitting
  //   fy = transformation to apply to y-data before linear fitting
  //   model = given x, slope, and intercept, calculate predicted y
  case class Estimator(fx: Double => Double, invfx: Double=> Double, fy: (Double,Double) => Double, model: Yp => Double) {}
  // C*n^alpha
  val alpha = Estimator(log, exp, (x,y) => log(y), p => p.b*pow(p.x,p.m))
  // C*log(n)*n^alpha
  val logalpha = Estimator(log, exp, (x,y) =>log(y/log2(x)), p => p.b*log2(p.x)*pow(p.x,p.m))

  // Use Theil-Sen estimator for calculation of straight-line fit
  case class Fit(slope: Double, const: Double, bounds: (Double,Double), fracrms: Double) {}
  def theilsen(data: Seq[(Int,Array[Double])], est: Estimator = alpha) = {
    // Use Theil-Sen estimator for calculation of straight-line fit for exponent
    // Assume timing relationship is t(n) = A*n^alpha
    val dat = data.map{ case (i,ad) => ad.map(x => est.fx(i) -> est.fy(i,x)) }
    val slopes = (for {
      i <- dat.indices
      j <- ((i+1) until dat.length)
      (pi,px) <- dat(i)
      (qi,qx) <- dat(j)
    } yield (qx - px)/(qi - pi)).sorted
    val mbest = slopes(slopes.length/2)
    val mp05 = slopes(slopes.length/20)
    val mp95 = slopes(slopes.length-(1+slopes.length/20))
    val intercepts = dat.flatMap{ _.map{ case (li,lx) => lx - li*mbest } }.sorted
    val bbest = est.invfx(intercepts(intercepts.length/2))
    val fracrms = math.sqrt(data.map{ case (x,ys) => ys.map(y => sq(1 - y/est.model(Yp(x,mbest,bbest)))).sum }.sum / data.map(_._2.length).sum)
    Fit(mbest, bbest, (mp05,mp95), fracrms)
  }

then you can get an estimate of the exponent when there's a log term also--error estimates exist to pick whether the log term or not is the correct way to go, but it's up to you to make the call (i.e. I'm assuming you'll be supervising this initially and reading the numbers that come off):
val tl3 = new TimeLord(x=>Vector.fill(x)(util.Random.nextInt))(_.sorted)
val timings = tl3.multibench(100,10000,0.1,10,10)

// Regular n^alpha fit
scala> tl3.theilsen( timings )
res20: tl3.Fit = Fit(1.1811648421030059,3.353753446942075E-8,(1.1100382697696545,1.3204652930525234),0.05927994882343982)

// log(n)*n^alpha fit--note first value is closer to an integer
//   and last value (error) is smaller
scala> tl3.theilsen( timings, tl3.logalpha )
res21: tl3.Fit = Fit(1.0369167329732445,9.211366397621766E-9,(0.9722967182484441,1.129869067913768),0.04026308919615681)

(Edit: fixed the RMS computation so it's actually the mean, plus demonstrated that you only need to do timings once and can then try both fits.)

A: I don't think your approach will work in general.
The problem is that "big O" complexity is based on a limit as some scaling variable tends to infinity.  For smaller values of that variable, the performance behavior can appear to fit a different curve entirely.
The problem is that with an empirical approach you can never know if the scaling variable is large enough for the limit to be apparent in the results.
Another problem is that if you implement this in Java / Scala, you have to go to considerable lengths to eliminate distortions and "noise" in your timings due to things like JVM warmup (e.g. class loading, JIT compilation, heap resizing) and garbage collection.
Finally, nobody is going to place much trust in empirical estimates of complexity.  Or at least, they wouldn't if they understood the mathematics of complexity analysis.

FOLLOWUP
In response to this comment:

Your estimate's significance will improve drastically the more and larger samples you use.

This is true, though my point is that you (Daniel) haven't factored this in.

Also, runtime functions typically have special characteristics which can be exploited; for example, algorithms tend to not change their behaviour at some huge n.

For simple cases, yes.
For complicated cases and real world cases, that is a dubious assumption.  For example:

*

*Suppose some algorithm uses a hash table with a large but fixed-sized primary hash array, and uses external lists to deal with collisions.  For N (== number of entries) less than the size of the primary hash array, the behaviour of most operations will appear to be O(1).  The true O(N) behaviour can only be detected by curve fitting when N gets much larger than that.

*Suppose that the algorithm uses a lot of memory or network bandwidth.  Typically, it will work well until you hit the resource limit, and then performance will tail off badly.  How do you account for this?  If it is part of the "empirical complexity", how do you make sure that you get to the transition point?  If you want to exclude it, how do you do that?

A: You should consider changing a critical aspects of your task.
Change the terminology that you are using to: "estimate the runtime of the algorithm" or "setup performance regression testing"
Can you estimate the runtime of the algorithm?  Well you propose to try different input sizes and measure either some critical operation or the time it takes.  Then for the series of input sizes you plan to programmaticly estimate if the algorithm's runtime has no growth, constant growth, exponential growth etc.
So you have two problems, running the tests, and programmatically estimating the growth rate as you input set grows.  This sounds like a reasonable task.

A: I'm not sure I get 100% what you want. But I understand that you test your own code, so you can modify it, e.g. inject observing statements. Otherwise you could use some form of aspect weaving?
How about adding resetable counters to your data structures and then increase them each time a particular sub-function is invoked? You could make those counting @elidable so they will be gone in the deployed library.
Then for a given method, say delete(x), you would test that with all sorts of automatically generated data sets, trying to give them some skew, etc., and gather the counts. While as Igor points out you cannot verify that the data structure won't ever violate a big-O bound, you will at least be able to assert that in the actual experiment a given limit count is never exceeded (e.g. going down a node in a tree is never done more than 4 * log(n) times) -- so you can detect some mistakes.
Of course, you would need certain assumptions, e.g. that calling a method is O(1) in your computer model.

A:
I actually know beforehand the big-oh of most of the methods that will
  be tested. My main intention is to provide performance regression
  testing for them.

This requirement is key. You want to detect outliers with minimal data (because testing should be fast, dammit), and in my experience fitting curves to numerical evaluations of complex recurrences, linear regression and the like will overfit. I think your initial idea is a good one.
What I would do to implement it is prepare a list of expected complexity functions g1, g2, ..., and for data f, test how close to constant f/gi + gi/f is for each i. With a least squares cost function, this is just computing the variance of that quantity for each i and reporting the smallest. Eyeball the variances at the end and manually inspect unusually poor fits.

A: For an empiric analysis of the complexity of the program, what you would do is run (and time) the algorithm given 10, 50, 100, 500, 1000, etc input elements. You can then graph the results and determine the best-fit function order from the most common basic types: constant, logarithmic, linear, nlogn, quadratic, cubic, higher-polynomial, exponential. This is a normal part of load testing, which makes sure that the algorithm is first behaving as theorized, and second that it meets real-world performance expectations despite its theoretical complexity (a logarithmic-time algorithm in which each step takes 5 minutes is going to lose all but the absolute highest-cardinality tests to a quadratic-complexity algorithm in which each step is a few millis).
EDIT: Breaking it down, the algorithm is very simple:
Define a list, N, of various cardinalities for which you want to evaluate performance (10,100,1000,10000 etc)
For each element X in N:
Create a suitable set of test data that has X elements.
Start a stopwatch, or determine and store the current system time.
Run the algorithm over the X-element test set.
Stop the stopwatch, or determine the system time again.
The difference between start and stop times is your algorithm's run time over X elements.
Repeat for each X in N.
Plot the results; given X elements (x-axis), the algorithm takes T time (y-axis). The closest basic function governing the increase in T as X increases is your Big-Oh approximation. As was stated by Raphael, this approximation is exactly that, and will not get you very fine distinctions such as coefficients of N, that could make the difference between a N^2 algorithm and a 2N^2 algorithm (both are technically O(N^2) but given the same number of elements one will perform twice as fast).

A: Wanted to share my experiments as well. Nothing new from the theoretical standpoint, but it's a fully functional Python module that can easily be extended.
Main points:

*

*It's based on scipy Python library curve_fit function that allows
to fit any function into the given set of points minimizing sum of
square differences;

*Since tests are done increasing the problem size exponentially points
closer to the start will kind of have a bigger weight, which does not
help to identify the correct approximation, so it seems to me that
simple linear interpolation to redestribute points evenly does help;

*The set of approximations we are trying to fit is fully under our
control; I've added the following ones:
        def fn_linear(x, k, c):
            return k * x + c

        def fn_squared(x, k, c):
            return k * x ** 2 + c

        def fn_pow3(x, k, c):
            return k * x ** 3 + c

        def fn_log(x, k, c):
            return k * np.log10(x) + c

        def fn_nlogn(x, k, c):
            return k * x * np.log10(x) + c

Here is a fully functional Python module to play with: https://gist.github.com/gubenkoved/d9876ccf3ceb935e81f45c8208931fa4, and some pictures it produces (please note -- 4 graphs per sample with different axis scales).


text:
Q: How to get the working directory in executor I am using the following command to submit Spark job, I hope to send jar and config files to each executor and load it there
spark-submit --verbose \
--files=/tmp/metrics.properties \
--jars /tmp/datainsights-metrics-source-assembly-1.0.jar \
--total-executor-cores 4\
--conf "spark.metrics.conf=metrics.properties" \
--conf "spark.executor.extraClassPath=datainsights-metrics-source-assembly-1.0.jar"  \
--class org.microsoft.ofe.datainsights.StartServiceSignalPipeline \
./target/datainsights-1.0-jar-with-dependencies.jar

--files and --jars is used to send files to executors, I found that the files are sent to the working directory of executor like 'worker/app-xxxxx-xxxx/0/
But when job is running, the executor always throws exception saying that it could not find the file 'metrics.properties'or the class which is contained in 'datainsights-metrics-source-assembly-1.0.jar'. It seems that the job is looking for files under another dir rather than working directory.
Do you know how to load the file which is sent to executors?
Here is the trace (The class 'org.apache.spark.metrics.PerfCounterSource' is contained in the jar 'datainsights-metrics-source-assembly-1.0.jar'):
ERROR 2016-01-14 16:10:32 Logging.scala:96 - org.apache.spark.metrics.MetricsSystem: Source class org.apache.spark.metrics.PerfCounterSource cannot be instantiated
java.lang.ClassNotFoundException: org.apache.spark.metrics.PerfCounterSource
at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[na:1.7.0_80]
at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_80]
at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_80]
at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_80]
at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[na:1.7.0_80]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.7.0_80]
at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[na:1.7.0_80]
at java.lang.Class.forName0(Native Method) ~[na:1.7.0_80]
at java.lang.Class.forName(Class.java:195) ~[na:1.7.0_80]

A: It looks like you have a typo in your --jars argument, so it could be that it's not actually loading the file and and continuing silently.


text:
Q: \leavevmode cause overlay of labels in description list I have a description list at the beginning of a proof environment and want the first label to begin in the same column as the remaining labels. When I put a \leavevmode before the first \item, the label for the first item overlays the label for the second item.
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}

\theoremstyle{definition}

\theoremstyle{remark}

\numberwithin{equation}{section}

\usepackage[colorlinks,hidelinks,draft=false]{hyperref}

\usepackage{cleveref}

% \newtheorem must follow cleveref
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
\def\corollaryautorefname{Corollary}         % Needed for \autoref
\newtheorem{definition}[theorem]{Definition}
\def\definitionautorefname{Definition}       % Needed for \autoref
\newtheorem{example}[theorem]{Example}
\newtheorem{lemma}[theorem]{Lemma}
\def\lemmaautorefname{Lemma}                 % Needed for \autoref

\newtheorem{remark}[theorem]{Remark}
\newtheorem{xca}[theorem]{Exercise}
\usepackage[draft]{showlabels}
\showlabels{cite}
\showlabels{cref}
\showlabels{crefrange}

\begin{document}
\begin{theorem}
foo
\begin{proof}
\begin{description}
\leavevmode
\item[prop1:]
proof of prop1.
\item[prop2:]
proof of prop2
\end{description}
\end{proof}
\end{theorem}
\end{document}

A: A latex list should only have items preceded by \item. \leavevmode is a syntax error, what is the intention?
If you want a "normal" paragraph to hole the proof label before the list starts you could put \leavevmode (or \mbox{} would be better LaTeX) before the
\begin{description}

Not after it.


text:
Q: Access folder outside of webapp I am having a hard time trying to configure Apache Tomcat 8 to access a folder what stand outside of webapp. I tried multiple things including context to the server.xml and then learned that this isn't the correct way to do it because docBase refers to the location of a web application.
I also tried adding a / to the project properties > web project settings: contect root. I have node_modules folder at the root level of the project. I get a 404 error on all my script tags trying to access this folder.
<script src="node_modules/core-js/client/shim.min.js"></script>

A: Since JS file outside webapp, there are only a solution, use absolute path.
By some ways, you maybe put js file inside webapp, you will do something like this:
<script src="${pageContext.request.contextPath}/node_modules/core-js/client/shim.min.js"></script>


text:
Q: GridView SelectedIndexChanged Event is not fired I want my GridView Rows to fire the SelectedIndexChanged event when I click on them.
I tried the following in code behind:
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            e.Row.Attributes.Add("onMouseOver", "Highlight(this)");
            e.Row.Attributes.Add("onMouseOut", "UnHighlight(this)");

            e.Row.Attributes.Add("onClick", String.Format("javascript:__doPostBack('GridView1','Select${0}')", e.Row.RowIndex));
        }
    }

Postback happens when I click on a row, but it doesn't fires SelectedIndexChanged. In the Page_Load I get the arguments from the request:
        if (IsPostBack)
        {
            object obTarget = this.Request.Form["__EVENTTARGET"]; //GridView1
            object obArg = this.Request.Form["__EVENTARGUMENT"]; //Select$4
        }

I think that SelectedIndexChanged would have to be raised, or do i have a misunderstanding on this?

A: You are probably rebinding the GridView to its DataSource on postback. You should do that only if(!IsPostBack) (with enabled ViewState), otherwise events aren't triggered.
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        GridView1.DatSource = GetGataSource();
        GridView1.DataBind();
    }
}

You should also register event handler on every postback but RowDataBound is only called on databinding. So use RowCreated instead.
It's also better to use Page.GetPostBackClientHyperlink instead of hardcoding the javascript function.
e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink((GridView)sender, "Select$" & e.Row.RowIndex)


text:
Q: Re-receive email in outlook I'm using an Azure logic app to process emails on an inbox. The trigger is set to fire whenever an email is received. This is working fine. The issue is if there is an error somewhere along the way, we want to re-process the email. We can accomplish this in a number of ways, but by far the simplest would be to just put the email back in the inbox and have it pick the email up again.
I've attempted many combinations of the instructions outlined here: https://www.msoutlook.info/question/218 and got it to work once. And haven't been able to replicate it since. Any advice would be much appreciated.
Edit to clarify my actual question: How can I get my Logic App to pick up the email again? Can this be done by simply moving the email back into the inbox or something similar? When the email is processed, it gets moved to a subfolder of the inbox and marked as read. I've attempted to mark it as unread put it back into the inbox as suggested by the above link, but to no avail. I have not been able to find further literature on the subject.

A: What we ended up doing was splitting the logic app into two pieces. One that listened to the mail box and one that did the actual processing (named it "..._Core"). The logic app that listened to the mailbox would then call the _Core logic app. In the case of errors, the _Core would send those emails to a "Failed" folder. To actually re-run those emails, we have another logic app that triggers when an email is flagged. When triggered, it would send those emails to the _Core app again, where it would either run successfully or end up right back in the "Failed" folder. This made debugging a simple process of 1) make edits to _Core, 2) flag the email, repeat if necessary.
As far as I can tell what I was asking for in this question is not possible.


text:
Q: Time series correlation with pandas I have some Particulate Matter sensors and CSVs with time series like:
Sensor A:
                     date           value
date
2017-11-30 00:00:00  30/11/17 0.00     49
2017-11-30 00:02:00  30/11/17 0.02     51
2017-11-30 00:03:00  30/11/17 0.03     54
2017-11-30 00:05:00  30/11/17 0.05     57
2017-11-30 00:07:00  30/11/17 0.07     53
2017-11-30 00:08:00  30/11/17 0.08     55
2017-11-30 00:10:00  30/11/17 0.10     55
2017-11-30 00:12:00  30/11/17 0.12     58
2017-11-30 00:13:00  30/11/17 0.13     57
2017-11-30 00:15:00  30/11/17 0.15     58
....
2018-02-06 09:30:00    6/2/18 9.30     33
2018-02-06 09:32:00    6/2/18 9.32     31
2018-02-06 09:33:00    6/2/18 9.33     34
2018-02-06 09:35:00    6/2/18 9.35     32
2018-02-06 09:37:00    6/2/18 9.37     33
2018-02-06 09:38:00    6/2/18 9.38     30

I set date as index with:
df.index = pd.to_datetime(df['date'], format='%d/%m/%y %H.%M')

I would like to correlate different time windows between data from the same sensor AND from different sensor in similar time windows. I expect to know if I have same increase/decrease behaviour in some part of the day/days.
After setting "date index" I'm able to get "All PM value from 9am to 10am everyday from sensor A"
df.between_time('9:00','10:00')

1) Problem 1: How to check correlation from same sensor but different days: I filtered data 9/10am from two days in two DataFrame, but not always they're taken exactly at the same minute. I may have situations like this:
01-01-2018 (df01 - I removed data column)
2018-01-01 09:05:00     11
2018-01-01 09:07:00     11
2018-01-01 09:09:00     10
....

02-01-2018 (df02)
2018-02-01 09:05:00     67
2018-02-01 09:07:00     68
2018-02-01 09:08:00     67
....

Should I rename data column? I actually care that the third value from 01/01/2018 will correlate with the third value from the second window.
df01.corr(df02)

returns
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

2) Problem 2: Correlate between different sensors In this case I have 2 CVS files with PM values from two sensors. As Problem1 I would like to correlate same time windows from them.
Even in this case I expect some "Casual lag" between data but errors between minutes are fine and I want to check just values 'at right position'. Example:
Sensor A:
                         date           value
    date
    2017-11-30 00:00:00  30/11/17 0.00     49
    2017-11-30 00:02:00  30/11/17 0.02     51
    2017-11-30 00:03:00  30/11/17 0.03     54
    2017-11-30 00:05:00  30/11/17 0.05     57

Sensor B:
                         date           value
    date
    2017-11-30 00:00:00  30/11/17 0.00     1
    2017-11-30 00:02:00  30/11/17 0.02     40
    2017-11-30 00:04:00  30/11/17 0.03     11
    2017-11-30 00:05:00  30/11/17 0.05     57

AxB
                         date           valueA    valueB
    date
    2017-11-30 00:00:00  30/11/17 0.00     49       1
    2017-11-30 00:02:00  30/11/17 0.02     51       40
    2017-11-30 00:03:00  30/11/17 0.03     54       11
    2017-11-30 00:05:00  30/11/17 0.05     57       57

Thank you in advance

A: I'll try to address both of your questions together. This looks like a job for pd.merge_asof(), which merges on nearest-matching keys, rather than only on exact keys.
Example data
df1
date            value
30/11/17 0.00   51
30/11/17 0.02   53
30/11/17 0.05   65
30/11/17 0.08   58

df2
date            value
30/11/17 0.01   61
30/11/17 0.02   63
30/11/17 0.04   65
30/11/17 0.07   68

Preprocessing
df1.date = pd.to_datetime(df1.date, format='%d/%m/%y %H.%M')
df2.date = pd.to_datetime(df2.date, format='%d/%m/%y %H.%M')
df1.set_index('date', inplace=True)
df2.set_index('date', inplace=True)

df1
                     value
date
2017-11-30 00:00:00     51
2017-11-30 00:02:00     53
2017-11-30 00:05:00     65
2017-11-30 00:08:00     58

df2
                     value
date
2017-11-30 00:01:00     61
2017-11-30 00:02:00     63
2017-11-30 00:04:00     65
2017-11-30 00:07:00     68

Merge DataFrames on nearest index match
merged = pd.merge_asof(df1, df2, left_index=True, right_index=True, direction='nearest')
merged
                         value_x  value_y
date
2017-11-30 00:00:00       51       61
2017-11-30 00:02:00       53       63
2017-11-30 00:05:00       65       65
2017-11-30 00:08:00       58       68

Correlations
Note that df.corr() doesn't accept data as an argument, so df1.corr(df2) doesn't work. The corr method computes pairwise correlation of the columns in the DataFrame you call it on (docs).
merged.corr()
          value_x   value_y
value_x  1.000000  0.612873
value_y  0.612873  1.000000

Notes
The above usage of pd.merge_asof keeps the index of df1; each row in df1 receives its closest match in df2, with replacement, so if df2 ever has fewer rows than df1, the result of merge_asof will contain duplicate values from df2. And the result will have the same number of rows as df1.
You mentioned that you really only care to compare rows by relative position, e.g., compare the 3rd value of df1 to the 3rd value of df2. Instead of using merge_asof, you could simply ignore the time index once you've used it to obtain time periods of interest, and access the underlying numpy arrays with df.values:
# Get a 2D array of shape (4, 1)
df1.values
array([[51],
       [53],
       [65],
       [58]])

# Get a 1D array of shape (4,)
df1.values.flatten()
array([51, 53, 65, 58])

# numpy correlation matrix
pd.np.corrcoef(df1.values.flatten(), df2.values.flatten())
array([[1.        , 0.61287265],
       [0.61287265, 1.        ]])


text:
Q: Checking Connection to Server in Android Studio Just as the title suggest, I have a problem with checking android connection to the server.
I have a project that I left for some month, back then the code that I used to check the server's connection was the answer from this question, but now when I opened this project again and try to run it, I can't seem to be able to reach the server.
This is my code to check the server's connection :
public static boolean isServerConnected() {
    try {
        URL myUrl = new URL(URL_CONNECTION);
        URLConnection connection = myUrl.openConnection();
        connection.setConnectTimeout(10000);
        connection.connect();
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

And this is where I call it (in a login button) :
btnLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (Servers.isServerConnected()) {
                username = edtUser.getText().toString();
                password = edtPass.getText().toString();
                login();
            } else {
                Toast.makeText(getApplicationContext(), "Server is not connected", Toast.LENGTH_SHORT).show();
            }
        }
    });

This is the exception that I got :
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
W/System.err: android.os.NetworkOnMainThreadException
    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:333)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:196)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356)
    at java.net.Socket.connect(Socket.java:586)
    at com.android.okhttp.internal.Platform.connectSocket(Platform.java:113)
    at com.android.okhttp.Connection.connectSocket(Connection.java:196)
    at com.android.okhttp.Connection.connect(Connection.java:172)
    at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)
    at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130)
    at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329)
    at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
    at
com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
    at
com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)
    at com.itats.huwenakapp.koneksi.Servers.isServerConnected(Servers.java:38)
    at com.itats.huwenakapp.Login$1.onClick(Login.java:74)
    at android.view.View.performClick(View.java:5610)
    at
com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
    at android.view.View$PerformClick.run(View.java:22265)
W/System.err:     at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

A: As stated in the exception log you are getting android.os.NetworkOnMainThreadException this occurs when you are performing a network call on Main Thread / UI Thread of android. To resolve this issue you have to perform the call on a background thread. This could include using a AsyncTask (depricated) or Coroutines (only for Kotlin) or RxJava or any other threading way to run the the call on background thread.
You can also check this question for answers.

A: you got  android.os.NetworkOnMainThreadException that means you cant check this with your main UI thread. you may have to create a new Thread.
you may check like this in short:
    new Thread(new Runnable() {
        public void run() {
            Boolean connected = isServerConnected();
            YourActivityName.this.runOnUiThread(new Runnable() {
                public void run() {
                    if(connected){
                        Log.e("isConnected", connected + " ");
                        //do your stuff
                    }
                }
            });
        }
    }).start();

// your found method
public static boolean isServerConnected() {
    try {
        URL myUrl = new URL(URL_CONNECTION);
        URLConnection connection = myUrl.openConnection();
        connection.setConnectTimeout(10000);
        connection.connect();
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

make sure URL_CONNECTION is properly formatted
Full Example:
      btnLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            new Thread(new Runnable() {
                public void run() {
                    Boolean connected = isServerConnected();
                    YourActivityName.this.runOnUiThread(new Runnable() {
                        public void run() {
                            if (connected) {
                                Log.e("isConnected", connected + " ");
                                //do your stuff
                                username = edtUser.getText().toString();
                                password = edtPass.getText().toString();
                                login();
                            } else {
                                Toast.makeText(getApplicationContext(), "Server is not connected", Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                }
            }).start();

        }
    });


text:
Q: How to give color to blurrview in iOS? I have created a blur view and added in the subview of main view. This is my code:
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.tintColor  = UIColor.green
blurEffectView.tag = 999;
let frame:CGRect = CGRect(x: self.internalView.frame.size.width + self.internalView.frame.origin.x, y: self.drawerView.frame.origin.y, width: self.drawerView.frame.size.width - self.internalView.frame.size.width, height: self.drawerView.frame.size.height)

blurEffectView.frame = frame
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.drawerView.insertSubview(blurEffectView, belowSubview: self.btnClose)

Now, I want to make it as dark green blur.

How can I achieve this using the code above?

A: Try this: Swift 3.0
 override func viewDidLoad() {
    super.viewDidLoad()

    let visualEffectView = UIVisualEffectView.init(effect: UIBlurEffect.init(style: .light))
    visualEffectView.backgroundColor = UIColor.init(red: 0.0, green: 0.5, blue: 0.0, alpha: 0.5)
    visualEffectView.frame = self.view.bounds
    self.view.addSubview(visualEffectView)

}

This line of code should change the background color of visualEffectView.
visualEffectView.backgroundColor = UIColor.init(red: 0.0, green: 0.5, blue: 0.0, alpha: 0.5)

Hope it helps!

A: You can try this one and adjust the alpha value:
blurView.backgroundColor = UIColor.red.withAlphaComponent(0.3)


text:
Q: Why does this element translate to 0,0,0 in my SVG/CSS/JS animation? I'm trying to animate an SVG I created in Inkscape using CSS/JS, and it seems like it should be fairly simple: I'm just adding the .rotating class to #gear-small on hover:
.logo {
  overflow: visible;
  transform: scale(0.5);
}

.rotating {
  animation-name: rotate;
  animation-duration: 3s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}

@keyframes rotate {
  from {transform: rotate(0deg);}
  to {transform: rotate(360deg);}
}

The problem is that, although the element rotates, it also seems to move to 0,0,0. I'm not sure what's going on here. I suspect it might have to do with the inline transform properties, but I'm pretty dumb on this one, so any help would be appreciated.
Looking at the jsfiddle I made should make everything clear.
I've tried overriding transform properties in my stylesheet, but it still seems to translate it to 0,0,0 no matter what I do.
Edit: To be clear, the gear is supposed to stay in place and rotate like a wheel.
Edit: Here's the complete html, css and js (as per requested, sorry about that):
html:
<!DOCTYPE HTML>
<html lang='en'>
  <head>
    <meta charset='utf-8'/>
    <link type='text/css' rel='stylesheet' href='test.css'/>
  </head>
  <body>
    <svg
      class='logo'
      width="64.32mm" height="120.5mm" version="1.1" viewBox="0 0 64.32 120.5" xmlns="http://www.w3.org/2000/svg">
      <g fill="#b3b3b3" stroke="#000" stroke-width=".26458">
        <g id="gear-small" transform="translate(40.785 47.68)">
          <path d="m8.3326-1.2236 1.0635-0.15617 0.6238 0.06064 1.7592 0.79639v1.0455l-1.7592 0.79639-0.6238 0.06064-1.0635-0.15617-0.50455 1.883 0.9991 0.3965 0.5099 0.36441 1.1254 1.5693-0.52274 0.90542-1.9218-0.18993-0.57054-0.25938-0.84293-0.667-1.3785 1.3785 0.667 0.84293 0.25938 0.57054 0.18993 1.9218-0.90542 0.52274-1.5693-1.1254-0.36441-0.5099-0.3965-0.9991-1.883 0.50455 0.15617 1.0635-0.06064 0.6238-0.79639 1.7592h-1.0455l-0.79639-1.7592-0.06064-0.6238 0.15617-1.0635-1.883-0.50455-0.3965 0.9991-0.36441 0.5099-1.5693 1.1254-0.90542-0.52274 0.18993-1.9218 0.25938-0.57054 0.667-0.84293-1.3785-1.3785-0.84293 0.667-0.57054 0.25938-1.9218 0.18993-0.52274-0.90542 1.1254-1.5693 0.5099-0.36441 0.9991-0.3965-0.50455-1.883-1.0635 0.15617-0.6238-0.06064-1.7592-0.79639v-1.0455l1.7592-0.79639 0.6238-0.06064 1.0635 0.15617 0.50455-1.883-0.9991-0.3965-0.5099-0.36441-1.1254-1.5693 0.52274-0.90542 1.9218 0.18993 0.57054 0.25938 0.84293 0.667 1.3785-1.3785-0.667-0.84293-0.25938-0.57054-0.18993-1.9218 0.90542-0.52274 1.5693 1.1254 0.36441 0.5099 0.3965 0.9991 1.883-0.50455-0.15617-1.0635 0.06064-0.6238 0.79639-1.7592h1.0455l0.79639 1.7592 0.06064 0.6238-0.15617 1.0635 1.883 0.50455 0.3965-0.9991 0.36441-0.5099 1.5693-1.1254 0.90542 0.52274-0.18993 1.9218-0.25938 0.57054-0.667 0.84293 1.3785 1.3785 0.84293-0.667 0.57054-0.25938 1.9218-0.18993 0.52274 0.90542-1.1254 1.5693-0.5099 0.36441-0.9991 0.3965z"/>
          <circle r="7.9375"/>
        </g>
        <g id="gear-medium" transform="translate(22.021 22.021)">
          <path d="m18.468-1.4872 0.46392-0.03736 1.237 0.20261 1.7194 0.71941v1.2051l-1.7194 0.71941-1.237 0.20261-0.46392-0.03736-0.24437 1.8562 0.45777 0.08399 1.1424 0.51586 1.4746 1.1399-0.31191 1.164-1.847 0.24989-1.2473-0.12445-0.43844-0.15615-0.71647 1.7297 0.42044 0.1996 0.96995 0.79396 1.1293 1.4827-0.60255 1.0437-1.8487-0.23666-1.1726-0.44302-0.38308-0.26431-1.1398 1.4854 0.35445 0.30162 0.73142 1.0179 0.70707 1.7245-0.85214 0.85214-1.7245-0.70707-1.0179-0.73142-0.30162-0.35445-1.4854 1.1398 0.26431 0.38308 0.44302 1.1726 0.23666 1.8487-1.0437 0.60255-1.4827-1.1293-0.79396-0.96995-0.1996-0.42044-1.7297 0.71647 0.15615 0.43844 0.12445 1.2473-0.24989 1.847-1.164 0.31191-1.1399-1.4746-0.51586-1.1424-0.08399-0.45777-1.8562 0.24437 0.03736 0.46392-0.20261 1.237-0.71941 1.7194h-1.2051l-0.71941-1.7194-0.20261-1.237 0.03736-0.46392-1.8562-0.24437-0.08399 0.45777-0.51586 1.1424-1.1399 1.4746-1.164-0.31191-0.24989-1.847 0.12445-1.2473 0.15615-0.43844-1.7297-0.71647-0.1996 0.42044-0.79396 0.96995-1.4827 1.1293-1.0437-0.60255 0.23666-1.8487 0.44302-1.1726 0.26431-0.38308-1.4854-1.1398-0.30162 0.35445-1.0179 0.73142-1.7245 0.70707-0.85214-0.85214 0.70707-1.7245 0.73142-1.0179 0.35445-0.30162-1.1398-1.4854-0.38308 0.26431-1.1726 0.44302-1.8487 0.23666-0.60255-1.0437 1.1293-1.4827 0.96995-0.79396 0.42044-0.1996-0.71647-1.7297-0.43844 0.15615-1.2473 0.12445-1.847-0.24989-0.31191-1.164 1.4746-1.1399 1.1424-0.51586 0.45777-0.08399-0.24437-1.8562-0.46392 0.03736-1.237-0.20261-1.7194-0.71941v-1.2051l1.7194-0.71941 1.237-0.20261 0.46392 0.03736 0.24437-1.8562-0.45777-0.08399-1.1424-0.51586-1.4746-1.1399 0.31191-1.164 1.847-0.24989 1.2473 0.12445 0.43844 0.15615 0.71647-1.7297-0.42044-0.1996-0.96995-0.79396-1.1293-1.4827 0.60255-1.0437 1.8487 0.23666 1.1726 0.44302 0.38308 0.26431 1.1398-1.4854-0.35445-0.30162-0.73142-1.0179-0.70707-1.7245 0.85214-0.85214 1.7245 0.70707 1.0179 0.73142 0.30162 0.35445 1.4854-1.1398-0.26431-0.38308-0.44302-1.1726-0.23666-1.8487 1.0437-0.60255 1.4827 1.1293 0.79396 0.96995 0.1996 0.42044 1.7297-0.71647-0.15615-0.43844-0.12445-1.2473 0.24989-1.847 1.164-0.31191 1.1399 1.4746 0.51586 1.1424 0.08399 0.45777 1.8562-0.24437-0.03736-0.46392 0.20261-1.237 0.71941-1.7194h1.2051l0.71941 1.7194 0.20261 1.237-0.03736 0.46392 1.8562 0.24437 0.08399-0.45777 0.51586-1.1424 1.1399-1.4746 1.164 0.31191 0.24989 1.847-0.12445 1.2473-0.15615 0.43844 1.7297 0.71647 0.1996-0.42044 0.79396-0.96995 1.4827-1.1293 1.0437 0.60255-0.23666 1.8487-0.44302 1.1726-0.26431 0.38308 1.4854 1.1398 0.30162-0.35445 1.0179-0.73142 1.7245-0.70707 0.85214 0.85214-0.70707 1.7245-0.73142 1.0179-0.35445 0.30162 1.1398 1.4854 0.38308-0.26431 1.1726-0.44302 1.8487-0.23666 0.60255 1.0437-1.1293 1.4827-0.96995 0.79396-0.42044 0.1996 0.71647 1.7297 0.43844-0.15615 1.2473-0.12445 1.847 0.24989 0.31191 1.164-1.4746 1.1399-1.1424 0.51586-0.45777 0.08399z"/>
          <circle r="7.9375"/>
        </g>
        <g id="gear-large" transform="translate(32.191 88.375)">
          <path d="m28.586-1.6656 1.704 0.34308 1.707 0.68859v1.2678l-1.707 0.68859-1.704 0.34308-0.14507 1.6581 1.6186 0.63377 1.5615 0.97454-0.22016 1.2486-1.8006 0.38172-1.7377 0.04196-0.43078 1.6077 1.4839 0.90519 1.3685 1.2309-0.43361 1.1914-1.8395 0.06325-1.7186-0.26042-0.70341 1.5085 1.3042 1.1491 1.134 1.4498-0.63391 1.098-1.8226-0.25714-1.6473-0.5549-0.95467 1.3634 1.0848 1.3581 0.865 1.6247-0.81494 0.9712-1.7502-0.56973-1.5259-0.8325-1.1769 1.1769 0.8325 1.5259 0.56973 1.7502-0.9712 0.81494-1.6247-0.865-1.3581-1.0848-1.3634 0.95467 0.5549 1.6473 0.25714 1.8226-1.098 0.63391-1.4498-1.134-1.1491-1.3042-1.5085 0.70341 0.26042 1.7186-0.06325 1.8395-1.1914 0.43361-1.2309-1.3685-0.90519-1.4839-1.6077 0.43078-0.04196 1.7377-0.38172 1.8006-1.2486 0.22016-0.97454-1.5615-0.63377-1.6186-1.6581 0.14507-0.34308 1.704-0.68859 1.707h-1.2678l-0.68859-1.707-0.34308-1.704-1.6581-0.14507-0.63377 1.6186-0.97454 1.5615-1.2486-0.22016-0.38172-1.8006-0.04196-1.7377-1.6077-0.43078-0.90519 1.4839-1.2309 1.3685-1.1914-0.43361-0.06325-1.8395 0.26042-1.7186-1.5085-0.70341-1.1491 1.3042-1.4498 1.134-1.098-0.63391 0.25714-1.8226 0.5549-1.6473-1.3634-0.95467-1.3581 1.0848-1.6247 0.865-0.9712-0.81494 0.56973-1.7502 0.8325-1.5259-1.1769-1.1769-1.5259 0.8325-1.7502 0.56973-0.81494-0.9712 0.865-1.6247 1.0848-1.3581-0.95467-1.3634-1.6473 0.5549-1.8226 0.25714-0.63391-1.098 1.134-1.4498 1.3042-1.1491-0.70341-1.5085-1.7186 0.26042-1.8395-0.06325-0.43361-1.1914 1.3685-1.2309 1.4839-0.90519-0.43078-1.6077-1.7377-0.04196-1.8006-0.38172-0.22016-1.2486 1.5615-0.97454 1.6186-0.63377-0.14507-1.6581-1.704-0.34308-1.707-0.68859v-1.2678l1.707-0.68859 1.704-0.34308 0.14507-1.6581-1.6186-0.63377-1.5615-0.97454 0.22016-1.2486 1.8006-0.38172 1.7377-0.04196 0.43078-1.6077-1.4839-0.90519-1.3685-1.2309 0.43361-1.1914 1.8395-0.06325 1.7186 0.26042 0.70341-1.5085-1.3042-1.1491-1.134-1.4498 0.63391-1.098 1.8226 0.25714 1.6473 0.5549 0.95467-1.3634-1.0848-1.3581-0.865-1.6247 0.81494-0.9712 1.7502 0.56973 1.5259 0.8325 1.1769-1.1769-0.8325-1.5259-0.56973-1.7502 0.9712-0.81494 1.6247 0.865 1.3581 1.0848 1.3634-0.95467-0.5549-1.6473-0.25714-1.8226 1.098-0.63391 1.4498 1.134 1.1491 1.3042 1.5085-0.70341-0.26042-1.7186 0.06325-1.8395 1.1914-0.43361 1.2309 1.3685 0.90519 1.4839 1.6077-0.43078 0.04196-1.7377 0.38172-1.8006 1.2486-0.22016 0.97454 1.5615 0.63377 1.6186 1.6581-0.14507 0.34308-1.704 0.68859-1.707h1.2678l0.68859 1.707 0.34308 1.704 1.6581 0.14507 0.63377-1.6186 0.97454-1.5615 1.2486 0.22016 0.38172 1.8006 0.04196 1.7377 1.6077 0.43078 0.90519-1.4839 1.2309-1.3685 1.1914 0.43361 0.06325 1.8395-0.26042 1.7186 1.5085 0.70341 1.1491-1.3042 1.4498-1.134 1.098 0.63391-0.25714 1.8226-0.5549 1.6473 1.3634 0.95467 1.3581-1.0848 1.6247-0.865 0.9712 0.81494-0.56973 1.7502-0.8325 1.5259 1.1769 1.1769 1.5259-0.8325 1.7502-0.56973 0.81494 0.9712-0.865 1.6247-1.0848 1.3581 0.95467 1.3634 1.6473-0.5549 1.8226-0.25714 0.63391 1.098-1.134 1.4498-1.3042 1.1491 0.70341 1.5085 1.7186-0.26042 1.8395 0.06325 0.43361 1.1914-1.3685 1.2309-1.4839 0.90519 0.43078 1.6077 1.7377 0.04196 1.8006 0.38172 0.22016 1.2486-1.5615 0.97454-1.6186 0.63377z"/>
          <circle r="7.9375"/>
        </g>
      </g>
    </svg>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="test.js"></script>
  </body>
</html>

test.css:
.logo {
  overflow: visible;
  transform: scale(0.5);
}

#gear-small {
  transform: translate(40.785, 47.68) !important;
}

.rotating {
  animation-name: rotate;
  animation-duration: 3s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}

@keyframes rotate {
  from {transform: rotate(0deg);}
  to {transform: rotate(360deg);}
}

test.js:
$(document).ready(function() {
  $('.logo').hover(function() {
    $('#gear-small').addClass('rotating');
  }, function() {
    $('#gear-small').removeClass('rotating');
  });
});

A: You forgot to add the initial transformation to your keyframes, so it's being overriden:
@keyframes rotate {
  from {transform: translate(40.785px, 47.68px) rotate(0deg);}
  to {transform: translate(40.785px, 47.68px) rotate(360deg);}
}

Please see the updated jsfiddle: https://jsfiddle.net/mj2ozjvd/2/
You may update animation-duration with the correct timings (it's easy to count) for the precize animation.

A: There is an implicit transform origin of 0,0,0
I changed it to be 23,23,23, have a look at the effect of that:
.rotating {
  animation-name: rotate;
  animation-duration: 3s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
  transform-origin: 23px 23px 23px;
}

https://jsfiddle.net/auext03x/
UPDATE
I moved the circle of the small cog (instead of using transform), and put a move at the beginning of the path for the cog.
https://jsfiddle.net/auext03x/


text:
Q: Install4j installation for all users I am working on packaging Java 7 application for Windows using install4j. In the installation i want to provide a choice to install the application for all users or just for the current user.

A: If by installing "for all users" you mean installing to the program files directory, then you can do that by setting the installation directory as runtime.
Add a custom form where you ask the user whether they want to to install it for all users or just the current user. To that form screen, add a "Run script" action that sets the installation directory via
context.setInstallationDirectory(...)

The program files directory is available from
WinFileSystem.getProgramFilesDirectory()

and the home directory from
System.getProperty("user.home")

If you want to install to the program files directory, you need elevated privileges. By default, install4j projects have a "Request privileges" action in the startup node of the installer. Move that action before the above "Run script" action and set its condition expression so that it is only executed for the "all users" case.


text:
Q: OpenCV console application I got an example of making contours around what it sees in a bitmap picture, and it works great!
But, the code is going to be part of a bigger project using leap motion and I need it to run in a console and just give me the values. I don't need any windows to be opened.
So when I am running the following code, I get _pFirstBlock == pHead. I searched for the error and it seemed to be that my DLL's are not in Multi-threaded Debug DLL (/MDd), but they are. I know this because if I delete everything in main(), the application works fine. If I run the application as usual, I get the error at the end of main() - when releasing memory. I put all my code from main() in an empty scope just to validate this, and it crashes with the same error at the end of the scope.
So it clearly has something to do with releasing memory.
What would it be?
Using OpenCV 2413
Full code:
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace cv;
using namespace std;
Mat src; Mat src_gray;
int thresh = 20;
RNG rng(12345);

int main(int, char** argv)
{
    {
        src = imread(argv[1], 1);
        cvtColor(src, src_gray, COLOR_BGR2GRAY);
        blur(src_gray, src_gray, Size(3, 3));

        cout << endl;
        Mat threshold_output;
        vector<vector<Point> > contours;
        vector<Vec4i> hierarchy;
        threshold(src_gray, threshold_output, thresh, 255, THRESH_BINARY);
        findContours(threshold_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0));
        vector<vector<Point> > contours_poly(contours.size());
        vector<Point2f>center(contours.size());
        vector<float>radius(contours.size());
        for (size_t i = 0; i < contours.size(); i++)
        {
            approxPolyDP(Mat(contours[i]), contours_poly[i], 3, true);
            minEnclosingCircle(contours_poly[i], center[i], radius[i]);
        }
        cout << "Found " << contours.size() << " contours. " << endl;
        Mat drawing = Mat::zeros(threshold_output.size(), CV_8UC3);
        for (size_t i = 0; i < contours.size(); i++)
        {
            Scalar color = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
            circle(drawing, center[i], (int)radius[i], color, 2, 8, 0);

            cout << "Found one at: (" << center[i].x << ", " << center[i].y << ") radius = " << radius[i] << endl;
        }

        drawing.release();
        threshold_output.release();
        src_gray.release();
        src.release();

    } //////////// CRASHES

    return(0);
}


text:
Q: Passing vector of Class> objects to other activity - in Android I'd like to ask what I'm doing wrong if I want to pass such data to other class:
String [] codes = {"code"};
Class<?> [] classes = { TestActivity.class };

    Intent i = new Intent();
    Pack p = new Pack();
    p.eat(classes,codes);
    i.putExtra("com.mbar", p);
    i.setClass(this, CaptureActivity.class);
    startActivity(i);

}
}

Later in other activity I try it to unpack like that:
Bundle b = getIntent().getExtras();
Pack p = (Pack)b.getParcelable("com.mbar");
if(p!=null){
classes = p.getClasses();
codes = p.getNames();

The Pack class which is Parcelable looks like:
package com.mbar;

import android.os.Parcel;
import android.os.Parcelable;

public class Pack implements Parcelable {
Class<?>[] classes;
String [] codes;

public void eat(Class<?>[] classes,String [] codes){
    this.classes = classes;
    this.codes = codes;
}
public Class<?>[] getClasses(){
    return this.classes;
}
public String [] getNames(){
    return this.codes;
}
@Override
public int describeContents() {
    // TODO Auto-generated method stub
    return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
}
}

A: String [] codes = {"code"};
Class<?> [] classes = { TestActivity.class };

    Intent i = new Intent();
    Pack p = new Pack(classes,codes);
    i.putExtra("com.mbar", p);
    i.setClass(this, CaptureActivity.class);
    startActivity(i)

Pack p = (Pack)getIntent().getParcelableExtra("com.mbar");
if(p!=null){
classes = p.getClasses();
codes = p.getNames();

public static class Pack implements Parcelable {
    Class<?>[] classes;
    String[] codes;

    public Pack(Class<?>[] classes, String[] codes) {
        this.classes = classes;
        this.codes = codes;
    }

    public Pack(Parcel in) {
        int len = in.readInt();
        String[] classnames = new String[len];
        in.readStringArray(classnames);
        classes = new Class<?>[classnames.length];
        for (int i = 0; i < classnames.length; i++) {
            try {
                classes[i] = Class.forName(classnames[i]);
            } catch (ClassNotFoundException e) {
            }
        }
        len = in.readInt();
        codes = new String[len];
        in.readStringArray(codes);
    }

    public Class<?>[] getClasses() {
        return this.classes;
    }

    public String[] getNames() {
        return this.codes;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Parcelable.Creator<Pack> CREATOR = new Parcelable.Creator<Pack>() {
        public Pack createFromParcel(Parcel in) {
            return new Pack(in);
        }

        public Pack[] newArray(int size) {
            return new Pack[size];
        }
    };

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        String[] classnames = new String[classes.length];
        for (int i = 0; i < classes.length; i++) {
            classnames[i] = classes[i].getName();
        }
        dest.writeInt(classnames.length);
        dest.writeStringArray(classnames);
        dest.writeInt(codes.length);
        dest.writeStringArray(codes);
    }
}


text:
Q: FAILURE: Build failed with an exception - Execution failed for task ':app:mergeExtDexDebug' This is what happened when I actually import a firestore dependency, all I thought it is about the connection but these errors happened all the time. Please help me

*

*What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Failed to transform firebase-storage-19.2.1.aar (com.google.firebase:firebase-storage:19.2.1) to match attributes {artifactType=android-dex, dexing-enable-desugaring=true, dexing-incremental-transform=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.

A: Did you try to add maven.google.com to your root level build.gradle file?

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

If you are using the android gradle plugin 3.x you can also use:
allprojects {
    repositories {
        jcenter()
        google()
    }
}

*

*Also maybe you forgot to add core dependency

implementation 'com.google.firebase:firebase-core:16.0.1'


text:
Q: Please create a tag synonyms between tooltipS and tooltip Please create a tag synonyms between tooltips and tooltip.
(I don't have enough rep in the tags to suggest one my self)
tooltip has 726 questions and tooltips has 144 questions with 22 questions in common.


text:
Q: xampp Apache won't start tried all in my Xampp Apache never start, so I try to change the port as all the suggestion. But even after that I get the same error message.
When I start Xampp I get his message

But I have change my port number 80 to 81 and when it does not work I have change it to 88 even and still it is the same result.
See the visual !

Anyone knows what I should do !
I am running it on Windows 8 !

A: Is Skype or Teamviewer is running on your system? If yes, close all application and Try, Otherwise in worst case, Try to install it in some other drive than C:


text:
Q: Contractibility of space of positive definite matrices of determinant 1 I know (of course) how to prove that the space ${\mathcal P}$ of all positive definite, symmetric matrices is contractible: the homotopy $H(t,P)=tE_n+(1-t)P$ uniformly moves all $P$ to $E_n$ through positive definite, symmetric matrices.
Now restrict to ${\mathcal P}_1$, that is, matrices in ${\mathcal P}$ of determinant $1$. The above homotopy does not preserve the property of having determinant $1$.
Is there some elegant way of proving that ${\mathcal P}_1$ is contractible?

A: Let $P'$ be the space of positive definite symmetric matrices with trace $1$. Since it is the intersection of $P$ with an affine space, it is still convex, hence contractible. Now the map from $P_1$ to $P'$ where you divide by trace is a homeomorphism.


text:
Q: creating a directory in java I'm trying to create a directory and copy files to it. The code I've implemented and its output is below. The problem seems self explanatory, but I'll make it explicit for those who can't tell.
Problem

No matter what I do, I can't seem to create the destination file required to copy the file.
Code

get is the file to be copied, and dest is the directory to which it will be copied. Line numbers and "ERR>" were added for clarity. I've commented out other methods of file creation which I've tried, but they all failed.
115:  private void copyTo(File get, File dest)
116:  {
117:    try
118:    {
119:      dest = new File((dest.getPath().endsWith(File.separator) ? dest.getPath() : dest.getPath() + File.separator) + get.getName());
120:
121:      java.io.FileInputStream fis = new java.io.FileInputStream(get);
122:      if (dest.exists())
123:        while(!dest.delete());
124:      dest.mkdir();
125://      dest.createNewFile();
126://      java.io.FileWriter w = new java.io.FileWriter(dest);
127://      w.write("");
128:      System.out.println("Writing \"" + get + "\" to \"" + dest + "\"");
129:ERR>  java.io.FileOutputStream fos = new java.io.FileOutputStream(dest);
130:      int b;
131:      do
132:      {
133:        b = fis.read();
134:        fos.write(b);
135:      }while (b != -1);
136:    }
137:    catch (FileNotFoundException ex)
138:    {
139://      System.err.println("404: \"" + get + "\"");
140:      ex.printStackTrace();
141:    }
142:    catch (java.io.IOException ex)
143:    {
144://      System.err.println("IO exception on \"" + get + "\"");
145:      ex.printStackTrace();
146:    }
147:  }

Output

Writing "J:\warehouse.txt" to "J:\backup\warehouse.txt"
java.io.FileNotFoundException: J:\backup\warehouse.txt (The system cannot find the path specified)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
        at copy.TUI.copyTo(TUI.java:129)
        at copy.TUI.copy(TUI.java:110)
        at copy.TUI.run(TUI.java:102)
        at copy.Main.main(Main.java:37)

A: Use dest.getParentFile().mkdir(). This will create the parent dir for your dest file. In case multiple parent path elements might be missing you can use the mkdirs() method to create all missing directories recursively.

A: Was able to fix it myself. Pretty derpy of me to not see it in the first place...
  private void copyTo(File get, File dest)
  {
    try
    {
      File newDest = new File((dest.getPath().endsWith(File.separator) ? dest.getPath() : dest.getPath() + File.separator) + get.getName());

      java.io.FileInputStream fis = new java.io.FileInputStream(get);
      if (dest.exists())
       dest.delete();
      dest.mkdirs();
      dest.setWritable(true);
      dest.setReadable(true);
//      dest.createNewFile();
//      java.io.FileWriter w = new java.io.FileWriter(dest);
//      w.write("");
      System.out.println("Writing \"" + get + "\" to \"" + dest + "\"");
      java.io.FileOutputStream fos = new java.io.FileOutputStream(newDest);
      int b;
      do
      {
        b = fis.read();
        fos.write(b);
      }while (b != -1);
    }
    catch (FileNotFoundException ex)
    {
//      System.err.println("404: \"" + get + "\"");
      ex.printStackTrace();
    }
    catch (java.io.IOException ex)
    {
//      System.err.println("IO exception on \"" + get + "\"");
      ex.printStackTrace();
    }
  }

A: Use following -
dest = dest.isDirectory() ?  new File(dest, get.getName()):  new File(dest.getParentDirectory(), get.getName());
dest.getParentDirectory().mkdirs();


text:
Q: Update JTable automically How would a JTable update automatically based off of time? So every time the current time changes, the table updates automatically. Could some provide a snippet of code of how this may work in Java? To have the Table update after the time changes. Please and thank you in advance.
          package times;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

public class TableTimeChange {

DefaultTableModel model2 = new DefaultTableModel();

String rowdata[] = new String[8];
Date[] date123 = new Date[8];

private SimpleDateFormat format = new SimpleDateFormat("HH:mm:dd:ss");
private JTable table = new JTable(getTableModel());

public TableTimeChange() {
    table.setPreferredScrollableViewportSize(table.getPreferredSize());
    JFrame frame = new JFrame();
    frame.add(new JScrollPane(table));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();

    Timer timer = new Timer(1000, new TimerListener());
    timer.start();
    frame.setVisible(true);
}

private TableModel getTableModel() {
    String[] cols = {"Time"};

    String array1[] = { "12-12-2001 10:18:30 PM", "12-15-2001 10:18:54 PM"};
    String array2[] = {"01-19-1989 01:18:27 AM", "01-19-2019 01:28:36 PM"};
    String array3[] = {"12-05-1989 05:18:57 PM", "08-25-1989 09:18:27 PM"};
    String array4[] = { "10-15-1985 09:18:17 AM", "10-25-1985 06:48:27 AM"};
    String array5[] = {"06-10-2001 03:09:19 AM", "05-16-2011 03:29:10 AM"};
    String array6[] = {"01-12-2000 09:00:08 PM", "11-22-2010 07:00:56 PM"};
    String array7[] = { "07-19-1969 12:18:47 PM", "02-05-1969 01:18:17 AM"};
    String array8[] = {"01-09-2010 10:09:50 AM", "12-09-2010 05:09:10 PM"};

    rowdata[0] = array1[0];
    rowdata[1] = array2[0];
    rowdata[2] = array3[0];
    rowdata[3] = array4[0];
    rowdata[4] = array5[0];
    rowdata[5] = array6[0];
    rowdata[6] = array7[0];
    rowdata[7] = array8[0];

    for(int t = 0; t<rowdata.length; t++)
    {

        DateFormat sdf = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss a");
        DateFormat sdf3 = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss a");

        try {

            date123[t] = sdf.parse(rowdata[t]);

        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    for(int i = 0; i<8; i++)
    {

    String[][] data = {{getFormatDate(date123[i])},{ getFormatDate(date123[i])}};
    DefaultTableModel model = new DefaultTableModel(data, cols);

   model2 = model;

    }

    return model2;
}

private String getFormatDate(Date date) {
    return format.format(date);
}

private class TimerListener implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
        DefaultTableModel model = (DefaultTableModel)table.getModel();
        for (int i = model.getRowCount() -1; i >= 0; i--) {
            model.setValueAt(getFormatDate(date123[i]), i, 0);
        }
    }
}

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            new TableTimeChange();
        }
    });
}
}

A: Just use a Swing Timer, like I mention in the comment. You need to provide an ActionListener to the Timer, of which the actionPerformed will be called every so many milliseconds (whatever you provide as the first argument in the constructor). There you will update the table model with the new Date or formatted date (As I did in the example below), and change whatever data in the table based on that date.
See more at How to Use Swing Timers
Disclaimer: I'm so out of it. Why the heck did I use dd in the format? That should not be there. It should be "HH:mm:ss". I'm too lazy to change it.

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

public class TableTimeChange {

    private SimpleDateFormat format = new SimpleDateFormat("HH:mm:dd:ss");
    private JTable table = new JTable(getTableModel());

    public TableTimeChange() {
        table.setPreferredScrollableViewportSize(table.getPreferredSize());
        JFrame frame = new JFrame();
        frame.add(new JScrollPane(table));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();

        Timer timer = new Timer(1000, new TimerListener());
        timer.start();
        frame.setVisible(true);
    }

    private TableModel getTableModel() {
        String[] cols = {"Time", "Is Seconds Even"};
        Object[][] data = { { getNewRow() }, { getNewRow() } };
        DefaultTableModel model = new DefaultTableModel(data, cols);
        return model;
    }

    private String getFormatDate(Date date) {
        return format.format(date);
    }

    private Object[] getNewRow() {
        Calendar cal = Calendar.getInstance();
        int seconds = cal.get(Calendar.SECOND);
        boolean isSecondsEven = (seconds % 2 == 0);
        return new Object[] { getFormatDate(cal.getTime()), isSecondsEven };
    }

    private class TimerListener implements ActionListener {

        @Override
        public void actionPerformed(ActionEvent e) {
            DefaultTableModel model = (DefaultTableModel)table.getModel();
            for (int i = model.getRowCount() -1; i >= 0; i--) {
                Object[] row = getNewRow();
                model.setValueAt(row[0], i, 0);
                model.setValueAt(row[1], i, 1);
            }
        }
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new TableTimeChange();
            }
        });
    }
}

A: You can use Timer
import java.util.Timer;
...
Timer timer = new Timer();
timer.schedule(new TimerTask()
{
  @Override
  public void run()
  {
    // Your code here
  }
}, time);

A: THIS:
Timer timer = new Timer(500,new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent ae){
    if (a == true){
      System.out.println("Hello");
      a = false;
    }
    if (a == false){
      System.out.println("ByeBye");
      a = true;
    }
  }
}
boolean a = true;
public MyFrame(){
        initComponents();
        a = true;
        timer.start();
}


text:
Q: AttributeError when creating tkinter.PhotoImage object with PIL.ImageTk I am trying to place an image resized with PIL in a tkinter.PhotoImage object.
import tkinter as tk # I use Python3
from PIL import Image, ImageTk

master = tk.Tk()
img =Image.open(file_name)
image_resized=img.resize((200,200))
photoimg=ImageTk.PhotoImage(image_resized)

However, when I later try to call
photoimg.put( "#000000", (0,0) )

I get an
AttributError: 'PhotoImage' object has no attribute 'put'

While this:
photoimg=tk.PhotoImage(file=file_name)
photoimg.put( "#000000", (0,0))

doesn't raise an error.
What am I doing wrong?

A: ImageTk.PhotoImage as in PIL.ImageTk.PhotoImage is not the same class as tk.PhotoImage (tkinter.PhotoImage)  they just have the same name
here is ImageTk.PhotoImage docs:
http://pillow.readthedocs.io/en/3.1.x/reference/ImageTk.html#PIL.ImageTk.PhotoImage
as you can see there is no put method in it.
but ImageTk.PhotoImage do have it:
http://epydoc.sourceforge.net/stdlib/Tkinter.PhotoImage-class.html

edit:
first link is now broken, this is the new link:
https://pillow.readthedocs.io/en/stable/reference/ImageTk.html?highlight=ImageTK#PIL.ImageTk.PhotoImage

A: My solution was something like this:
from tkinter import *
from PIL import Image, ImageTk

root = Tk()

file = 'image.png'

zoom = 1.9

# open image
image = Image.open(file)
image_size = tuple([int(zoom * x)  for x in image.size])
x,y = tuple([int(x/2)  for x in image_size])

# canvas for image
canvas = Canvas(root, width=image_size[0], height=image_size[1], relief=RAISED, cursor="crosshair")
canvas.grid(row=0, column=0)

ImageTk_image = ImageTk.PhotoImage(image.resize(image_size))
image_on_canvas = canvas.create_image(0, 0, anchor = NW, image = ImageTk_image)

canvas.create_line(x-3, y, x+4, y, fill="#ff0000")
canvas.create_line(x, y-3, x, y+4, fill="#ff0000")
canvas.create_line(x, y, x+1, y, fill="#0000ff")

root.mainloop()


text:
Q: Fixed position on desktop browsers, relative/static position on mobile devices (Android, iOS ...) A few days ago i run into a problem that i did not imagine that exists regarding fixed position. I have searched and i have found a few articles regarding this (best described is http://bradfrost.com/blog/mobile/fixed-position/ ) and it seems that no viable solution exist.
On short, i want to have a fixed nav and a side block as you can see bellow (the code works perfect on desktop browsers (Chrome, Firefox, IE8) ), that shows and works like that only on desktop browsers. If a mobile device browser is used like Android, iOS, Windows Mobile eg), the fixed position for nav and sidebar should be changed in static or relative, to make those 2 blocks scroll up with the rest of the page.
Solutions via media queries are not ok because they target device screen and not actual device/browser.
Can this be done? I would appreciate a jsfiddle to test it with mobile devices. Thanks

var win      = $(window),
    fxel     = $('nav'),
    eloffset = fxel.offset().top;

win.scroll(function() {
    if (eloffset < win.scrollTop()) {
        fxel.addClass("fixed");
    } else {
        fxel.removeClass("fixed");
    }
});

/*!
 * StickySidebar jQuery Plugin v1.0.1
 * Copyright 2014 Dawid Pawelec
 * Released under the MIT license
 */

(function ($) {
    var $w = $(window);

    $.fn.stickySidebar = function (options) {
        var o = $.extend({}, $.fn.stickySidebar.defaults, options),
            $c = $(o.container);

        return this.each(function () {
            var $s = $(this),
                sh = $s.outerHeight(),
                originalMarginTop = parseInt($s.css('margin-top'), 10),
                top = $s.offset().top - o.offsetTop - originalMarginTop,
                bottom = $c.offset().top + $c.outerHeight() - o.offsetTop,

                handleScroll = function () {
                    var scroll = $w.scrollTop();
                    if (scroll > top) {
                        if (scroll + sh + o.offsetBottom > bottom && o.bottom) {
                            $s.removeClass(o.stuckClass);
                            $s.addClass(o.bottomClass);
                        } else {
                            $s.css('margin-top', o.offsetTop + originalMarginTop);
                            $s.addClass(o.stuckClass);
                        }
                    } else {
                        $s.css('margin-top', originalMarginTop);
                        $s.removeClass(o.stuckClass);
                        $s.removeClass(o.bottomClass);
                    }
                };

            $w.on('scroll', handleScroll);
        });

    };

    $.fn.stickySidebar.defaults = {
        stuckClass: 'fixed',
        bottomClass: 'bottom',
        container: '.container',
        offsetTop: 80,
        offsetBottom: 0,
        bottom: true
    };

}(jQuery));

// Usage
$('.sidebar').stickySidebar({
    container: '.container',
    offsetBottom: 5
});
.header, .footer {
    background: #ddd;
    padding: 15px;
    border-radius: 5px
}
.header-top {height:50px;}
.header-bottom {height:60px;}
.header {
    margin-bottom: 5px;
    height: 120px;
}

.container {
    background: #ddd;
    margin-bottom: 5px;
    padding: 5px;
    position: relative;
    border-radius: 5px;
}

.sidebar, .main-content {
    background: #fff;
    border: 1px solid #ccc;
    padding: 15px;
}

.sidebar {
    position: absolute;
    width: 169px;
    height: 200px;
}

.sidebar.fixed {
    position: fixed;
    top: 0;
}

.sidebar.bottom {
    bottom: 5px;
}

.main-content {
    margin-left: 205px;
    width: 253px;
    height: 2000px;
    min-height: 400px;
}

.footer {
    height: 500px;
}

nav {
  height:50px;
  padding:10px;
  background-color:black;
  color:white;
}

nav.fixed {
  position:fixed;
  top:0px;
  right:0px;
  left:0px;
  z-index:999;
}

Header

Sticky!

Sidebar

Main

    Footer

A: I managed to solve the issue by inserting all the jquery code between
if( /Windows|OS X/i.test(navigator.userAgent) ) {
ALL JQUERY CODE
}
This way, all is working properly (tested on windows - Chrome/IE8/Firefox; osx laptop -Safari/Chrome/Firefox; Android tablet)


text:
Q: JVM Monitor char array memory usage I'm creating a 4096 x 4096 array of my class. When I'm profiling, it's showing that the most memory is used by char arrays. I don't have any char arrays or strings in my class.
Here is my Java class:
public class MyClass {
    private int id;
    private boolean flag;

    public MyClass() {
        id = 0;
        flag = false;
    }
}

And my Main class:
public class Main {

    public static void main(String[] args) {
        MyClass[][] objects = new MyClass[4096][4096];

        for (int i = 0;i<4096;i++) {
            for(int j = 0;j<4096;j++) {
                objects[i][j] = new MyClass();
            }
        }

        while(true);
    }
}

I'm using JVM Monitor for profiling. Why is it showing this?
Here's a screenshot of it running in Eclipse:

A: From your image, it looks like the instances of MyClass you created aren't even live when you're doing the profiling.  The char[] usage is expected since char arrays back Strings, which are used extensively in class definitions, etc.
It could be that your array is getting garbage collected since it's not used.  Try adding a line after the sleep that uses the array, and then try to profile again.  Example:
    MyClass[][] objects = new MyClass[4096][4096];
    for(int i = 0;i<4096;i++)
    {
        for(int j = 0;j<4096;j++)
        {
            objects[i][j] = new MyClass();

        }
    }

    Thread.sleep(1000000);
    System.out.println(objects[10][40]);

This ensures that the array is not eligible for garbage collection until you've had a chance to profile it.

A: make sure you run System.gc() or similar before taking your heap dump. Else you will see a lot of objects that are no longer referenced in your sample.


text:
Q: UICollectionViewCell NSindexpath reference position How do I reference a specific UICollectionViewCell so that each of them segue to different VCs?
Here is the code for the cells:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    Cell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath];
    cell.imageView.image = [UIImage imageNamed:self.myCellImages[0]];
    UIImage *cellImage = [[UIImage alloc] init];
    cellImage = [UIImage imageNamed:[self.myCellImages objectAtIndex:indexPath.row]];
    cell.imageView.image = cellImage;
    return cell;
}

So this displays a bunch of different cells depending on how many images I load in to my array.
say my array is:
 self.myCellImages = @[@"1.jpg", @"2.jpg",.... @"20.jpg"];

how do I reference an individual cell so that it segues into different VC? For example, clicking on the cell that has image 1.jpg segues into 1VC and clicking on the cell with17.jpg segues to 17VC
Is it something like:
if (NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:0];)
{
//segue here
}

I can't figure out the correct syntax
Thanks to Timothy, I added
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:indexPath
{
    NSString *storyboardId = @"main_to_VC1";
    [self performSegueWithIdentifier:storyboardId sender:indexPath];
}

A: You need to establish segues between your collection view controller (not the cell) and the destination controllers, giving each a unique storyboard ID.
Then in the collectionView:didSelectItemAtIndexPath: delegate method, decide which controller you want to segue to based on the indexPath and initiate the segue programmatically:
- (void)collectionView:collectionView didSelectItemAtIndexPath:indexPath
{
    NSString *storyboardId = ...; // determine storyboard ID based on indexPath
    [self performSegueWithIdentifier:storyboardId sender:indexPath];
}


text:
Q: Doubt in css selector > [#id (.class1 or .class2)] I think that it should exist a better way of doing this...
I'm using the follow css selector
#book_form .ano_chegada, #book_form .ano_partida {...}

Html:
<form id="book_form">
<input class='ano_chegada' .../>
<input class='ano_partida' .../>
</form>

I really don't like to repeat the form id twice. Is it strictly necessary?
I know that it should work without the second id (#book_form) but it will select all the elements which share the same class (.ano_partida), right?
Thank you =) (Obrigado, in portuguese)
Cheers from Portugal

A: Yes, it is strictly necessary if you want to select only elements with those classes that live inside #book_form.
CSS by itself doesn't feature nested selectors, however some server-side solutions may provide you with CSS extensions that grant you such functionality.

A: Only one browser vendor has implemented this feature, 4 months ago in a browser still in beta.
See http://hacks.mozilla.org/2010/05/moz-any-selector-grouping/

A: You could adjust your HTML a bit to make the CSS selectors easier to use.  (This is not necessarily worth it, and could increase the size of your output.)
Add another class name to the class tags:
<form id="book_form">
<input class='ano_chegada something' .../>
<input class='ano_partida something' .../>
</form>

#book_form .something {...}

Or split what is there into multiple classes:
<form id="book_form">
<input class='ano chegada' .../>
<input class='ano partida' .../>
</form>

#book_form .ano {...}


text:
Q: Finding cosine similarity in R I have two csv files with characters running up to 50000 variables in a first column of these two files. I have to calculate cosine similarity between these columns of two files. I have tried to use LSA in R. But some problem with my result. Can any one help me? Below is my coding for the same.
library(lsa)
Gyan=tempfile()
dir.create(Gyan)
single_tags=read.csv(file.choose(), sep = ',')
as.character(single_tags$CULTAGS)
options(max.print = 1000000)
write(as.character(single_tags$CULTAGS),file = paste(Gyan, 'D1',sep = '1'))
Single_ASFA=read.csv(file.choose(),sep = ',')
options(max.print = 1000000)
as.character(Single_ASFA$ASFACV)
write(as.character(Single_ASFA$ASFCV),file = paste(Gyan, '/'))
Mycomparison = textmatrix(Gyan, minWordLength = 1)
Mycomparison
res = lsa::cosine(myMatrix[,1],myMatrix[,2])
res

A: It seems that there is no relation with myMatrix and Mycomparison. If you substitute MyMatrix to Mycomparison everything works. See as below:
# Data Simulation
single_tags_df <- data.frame( CULTAGS =  c("dog", "cat", "sushi", "mouse", "leech"))
Single_ASFA_df <- data.frame(ASFCV =  c("hamster", "mouse", "sushi", "man"))
write.csv(single_tags_df, file = "single.csv")
write.csv(Single_ASFA_df, file = "ASFA.csv")

library(lsa)
Gyan <- tempfile()
dir.create(Gyan)

single_tags <- read.csv("single.csv", sep = ",")
as.character(single_tags$CULTAGS)
options(max.print = 1000000)
write(as.character(single_tags$CULTAGS), file = paste(Gyan, "D1", sep = "/"))
Single_ASFA <- read.csv("ASFA.csv", sep = ",")
options(max.print = 1000000)
as.character(Single_ASFA$ASFCV)
write(as.character(Single_ASFA$ASFCV), file = paste(Gyan, "D2", sep = "/"))

Mycomparison <- textmatrix(Gyan)
Mycomparison
unlink(Gyan)

res <- lsa::cosine(Mycomparison[, 1], Mycomparison[, 2])
res
#           [,1]
# [1,] 0.4472136


text:
Q: Place div in specific column depending on screen size I have the following layout:

    Column 1

    Column 2

    Column 3

This needs to be displayed

As you can see there's an extra div in the third column. I'd like for it to be moved to the second column when the page is rendered in the xs size. I know I can just duplicate it but I'd rather not. Is there an easy/better way to accomplish this?
Edit: Bootply: http://www.bootply.com/FY98eVO6hC

A: Get html of #important div and append if window load on small screen
function resize() {
    var docWidth = $(window).width();
    if (docWidth < 768){
        var getData = $('#important').html();
        $('.col-lg-3.hidden-xs #important').remove();
        $('.col-lg-3.hidden-xs').append('
'+getData+'
');
    }
}

$(document).ready(function(){
    resize();

    $(window).resize(function() {
        resize();
    });
});

A: You should be able to just query the window width and act accordingly. The xs breakpoint is 767px. You will obviously need to add additional logic to cater for the #important element needing to go back to column 3 when greater than 767px though ;-)
js/jQuery
function resize()
{
    var width = $(window).width();
    if (width <= 767) // xs breakpoint
    {
        var html = $('#important').html(); // get the current "important" html
        $('#important').remove(); // remove from current column

        // Append to second/middle column
        $('.col-lg-4.hidden-xs').append('
'+ html +'
');
    }
 }

$(document).ready(function(){
    resize(); // set on page load

    // listen for window resize events
    $( window ).resize(function() {
          resize();
    });
});

NB: Standard Bootstrap Breakpoints
xs = 0 - 767 pixels
sm = 768 - 991 pixels
md = 992 - 1199 pixels
lg = 1200+ pixels


text:
Q: Constant spinning circle right hand side on iPhone 4 I have an iPhone 4 and for the last few days there has been a spinning circle in the right hand side of the status bar. I am wondering why this is.
I've tried turning off the Wi-Fi and restricting cellular data of all apps and nothing has worked. I am worried that there is something wrong with my phone. It seems to be draining my battery also.


text:
Q: Moving tensor products inside homs Suppose that $(\mathcal C, \otimes, I)$ is a closed symmetric monoidal category with $\hom(A,B)$ the hom-sets and $[A,B]$ the internal hom (where $[A,-]$ is right adjoint to $-\otimes A$).  Is there always a map $[A,B]\otimes C \to [A,B\otimes C]$?  Are there additional hypotheses needed to get such a map?
The map exists in $R$-mod, where $R$ is a commutative ring.  However, I am having trouble finding a purely categorical justification for its existence (unlike, say, the evaluation map $A\otimes [A,B]\to B$, which is the image of the identity map under a hom-tensor adjunction $\hom([A,B],[A,B])\to \hom([A,B]\otimes A,B)$).

A: A map $[A,B]\otimes C\to[A,B\otimes C]$ is the same as a map $A\otimes[A,B]\otimes C\to B\otimes C$, and you have one $A\otimes[A,B]\to B$.


text:
Q: Simple SAT practice geometry question I faced this question earlier today while taking a shot at this SAT Practice Test.
I solved the question pretty quick and my final result was 6. I reached that value by calculating the ACD triangle area then subtracting the ECD area from it. Pretty easy. To my surprise, there was no option for my result, and after I guessed what the answer was, this is their explanation as to why it should be 4.5. I think whoever wrote this explanation forgot that the AD and AE sides overlap and so AE is actually 4/3 (~1.333...) and not 1.
I ask you now: are they correct?

A: Yes, they are correct. If you go through the similar triangle proportion, you will see that they are correct.
$\frac{AB}{CD} = \frac{AE}{ED}$, $AE + ED = 4, AB = 3, CD = 9$
$\frac{3}{9} = \frac{AE}{4 - AE}$
$12 - 3AE = 9 AE$
$AE = 1$

A: Here's what we can infer from the given triangle:

We want to find the missing side $AE$. Based on the second triangle, using the ratios of $\displaystyle \frac{\text{height}}{\text{base}}$ for the method of similar triangles, we get
$$\frac{4}{12}= \frac{AE}{3}$$
Solving for $AE$ gives $AE=1$. Therefore, the area is
$$A=\frac 12 (AE)(CD)=\frac 12(1)(9)=\boxed{4.5}$$
which is choice (D).