text:
Q: PHP multiple variable array output I have a simple query.
I have an array, which has two variables, which I define this way:
$sArray[0]['Name'] = $sName;
$sArray[0]['ID'] = $sID;

The above is in a loop which feeds the data for sName and sID. Example of the Data is:
Name: John Smith ID: 123
Name: Sue Smith ID:234

I'd like to output the sName data in a multi Select HTML and store the ID as the value and Name as the option display. The code I have below so far only outputs the first entry in the list, so the looping is not right. So, please help. :)
  <select class="form-select" multiple id="SelectName" name="name_list[]">
  <?php
    $selectLength = count($sArray);
    for ($j=0 ; $j<$selectLength ; $j++) {
    foreach ($sArray[$j] as $value) {
    echo"<option value=$value name='name_list[]'>$value</option>"?>
   <?php
        }
    } ?>
 </select>

Below is the dump of the array contents:
array(1) { [0]=> array(2) { ["Name"]=> string(3) "Sue" ["ID"]=> string(3) "234" } } array(1) { [0]=> array(2) { ["Name"]=> string(4) "John" ["ID"]=> string(3) "123" } }

Thanks in advance.
UPDATE:
As requested, below is the loop which populates the array. It basically reads an XML file which has Name and ID data and places it in the array.
$fetchdata = simplexml_load_string($xml);
foreach ($elm->res as $list) {
        $Team = $Agentlist->xpath('team[@name="Stock"]');
        if (count($Team) >= 1) {
            $fName = (string)$list->fName;
            $ID = (string)$list->ID;
            $sArray[0]['Name'] = $fName;
            $sArray[0]['ID'] = $ID;
            var_dump($sArray);
        }
    }

A: As I can see, all you need is a foreach for you array. Take a look
foreach($sArray as $value){
    echo '<option value="'.$value['ID'].'">'.$value['Name'].'</option>';

    }

A: You can use a foreach loop and inside the loop, the current object ($value) will contain ID and Name which you can use to build the dropdown
<?php
$sArray[0]['Name'] = 'John';
$sArray[0]['ID'] = '123';
$sArray[1]['Name'] = 'Sue';
$sArray[1]['ID'] = '234';

?>

<select class="form-select" multiple id="SelectName" name="name_list[]">
    <?php
    foreach ($sArray as $value) {

        echo'<option value="'.$value['ID'].'" name="name_list[]">'.$value['Name'].'</option>';

    }
    ?>
</select>

A: The cleaner way of achieving this would be using an ID as a key of an array with user data. However, if you have no control over the array structure, then just extract the ID as any other value.
This way your array will be lighter and easier to read.
You also should create an output function, in case you need to create select box multiple times, so you can reuse it.
Example:
$user_list[$id]['first_name'] = 'John';
$user_list[$id]['last_name'] = 'Doe';

function select_user($user_list=[], $name='user_list', $multiple=''){

    $select = '<select name="'.$name.'" '.$multiple.'>'; //use attribute multiple for multiselect
    foreach($user_list as $user_key=>$user){
        $user_ID = $user_key;   // Option 1: $user_ID as Key
        $user_ID = $user['ID']; // Option 2: $user_ID as Value
        $select .= '<option value="'.$user_ID.'">'.$user['first_name'].' '.$user['last_name'].'</option>';
    }
    $select .= '</select>';
    return $select;
}

Then  simply run this function where you want it:
$user_list = get_users_from_DataBase(); // example function for getting all users from DB
echo select_user($user_list); // Simple Select box
echo select_user($user_list,'user_list[]','multiple'); // Select Box with custom array name[]* & with attribute "multiple"

If you need more explanation, you can Google for:
PHP Multidimensional Associative Arrays or read using the link below from official PHP documentation here:
http://php.net/manual/en/language.types.array.php


text:
Q: Is there a "measure of nonlinearity" that can be measured when testing quantum mechanics? For context, I think the comparison to tests of general relativity here is apt. There is the post-Newtonian formalism that has some well-defined parameters that can discriminate between general relativity and other theories.
Is there anything like this but for quantum mechanics? If there is, is there any neatly defined parameter that can be thought of as a "measure of nonlinearity" for tests of quantum mechanics?
(Obviously, the parameter would be zero according to quantum mechanics, but that's besides the point.)
This physics SE post is relevant, but it doesn't ask the same question. I haven't yet looked at Weinberg's paper.

A: The post-Newtonian expansion in GR is an expansion in powers of $1/c^2$. You can derive this expansion from an effective field theory approach in which every possible term consistent with symmetries is considered, and "ranked" according to its importance in the $1/c^2$ expansion. We can therefore identify what are the most important terms that would give the largest contributions, if they were different from GR. (Actually, to be precise, the post-Newtonian expansion is just a way of doing perturbation theory with GR; it is the parameterized post-Newtonian framework that is used to test GR, by replacing known, computable coefficients in the post-Newtonian expansion with free parameters that can be constrained with observations).
The situation in quantum mechanics is quite different, since there's not really a physical parameter with respect to which we know it makes sense to deform the theory, and therefore there is not a physically motivated, systematic expansion of correction terms ordered by importance. You could try to test specific non-linear alternatives to quantum mechanics if you have one in mind, but this is more analogous to testing specific alternative theories of gravity, as opposed to the post-Newtonian expansion.
Actually, I am not even sure if there is a viable, non-linear alternative to quantum mechanics that can be experimentally tested, although admittedly I am not an expert on this topic so there may well be one that someone can point to here. Weinberg proposed a framework for introducing nonlinearities into quantum mechanics in [1], but this was shown to lead to superluminal signaling in [2] and [3]. Some of the history is discussed in [4].
References
[1] S. Weinberg. Precision tests of quantum mechanics, Phys. Rev. Lett. 62:485, 1989
[2] N. Gisin. Weinberg's non-linear quantum mechanics and superluminal communications, Phys. Lett. A
143:1–2, 1990.
[3] J. Polchinski. Weinberg's nonlinear quantum mechanics and the Einstein-Podolsky-Rosen paradox,
Phys. Rev. Lett. 66:397–400, 1991.
[4] S. Aaronson. Is Quantum Mechanics An Island In Theoryspace? https://arxiv.org/abs/quant-ph/0401062

A: Nonlinear terms in the Schrodinger equation are used in so-called objective collapse theories. These are theories of quantum mechanics which explicitly (mathematically) specify under what conditions the famous Copenhagen wavefunction collapse happens. This is unlike the traditional Copenhagen interpretation which leaves this question unanswered, resulting in an INCOMPLETE physical theory.
Wavefunction collapse is nonlinear because we might have
$$
|\psi_1\rangle = \frac{1}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle \rightarrow |0\rangle
$$
and
$$
|\psi_2\rangle = \frac{1}{\sqrt{4}}|0\rangle + \sqrt{\frac{3}{4}}|1\rangle \rightarrow |0\rangle
$$
but no linear operator could map both $|\psi_1\rangle$ and $|\psi_2\rangle$ to  $|0\rangle$
Therefore, objective collapse theories include explicit nonlinear (and stochastic) terms into the Schrodinger equation to explain wavefunction collapse.
These theories make predictions different than regular quantum mechanics. See my answer at https://physics.stackexchange.com/a/659421/128186 for more details. In short, regular quantum mechanics says that we could perform double slit experiments with bigger and bigger objects and see interference patterns if we are able to sufficiently isolate the large particles from environmental interactions. By contrast, objective collapse theories have terms that induce wavefunction collapse if the particle becomes too "macroscopic". Here macroscopic can be defined as some combination of too massive, to spatially large, too many particles, or various other measures of macroscopicity.
Therefore, one way to test for the presence and bound the magnitude of these non-linear terms is to perform macroscopic superposition experiments, such as double slit experiments with large objects. See https://arxiv.org/abs/1410.0270.
Finally, I'll put a quick plug for a totally different approach, though I don't have a reference. Another way to test deviations from the Schrodinger equation would be to take a system with many particles and perform operations to put them into complicated superposition and entangles states and allow them to evolve under various interactions. Then, measure very precisely the final state of the system of particles and check if you get the prediction of regularly quantum mechanics. The bigger your system is and the more complicated interactions you perform the more sensitive you become to deviations from linearity of the Schrodinger equation. In fact, what I have just described is a quantum computer. A large controllable quantum system.
In summary, we can test for non-linear terms in the Schrodinger equation by performing experiments with LARGE quantum system and seeing if we get the results that are expected by regular quantum mechanics, and not the results expected by a theory with a non-linear term.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Customise the default "Follow-up" list in Outlook 2007? Does anyone know whether it's possible to customise the default options on the "Follow up" list in Outlook 2007? It comes with Today, Tomorrow, This Week, Next week, No date and custom. I get loads of emails that don't need to be followed up that quickly. Would like "Next two weeks" and "Next month".
Or is it time to dust down my Outlook VBA skills?
Thanks, Rob.


text:
Q: How to return a value from a function in batch file which can be used for further processing? I want a value to be returned from a subroutine/function which I can use for further processing.
Here, I want "rtn" value to be returned properly from SUB_ONE function. I am getting value ""(NULL) even after script gets into else loop and set %~1=0 inside SUB_ONE.
Code Snippet:
set rtn=""

FOR /L %%i IN (0, 1, 3) do (
   call :SUB_ONE rtn
   echo "Value of rtn is %rtn%
   if %rtn% NEQ "" ( goto :nextScript )     ## Here, rtn value is not returned as 0 from subroutine even after entering else loop in SUB_ONE function
   echo "Completed wait for %%i time";
   if %%i == "3" ( goto :nextScript )
 )

:SUB_ONE
 bjobs -J main_jobs |  (set /p myVar= )
 if %errorlevel% equ 0 (
    echo  jobs are still there. Waiting for some more time
   sleep 9
 ) else (
     echo jobs are finished
     echo Triggering another job now
     set %~1=0
     echo %rtn% is rtn value
)
exit /B 0

Here, rtn value is not set to 0 inside the for loop, and the condition 'if %rtn% NEQ ""' is never getting true even after it should be. I mean script enters the else loop inside :SUB_ONE, prints statements, set %~1=0, and here on echo %rtn%, I get value 0. But, when the function is exited, it must return value of rtn as 0, but it isn't. And if %rtn% NEQ "" ( goto :nextScript ) is not called (the %rtn% value is still NULL). I would want rtn at line 'if %rtn% NEQ "" ( goto :nextScript )'  to be 0.
Please help.
Thanks!


text:
Q: List overlapping instances of a pattern I'm trying to capture a string and the 21 characters preceding it then output this to a new file. This is what I'm using currently:
    grep -o ".\{21\}gt" ../data/fastadata.txt > primerdata.txt

And I get some of the output I desire, but it skips instances of gt, when any amount of the preceding 21 characters were part of a previous capture string. For example:
aaaatccataaatcgaggattacaagtggaaaacaaggaggcagt

will capture
tccataaatcgaggattacaagt

but not
caagtggaaaacaaggaggcagt

I believe it's, because the two strings would share caagt and the end and beginning of strings 1 & 2 respectively. It ends up missing at least half of all instances.
How do I correct this?
It captures 121 instances of ...gt, but there are something like 200 instances of 21 characters preceding gt in the text file below.
Here is some text from the file I'm searching that contains instances of what I'm talking about (hard-wraps for formatting):
aaaccggcctcaagggaacgggtatgtctgcctcacctgtcggagatctacccaatcccagtctgcatct
aacggacactctaatgcaactgctggactgctgcttcctcaccctaacctgcagtggccaaatcgttttg
gtatccaccagcgtggagcagctattgggtcactgtcagtccgatttgtatggccagaatctactgcaga
tcacgcatcccgatgatcaggatctgttaagacagcagctaatacccagggatatagagaccctgttcta
tcagcatcagcaccaccagcagcaggggcacaatccccagcagcactccacttccacgtcggcctcaact
tcgggcagtgatctggaggaggaggaaatggagacggaggaacaccgtctgggtcggcagcagggagagg
cggacgatgacgaggatcacccgtacaaccgacgaacacccagcccgcggagaatggcccatttggcgac
cattgatgaccgactacgcatggatcggcgctgctttaccgtccgcttggctagggcttccacgcgagcg
gaggccacgcgtcattacgagcgggttaagatcgatggctgctttcgtcgcagtgactcctccttaaccg
gaggtgccgctgccaactatccgattgtctcccagctgatacgacgctcgagaaacaacaatatgctggc
tgctgctgcagcagtggcagcagaagcggcgacggtgccgccccagcacgatgccattgcccaggcggcg
ctgcacgggattagcggcaatgatattgtcctggtggccatggccagggtgctgcgagaggaacggccgc
ctgaggagacggagggtacagtgggcttgaccatttacagacagccagaaccctatcagttggagtacca
tacgaggcatctaatcgacggcagcatcatcgactgtgatcaaaggattggtctggtggcgggatatatg
aaggatgaggtgggtatattaacatcatctctctgaactgcttacgacaactaatcgtgtactctccact
cgaaacaggtgcgcaaccttagtcccttctgtttcatgcacctggacgacgttcgctgggtgattgtggc
ccttcgacaaatgtacgattgcaacagtgactacggcgagagctgctaccgtctgctgtcccgcaacggg
cgcttcatttacctgcacaccaagggatttctggaggtcgaccgtggcagtaataaggtgcattcctttc
tgtgcgtcaacacgctgctcgatgaggaggcgggccggcaaaaggtgcaggagatgaaggagaaattctc
gacaatcatcaaggcggagatgcccacgcagagcagcagtcccgatttgcccgcctcgcaggcaccgcag
caacttgagagaattgtcctctatctaatagagaacctacagaagagtgtggattcagcagagacggttg
gcggccagggcatggaaagcctaatggacgatggctacagttcgccagcaaataccttaactctcgagga
gttagctccctcgcccacgcccgccttggccttggtgccgccggctccctcatcggtcaagagctccatc
tccaagtcggtgagtgtggtcaatgtgacggcggccagaaagtttcagcaggagcatcagaagcagcgtg
aacgtgaccgtgagcagcttaaggagcgcaccaactccacgcagggcgtgatccggcaactgagcagctg
cctaagcgaggcggaaacggcatcctgtatcctatcaccagccagtagcttgagtgccagcgaagcaccg
gacacgcccgatccgcacagcaacacatcaccgccaccgtcgctccacacacgtcccagtgtcctgcatc
gaaccctgaccagcacgctgcgatgacgggctgatggaacctggtttgccttctaattgggtgtgtggaa
atggacgtcattggtagctcacgtgcccacaaacgaattagtatcggtaatataatcctggccaatcgca
aaatgaaaacccaaaatgtatcagaaaaaaacgagcattattcaaatagtttaaaaattcagccaaaaaa
cttaaaaacgaaaaaaaagagcgtgggttgaaaaaccttttgttttcatattcacatttccaagctttga
gcaatcaaacaattttaattttcagtatacacatatgtataatgagttggctttacaaaagctattaaca
aatcaagcaattgtgt

A: I think the issue is that the regex consumes the characters that it matches. You may be able to work around that to some extent using zero-length assertions, if your regex engine supports them.
For example, if you only need to count the occurrences, you could use a PCRE consisting of a single character followed by a lookahead consisting of (21 - 1) characters followed by gt, e.g. in GNU grep with its PCRE mode,
$ printf 'aaaatccataaatcgaggattacaagtggaaaacaaggaggcagt' |
grep -Po '.(?=.{20}gt)'
t
c

which outputs the initial character of each matching substring, allowing overlaps of all but a single character. (You can pipe the result to wc -l for an actual count).
If you need to recover the actual matching strings that is obviously harder, since you need to both consume and not consume characters - probably there is a way to do it by returning the match indices and then doing substring matches, for example something like this in (probably bad) perl
$ printf 'aaaatccataaatcgaggattacaagtggaaaacaaggaggcagt' |
perl -lne 'while ($_ =~ m/.(?=.{20}gt)/g) {print substr($_,@+[0]-1,23)}'
tccataaatcgaggattacaagt
caagtggaaaacaaggaggcagt


text:
Q: Sharepoint 2013 Master Page
I created a SharePoint document library, when user add items with long name the site will push to the Right, can someone please advice how to get this issue resolved?

A: You can use following CSS in the master page
#DeltaPlaceHolderMain {
    width: 400px; /*change this as per your design*/
    overflow: auto;
}


