text:
Q: Creating a New Draft of a Journey Creating a New Draft of an interaction – Can the new draft of an interaction identify where the original(prior version) was stopped mid way and continue from there. I personally feel it's not possible however in case it is, how can we achieve this? The idea is not to repeat all the steps covered in the prior version and only cover the remaining journey hence excluding the customers all ready covered and targeting the remaining ones.

A: I deleted my previous answer. So this is how it behaves -
Let's say you deploy a journey and 100 contacts are injected into it. Now mid-way you decide to create a new draft.
In this case, those 100 people will stay in the previous version only and only the new ones will enter the newer version of the journey while those 100 will stay in the previous version till they exit the journey. Hope it helps.
You can read through the below documentation as well
Journey Builder Interaction Versions


text:
Q: The sum of consecutive integers is $50$. How many integers are there? I started off by calling the number of numbers in my list "$n$". Since the integers are consecutive, I had $x + (x+1) + (x+2)...$ and so on. And since there were "$n$" numbers in my list, the last integer had to be $(x+n)$. This is where I got stuck. I didn't know how to proceed because I am not given the starting point of my integers, nor an ending point.

A: $$\scriptsize\begin{align}
50
&=2\times 25
&&=25\boxed{+}25
&&=24.5\boxed{+}25.5 \text{ (AP but not integer AP)}\\
&=4\times 12.5
&&=12.5+12.5\boxed{+}12.5+12.5
&&=\color{red}{11+12\boxed{+}13+14}\\
&=5\times 10
&&=10+10+\boxed{10}+10+10
&&=\color{red}{8+9+\boxed{10}+11+12}\\
&=10\times 5
&&=\underbrace{\underbrace{5+5+\cdots+5}_{5}\boxed{+}\underbrace{5+5+\cdots +5}_{5} }_{10}
&&=\underbrace{\underbrace{0.5+1.5+\cdots+4.5}_{25}\boxed{+}\underbrace{5.5+\cdots+9.5}_{25}}_{50}\\
& && && \quad \text{(AP but not integer AP)}\\
&=20\times 2.5
&&=\underbrace{\underbrace{2.5+2.5+\cdots+2.5}_{10}\boxed{+}\underbrace{2.5+\cdots +2.5}_{10} }_{20}
&&=\color{red}{\underbrace{\underbrace{-7+(-6)+\cdots+2}_{10}\boxed{+}\underbrace{3+4+\cdots+12}_{10}}_{20}}\\
&=25\times 2
&&=\underbrace{\underbrace{2+2+\cdots+2}_{12}+\boxed{2}+\underbrace{2+\cdots +2}_{12} }_{25}
&&=\color{red}{\underbrace{\underbrace{-10+(-9)+\cdots+1}_{12}+\boxed{2}+\underbrace{3+\cdots+13+14}_{12}}_{25}}\\
&=50\times 1
&&=\underbrace{\underbrace{1+1+\cdots+1}_{25}\boxed{+}\underbrace{1+\cdots +1}_{25} }_{50}
&&=\underbrace{\underbrace{-23.5+(-22.5)+\cdots+0.5}_{25}\boxed{+}\underbrace{1.5+\cdots+25.5}_{25}}_{50}\\
& && && \quad \text{(AP but not integer AP)}\\
&=100\times 0.5
&&=\underbrace{0.5+0.5+\cdots+0.5}_{50}\boxed{+}\underbrace{0.5+0.5+\cdots+0.5}_{50}
&&=\color{red}{\underbrace{\underbrace{-49+(-48)+\cdots+0}_{50}\boxed{+}\underbrace{1+2+\cdots +49+50}_{50} }_{100}}
\end{align}$$

In more detail:
$$\frac {50}n=m$$
If $n$ is even $(n=2p)$, then we want $m=a+0.5 \;\;(a\in \mathbb Z)$ $\cdots$  Condition $(1)$

*

*The AP would comprise $p$ consecutive integers on either side of $m$.

If $n$ is odd $(n=2p+1)$, then we want $m\in \mathbb Z$ $\cdots$ Condition $(2)$

*

*The AP would comprise $p$ consecutive integers on either side of $m$, as well as $m$ itself.

Try different values of $n$ (excluding the trivial case  $n=1$):

*

*If $n=2$, then $m=25$, hence Condition ($1$) not satisfied.

*If $n=3$, then $m=16\frac 23$, hence  Condition ($2$) not satisfied.

