text:
Q: How do I redirect output from the Visual Studio debugger? In Visual Studio 2008, I can specify a message to be printed when a breakpoint is hit (by right-clicking the breakpoint and choosing 'When Hit...'). When the program is run, these messages appear in the Output Window. I would like to know, is there any way to redirect them to a file?
Specifying >file.txt as a command argument to the program does not work: this redirects the program's output, but not the debugger's.
(FWIW the behaviour I wish to achieve is to get the debugger to repeatedly print a variable's value to a file, rather than peppering my code with printf/cout statements.)

A: Under Windows 2000, XP, Server 2003 and Vista DebugView will capture:

*

*Win32 OutputDebugString

*Kernel-mode DbgPrint

*All kernel-mode variants of DbgPrint implemented in Windows XP and Server 2003

DebugView allows you to filter the output, add time stamps and log to file.
The catch is, you need to run without attaching to the debugger, for DbgView to capture the output. (Use Ctrl+F5)

A: *

*Set the option Redirect all Output Window text to the Immediate Window. We find it in Tools → Options → Debugging → General (fifth to last item).

*Open the Immediate Window: Ctrl + Alt + I or Debug → Windows → Immediate Window

*Enter a command like the following in the Immediate window:
> Tools.LogCommandWindowOutput /on C:\mylogfile.txt

*To stop writing to the file, enter the following command in the Immediate window:
> Tools.LogCommandWindowOutput /off

A: I don't know of a way to write the output window contents to a file short of writing a VS plugin, but you can highlight the text in the output window and copy it to the clipboard, then paste it into a text file.


text:
Q: GCML Prediction Error 502 Bad Gateway An initial call (after every few hours) to the "Online" prediction services of GCML always results in Server Error 502. After a few minutes, the same request succeeds.
googleapiclient.errors.HttpError: <HttpError 502 when requesting https://ml.googleapis.com/v1beta1/projects/<project-name>/<model-name>/versions/<version-name>:predict?alt=json returned "Bad Gateway"

Why does this happen ? Is it that every time a request made to the model the restored session is cached so subsequent calls succeed while the initial call fails? How can this service be used for RRS (Request response service)
[Update]
Now getting 502 error on all the prediction services. Even for models which  were working before. Have tried local prediction on the models which work correctly

redpajama_set_name: RedPajamaStackExchange


text:
Q: Scala error: Exception in thread "main" org.apache.spark.SparkException: Task not serializable I got not serializable error when running this code:
import org.apache.spark.{SparkContext, SparkConf}
import scala.collection.mutable.ArrayBuffer
object Task1 {
  def findHighestRatingUsers(movieRating: String): (String) = {
    val tokens = movieRating.split(",", -1)
    val movieTitle = tokens(0)
    val ratings = tokens.slice(1, tokens.size)
    val maxRating = ratings.max
    var userIds = ArrayBuffer[Int]()

    for(i <- 0 until ratings.length){
      if (ratings(i) == maxRating) {
        userIds += (i+1)
      }
    }

    return movieTitle + "," + userIds.mkString(",")

    return movieTitle
  }

  def main(args: Array[String]) {

    val conf = new SparkConf().setAppName("Task 1")
    val sc = new SparkContext(conf)

    val Lines = sc.textFile(args(0))

    val TitleAndMaxUserIds = Lines.map(findHighestRatingUsers)
      .saveAsTextFile(args(1))
  }
}

The error occurs at line:
val TitleAndMaxUserIds =Lines.map(findHighestRatingUsers)
      .saveAsTextFile(args(1))

I believe this is due to something in function 'findHighestRatingUsers'. Could somebody explain why and how to fix it?
More info in the exception is like:
Exception in thread "main" org.apache.spark.SparkException: Task not serializable
    at org.apache.spark.util.ClosureCleaner$.ensureSerializable(ClosureCleaner.scala:416)
    at org.apache.spark.util.ClosureCleaner$.clean(ClosureCleaner.scala:406)
    at org.apache.spark.util.ClosureCleaner$.clean(ClosureCleaner.scala:162)
    at org.apache.spark.SparkContext.clean(SparkContext.scala:2362)
    at org.apache.spark.rdd.RDD.$anonfun$map$1(RDD.scala:396)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
    at org.apache.spark.rdd.RDD.withScope(RDD.scala:388)
    at org.apache.spark.rdd.RDD.map(RDD.scala:395)
    at Task1$.main(Task1.scala:63)
    at Task1.main(Task1.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
    at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:928)
    at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:180)
    at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:203)
    at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:90)
    at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1007)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1016)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.io.NotSerializableException: Task1$
Serialization stack:
    - object not serializable (class: Task1$, value: Task1$@3c770db4)
    - element of array (index: 0)
    - array (class [Ljava.lang.Object;, size 1)
    - field (class: java.lang.invoke.SerializedLambda, name: capturedArgs, type: class [Ljava.lang.Object;)
    - object (class java.lang.invoke.SerializedLambda, SerializedLambda[capturingClass=class Task1$, functionalInterfaceMethod=scala/Function1.apply:(Ljava/lang/Object;)Ljava/lang/Object;, implementation=invokeStatic Task1$.$anonfun$main$1:(LTask1$;Ljava/lang/String;)Ljava/lang/String;, instantiatedMethodType=(Ljava/lang/String;)Ljava/lang/String;, numCaptured=1])
    - writeReplace data (class: java.lang.invoke.SerializedLambda)
    - object (class Task1$$$Lambda$1023/20408451, Task1$$$Lambda$1023/20408451@4f59a516)
    at org.apache.spark.serializer.SerializationDebugger$.improveException(SerializationDebugger.scala:41)
    at org.apache.spark.serializer.JavaSerializationStream.writeObject(JavaSerializer.scala:47)
    at org.apache.spark.serializer.JavaSerializerInstance.serialize(JavaSerializer.scala:101)
    at org.apache.spark.util.ClosureCleaner$.ensureSerializable(ClosureCleaner.scala:413)
    ... 22 more

I checked this post
Difference between object and class in Scala and tried to use object to enclose the function:
import org.apache.spark.{SparkContext, SparkConf}
import scala.collection.mutable.ArrayBuffer

object Function{
    def _findHighestRatingUsers(movieRating: String): (String) = {
      val tokens = movieRating.split(",", -1)
      val movieTitle = tokens(0)
      val ratings = tokens.slice(1, tokens.size)
      val maxRating = ratings.max
      var userIds = ArrayBuffer[Int]()

      for(i <- 0 until ratings.length){
        if (ratings(i) == maxRating) {
          userIds += (i+1)
        }
      }

      return movieTitle + "," + userIds.mkString(",")
    }

}

object Task1 {

  def main(args: Array[String]) {
    val conf = new SparkConf().setAppName("Task 1")
    val sc = new SparkContext(conf)

    val textFile = sc.textFile(args(0))

    val output = textFile.map(Function._findHighestRatingUsers)
      .saveAsTextFile(args(1))
  }
}

But still got exception With a huge amount of errors...

This time I tried to put object Function in the object task1 like this:
import org.apache.spark.{SparkContext, SparkConf}
import scala.collection.mutable.ArrayBuffer
object Task1 {

  object Function{
    def _findHighestRatingUsers(movieRating: String): (String) = {
      val tokens = movieRating.split(",", -1)
      val movieTitle = tokens(0)
      val ratings = tokens.slice(1, tokens.size)
      val maxRating = ratings.max
      var userIds = ArrayBuffer[Int]()

      for(i <- 0 until ratings.length){
        if (ratings(i) == maxRating) {
          userIds += (i+1)
        }
      }

      return movieTitle + "," + userIds.mkString(",")
    }
  }

  def main(args: Array[String]) {
    val conf = new SparkConf().setAppName("Task 1")
    val sc = new SparkContext(conf)

    val textFile = sc.textFile(args(0))

    val output = textFile.map(Function._findHighestRatingUsers)
      .saveAsTextFile(args(1))
  }
}

And problem solved. But I still don't know why the nested object solves this problem. Could somebody explain it?
And further more, I have several points not sure:

*

*What is main function in scala? Is it the entrance of program?

*Why we use an object to describe main function?

*Could somebody give a common structure of a Scala program containing function, class or some basic components?

A: First thing is that I would recommend that you should get familiar by reading documentation both with Scala and Spark as your questions highlight that you are just starting working with it.
I'll give you some insights for your original question about "Task not serializable" (but not answering it precisely though) and let you open other questions for the questions you added later in your post otherwise this answer will be a mess.
As you probably know, Spark allows distributed computation. To do so, one thing Spark does is take the code you write, serialize it and send it to some executors somewhere to actually run it. The key part here is that your code must be serializable.
The error you got is telling you that Spark cannot serialize your code.
Now, how to make it serializable? This is where it can becomes challenging and even though Spark tries to help you by providing a "serialization stack", sometimes the info it provides are not that helpful.
In your case (1st example of code), findHighestRatingUsers must be serialized but to do so it has to serialize the whole object Task1 which is not serializable.
Why is Task1 not serializable? I'll admit I'm not really sure but I would bet on the main method, though I'd expected your 2nd example to be serializable then.
You can read more about this on various documentation or blog posts on the web. For instance: https://medium.com/swlh/spark-serialization-errors-e0eebcf0f6e6


text:
Q: Getting NullReference after Rebind in Ninject I am trying to replace a dependency when I am in the context of a specific method.
So I am doing something like this:
In my Ninject module I have the dependency originally registered like this:
Bind<IMyDependency>().To<OriginalType>();

Then in the method for which I want to replace the dependency I am using rebind, like this:
MyMethod()
{
   _kernel.Rebind<IMyDependency, ReplacementType>();

   ... some logic ...

   _kernel.Rebind<IMyDependency, OriginalType>();
}

However, after the first rebind I am getting NullReference when I try to resolve 'IMyDependency'
What am I missing? :)

A: Are you sure you need to use
  _kernel.Rebind<IMyDependency, ReplacementType>();

instead of
  _kernel.Rebind<IMyDependency>().To(ReplacementType);

?
IBindingToSyntax<T1, T2> Rebind<T1, T2>();

method is used to rebind services T1 and T2, not to resolve T1 as T2.


text:
Q: boost serialization base class without base_object I am using multiple inheritance with boost serialization. instead of doing
boost::serialization::base_object< Connection<T> >(*this)
boost::serialization::base_object< Collection<C> >(*this)

I am doing
template<typename ArchiveT>
void save(ArchiveT& arc, const unsigned version) const{
  //both Connection<T> and Collection<C> are Base Classes
  Connection<T>::save(arc, version);
  Collection<C>::save(arc, version);
}

and its working. So is two of them the same thing ? or there is any harm in doing this ? should I change this code ?
{This thing was coded long ago. So I forgot Why I coded it in that way. may be I was not aware of base_object at that time}
I am serializing huge set of data (~1.6 GB) .When I serialize I see serialization process is taking a lot of memory and hitting 3GB barrier. I've tried commenting serialization code and  it takes < 50MB memory . So what makes serialization taking that big memory ?

A: You should change your code and serialize the base classes through base_object<>().
From the documentation:

[...] Note that this is NOT the same as calling the serialize function of the base class. This might seem to work but will circumvent certain code used for tracking of objects, and registering base-derived relationships and other bookkeeping that is required for the serialization system to function as designed. For this reason, all serialize member functions should be private.

The extra memory consumption is probably caused by object tracking.
If you have a large quantity of objects being tracked, the memory consumption can increase drastically during serialization.
From special considerations:

If it is known a priori that no pointer values are duplicated, overhead associated with object tracking can be eliminated by setting the object tracking class serialization trait appropriately.

If you don't require object tracking, you may disable it with:
BOOST_CLASS_TRACKING(the_class, boost::serialization::track_never)


text:
Q: Blur filter works, but check50 disagrees I've been working on problem set four of the CS50 computer science course and ran into a problem in the blur filter that I'm not sure how to fix. This filter is meant to, for each pixel, take the average of all the color values in a 3x3 area within the current pixel, and change the middle pixel using the average of those pixels. My filter is blurring the picture, but is a little off of what check50 requires. Here's my code.
// Blur image
void blur(int height, int width, RGBTRIPLE image[height][width])
{
    RGBTRIPLE copy[height][width];

    for (int i = 0;i < height;i++)
    {
        for (int j = 0;j < width;j++)
        {
            copy[i][j] = image[i][j];
        }
    }

    for (int i = 0;i < height;i++)
    {
        for (int j = 0;j < width;j++)
        {
            int redAvrg = 0;
            int blueAvrg = 0;
            int greenAvrg = 0;
            int count = 0;

            for (int x = i - 1;x < i + 2;x++)
            {
                for (int y = j - 1;y < j + 2;y++)
                {
                    if(x >= 0 && y >= 0 && x < height && y < width)
                    {
                        redAvrg += copy[x][y].rgbtRed;
                        blueAvrg += copy[x][y].rgbtBlue;
                        greenAvrg += copy[x][y].rgbtGreen;
                        count++;
                    }
                }
            }
            image[i][j].rgbtRed = round(redAvrg / count);
            image[i][j].rgbtBlue = round(blueAvrg / count);
            image[i][j].rgbtGreen = round(greenAvrg / count);
        }
    }
    return;
}


text:
Q: How can I display and move images according to x,y Coordinates in OPENGL ANDROID How can I display and move images from Drawables according to x,y coordinates?

A: I would say don't use straight OpenGL without knowing what you're doing, and since you're asking I'm pretty sure you aren't quite there. Of course, you're always welcome to delve into new territory, it's just it has a lot of little nuances that you'll bang your head against the desk for days not even knowing where to start diagnosing certain problems... I know I did
1) Maybe utilize a Canvas instead?
2) Possibly jump over to AndEngine, Nic uses OpenGL and he handles it very well. Makes it much easier to start using more complex rendering methods.
3) If you're still wanting OpenGL, try looking at these examples.
Good luck either way!