text:
Q: Unable to put constraints to the included layout elements In my android app, I am trying to have a common layout having some basic components that I can reuse in multiple layouts. However, it is not working.
This is my common layout, "common_elements.xml":
<?xml version="1.0" encoding="utf-8"?>

<merge xmlns:android="http://schemas.android.com/apk/res/android">

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/horizontalGuideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.5" />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/verticalGuideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.5" />

    <ProgressBar
        android:id="@+id/progressBar2"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="@+id/horizontalGuideline"
        app:layout_constraintLeft_toLeftOf="@+id/verticalGuideline"
        app:layout_constraintRight_toRightOf="@+id/verticalGuideline"
        app:layout_constraintTop_toTopOf="@+id/horizontalGuideline" />

</androidx.constraintlayout.widget.ConstraintLayout>

</merge>

I am trying to include common_elements like this:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".TL">

    <include android:id="@+id/horizontalGuideline" layout="@layout/common_elements" />
<!-- I have tried including an individual component as well as whole layout.
    Both of these don't work.
    -->

    <include layout="@layout/common_elements"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        />

    <TextView
        android:id="@+id/promptLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Enter"
        app:layout_constraintBottom_toTopOf="@+id/horizontalGuideline"
        app:layout_constraintTop_toBottomOf="@+id/horizontalGuideline"
        app:layout_constraintLeft_toRightOf="@+id/verticalGuideline"
        app:layout_constraintRight_toLeftOf="@+id/verticalGuideline"
        android:layout_marginLeft="12dp"
        />

</androidx.constraintlayout.widget.ConstraintLayout>

Observed Behaviour
In the common layout I have things like guidelines and progressbar, which I don't want to define in each layout file. In the new layout I am trying to put constraints with respect to the guidelines defined in the included layout.
However, the elements in new layout are not honouring those constraints and are jumping to the beginning of the screen.
I have tried solutions like including merge tag, giving height/width to included layout, including just one component instead of whole layout.
None of these worked.
What am I doing wrong?


text:
Q: Canvas Slideshow with slider I wanted to create canvas slideshow with speed controller. But slider is not working. It's not controlling the speed of slideshow.
I can change the value manually from setinterval value but I want to control when I move the slider but it's not working. Other than that everything working fine.
Here is my code:
<!DOCTYPE html>

<title>Page Title</title>

 Slider

<canvas id="myCanvas" width="400" height="300"
style="border:1px solid #d3d3d3;">
</canvas>

    <input id="speed" name="speed" type="range" min="1" max="5" value="3">

Value:

A: There are two main problems with this code:

*

*the new interval is not being set when the slider is moved

*the speed settings are reversed so that a 5 gives an interval of 5 seconds and 1 gives an interval of 1 second.

For the first problem we need to reset the interval by calling setInterval BUT be aware that if you just did that you would set up a new interval timer each time the slider is moved but the old one would still be running, so you'd get some odd timing effects (and eventually even run into storage problems).
On setting a time interval you must clear any previous setting.
For the speeds being the wrong way round this snippet simply subtracts the slider value from 6 to give 1second when the value is 5 and 5 seconds when the value is 1. If you are thinking of experimenting with different ranges put in some more sophisticated code which will calculate the desired interval from any range.

            var slider = document.getElementById("speed");
            var output = document.getElementById("speedValue");
            var speedMod= 3;
            let interval; //will be set by setInterval

            output.innerHTML = slider.value;

            slider.oninput = function() {
            output.innerHTML = this.value;
            speedMod = this.value;
            clearInterval(interval);
            interval = setInterval(draw_next_image, (6-speedMod)*1000);
            }

var image0 = new Image();
image0.src = "http://placekitten.com/200/300";
var image1 = new Image();
image1.src = "http://placekitten.com/205/305";
var image2 = new Image();
image2.src = "http://placekitten.com/300/400";
var image3 = new Image();
image3.src = "http://placekitten.com/800/600";

images = new Array(image0, image1, image2, image3);

var counter = 0; var ctx;
function draw(){
    myCanvas = document.getElementById("myCanvas");
    ctx = myCanvas.getContext("2d");

}
function draw_next_image(){
    ctx.clearRect(0, 0, myCanvas.width, myCanvas.height);
    ctx.drawImage(images[counter], 0, 0);
    counter++;
   if (counter==images.length) {counter=0;}
    ;

}
clearInterval(interval);
interval = setInterval(draw_next_image, (6-speedMod)*1000);
window.onload = draw;

 Slider

<canvas id="myCanvas" width="400" height="300"
style="border:1px solid #d3d3d3;">
</canvas>

    <input id="speed" name="speed" type="range" min="1" max="5" value="3">

Value:

Incidentally, there is a pause at the start before an image is seen as the canvas is drawn before the image is loaded (the window.onload is not doing anything in this situation).


text:
Q: NPE in setText with TextView with AsyncTask in onPostExecute inside a Fragment I'm having a problem: I am developing an android app where I have to parse some information.I am parsing information from a url using AsyncTask, I've succesfully parsed some info and in the method onPostExecute() I call a method that displays the parsed info in a TextView that will be displayed in a Fragment. My app is separated by Fragments, but everytime I run my app I get a NullPointerException in the line where I set the text in a TextView called title.
In onPostExecute I call the method displayText() and inside this method, I update the title variable. Here's part of the code so you can easily understand:
This is the Fragment
public class WeatherActivity extends Fragment{

TextView title;

public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
    super.onCreateView(inflater, container, savedInstanceState);
    View view=inflater.inflate(R.layout.weather_activity, container,false);
    title=(TextView)view.findViewById(R.id.weatherTitle);
    return view;
}

public void displayWeather(Weather weather){
    title.setText(weather.getTitle());//this is the line that gives me the NPE
}
}

 This is the class that makes the parsing
public class WeatherManager extends AsyncTask<Void,Void,Void>{

public static final String WEATHER_URL="some url";
Weather weather;
WeatherActivity wa=new WeatherActivity();
@Override
protected Void doInBackground(Void... params) {
    loadXML();//does the parsing
    return null;
}

 protected void onPostExecute(Void result) {
    wa.displayWeather(weather);//calls to update fragment
}

public void loadXML(){
    //does all the work and returns the info in an object weather
}

}

This is my xml. For the moment, I only have one TextView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<TextView
    android:id="@+id/weatherTitle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:textAppearance="?android:attr/textAppearanceLarge" />

And this is my LogCat
E/AndroidRuntime(27441): FATAL EXCEPTION: main
E/AndroidRuntime(27441): Process: com.example.test23, PID: 27441
E/AndroidRuntime(27441): java.lang.NullPointerException
E/AndroidRuntime(27441):    at com.example.test23.WeatherActivity.displayWeather(WeatherActivity.java:25)
E/AndroidRuntime(27441):    at com.example.test23.WeatherManager.onPostExecute(WeatherManager.java:30)
E/AndroidRuntime(27441):    at com.example.test23.WeatherManager.onPostExecute(WeatherManager.java:1)