*If $n=4$, then $m=12.5$, hence Condition $(1)$ satisfied,
so the AP is $\lbrace (m-1.5), (m-0.5), (m+0.5), (m+1.5)\rbrace$, i.e.
$\color{red}{11,12,13,14}$ ($AP1$).
Adding negative terms  and corresponding positive terms which cancel out gives:
$\color{blue}{-10,-9,-8\cdots, 0\cdots, 8,9,10,}\color{red}{11,12,13,14}$ ($AP 1'$)

*If $n=5$, then $m=10 $, hence Condition $(2)$ satisfied,
so the AP is $\lbrace (m-2),(m-1),m,(m+1),(m+2)\rbrace$, i.e. $\color{red}{ 8,9,10,11,12}$ ($AP 2$).
Adding negative terms  and corresponding positive terms which cancel out gives:
$\color{blue}{-7,-6,-5\cdots, 0\cdots, 5,6,7,}\color{red}{8,9,10,11,12}$ ($AP 2'$)

*If $n=6, 7,8,9$, then $m\notin\mathbb Z$ and $m\neq a+0.5 $, hence neither Conditions $(1)$ or $(2)$ satisfied.

*If $n=10$, then $m=5$, hence Condition $(2)$ not satisfied - not possible.

*If $n=11,12,\cdots, 24$, then $m\notin\mathbb Z$ and $m\neq a+0.5$, hence neither Conditions $(1)$ or $(2)$ satisfied.

*If $n=25$, then $m=2$, hence Condition $(2)$ satisfied, so AP is
$\color{red}{\underbrace{-10,-9,\cdots 0,1}_{12\text{ terms}},2,\underbrace{3,\cdots 9,10,11,12,13,14}_{12 \text{ terms}}}$  (same as $AP 1'$)

*If $n=26,27,\cdots, 49$, then $m\notin\mathbb Z$ and $m\neq a+0.5 $, hence neither Conditions $(1)$ or $(2)$ satisfied.

*If $n=100$, then $m=0.5$, hence Condition $(1)$ satisfied, so AP is
$\color{red}{\underbrace{-49,-48,\cdots -2,-1,0}_{50\text{ terms}},\underbrace{1,2,3,\cdots 48,49,50}_{50 \text{ terms}}}$ ($AP 3$)

*For higher values of $n$, $0<m<0.5$ - not possible.

A: Without reading other answers... this should tell you how an old computer programmer thinks, versus a real mathematician.
First the obvious answer is the single integer 50. However, if negative numbers are allowed, then we can scoop up the sequence from -49 to 50 for 100 consecutive numbers. This is the longest possible sequence.
If n is the starting number of a sequence and s is the number of consecutive numbers, then we end up with
50 = (n+0) + (n+1) + (n+2) +... + (n+s-1)
50 = ns + (s-1)(s)/2

This is helpful, maybe, as ns pretty much puts a box around the solution set. Since we know the nature of the rightmost term, we can tell that s is 10 or less.
Consider the transformation if we multiply both sides by 2/s:
100/s = 2n + s - 1

The right side will always be an integer. Therefore, s must always divide 100 evenly.  From above we know that s is between 1 and 10, so the only possible values for s are 1, 2, 4, 5, and 10.
That reduces the problem to 5 single-degree-of-freedom equations. Let's do it.
100/1 = 2n, n = 50, seq is (50)
100/2 = 2n + 1, no solution
100/4 = 2n + 4 - 1, 25-3 = 2n, n = 11, seq is (11, 12, 13, 14)
100/5 = 2n + 5 - 1, 20 = 2n + 4, 16=2n, n = 8, seq is (8, 9, 10, 11, 12)
100/10 = 2n + 10 - 1, 10 = 2n +9, 1 = 2n, no solution

So those are all the solutions where n and s both > 0.

A: If your $n$ is odd, then the middle number has to be $50/n$.  The odd divisors of $50$ are $1$ and $5$, which gives us two solutions $50=50$ and $8+9+10+11+12=50$
If $n$ is even, then $50/n$ is the half-integer between the middle two numbers.  So $n$ has to be an even divisor of $100$, but not a divisor of $50$, so $n=4$ or $20$.
If $n=4$, then $50/4 = 12.5$ and we get $11+12+13+14=50.$
If $n=20$. then $50/20 = 2.5$ and we get $-7+-6+-5+\cdots +11+12 = 50.$
So there are 4 answers: $n=1, 4, 5, $ and $20$.
Edit:  As Bill points out, I missed the divisors $25$ and $100$, which give two more answers:  $50 = -10+-11+\cdots+14$ and $50 = -49 +-48+\cdots +50$.
Note that each solution with negative integers is related to an all-positive solution.  From the solution $11+12+13+14=50$, we just prepend the terms $-10, -9, \ldots, 10$, which add to $0$, and we have another solution.

A: What may be helpful is to use the formula for the sum of an arithmetic progression: if you have a sequence whose first term is $a$ and each term is $d$ more than the rest, then the sum of the first $n$ terms is $na+\frac{n(n-1)}{2}d$. In this case, since we are looking at consecutive integers, $d=1$, and so you are trying to find $a$ and $n$ such that $na+\frac{n(n-1)}2=50$, or equivalently $n(2a+n-1)=100$.

A: Using the standard summation of an arithmetic progression formula:
$S_n=\frac{n(2a_1+(n-1)d)}{2}$
here since $d=1$
$2S_n=n(2a_1+n-1)$
$2S_n=n(a_1+(a_1+n-1))$
Here $a_1+n-1$ is just the last term.
$2S_n=n(a_1+a_n)$
Rewrite as
$n=\frac{2S_n}{a_1+a_n}$
If n is even:
$n=\frac{2S_n}{a_1+a_n+a_{n/2}-a_{n/2}}$
$n=\frac{2S_n}{2a_{n/2}}$ Since $a_1+a_{n/2}+a_n-a_{n/2}=2a_{n/2}$
hence $n=\frac{S_n}{a_{n/2}}$ and since $n\in Z$ , so $a_{n/2}$ is a divisor of $S_n$
once you get the required $n, a=a_{n/2}-n/2$
Similarly for odd $S_n$ you get $n=\frac{S_n}{a_{(n-1)/2}-1}$
where
$a_{(n-1)/2}-1$ is a divisior of $S_n$

A: The sum of consecutive numbers $1\dots n$ up to $n$ starting from 1 is $\frac{n(n+1)}{2}$. Since you want only a partial sum from, say, $m+1$ to $n$, you can just subtract to get the partial sum:
$$
\frac{n(n+1)}{2} - \frac{m(m+1)}{2} = \frac{n^2+n-m^2-m}{2} = 50
$$
Multiplying by 2 gets you
$$
100 = n^2+n-m^2-m = (n+m)(n-m) + n-m = (n+m+1)(n-m)
$$
Now the trick: $n+m$ and $n-m$ are either both even or both odd. This means that in the last formula, one term must be even, the other one must be odd. Factorization of $100 = 5\cdot 5 \cdot 2 \cdot 2$ means that there are very limited solutions. For instance, one term is 25, the other is 4 (there is one other nontrivial combination, see below). Since $n+m+1$ is larger than $n-m$, in the choice shown here, you must have
\begin{align}
n+m+1 &= 25\\
n-m &=4
\end{align}
Solving this will give you the desired numbers.
Addendum You get the combination by observing that you get all acceptable combinations of the factorisation via:
\begin{align}
100 &= 1\cdot (5\cdot5\cdot2\cdot2)\\
 &= 5\cdot (5\cdot2\cdot2)\\
 &= (5\cdot 5)\cdot(2\cdot2)
\end{align}
where you have to stop as all the following factorisations will contain only even factors.

A: Let tere be $n\geq1$ numbers, the smallest of them being $p\in{\mathbb Z}$. We then want
$$p+(p+1)+\ldots+\bigl(p+(n-1)\bigr)=50\ ,$$
which amounts to $np+{(n-1)n\over2}=50$, or
$$n(n+2p-1)=100\ .$$
Going with $n$ through the $9$ divisors of $100$ we obtain the following table:
$$\matrix{n:&1&2&4&5&10&20&25&50&100 \cr
p:&50&&11&8&&-7&-10&&-49\cr}$$
When $n\in\{2,10,50\}$ solving $n+2p-1={100\over n}$ for $p$ does not lead to an integer $p$. It follows that there are $6$ solutions in all.

A: First, welcome to Mathematics stack exchange. Second, if you start like $x+(x+1)+...+(x+n)$, you will end nowhere. $50$ is a concrete and small number so what can you try is to use that fact, sum of two consecutive numbers it is not, due to sum of two consecutive numbers can not be divided with $2$ in $\mathbb{Z}$, sum of three consecutive numbers is divisible with $3$, so it is not sum of three numbers. Four consecutive numbers- now this is on first look possible(remainder mod $4$ is $2$) but each one of them has to be around $12$, so first options that you have is $11+12+13+14=23+27= 50$, hence the solution. Maybe there are even other solution, but I feel free to interpret your question as required to see one possible solution.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Starting a service that start an activity on device boot im trying to start an application on device boot.
my code is as follow
1- firstly the main class which contain a background thread (asynctask) that send data to a mysql database.
2- Service class
package com.seven.ex.helper;

import com.seven.ex.AndroidGPSTrackingActivity;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class service extends Service {
private static final String TAG = "MyService";
@Override
public IBinder onBind(Intent intent) {
    return null;
}
public void onDestroy() {
    Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG).show();
    Log.d(TAG, "onDestroy");
}

@Override
public void onStart(Intent intent, int startid)
{
    Intent intents = new Intent(getBaseContext(),AndroidGPSTrackingActivity.class);
    intents.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intents);
    Toast.makeText(this, "My Service Started", Toast.LENGTH_LONG).show();
    Log.d(TAG, "onStart");
}
}

3- BootUpReceiver class
package com.seven.ex.helper;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class BootUpReceiver extends BroadcastReceiver{

@Override
public void onReceive(Context arg0, Intent arg1) {
    Intent intent = new Intent(arg0,service.class);
    arg0.startService(intent);
    Log.i("Autostart", "started");
}

}

4- the android manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gpstracking"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

   <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name="com.seven.gpstracking.AndroidGPSTrackingActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service android:name=".service"
              android:label="@string/app_name"
              >
    </service>

    <receiver android:enabled="true" android:name=".BootUpReceiver">

    <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
   </receiver>

    </application>

   </manifest>

The main method is working correctly before i tried to start it on boot.
Also the app still working after i ignore the android error on boot (The App Closed)
in the log cat am getting a class not found  exception
can you please help ?

A: Your Service won't work like it is at the moment. You will have to move the stuff from onStart() to onStartCommand() and then return whether the service is sticky or not. The problem is that the onStart()-method has a good chance of not getting called at all (as it is deprectaed by now).
@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {

        //do your stuff here

    return Service.START_NOT_STICKY;
}

A: In your manifest you have assigned package: com.example.gpstracking. When u then define .BootUpReceiver. The system should expect to locate the class at com.example.gpstracking.BootUpReceiver.
Please try and change the package .BootUpReceiver to the full path com.seven.ex.helper.BootUpReceiver. The same goes for AndroidGPSTrackingActivity as this should be com.seven.ex.AndroidGPSTrackingActivity as far as I can tell.


text:
Q: SilverStripe 4 GraphQL and GraphiQL UI not working even the procedures were followed properly from the documentation I'm using SilverStripe 4 and applied a plug-in using composer require silverstripe/graphql.
After following the instructions from the document of silverstripe/graphql from this source https://github.com/silverstripe/silverstripe-graphql, I can't seem to access the GraphiQL of the GraphQL through this url localhost/silverstripe/dev/graphiql (silverstripe is the name of my folder in htdocs, graphiql is the UI counter part that will help me to perform queries for GraphQL)
GraphQL sample output:

Using Postman:

GraphiQL sample output:

My namepace is SS\GraphQL

Also applied this into my routes.yml file:

I have these inside a GraphQL folder inside the _config

membertypecreator.yml:

readmemberquerycreator.yml:

Am I doing something wrong here? I was able to reproduce the steps and codes from the documentation
Kindly requesting for your help please...

A: OK FINALLY, was able to answer my query, by installing composer require --dev silverstripe/graphql-devtools, I was able to go to localhost/silverstripe/dev/graphiql and was able to open this UI:


text:
Q: Convert date field to mm/dd/yy format in visual foxpro I have a date value mm/dd/yyyy format in visual FoxPro. while fetching I want to convert it to mm/dd/yy.
Want to know how we can achive this.

A: Your question is not clear. A date field is always stored as a 'date' regardless of the display format. What you are saying is a display format. You can achieve it in multiple ways. ie:
set century off  && default
set date MDY

or:
set century off
set date AMERICAN && default

If what you meant is just to use 2 digits for century actually it is the default, if changed in your config.fpw then simply use:
set century off

Note: Both "set century" and "set date" are scoped to current data session.


text:
Q: Deploying Meteor on a CDN or S3 Is there a way to get the static assets generated by a Meteor app deployed on a CDN - or a static hosting solution like S3 - in order to improve loading speed and reduce hosting costs ?

A: CloudFront
I've detailed how we accomplished this at Edthena in this post. The TLDR is:
Add this line somewhere in your server code:
WebAppInternals.setBundledJsCssPrefix(CDN_URL);

Where CDN_URL is your CloudFront URL (e.g. https://a27n0s89ik4xb3.cloudfront.net).
We kept the defaults when creating the CloudFront distribution except for the following:
Origin Domain Name: myapp.example.com
Origin ID: myapp.example.com
Viewer Protocol Policy: HTTPS Only
Compress Objects Automatically: yes

If you serve your own fonts, you can end up with cross origin errors (unless you use a font data URL). Josh Owens describes how to deal with that in his post.
CloudFlare
Have a look at Cloudflare Meets Meteor on the meteorhacks blog. If you happen to be a CloudFlare user, it's a pretty easy solution but you'll need to disable WebSockets (or pay a lot, or use a complex workaround).

A: If you are using meteorite, you can use this package: https://github.com/nate-strauser/meteor-aws-sdk

A: If deploying through demeteorizer, it is pretty easy to upload the content of the static_cacheable to a CDN and change the links in app.html and app.json.
That process can probably be automated in a custom deploy/capistrano script.


text:
Q: imagecreatefromjpeg not giving me a resource? I am trying to code a script for file resizing.In the script, I use getimagesize() to get the mime information from the image and then test it's value using a switch statement, assigning different values to variables in different cases.
However after running the script, I'm getting the error
PHP Warning:  imagecopyresampled() expects parameter 2 to be resource, string given in ..........

Why exactly am I getting this error when all I'm doing is passing it the variable from createimagefromjpeg?
My Code extract:
list($width,$height,$type)=getimagesize($_FILES["BusinessCreateFileUpload"]["tmp_name"]);
        //checks the mime type and gets the extension
        //Declares the $uploadedfile,$src and $ext variables.
        $uploadedfile='';
        $src='';
        $ext='';
        switch($type)
        {
            case"image/jpeg":
                $uploadedfile=$_FILES["BusinessCreateFileUpload"]["tmp_name"];
                $src=imagecreatefromjpeg($uploadedfile);
                $ext=".jpg";
                break;
            case"image/png":
                $uploadedfile=$_FILES["BusinessCreateFileUpload"]["tmp_name"];
                $src=imagecreatefrompng($uploadedfile);
                $ext=".png";
                break;
            default:
                echo"An error has occurred.Please follow the link to try again";
        }
        //Creates thumbnail
        $newwidth=100;
        $newheight=100;
        $thumbimg=imagecreatetruecolor($newwidth, $newheight);
        imagecopyresampled($thumbimg,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
        //Creates displayimage
        $newwidth1=250;
        $newheight1=250;
        $displayimg=imagecreatetruecolor($newwidth1, $newheight1);
        imagecopyresampled($displayimg,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);

I'm editing bits and pieces of a script I found on the internet as I'm still rather new to programming so I might have inadvertently screwed something up, though I can't seem to figure out where exactly did I go wrong.

A: Your code sets a default value of $src to an empty string. The following lines are then accessing this empty string of $src, which is why it is giving the error:
imagecopyresampled($thumbimg,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagecopyresampled($displayimg,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);

As per your code, this would occur when the switch case for $type is assuming a default value, and therefore your code must be outputting the following line as well:

An error has occurred.Please follow the link to try again

Regarding OP's comment (the answer seemed long, so including it here):

*

*First, make your script use die instead of echo in your default case of the switch statement. So, if the value of $type is not as desired, then the script will give an error and stop.

*Secondly, the function getimagesize returns mimetype as an INT value, which is what your variable $type will be set as. Instead, you are comparing your $type variable to strings which is wrong, and would always make use of the default case. Therefore, change your switch statement and compare the values to INT values.

*Also, make sure your case statements and echo statements have a space after keywords, i.e. after case and echo

Considering the above, you can replace your switch statement with this:
$src = 0;
switch($type)
    {
        case 2:
            $uploadedfile=$_FILES["BusinessCreateFileUpload"]["tmp_name"];
            $src=imagecreatefromjpeg($uploadedfile);
            $ext=".jpg";
            break;
        case 3:
            $uploadedfile=$_FILES["BusinessCreateFileUpload"]["tmp_name"];
            $src=imagecreatefrompng($uploadedfile);
            $ext=".png";
            break;
        default:
            die "An error has occurred.Please follow the link to try again";
    }

A: The getimagesize function returns in 3th parameter the type using a int value, not a string mimetype.
Check the docs in php.net.

1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel
  byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 =
  JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM

var_dump the $type variable.


text:
Q: form_for without module and namespace I have a model named MongoidContainer::Contact. I have a controller called ContactsController. Only the model is namedspaced inside the MongoidContainer module. When I use form_for, like this:
<%= form_for @contact %>

It raises an exception:
undefined method `mongoid_container_contacts_path' for #<#<Class:0x007f99823f41e8>:0x007f9989d918c0>

But I want it to point to contacts_path, not mongoid_container_contacts_path.
Furthermore, the name attributes look like mongoid_container_contact[name] instead of contact[name].
Is there a way to pass the demodulized object into form_for?

A: you can specify the path you want:
form_for @contact, url: contacts_path


text:
Q: Ajax action has 200 status but response of No response data available for this request I'm developing a custom plugin that implements an ajax-powered search form on a WordPress site. It runs a WordPress query and outputs the results just below the search box where a user types their search string. Locally in my development environment, the plugin works fine. But when I install it on my production server it does not work. According to the Chrome dev tools, the XHR action for my form submission is returning 200 status but the response says No response data available for this request. The ajax error does not get logged to the console so the request isn't failing.
I have no direct access to the server so I can't change or check those settings, I'm assuming it's something blocking the action from running? I had requested the server administrators to check for any issues with my action running on their server and they said they had resolved this but I'm still having the issue.
This is my code:
add_action('wp_ajax_data_fetch' , 'data_fetch');
add_action('wp_ajax_nopriv_data_fetch','data_fetch');

function data_fetch(){
    $max_posts = -1;
    $the_query = new WP_Query( array( 'posts_per_page' => $max_posts, 's' => esc_attr( $_POST['keyword'] ), 'post_type' => 'rrm_safety', 'orderby' => 'title', 'order' => 'ASC' ));

    if( $the_query->have_posts() ) :
        $results = "";

        foreach($the_query->posts as $result)
        {
            $results.= '
ID).'">'.$result->post_title.'
';
        }
        print $results;
    else:
        print '
No results
';
    endif;

    die();
}

add_action( 'wp_footer', 'ajax_fetch' );
function ajax_fetch() {
?>


text:
Q: Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile-custom protoc did not exit cleanly I've been struggling with the following error.
[ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile-custom (compile) on project grpc: protoc did not exit cleanly. Review output for more information. -> [Help 1]

I have a parent pom where I have defined plugin under pluginManagement tag. In child pom I am using the plugin defined in parent pom. Here is how my pom file looks like.
Parent pom:
<pluginManagement>
             <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.6.1</version>
             </plugin>
</pluginManagement>

Child pom:
    </plugins>
         <plugin>
            <groupId>org.xolstice.maven.plugins</groupId>
            <artifactId>protobuf-maven-plugin</artifactId>
            <configuration>
                    <protocArtifact>
                        com.google.protobuf:protoc:3.14.0:exe:${os.detected.classifier}
                    </protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:${protoc.version}:exe:${os.detected.classifier}
                    </pluginArtifact>
                    <protocPlugins>
                        <protocPlugin>
                            <id>vertx-grpc-protoc-plugin</id>
                            <groupId>io.vertx</groupId>
                            <artifactId>vertx-grpc-protoc-plugin</artifactId>
                            <version>4.2.3</version>
                            <mainClass>io.vertx.grpc.protoc.plugin.VertxGrpcGenerator</mainClass>
                        </protocPlugin>
                    </protocPlugins>
                </configuration>
                <executions>
                    <execution>
                        <id>compile</id>
                        <configuration>
                            <outputDirectory>${protobuf.output.directory}</outputDirectory>
                            <clearOutputDirectory>false</clearOutputDirectory>
                        </configuration>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <goals>
                            <goal>test-compile</goal>
                            <goal>test-compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
        </plugin>
    </plugins>


text:
Q: How to create a VM instance from an instance template within Cloud Functions? I need to start a Google Compute instance based off a template I've made which has a startup script which downloads the latest game-server executable from my server and runs it. This all works perfectly fine.
Now, my custom built matchmaker will determine if all current games (which are instances of the game server) are full, and if so I want it to run a Cloud Function that creates another new instance from the template I've mentioned above (which basically acts lobby/game for 12 players). Once the instance is created I need the cloud function to return the IP of the newly created instance back to whatever called it (which would be my game).
I know the first part is possible via HTTP POST but I cannot find anywhere in the cloud functions docs/compute docs/admin SDK docs that allows me to create instances and get the IP, is this possible?
EDIT: I have found this documentation but I have not yet found a function to start a VM from a template which then returns the VM's object - which includes it's IP...

A: You can use directly the APIs. First create the VM, then wait the running state to get the internal and external IP
async function main() {
    const auth = new GoogleAuth({
        scopes: 'https://www.googleapis.com/auth/cloud-platform'
    });
    const client = await auth.getClient();

    const url = `https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/europe-west1-b/instances`
    const template= 'projects/PROJECT_ID/global/instanceTemplates/instance-template-1';

    const instanceName = 'example-instance'
    const body= '{ "name": "' + instanceName + '" }'

    let res = await client.request({ url: url + "?sourceInstanceTemplate=" + template,
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: body
    });
    res = await client.request({ url: url + "/" + instanceName,
        method: 'GET'});

    while (res.data['status'] != 'RUNNING') {
        setTimeout(function(){},1000)
        res = await client.request({ url: url + "/" + instanceName,
            method: 'GET'});
    }
    //Internal Ip (interface0)
    console.log(res.data.networkInterfaces[0].networkIP);
    //External Ip
    console.log(res.data.networkInterfaces[0].accessConfigs[0].natIP);

}
main().catch(console.error);

My NodeJs skill is low (style, format, idioms,...), but this works.


text:
Q: Undefined Variable using Yii2 and SQL I'm trying to do a simple application in Yii. I'm trying to show only a type of query that has a boolean value in it. There's my function:
public function actionScelta($basket=0, $bowling=0, $calcio=0, $pingpong=0, $corsa=0, $tennis=0, $carte=0, $cricket=0) {
    $scelta=[];

    if($basket == 1)
    {
    $scelta=Partite::find()->where(['Basket' => 1])->all();
    }

    if($bowling == 1)
    {
    $scelta=Partite::find()->where(['Bowling' => 1])->all();
    }

    if($calcio == 1)
    {
    $scelta=Partite::find()->where(['Calcio' => 1])->all();
    }

    if($pingpong == 1)
    {
    $scelta=Partite::find()->where(['PingPong' => 1])->all();
    }

    if($corsa == 1)
    {
    $scelta=Partite::find()->where(['Corsa' => 1])->all();
    }

    if($tennis == 1)
    {
    $scelta=Partite::find()->where(['Tennis' => 1])->all();
    }

    if($carte == 1)
    {
    $scelta=Partite::find()->where(['Carte' => 1])->all();
    }

    if($cricket == 1)
    {
    $scelta=Partite::find()->where(['Cricket' => 1])->all();
    }

    return $this->render('scelta',['Basket' => $basket,'Bowling' => $bowling, 'Calcio' => $calcio,'PingPong' => $pingpong,'Corsa' => $corsa,'Tennis' => $tennis,'Carte' => $carte,'Cricket' => $cricket,'scelta' => $scelta]);

}

And there is my view:
<?php if ($basket == 1){ ?>
    <p> <?php echo $scelta->Partita; ?>
<?php } ?>

It says "$basket" is an undefined variable. Why?


text:
Q: Check_box_tag input id I have a check_box_tag that looks like this :
check_box_tag('shipping_method[shipping_categories][]', category.id,
@shipping_method.shipping_categories.include?(category))

When inspecting the output in browser, I have the following :
<input id="shipping_method_shipping_categories_"
name="shipping_method[shipping_categories][]" type="checkbox" value="1" />

I don't get why the id has no "id", meaning that the underscore at the end of
id="shipping_method_shipping_categories_"

makes me expect an id for this particular shipping_category.
Any of you guys and gals have thoughts on this ?
Thanks !

A:
I don't get why the id has no "id", meaning that the underscore at the
  end of id="shipping_method_shipping_categories_" makes me expect an id
  for this particular shipping_category.

That is the default behavior of the check_box_tag. In other words it is constructed that way. When you look upon the code of how it is constructed, you will see the below
# File actionview/lib/action_view/helpers/form_tag_helper.rb, line 374
def check_box_tag(name, value = "1", checked = false, options = {})
  html_options = { "type" => "checkbox", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys)
  html_options["checked"] = "checked" if checked
  tag :input, html_options
end

So, the "id" is constructed with the method sanitize_to_id(name). So I've further looked upon sanitize_to_id(name) to see its code and I've found this
def sanitize_to_id(name)
  name.to_s.delete("]").tr("^-a-zA-Z0-9:.", "_")
end

So, shipping_method[shipping_categories][].to_s.delete("]").tr("^-a-zA-Z0-9:.", "_") returns shipping_method_shipping_categories_. That explains its behavior.
If you want to achieve what you are expecting, I recommend you to go with collection_check_boxes
For example,
collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial)

returns
<input id="post_author_ids_1" name="post[author_ids][]" type="checkbox" value="1" checked="checked" />


text:
Q: How does the require function takes parameter in Node.js with Socket.io I do not understand what does (http) means here in the following javascript code. If its a method it should have been called after a dot. But its not. So what exactly is it?
var io = require('socket.io')(http)

A: It's a function call.
require('socket.io') returns a function. The function is then called with parameter http.
Maybe this makes it clearer, it's the same thing but with an extra variable assignment:
var factoryFunction = require('socket.io')
var io = factoryFunction(http)


text:
Q: X-AppEngine-Country removed from Google App Engine HTTP Headers The last version of AppEngine removed some usefull headers like X-APPENGINE-COUNTRY, X-APPENGINE-REGION, X-APPENGINE-CITY and X-APPENGINE-CITYLATLONG.
I liked this headers because it was an easy/free way to approximately geolocalize users. Is there an alternative or other headers to keep this simplicity ?
Thank you.

A: The documentation has been updated and these headers are not planned to be removed anymore:

Removed headers
Headers that match the following pattern are removed from the request:
X-Google-* In addition, some selected headers that match the following
  pattern are removed from the request:
X-Appengine-* Added headers
App Engine adds the following headers to all requests:
Via: "1.1 google"

*

*X-AppEngine-Country [...]

*X-AppEngine-Region [...]

*X-AppEngine-City [...]

*X-AppEngine-CityLatLong [...]

*X-Cloud-Trace-Context [...]

*X-Forwarded-For: [...]

*X-Forwarded-Proto [...]

A: As far as I know the headers are still there according to the Nov 16 update.
https://cloud.google.com/appengine/docs/go/how-requests-are-handled
Some standards were deprecated in order to apply the ISO standard.

A: Currently, the X-AppEngine-(Country|City|CityLatLong|Region) headers are not available in the flexible environment.
To clarify Nilo_DS's response, the headers are still available in the Standard environment, https://cloud.google.com/appengine/docs/python/how-requests-are-handled#app-engine-specific-headers.

A: https://cloud.google.com/appengine/docs/flexible/python/reference/request-headers
The docs suggest the headers can be used in flex.
I have tested a nodejs flex service and got information back for:
"x-appengine-country": "GB",
"x-appengine-region": "eng",
"x-appengine-city": "blank for security",
"x-appengine-citylatlong": "blank for security"


text:
Q: Creating a weighted undirected graph in "igraph" in C/C++ Problem:
I want to make a weighted undirected graph from adjacency matrix stored in a .csv file using igraph and then do the minimum spanning tree and some other algorithms on it.
I started with making a directed graph with 10 vertices and 5 edges. By default igraph does not allow weights for edges and you have to use some attributes which does not make sense to me (something like igraph_i_set_attribute_table) in the documentation.
Can someone please help me regarding this.
void print_vector(igraph_vector_t *v, FILE *f) {
  long int i;
  for (i=0; i<igraph_vector_size(v); i++) {
    fprintf(f, " %li", (long int) VECTOR(*v)[i]);
  }
  fprintf(f, "\n");
}

int main(int argc, char* argv[])
{
  igraph_t g;
  igraph_vector_t v;
  int ret;
  igraph_es_t es;

  /* Initialize the vector for edges */
  igraph_vector_init(&v,10);

  VECTOR(v)[0]=0;VECTOR(v)[1]=1;
  VECTOR(v)[2]=1;VECTOR(v)[3]=3;
  VECTOR(v)[4]=1;VECTOR(v)[5]=5;
  VECTOR(v)[6]=2;VECTOR(v)[7]=3;
  VECTOR(v)[8]=2;VECTOR(v)[9]=5;

  igraph_create(&g,&v,0,IGRAPH_DIRECTED);

  print_vector(&v,stdout);

  /* igraph_i_set_attribute_table(&igraph_cattribute_table); */

  igraph_vector_destroy(&v);
  igraph_destroy(&g);

  return 0;
}

A: First of all, in general you are much better off using igraph from R or Python, attributes are much-much better supported. For example you can easily select vertices or edges based on attribute values, etc. In C, the support for attributes is minimal, and you are mostly on your own, when it comes to working with them. So, unless you really need C, I would suggest to use R or Python.
If you still want C, then the first thing to keep in mind is that you need to include
igraph_i_set_attribute_table(&igraph_cattribute_table);

in your code before you do anything with attribute explicitly or implicitly. Ie. even if you don't manipulate attributes explicitly, but create a graph that might have some attributes, eg. read a graph a GraphML file, you need this call before, otherwise the attributes are dropped. It is best to include the call at the beginning of your main() function.
It is not true that you have to use any attributes, I am not sure what you mean by that.
As for setting and querying the attributes, see the files in the examples/simple directory:
https://github.com/igraph/igraph/blob/master/examples/simple/cattributes.c
https://github.com/igraph/igraph/blob/master/examples/simple/cattributes2.c
https://github.com/igraph/igraph/blob/master/examples/simple/cattributes3.c
https://github.com/igraph/igraph/blob/master/examples/simple/cattributes4.c
These examples are largely artificial, because they are mainly used for testing purposes, but they show the basic usage.


text:
Q: What is change point analysis for At Most One Change(AMOC)? Can any one explain me how can I choose the pen.value and penalty for the single change point detection i.e., for At Most One Change (AMOC). Is there any books that contains rich explanation of these parameters?. I'm not able to figure out when exactly to use what. It would be helpful if you explain it with an example. what is the diff between the cpt.mean, cpt.var, cpt.meanvar(same confusion when to use what?). I'm getting diff diff change points and in that how can I found the most desirable one?. Help me out of these
Thanks in advance

A: It appears as though you are using the changepoint package in R from the function names mentioned and the AMOC definition.
If this is correct then the help files for the package give references:
 ?cpt.mean

gives the following references:
 Change in Normal mean: Hinkley, D. V. (1970) Inference About the Change-Point
 in a Sequence of Random Variables, Biometrika 57, 1–17
 CUSUM Test: M. Csorgo, L. Horvath (1997) Limit Theorems in Change-Point Analysis, Wiley

I acknowledge that it isn't 100% clear that AMOC should use these references.  If you have test.stat="Normal" which is the default then the first Hinkley reference is the one you want.  If you use test.stat="CUSUM" then you want the second reference.
The majority of changepoint techniques start with AMOC or a single changepoint.  The changepoint package was designed more for multiple changes but allows single changes using AMOC.
The above covers the reference part of your question.  For the "what pen.value option should I use" that is like asking "who is the best guitarist?", the answer depends on personal experience.
For AMOC you have the option of using asymptotic penalty values, for example, if you want to be 95% confident that a changepoint has occurred then you would use penalty="Asymptotic", pen.value=0.05.  If you are happy with any of the other penalty choices i.e. MBIC (default), BIC, SIC, AIC, Hannan-Quinn then you don't need to specify pen.value as it is taken care of by setting the penalty to be one of the options, e.g. cpt.mean(data,penalty='SIC') would be valid if you wanted to use the SIC penalty.
If you don't like any of the options then you can set your own penalty but you have to select a value that works for your problem - sadly it is still an open research question as to which penalty is best.
Finally, you will get different answers when using the different cpt.mean, cpt.var, cpt.meanvar functions as they are doing different things.  cpt.mean looks for a change in the mean value only, assuming a constant variance. cpt.var looks for a change in the variance only, assuming a constant mean. cpt.meanvar looks for a change in both the mean and variance.
If you haven't read the paper associated to the package then I suggest you read it as it gives several examples demonstrating how to change the penalties and also how to use the 3 different functions.
URL to paper


text:
Q: Export from DataGridView to Excel & border around data How could I create a border around exported data in Excel? I export the data like this:
For i = 0 To ds1.Tables(0).Rows.Count - 1
    For j = 1 To ds1.Tables(0).Columns.Count - 1
        xlWorkSheet.Cells(i + 1, j) = ds1.Tables(0).Rows(i).Item(j)
    Next
Next

A: You create borders by setting xlWorksheet.Range.Borders.LineStyle equal to one of the Excel.XlLineStyle enums like this:
xlWorksheet.Range("A1:B2").Borders.LineStyle = Excel.XlLineStyle.xlContinuous

Borders.Linestyle will set the border for all sides of the cell by default. If you want to do only one side of the sell, you just add a borders enum argument to Borders like this:
xlWorksheet.Range("A1:B2").Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlLineStyle.xlContinuous

Visual studio's intellisense will show you the different options for the xlBordersIndexes and XlLineStyles once you start typing

EDIT: To highlight what you just exported, use the row and column count to define the range:

xlWorksheet.Range(xlWorksheet.Cells(1, 1), xlWorksheet.Cells(ds1.Tables(0).Rows.Count, ds1.Tables(0).Columns.Count)).Borders.LineStyle = Excel.XlLineStyle.xlContinuous

Note that the code above is just an example for the first dataset you export, for the rest, you will have to modify the line slightly. The range start cell would have to be set to wherever you're beginning to export the second dataset to instead of just cell(r1,c1). And the end cell of the range would be cell([startrow + ds.rows.count],[startcol + ds.columns.count])...something like this:
Dim startrow As Integer = 50
Dim startcol As Integer = 1
xlWorksheet.Range(xlWorksheet.Cells(startrow, startcol), xlWorksheet.Cells(startrow + ds1.Tables(0).Rows.Count, startcol + ds1.Tables(0).Columns.Count)).Borders.LineStyle = Excel.XlLineStyle.xlContinuous


text:
Q: Viewcell binding context is not working in xamarin forms I have a listview and many viewcells. The Itemstemplate are selected by using MessageTemplateSelector class. In MainViewModel there is a Messages collection. I have bind the Message collection into the listview. It's working fine. But the viewcell UI element is binded with viewmodel property named as ShowSenderIcon, that is not binded into the UI element. I have tried many suggestion. But it is not working. My sample code is mentioned below, Please refer, My requirement is i want to hide the Frame by using viewmodel (ShowSenderIcon) property.
I have tried this,
MainPage.xaml
<sync:SfListView
  x:Name="ListView"
  Grid.Row="0"
  Margin="0"
  AutoFitMode="Height"
  IsBusy="True"
  ItemSize="100"
  ItemSpacing="10"
  ItemTemplate="{StaticResource MessageTemplateSelector}"
  ItemsSource="{Binding Messages}"
  SelectionMode="None"
  VerticalOptions="Start"/>

IncomingViewCell.cs
<Frame
  x:Name="avatorFrame"
  CornerRadius="25"
  HasShadow="false"
  IsVisible="{Binding Path=BindingContext.ShowSenderIcon, Source={x:Reference ListView}, Mode=TwoWay}"
  OutlineColor="Gray"/>

MainPageViewModel.cs
private bool showSenderIcon = false;
public bool ShowSenderIcon
{
   get { return showSenderIcon; }
   set { showSenderIcon = value; OnPropertyChanged("ShowSenderIcon"); }
}

private ObservableCollection<Message> messagesList;
public ObservableCollection<Message> Messages
{
   get { return messagesList; }
   set { messagesList = value; }
}

public MainPageViewModel()
{
   Messages = new ObservableCollection<Message>();
   Messages.Add(new Message { Text = "Hi", IsIncoming = true, MessagDateTime = DateTime.Now, ShowTimeStamp = false });
}


text:
Q: Selecting Directory via Explorer on Console Application I have a pretty simple question, i'm running a peer2peer service via a Console Application, I was wondering if I could simply open Windows Explorer, select the folder for my directory of Host Files and open another Windows Explorer and select another folder for Receiving Files.
Is this possible, keep in mind I don't think I am able to use STAThread because the peers are inherently multithreaded.
Right now, i'm using
Process.Start(@hostDirectory);

to simply browse where I am, but I want to make it easier on the user via Windows explorer.


text:
Q: Why does `ofstream` miss some lines when writing to file? I have generated a bunch of UTF-16LE strings (3.8k+, \n-terminated) to write to a text file, still in UTF16. Somehow a part of these strings (~1.7k) are missing in the final file. The bug is not random, and the missing part is fixed no matter how I try to code the writing part.
Here is the code I used (slightly paraphrased):
inline std::u16string str_u8_to_u16(const std::string & u8_str){
  return std::wstring_convert<
    std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(u8_str);
}

std::ofstream fout("output.txt", std::ios::trunc);
extern std::vector<std::pair<char16_t, std::size_t> > str_vec;

for (auto itr = str_vec.cbegin(); itr != str_vec.cend(); ++itr) {
  std::u16string line_to_write = std::u16string(1, itr->first) + u"\t"
                               + str_u8_to_u16(std::to_string(itr->second)) + u"\n";
                               // because the second term can be greater than 9
  // byte-by-byte write
  fout.write(reinterpret_cast<const char*>(line_to_write.c_str()),
             line_to_write.size() * 2);

  fout.flush();
}

I suppose inserting flush() into the loop would solve the problem, but no, the bug persists. I haven't tried wchar_t because I want to save memory, and I suppose these two shouldn't conflict.
I'm actually not sure whether I'm asking the right question, but I'm guessing it has something to do with my usage of ofstream and char16_t.
I even tried this:
for (auto itr = str_vec.cbegin(); itr != str_vec.cend(); ++itr) {
  std::u16string line_to_write = std::u16string(1, itr->first) + u"\t"
                               + str_u8_to_u16(std::to_string(itr->second)) + u"\n";
  auto end_before_write = fout.tellp();
  fout.write(reinterpret_cast<const char*>(line_to_write.c_str()),
             line_to_write.size() * 2);
  auto end_after_write = fout.tellp();
  std::cerr << std::dec << "end_before_write = " << end_before_write
            << ", end_after_write = " << end_after_write
            << ", diff = " << end_after_write - end_before_write << std::endl;
  fout.flush();
}

And the result is even more confusing: the difference of two tellp()s is never zero and actually looks perfectly normal. So where do the contents go? They can't just disappear into oblivion.
In case that matters, I'm on macOS 10.14.5 using gcc version 9.1.0 (Homebrew GCC 9.1.0).


text:
Q: How to choose the proper drawables depending on device I have been working on few Android apps, but I still don't get the drawable folders. My apps always use only one of the 4 drawables for all sizes in stead of using the appropriate one.
For my current project, I created images that I scaled to 92x92, 72x72, 48x48 and 32x32
how can I tell my app to choose from these depending on the device that is used?
Please guide me to any articles or tutorials that u have found helpful. Thanks

A: You cannot always trust what Eclipse and an AVD will use for drawables, especially for newer XXHDPI devices.  See my post here: Drawable-xxxx : Eclipse Versus AVD.
The folder used by Eclipse (in design view) and what an AVD uses is NOT the same as a real device will use.  However, the result will look the same.  So, they may choose images in the XHDPI folder, whereas a real device will use the XXHDPI folder, but they try to emulate the display as close as possible.  So, what you see in an AVD looks almost the same as a real device.  So, an AVD I created to emulate an LG G2 looks very close to what my real LG G2 looks like, even though they are using different folders.
The bottom line is that the way a real device selects what folder to use and the algorithms used to scale it are not the same that our development and testing tools use.
I have only used Eclipse/ADT though.  Maybe Android Studio is different?


text:
Q: Rails conditional order by priority and status I want to order my Order model by priority, so that the ones with priority: true and with status != 'delivered' are on top. The ones with priority: true and status: delivered should be in the table below with all other orders sorted by updated_at.
In the end it should be sorted like this:
ID     PRIORITY     STATUS          UPDATED_AT
5      true         ready           1 min ago
8      true         in_transport    5 min ago

13     false        ready           less than a min ago
1      true         delivered       3 min ago
2      false        delivered       15 min ago
4      true         delivered       16 min ago
10     false        in_transport    20 min ago

I managed to achieve this partially with:
orders = Order.where(...)
sql = "(CASE WHEN (priority = true AND status = 'delivered') THEN 1 ELSE 0 END), priority desc"

orders.order(sql)

With this query the priority ones which are delivered are pushed to the end of the list and which I don't want:
ID     PRIORITY     STATUS          UPDATED_AT
5      true         ready           1 min ago
8      true         in_transport    5 min ago

13     false        ready           less than a min ago
2      false        delivered       15 min ago
10     false        in_transport    20 min ago
...
1      true         delivered       3 min ago
4      true         delivered       16 min ago

I would appriciate any guidelines here.

A: A possible approach is to use two separate queries and combine them.
Something like (not tested):
orders = Order.where(...)

priority_orders = orders.where(priority: true).where.not(status: 'delivered')
other_orders = orders.where.not(id: priority_orders.ids)

result =
  priority_orders.order(updated_at: :desc) +
  other_orders.order(priority: :desc, status: :asc, updated_at: :desc)

A: One approach would be using multiple order clause.
sql = "(CASE WHEN (priority = true AND status = 'delivered') THEN 1 ELSE 0 END), priority desc"

update the above to:
orders.order("CASE WHEN (priority = true AND status != 'delivered') THEN 0 ELSE 1 END, updated_at desc")

The query is self explanatory but let me know if you need any detail.


text:
Q: How to get value of selected option of yii2 select2 widget I am trying to get the value of selected option within same page.
I am using select2 widget.
<?php
echo '<label class="control-label">Group</label>';
$data = ['1' => 'option1', '2' => 'option2'];
echo Select2::widget([
    'name'=> 'group',
    'data' => $data,
    'options' => ['placeholder' => 'Select a option...', 'id' => 'sem'],
    'pluginOptions' => [
        'allowClear' => true
    ],
]);
?>
<input type="text" id='items' value="<?=$selectedvalue?> />'

Here I want get that selected value within that page in input box.
<input type="text" id='items' value="<?=$selectedvalue?> />

I am using Yii2 I am new on it.
can anyone help me?

A: You can get the selected value with jQuery with:
$("#id_of_your_select2_widget").on("change", function (e) {
    var id = $("#id_of_your_select2_widget").select2("data")[0].id;

   // Now you can work with the selected value, i.e.:
   $("#items").val(id);
});


text:
Q: Index match with partial text and multiple matches I have a dynamic table with input data which i am trying to gather specific data from. The table looks like this:
enter image description here
What i am trying to do is to retrieve the name of the different contracts based on a partial text. So in cell A1 (formula cell) i want to use index & match on the above table, and find the contract which has "ER" in it. As you can see there are multiple contracts thats named "ER", and this is the only fixed part. (ERZ2, ERZ3 and ERM3, these data will change, but there will never be more than three "ERs" at once.
In cell A1 i want the first ER-contract, and in A2 and A3 etc. i want the next ER-contracts. If my criteria is that the cells in my input table contains "ER", then i only get the first match, which is ERZ2. Which formula can i use in the different output cells (A1, A2 and A3) so that i get all the ER-contracts (ERZ2, ERZ3 and ERM3)?
Many thanks for help in advance!


text:
Q: Why is rowid not contained in asterisk wildcard queries? In sqlite the query:

select * from [....]

is often implemented to grab all the info associated with pertinent entries.
But, as this question asks, rowid is not one of the items returned with select all.
Why is rowid not automatically returned with a select all search?

A: All RDBMS (relational database management systems) implement some way to distinguish between rows in a table regardless of what keys are defined by the user.  Otherwise there would be no way for the system to distinguish between rows for internal processing.  Other systems also do not reveal their internal record-keeping metadata in * queries and only include user-defined columns.  The fact that sqlite documentation reveals the existence of rowid, or even that one can explicitly request the rowid does not change that it is still essentially a special metadata column, so there is really no reason for it to be included in SELECT * queries.
If you rely on such an integer primary key and/or insist that it appears in the full list of columns returned by SELECT *, then you can add an alias for the rowid by defining an explicit integer primary key.  See sqlite CREATE TABLE docs for details.  Here is just one example from the documentation that creates a valid rowid alias:

CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z);


text:
Q: get metric size of image in cpp I want to read the metric sizes from an image in C++. In Octave I could do this up to now:
IM.info = imfinfo(path_to_image);
IM.info.ResolutionUnit
IM.info.XResolution
IM.info.YResolution

For example, when I export a PNG on Inkscape, I specify DPI and the pixel size of the image. So this information should be available in the metadata right? I find many examples of how to read the pixel sizes, but none that can read metric information. What is the best way to do this?

A: The C++ standard library does not have functions for reading PNG files. You will need to parse the file.
According to the specification Chapter 11. PNG Options and Extensions, the relevant chunk should be Physical Pixel Dimensions (pHYs).


text:
Q: Sys.getsizeof vaue of numpy ndarray seems too small import sys
npArrayList = 20000 * [None]
npNdArray = np.random.normal(size = (20000, 4))
for i in xrange(20000):
    npArrayList[i] = npNdArray[i, ]
    if i == 0:
        print 'npArrayList[i].nbytes = ' + str(npArrayList[i].nbytes)

print 'npArrayList size = ' + str(sys.getsizeof(npArrayList))
print 'npNdArray.nbytes = ' + str(npNdArray.nbytes)

The console results are:
npArrayList[i].nbytes = 32
npArrayList size = 160064
npNdArray.nbytes = 640000

The value of 'npArrayList size' seems too small. 32 * 20000 = 640000, while the value is just 160064.
How to explain this?


text:
Q: BindingSource.Filter Exclude Values - How? My BindingSource is bound to a collection of objects (not using ADO.NET) and I would like to filter it and exclude some values but not sure if I'm using this exactly since the result set I am expecting is not coming back.  I was thinking something like this, but its not working:
MyBindingSource.Filter = "State = 'NY' AND State = 'MA' AND State = 'CO'";

Any assistance will be greatly appreciated!

A: You've used AND.
If you want your filter to work you want this:
MyBindingSource.Filter = "State = 'NY' OR State = 'MA' OR State = 'CO'";

There is no way that something in boolean can be in two states at the same time. (At least in logic realms I work in anyway...)

A: I never tried it outside of the WPF world, but you could take a look at the ListCollectionView (for IList)/BindingListCollectionView (for IBindingList). It should raise the necessary events, and you can use the filter without the underlying list.


text:
Q: Beginning of Sudoku solution: 2 x rspec failing Why is the first test returning 173, not 81 and the second 20, not 9? How can i return the number of arrays from @cells.each_slice(9).map { |v| v } - count method?
class Grid

  attr_reader :cells

  def initialize(puzzle)
    @cells = puzzle.chars.map { |x| (x.to_i) }
  end

  def rows
    @rows = @cells.each_slice(9).map { |v| v }
  end
end

spec
 require 'Grid'

  describe Grid do

    context "initialization" do
      let(:puzzle) { '01500300200010090627
                      00684304900020175010
                      40380003905000900081
                      04086007002503720460
                      0'}
      let(:grid) { Grid.new(puzzle) }

       it 'should have 81 cells' do
        expect(grid.cells.length).to eq(81)
      end

       it 'should have an unsolved first cell' do
        expect(grid.cells.first).to eq(0)
      end

      it 'should have 9 rows' do
        expect(grid.rows).to eq(9)
      end
    end
  end

rspec report
Grid
  initialization
    should have 81 cells (FAILED - 1)
    should have an unsolved first cell
    should have 9 rows (FAILED - 2)

Failures:

  1) Grid initialization should have 81 cells
     Failure/Error: expect(grid.cells.length).to eq(81)

       expected: 81
            got: 173

       (compared using ==)
     # ./spec/grid_spec.rb:14:in `block (3 levels) in <top (required)>'

  2) Grid initialization should have 9 rows
     Failure/Error: expect(grid.rows).to eq(9)

       expected: 9
            got: 20

       (compared using ==)
     # ./spec/grid_spec.rb:22:in `block (3 levels) in <top (required)>'

Finished in 0.00165 seconds
3 examples, 2 failures

A: I copied and pasted the numeric string into irb and found where the 173 is coming from:
irb(main):001:0> a = '01500300200010090627
irb(main):002:0'                       00684304900020175010
irb(main):003:0'                       40380003905000900081
irb(main):004:0'                       04086007002503720460
irb(main):005:0'                       0'
=> "01500300200010090627\n                      00684304900020175010\n                      40380003905000900081\n                      04086007002503720460\n                      0"
irb(main):006:0> a.length
=> 173

As you can see it is including the newlines and spaces. You probably want this:
let(:puzzle) { '01500300200010090627' +
               '00684304900020175010' +
               '40380003905000900081' +
               '04086007002503720460' +
               '0' }

Regarding @rows I am guessing you want
@rows = @cells.each_slice(9).to_a

but in your test you should have
expect(grid.rows.size).to eq(9)

A: Do change the line
  @cells = puzzle.chars.map { |x| (x.to_i) }

as
  @cells = puzzle.gsub(/[^0-9]/,'').chars.map { |x| (x.to_i) }

Full code :
class Grid

  attr_reader :cells

  def initialize(puzzle)
    @cells = puzzle.gsub(/[^0-9]/,'').chars.map { |x| (x.to_i) }
  end

  def rows
    @rows = @cells.each_slice(9).map { |v| v }
  end
end

s = '01500300200010090627
     00684304900020175010
     40380003905000900081
     04086007002503720460
                      0'
grid = Grid.new(s)
grid.cells.length # => 81
grid.rows.size # => 9


text:
Q: Most effective "architecture" for layered 2D app using OpenGL on iPhone? I'm working on an iPhone OS app whose primary view is a 2-D OpenGL view (this is a subclass of Apple's EAGLView class, basically setting up an ortho-projected 2D environment) that the user interacts with directly.
Sometimes (not at all times) I'd like to render some controls on top of this baseline GL view-- think like a Heads-Up Display. Note that the baseline view underneath may be scrolling/animating while controls should appear to be fixed on the screen above.
I'm good with Cocoa views in general, and I'm pretty good with CoreGraphics, but I'm green with Open GL, and the EAGLView's operations (and its relationship to CALayers) is fairly opaque to me. I'm not sure how to mix in other elements most effectively (read: best performance, least hassle, etc). I know that in a pinch, I can create and keep around geometry for all the other controls, and render those on top of my baseline geometry every time I paint/swap, and thus just keep everything the user sees on one single view. But I'm less certain about other techniques, such as having another view on top (UIKit/CG or GL?) or somehow creating other layers in my single view, etc.
If people would be so kind to write up some brief observations if they've travelled these roads before, or at least point me to documentation or existing discussion on this issue, I'd greatly appreciate it.
Thanks.

A: Create your animated view as normal. Render it to a render target. What does this mean? Well, usually, when you 'draw' the polygons to the screen, you're actually doing it to a normal surface (the primary surface), that just so happens to be the one that eventually goes to the screen. Instead of rendering to the screen surface, you can render to any old surface.
Now, your HUD. Will this be exactly the same all the time or will it change? Will only bits of it change?
If all of it changes, you'll need to keep all the HUD geometry and textures in memory, and will have to render them onto your 'scrolling' surface as normal. You can them apply this final, composite render to the screen. I wouldn't worry too much about hassle and performance here -- the HUD can hardly be as complex as the background. You'll have a few textures quads at most?
If all of the hud is static, then you can render it to a separate surface when your app starts, then each frame render from that surface onto the animated surface you're drawing each frame. This way you can unload all the HUD geom and textures right at the start. Of course, it might be the case that the surface takes up more memory -- it depends on what resources your app needs most.
If your had half changes and half not, then technically, you can pre-render the static parts and then render the other parts as you're going along, but this is more hassle than the other two options.
Your two main options depend on the dynamicness of the HUD. If it moves, you will need to redraw it onto your scene every frame. It sucks, but I can hardly imagine that geometry is complex compared to the rest of it. If it's static, you can pre-render and just alpha blend one surface onto another before sending to the screen.
As I said, it all depends on what resources your app will have spare.


text:
Q: Assembly MOV and dereferencing I came across this line from a textbook.
mov var, 10                   ;var contains 1 at 0xA

mov RAX, [var+5]              ;This will add 5 to the address already held by var, then dereference the new address and put whatever is at that address into RAX.

So the steps taken will be

*

*Calculate new Address

*Dereference new address to get value stored in memory location

For step1, will they use (0x1 from the value(1) + 5)
OR (10 from address(0xA) + 5)?
What would be the answer for Step1 ?


text:
Q: Landsat 8 - Surface reflectance panchromatic band ? I ordered landsat 8 surface reflectance high level data products via Espa: http://espa.cr.usgs.gov/ordering/new.
Is it correct that there is no surface reflectance panchromatic band available after processing?

A: This is abolutely true!
The surface reflectance is only available for bands 1-7:
http://landsat.usgs.gov/documents/provisional_l8sr_product_guide.pdf


text:
Q: Closed form for $f(z,a)=\sum_{n=1}^\infty \frac{H_n}{n^a}z^n$? So I have been working with some power series involving the Harmonic numbers. I have been able to evaluate the first couple of sums as
$$f(z,0)=\sum_{n=1}^\infty H_n z^n=\sum_{n=1}^\infty z^n\int_0^1 \frac{1-x^n}{1-x}dx=-\frac{\ln(1-z)}{1-z}$$
$$f(z,1)=\sum_{n=1}^\infty \frac{H_n}{n}z^n=\int_0^z\frac{f(x,0)}{x}dx=\operatorname{Li}_2(z)+\frac{\ln^2(1-z)}{2}$$
$$f(z,2)=\sum_{n=1}^\infty \frac{H_n}{n^2}z^n=\int_0^z \frac{f(x,1)}{x}dx=\operatorname{Li}_3(z)-\operatorname{Li}_3(1-z)+\operatorname{Li}_2(1-z)\ln(1-z)+\frac{\ln(z)\ln^2(1-z)}{2}+\zeta(3)$$
and in general$$f(z,a)=\sum_{n=1}^\infty \frac{H_n}{n^a}z^n=\int_0^z \frac{f(x,a-1)}{x}dx$$ I was wondering if it is possible to derive a general formula for $f(z,a)$ as computing each integral of $\frac{f(x,a-1)}{x}$ becomes very tedious and complicated to do and does not seem to provide a closed form answer for any $a$. I know that there exists a closed form for $f(1,a)$ but how could we generalize this to $f(z,a)$?

A: By coincidence, I asked virtually the same question. I managed to answer it myself which is,
$$F_a(z) = \sum_{n=1}^{\infty}\frac{H_n}{n^a}z^n= S_{a-1,2}(z) + \rm{Li}_{a+1}(z)$$
with polylogarithm $\rm{Li}_{a+1}(z)$ and Nielsen generalized polylogarithm $S_{n,p}(z)$. The situation then is subsumed by the Nielsen polylogs.
There are formulas for general $z$ when $a=1,2$ (as you mentioned) as well as for $a=3$, though I am not sure if there is for higher.


text:
Q: Jquery toggle between append and remove not working as i expected The following toggle between append and remove does not work:
$('.t').click(function() {
            var className = $(this).data('class');
            $(this).toggleClass(className).toggleClass(className+'1');

            var newTable='

T1

20

8

';
            $("#newDiv").append(newTable).remove(newTable);
        });

HTML

 8cghfghfghfghfg

20cghfghfghfghfg

 4cghfghfghfghfg

Working Demo Here..
Here, what i want to do is.. if i click on div.t, i want to remove the particular class(Ex: .a) and add respective class (Ex .a1), this one i achieved.
But i want to add a table while clicking first time, want to remove that added table while second time clicking.
how can i achieve this, please can anyone help me put...
Thanks

A: To toggle append and remove, you can make use of the data property of the clicked element. Its a cleaner approach :
    $('.t').click(function () {
        //general stuff must happen everytime class is clicked
        //get the className from data- attr
        var className = $(this).data('class');
        //toggling to change color
        $(this).toggleClass(className).toggleClass(className + '1');

        //check if its clicked already using data- attribute
        if ($(this).data("clicked")) {
            //remove it if yes
            $("#newDiv").find("#tablefor-" + className).remove();
        } else {
            //new table - note that I've added an id to it indicate where it came from
            var newTable = '

T1' + className + '

20

8

';

            //append table
            $("#newDiv").append(newTable);
        }
        //reverse the data of clicked
        $(this).data("clicked", !$(this).data("clicked"));
    });

Demo : http://jsfiddle.net/hungerpain/m9ak9/11/

A: Just use an if switch to determine wether the table is already present or not. I modified your fiddle to demonstrate this: http://jsfiddle.net/m9ak9/6/
I added an id to the table to make it easiert to identify, but you could also look for it with something like this:
var findTableInDiv = $('#newDiv').find('table');


text:
Q: explanation about prototype.js function binding code From: http://ejohn.org/apps/learn/#2
Function.prototype.bind = function(){
  var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift();
  return function(){
    return fn.apply(object,
      args.concat(Array.prototype.slice.call(arguments)));
  };
};

Can anyone tell me why the second return is necessary (before fn.apply)?
Also, can anyone explain why args.concat is necessary?  Why wouldn't it be re-written as:
fn.apply(object, args)

instead of
return fn.apply(object,
          args.concat(Array.prototype.slice.call(arguments)));

A: The second return is necessary because otherwise we will lose any return value from the bound function.
You may already know this, but doesn't hurt to mention. If we don't wrap fn.apply inside another function, then we are directly calling the function fn which is sub-optimal, as bind is only supposed to set the execution context (what should this refer to inside the function), and not invoke it.
Javascript methods can be invoked by calling the call or apply method on them. Here's a small example:
function example() {
    alert("useless example");
}

example.apply() // or example.call(), alerts "useless example";

The outer function in Prototype's bind() is supposed to work like an invisible wrapper around the bound function. Thus any arguments that are passed to the wrapper should be passed to the bound function as well, and it must return any value that the bound function returns, which is why the return statement is there.
The reason for doing args.concat inside fn.apply is different and it's not optional. bind in Prototype allows you to prepend arguments to the bound function.
args represents the arguments that were passed when we called bind on the function. arguments represents the arguments that were passed when we called the bound function. We're basically concatenating two arrays there.
From the above example:
var obj = { x: 'prop x' };
var boundExample = example.bind(obj, 12, 23); // args => 12, 23
boundExample(36, 49); // arguments => 36, 49

// arguments that our example() function receives => 12, 23, 36, 49

A: Old post but a newer approach ;)
Function.prototype.bind = function(){
    var fn = this,
    context = arguments[0],
    args = Array.prototype.slice.call(arguments, 1);
    return function(){
        return fn.apply(context, args.concat([].slice.call(arguments)));
    }
}

obj = {'abc':'x'};
var func = function() {
  console.log(arguments);
  alert(this.abc);
}
var x = func.bind(obj);

console.log(x(1,2,3));

This is a very good example to explain. Run it and check the console log.
Then modify the code to leave out
[].slice.call(arguments)

You will see that the console.log of the execution of x(1,2,3) is not showing up the arguments anymore. This is because the arguments objects is a local variable within all functions.
That might sound a bit confusing, but what it means is basically:
var x = func.bind(obj,1,2,3);

Returns this function internally:
function() {
    return fn.apply(obj, [1,2,3].concat([].slice.call(arguments)));
}

So it is more of a template for the function.
When you do now run it like:
x(4,5,6)

This will be ran:
fn.apply(obj, [1,2,3].concat([].slice.call(arguments)))

with a special arguments object = {0:4,1:5,2:6} , which  can be converted into an array using [].slice.call
where arguments is a local object, that is automatically beeing assigned during the invokation of the function.


text:
Q: Increase the width of a row inside a box-title I'm trying to create two columns in a box-title within the box-header. It works in the box-body but it only spans half of the length of the title. It would be very useful if I could do it. Can anyone help please?

New Character

Old Character

                <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="" data-original-title="Collapse">
                    </button>

left side

right side

A: I have removed the box-title and I can see the two column across the header. Maybe no the most elegant solution but it works.


text:
Q: How can I get the encoding of my system? Is there any command for command prompt through which I can know the default encoding of my system?

A: Just head to the 'Control Panel' → 'Regional and Language Options' → 'Advanced' tab.
Or
Microsoft Docs has a solution to get the encoding for the operating system's current ANSI code page. You can use the following VB code:
'Declaration (FYI)
'Public Shared ReadOnly Property Default As Encoding

'Usage
Dim value As System.Text.Encoding
value = System.Text.Encoding.Default
System.Console.WriteLine(value.WebName) ' (e.g.)

There are also syntaxes for C#, C++ and JScript. Have a look at Microsoft Docs for more info.


text:
Q: CSS - Hover passes through elements to activate hover on covered element I have a page layout involving a lot of position absolute and z-indexing, so there are a lot of elements that are overlapping one another.
One of the elements just contains text and it hovers over top of a lot of other things.
Underneath that element there are several elements that have CSS Hover Pseudo Classes applied.
When the mouse passes over the element containing text, I would like for somehow the Element underneath to respond to the presence of the mouse and activate the pseudo class styles.
Is there any way to style an element so it allows the hover to pass through it to any elements underneath?
This wouldn't be too hard with JavaScript, but I would rather not go that route at the moment in order to keep things as simple as they can be.  I'll be complicating things with JavaScript enough later.
Thanks
P.S. - I'm using HTML5 and CSS3 already, so I would have no problem with solutions utilizing these newer standards.

A: you can use pointer-events: none; to the element on top:

div {
   width   : 200px;
   height  : 200px;
   float   : left;
   cursor  : pointer;
   border  : 1px green solid;
}

div + div:hover { background: #a1a6c8; }

div:first-child {
   pointer-events : none;
   position       : absolute;
   top            : 100px;
   left           : 100px;
   border         : 1px green solid;
   background     : #c1c6c8;
}

 on top of all: hover me

1

2

3

4

5

6

as you can see, when you hover the element on the top the element behind is activated. For more info about this property: https://developer.mozilla.org/en/CSS/pointer-events

A:
Also, something that people may find useful is that you can re-enable pointer events on child elements of the pointer-events:none element by setting them to pointer-events:auto explicitly. This doesn't seem to be well documented and turns out to be very useful. – slicedtoad

@slicedtoad's comment was hugely useful for me, so I think it deserves a full answer.  If you set pointer-events: none to a parent, you'll disable the events for it's children.  HOWEVER, if you set point-events: auto to the children, they will work again.
This also works when the children have a negative z-index, and therefore become unresponsive to pointer-events.

A: This is a Javascript solution which the question doesn't call for, but this page is connected to this sort of hover problem search query:
I have a case where this arrow button is sitting on top of an item that I want to remain hovered in grey. More specifically, the item is in a list of items that each will have various buttons appear on top when hovered over.

So with jQuery events:
var selectedItem;
var lastSelectedItem;

$(".item").mouseover(function(){
  $(this).addClass("item-hovered")       // css class with hover styles
  selectedItem = $(this);
});
$(".item").mouseleave(function(){
  $(this).removeClass("item-hovered")
  selectedItem = null;
  lastSelectedItem = $(this);
});

$(".button").mouseover(function(){
  selectedItem = lastSelectedItem;
  selectedItem.addClass("item-hovered")
});

"lastSelectedItem" is used to differentiate between moving off item onto whitespace and off item onto button, so selectedItem holds a value only if the mouse is either over an item or its corresponding button.


text:
Q: Why plain strings are considered bug free? In the code if I have the following line of code doesn't throw an error:
'any string'
console.log('test');

Obviously this throws:
'any string' console.log('test'); // missing ;

But not this: 'any string'; console.log('test');
I mean the 'any string' has nothing to do in the script but it is considered bug free, why?

A: The string is just an expression - JS doesn't differentiate between function calls and ordinary expressions.
In the first case, a semicolon is automatically placed at the end of the first line, breaking it up. That clearly doesn't exist in the second example. In the third, again, you break them up into different expressions.
Even console.log() is an expression - it is a function call that returns undefined and has side effects.
This effect is intentionally used to force strict mode interpretation. A strict-mode function is written as:
function myFunc() {
"use strict"; // just the plain string
// function body
}

A: JavaScript statements are terminated by semicolons: ;, in theory.
However, JS has the idea of semicolon insertion, where semicolons can be inserted into code under certain conditions - specifically, after } or newlines (see "Rules of Automatic Semicolon Insertion" in the spec).

A: The JavaScript engine in most browsers is not that strict than what you would expect from other languages e.g. compiled C.
Therefore it is a good idea to sometimes check your JavaScript code with a static analysis tool like JsLint.
Pasting your snippet into it gives

Expected an assignment or function call and instead saw an expression.
'any string'
line 1 character 13 Expected ';' and instead saw 'console'.
'any string'
line 2 character 1 'console' was used before it was defined.
console.log('test');


text:
Q: Detected a mismatch for the compiler version between your conan profile settings and CMake I had an issue with CMake who were not detecting the right version of the CMake compiler.
My CMake was working with the command line but not in CLion.
Here the output log from the CMake tool in CLion:
CMake Error at build/conanbuildinfo.cmake:1344 (message): Detected a mismatch for the compiler version between your conan profile settings and CMake: Compiler version specified in your conan profile: 9 Compiler version detected in CMake: 8.3 Please check your conan profile settings (conan profile show [default|your_profile_name])

A: The solution for this problem is to change the two path for compilation:
Press CTRL + ALT + S to open the parameters
Go to Build, Execution, Deployment > Toolchain
Switch C Compiler to /usr/bin/gcc and C++ Compiler to /usr/bin/g++


text:
Q: Changing Amazon Textract bounding box values I'm writing a code in python for text extraction in python using Textract. My aim is to extract data from a restaurant menu card as item and price and I'm using tabular form to get data extracted. But during some image extraction some tables are not there in result.
To solve this i tried changing the BoundingBox attribute and still not working.
response = textractmodule.analyze_document(
Document={
    'S3Object': {
        'Bucket': s3BucketName,
        'Name': TabledocumentName
    }
},
FeatureTypes=["TABLES"])
doc = Document(response)
print ('------------- Print Table detected text ------------------------------')
for page in doc.pages:
    for table in page.tables:
        for r, row in enumerate(table.rows):
            itemName  = ""
            for c, cell in enumerate(row.cells):
                print("Table[{}][{}] = {}".format(r, c, cell.text))

This is the code and I'm not getting to change its bounding box. Or is there any other issue or any other method??


text:
Q: Laravel relationship returns items twice I have categories and products in Laravel 5.5
Each product has a category and categories can have parent categories. I want to get all children products of a category when it's showed. Example: Clothes is a cateogry and has subcategories like shirts, jackets etc. and I when it's clicked on the Clothes category I want to show all products which have the shirts or jackets category.
Here is my Category.php model:
public function children()
{
    return $this->hasMany('App\Category', 'parent_id');
}
public function products()
{
    return $this->hasMany('App\Product');
}

public function getAllProducts()
{
     $products = $this->products;

     foreach ($this->children as $child) {
        foreach ($child->products as $product) {
           $products[] = $product;
         }
      }

     return $products;
}

In my case I have three products which are "cloth1", "cloth2" and "shirt1". "cloth1" and "cloth2" belongs to the clothes category and "shirt1" belongs to the shirts category which is subcategory of clothes. So when I'm on the clothes category page I want to show all products ("cloth1", "cloth2" and "shirt1")
But in the view
{{dd($category->getAllProducts())}}

returns "cloth1", "cloth2", "shirt1", "shirt1" (it returns the shirt twice). Any idea why and how to fix this ?
EDIT: When I try $category->products on the clothes category it returns "cloth1" and "cloth2" and when I try it on the shirts category it returns "shirt1" only once (which is how it should be)

A: I fixed my problem using the contains() method
the function now looks like this:
public function getAllProducts()
{
    $products = $this->products;

    foreach ($this->children as $child) {
        foreach ($child->products as $product) {
            if (!$products->contains($product)) {
                $products[] = $product;
            }
        }
    }

    return $products;
}

But I still don't know why it returns "shirt1" twice if I don't use contains


text:
Q: FBProfilePictureView object won't show image I'm doing the scrumptios facebook developer tutorial for the 3.1 iOS SDK.
I've managed to display my profile name from facebook, however the FBProfilePictureView wont show the picture
here's the code for iboutlet
@property (strong, nonatomic) IBOutlet FBProfilePictureView *useProfileImage;

here is what I used to display the pic
self.useProfileImage.profileID = user.id;

I have confirmed that the it changed the profileid variable of the image by displaying it in a label.
When I first ran the project I had this error

"2012-05-18 04:04:11.620 Scrumptious[6548:f803] Unknown class
  FBProfilePictureView in Interface Builder file."

and solved it they way the FB tutorial suggested- by adding [FBProfilePictureView class];
to "applicationdidfinishlaunching: withoptions" in the app delegate.
any idea why the picture wouldn't show?
link to the tutorial

A: To resolve this, add this as the first line in the app delegate's application:didFinishLaunchingWithOptions: method:
[FBProfilePictureView class];

A: Adding the [FBProfilePictureView class]; as the first line in the app delegate method of didFinishLaunching seems kinda hacky to me.
Check out the HelloFacebookSample inside the SDK.  Here is the 4 line comment:
// If you have not added the -ObjC linker flag, you may need to uncomment the following line because
// Nib files require the type to have been loaded before they can do the wireup successfully.
// http://stackoverflow.com/questions/1725881/unknown-class-myclass-in-interface-builder-file-error-at-runtime
// [FBProfilePictureView class];

I tried adding the -ObjC flag and it worked fine.

A: As documented in the facebook webpages you need to put the [FBProfilePictureView class]; as the first line in the app delegate method of didFinishLaunching. (Note their sample code does not have this but still works, in my case it will not work without it.
I created a UIView object sized it up and then selected the class from UIView to FBProfilePictureView.  This will disconnect any connection between your program and IB so you need to reconnect again, the error in which you are not able to see the picture is due to the object not being wired up to an IBOutlet item.
I am not sure if a cut and paste will work, maybe it will, but I created the object from UIView and just changed the class manually through IB.
Without the [FBProfilePictureView class];  it will give you an error.
If done correctly, if you view the XIB  - in the object window/list you should see "Profile Picture View"along with Button and Label instead of FBProfilePictureView. The profile pic from facebook should show.

A: I have the same problem. My solution is to uncheck the "Use autolayout" option in "File Inspector" of the xib file. To open the "File Inspector", press cmd+option+1 after opening the  xib file.
Edit 1: Just find another solution.
Try to set a width constraint and height constraint to the profile picture view. I find this tutorial is useful.

A: I had the same issue, xcode4.5.1 ios6.
to fix do this: in IB uncheck use autolayout for FBprofilepictureview, also uncheck "autoresize subview" into the view

A: They(fb developer forum) said paste that in your app delegate didLunch method like that
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

        [FBProfilePictureView class];

        // Create a LoginUIViewController instance where the login button will be
        LoginUIViewController *loginUIViewController = [[LoginUIViewController alloc] init];

        // Set loginUIViewController as root view controller
        [[self window] setRootViewController:loginUIViewController];

        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
        return YES;
    }

just replace
    [FBProfilePictureView class];

with these commented lines it will work

    // Override point for customization after application launch.

    // Load the FBProfilePictureView
    // You can find more information about why you need to add this line of code in our troubleshooting guide
    // https://developers.facebook.com/docs/ios/troubleshooting#objc
    [FBProfilePictureView class];

it will work magically :)