text:
Q: 3Sum leetcode algorithm I'm having trouble with the following input for 3sum algorithm.  I'm
getting

Time Limit Exceeded

Is my algorithm too slow for this input, any suggestions how to improve it?
The original leetcode question:

Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

let data = [82597,-9243,62390,83030,-97960,-26521,-61011,83390,-38677,12333,75987,46091,83794,19355,-71037,-6242,-28801,324,1202,-90885,-2989,-95597,-34333,35528,5680,89093,-90606,50360,-29393,-27012,53313,65213,99818,-82405,-41661,-3333,-51952,72135,-1523,26377,74685,96992,92263,15929,5467,-99555,-43348,-41689,-60383,-3990,32165,65265,-72973,-58372,12741,-48568,-46596,72419,-1859,34153,62937,81310,-61823,-96770,-54944,8845,-91184,24208,-29078,31495,65258,14198,85395,70506,-40908,56740,-12228,-40072,32429,93001,68445,-73927,25731,-91859,-24150,10093,-60271,-81683,-18126,51055,48189,-6468,25057,81194,-58628,74042,66158,-14452,-49851,-43667,11092,39189,-17025,-79173,13606,83172,92647,-59741,19343,-26644,-57607,82908,-20655,1637,80060,98994,39331,-31274,-61523,91225,-72953,13211,-75116,-98421,-41571,-69074,99587,39345,42151,-2460,98236,15690,-52507,-95803,-48935,-46492,-45606,-79254,-99851,52533,73486,39948,-7240,71815,-585,-96252,90990,-93815,93340,-71848,58733,-14859,-83082,-75794,-82082,-24871,-15206,91207,-56469,-93618,67131,-8682,75719,87429,-98757,-7535,-24890,-94160,85003,33928,75538,97456,-66424,-60074,-8527,-28697,-22308,2246,-70134,-82319,-10184,87081,-34949,-28645,-47352,-83966,-60418,-15293,-53067,-25921,55172,75064,95859,48049,34311,-86931,-38586,33686,-36714,96922,76713,-22165,-80585,-34503,-44516,39217,-28457,47227,-94036,43457,24626,-87359,26898,-70819,30528,-32397,-69486,84912,-1187,-98986,-32958,4280,-79129,-65604,9344,58964,50584,71128,-55480,24986,15086,-62360,-42977,-49482,-77256,-36895,-74818,20,3063,-49426,28152,-97329,6086,86035,-88743,35241,44249,19927,-10660,89404,24179,-26621,-6511,57745,-28750,96340,-97160,-97822,-49979,52307,79462,94273,-24808,77104,9255,-83057,77655,21361,55956,-9096,48599,-40490,-55107,2689,29608,20497,66834,-34678,23553,-81400,-66630,-96321,-34499,-12957,-20564,25610,-4322,-58462,20801,53700,71527,24669,-54534,57879,-3221,33636,3900,97832,-27688,-98715,5992,24520,-55401,-57613,-69926,57377,-77610,20123,52174,860,60429,-91994,-62403,-6218,-90610,-37263,-15052,62069,-96465,44254,89892,-3406,19121,-41842,-87783,-64125,-56120,73904,-22797,-58118,-4866,5356,75318,46119,21276,-19246,-9241,-97425,57333,-15802,93149,25689,-5532,95716,39209,-87672,-29470,-16324,-15331,27632,-39454,56530,-16000,29853,46475,78242,-46602,83192,-73440,-15816,50964,-36601,89758,38375,-40007,-36675,-94030,67576,46811,-64919,45595,76530,40398,35845,41791,67697,-30439,-82944,63115,33447,-36046,-50122,-34789,43003,-78947,-38763,-89210,32756,-20389,-31358,-90526,-81607,88741,86643,98422,47389,-75189,13091,95993,-15501,94260,-25584,-1483,-67261,-70753,25160,89614,-90620,-48542,83889,-12388,-9642,-37043,-67663,28794,-8801,13621,12241,55379,84290,21692,-95906,-85617,-17341,-63767,80183,-4942,-51478,30997,-13658,8838,17452,-82869,-39897,68449,31964,98158,-49489,62283,-62209,-92792,-59342,55146,-38533,20496,62667,62593,36095,-12470,5453,-50451,74716,-17902,3302,-16760,-71642,-34819,96459,-72860,21638,47342,-69897,-40180,44466,76496,84659,13848,-91600,-90887,-63742,-2156,-84981,-99280,94326,-33854,92029,-50811,98711,-36459,-75555,79110,-88164,-97397,-84217,97457,64387,30513,-53190,-83215,252,2344,-27177,-92945,-89010,82662,-11670,86069,53417,42702,97082,3695,-14530,-46334,17910,77999,28009,-12374,15498,-46941,97088,-35030,95040,92095,-59469,-24761,46491,67357,-66658,37446,-65130,-50416,99197,30925,27308,54122,-44719,12582,-99525,-38446,-69050,-22352,94757,-56062,33684,-40199,-46399,96842,-50881,-22380,-65021,40582,53623,-76034,77018,-97074,-84838,-22953,-74205,79715,-33920,-35794,-91369,73421,-82492,63680,-14915,-33295,37145,76852,-69442,60125,-74166,74308,-1900,-30195,-16267,-60781,-27760,5852,38917,25742,-3765,49097,-63541,98612,-92865,-30248,9612,-8798,53262,95781,-42278,-36529,7252,-27394,-5021,59178,80934,-48480,-75131,-54439,-19145,-48140,98457,-6601,-51616,-89730,78028,32083,-48904,16822,-81153,-8832,48720,-80728,-45133,-86647,-4259,-40453,2590,28613,50523,-4105,-27790,-74579,-17223,63721,33489,-47921,97628,-97691,-14782,-65644,18008,-93651,-71266,80990,-76732,-47104,35368,28632,59818,-86269,-89753,34557,-92230,-5933,-3487,-73557,-13174,-43981,-43630,-55171,30254,-83710,-99583,-13500,71787,5017,-25117,-78586,86941,-3251,-23867,-36315,75973,86272,-45575,77462,-98836,-10859,70168,-32971,-38739,-12761,93410,14014,-30706,-77356,-85965,-62316,63918,-59914,-64088,1591,-10957,38004,15129,-83602,-51791,34381,-89382,-26056,8942,5465,71458,-73805,-87445,-19921,-80784,69150,-34168,28301,-68955,18041,6059,82342,9947,39795,44047,-57313,48569,81936,-2863,-80932,32976,-86454,-84207,33033,32867,9104,-16580,-25727,80157,-70169,53741,86522,84651,68480,84018,61932,7332,-61322,-69663,76370,41206,12326,-34689,17016,82975,-23386,39417,72793,44774,-96259,3213,79952,29265,-61492,-49337,14162,65886,3342,-41622,-62659,-90402,-24751,88511,54739,-21383,-40161,-96610,-24944,-602,-76842,-21856,69964,43994,-15121,-85530,12718,13170,-13547,69222,62417,-75305,-81446,-38786,-52075,-23110,97681,-82800,-53178,11474,35857,94197,-58148,-23689,32506,92154,-64536,-73930,-77138,97446,-83459,70963,22452,68472,-3728,-25059,-49405,95129,-6167,12808,99918,30113,-12641,-26665,86362,-33505,50661,26714,33701,89012,-91540,40517,-12716,-57185,-87230,29914,-59560,13200,-72723,58272,23913,-45586,-96593,-26265,-2141,31087,81399,92511,-34049,20577,2803,26003,8940,42117,40887,-82715,38269,40969,-50022,72088,21291,-67280,-16523,90535,18669,94342,-39568,-88080,-99486,-20716,23108,-28037,63342,36863,-29420,-44016,75135,73415,16059,-4899,86893,43136,-7041,33483,-67612,25327,40830,6184,61805,4247,81119,-22854,-26104,-63466,63093,-63685,60369,51023,51644,-16350,74438,-83514,99083,10079,-58451,-79621,48471,67131,-86940,99093,11855,-22272,-67683,-44371,9541,18123,37766,-70922,80385,-57513,-76021,-47890,36154,72935,84387,-92681,-88303,-7810,59902,-90,-64704,-28396,-66403,8860,13343,33882,85680,7228,28160,-14003,54369,-58893,92606,-63492,-10101,64714,58486,29948,-44679,-22763,10151,-56695,4031,-18242,-36232,86168,-14263,9883,47124,47271,92761,-24958,-73263,-79661,-69147,-18874,29546,-92588,-85771,26451,-86650,-43306,-59094,-47492,-34821,-91763,-47670,33537,22843,67417,-759,92159,63075,94065,-26988,55276,65903,30414,-67129,-99508,-83092,-91493,-50426,14349,-83216,-76090,32742,-5306,-93310,-60750,-60620,-45484,-21108,-58341,-28048,-52803,69735,78906,81649,32565,-86804,-83202,-65688,-1760,89707,93322,-72750,84134,71900,-37720,19450,-78018,22001,-23604,26276,-21498,65892,-72117,-89834,-23867,55817,-77963,42518,93123,-83916,63260,-2243,-97108,85442,-36775,17984,-58810,99664,-19082,93075,-69329,87061,79713,16296,70996,13483,-74582,49900,-27669,-40562,1209,-20572,34660,83193,75579,7344,64925,88361,60969,3114,44611,-27445,53049,-16085,-92851,-53306,13859,-33532,86622,-75666,-18159,-98256,51875,-42251,-27977,-18080,23772,38160,41779,9147,94175,99905,-85755,62535,-88412,-52038,-68171,93255,-44684,-11242,-104,31796,62346,-54931,-55790,-70032,46221,56541,-91947,90592,93503,4071,20646,4856,-63598,15396,-50708,32138,-85164,38528,-89959,53852,57915,-42421,-88916,-75072,67030,-29066,49542,-71591,61708,-53985,-43051,28483,46991,-83216,80991,-46254,-48716,39356,-8270,-47763,-34410,874,-1186,-7049,28846,11276,21960,-13304,-11433,-4913,55754,79616,70423,-27523,64803,49277,14906,-97401,-92390,91075,70736,21971,-3303,55333,-93996,76538,54603,-75899,98801,46887,35041,48302,-52318,55439,24574,14079,-24889,83440,14961,34312,-89260,-22293,-81271,-2586,-71059,-10640,-93095,-5453,-70041,66543,74012,-11662,-52477,-37597,-70919,92971,-17452,-67306,-80418,7225,-89296,24296,86547,37154,-10696,74436,-63959,58860,33590,-88925,-97814,-83664,85484,-8385,-50879,57729,-74728,-87852,-15524,-91120,22062,28134,80917,32026,49707,-54252,-44319,-35139,13777,44660,85274,25043,58781,-89035,-76274,6364,-63625,72855,43242,-35033,12820,-27460,77372,-47578,-61162,-70758,-1343,-4159,64935,56024,-2151,43770,19758,-30186,-86040,24666,-62332,-67542,73180,-25821,-27826,-45504,-36858,-12041,20017,-24066,-56625,-52097,-47239,-90694,8959,7712,-14258,-5860,55349,61808,-4423,-93703,64681,-98641,-25222,46999,-83831,-54714,19997,-68477,66073,51801,-66491,52061,-52866,79907,-39736,-68331,68937,91464,98892,910,93501,31295,-85873,27036,-57340,50412,21,-2445,29471,71317,82093,-94823,-54458,-97410,39560,-7628,66452,39701,54029,37906,46773,58296,60370,-61090,85501,-86874,71443,-72702,-72047,14848,34102,77975,-66294,-36576,31349,52493,-70833,-80287,94435,39745,-98291,84524,-18942,10236,93448,50846,94023,-6939,47999,14740,30165,81048,84935,-19177,-13594,32289,62628,-90612,-542,-66627,64255,71199,-83841,-82943,-73885,8623,-67214,-9474,-35249,62254,-14087,-90969,21515,-83303,94377,-91619,19956,-98810,96727,-91939,29119,-85473,-82153,-69008,44850,74299,-76459,-86464,8315,-49912,-28665,59052,-69708,76024,-92738,50098,18683,-91438,18096,-19335,35659,91826,15779,-73070,67873,-12458,-71440,-46721,54856,97212,-81875,35805,36952,68498,81627,-34231,81712,27100,-9741,-82612,18766,-36392,2759,41728,69743,26825,48355,-17790,17165,56558,3295,-24375,55669,-16109,24079,73414,48990,-11931,-78214,90745,19878,35673,-15317,-89086,94675,-92513,88410,-93248,-19475,-74041,-19165,32329,-26266,-46828,-18747,45328,8990,-78219,-25874,-74801,-44956,-54577,-29756,-99822,-35731,-18348,-68915,-83518,-53451,95471,-2954,-13706,-8763,-21642,-37210,16814,-60070,-42743,27697,-36333,-42362,11576,85742,-82536,68767,-56103,-63012,71396,-78464,-68101,-15917,-11113,-3596,77626,-60191,-30585,-73584,6214,-84303,18403,23618,-15619,-89755,-59515,-59103,-74308,-63725,-29364,-52376,-96130,70894,-12609,50845,-2314,42264,-70825,64481,55752,4460,-68603,-88701,4713,-50441,-51333,-77907,97412,-66616,-49430,60489,-85262,-97621,-18980,44727,-69321,-57730,66287,-92566,-64427,-14270,11515,-92612,-87645,61557,24197,-81923,-39831,-10301,-23640,-76219,-68025,92761,-76493,68554,-77734,-95620,-11753,-51700,98234,-68544,-61838,29467,46603,-18221,-35441,74537,40327,-58293,75755,-57301,-7532,-94163,18179,-14388,-22258,-46417,-48285,18242,-77551,82620,250,-20060,-79568,-77259,82052,-98897,-75464,48773,-79040,-11293,45941,-67876,-69204,-46477,-46107,792,60546,-34573,-12879,-94562,20356,-48004,-62429,96242,40594,2099,99494,25724,-39394,-2388,-18563,-56510,-83570,-29214,3015,74454,74197,76678,-46597,60630,-76093,37578,-82045,-24077,62082,-87787,-74936,58687,12200,-98952,70155,-77370,21710,-84625,-60556,-84128,925,65474,-15741,-94619,88377,89334,44749,22002,-45750,-93081,-14600,-83447,46691,85040,-66447,-80085,56308,44310,24979,-29694,57991,4675,-71273,-44508,13615,-54710,23552,-78253,-34637,50497,68706,81543,-88408,-21405,6001,-33834,-21570,-46692,-25344,20310,71258,-97680,11721,59977,59247,-48949,98955,-50276,-80844,-27935,-76102,55858,-33492,40680,66691,-33188,8284,64893,-7528,6019,-85523,8434,-64366,-56663,26862,30008,-7611,-12179,-70076,21426,-11261,-36864,-61937,-59677,929,-21052,3848,-20888,-16065,98995,-32293,-86121,-54564,77831,68602,74977,31658,40699,29755,98424,80358,-69337,26339,13213,-46016,-18331,64713,-46883,-58451,-70024,-92393,-4088,70628,-51185,71164,-75791,-1636,-29102,-16929,-87650,-84589,-24229,-42137,-15653,94825,13042,88499,-47100,-90358,-7180,29754,-65727,-42659,-85560,-9037,-52459,20997,-47425,17318,21122,20472,-23037,65216,-63625,-7877,-91907,24100,-72516,22903,-85247,-8938,73878,54953,87480,-31466,-99524,35369,-78376,89984,-15982,94045,-7269,23319,-80456,-37653,-76756,2909,81936,54958,-12393,60560,-84664,-82413,66941,-26573,-97532,64460,18593,-85789,-38820,-92575,-43663,-89435,83272,-50585,13616,-71541,-53156,727,-27644,16538,34049,57745,34348,35009,16634,-18791,23271,-63844,95817,21781,16590,59669,15966,-6864,48050,-36143,97427,-59390,96931,78939,-1958,50777,43338,-51149,39235,-27054,-43492,67457,-83616,37179,10390,85818,2391,73635,87579,-49127,-81264,-79023,-81590,53554,-74972,-83940,-13726,-39095,29174,78072,76104,47778,25797,-29515,-6493,-92793,22481,-36197,-65560,42342,15750,97556,99634,-56048,-35688,13501,63969,-74291,50911,39225,93702,-3490,-59461,-30105,-46761,-80113,92906,-68487,50742,36152,-90240,-83631,24597,-50566,-15477,18470,77038,40223,-80364,-98676,70957,-63647,99537,13041,31679,86631,37633,-16866,13686,-71565,21652,-46053,-80578,-61382,68487,-6417,4656,20811,67013,-30868,-11219,46,74944,14627,56965,42275,-52480,52162,-84883,-52579,-90331,92792,42184,-73422,-58440,65308,-25069,5475,-57996,59557,-17561,2826,-56939,14996,-94855,-53707,99159,43645,-67719,-1331,21412,41704,31612,32622,1919,-69333,-69828,22422,-78842,57896,-17363,27979,-76897,35008,46482,-75289,65799,20057,7170,41326,-76069,90840,-81253,-50749,3649,-42315,45238,-33924,62101,96906,58884,-7617,-28689,-66578,62458,50876,-57553,6739,41014,-64040,-34916,37940,13048,-97478,-11318,-89440,-31933,-40357,-59737,-76718,-14104,-31774,28001,4103,41702,-25120,-31654,63085,-3642,84870,-83896,-76422,-61520,12900,88678,85547,33132,-88627,52820,63915,-27472,78867,-51439,33005,-23447,-3271,-39308,39726,-74260,-31874,-36893,93656,910,-98362,60450,-88048,99308,13947,83996,-90415,-35117,70858,-55332,-31721,97528,82982,-86218,6822,25227,36946,97077,-4257,-41526,56795,89870,75860,-70802,21779,14184,-16511,-89156,-31422,71470,69600,-78498,74079,-19410,40311,28501,26397,-67574,-32518,68510,38615,19355,-6088,-97159,-29255,-92523,3023,-42536,-88681,64255,41206,44119,52208,39522,-52108,91276,-70514,83436,63289,-79741,9623,99559,12642,85950,83735,-21156,-67208,98088,-7341,-27763,-30048,-44099,-14866,-45504,-91704,19369,13700,10481,-49344,-85686,33994,19672,36028,60842,66564,-24919,33950,-93616,-47430,-35391,-28279,56806,74690,39284,-96683,-7642,-75232,37657,-14531,-86870,-9274,-26173,98640,88652,64257,46457,37814,-19370,9337,-22556,-41525,39105,-28719,51611,-93252,98044,-90996,21710,-47605,-64259,-32727,53611,-31918,-3555,33316,-66472,21274,-37731,-2919,15016,48779,-88868,1897,41728,46344,-89667,37848,68092,-44011,85354,-43776,38739,-31423,-66330,65167,-22016,59405,34328,-60042,87660,-67698,-59174,-1408,-46809,-43485,-88807,-60489,13974,22319,55836,-62995,-37375,-4185,32687,-36551,-75237,58280,26942,-73756,71756,78775,-40573,14367,-71622,-77338,24112,23414,-7679,-51721,87492,85066,-21612,57045,10673,-96836,52461,-62218,-9310,65862,-22748,89906,-96987,-98698,26956,-43428,46141,47456,28095,55952,67323,-36455,-60202,-43302,-82932,42020,77036,10142,60406,70331,63836,58850,-66752,52109,21395,-10238,-98647,-41962,27778,69060,98535,-28680,-52263,-56679,66103,-42426,27203,80021,10153,58678,36398,63112,34911,20515,62082,-15659,-40785,27054,43767,-20289,65838,-6954,-60228,-72226,52236,-35464,25209,-15462,-79617,-41668,-84083,62404,-69062,18913,46545,20757,13805,24717,-18461,-47009,-25779,68834,64824,34473,39576,31570,14861,-15114,-41233,95509,68232,67846,84902,-83060,17642,-18422,73688,77671,-26930,64484,-99637,73875,6428,21034,-73471,19664,-68031,15922,-27028,48137,54955,-82793,-41144,-10218,-24921,-28299,-2288,68518,-54452,15686,-41814,66165,-72207,-61986,80020,50544,-99500,16244,78998,40989,14525,-56061,-24692,-94790,21111,37296,-90794,72100,70550,-31757,17708,-74290,61910,78039,-78629,-25033,73172,-91953,10052,64502,99585,-1741,90324,-73723,68942,28149,30218,24422,16659,10710,-62594,94249,96588,46192,34251,73500,-65995,-81168,41412,-98724,-63710,-54696,-52407,19746,45869,27821,-94866,-76705,-13417,-61995,-71560,43450,67384,-8838,-80293,-28937,23330,-89694,-40586,46918,80429,-5475,78013,25309,-34162,37236,-77577,86744,26281,-29033,-91813,35347,13033,-13631,-24459,3325,-71078,-75359,81311,19700,47678,-74680,-84113,45192,35502,37675,19553,76522,-51098,-18211,89717,4508,-82946,27749,85995,89912,-53678,-64727,-14778,32075,-63412,-40524,86440,-2707,-36821,63850,-30883,67294,-99468,-23708,34932,34386,98899,29239,-23385,5897,54882,98660,49098,70275,17718,88533,52161,63340,50061,-89457,19491,-99156,24873,-17008,64610,-55543,50495,17056,-10400,-56678,-29073,-42960,-76418,98562,-88104,-96255,10159,-90724,54011,12052,45871,-90933,-69420,67039,37202,78051,-52197,-40278,-58425,65414,-23394,-1415,6912,-53447,7352,17307,-78147,63727,98905,55412,-57658,-32884,-44878,22755,39730,3638,35111,39777,74193,38736,-11829,-61188,-92757,55946,-71232,-63032,-83947,39147,-96684,-99233,25131,-32197,24406,-55428,-61941,25874,-69453,64483,-19644,-68441,12783,87338,-48676,66451,-447,-61590,50932,-11270,29035,65698,-63544,10029,80499,-9461,86368,91365,-81810,-71914,-52056,-13782,44240,-30093,-2437,24007,67581,-17365,-69164,-8420,-69289,-29370,48010,90439,13141,69243,50668,39328,61731,78266,-81313,17921,-38196,55261,9948,-24970,75712,-72106,28696,7461,31621,61047,51476,56512,11839,-96916,-82739,28924,-99927,58449,37280,69357,11219,-32119,-62050,-48745,-83486,-52376,42668,82659,68882,38773,46269,-96005,97630,25009,-2951,-67811,99801,81587,-79793,-18547,-83086,69512,33127,-92145,-88497,47703,59527,1909,88785,-88882,69188,-46131,-5589,-15086,36255,-53238,-33009,82664,53901,35939,-42946,-25571,33298,69291,53199,74746,-40127,-39050,91033,51717,-98048,87240,36172,65453,-94425,-63694,-30027,59004,88660,3649,-20267,-52565,-67321,34037,4320,91515,-56753,60115,27134,68617,-61395,-26503,-98929,-8849,-63318,10709,-16151,61905,-95785,5262,23670,-25277,90206,-19391,45735,37208,-31992,-92450,18516,-90452,-58870,-58602,93383,14333,17994,82411,-54126,-32576,35440,-60526,-78764,-25069,-9022,-394,92186,-38057,55328,-61569,67780,77169,19546,-92664,-94948,44484,-13439,83529,27518,-48333,72998,38342,-90553,-98578,-76906,81515,-16464,78439,92529,35225,-39968,-10130,-7845,-32245,-74955,-74996,67731,-13897,-82493,33407,93619,59560,-24404,-57553,19486,-45341,34098,-24978,-33612,79058,71847,76713,-95422,6421,-96075,-59130,-28976,-16922,-62203,69970,68331,21874,40551,89650,51908,58181,66480,-68177,34323,-3046,-49656,-59758,43564,-10960,-30796,15473,-20216,46085,-85355,41515,-30669,-87498,57711,56067,63199,-83805,62042,91213,-14606,4394,-562,74913,10406,96810,-61595,32564,31640,-9732,42058,98052,-7908,-72330,1558,-80301,34878,32900,3939,-8824,88316,20937,21566,-3218,-66080,-31620,86859,54289,90476,-42889,-15016,-18838,75456,30159,-67101,42328,-92703,85850,-5475,23470,-80806,68206,17764,88235,46421,-41578,74005,-81142,80545,20868,-1560,64017,83784,68863,-97516,-13016,-72223,79630,-55692,82255,88467,28007,-34686,-69049,-41677,88535,-8217,68060,-51280,28971,49088,49235,26905,-81117,-44888,40623,74337,-24662,97476,79542,-72082,-35093,98175,-61761,-68169,59697,-62542,-72965,59883,-64026,-37656,-92392,-12113,-73495,98258,68379,-21545,64607,-70957,-92254,-97460,-63436,-8853,-19357,-51965,-76582,12687,-49712,45413,-60043,33496,31539,-57347,41837,67280,-68813,52088,-13155,-86430,-15239,-45030,96041,18749,-23992,46048,35243,-79450,85425,-58524,88781,-39454,53073,-48864,-82289,39086,82540,-11555,25014,-5431,-39585,-89526,2705,31953,-81611,36985,-56022,68684,-27101,11422,64655,-26965,-63081,-13840,-91003,-78147,-8966,41488,1988,99021,-61575,-47060,65260,-23844,-21781,-91865,-19607,44808,2890,63692,-88663,-58272,15970,-65195,-45416,-48444,-78226,-65332,-24568,42833,-1806,-71595,80002,-52250,30952,48452,-90106,31015,-22073,62339,63318,78391,28699,77900,-4026,-76870,-45943,33665,9174,-84360,-22684,-16832,-67949,-38077,-38987,-32847,51443,-53580,-13505,9344,-92337,26585,70458,-52764,-67471,-68411,-1119,-2072,-93476,67981,40887,-89304,-12235,41488,1454,5355,-34855,-72080,24514,-58305,3340,34331,8731,77451,-64983,-57876,82874,62481,-32754,-39902,22451,-79095,-23904,78409,-7418,77916]