Edit
This is my MainActivity that creates the tabs/fragments
public class MainActivity extends FragmentActivity{
    private String tabs[]={"Some String that will display the name of the tabs"};
    ViewPager viewPager=null;
    FragmentManager fragmentManager=getSupportFragmentManager();
    AdapterView adapterView;
    private Fragment fragment;
    private Activity activity;
    static List<Item> news=new ArrayList<Item>();
    ArrayList<Item> sports=new ArrayList<Item>();
    ArrayList<Item> articles=new ArrayList<Item>();
    public static final int TIME_ENTRY_REQUEST_CODE=1;
        static ParseManager parser=new ParseManager();
    JSONManager jmanager=new JSONManager();
    WeatherManager weather=new WeatherManager();

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressLint("NewApi")

@Override

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    viewPager=(ViewPager)findViewById(R.id.pager);
    viewPager.setAdapter(new AdapterView(fragmentManager));
    viewPager.setOffscreenPageLimit(6);
    adapterView=new AdapterView(getSupportFragmentManager());
    final android.app.ActionBar actionbar=getActionBar();
    ColorDrawable color=new ColorDrawable(Color.parseColor("#cd853f"));
    actionbar.setBackgroundDrawable(color);

    actionbar.setTitle("App title");
    ActionBar.TabListener tabListener=new ActionBar.TabListener() {
        @Override
        public void onTabUnselected(Tab tab, FragmentTransaction ft) {

        }

        @Override
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            viewPager.setCurrentItem(tab.getPosition());

        }

        @Override
        public void onTabReselected(Tab tab, FragmentTransaction ft) {

        }
    };
    /*Displaying Tabs for the app */
    for(int i=0;i<tabs.length;i++)          actionbar.addTab(actionbar.newTab().setText(tabs[i]).setTabListener(tabListener));
    actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionbar.setSelectedNavigationItem(position);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
    parser.execute();//Asynctask
    jmanager.execute();
    weather.execute();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

public void onDestroy(){
    super.onDestroy();
}

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.option1:
            Intent intentContact=new Intent(this,SomeClass.class);
            startActivityForResult(intentContact,TIME_ENTRY_REQUEST_CODE);
              return true;
        case R.id.option2:
            Intent intentAbout=new Intent(this,SomeOtherClass.class);
            startActivityForResult(intentAbout,TIME_ENTRY_REQUEST_CODE);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}

public void onRefreshClicked(MenuItem refresh);
}

}
Any help is appreciated, if you need more information please let me know. Thanks in advance.

A: I see a couple of problems:
1) You shouldn't instantiate an Fragment by calling its constructor. It is Android's job to do that for you via the FragmentManager class.
2) You are trying to use the wa Fragment variable to call a method on it. While this makes sense in regular Java classes. Fragments have their own lifecycle. Part of this lifecycle is the onCreateView() state. In onCreateView() the systems expects you to inflate the layout you want to display. Now, you are creating an instance of an Fragment by calling its constructor, and immediately after, you are calling a method that references a TextView that hasn't been inflated yet; hence there is no TextViewso it is null.

A: As @emmanuel explained, onCreateView inside fragment in not called until your fragment is attached to an activity. Consequently, textView is not initialized and is null.
You should not call any method on fragment object before displaying it.
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.your_placehodler, new YourFragment());
ft.commit();

After this line onCreateView of fragment gets called and the view returned by this is displayed inside R.id.your_placehodler on your activity.
Calling displayWeather now will not cause NLP.


text:
Q: Can I get user's phone number by requesting for permission in ios 6? I am building an IOS6 app which requires the user's phone number,
Is there a way to ask the user for permission and get the number in programmatic way?
Or he has to manually type it in?
I am using Xcode 4.5 if it matters..

A: You can't get the phone via any easy API within iOS.  There might be a way to do it via the technique described in this related question, but this is a few years old and Apple may have closed this hole (which uses an undocumented key). I also wonder if Apple wouldn't allow the app on the App Store for privacy reasons. Probably not.
You'll have to trust the user to type in the correct phone number if you prompt him/her to.


text:
Q: When will this break? I've got a trigger that originally just converted the members of a Campaign into a text string in order to create a "CC List" for mailmerges.  Worked brilliantly.  However, over time I've been asked to add bits and pieces, and now the trigger is more of a 'class' than just a trigger.  Other than needed to now make this a class, what other risks can you see in what the code is trying to do?  Basically, what is going to cause this to break?  Also, any best practice suggestions regarding how this is currently written?
trigger UpdateQuarterlyLetterCampaign on CampaignMember (after insert, after update) {
    list<campaignMember> newMember = trigger.new;
    list<campaignMember> allMembers = new list<campaignMember>();
    set<id> campID = new set<ID>();
    campaign thisCampaign;
    string ccText = '';

for (campaignmember cmCheck: newMember){
    campID.add(cmCheck.CampaignId);
}

if(campID.size() != 1){
    }
else{
    thisCampaign = [select id, name, cc_list__c, recordtypeid, recordtype.name from campaign where id in :campID ];
    allMembers = [select id, firstname, lastname, cc_order__c, CompanyOrAccount from campaignMember where campaignid in :campID and cc_order__c <> 'Primary' and cc_order__c <> '' order by cc_order__c];
    system.debug('AllMembers is this big:'+allMembers.size());
        if(allMembers.size() > 15){
            thisCampaign.cc_list__c = 'A maximum of 15 CC names can be added to this Campaign';
            }
        else{
            if(thisCampaign.recordtype.name == 'Asset Management Quarterly Letter'){
                for(campaignmember am: allMembers){
                ccText = ccText + am.FirstName +' '+ am.lastname +' - '+ am.CompanyOrAccount +'\r\n';
                thisCampaign.cc_list__c = ccText;
                }
            }
        }
}
update thisCampaign;
}

Trigger code updated to "update outside of loop"
Another update to pull SOQL out of loop.

A: There are some simplifications you can do and also much fewer variable names
trigger UpdateQuarterlyLetterCampaign on CampaignMember (after insert, after update) {

    set<ID> cIdSet = new set<ID> ();  // campaigns in the triggered CampaignMembers
    for (CampaignMember cm: Trigger.new)
        cIdSet.add(cm.campaignId);

    // get all campaigns and their CampaignMembers in the trigger list
    map<ID,Campaign> cIdToCampaignMap = new map<ID,Campaign> (
                                            [select id, recordType.name
                                              (select id, firstName, lastName, companyOrAccount
                                                 from CampaignMember
                                                 where cc_order__c <> 'Primary' and
                                                        cc_order__c <> ''
                                                )
                                              from Campaign
                                              where id IN :cIdSet]);
    for (Campaign c: cIdToCampaignMap.values()) {
        if (c.campaignMembers.size() > 15)
            c.cc_list__c = 'Max 15 cc';
        else {
            c.cc_list__c = '';
            for (CampaignMember cm : c.campaignMembers)
                c.cc_list__c += c.recordType.name = 'Asset Mgt...'
                                    ? cm.firstName + ' ' + cc.lastName + ' ' + cc.companyOrAccount + '/r/n'
                                    : '';
        }
    }
    update cIdToCampaignMap.values();
}

Your business logic is a bit weird in that you check for 15+ members of any recordtype and decide that is too many but you appear to only really care about 15 asset mgt members. I'll leave that change to you (hint, extend the soql where clause).


text:
Q: Journaling Backup Is there any software that takes journaled backups for Ubuntu?
I'm currently using the built-in deja-dup, which is great. However, it backs up at most once every 24 hours (daily). Is there any way to have a backup system in Ubuntu that backs up a file every time it's changed?
Also: Could and/or would it make sense for a file-level backup system make use of ext4's journaling features? Or am I misunderstanding ext4 as a "journaling filesystem"?
EDIT: Perhaps ext4 journaling is ill-suited for this task. In that case, is there software that runs a daemon tracking real-time file changes, and backs up accordingly?

A: *

*Take a look at bup. It's a git-based backup software, which is in an early stage, but looks very promising and last time I checked, they did plan to implement a file notification based backup system. I guess it's best to check out the mailing list for the current status.
edit: I forgot to mention, there's a gui available, named Kup.

*Another possible tool is inosync, which actually supports inotify-based realtime backups in combination with rsync.

A: Do not confuse a "journaled filesystem" with a "backup system".
A journaled filesystem is more robust, is journaled to keep track of the variations on the filesystem and, in case something goes wrong, recover that filesystem.
This has nothing to do with your data on that filesystem, you can loose your data and have a perfectly healty filesystem fully recovered.
To answer your question i think that a cron job and rsync could be the tools that you need.
https://help.ubuntu.com/community/CronHowto
https://help.ubuntu.com/community/rsync


text:
Q: Keep track of MS access updated records I have a bound MS Access form which is updated by multiple users.
I want to keep track of any edits by the users. Currently i record whenever a record is updated by using the timestamp and username.environ function
However i would like to track the changed contents as well with an inactive flag.
For example my record is
101 | Software | Jan-2017  | $5600 | Expense for Software (desc) | Active
If someone was to make any change to it, i would like the changed record to be considered active but keep this record as inactive.
Any suggestions appreciated

A: The traditional way to do this sort of thing is with some sort of a flag on the record to indicate the current record (be it a boolean or a sequence number or a date stamp).
Then when you are working with the current data and you end up working on a selection from the table, pruning it down to just what is current (i.e., an sql statement with where archive_date is null or where active = 'T' or you could do it one the max value for the sequence/date stamp).
That style presents certain problems for bound forms. So your mileage may vary.
My quick and dirty way out of this would be to make a data history table (parallel structure to the one your working with, with an extra date/time field and a userid field), and then add a trigger (ideally at the database level, but you could do it on the controlling form) to log the new value in the history table.


text:
Q: Unable to display PrimeNg toasts when switching pages I'm trying to use the PrimeNg Toasts to confirm the deletion of one user.
Basically, here is my code:
  deleteUser() {
    this.confirmationService.confirm({
      message: this.translateService.instant('common.messages.deletion-confirm'),
      header: this.translateService.instant('common.messages.deletion-title'),
      icon: 'fa-light fa-triangle-exclamation',
      acceptLabel: this.translateService.instant('common.messages.ok'),
      rejectLabel: this.translateService.instant('common.messages.cancel'),
      rejectButtonStyleClass: 'p-button-secondary p-button-text',

      accept: async () => {
        await this.userSettingsService.deleteUser(this.store.selectSnapshot(state => state.userSettings.activeUser.id));
        this.messageService.add({ severity: 'success', summary: 'User deleted', detail: 'User deleted successfully' });
      },
    });
  }

The userSettingsService will call the backend and ask for a route change(to go to the user list) in case of success.
According to my tests, the messageService only tries to display a toast in the current component, if I set a component in a parent component(like my layout component), it is just not displayed.
Since I'm transitioning from my user page to the user list page, I'm not sure how it would be possible to set a <p-toast>.
I've tried to put:

*

*one in a parent component

*one in the user detail page

*one in the user list page

*one at each page

But nothing gets displayed. Any idea?

A: You can put <p-toast> in app.component.ts.
In another cause, Make sure you provided only single MessageService in app.module.ts.


text:
Q: Cycle through a resource until all the parameters are satisfied I am trying to log a process; this process has 3 states, and they are sequential, so A->B->C; they can happen only in this sequence.
The only way that I have to follow this process is through a function, that return the current state of a specific type analyzed, that is passed to the function.The return data from a function (it is a list), which looks like this:
[typeX, date, time, process running]
compound, 12/12/14, 10:20, A