A: Classes that use categories to extend existing classes are not loaded automatically. Classes that are used from the Xcode interface builder aren't loaded automatically, for example when you add a FBLoginView to your interface by drawing a view in your .xib file and then classing it as FBLoginView from the interface builder UI.
class helps to create a pointer to the FBProfilePictureView.


text:
Q: Can I check if a button was pressed in node.js? I'm trying to check if a button was pressed and then open a new html file, I'm using express.js app.get method to open all of my HTML files. So my question is how can I open a HTML file on the same window when I press a button?

A: You could but shouldnt. NodeJS is backend.
Also note, that NodeJS is no JavaScript as normally referred to.
It is written/programmed in JavaScript.
To do something on click you would need either a normal <a> tag if you just want to open a link or you use client-side JavaScript with an onlick handler to execute something after a user clicked on an element.

A: You can accomplish this using javascript embedded into the html like this:
<button onclick="window.location='http://google.com'">Click me</button>

you can also try window.open=url
please note that this isn't really using node, just javascript.  this type of behavior belongs in the page.

A: I think this thread would help you :)
https://stackoverflow.com/a/33703429/4578393
it uses if statements to check if the button has been pressed
 if(req.body.hasOwnProperty("butt1")){
 console.log("butt1 clicked");

Taine


text:
Q: SearchView drawables in ActionBar appear blurred I have the following menu layout for my ActionBar:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/itemSearch"
        android:icon="@drawable/actionbar_icon_search"
        android:showAsAction="ifRoom|collapseActionView"
        android:actionViewClass="android.widget.SearchView"
        android:title="Search"/>
</menu>

And here's the setup code:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.actionbar_default, menu);

    SearchView searchView=(SearchView) menu.findItem(R.id.itemSearch).getActionView();
    int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
    View searchEditText = searchView.findViewById(searchPlateId);
    ((TextView) searchEditText).setTextColor(Color.WHITE);
    searchView.setOnCloseListener(new OnCloseListener() {...});
    searchView.setOnQueryTextListener(new OnQueryTextListener() {...});
}