var threeSum = function(nums) {
var solutions = [];
var target = 0;
nums.sort(function(a, b) {
    return a - b;
});
console.log('sorted array ',nums);
for(var i = 0; i < nums.length - 1 && nums[i] <= 0; i++) {
    if(nums[i] === nums[i - 1]) continue; // continue means skip
    var hash = {};
    for(var j = i + 1; j < nums.length; j++) {
        if(hash[target - nums[i] - nums[j]] === undefined){
            hash[nums[j]] = 1;
        }else{
          hash[target - nums[i] - nums[j]]++;
          if(hash[target - nums[i] - nums[j]] >  2){

          }else{
              solutions.push([nums[i], target - nums[i] - nums[j], nums[j]]);
          }
        }
    }
    console.log(hash);
    console.log("____________________________")
}
return solutions;
};

A: I have modified your solution using a two-pointer approach and the code now passes all the test cases. The overall runtime complexity of the following algorithm is O(n^2).
var threeSum = function(nums) {
    var solutions = [];
    var target = 0;
    nums.sort(function(a, b) {
        return a - b;
    });
    for(var i = 0; i < nums.length - 2; i++) {
        if(i === 0 || (i > 0 && nums[i] !== nums[i - 1])) {
        var lo = i + 1;
        var hi = nums.length - 1;
        var sum = - nums[i];
        while(lo < hi) {
            if(nums[lo] + nums[hi] === sum) {
                solutions.push([nums[i],nums[lo],nums[hi]]);
                while (lo < hi && nums[lo] === nums[lo + 1]) lo++;
                while (lo < hi && nums[hi] == nums[hi-1]) hi--;
                lo++; hi--;
            }else if (nums[lo] + nums[hi] > sum) {
                hi--;
            }else {
                lo++;
            }
        }
        }
};
    return solutions;
}