I need to be sure that a specific type, goes from A to B and then C. I am using this in a chemical analysis application, that parse results coming from a machine. I can't do nothing beside use the API that the machine supply; and this function is one of them. You can run it any time you want; it will always return the info about a specific type.
my approach:
running = True
while running:
    return_value = myfunction(type)
    if A in return_value[3]:
        valueA = True
        print "found A"
    if B in return_value[3]:
        valueB = True
        print "found B"
    if C in return_value[3]:
        valueC = True
        print "found C"
    if valueA and valueB and ValueC:
        running  = False
        print "Done"

This works, but it looks not really elegant IMO; since every time I run the function, it will verify again all the if conditions, even if I already found one or 2 of them. Not a big concern for my example, but I have to run this on a process that deal with thousands of entry, so performances may be an issue in the long run. Also if I call the function and it return the same value, I  get printed the value over and over:
found A
found A
[value change]
found B
found B
found B
[value change]
found C
Done

Pretty sure that there is a better way; if I put a sleep in the while loop, I may loose state B, and get only A and C, if I do it too often, I will get print on screen that goes on forever, printing the same string, since the value didn't change.
The final result should be one print per type; in this way I don't get a long output. What would be a good pythonic way to do so?

A: Few ideas come to mind.
Simplest approach to the "one print per type" would be just to add a check for each value in the if statement (provided you have them set to False somewhere)
if A in return_value[3] and not valueA:
You could simplify it a bit like this:
a_found = b_found = c_found = False

while not (a_found and b_found and c_found):
    return_value = myfunction(type)
    if A in return_value[3] and not a_found:
        a_found = True
        print("found A")

    [...]

print("Done")


text:
Q: Importing a module in haskell makes the code not compile I wrote the following haskell code for test. It compiles fine with ghc (version 8.0.2), and prints 20, as expected.
f x = x * 2

main = print $ f 10

But when I import Char module like this:
module Data.Char

f x = x * 2

main = print $ f 10

it gives me this error: test.hs:3:1: error: parse error on input 'f'.
Does haskell change the environment when a module is imported? What is the difference and am I importing the module wrong?

A: module does not import modules; import does:
import Data.Char


text:
Q: Chisel Cannot reassign to read-only This is a continuation from the other question i asked : Instanciation of a class doesn't work (Chisel/Scala)
Actually, I wanna print the "result" variable. I wrote this command :  sbt test, and I don't understand this error :
"chisel3.internal.ChiselException: Cannot reassign to read-only combinedTausworthe.b: OpResult[UInt<32>] "
This is the Test file
import chiseltest._
import org.scalatest.freespec.AnyFreeSpec

class combined_test extends AnyFreeSpec with ChiselScalatestTester {
  "combinedTauswhore" in {

    test(new combinedTausworthe() ){ c =>
      //Initialisation
       c.clock.step(1)
      println(c.result)

      c.clock.step(1)
      println(c.result)

    }

  }

}

This is the class :

import chisel3._

 class combinedTausworthe extends Module{
   val io = IO(new Bundle {
   })
   val seed1 = RegInit(322769304.U(32.W))
   val seed2 = RegInit(424235419.U(32.W))
   val seed3 = RegInit(212119443.U(32.W))
   var result= 0.U

   var b = ((seed1 << 13)(31,0) ^ seed1)
   seed1 := ((seed1 & 4294967294L.U) << 12)(31,0) ^ b
   b := ((seed2 << 2)(31,0) ^ seed2) >> 25
   seed2 := ((seed2 & 4294967294L.U) << 4)(31,0) ^ b
   b := ((seed3<<3)(31,0) ^ seed3) >> 11
   seed3 := ((seed3 & 4294967294L.U) <<17)(31,0) ^ b

   result := (seed1 ^ seed2 ^ seed3)

 }

object Main extends App {

}

A: In Chisel3, := is the connection operator for driving a signal with some value. Think about it as creating an electrical connection. In your code, it looks like you are trying to reassign to a mutable variable rather than drive the value of that variable with a value, try =:
import chisel3._

class combinedTausworthe extends Module{
  val io = IO(new Bundle {
  })
  val seed1 = RegInit(322769304.U(32.W))
  val seed2 = RegInit(424235419.U(32.W))
  val seed3 = RegInit(212119443.U(32.W))
  var result= 0.U

  var b = ((seed1 << 13)(31,0) ^ seed1)
  seed1 := ((seed1 & 4294967294L.U) << 12)(31,0) ^ b
  // Note using assignment (=), not connection (:=)
  b = ((seed2 << 2)(31,0) ^ seed2) >> 25
  seed2 := ((seed2 & 4294967294L.U) << 4)(31,0) ^ b
  b = ((seed3<<3)(31,0) ^ seed3) >> 11
  seed3 := ((seed3 & 4294967294L.U) <<17)(31,0) ^ b

  // Same thing here
  result = (seed1 ^ seed2 ^ seed3)
}

That being said, as Scala is a functional programming language and we stylistically prefer pure/immutable constructs, try just using values:
import chisel3._

class combinedTausworthe extends Module{
  val io = IO(new Bundle {
  })
  val seed1 = RegInit(322769304.U(32.W))
  val seed2 = RegInit(424235419.U(32.W))
  val seed3 = RegInit(212119443.U(32.W))
  // Note result var removed and replaced with val below

  val b1 = ((seed1 << 13)(31,0) ^ seed1)
  seed1 := ((seed1 & 4294967294L.U) << 12)(31,0) ^ b1
  val b2 = ((seed2 << 2)(31,0) ^ seed2) >> 25
  seed2 := ((seed2 & 4294967294L.U) << 4)(31,0) ^ b2
  val b3 = ((seed3<<3)(31,0) ^ seed3) >> 11
  seed3 := ((seed3 & 4294967294L.U) <<17)(31,0) ^ b3

  val result = (seed1 ^ seed2 ^ seed3)
}


text:
Q: Clear memory of All Images - c# Telerik WinForms my program is a CRM, I used Rad Ribbon Bar, so Many Buttons with images, RadGridView (which some columns contain images) and so many other controls which contain images. It's a mdi parent/child program. In so many cases while loading a mdi child or working with some grid views the program will hang and give me this error:
OutOfMemoryException occurred in System.Drawing.dll
I can not find where and which image causes this error, nothing will show just the error title.
I tried GC.Collect() on certain parts but no success.
So How can I find which image or control is causing this problem or how can I clear all images from the memory before loading a mdi child?
UPDATED:
as for codes, really for setting images there is no code! for example for setting an image for a button I used its properties in visual studio. I have set All other control images in this way using the properties panel in visual mode.

and These are some designer codes related to drawing:
    this.backStage.Size = new System.Drawing.Size(1151, 625);

    this.MainRibbonBar.Font = new System.Drawing.Font("B Nazanin", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(178)));

    this.btnCustomerList.Image = global::MihmanyCRM.Properties.Resources.CustomerList32;

    gridViewCommandColumn1.Image = global::MihmanyCRM.Properties.Resources.ViewShop32;


text:
Q: How to know the server in reachable or not in android? Hi, I want to know is my website in reachable or available?
whit this method I know my device is online or not:
protected boolean isOnline() {

        ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = cm.getActiveNetworkInfo();
        if (netInfo != null && netInfo.isConnectedOrConnecting()) {
            Toast.makeText(this, "You are connecting to Internet!", Toast.LENGTH_LONG).show();
            return true;
        } else {
            Toast.makeText(this, "You are not connecting to Internet!", Toast.LENGTH_LONG).show();
            return false;
        }
    }

and with this method I want to know is URL available or not:
public boolean isServerReachable(String serverURL) {

        ConnectivityManager connMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = connMan.getActiveNetworkInfo();
        if (netInfo != null && netInfo.isConnected()) {
            try {
                URL urlServer = new URL(serverURL);
                HttpURLConnection urlConn = (HttpURLConnection) urlServer.openConnection();
                urlConn.setConnectTimeout(3000); //<- 3Seconds Timeout
                urlConn.connect();
                if (urlConn.getResponseCode() == 200) {
                    Toast.makeText(this, "Server is Available", Toast.LENGTH_LONG).show();
                    return true;
                } else {
                    Toast.makeText(this, "Server is not Available", Toast.LENGTH_LONG).show();
                    return false;
                }
            } catch (MalformedURLException e1) {
                return false;
            } catch (IOException e) {
                return false;
            }
        }
        return false;
    }

then I create a Button, when clicked this two method will call, like this:
if (isOnline()) {
    isServerReachable("https://www.google.com/");
 }

when I click the Button if WiFi is Off this Message will show:

You are not connecting to Internet!

and when WiFi is On this error will show:
> Process: com.rastari.salar.salytest, PID: 3864
>     android.os.NetworkOnMainThreadException
>             at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147)
>             at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
>             at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
>             at java.net.InetAddress.getAllByName(InetAddress.java:215)
>             at com.android.okhttp.HostResolver$1.getAllByName(HostResolver.java:29)
>             at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:232)
>             at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:124)
>             at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:272)
>             at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
>             at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:382)
>             at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)
>             at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
>             at com.android.okhttp.internal.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:25)
>             at com.rastari.salar.salytest.MainActivity.isServerReachable(MainActivity.java:78)
>             at com.rastari.salar.salytest.MainActivity$1.onClick(MainActivity.java:37)
>             at android.view.View.performClick(View.java:4780)
>             at android.view.View$PerformClick.run(View.java:19866)
>             at android.os.Handler.handleCallback(Handler.java:739)
>             at android.os.Handler.dispatchMessage(Handler.java:95)
>             at android.os.Looper.loop(Looper.java:135)
>             at android.app.ActivityThread.main(ActivityThread.java:5254)
>             at java.lang.reflect.Method.invoke(Native Method)
>             at java.lang.reflect.Method.invoke(Method.java:372)
>             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
>             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 06-25
> 06:14:16.845    1557-1557/? E/EGL_emulation﹕ tid 1557:
> eglCreateSyncKHR(1207): error 0x3004 (EGL_BAD_ATTRIBUTE) 06-25
> 06:14:17.614    1708-1891/? E/WifiStateMachine﹕ CMD_START_SCAN :
> connected mode and no configuration

How can I determine that the server is available or not?
Thank u.

A: Call your method isServerReachable() from an Asynctask.
Since your doing a network call on main thread of your application, it crashes.

A: The error is due to isServerReachable() method because you are doing the networking operations in the UI thread, which will result NetworkOnMainThreadException. Instead to running them directly execute the method in a AsyncTask or another worker Thread.
 public class MyAsyncTask extends AsyncTask<Void, Void, Boolean> {
        @Override
        protected Boolean doInBackground(Void... params) {
            return isServerReachable(URl);
        }

        @Override
        protected void onPostExecute(Boolean aBoolean) {
            super.onPostExecute(aBoolean);
            //Perform operations.
        }
    }


text:
Q: Dictionary to datetime I am looking to convert a string which is a date '31-Dec-2018' to datetime object: datetime.date(2018, 12, 31). Is there any built in method that can be helpful ?
Say I have a dictionary basedate that has date in it. I have to convert it to datetime object. I am trying this:
basedate = {date: '31-Dec-2018'}
datetimetime.strptime(basedate, '%dd-%MMM-%yyyy')

I am getting an error while converting the string to datetime which states that it does not match the %dd-%MM-%yyyy format