Everything is ok, except for one thing: on my Asus tablet (TF-201, Android 3.2.1) graphics are blurred:

If I remove android:actionViewClass="android.widget.SearchView", everything looks normal:

This problem is not reproduced on 4.1.2 emulator. I tried leaving only menu inflation code in my onCreateOptionsMenu() but that didn't help.
How do I fix this?

A: So I beat up the solution, however, it declares right compatibility only for API 14 and above, if not using ActionBarSherlock library.

First solution (API 14+)
Important is to be connected to Themed Context of application, otherwise you get lowest possible design for SearchView (blurry icons)
Creating SearchView programmatically
FRAGMENT
SearchView searchView =
                new SearchView(getActivity().getActionBar().getThemedContext());

ACTIVITY
SearchView searchView = new SearchView(getActionBar().getThemedContext());

Second solution (ABS compatibility, API 8+)
ACTION BAR SHERLOCK FRAGMENT
SearchView searchView =
  new SearchView(getSherlockActivity().getSupportActionBar().getThemedContext());

ACTION BAR SHERLOCK ACTIVITY
SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());

Third solution (API 11+)
In some cases, setting SearchView.setBackgroundColor(int color) makes the icon appear less blurry, try Color.WHITE or Color.BLACK
Note that this changes background color for MenuItem whether collapsed or not, and eg. by using Theme Holo.Light.DarkActionBar you need to use right color, according to your ActionBar style.