And the solution beats almost 98% of JavaScript submissions

A: var threeSum = function(array) {
     array.sort((a,b) => a - b);
    const triplets = [];

    for(let i=0; i < array.length - 2; i++){
        if(array[i] != array[i-1]){
            let left = i + 1;
          let right = array.length - 1;

            while (left < right){
                const currentSum = array[i] + array[left] + array[right];
                if (currentSum === 0){
                    triplets.push([array[i], array[left], array[right]]);
                    while(array[left] == array[left + 1]) left ++
                    while(array[right] == array[right - 1]) right --
                    left ++;
                    right --;
                } else if(currentSum < 0) {
                    left ++
                } else if(currentSum > 0){
                    right --
                }
            }
        }
    }
    return triplets
};

console.log(threeSum([-1,0,1,2,-1,-4]));
console.log(threeSum([0,1,1]));
console.log(threeSum([0,0,0]));


text:
Q: Random number file writer and read Instructions
Write a program that writes a series of random numbers to a file.

*

*The count of numbers to be generated for each execution will be
randomly between 1 and 20.

*The actual numbers generated will be random integers between 1 and
100

*Each run of the program will display a message indicating the
number of new numbers written to the file

*Each run of the program will display a message indicating the
number of records read from the file

*You cannot count or assume to know how many records are in the
file. Use the deadline method with a loop to EOF.

*Your file read and file write must each be functions (2 functions,
one for each), and each be called from main.

*You must use w mode for the first write to the file and a or
w mode for each time after.

*User will determine whether to append to existing file or write new
file.
Here's what I have
import random

def main():
        more = 'y'

        while more.lower() == 'y':

                random_numbers = open('Unit 4 numbers.txt', 'w')
                NumtoBeWr = random.randint(1, 20)
                print(NumtoBeWr, 'numbers added to output file: ')

                for count in range(NumtoBeWr):
                      number = random.randint(1, 100)
                      print(number)
                      random_numbers.write(str(number) + '\n')

                random_numbers.close()

                random_numbers = open('Unit 4 numbers.txt', 'r')

                # This the code to read the file

                line = random_numbers.readline()
                number = 0
                total = 0

                while line != " ":
                        number = int(line)

                        line = line.rstrip('\n')
                        print(number)
                        total = total + int(line)
                        number = number + number
                        line = random_numbers.readline()

                        print("The total of the numbers: "+ str (total))
                        print("Total count of numbers read from file: "+ str (number))
                        more = input("Do you want to run again to write and read more numbers. (Y/N): ")
                random_numbers.close()

        print("Thank for using this program")

main()

A few problems I an having

*

*It's not adding all the number together

*It's not counting all the number together

Sample output for the finish program should look like this:

A: You should update your while loop as follows:
while line:
    number += int(line)
    total += 1
    line = random_numbers.readline().rstrip("\n")

print("The total of the numbers: " + str(total))
print("Total count of numbers read from file: " + str(number))
more = input("Do you want to run again to write and read more numbers. (Y/N): ")

That is, you should put the printing of the total counts outside of the loop. Furthermore, you should increment total by one instead of by the number in the current line to get the total numbers generated.


text:
Q: Http post a file data I have two <input> tag on my client to choose a file. Once the client choose the files (24-bit BMP 640*480), I have to make a http.post so that I could save the imageData of each file and make a http.get when I need it. I tried posting an ImageData object or just an Uint8ClampedArray but I was getting some errors. Now I tried to convert it to base64 and send it but I'm still not getting anything.
This is my http.post:
public submitInfo(): void {
  this.http.post("http://localhost:3000/sologame", { "name": this.game.gameName, "image1": this.game.picture }, HTTP_OPTIONS).pipe(
    catchError(this.handleError("submitInfo"))).subscribe();
}

This is the error I'm getting now that I'm trying to send a base64 string:
How can I send the data of my image?

A: There is two way to do it:

*

*Send binary data

onUpload(selectedFile: File) {
    this.http.post('api/file-upload', selectedFile).subscribe(...);
}

*Send as FormData

onUpload(selectedFile: File) {
    const uploadData = new FormData();
    uploadData.append('file', selectedFile, selectedFile.name);
    this.http.post('api/file-upload', uploadData).subscribe(...);
}


text:
Q: django admin - how to override the default  view for foreign key? I have 2 django model
class Location
  address = models.CharField(max_length=100)
  city = models.CharField(max_length=20)

class Client
  location = models.ForeignKey(Location)
  name = models.CharField(max_length=100)

And I have the following admin.py
class ClientAdmin(admin.ModelAdmin):
fieldsets = [
    ('Client Details', {'fields': ['name']}),
    ('Location Details', {'fields': ['location']}),
]

admin.site.register(Client, ClientAdmin)

When I try to add a Client I like to have a editable "location" fields i.e. address and city text fields. django by default gives a  list.. how can I get the fields from the foregin tables?
any way I can do this? I don't wish to register the Location table in the admin.
thanks

A: You could put an inline table for the location and use the method queryset to handle the field values.
So, this is the ideia of the solution:
class LocationInline(admin.StackedInline):
    model = Location

    def queryset(self, request):
        query = ... #your custom query here
        qs = super(LocationInline, self).queryset(request).filter(query)
        return qs

class ClientAdmin(admin.ModelAdmin):
    inlines = [LocationInline]
    fieldsets = [
        ('Client Details', {'fields': ['name']}),
    ]

Edit:
There is another way to do it in django 1.1.
class ClientAdmin(admin.ModelAdmin):
    fieldsets = [
        ('Client Details', {'fields': ['name']}),
        ('Location Details', {'fields': ['location']}),
    ]

def formfield_for_foreignkey(self, db_field, request, **kwargs):

    if db_field.name = "location":
        locations = Location.objects.filter( ... ) #your query

        kwargs["queryset"] = Location.objects.filter(query)

    return super(ClientAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)

The docs are here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey
It's an old question, but answering this can help a lot of other people too.
So, I hope it helps! ;)


text: Q: Reporting Services Report Export to Excel Crashed in My Program I have a problem ssrs report export to excel in my application .I taken always this error .I attached picture.How can I solve problem ? I think it can be internet options security settings but I didn't find anything :


text:
Q: How to detect if `-Wdev` was passed to CMake? Is there a way to detect if -Wdev was passed to CMake from within a CMakeLists.txt file?

A: When -Wdev or -Wno-dev options are passed to cmake.exe the user's choice is persisted in the CMAKE_SUPPRESS_DEVELOPER_WARNINGS cached variable (see cmake.cxx). But be aware that the variable is not there, if no -W option is given.
I've done some testing and e.g. with -Wdev command line option I see the following lines added to my CMakeCache.txt:
//Suppress Warnings that are meant for the author of the CMakeLists.txt
// files.
CMAKE_SUPPRESS_DEVELOPER_WARNINGS:INTERNAL=FALSE

So you can check for this variable and see if it's set to FALSE with:
if (DEFINED CMAKE_SUPPRESS_DEVELOPER_WARNINGS AND
    NOT CMAKE_SUPPRESS_DEVELOPER_WARNINGS)