A: You need to use the correct format: https://docs.python.org/3/library/datetime.html?#strftime-strptime-behavior
And parse the actual string, not the dictionary.
datetime.strptime('31-Dec-2018','%d-%b-%Y')

A: Here's a solution to your specific problem:
First correct your dictionary as:
basedate = {'date': '31-Dec-2018'}
Code:
from datetime import datetime

basedate = {'date': '31-Dec-2018'}
basedate = datetime.strptime(basedate['date'], '%d-%b-%Y').date()


text:
Q: Load CreateJS canvas from json data I use create.js library and want to load canvas objects from json data and import canvas object to json.
Previously I used fabric.js and there was function:
canvas.loadFromJSON(jsonData, function() {});

and
to import canvas to JSON data canvas.toJSON() or canvas.toDatalessJson(),
so I'm interested if this is possible in create.js too?
if yes how i can do it?


text:
Q: Get value from Directive into Controller So I have this filter directive:
app.directive('filter', function(){
  return {
    restrict: 'E',
    transclude: true,
    scope: {
        callFunc: '&'
    },
    template:
            '
' +
            '

' +
            '
',
    controller: function($scope, $element, $attrs){
        this.getData = function() {
            $scope.callFunc()
        }
    }
  }
});

app.directive('positions', function(){
  return {
    require: '^filter',
    scope: {
        selectedPos: '='
    },
    template:
            '  Positions: {{selectedPos}}' +
            '
' +
            '
' +
            '           {{pos.name}}' +
            '
' +
            '
',
    controller: function($scope, $element, $attrs){
          $scope.positions = [
            {name: '1'},
            {name: '2'},
            {name: '3'},
            {name: '4'},
            {name: '5'}
          ];
          $scope.selectedPos = $scope.positions[0].name;
          $scope.setPosition = function(pos){
            $scope.selectedPos = pos.name;
          };

    },
    link: function(scope, element, attrs, filterCtrl) {
        scope.posRegData = function() {
            filterCtrl.getData();
        }
    }
  }
})

And the controller:
app.controller('keyCtrl', ['$scope', function($scope) {
  var key = this;
  key.callFunc = function() {
    key.value = key.selectedPos;
    console.log(key.selectedPos)
  }
}]);

The main question is why the key.selectedPos in the controller get's the right value only on the second click?
Here is a plunker replicating my issue.

A: You can send a param when you call your callFunc().
Update your func in the ctrl: key.callFunc = function(filterParams), also don't forget to update you passed method call-func="key.callFunc(filterParams)
In filter directive change your getData method to:
this.getData = function(val) {
  $scope.callFunc({filterParams: val})
}

In positions directive pass the value that you need:
scope.posRegData = function() {
  filterCtrl.getData({position: scope.selectedPos});
}

Now in your keyCtrl you can get the value:
key.callFunc = function(filterParams) {
  key.value = filterParams.position;
  console.log(filterPrams.position)
}

Here is a working plunker

A: You can use $broadcast on the $rootScope
in your controller do:
$rootScope.$broadcast('myEvent', $scope.selectedPos);

in your target controller you then have a listener:
$scope.$on('myEvent', function(event, myData){...})

angularJS documentation $on
and a plunker

A: As suggested, I think an isolated scope works:
app.directive('positions', function(){
  return {
    require: '^filter',
    scope : {
      selectedPos: '='
    },
    template:
        '<button dropdown>' +
        '    {{selectedPos}}' +
        '
' +
        '
' +
        '      {{pos.name}}' +
        '
' +
        '
' +
        '</button>',
    controller: function($scope, $element, $attrs){
          $scope.setPosition = function(pos){
            $scope.selectedPos = pos.name;
          };
          $scope.positions = [
            {name: '1'},
            {name: '2'},
            {name: '3'}
          ];
          $scope.selectedPos = $scope.positions[0].name;
    }
  }
});

See:http://plnkr.co/edit/boKjmMmsCCZem0lETT3B?p=preview


text:
Q: C++ Looking for the Element with the highest occurrence in an array I'm looking for an elegant way of determining which element has the highest occurrence (mode) in a C++ ptr array.
For example, in
{"pear", "apple", "orange", "apple"}

the "apple" element is the most frequent one.
My previous attempts have failed
EDIT: The array has already been sorted.
int getMode(int *students,int size)
{
    int mode;
    int count=0,
    maxCount=0,
    preVal;

    preVal=students[0]; //preVall holds current mode number being compared
    count=1;
    for(int i =0; i<size; i++) //Check each number in the array
    {
        if(students[i]==preVal) //checks if current mode is seen again
        {
            count++; //The amount of times current mode number has been seen.
            if(maxCount<count)  //if the amount of times mode has been seen is more than maxcount
            {
                maxCount=count; //the larger it mode that has been seen is now the maxCount
                mode=students[i]; //The current array item will become the mode
            }else{
                preVal = students[i];
                count = 1;
            }

        }

    }

    return mode;
}

A: There are several possible solutions to that problem, but first some advice:
Don't use C-style arrays. Use std::array for fixed (compiletime) size arrays or std::vector for arrays on the heap (or C++14's std::dynarray if the array size is determined at runtime but does not change after creation). Those containers do the memory management for you, and you do not need to pass the array size around separately. In addition to using containers, prefer to use the algorithms in <algorithm> where appropiate. If you don't know the containers and algorithms, take some time to get familiar with them, that time will pay off very soon.
So, here are some solution sketches:

*

*Sort the array, then count the ocurrences of consecutive values. It's much easier than to keep track of which values you have already counted and which not. You basically need only two value-count pairs: one for the value you are currently counting, one for the maximum count up to now. You will only need a fifth variable: the iterator for the container.

*If you cannot sort your array or need to keep track of all counts, use a map to map values to their number of occurrence in the array. If you are familiar with std::map, that is very simple to do. At the end, search for the maximum count, i.e. for the maximum map value:
for (auto i: students) countMap[i]++;
auto pos = std::max_element(begin(countMap), end(countMap),
  [](auto lhs, auto rhs){ return lhs.second < rhs.second }); //! see below
auto maxCount = pos->second;

Note: this uses C++11's range based for and a C++14 polymorphic Lambda. It should be obvious what is done here, so it can be adjusted for the C++11/C++14 support your compiler provides.


text:
Q: How do I add a legend to a ggplot with multiple groups that have multiple columns of data in a dataframe I have a 60x13 dataframe that contains 4 groups of data, 1 column is time in months 1-60, 1 column is for the median value at timepoint n and 2 for the credible intervals at time point n. I want to produce a plot that has a solid line for the median and dashed lines for the confidence intervals over time, I've been able to do this by adding each column as it's own geom_line and grouping manually by matching the colours of the medians and their corresponding credible intervals, however, I am unable to add a legend. Any help would be appreciated thanks.
ggplot(data=data1,
       aes(x=month)) +
  xlab("Month") +
  ylab("Hazard Ratio") +
  theme(plot.title = element_text(hjust = 0.5)) +
  geom_line(aes(y=median),
            color = "#4682B4",
            size = 1) +
  geom_line(aes(y=ucrd),
            color = "#4682B4",
            linetype=2,
            size = 0.9,
            alpha=0.5) +
  geom_line(aes(y=lcrd),
            color = "#4682B4",
            linetype=2,
            size = 0.9,
            alpha=0.5) +
  geom_line(aes(y=median.1),
            color = "#4BB446",
            size = 1) +
  geom_line(aes(y=ucrd.1),
              color = "#4BB446",
            linetype=2,
            size = 0.9,
            alpha=0.5) +
  geom_line(aes(y=lcrd.1),
            color = "#4BB446",
            linetype=2,
            size = 0.9,
            alpha=0.5) +
  geom_line(aes(y=median.2),
          color = "#AF46B4",
          size = 1) +
  geom_line(aes(y=ucrd.2),
            color = "#AF46B4",
            linetype=2,
            size = 0.9,
            alpha=0.5) +
  geom_line(aes(y=lcrd.2),
            color = "#AF46B4",
            linetype=2,
            size = 0.9,
            alpha=0.5) +
  geom_line(aes(y=median.3),
            color = "#B47846",
            size = 1) +
  geom_line(aes(y=ucrd.3),
            color = "#B47846",
            linetype=2,
            size = 0.9,
            alpha=0.5) +
  geom_line(aes(y=lcrd.3),
            color = "#B47846",
            linetype=2,
            size = 0.9,
            alpha=0.5)
scale_color_manual(name= "Treament",
                     values=c("4682B4", "4BB446", "AF46B4", "B47846"),
                       labels=c("a",
                                "b",
                                "c",
                                "d"
                       ))

A: This sounds a lot like a data shape problem. Since no data was provided, here is an example with dummy data.
First we generate some data roughly in the shape of what you mention in the text.
library(tidyr)
library(ggplot2)

n <- 60
df <- data.frame(
  time = seq_len(n),
  group1_median = rnorm(n),
  group1_low = rnorm(n, -2),
  group1_high = rnorm(n, 2),
  group2_median = rnorm(n),
  group2_low = rnorm(n, -2),
  group2_high = rnorm(n, 2),
  group3_median = rnorm(n),
  group3_low = rnorm(n, -2),
  group3_high = rnorm(n, 2),
  group4_median = rnorm(n),
  group4_low = rnorm(n, -2),
  group4_high = rnorm(n, 2)
)

Now, we are going to reshape this from a wide format to a long format. What exactly the following function should look like depends a lot on the column names of your data. I chose the dummy data column names to be pretty easy.
df <- pivot_longer(
  df, -time,
  names_to = c("group", "metric"),
  names_sep = "_"
)

Because median, low and high are now regarded as seperate observations, we need to reshape the data again to make it slightly wider.
df <- pivot_wider(
  df, names_from = "metric"
)

Then it is in pretty decent shape to put into ggplot2, and the legend will sort out itself.
ggplot(df, aes(time, colour = group)) +
  geom_line(aes(y = median)) +
  geom_ribbon(aes(ymin = low, ymax = high),
              linetype = 2, fill = NA)

If anyone has more appropriate reshape strategies, I'd love to hear them because I'm still learning to pivot correctly too.


text: Q: How can I control the order of attributes in my xml serialization? Is there a way to have the System.Xml.Serialization serialize attributes in a specific order?  I am creating  new xml export and the attributes are not in the same order currently.  I know that attribute order should not matter, but I have to send this xml to servers that may not have such enlightened ideas.


text:
Q: Is it possible to change workflow primary entity in Dynamics CRM 365? I have created a workflow in Dynamics 365 and accidentally had set the primary entity to Contract instead of Contact. Is it possible to change it without recreating?

A: I found the answer in another forum, so, just for the records, it's not possible. Only solution is to delete and recreate.


text:
Q: replace specific index character with different character from same index I'm still very new java and find that I spend a lot of time spinning my wheels for things that may be simple. I am writing an app that takes a user entered string of text and places it into a charArray. From here,  I want to use the replace method to replace the character at  index 0 with the character at index 1. ( I understand that replace will change all other values in the string that have the same value as char(0).
if (input.equals(blank) || input.equals(mptee)){
    System.out.println("You have choen to exit, Goodbye");
}

char[] stringToCharArray = input.toCharArray(); // convert string to charArray

for(char output : stringToCharArray) {
    System.out.print(output);
    //code to simplify character validation
    Character x = input.charAt(0);
    Character y = input.charAt(1);
    if( Character.isLetter(input.indexOf(0))
                        && ( Character.isLetter(input.indexOf(1))) ){
        input.replace(input.charAt(0),input.charAt(1));
    }
}
System.out.println(input);