A: I experienced same problem but other answer did not resolve my problem. I am extending my activity class from AppCompatActivity. My searchview icon was looking blurry on Android 4.* and it was looking good on Android 5.* without any problem.
I changed my xml to this:
  <item android:id="@+id/action_search"
      android:icon="@drawable/ic_search_white_24dp"
      app:showAsAction="always"
      app:actionViewClass="android.support.v7.widget.SearchView"
      android:iconifiedByDefault="true" />

And imported
import android.support.v7.widget.SearchView;

Instead of import android.widget.SearchView;
And problem fixed.


text:
Q: Fontawesome Wordpress Icon CSS rule I'm trying to use  WordPress fontawesome Icon but I can't find the CSS rule anywhere.
found the rule below but it shows up broken. any idea on how this can be achieved.
I know how to use font awesome but I'm trying to insert the WordPress icon via CSS. Every other iconis showing except for that of Wordpress.
 .side-box ul li:nth-of-type(4):before {
    content:"\f205";
    width: auto;
    font-family: FontAwesome;
    position: absolute;
    z-index: 999999;
    color: #69B5D5;
    font-size: 18px;
    left: 20px;
}


text:
Q: Set to inactive instead of deleting Is it possible to set objects to inactive instead of deleting them in rails? Since I need this in almost every of my models it would be nice to have a central spot for this.