text:
Q: MySQL: Make calculated column from multiple tables with complicated equation I wrote a formula in PHP that uses fields from different tables to calculate percentage. What i want to try and accomplish is translating it into SQL, if it's possible.
I understand that i can use SET to make local variables, then SELECT that variable to display in my final table, but setting those variables as equations is giving me some hassle.
Here's the PHP. I tried to make it as simple as possible without being confusing.
/*Setting fields to variables for ease*/
$PU = {table1.PU}*60;
$PD = {table1.PD};
$UD = {table3.UD};
$GP = {table1.GP};
$S = {table2.S};
$R = {table4.R};
$PR = {table1.CT}/60;

/*Combining variables*/
$TRT = $PU - $PD - $UD;
$PT = $TRT * $PR;
$TP = $GP + $S + $R;

/*Checking and correcting for zero division plus final calculation*/
if ($PU == 0 || $PT == 0 || $TP == 0){
    {complete} = "Error!";
}
else {
$a = $TRT/$PU;
$b = $TP/$PT;
$c = $GP/$TP;
{complete} = 100 * ($a * $b * $c);
}

And the MySQL i have started. My plan of attack was to assign the formulas to variables using the column names, including checking for zero-division. Running this through SQL Maestro, giving the error on invalid SET token. I've tried wrapping the whole thing in double quotes (and checked @variable $variable, =, := all with no luck) and checked several sources, my SET command should be correct. My private keys and foreign keys are set correctly.
SET @a = (((table1.PU*60) - table1.PD - table3.UD) / (table1.PU*60));
SET @b = (table1.GP + table2.S + table4.R)/(((table1.PU*60) - table1.PD - table3.UPD)*(table1.CT/60));
SET @c = table1.GP/(table1.GP + table2.S + table4.R);
SET @complete = 100*(@a*@b*@c);

IF(table1.PU = 0, 'Error!',@a),
IF(table1.CT = 0, 'Error!',@p),

SELECT
  table1.PU,
  table1.PD,
  table1.CT,
  table2.S,
  table3.UD,
  table4.R,
  @complete
FROM
  table1
  LEFT JOIN table2
  LEFT JOIN table3
  LEFT JOIN table4

The final result i'm looking for is to display all the individual fields i'm selecting, as well as the calculated field. I've looked into PROCEDURE and i think that might be beneficial but i am unsure of how to incorporate it fully.

A: I think SET works with select queries only: How to set variable from a SQL query?
Furthermore, I assumed table1-4 only contain a single row. Otherwise, SET doesn't work.
SET @a = (SELECT
           (((table1.PU*60) - table1.PD - table3.UPD) / (table1.PU*60))
          FROM table1, table3);
SET @b = (SELECT
           (table1.GP + table2.S + table4.R)/(((table1.PU*60) - table1.PD - table3.UPD)*(table1.CT/60))
          FROM table1, table2, table3, table4);
SET @c = (SELECT
           table1.GP/(table1.GP + table2.S + table4.R)
          FROM table1, table2, table4);
SET @complete = 100*(@a*@b*@c);

IF(table1.PU = 0, 'Error!',@a),
IF(table1.CT = 0, 'Error!',@p),

SELECT
    table1.PU,
    table1.PD,
    table1.CT,
    table2.S,
    table3.UPD,
    table4.R,
    @complete // or perhaps (SELECT @complete as complete)
FROM
  table1, table2, table3, table4

A: You don't need SET for this. Here's a simple SELECT which makes all the calculations:
SELECT
    table1.PU * 60 AS PU,
    table1.PD AS PD,
    table3.UPD AS UPD,
    table1.GP AS GP,
    table2.S AS S,
    table4.R AS R,
    table1.CT/60 AS PR,
    (table1.PU * 60) - table1.PD - table3.UPD AS TRT,
    (table1.PU * 60 - table1.PD - table3.UPD) * (table1.CT/60) AS PT,
    table1.GP + table2.S + table4.R AS TP,
    ((table1.PU * 60) - table1.PD - table3.UPD) / (table1.PU * 60) AS a,
    (table1.GP + table2.S + table4.R) / ((table1.PU * 60 - table1.PD - table3.UPD) * (table1.CT/60)) AS b,
    table1.GP / (table1.GP + table2.S + table4.R) AS c,
    100 * (((table1.PU * 60) - table1.PD - table3.UPD) / (table1.PU * 60)) * ((table1.GP + table2.S + table4.R) / ((table1.PU * 60 - table1.PD - table3.UPD) * (table1.CT/60))) * (table1.GP / (table1.GP + table2.S + table4.R)) AS complete
FROM
    table1,
    table2,
    table3,
    table4

Assuming all your tables only contain one row. Otherwise you need to specify some JOIN conditions.


text:
Q: Can BoxWhiskerChart show both the median and outliers at the same time? Is there an easy way to make BoxWhiskerChart show both the outliers and the median line? g1 below shows outliers but not the median line, and g2 shows the median line but not the outliers.
data = RandomReal[NormalDistribution[0, 1], 100];
g1 = BoxWhiskerChart[data, "Outliers"]
g2 = BoxWhiskerChart[data]

That is, can BoxWhiskerChart make a boxplot in the style of BoxWhiskerPlot?
Needs["StatisticalPlots`"]
data = RandomVariate[StudentTDistribution[5], 100];
BoxWhiskerPlot[data, BoxOutliers -> Automatic]

Thanks!

A: If you read the Details & Options section in the documentation for BoxWhiskerChart you will find that there are presets but also the ability to control each element. If you want both outliers and a median marker you could do something like the following.
   BoxWhiskerChart[
     RandomVariate[NormalDistribution[0, 1], 10]~
      Join~{5}, {{"Outliers", "o"}, {"MedianMarker", Automatic}}]


text:
Q: what does this events error mean I have desktop application that have web service reference, in some cases it crash giving those errors in the system event log of client machine

1000
Faulting application xxxxxxxx.exe, version 1.0.0.14,
  stamp 4ef30030, faulting module mscorwks.dll, version 2.0.50727.3625, stamp
  4e154c98, debug? 0, fault address 0x000a20c6.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
1023
.NET Runtime version 2.0.50727.3625 - Fatal Execution Engine Error (7A0BC59E) (80131506)
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

the webservice designed using .NET 3.5 so it hosted under 2.0.5 framework on the IIS 7, the server is windows server standard 2008 service pack 2
any idea to solve this issue

A: If you have access to the hosting server, you could try re-installing the .net Framework version in this case version 2.
Here are two good Microsoft KB articles that could help.
How to repair an existing installation of the.NET Framework
How to manually remove and then reinstall the.NET Framework 2.0


text:
Q: Making a custom JPA Hibernate sequence for non id field I have this entity.
@Entity
@Table(schema = "public")
public class Policeman implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name="id")
    private Long id;

    @Column
    private String number;

    @Column
    private String fam;

    @Column
    private String name;

    @Column
    private String otch;
//setters, getters i ommited
}

I would like to make a custom autogeneration for field "number" for non "id" field when record inserts in db. I want to make an autoincrement. I want to use the following pattern "policeman-" + several zeros + number. policeman - (number consists 4 digits, empty ones fills with zeros).
For example, generated numbers such as
policeman-0001
the next one is:
policeman-0002
another example:
policeman-0315
etc.
Which technologies, libraries, methods, annotations should i use to implement this? Thanks


text:
Q: What is the scope of a DI scope - Hangfire in .NET Core Imagine in ASP.NET Core I register a dependency as Scoped like the following:
IServiceCollection services = ...
services.AddScoped<IEmailService, EmailService>();

Then I know that for each HTTP request a new scope will be created and a new instance of Email service will be reused. Moreover, the same scope will persist for the lifetime of a request.
Now, imagine I add a Hangfire Background Job like this:
RecurringJob.AddOrUpdate<IServiceA>("DoA", s => s.DoA(), Cron.Daily());

where
public class ServiceA: IServiceA {
    public ServiceA(IEmailService emailService) { ... }
    public void DoA() { ... }
}

I would like to understand what does scoped mean in hangfire job terms, by default, does hangfire

*

*use a single scope for all the jobs and runs

*create separate scopes for each job, but different runs of the same job share the scope

*create separate scopes for each run of any job

Bonus points for an explanation on how to configure it.

A: As Panagiotis Kanavos put in a comment above (but to make more visible as an accepted answer):

Looks like this is provided out of the box if you simply call AddHangFire in your DI configuration. Each execution is wrapped in a scope, no matter what DI container is used. This isn't documented anywhere though


text:
Q: How to maximize 3 variable equations subject to a constraint? Let's say I want to maximise a function $f(x,y,z)=a\ln(x)+(1-a)\ln(y)-\frac{z^2}{2}$ subject to a constraint that is equal to $x+\frac{y}{1+r}=Wz$
Assume variables are all real numbers and $0<a<1$
How would I go about doing this?
z
I have tried:
$\mathcal{L}= \alpha \ln{x}+(1-\alpha)\ln{(y)}-\frac{{z}^2}{2}+ \lambda(Wz-{By}-x)$ and partially differentiating w.r.t. $x,y,z$ but I get stuck on finding $z$ as $Wz$ varies with $z$.
Attempt:
$\frac{\partial{\mathcal{L}}}{\partial{x}}=\frac{\alpha}{x}-\lambda=0$
$\frac{\alpha}{x}=\lambda$
$\frac{\partial{\mathcal{L}}}{\partial{y}}=\frac{1-\alpha}{y}-\frac{\lambda}{1+r}=0$
$\frac{1-\alpha}{y}=\frac{\lambda}{1+r}$
$\frac{(1-\alpha)(1+r)}{y}=\lambda$
$\frac{\partial{\mathcal{L}}}{\partial{z}}=W\lambda-z=0$
$W\lambda=z$
$\frac{z}{W}=\lambda$

A: Hint:
Maximize
$$a\ln(x)+(1-a)\ln(y)-\frac12\left(bx+cy\right)^2$$ for $x,y$ (without constraint; auxiliary constants introduced for convenience).

$$\dfrac ax-b(bx+cy)=\dfrac{1-a}y-c(bx+cy)=0.$$ There is no valid solution !

A: Using the Lagrangian multipliers procedure:
calling
$$
f(x,y,z) = a\ln x+(1-a)\ln y -\frac 12 z^2
$$
the lagrangian can be established as
$$
L(x,y,z,\lambda) = f(x,y,z)+\lambda\left(x+\frac{y}{r+1}-z W\right)
$$
The $L$ stationary points are the solutions for
$$
\nabla L = 0 = \left\{
\begin{array}{rcl}
 \frac{a}{x}+\lambda  & = & 0\\
 \frac{1-a}{y}+\frac{\lambda }{r+1} & = & 0\\
 \lambda  W+z & = & 0\\
 x+\frac{y}{r+1}-W z & = & 0\\
\end{array}
\right.
$$
obtaining
$$
\left[
\begin{array}{ccccc}
 f & x & y & z & \lambda \\
a \log (a W)-(a-1) \log ((1-a) (r+1) W)-\frac{1}{2} & a W & (1-a) (r+1) W & 1 & -\frac{1}{W} \\
 a \log (-a W)-(a-1) \log ((a-1) (r+1) W)-\frac{1}{2} & -a W & (a-1) (r+1) W & -1 & \frac{1}{W} \\
\end{array}
\right]
$$
NOTE
Depending on the parametric values for $a,r,W$ the obtained values cannot be feasible.


text:
Q: Bash sort tab delimited rows based on specific column with most values delimited by comma I have rows like so:
rs6605071   chr1:962943 XM_017002478.2  stuff1,stuff2                           morestuff
rs6605071   chr1:962943 XM_017002479.1  stuff1,stuff2,stuff3,stuff4,stuff5      morestuff
rs6605071   chr1:962943 XR_001737138.1  stuff1,stuff2,stuff3                    morestuff
rs6605071   chr1:962943 XR_001737478.1  stuff1,stuff2,stuff3,stuff4             morestuff
rs6605071   chr1:962943 NC_426604.3     stuff1                                  morestuff
rs6605071   chr1:962943 NC_426605.3     stuff1                                  morestuff

I would like to sort my rows by the 4th column for the desired output:
rs6605071   chr1:962943 XM_017002479.1  stuff1,stuff2,stuff3,stuff4,stuff5      morestuff
rs6605071   chr1:962943 XR_001737478.1  stuff1,stuff2,stuff3,stuff4             morestuff
rs6605071   chr1:962943 XM_017002478.2  stuff1,stuff2                           morestuff
rs6605071   chr1:962943 NC_426604.3     stuff1                                  morestuff
rs6605071   chr1:962943 NC_426605.3     stuff1                                  morestuff

What is the best approach to achieve such result in bash ?
Edit 1: The column 4 shouldn't be sorted alphabetically. It has to be sorted according to the number of values found (delimited by commas).
Thank you in advance

A: So this is a bit hacky, but it works.  I can't tell your delimeter (if it's tabs or spaces), but something like this will work, and allows for fairly easily manipulation:
 cat asdfasdf.txt | awk '{print gsub(/,/,","),$1,$2,$3,$4,$5}' | sort -r | cut -d' ' -f2,3,4,5,6