Although it accepts a string, and gives the length, the character replace does not occur. I have read for days on "indexOf" , String RegEx, and much more.  Any assistance would be appreciated.

A: Strings are immutable so after you call the replace method you need to assign it back to input. Change
input.replace(input.charAt(0),input.charAt(1));

to
input  = input.replace(input.charAt(0),input.charAt(1));

A: String input = new String("abcdefgh");
input = input.substring(1, 2) + input.substring(1);

gives you bbcdefgh if that is what you want?
Is it a must to convert the string to a char array and go through the for loop?
I find it a bit unnecessary since you are only working on the first & second character.
If you must convert it to a char array, what about this?
String input = new String("abcdefgh");
char[] stringToCharArray = input.toCharArray();

if(Character.isLetter(stringToCharArray[0]) && Character.isLetter(stringToCharArray[1]))
{
    // Replace character at index 0 with character at index 1
    stringToCharArray[0] = stringToCharArray[1];
}

input = String.valueOf(stringToCharArray); // Convert back to String
System.out.println(input); // Gives you bbcdefgh

There is more than 1 way to achieve what you want, so maybe you can take a look at the String documentation?


text:
Q: JavaScript Pong game. I can't move 2 players at once I stuck in one place for few hours, so I decided to go for help here. I'm beginner and i wish to try write a simple pong game.
At this link in Khan Academy you'll see result.
KHAN ACADEMY my pong game
My issue is:
I can't move two players at once. Only player can move - who hit last the keyboard. Last hit key win.
I know there are few ready pong games, but a lot of it is in Java, or all different logic. Can you help me good people? :)
//THIS IS GAME FOR 2 PEOPLE
//PLAYER 1 CONTROLS: UP ARROW (MOVE UP), DOWN ARROW (MOVE DOWN)
//PLAYER 2 CONTROLS: W KEY (MOVE UP), S KEY (MOVE DOWN)

var player1Y = height/2;
var player2Y = height/2;
var player1Score = 0;
var player2Score = 0;
var ball;
var gameStarted = false;
var t = 0;

//Constants
var PAUSE_TIME = 60;
var PLAYER_MOVE_SPEED = 2;
var BALL_SPEED = 3;
var PADDLE_HEIGHT = 80;
var PADDLE_WIDTH = 8;

angleMode = "degrees";

var Ball = function(position, speed) {
    this.position = position;
    this.speed = speed || BALL_SPEED;

    this.radius = 6;

    this.resetVelocity = function() {
        this.theta = random(0, 75);
        this.velocity = new PVector(
        this.speed*cos(this.theta), -this.speed*sin(this.theta));

    };
    this.resetVelocity();

    this.draw = function() {
        fill(0, 0, 0);
        noStroke();
        ellipse(this.position.x, this.position.y,
        this.radius*2, this.radius*2);
    };

    this.collideWithPaddle = function(x, y) {
        if (this.position.x - this.radius < x + PADDLE_WIDTH/2 &&
        this.position.x + this.radius > x - PADDLE_WIDTH/2) {
            if (dist(0, this.position.y, 0, y) <
            PADDLE_HEIGHT/2 + this.radius) {
                if (this.position.x > x) {
                    this.position.x = x +
                    this.radius + PADDLE_WIDTH/2;
                }
                else if (this.position.x < x) {
                    this.position.x = x -
                    this.radius - PADDLE_WIDTH/2;
                }
                this.velocity.mult(new PVector(-1, 1));
            }
        }
    };

    this.update = function() {
        //Handle wall collisions
        if (this.position.x < 0) {
            player2Score++;
            this.position = new PVector(width/2, height/2);
            gameStarted = false;
            this.resetVelocity();
        }
        else if (this.position.x > width) {
            player1Score++;
            this.position = new PVector(width/2, height/2);
            gameStarted = false;
            this.resetVelocity();
        }
        if (this.position.y < 0) {
            this.position.y = 0;
            this.velocity.mult(new PVector(1, -1));
        }
        else if (this.position.y > height) {
            this.position.y = height;
            this.velocity.mult(new PVector(1, -1));
        }

        //Handle paddle collisions
        this.collideWithPaddle(20, player1Y);
        this.collideWithPaddle(width-20, player2Y);

        this.position.add(this.velocity);
    };
};

ball = new Ball(new PVector(width/2, height/2));

var drawScores = function() {
    var s;
    fill(0, 0, 0);
    textSize(16);
    s = "Player 1: " + player1Score;
    text(s, width*0.25-textWidth(s)/2, 25);
    s = "Player 2: " + player2Score;
    text(s, width*0.75-textWidth(s)/2, 25);
};

//Move the player1 up
var movePlayer1Up = function() {
    player1Y -= PLAYER_MOVE_SPEED;
};
//Move the player1 down
var movePlayer1Down = function() {
    player1Y += PLAYER_MOVE_SPEED;
};

//Move the player2 up
var movePlayer2Up = function() {
    player2Y -= PLAYER_MOVE_SPEED;
};
//Move the player2 down
var movePlayer2Down = function() {
    player2Y += PLAYER_MOVE_SPEED;
};

var drawPlayers = function() {
    //Constrain the player movement
    player1Y = constrain(player1Y, 0, 400);
    player2Y = constrain(player2Y, 0, 400);
    rectMode(CENTER);
    fill(0, 0, 0);
    rect(20, player1Y, PADDLE_WIDTH, PADDLE_HEIGHT);
    rect(width-20, player2Y, PADDLE_WIDTH, PADDLE_HEIGHT);
};

draw = function() {
    //Control Player 1
    if (keyIsPressed) {
        if (keyCode===38){
            movePlayer1Up();
        }
        else if(keyCode===40) {
            movePlayer1Down();
        }
    }
    //Control Player 2
    if (keyIsPressed) {
        if (key.toString()==="w"){
            movePlayer2Up();
        }
        else if(key.toString()==="s"){
            movePlayer2Down();
        }
    }

    //Draw the environment
    background(255, 255, 255);
    drawPlayers();
    drawScores();
    stroke(100, 100, 100);
    line(width/2, 0, width/2, height);

    //Draw the ball
    ball.draw();

    if (!gameStarted) {
        t++;
        if (t >= PAUSE_TIME) {
            t = 0;
            gameStarted = true;
        }
        return;
    }

    ball.update();
};

A: You should be watching the onkeyup, onkeydown events for moving players, see this related question here. JavaScript multiple keys pressed at once

A: Now I understand concept, and I just did something like that:
Scope for multiple keys:
var keys = [];
var keyPressed = function(){
    keys[keyCode] = true;
};
var keyReleased = function(){
    keys[keyCode] = false;
};

and drawing function:
 //Controls

 if (keys[87]) {
 movePlayer2Up();
 }
 if (keys[83]) {
 movePlayer2Down();
 }
 if (keys[38]) {
 movePlayer1Up();
 }
 if (keys[40]) {
 movePlayer1Down();
 }

And now it's working! The same link to the Khan Academy - there's the effect. Thank you one more time.


text:
Q: Crash error after system upgrade to Sierra Mac After upgrading from Mountain Lion to Sierra I get the crash report below on Launching the app.  Unfortunately, don't know what a Mach-0 error is.  I understand that some of the changes to the OS have killed much legacy software, but I was wondering if there might be an easy fix for this?
REPORT
Date/Time:             2016-11-13 10:12:45.737 +0000
OS Version:            Mac OS X 10.12.1 (16B2555)
Report Version:        12
Anonymous UUID:        B12B92D6-E58A-AE2F-ABD0-A1AC308EDE54

Sleep/Wake UUID:       46ADF4CD-C560-4953-B203-57A62C461FA4

Time Awake Since Boot: 11000 seconds
Time Since Wake:       670 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGKILL)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    EXEC, [0xc] This UPX compressed binary contains an invalid Mach-O header and cannot be loaded.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff9e066bb2 __posix_spawn + 10
1   libsystem_kernel.dylib          0x00007fff9e061ef2 posix_spawn + 386
2   xpcproxy                        0x00000001098efd6d 0x1098ed000 + 11629
3   xpcproxy                        0x00000001098f098a 0x1098ed000 + 14730
4   libdyld.dylib                   0x00007fff9df38255 start + 1

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x000000000000000d  rbx: 0x0000000000000000  rcx: 0x00007fff56312388  rdx: 0x00007fff563123a0
  rdi: 0x0000000000000000  rsi: 0x00007f8f1c8010e5  rbp: 0x00007fff56312430  rsp: 0x00007fff56312388
   r8: 0x00007f8f1c600d90   r9: 0x00007f8f1c600d90  r10: 0x00007f8f1c402480  r11: 0x0000000000000202
  r12: 0x00007f8f1c402480  r13: 0x00007f8f1c8010e5  r14: 0x00007fff56312950  r15: 0x00007fff56312958
  rip: 0x00007fff9e066bb2  rfl: 0x0000000000000203  cr2: 0x00007fffa6c310a8

Logical CPU:     0
Error Code:      0x020000f4
Trap Number:     133