A: Take a look at ActsAsParanoid gem.


text:
Q: Unable to start a spring boot web application with spring batch admin I am trying to run a web application with embedded tomcat including a number of spring batch jobs and the spring batch admin. However when I try to run the generated fat jar I get the following error, can anybody from spring batch or boot team help:
Error registering Tomcat:j2eeType=WebModule,name=//localhost/*,J2EEApplication=none,J2EEServer=none

Adding more information:
Version of spring boot: 1.1.9.RELEASE from spring.io parent pom version 1.0.3.RELEASE
I tried running it from STS as well as using mvn spring-boot:run with the same effect.
The batch jobs read from a file and write to hornetq.
The complete stack trace is as follows:
2014-11-14 14:22:45.236 ERROR 404 --- [ost-startStop-1] org.apache.tomcat.util.modeler.Registry  : Error registering Tomcat:j2eeType=WebModule,name=//localhost/*,J2EEApplication=none,J2EEServer=none`

javax.management.RuntimeOperationsException: null
    at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:411)`
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)`
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
    at org.apache.tomcat.util.modeler.Registry.registerComponent(Registry.java:742)
    at org.apache.catalina.util.LifecycleMBeanBase.register(LifecycleMBeanBase.java:158)
    at org.apache.catalina.util.LifecycleMBeanBase.initInternal(LifecycleMBeanBase.java:61)
    at org.apache.catalina.core.ContainerBase.initInternal(ContainerBase.java:1084)
    at org.apache.catalina.core.StandardContext.initInternal(StandardContext.java:6506)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Repository: cannot add mbean for pattern name Tomcat:j2eeType=WebModule,name=//localhost/*,J2EEApplication=none,J2EEServer=none
    ... 19 common frames omitted

A: I assume the name is not a valid object name: //localhost/*
Could you try with a different name, or either escape or quote the name. This should fix the problem.