Now, there has got to be a way to do this entirely in awk, and I'm always in awe of the awk experts who know it so well.
I hope one of them puts together a more elegant command, but for now, this will help in a pinch.


text:
Q: How can I distinguish a service form a process in Activity Monitor? Is there a way to determine if an entry listed in Activity Monitor is a service (daemon) or a process (application)?
Examples:

*

*Firefox (application)

*com.apple.audio.SandboxHelper (daemon?)

Is there a good definition of what these terms (that I'm using loosely) mean in OS X?

A: All Processes, Hierarchically
Activity Monitor can show the process hierarchy:
Activity Monitor.app > View (menu) > All Processes, Hierarchically
The grouping shows those processes launched by another process. Typically child-process will be services of the parent. On macOS many of these child processes will be XPC instances.
Services are Processes
On macOS, daemons are processes and services are processes. In your example, com.apple.audio.SandboxHelper, this is an XPC service.

A: Technically speaking, anything that gets loaded and executed is a process; so a service is a process.
A service is a nuanced definition of something that gets loaded to provide a service like DHCP or DNS.
A alternative way to sum this up is all services are processes, but not all processes are services.  An example would be Firefox, it's a process, but not a service - it's an application.


text:
Q: Solving the geodesic equation for a singularity crossing curve [Apologies if this question is not considered research level, but it received no substantive comments and no answers at math.SE; I thought it was straightforward, but maybe it isn't.]
Part I - What are the formal conditions for the solubility of the geodesic equation
$$\frac{d^2 x^\mu}{ds^2} =- \Gamma^{\mu}_{\alpha \beta} \frac{dx^\alpha}{ds} \frac{dx^\beta}{ds} ?$$
Part II - Consider (see figure) the particular case of a pseudo-Riemannian manifold whose metric is everywhere constant except on the surface $\Sigma$ (and the metric on $\Sigma$ may vary smoothly from place to place) such that every causal curve from $p$ to $q$ intersects the surface $\Sigma$ at a single point (except possibly in the null case), which surface - appearances in the figure not withstanding - might be or have null regions, and across which the metric is discontinuous.
Are there any conditions on the metric on $\Sigma$ (or otherwise) that make the geodesic equation soluble? (Possibly piecewise?).
Notes
The usual approach to solving the geodesic equation will not work, I believe, because of the curvature discontinuity introduced by $\Sigma$ that entails undefined derivatives across $\Sigma$, but maybe if one took as an assumption that $\Sigma$ is nowhere null, one could consider the curves to $\Sigma$ on each side separately and seek identity of their limit points.
If there are regions of $\Sigma$ that are null it seems to me it might be possible for the limit points of the two segments of $\gamma$ to be separated in $\Sigma$.
PS I'm not a mathematician, so in attempting to be suitably precise for those who are, I may in fact have had the opposite effect; I hope others can read between the lines.

A: This is probably a longer comment, but let me make this into an answer.
Suppose $\gamma$ is a curve in your manifold and we are asking if it satisfies the geodesic equation in some sense. Then either
(a) it hits $\Sigma$ at a discrete set of points $t_k$. Then the natural requirement that $\gamma$ satisfies the geodesic equation on the intervals $(t_k, t_{k+1}), \dots$ plus asking that the left and right sided derivatives at the points $t_k$ coincide already makes it into a geodesic of usual Minkowski space, i.e. a straight line, and the modification of the metric on $\Sigma$ does not play a role.
(b) The set of times $t$ such that $\gamma(t) \in \Sigma$ is not discrete. Then one would need to make sense of the geodesic equation at $\Sigma$, which seems kind of hard, because there is no way to define the Christoffel symbols etc. Also, a weak formulation (using Sobolev spaces etc.) does not really make sense, because $\Sigma$ is a zero set, hence the metric modified on $\Sigma$ as your describe defines the same element in $L^2$ as the original Minkowski metric.
So it seems that either we are in a trivial situation, and your modification just doesn't play a role, or we are in a situation where it is impossible to say what the geodesic equation even means.

A: Perhaps you mean to say that your metric behaves rather like those arising  in Snell's law from geometric optics
where to  model the  refraction of  light as it passes from one medium to another you take an  index of refraction $n$ constant along slabs with a jumps at the interface? The optical metric is  $(1/n) (dx^2 + dy^2 + dz^2)$ where  the scalar function $n$ is piecewise constant, suffering a jump at the interface.  Do you perhaps mean   your pseudo-Riemannian  metric to have  the form
$A_- (dx^2 + dy^2 + dz^2 - c^2 dt ^2 )$ on one side of your hypersurface $\Sigma$, and $A_+ (dx^2 + dy^2 + dz^2 - c^2 dt ^2 )$ on the other side, where $A_+, A_-$
are positive constants?  If so,   a kind of `Snell law'' will hold. To compute  this law for the angle
of ``refraction' as your geodesic crosses   $\Sigma$ you extremize its arclength relative to   the constraint that the curve is piecewise linear
with a jump at $\Sigma$.  This will yield a calculus problem in 4-space.


text:
Q: If any value equals any value condition doesn't accept two words I am creating a workflow in SharePoint Designer and am using the "If any value equals any value" condition.
I want to check if the current item is in a particular folder. The folder has two words to it's name: let's say the folder is called "This Folder". The if condition looks like this now: If CurrentItem:URL Path contains This Folder.
I set a task in the true part of the condition to email myself, then I have a task at the end of the workflow to email the CurrentItem:URL Path. I only get the second email. And when I look at the URL it has /[site]/[subsite]/This Folder/[filename] yet it did not pick it up in the if condition.
I've tried using quotes like: "This Folder". Still did not work. Also many articles I've read shows the user using the same syntax and apparently returned the right item for them when they were looking for something with two words.
Note: A workaround I found, but don't want to use is using the CurrentItem:Encoded Absolute URL containts This%20Folder. Since the URL is encoded it can't have spaces so using %20 makes it all one word, but I'd prefer to keep all my if checks with CurrentItem:URL Path


text:
Q: Next Js Accrodion should be collapse when click arrow icon I am using Accordion in next js. I am following this (react-accessible-accordion) package.
Currently it is getting collapse when main div is getting clicked. What i want to achieve is According should be collapse when click on arrow icon not on main div.
If there is an alternate way of doing this please let me know.
UPDATE
Here is the code sandbox
What i want to achieve is explained here
Thanks!

A: first I had to modify the styles so the icon is not taking the full width.
Accordion.css
.accordion__icon {
  /* margin-left: auto; */
  transition: transform 0.6s ease;
}

.accordion {
  background-color: #eee;
  color: #444;
  cursor: pointer;
  padding: 18px;
  display: flex;
  align-items: center;
  border: none;
  outline: none;
  transition: background-color 0.6s ease;
  /* add flex display and justify content */
  display: flex;
  justify-content: space-between;
}

Add onClick to the main SVG and pass it through the props.
Chevron.js
// pass an onClick props to the main SVG
function Chevron(props) {
  return (
    <svg
      className={props.className}
      height={props.height}
      width={props.width}
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 320 512"
      onClick={props.onClick}
    >
      <path
        fill={props.fill}
        d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"
      />
    </svg>
  );
}

export default Chevron;

Finally make the props.onClick of the Chevron component handle the onClick event not its Button parent component.
Accordion.js
...
// move the onClick from the button to the Chevron component
return (

      <button className={`accordion ${setActive}`}>

{props.title}

        <Chevron
          onClick={toggleAccordion}
          className={`${setRotate}`}
          width={10}
          fill={"#777"}
        />
      </button>
...)

full sandbox link


text:
Q: Fade out video/audio with FFMPEG i'm trying to simply fade out both video and audio of an input.mp4.
The video lasts 00:29:59 (1799 sec) and i want to fade out the last sec.
I'm using this command (it should just fadeout the video):
ffmpeg -i input.mp4 -vf fade=t=out:st=1798:d=1 output.mp4
but it always give me the same error:
Too many packets buffered for output stream 0:1.
[aac @ 0000000002605b60] Qavg: 2430.591
[aac @ 0000000002605b60] 2 frames left in the queue on closing

What am I doing wrong?
EDIT: The file i was trying to edit was corrupted, with other files the filter works well :)

A: Well if you were trying to also fade out the audio you would I believe need to incorporate the afade filter. You can accomplish both using a complex filter:
ffmpeg -i input.mp4 \
    -filter_complex \
        "[0:v]fade=t=out:st=1798:d=1[v]; \
         [0:a]afade=t=out:st=1798:d=1[a]" \
     -map "[v]" -map "[a]" output.mp4

A: add '-max_muxing_queue_size 999' to your ffmpeg command that is:
ffmpeg -i input.mp4 -max_muxing_queue_size 999 -vf fade=t=out:st=1798:d=1 output.mp4
haven't tried this command myself but I've encounter myself with same error and the flag solved the problem. See also ffmpeg ticket


text:
Q: Oracle SQL - Group by distinct columns I have a query that is being created dynamically based on a different query (a string) which is passed in. In the below, the string being passed in to generate the query is the quoted parameter of dbms_xmlgen.get_xmltype (The quoted query is irrelevant to answering the question, I am looking to change the outer query)
SELECT s.value AS "value"
         ,im.sequence AS "sequence"
         ,lookup_detail_lib.get_type_value_message AS "prefix"
         ,lookup_detail_lib.get_type_value_message AS "suffix"
         ,im.field AS "field"
    FROM xmltable('for $i in ./ROWSET/ROW/* return $i' passing
                  dbms_xmlgen.getxmltype('SELECT blah blah this generates a clob') columns
                  column_name VARCHAR2(100) path 'local-name()'
                 ,VALUE CLOB path 'text()') s
        ,info_metadata im
        ,task t
        ,job j
   WHERE im.column_name = s.column_name
     AND im.job_type = j.job_type
     AND j.job_id = t.job_id
     AND NVL(im.task_type, t.task_type) = t.task_type
     AND t.task_id = 13580
   ORDER BY im.sequence;

The  result of this query is:

However my desired result would put the column im.sequence in this order: 1,2,3,4,2,3,4 (rather than the shown 1,2,2,3,3,4,4). My question is, is there a way I could sort of group these so that they are in order of distinct ascending im.sequence? Note: For further clarification, I am looking to manipulate the outside query, I cannot change the inner quoted query. Any feedback is appreciated!

A: You can do:
with t as (
      <your query here>
     )
select t.*
from (select t.*,
             row_number() over (partition by sequence order by sequence) as seqnum
      from t
     ) t
order by sequence;

This does not duplicate the "1" row but it does sort the rest as you desire.


text:
Q: SOAP webservice I am trying to create the web services client and for that generated the proxy classes using wsdl file.
After that i follow the below steps:

*

*created the service class object

*using service class got the associated port

*invoking the service method on the port object.

My services class(server side code) signature is something like this:
public javax.xml.soap.SOAPElement validateAddress(javax.xml.soap.SOAPElement validateAddress){

    .......

    return SOAPElement ;
}

my problem is i don't have any idea how to create SOAPElement object to call this method as well as after receiving SOAPElement as a result how to extract that to get the actual value.
can anybody help me on this...
Thanks for advance.

A: You may follow this well written complete guide:
http://www.ibm.com/developerworks/webservices/tutorials/ws-jse/


text:
Q: How to show only one option of the many options to each participant on Qualtrics using Piped Text? Background:

*

*193 emails. Each email is one sentence.

*mTurk participants see the question "the next day you receive this email (inserted one email out of 193 emails)" then asked to rate the email. The question is Descriptive Text. The rating is made into a separate multi-choice question.

What I want to do:
Each participant will see only one email out of the 193 emails, randomly.
What I tried to do:
Using Piped Text to pipe 193 emails into Descriptive Text. I tried to input the 193 emails into Loop & Merge, then pipe Loop & Merge into Descriptive Text. None of the emails was shown when I previewed the block.
My sense now is that I should use embedded data, but I can't figure out a way to input the 193 emails into an embedded data field.
My question:
How to achieve what I want to do? I'm also open to using tools other than Piped Text. I just can't figure out a way to do this on Qualtrics. Any help greatly appreciated!

A: In your survey flow, add a randomizer then under the randomizer add 193 embedded data blocks.  Inside each embedded data block assign one of the 193 emails to the embedded data variable.
email_pipe = Email 1
email_pipe = Email 2
email_pipe = Email 3
etc.

Set the randomizer to present 1 of the 193 elements and check Evenly Present.
If you find it cumbersome to do in the survey flow, you could do a multiple choice question with 193 choices and use Advanced Randomization to randomly display 1 of the 193 choices, evenly presented. Then hide the question with JavaScript and pipe the displayed choices into your question.


text:
Q: Hay alguna manera de poner codigo php en contact form 7 para realizar mi trackin? Tengo unas Landing Page en código html, ahora estoy pensando en pasarlas a wordpress, en los contact.php tengo un código php que coge unos valores, me gustaría saber si yo al pasarlo a wordpress esos códigos php que tengo en el contact.php puedo ponerlos en el plugin contact form 7 de wordpress?
Os pongo el codigo que tengo en contact.php que utilizamos composer
<?php
// Composer's auto-loading functionality
require "vendor/autoload.php";

use Google\Spreadsheet\DefaultServiceRequest;
use Google\Spreadsheet\ServiceRequestFactory;

//

 $nombreAplicacion = "XXXX";
 $direccionCorreo = "XXXXXXX";
 $idCliente = "XXXXX";

// Nombre del SpreadSheet creada
 $nombreSpreahSheet = "Php Sheet volcado";
 // Nombre de hoja de cálculo
 $hojaCalculo = "Hoja 2";

 $scope = array('https://spreadsheets.google.com/feeds');

 // Inicializamos Google Client
 $client = new Google_Client();
 $client->setApplicationName($nombreAplicacion);
 $client->setClientId($idCliente);

 // credenciales, scope y archivo p12. Agregar el correcto Path al archivo p12
 $cred = new Google_Auth_AssertionCredentials(
 $direccionCorreo,
 $scope,
 file_get_contents('PhpSheet-3a5bbd2c9ada.p12')
);

 $client->setAssertionCredentials($cred);

 // si expiro el access token generamos otro
if($client->isAccessTokenExpired()) {
 $client->getAuth()->refreshTokenWithAssertion($cred);
}

// Obtenemos el access token
$obj_token = json_decode($client->getAccessToken());
$accessToken = $obj_token->access_token;

 // Inicializamos google-spreadsheet-client
 $serviceRequest = new DefaultServiceRequest($accessToken);
 ServiceRequestFactory::setInstance($serviceRequest);

 //Obtenemos los Spreadsheets disponibles para las credenciales actuales
 $spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
 $spreadsheetFeed = $spreadsheetService->getSpreadsheets();

// Obtenemos la spreadsheet por su nombre
$spreadsheet = $spreadsheetFeed->getByTitle($nombreSpreahSheet);

// Obtenemos las hojas de cálculo de la spreadsheet obetenida
$worksheetFeed = $spreadsheet->getWorksheets();

// Obtenemos la hoja de cálculo por su nombre
 $worksheet = $worksheetFeed->getByTitle($hojaCalculo);
 $listFeed = $worksheet->getListFeed();

 if(!empty($_SESSION['nombre'])) {
 $dataAgregar = array('gclid' => $_SESSION['gclid'],
 'nombre' => $_SESSION['nombre'],
 'email' => $_SESSION['email'],
 'telefono' =>"'" .$_SESSION['phone'],
 'mensaje' => $_SESSION['mensaje'],
 'landing' =>  $landingP
 );
  $listFeed->insert($dataAgregar);
 }
 if(!empty($_SESSION['nombre2'])) {
  $dataAgregar2 = array('gclid' => $_SESSION['gclid2'],
 'nombre' => $_SESSION['nombre2'],
 'email' => $_SESSION['email2'],
 'telefono' =>"'" .$_SESSION['phone2'],
 'mensaje' => $_SESSION['mensaje2'],
 'landing' =>  $landingP2
 );
 $listFeed->insert($dataAgregar2);
 }
 ?>

Como tenemos que utilizar composer en la carpeta del theme he de subir un index.php, una carpeta de vendor y unos archivos composer, como en el theme ya tenemos un index.php no se si tambien sirve coger el codigo el index.php e introducirlo en el index.php del theme para que funcione composer?

A: Podrías añadir en el functions.php el siguiente código:
add_action('wpcf7_before_send_mail', 'mi_funcion');

function mi_funcion($cf7) {
    //Código PHP
}

La manera de tratar las variables de envío es accediendo a la variable  $_POST['nombre_de_mi_campo'] donde 'nombre_de_mi_campo' se corresponde con el nombre definido en el formulario de contact form 7. Sólo te faltaría añadir tu código ligeramente modificado para acceder a las variables correctamente dentro de la función.
Edito la respuesta porque has editado la pregunta
Bueno, de repente estamos hablando de composer, poco te puedo decir al respecto, una manera de utilizarlo es creando un directorio en la ruta "themes/mi_tema/directorio" donde alojar todo lo necesario, así cuando ejecutes "composer install" te creará el directorio vendor e instalará en él las dependencias que especificas en el json (creo que es así).
Una vez has hecho esto, añade la siguiente línea en functions.php o en wp-config.php:
require_once(__DIR__ . '/vendor/autoload.php');

y ya debería funcionar.
Comentas que te arroja un error 500, esto en wordpress puede ocurrir por falta de memoria en PHP o por un error en el htaccess.


text:
Q: tcp socket data send in xml packet I'm trying to send some data over tcp socket. Now the thing is instead of sending simple char* data I need to buffer some data and make one xml packet structure out there and therefore send that xml data over the network. For example I have one ini file to read all the data into corresponding variables. say:
[Device data ini]

DeviceID = 0042
Manufacturer = Company Name
VendorID = 00-291-647
Timestamp = 2014-08-13 12:40:11

Now I need to make the xml out of above data like below:
<?xml version="1.0" encoding="utf-8"?>
<DataBlock xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <DeviceID>0042</Device>
    <Manufacturer>Company Name</Manufacturer>
    <VendorID>00-291-647</VendorID>
    <TimeStamp>2014-08-13 12:40:11</TimeStamp>
</DataBlock>

And send these whole data as char* to server. What would be the best approach to build the xml data packet from simple char* data structure. Code will be written in c++ and the xml will be parsed at the server side with c# code. Any suggestions or recommendation would be off great help.

A: Use any C++ tokenizer to split input/source data in order to process each line separately (use \r\n as separators).
For example you can use boost::split to do that. After that for each line use the same technique to extract the key and the value (use = as separator character). You can put parsed keys and values to a std::map because you'll need them on next step. The last step - simply format your target xml string using parsed data. To do that you need to iterate through map elements and format the result string. You can also use XML template string with placeholders for each attribute and replace them with parsed values.

A: I would suggest that it would not be good approach to first convert the data into XML, until and unless its very important or there is no other choice. The reason for this is that when you are formatting the values in XML, you are increasing the number of bytes to be send over the network. Instead of this, a better approach would be send the values to the other end and convert it to XML before handing over to the C#. You can use structure approach for sending and receiving.


text:
Q: Show number of ListTile according to a condition I want to develop an app about five books all with different number of chapters e.g

*

*Book A - 20 chapters

*Book B - 14 chapters

*Book C - 23 chapters

*Book D - 18 chapters

*Book E - 19 chapters

I have done :

the signIn page the the signUp page and the the choose book page

I want to do :

the choose chapter page

NOTE: BOTH the choose book page AND the choose chapter page USE LISTTILE
When it came to the choose chapter page i had a problem with displaying the number of ListTiles according to book type, should i create different choose chapter pages for each book (i was afraid of repetition of code) or there is a feature in Flutter that lets you show number of ListTiles according to certain condition (if its available) the condition in my case being the book type
I need a guide to whether i should :

*

*Create different choose chapter pages for each book.

*Use a feature in Flutter that lets you update ListTiles according to certain condition.

In the the choose book page one of the ListTile
CODE I TRIED SO FAR
ListTile(
          leading: CircleAvatar(
            backgroundImage: AssetImage("assets/books/book_a.jpg"),
          ),
          title: Text(
            'Book A',
          ),
          subtitle: Text('2348033980943')
          onTap: ()
          {
            //can i define no.ofchapters here and take the value on to the next screen??
            int number_of_chapters = 20,
            Navigator.pushNamed(context, ChooseChapterScreen.id);
          },
        ),`

A: class Chapters{
   String title;
   List<String> chapters;

   Chapters(this.title,this.chapters);
}

              // Inside your tap method
              onTap: ()
              {
                List<String> chaptersList= ["Chapter 1", "Chapter 2", "Chapter 3"];
                // you can pass arguments with named routes
                Navigator.pushNamed
                       (context,
                       **Your_Next_Screen**,
                       arguments: Chapters(
                       'Book A',
                       chaptersList,
                       ),
                );
              },

Inside your build method of the Your_Next_Screen retrieve the data like,
@override
  Widget build(BuildContext context) {
    // Extract the arguments from the current ModalRoute settings and cast
    // them as Chapters.
    final Chapters args = ModalRoute.of(context).settings.arguments;

    var title= args.title;
    var list= args.chapters;

    return Scaffold(
      // your widget
    );
  }
}

A: You can use a ListView.builder()(Docs) for that. It takes some parameters, like the number of items you want to build, and a builder method to be called for each of the N elements you wish to build.
ListView.builder(
  itemCount: book.chapters.length, // Use the number of chapters here
  itemBuilder: (BuildContext context, int index) {
    // Each chapter will be a ListTile, you can add more parameters, or use whatever widget
    return ListTile(title: Text("Chapter $index"));
  }
)

Here's an example by the Flutter team.


text:
Q: SQUID Transparent Proxy: Error INVALID_URL and ACCESS_DENIED I configure squid proxy on Centos 7. I am using Squid version 3.5.20.
I also try squid 4.10 on Ubuntu 20.04, but I got the same problem. Maybe my ACL was wrong.
I configure DSTNAT on Router to intercept HTTP traffic from 192.168.1.0/24 to Squid Proxy 10.10.10.10:3128.

This is /etc/squid/squid.conf file:
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl whitelist_domain dstdomain "/etc/squid/whitelist.acl"

http_access allow localnet
http_access allow localhost
http_access allow whitelist_domain
http_access deny all

http_port 3128
coredump_dir /var/spool/squid
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%  1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%  0
refresh_pattern .               0   20%     4320

And this is the /etc/squid/whitelist.acl file:
linux.or.id
lipi.go.id

Please help me to find the problem.
So,regarding the above config, the client will be denied to access all http website, except linux.or.id and lipi.go.id. Right?
However, when I try to connect. All website has this error: INVALID URL

This is /var/log/squid/access.log
1633885185.900      0 192.168.1.251 TAG_NONE/400 3867 GET / - HIER_NONE/- text/html
1633885185.970      0 192.168.1.251 TCP_IMS_HIT/304 295 GET http://linux:3128/squid-internal-static/icons/SN.png - HIER_NONE/- image/png

I was trying to change the squid.conf like this:
http_access allow all
http_port 3128 intercept
http_port 3129
coredump_dir /var/spool/squid
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%  1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%  0
refresh_pattern .               0   20%     4320

That ACL will allow all request.
However, I got ERROR ACCESS DENIED, which mean my ACL blocked the access right?


text:
Q: How to programmatically create a GraphQl request Currently I am trying to make a graphql POST request in Spring Boot. This is my request :
mutation { update(bank: {id : "c0ad2522-c40c-4478-8b6f-b0261eab1116", bank : "bankExample", IBAN : "1234", currency : "GBP" }){ id } }
How can I programatically create the above mentioned query in Java. Since the syntax is not a json is there a builder or an object mapper for this? I've tried to check everywhere but could not find an example or documentation. I'm trying to make this call between two spring boot microservices with two different graphql schemas.
Thank you for you time.


text:
Q: Changing access modifier of CreateRow method of GridView Is it possible to change the access modifier in c# asp.net for a dll file.
For example, i am trying to use CreateRow of GridView in C# asp.net and the error i get is
"System.Web.UI.WebControls.GridView.CreateRow(int, int, System.Web.UI.WebControls.DataControlRowType, System.Web.UI.WebControls.DataControlRowState)
is inaccessible due to its protection level"
I checked the modifier and it is protected. When i tried to change, it says readonly and cannot be changed. Is it possible?
UPDATE: I am trying to get a dataset from database and trying to bind it to gridview. Dataset might have upto 4 rows. If it has any rows less than 4 the remaining rows should be shown empty in the gridview. So i am trying to create 4 empty rows using CreateRow method and then binding each row from the dataset. I hope i am clear!
Thank you in advance!!

A: I'm not going to anwer your original question as asked ("Is it possible to change the access modifier in c# asp.net for a dll file"), but the root of your question (adding empty rows to your GridView).
I think the better approach (rather than trying to call CreateRow on the GridView) is to just add empty rows to your dataset, and then bind it to your GridView.  this would be different based on what specific data type your storing your data in, but the basic steps would be:

*

*Get your data from the database

*Use logic to check how many rows there are

*If there are less than 4 items, add additionaly (empty) items / rows to the collection where your data is stored from step 1.

*Set GridView.DataSource to that data collection

*Call GridView.DataBind();

To elaborate on step #3, do something like this:
// Get your DataSet from the database
DataSet data = getMyDataSomeHow();
// Create a blank row
object[] newRow = new object[3]; // where "3" is the number of columns in your table
newRow[0] = "";
newRow[1] = "";
newRow[2] = "";
//Add the blank row
data.Tables["myTable"].BeginLoadData();
data.Tables["myTable"].LoadDataRow(newRow, true);
data.Tables["myTable"].EndLoadData();


text:
Q: Girsanov transformation brownian motion If you have a SDE say:
$dX = \mu dt + \sigma d W$,
where $\mu$ and $\sigma$ are not necessarily constant. Say, this process corresponds to a probability $P$. If you apply a Girsanov transformation and obtain a process $d\hat{X}$, under a new probability $\hat{P}$, is this new probability density always that of a Brownian motion density? I.e,. something like:
$\frac{1}{\sqrt{t} \sqrt{2 \pi}} exp \left[-\frac{1}{2} \left(\frac{x}{\sqrt{t}}\right)^2\right] dx$,
where this is the density of $d\hat{W}(t)$ at $x$?

A: Unless $\mu$ and $\sigma$ are deterministic, there is no reason to expect that the distribution of $X$ will be Gaussian under $P$. By the same token, if $\mu$ and $\sigma$ are deterministic but the drift of $W$ under $\widetilde{\mathbb{P}}$ is not (and there is no guarantee it will be deterministic) then $X$ is unlikely to be Gaussian under $\widetilde{\mathbb{P}}$.


text:
Q: Creating WooCommerce Analytical report with SQL I just recently moved to WooCommerce platform and need to build SQL in MySQL to run my own analytical reports. For example, I need report that shows total number of sales per sku, per country in the last 30 days.
I explored tables like 'wp_posts', 'wp_postmeta' and found that most fields from products and orders are record-based, not column based which makes the SQL a little more challenging.

A: Finally built the SQL by myself. Hope it will be useful for other WooCommerce users who don't want to use analytical out-of-the box solutions or need custom reporting.
SELECT
    sku, count(1)
FROM
    wp_woocommerce_order_items oi, -- orders table
    wp_posts p, -- woocommerce use posts to keep metadata on the order
    wp_postmeta pm, -- we use this table to filter the completed orders
    wp_postmeta pm1, -- we use this table again for getting the shipping country info
    wp_woocommerce_order_itemmeta oim, -- use this table to get product ids from orders
    (SELECT p.id as product_id, meta_value as sku FROM wp_posts p, wp_postmeta pm  where
        post_type='product' and post_status='publish'
        and meta_key='_sku'
        and p.id=pm.post_id) as sku_table -- building temp sku table from published products that defines relationship between product id and sku
WHERE
    oim.meta_value=sku_table.product_id AND
    oi.order_id=p.ID AND
    p.id=pm.post_id AND
    pm.meta_key='_paid_date' AND  -- here we make sure that the order was completed
    p.id=pm1.post_id AND
    order_item_type='line_item' AND -- get only line items but not tax or shipping
    oi.order_item_id=oim.order_item_id AND
    oim.meta_key='_product_id'  AND
    post_date>'2014-01-01' AND -- limits the report date
    pm1.meta_key='_shipping_country' AND -- get shipping country
    pm1.meta_value='US' -- limits the country
GROUP BY sku
ORDER BY sku;

A: Correct me if I'm wrong but I think you missed that each line item also has a quantity in wp_woocommerce_order_itemmeta. So your query is just counting how many orders there are for each SKU and not how many of them were sold.


text:
Q: How to change the first value and last value in a matrix I try to simplify my encounter,so I post a question.But I aware that turn a unexpected direction.I try to re-assign the first and last element in a matix,such as I have:
mat={{1,2,3,4},{5,6,7,8},{9,10,11,12}}

How to get with a concise method?
{{a,2,3,4},{5,6,7,8},{9,10,11,b}}

And I try to use mat[[{{1,1},{-1,-1}}]]={a,b} to get what I want,I get some error information,despite I think I have not made syntax error.

A: You could always do this with ReplacePart although you have to reassign mat altogether:
In[50]:= mat = ReplacePart[mat, {{1, 1} -> a, {-1, -1} -> b}]

Out[50]= {{a, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, b}}

A: Also
indices = {{1, 1}, {-1, -1}};
vals = {a, b};

mat = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
(mat[[##]] = vals[[#]]) & @@@indices; mat

{{a, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, b}}

Or
mat = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
mat = Block[{i = 1}, MapAt[vals[[i++]] &, mat, indices]]; mat

{{a, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, b}}

Or
mat = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
(mat[[## & @@ #]] = #2) & @@@ Transpose[{indices, vals}]; mat

{{a, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, b}}


text:
Q: Complete HTML Strip function I have an HTML string like this:

First Sentence is this. Second sentence is this.

I am able to remove the
 tags from the above string using a regex function.
But, how to remove   - encoded characters from the above string in winforms?
I don't want   to be present in the output.

A: You can use XElement.Parse to get the node value like this:
 var htmlString = "
First Sentence is this. Second sentence is this.
";
 var result = System.Xml.Linq.XElement.Parse(htmlString).Value;

If not all the strings contain valid XML structure, or may have no tags at all, you can add fake tags like this:
 var htmlString = "
First Sentence is this. Second sentence is this.
";
 var result = System.Xml.Linq.XElement.Parse("<root>" + htmlString + "</root>").Value;

Result:

You might want to add error handling for this, but this is clearly better than using a regex for this.
EDIT:
In case this is still not working, and you want to just handle the entities, you can leverage System.Web.HttpUtility.HtmlDecode method to replace HTML entities with literals:
var final_result = System.Web.HttpUtility.HtmlDecode(result);

A: Considering the fact the input is a plain string
string x = "
First Sentence is this. Second sentence is this.
";
x= x.Replace(" "," ");

This is way too simple, but will work.


text:
Q: Javascript /Jquery Reload I have a slider on my blog that won't work once the page is cached. The slider is only visible on the home page so I want to reload just this page and not take away cache functionality from other pages. Can I enter an argument into javascript to get the home page to load from server every time? or?
Thanks!
KIN
UPDATE
Still working on this. I have noticed that the error I get when the slider dose not load is
Uncaught TypeError: Object #<Object> has no method 'bxSlider' page2.html:1175
(anonymous function) page2.html:1175
k jquery.min.js:2
l.fireWith jquery.min.js:2
p.extend.ready jquery.min.js:2
D

Here is the code I am using.
<head>
<!-- jQuery library (served from Google) -->
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'/>
<!-- bxSlider Javascript file -->
<script src='https://googledrive.com/host/0B4lBcpVXd4Y-c2kyZWF5QWpxME0' type='text/javascript'/>
<script type='text/javascript'>
$(document).ready(function(){
  $('.bxslider').bxSlider();
});
</script></head>

Any help is greatly appreciated!

A: The cache shouldn't have anything to do w/ the slider, but to answer your question, use location.reload(true). Documentation here: http://www.w3schools.com/jsref/met_loc_reload.asp
The true argument forces the page to reload from server.


text:
Q: Question About Automatically set method parameters There are dictionary and methods.
ALL_DIC = {"A":"a", "B":"b", "C":"c", "D":"d", "E":"e"}

def something(A=None, B=None, D=None):
    print(A,B,D)

something(**ALL_DIC)

The following error occurred:
Traceback (most recent call last):
  File "D:/crawl_master/nolja.py", line 186, in <module>
    something(**ALL_DIC)
TypeError: something() got an unexpected keyword argument 'C'

So I used the followings,
but I don't like it. I'd like to know if there is a better way or library.
import inspect
args, _, _, values = inspect.getargspec(something)
for key in list(ALL_DIC.keys()):
    if key not in args:
        del ALL_DIC[key]

something(**ALL_DIC)

I'd like some advice. Thank you for reading it.

A: A much easier way to do it is to make something accept variable keyword arguments:
def something(A=None, B=None, D=None, **kwargs):
    print(A,B,D)

so that any additional keyword arguments passed to something will be accepted (and ignored, if you don't use kwargs).


text:
Q: How to translate a touch event on screen to SeekBar progress? I'm trying to make a (vertical) SeekBar that gets it's progress according to the Y value of a touch event, on touch somewhere on the screen, so that if the touch is above the seekbar, it's progress is 100, if the touch is below the seekbar and otherwise the seekbar's thumb should be at the same line of the touch on screen.
How such thing could be done?
Example:

A: It may not be the best solution, but a simple one would be adding two empty views, one above and one below the SeekBar. You would be able then to detect the onClick on each view and change the SeekBar's progress manually.
Example:
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <View
        android:id="@+id/view_top"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.4"/>

    <SeekBar
        android:id="@+id/seek_bar"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:rotation="270"/>

    <View
        android:id="@+id/view_bottom"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.4"/>
</LinearLayout>

Java:
findViewById(R.id.view_top).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        mSeekBar.setProgress(YOUR_MAX_PROGRESS);
    }
});

findViewById(R.id.view_bottom).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        mSeekBar.setProgress(YOUR_MIN_PROGRESS);
    }
});

Edit: I'm currently missing the detection on the sides of the SeekBar


text:
Q: How to tell when execution is complete in node.js func1() calls func2() twice. func2() calls func3() a variable number of times (based on a parameter that is passed to it). As node.js is asynchronous, how can I tell when the last call to func3() has finished executing? Assume I do not know how many times func3() would be called.
This ought to be simple but is definitely out of my reach.
Thanks

A: Without async you may simply writes console.log('yep') or many others at end of code-block of func3(). If you want - write there you code for details of help.


text:
Q: SFML - How to get expected string width? How to get the expected sf::String's width when drawn on the window? Currently I only know how to get the sf::String's heigh, with the GetSize() method.
OBS: I'm using SFML v1.6 on Linux.

A: According to the doc, sf::String has a GetRect member function which returns a sf::Rect< float >, with a GetWidth() member.
float width = str.GetRect().GetWidth();

A: You could go through sf::Font::GetImage which returns the drawn glyphs of the font, and after you can use sf::Image::GetWidth.
Also, unless you have a very good reason to stay with 1.6, I would highly suggest you update to a more recent version. 1.6 is more than 7 years old. It is not supported and has a few bugs.