Binary Images:
       0x1098ed000 -        0x1098f1fff  xpcproxy (2.0.0 - 972.20.3) <4A173B59-A786-3CBF-9740-CFC693060FEF> /usr/libexec/xpcproxy
       0x113adc000 -        0x113b19287  dyld (421.2) <13A9466A-2576-3ABB-AD9D-D6BC16439B8F> /usr/lib/dyld
    0x7fff9c93d000 -     0x7fff9c93eff3  libSystem.B.dylib (1238) <CFC3669C-FB44-3A51-8815-1E84A168F3C5> /usr/lib/libSystem.B.dylib
    0x7fff9cab4000 -     0x7fff9cab4ff3  libauto.dylib (187) <5BBF6A00-CC76-389D-84E7-CA88EDADE683> /usr/lib/libauto.dylib
    0x7fff9cad5000 -     0x7fff9cb2bff7  libc++.1.dylib (307.4) <BEE86868-F831-384C-919E-2B286ACFE87C> /usr/lib/libc++.1.dylib
    0x7fff9cb2c000 -     0x7fff9cb56fff  libc++abi.dylib (307.2) <1CEF8ABB-7E6D-3C2F-8E0A-E7884478DD23> /usr/lib/libc++abi.dylib
    0x7fff9d647000 -     0x7fff9da1c127  libobjc.A.dylib (706) <47104A1B-13E8-369F-BC36-27FF465809FD> /usr/lib/libobjc.A.dylib
    0x7fff9de5c000 -     0x7fff9de60ff7  libcache.dylib (79) <84E55656-FDA9-3B29-9E4F-BE31B2C0AA3C> /usr/lib/system/libcache.dylib
    0x7fff9de61000 -     0x7fff9de6bfff  libcommonCrypto.dylib (60092.20.1) <31040F10-5E57-3B9C-8D5B-33AD87D1BEE8> /usr/lib/system/libcommonCrypto.dylib
    0x7fff9de6c000 -     0x7fff9de73fff  libcompiler_rt.dylib (62) <486BDE52-81B4-3446-BD72-23977CAE556F> /usr/lib/system/libcompiler_rt.dylib
    0x7fff9de74000 -     0x7fff9de7cfff  libcopyfile.dylib (138) <0DA49B77-56EC-362D-98FF-FA78CFD986D6> /usr/lib/system/libcopyfile.dylib
    0x7fff9de7d000 -     0x7fff9defffdb  libcorecrypto.dylib (442.20.2) <2684CC01-087E-33E2-8219-AAA3BBD9BFD7> /usr/lib/system/libcorecrypto.dylib
    0x7fff9df00000 -     0x7fff9df32fff  libdispatch.dylib (703.20.1) <877B505D-826C-3246-84F7-0F850636039E> /usr/lib/system/libdispatch.dylib
    0x7fff9df33000 -     0x7fff9df38ff3  libdyld.dylib (421.2) <7BFA3476-6210-3BCB-8CE8-9B952F87BD84> /usr/lib/system/libdyld.dylib
    0x7fff9df39000 -     0x7fff9df39ffb  libkeymgr.dylib (28) <09CD7CA6-46D2-3A9F-B9F1-7C4CA5CA0D68> /usr/lib/system/libkeymgr.dylib
    0x7fff9df47000 -     0x7fff9df47fff  liblaunch.dylib (972.20.3) <7AB2E2EA-8B47-3420-87CE-5EE18A4EEE49> /usr/lib/system/liblaunch.dylib
    0x7fff9df48000 -     0x7fff9df4dfff  libmacho.dylib (894) <1EAE5ADD-490C-3B1F-9F97-447BA8E0E90F> /usr/lib/system/libmacho.dylib
    0x7fff9df4e000 -     0x7fff9df50ff3  libquarantine.dylib (85) <F3E47D7C-8776-327C-9426-DD7DEB30DBDD> /usr/lib/system/libquarantine.dylib
    0x7fff9df51000 -     0x7fff9df52ffb  libremovefile.dylib (45) <C4FC07FF-ED86-382E-B06F-33C34718080C> /usr/lib/system/libremovefile.dylib
    0x7fff9df53000 -     0x7fff9df6bff7  libsystem_asl.dylib (349.1.1) <F0987490-8427-367F-B302-A05A7D61FEBF> /usr/lib/system/libsystem_asl.dylib
    0x7fff9df6c000 -     0x7fff9df6cff7  libsystem_blocks.dylib (67) <B8C3701D-5A91-3D35-999D-2DC8D5393525> /usr/lib/system/libsystem_blocks.dylib
    0x7fff9df6d000 -     0x7fff9dffafef  libsystem_c.dylib (1158.20.4) <5F9531F5-EDA3-3D25-A827-3E0FD6B392BA> /usr/lib/system/libsystem_c.dylib
    0x7fff9dffb000 -     0x7fff9dffeffb  libsystem_configuration.dylib (888.20.5) <CDC55FCB-C1FC-350D-A919-5DBCFC835B63> /usr/lib/system/libsystem_configuration.dylib
    0x7fff9dfff000 -     0x7fff9e002fff  libsystem_coreservices.dylib (41.2) <5DE691C6-7EE6-3210-895D-9EA3ECBC09B4> /usr/lib/system/libsystem_coreservices.dylib
    0x7fff9e003000 -     0x7fff9e01bffb  libsystem_coretls.dylib (121.1.1) <8F7E9B12-400D-3276-A9C5-4546B0258554> /usr/lib/system/libsystem_coretls.dylib
    0x7fff9e01c000 -     0x7fff9e022fff  libsystem_dnssd.dylib (765.20.4) <28E52C39-DF10-340F-A3EC-C0119AF6361F> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff9e023000 -     0x7fff9e04cfff  libsystem_info.dylib (503) <C686B834-5E7D-382C-AF6E-44AB78EE83E2> /usr/lib/system/libsystem_info.dylib
    0x7fff9e04d000 -     0x7fff9e06fff7  libsystem_kernel.dylib (3789.21.3) <EC53F92A-0DFA-3027-A220-414A01F17B2E> /usr/lib/system/libsystem_kernel.dylib
    0x7fff9e070000 -     0x7fff9e0b7fe7  libsystem_m.dylib (3121.4) <7F86C291-B105-31C1-9923-90EBAB22B73F> /usr/lib/system/libsystem_m.dylib
    0x7fff9e0b8000 -     0x7fff9e0d6ff7  libsystem_malloc.dylib (116) <F9840080-4C2C-3F3B-8087-7C738F12A1C7> /usr/lib/system/libsystem_malloc.dylib
    0x7fff9e0d7000 -     0x7fff9e12eff3  libsystem_network.dylib (856.20.4) <2BAFB24F-999C-3148-BDD8-F28E05F716F7> /usr/lib/system/libsystem_network.dylib
    0x7fff9e12f000 -     0x7fff9e138ff3  libsystem_networkextension.dylib (563.20.3) <971DD3AD-D17A-32FF-95DE-0A5A979E68AE> /usr/lib/system/libsystem_networkextension.dylib
    0x7fff9e139000 -     0x7fff9e142ff3  libsystem_notify.dylib (165.20.1) <EAD023A2-AD3F-31C8-9489-274B9A42DA61> /usr/lib/system/libsystem_notify.dylib
    0x7fff9e143000 -     0x7fff9e14bfe7  libsystem_platform.dylib (126.1.2) <2F2D6A81-C36C-353D-B27B-A6643A32375E> /usr/lib/system/libsystem_platform.dylib
    0x7fff9e14c000 -     0x7fff9e156ff7  libsystem_pthread.dylib (218.20.1) <46375095-4731-3034-9D87-396DE95FC697> /usr/lib/system/libsystem_pthread.dylib
    0x7fff9e157000 -     0x7fff9e15aff7  libsystem_sandbox.dylib (592.21.2) <2D42A2BF-A7AF-352A-A821-D8F6E85A63AC> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff9e15b000 -     0x7fff9e15cfff  libsystem_secinit.dylib (24) <A54B8FEF-E792-3C54-8E0B-E80A376662F2> /usr/lib/system/libsystem_secinit.dylib
    0x7fff9e15d000 -     0x7fff9e164fff  libsystem_symptoms.dylib (532.1.1) <8FB7CA37-79EF-3651-B5B9-B5E1E0947067> /usr/lib/system/libsystem_symptoms.dylib
    0x7fff9e165000 -     0x7fff9e185ff7  libsystem_trace.dylib (518.20.8) <C029B910-A65F-35F6-B194-B933B454EAB4> /usr/lib/system/libsystem_trace.dylib
    0x7fff9e186000 -     0x7fff9e18bffb  libunwind.dylib (35.3) <9F7C2AD8-A9A7-3DE4-828D-B0F0F166AAA0> /usr/lib/system/libunwind.dylib
    0x7fff9e18c000 -     0x7fff9e1b5ff7  libxpc.dylib (972.20.3) <85EB25FD-218F-38EE-9E69-391CC8EBE6C5> /usr/lib/system/libxpc.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 5848
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=119.5M resident=0K(0%) swapped_out_or_unallocated=119.5M(100%)
Writable regions: Total=38.4M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=38.4M(100%)

                                VIRTUAL   REGION
REGION TYPE                        SIZE    COUNT (non-coalesced)
===========                     =======  =======
Kernel Alloc Once                    8K        2
MALLOC                            30.2M       10
MALLOC guard page                   16K        4
STACK GUARD                       56.0M        2
Stack                             8192K        2
VM_ALLOCATE                          4K        2
__DATA                            1460K       43
__LINKEDIT                       111.6M        4
__TEXT                            8108K       42
shared memory                       12K        4
===========                     =======  =======
TOTAL                            215.1M      105

Model: MacBookPro8,2, BootROM MBP81.0047.B2C, 4 processors, Intel Core i7, 2.2 GHz, 4 GB, SMC 1.69f3
Graphics: Intel HD Graphics 3000, Intel HD Graphics 3000, Built-In
Graphics: AMD Radeon HD 6750M, AMD Radeon HD 6750M, PCIe, 1024 MB
Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1333 MHz, 0x80CE, 0x4D34373142353737334448302D4348392020
Memory Module: BANK 1/DIMM0, 2 GB, DDR3, 1333 MHz, 0x80CE, 0x4D34373142353737334448302D4348392020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xD6), Broadcom BCM43xx 1.0 (5.106.98.100.24)
Bluetooth: Version 5.0.1f7, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en1
Serial ATA Device: KINGSTON SH100S3480G, 480.1 GB
Serial ATA Device: MATSHITADVD-R   UJ-898
USB Device: USB 2.0 Bus
USB Device: FaceTime HD Camera (Built-in)
USB Device: Hub
USB Device: Apple Internal Keyboard / Trackpad
USB Device: BRCM2070 Hub
USB Device: Bluetooth USB Host Controller
USB Device: USB 2.0 Bus
USB Device: Hub
USB Device: IR Receiver
Thunderbolt Bus: MacBook Pro, Apple Inc., 22.1


text:
Q: Where does flash cookie store on Mac? Where does flash cookie store on Mac? I searched this question in google. Some people say the flash cookie is a .sol file stored in folder /User's Home Folder/Library/Preferences/Macromedia/Flash Player/.
But I cannot find this file/folder on my mac. Where is it? Could someone kindly tell me how to find it. Thanks.

A: They're stored in ~/Library/Preferences/Macromedia/Flash Player/#SharedObjects/<some random string>/, and then you'll have subfolders for each domain name. For Google Chrome, the path is ~/Library/Application Support/Google/Chrome/Default/Pepper Data/Shockwave Flash/WritableRoot/#SharedObjects/<some random string>/ instead.
Note that on Mac OS X Lion, the Library folder is hidden, you need to open it using the "Go To" menu in Finder or via Terminal.

A: If you use Mac OS X 10.7 and your whole library folder is hidden, see: http://reviews.cnet.com/8301-13727_7-20082044-263/os-x-lion-where-did-my-library-go/


text:
Q: No result on SHOW FIELDS FROM mysqltable I'm working on a back office project - I first implemented add, update and delete database entries and now I need to imlement some specific actions on some datatypes.
So I want to retrieve the datatype
Only the $fieldtypes = mysql_query("SHOW FIELDS FROM mysqltable"); returns NULL
This is how code is at this time :
<?php
$serveur='localhost';
$user='root';
$password='xxxx';
$base='db';
$champs=array(
"member"=>array("id","group","login","lastname","firstname","email","pswd","account","searchingfor","searchingfordistance","searchedfor","searchedfordistance","mydescription","groupdescription","searchdescription","resourcesdescription"),
    "place"=>array("id","idm","ids","name","town","postalcode","address","coord")
);

$connexion = mysql_connect("$serveur","$user","$password") or die ("Impossible de se connecter à la base de données");
mysql_select_db("$base",$connexion) or die("Erreur de connexion a la base de donnees");

$fieldtypes = mysql_query("SHOW FIELDS FROM place");

ob_start();
var_export($fieldtypes);
$tab_debug=ob_get_contents();
ob_end_clean();
$fichier=fopen('gs.log','w');
fwrite($fichier,$tab_debug);
fclose($fichier);

... (rest of code works)

Can anyone help me to find out what went wrong ?
Thanks!

A: Even with a metadata query like SHOW FIELDS, you still need to fetch rows from your result resource. It behaves like a regular query returning rows, so fetch them in a while loop like you always would.
$fields = array();
$fieldtypes = mysql_query("SHOW FIELDS FROM place");
if ($fieldtypes) {
  while ($row = mysql_fetch_assoc($fieldtypes)) {
    $fields[] = $row;
  }
}
ob_start();
// Dump your $fields array
var_export($fields);
$tab_debug=ob_get_contents();
ob_end_clean();

By the way, it is unnecessary and redundant to surround variables in double quotes when they are not being interpolated inside a string:
// Don't quote these vars -- it's poor practice
$connexion = mysql_connect("$serveur","$user","$password")


text:
Q: Need C# solution to read xml element value I have a complex structure xml from which I need to read some element value.
My xml is somewhat like this:
<plist version="1.0">
<dict>
<key>XYZ</key>
<dict>
    <key>KEYVALUE1</key>
    <dict>
        <key>A</key>
        <date>AVALUE1</date>
        <key>B</key>
        <string>BVALUE1</string>
    </dict>
    <key>KEYVALUE2</key>
    <dict>
        <key>A</key>
        <date>AVALUE2</date>
        <key>B</key>
        <string>BVALUE2</string>
        <key>C</key>
        <string>CVALUE2</string>
    </dict>
</dict>
</dict>
</plist>

What I need is: search for a dict with KEYVALUE2, and wherever I get it, pick BVALUE2 out of it (you can replace 2 with whatever number, I have just included 2 nodes for brevity).
I am newbie for xml programming and all my attempts to try out MS documentation have only confused me more. Sometimes I find a xmlreader example which didn't quite serve my purpose, and other time I got LINQ example which confused me because of its structure. Please help!

A: There are many technologies that allow you to access XML.
Since linq wasn't your taste, you could do the following:
Use XmlDocument with XPath, such as in this example:
XmlDocument xmldoc = new XmlDocument();
xmlDoc.LoadXml(xml);
string bvalue = xmlDoc.SelectSingleNode("//dict[key='" + key + "']/dict/string).InnerText;

But I would advice changing the structure of your XML first..
XML is a great relational data structure. The way your keys are arranged is not relational.. In my opinion, there should be one key on each level like this:
<dict>
    <KeyValuePair>
        <key type="date">A</key>
        <value>AVALUE2</value>
    </KeyValuePair>
    <KeyValuePair>
        <key type="string">B</key>
        <value>BVALUE2</value>
    </KeyValuePair>
</dict>

That way you could write:
string value = xmlDoc.SelectSingleNode("//KeyValuePair[key = 'B']/value").InnerText;

Good Luck!


text:
Q: How can i install and test my app on jailbroken iDevice without developer account? I want to test my app on real device (jailbroken).
But, i have no developer account.
How can i install and test my app on device?
Please, suggest me.

A: You do not need a developer account for jailbroken devices.
Simply download from your Mac to your device and test your apps.
For more information.


text:
Q: GNU Radio no output from other blocks parallel with my own OOT block I would like to code my own general block with 1 input and 1 output for GNU Radio in C++. I followed the steps in gnuradio.org using gr_modtool. It can works well. But when I connect other block(scope sink2) with the same source there is no output in it.
I connect the flow graph as:
                            /-> Scope Sink2
Signal Source -> Throttle -|
                            \-> my own block -> Scope Sink1

I'm using GNU Radio Companion v3.7.6.1-65-g500517ac
I created the block 'energy_de'. This create among other four files:
energy_de.h
#ifndef INCLUDED_CPP_ENERGY_DE_H
#define INCLUDED_CPP_ENERGY_DE_H

#include <cpp/api.h>
#include <gnuradio/block.h>

namespace gr {
  namespace cpp {

    /*!
     * \brief <+description of block+>
     * \ingroup cpp
     *
     */
    class CPP_API energy_de : virtual public gr::block
    {
     public:
      typedef boost::shared_ptr<energy_de> sptr;

      /*!
       * \brief Return a shared_ptr to a new instance of cpp::energy_de.
       *
       * To avoid accidental use of raw pointers, cpp::energy_de's
       * constructor is in a private implementation
       * class. cpp::energy_de::make is the public interface for
       * creating new instances.
       */
      static sptr make(float makenoise);

      virtual float noise () const = 0;
      virtual void set_noise (float noise) = 0;
    };

  } // namespace cpp
} // namespace gr

energy_de_impl.h
#ifndef INCLUDED_CPP_ENERGY_DE_IMPL_H
#define INCLUDED_CPP_ENERGY_DE_IMPL_H

#include <cpp/energy_de.h>

namespace gr {
  namespace cpp {

    class energy_de_impl : public energy_de
    {
     private:
      float d_noise;

     public:
      energy_de_impl(float noise);
      ~energy_de_impl();

      // Where all the action really happens
      void forecast (int noutput_items, gr_vector_int &ninput_items_required);
      float noise() const { return d_noise; }
      void set_noise(float noise) { d_noise = noise; }

      int general_work(int noutput_items,
               gr_vector_int &ninput_items,
               gr_vector_const_void_star &input_items,
               gr_vector_void_star &output_items);
    };

  } // namespace cpp
} // namespace gr

energy_de_impl.cc
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <gnuradio/io_signature.h>
#include "energy_de_impl.h"

namespace gr {
  namespace cpp {

    energy_de::sptr
    energy_de::make(float noise)
    {
      return gnuradio::get_initial_sptr
        (new energy_de_impl(noise));
    }

    /*
     * The private constructor
     */
    energy_de_impl::energy_de_impl(float noise)
      : gr::block("energy_de",
              gr::io_signature::make(1, 1, sizeof(float)),
              gr::io_signature::make(1, 1, sizeof(float))),
        d_noise(noise)
    {
    }

    /*
     * Our virtual destructor.
     */
    energy_de_impl::~energy_de_impl()
    {
    }

    void
    energy_de_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
    {
         ninput_items_required[0] = noutput_items;
    }

    int
    energy_de_impl::general_work (int noutput_items,
                       gr_vector_int &ninput_items,
                       gr_vector_const_void_star &input_items,
                       gr_vector_void_star &output_items)
    {
        const float *in = (const float *) input_items[0];
        float *out = (float *) output_items[0];

        for(int i = 0; i < noutput_items; i++){
            if (in[i]*in[i] > d_noise){
              out[i] = 1.0;
            }
            else{
              out[i] = 0.0;
            }
        }

        return noutput_items;
    }

  } /* namespace cpp */
} /* namespace gr */

cpp_energy_de.xml
<?xml version="1.0"?>
<block>
  <name>energy_de</name>
  <key>cpp_energy_de</key>
  <category>cpp</category>
  <import>import cpp</import>
  <make>cpp.energy_de($noise)</make>
  <callback>set_niose($noise)</callback>

  <param>
    <name>noise</name>
    <key>noise</key>
    <type>float</type>
  </param>

  <sink>
    <name>in</name>
    <type>float</type>
  </sink>

  <source>
    <name>out</name>
    <type>float</type>
  </source>
</block>

Why I cannot get an out put from Scope Sink2? What have I forgotten to write inside the four files? Is this the problem about input_items buffer of my block?

A: When using a general block rather than a sync_block, your general_work must call consume, indicating how many items you've read, otherwise your own block's input buffer (== throttle's output buffer) quickly fills up, throttle can't put new samples into it and your flow graph halts. At that point, your scope sink might simply not have enough input to show anything.
I think for your use case, just using a sync_block would be much easier, and hence, the correct way to do this.
I'd like to point you to a mail I've written today to the discuss GNU Radio mailing list. It explains the buffer space concepts behind this.

              /->A->Null Sink
File Source -|
              \->B->File Sink

[...]
So the mechanism below is: the output buffer of File Source is the
  input buffer of A and the input buffer of B. No memory duplication
  here.
File Source has a buffer writer with a write pointer, and A and B have
  their own read pointers pointing into that buffer.
When File Source produces N items, the write pointer advances by N.
Similarly, when A consumes M items, A's read pointer advances by M.
When calling (general_)work, the input_items buffer(s) is (are) really
  just a pointer (start_of_buffer + read pointer). Equivalently, the
  output_items buffer(s) is (are) really just pointing to the write
  pointer.
File Source is only allowed to produce so many items that the write pointer doesn't advance beyond the minimum read pointer, because in that case, it would overwrite samples that a downstream block hasn't consumed.


text:
Q: How to install Semantic-UI in Azure I am installing a pipeline, CI/CD a React Project but suddenly it wants me to select an option on my semantic plugin.
How do I force it to install the automatic?
https://prnt.sc/v5ogsf

A: According to the document: Semantic UI includes an interactive installer to help setup your project. However, we cannot interact with command line task in azure pipelines.
As a workaround, you can complete install Semantic UI step locally.
1.Clone your azure repository to your local.
2.Run npm install semantic-ui command in your project. Please refer to the steps about install Semantic UI in this document.
3.Commit and push the changes to your azure repository.


text:
Q: How to refetch graphql data for gatsby build? I have a gatsby-theme React application that uses gatsby-source-graphql to fetch the data from my back-end application. I had set the refetchInterval: 20 in my gatsby-config.js file. My gastby-config.js file is as below
module.exports = {
  siteMetadata: {
    title: 'Gatsby Theme Mytheme',
    ...
  },
  pathPrefix: `/gtm`,
  plugins: [
    {
      ...
      ...
    {
      resolve: `gatsby-source-graphql`,
      options: {
        fieldName: `cms`,
        url: `http://127.0.0.1:7000/api/graphiql`,
        typeName: `CMSData`,
        refetchInterval: 20,
      },
    },
    `gatsby-plugin-sharp`,
    `gatsby-transformer-sharp`,
  ],
};

When I run the application in the development mode (gatsby develop) I'm able to see (console.log) the changes made in the back-end CMS application after an interval of 20 seconds. But the changes are not able to see/display on the build (gatsby build). Therefore after the build, whatever I change in the backed it is not reflected in my front-end application. So how can I fetch the changes from the back-end application for my a gatsby build dynamically?
The component I use to fetch the back-end GraphQL data is given as
import { useStaticQuery, graphql } from "gatsby";

export function myComponent() {
  const cmsMenu = useStaticQuery(graphql`
    {
      cms {
        allMenus {
          edges {
            node {
              menuName
            }
          }
        }
      }
    }
  `)
  console.log("CMS menu from MenuProvider", cmsMenu);
}


text:
Q: emberjs-2.0 dynamically add more component on click I have component called display-me. I can add multiple of that same component to thesame template as shown in the jsfiddle by adding multiple calls to that component like this:
  <script type="text/x-handlebars" data-template-name="index">
     {{display-me  action='add'}}
     {{display-me  action='add'}}
  </script>

However, what I desire, is a situation where I can click a button to add the second entry for the component instead of adding it manually as above because I want use to click and add as many as that want.
I have added this action to my index route but it doesn't work:
 App.IndexRoute = Ember.Route.extend({
    actions: {
      add: function(){

        var comp = App.__container__.lookup("component:display-me");

        //var comp = App.DisplayMeComponent.create();

        //comp.appendTo(".test");
        //comp.appendTo('#input');

        Ember.$(".test").append($('<div> {{display-me  action="add"}} </div>'));

      }
    }
  });

Here is the complete jsfiddle

A: You need an each loop in your template to produce multiple inputs.
For the each loop to iterate through something, create a range: an array with as much elements as the desired number of inputs:
http://emberjs.jsbin.com/defapo/2/edit?html,js,output
But this makes little sense as all your inputs will bind to the same value.
In order to have different values, create and populate an array of values:
names: ['James'],

actions: {
  add: function() {
    this.get('names').pushObject('John Doe');
  }
}

{{#each names key="@index" as |name|}}
  <p>  {{input value=name}} </p>
{{/each}}

That's better, but in Ember you'll have a hard time manipulating raw strings. One example is that you need this strange key="@index" thingie.
Instead of raw stings, operate objects:
  people: [ Ember.Object.create({name: 'James'}) ],

  actions: {
    add: function(){
       this
         .get('people')
         .pushObject(Ember.Object.create({name: 'John Doe'}));
    }
  }

{{#each people as |person|}}
  <p>  {{input value=person.name}} </p>
{{/each}}

Demo: http://emberjs.jsbin.com/defapo/3/edit?html,js,output
The next step for improvement is to use Ember Data. You're probably collecting names to persist the list of names on the backend, and Ember Data is the way to do it.