text:
Q: Cannot get tracks in a playlist on Android 10 I am trying to get a list of the playlists and how many tacks are in each on a device with Android 10 installed.  I am using compileSdkVersion = targetSdkVersion = 30. I am requesting READ_EXTERNAL_STORAGE, which seems to be necessary.
I have never tried this before, but it seems straightforward: Get a cursor of the playlists and using the _id of that playlist, then get a cursor over the tracks.
It works as expected as far as getting the name and data (the location), but it always returns 1 for the _id, and it finds no tracks (i.e. cursor.getCount() is zero). The files are not empty. I may have a stupid error, but I am not seeing it.
Added 7/22/2021: There are only 5 column names returned with *: date_modified, _id, name, _data, date_added. The values for all except _id are correct (or at least reasonable). _id (MediaStore.Audio.Playlists._ID) is always 1.
This is the code:

private void showPlaylists() {
    StringBuilder sb = new StringBuilder();
    sb.append("\nPlaylists\n");
    Uri collection;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
        collection = MediaStore.Audio.Playlists.getContentUri(MediaStore.VOLUME_EXTERNAL);
    } else {
        collection = MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;
    }
    String name, data;
    long id;
    // External
    try (Cursor playListCursor =
                 this.getContentResolver().query(
                         collection,
                         null, null, null, null)) {
        if (playListCursor == null) {
            sb.append("Cannot access external playlists\n");
            return;
        }
        for (int i = 0; i < playListCursor.getCount(); i++) {
            playListCursor.moveToPosition(i);
            name = playListCursor.getString(
                    playListCursor.getColumnIndex("name"));
            sb.append(i).append(" ").append(name).append("\n");
            // This is apparently the path
            data = playListCursor.getString(
                    playListCursor.getColumnIndex(MediaStore.Audio.Media.DATA));
            sb.append("    ").append(data).append("\n");
            id = playListCursor.getColumnIndex(MediaStore.Audio.Playlists._ID);
            sb.append("    id=").append(id).append("\n");

            // Get the playlist from the id
            String[] projection = null; // All columns
            try (Cursor cursor =
                         this.getContentResolver().query(MediaStore
                                         .Audio.Playlists.Members.getContentUri
                                                 ("external", id),
                                 projection, null, null, null)) {
                if (cursor == null) {
                    sb.append("    Cannot get contents\n");
                } else {
                    sb.append("    Tracks: ").append(cursor.getCount())
                            .append("\n");
                }
            } catch (Exception ex) {
                String msg = "    Error getting playlist " + i;
                Log.e(TAG, msg, ex);
            }
        }
    } catch (Exception ex) {
        String msg = "Error getting external playlists";
        Utils.excMsg(this, msg, ex);
        Log.e(TAG, msg, ex);
    }
    Log.e(TAG, sb.toString());
}

and this is the output in Logcat:

0 Carmen Cavallero
    /storage/3535-6434/Playlists/Carmen Cavallero.m3u
    id=1
    Tracks: 0
1 Chris Botti
    /storage/3535-6434/Playlists/Chris Botti.m3u
    id=1
    Tracks: 0
2 Diana Krall
    /storage/3535-6434/Playlists/Diana Krall.m3u
    id=1
    Tracks: 0
3 Dinner Party
    /storage/3535-6434/Playlists/Dinner Party.m3u
    id=1
    Tracks: 0
4 Meditation 1
    /storage/3535-6434/Playlists/Meditation 1.m3u
    id=1
    Tracks: 0
5 Romance
    /storage/3535-6434/Playlists/Romance.m3u
    id=1
    Tracks: 0
6 Tablet
    /storage/3535-6434/Playlists/Tablet.m3u
    id=1
    Tracks: 0
7 Jean Sidwell
    /storage/3535-6434/Playlists/Jean Sidwell.m3u
    id=1
    Tracks: 0
8 Bill Evans MM2
    /storage/3535-6434/Playlists/Bill Evans MM2.m3u
    id=1
    Tracks: 0
9 Selena
    /storage/3535-6434/Playlists/Selena.m3u
    id=1
    Tracks: 0

A: You can try to apply the MANAGE_EXTERNAL_STORAGE permission for android 10.
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

For more details,check Docs.

A: This is my approach
   public Uri get_audio_playlist_members_uri(Long playlist_id){
if(playlist_id==null){
    playlist_id= 0L;
}
    Uri uri_to_use = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {

        uri_to_use   = MediaStore.Audio.Playlists.getContentUri(MediaStore.VOLUME_EXTERNAL)
                .buildUpon()
                .appendEncodedPath(Long.toString(playlist_id))
                .appendEncodedPath("members")
                .build();
    } else {
        uri_to_use = MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI
                .buildUpon()
                .appendEncodedPath(Long.toString(playlist_id))
                .appendEncodedPath("members")
                .build();
    }
    return uri_to_use;
}

public Cursor getPlaylistTracks(Context context, Long playlist_id) {
    if (context != null) {
        Uri newuri = uris.get_audio_playlist_members_uri(playlist_id);
        ContentResolver resolver = context.getContentResolver();
        String _id = MediaStore.Audio.Playlists.Members._ID;
        String audio_id = MediaStore.Audio.Playlists.Members.AUDIO_ID;
        String artist = MediaStore.Audio.Playlists.Members.ARTIST;
        String album = MediaStore.Audio.Playlists.Members.ALBUM;
        String album_id = MediaStore.Audio.Playlists.Members.ALBUM_ID;
        String title = MediaStore.Audio.Playlists.Members.TITLE;
        String duration = MediaStore.Audio.Playlists.Members.DURATION;
        String location = MediaStore.Audio.Playlists.Members.DATA;
        String composer = MediaStore.Audio.Playlists.Members.COMPOSER;
        String playorder = MediaStore.Audio.Playlists.Members.PLAY_ORDER;
        String date_modified = MediaStore.Audio.Playlists.Members.DATE_MODIFIED;
        String[] columns = {_id, audio_id, artist, album_id, album, title, duration,
                location, date_modified, playorder, composer};
        try {
            return resolver.query(newuri, columns, null, null, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return null;

}

A: The answer is that I was using:

            id = playListCursor.getColumnIndex(MediaStore.Audio.Playlists._ID));

rather than:

            id = playListCursor.getLong(playListCursor.getColumnIndex(MediaStore.Audio.Playlists._ID));

My mistake. Sorry.


text:
Q: how to get % of transaction amount from top 1000 sellers over all sellers, Month to Date, using bigquery so I have table that consist : table, shop_id, and transaction amount.
date_key    shop_id    transaction_amount
2022-01-01    S_001       2000
2022-01-01    S_002       2500
2022-01-02    S_001       2600
2022-01-02    S_002       2200
.
.
.
.

the goal is I want to calculate the % of transaction amount of top 1000 sellers MTD. on average I have around 50k sellers that has transaction on each day. since the calculation is month to date, so there's possibility if we will find different top 1000 sellers on each day.
top 1000 seller mtd meaning : the performance is based on cumulative MTD transaction amount e.g for data on 2022-01-05 the we need to calculate cumulative transaction amount from 2022-01-01 to 2022-01-04 for each shop_id then sort it based on highest transaction amount.
the goal is to create table below
date_key   amount_from_top_1000_sellers(a) amount_from_all_sellers (b)    ratio (a/b)
2022-01-01         4000                              200000                   2%
...
...
...

A: Window Function will do this task. For each day you need a row_number ordered by the selling amount column.
First we generate some random data in the tbl table. Then we add the row number for each day. Next we need to filter the first 100 top seller per day (if statement). The increase to 1000 top seller per day is obvious. The calculation of remaining selling amount and the ration can be done by including the last SELECT in the WITH as further table and query this table again with   SELECT.
WITH
  tbl AS (
  SELECT
    DATE_SUB(CURRENT_DATE(),INTERVAL d day) AS date_key,
    a AS shop_id,
    100*RAND() AS transaction_amount
  FROM
    UNNEST(GENERATE_ARRAY(1,1000)) a,
    UNNEST(GENERATE_ARRAY(0,100)) d ),
  trunc_to_month AS (
  Select
  date_trunc(date_key,month) as date_key_month,#aggregate to month and year
  shop_id,
  sum(transaction_amount) as transaction_amount,
  from tbl
  group by 1,2
  ),
  tmp AS (
  SELECT
    *,
    ROW_NUMBER() OVER (PARTITION BY date_key_month ORDER BY transaction_amount DESC ) AS rownum
  FROM
    trunc_to_month )
SELECT
  date_key_month, # keep only the month and year; remove the day
  SUM(transaction_amount) AS transaction_amount_total,
  SUM(IF(rownum<=100,transaction_amount,0)) AS amount_from_top_100_sellers
FROM
  tmp
GROUP BY 1

redpajama_set_name: RedPajamaStackExchange


text:
Q: SQL Query Date compare options I'm trying to compare the current date with database datetime column. I tried the following three options, but no luck. Any idea?
Option 1
select something from tableA
where  cast(lastupdateddate as date)=cast(GETDATE() as date)

Option 2
select something from tableA
where  CONVERT(date, lastupdateddate)=CONVERT(date, GETDATE())

Option 3
select something from tableA
where  CONVERT(VARCHAR(8), lastupdateddate,1)=CONVERT(VARCHAR(8), GETDATE(),1)

A: Right the first option should already work, provided the column has really datetime datatype, e.g.
create table tablea (
  id int,
  lastupdateddate datetime
);

and the query
select *
from tablea
where cast(lastupdateddate as date) = cast(getdate() as date)

See SQLFiddle


text:
Q: If (set of conditions) do this, if (set of conditions) do this, if (set of conditions) do this. What? So, I'm building a weather website, and I use Wunderground's API. In the AJAX XML dump, the value for "icon" seems to be the way to go. This response will dynamically change the CSS on the page. I have multiple statuses of the page that I want possible, but I can't seem to get them to work. It seems to be stopping after the first "if" statement. I need it to check if wu_icon == certain conditions, if not, move to the next one and see if wu_icon == the next set of conditions.
Here's the website.
Any help would be much appreciated.
function get_weather(position) {
    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;
    wu_query = latitude + ',' + longitude;

    //Weather underground request URL format.
    wu_url = wu_base_url + '/' + wu_api_key + '/' + wu_features + '/q/' + wu_query + '.json';
    console.log('URL Query: ' + wu_url);

    $.ajax({
        url: wu_url,
        dataType: "jsonp",
        success: function(parsed_json) {
            console.log(parsed_json);

            var location = parsed_json['location']['city'];
            var wuurl = parsed_json['location']['wuiurl'];

            //simple forecast day 1.
            var wu = parsed_json['current_observation'];
            var wu_temp_f = wu['temp_f'];
            var wu_high_temp = wu['high'];
            var wu_low_temp = wu['low'];
            var wu_icon = wu['icon'];

            $('#location').html(location);
            $('#temp').html(wu_temp_f + '&degF');

            if (wu_icon == 'partlycloudy' || 'partlysunny' || 'unkown'){
                document.getElementById('rainclouds').style.display = 'none';
                document.getElementById('topclouds').style.display = 'block';
                document.getElementById('bottomclouds').style.display = 'block';
                document.getElementById('canvas').style.display = 'none';
                document.getElementById('snow').style.display = 'none';
                window.alert("1");
                }

            else if (wu_icon == 'rain' || 'chancerain' || 'chancetstorms' || 'tstorms'){
                document.getElementById('rainclouds').style.display = 'block';
                document.getElementById('topclouds').style.display = 'none';
                document.getElementById('bottomclouds').style.display = 'none';
                document.getElementById('canvas').style.display = 'block';
                document.getElementById('snow').style.display = 'none';
                window.alert("2");
                }

            else if (wu_icon == 'flurries' || 'snow' || 'chanceflurries' || 'chancesnow'){
                document.getElementById('rainclouds').style.display = 'block';
                document.getElementById('topclouds').style.display = 'none';
                document.getElementById('bottomclouds').style.display = 'none';
                document.getElementById('canvas').style.display = 'none';
                document.getElementById('snow').style.display = 'block';
                window.alert("3");
                }

            else if (wu_icon == 'clear' || 'mostlysunny' || 'sunny'){
                document.getElementById('rainclouds').style.display = 'none';
                document.getElementById('topclouds').style.display = 'block';
                document.getElementById('bottomclouds').style.display = 'none';
                document.getElementById('canvas').style.display = 'none';
                document.getElementById('snow').style.display = 'none';
                window.alert("4")
                }

            else if (wu_icon == 'chancesleet' || 'sleet'){
                document.getElementById('rainclouds').style.display = 'block';
                document.getElementById('topclouds').style.display = 'none';
                document.getElementById('bottomclouds').style.display = 'none';
                document.getElementById('canvas').style.display = 'block';
                document.getElementById('snow').style.display = 'block';
                window.alert("5");
                }

            else if (wu_icon == 'cloudy' || 'mostlycloudy' || 'fog' || 'hazy'){
                document.getElementById('rainclouds').style.display = 'block';
                document.getElementById('topclouds').style.display = 'none';
                document.getElementById('bottomclouds').style.display = 'none';
                document.getElementById('canvas').style.display = 'none';
                document.getElementById('snow').style.display = 'none';
                window.alert("6");
                }

        }

A: your if statement should look like
if (wu_icon == 'partlycloudy' || wu_icon == 'partlysunny' || wu_icon == 'unkown')

shorter version would be
if (["partlycloudy","partlysunny","unkown"].indexOf(wu_icon) != -1)


text:
Q: JPA 2.1: received org.hibernate.exception.ConstraintViolationException using orphanRemoval I have 3 enties which have following mapping and I want to use orphanRemoval when I want to delete parent entities:
@Entity
@Table(name = "EvaluationRequest", schema = "dbo")
public class EvaluationRequestDMO implements java.io.Serializable {

private Set<EvalStatusDMO> evaluationStatuses = new HashSet<EvalStatusDMO>(0);

@OneToMany(fetch = FetchType.LAZY, mappedBy = "evaluationRequest", orphanRemoval = true)
    public Set<EvalStatusDMO> getEvaluationStatuses() {
        return this.evaluationStatuses;
    }
}

@Entity
@Table(name = "EvaluationStatus")
public class EvalStatusDMO implements Serializable{
    private EvaluationRequestDMO evaluationRequest;
    private EvaluationResponseDMO evaluationResponce;
@ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "EvalRequestId", nullable = false)
    public EvaluationRequestDMO getEvaluationRequest() {
        return evaluationRequest;
    }
    public void setEvaluationRequest(EvaluationRequestDMO evaluationRequestDMO) {
        this.evaluationRequest = evaluationRequestDMO;
    }
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "EvalResponseId", nullable = false)
    public EvaluationResponseDMO getEvaluationResponce() {
        return evaluationResponce;
    }
    public void setEvaluationResponce(EvaluationResponseDMO evaluationResponceDMO) {
        this.evaluationResponce = evaluationResponceDMO;
    }
}

@Entity
@Table(name = "EvaluationResponse")
public class EvaluationResponseDMO implements Serializable{
private Set<EvalStatusDMO> evalStatusDMO = new HashSet<EvalStatusDMO>(0);
@OneToMany(fetch = FetchType.LAZY, mappedBy = "evaluationResponce", orphanRemoval = true)
    public Set<EvalStatusDMO> getEvalStatusDMO() {
        return evalStatusDMO;
    }

}

Now I want to delete EvaluationRequest and EvaluationResponse entities:
@Override
    @Transactional
    public void deleteEvaluationInfoByPgSelIdAndProfileId(long programSelectedId, long profileId) {
        List<EvaluationRequestDMO> evaluationRequestDMOList = evaluationRequestDAO.findByProfileIdAndProgramId(profileId, programSelectedId);
        if (evaluationRequestDMOList != null) {
            List<EvaluationResponseDMO> evaluationResponseDMOList = new ArrayList<>();
            for (EvaluationRequestDMO evaluationRequestDMO : evaluationRequestDMOList) {
                if (evaluationRequestDMO.getEvaluationStatuses() != null) {
                    evaluationResponseDMOList.addAll(collect(evaluationRequestDMO.getEvaluationStatuses(), TransformerUtils.invokerTransformer("getEvaluationResponce")));
                }
            }
            filter(evaluationRequestDMOList, PredicateUtils.notNullPredicate());
            evaluationResponseDAO.deleteInBatch(evaluationResponseDMOList);
            evaluationRequestDAO.deleteInBatch(evaluationRequestDMOList);
        }
    }

On deleting evaluationResponseDAO.deleteInBatch(evaluationResponseDMOList); I get org.hibernate.exception.ConstraintViolationException:
The DELETE statement conflicted with the REFERENCE constraint "FK_EvaluationStatus_EvaluationResponse". The conflict occurred in database "unicas_ux", table "dbo.EvaluationStatus", column 'EvalResponseId'.
I know that I could delete it successfully in the following order:
EvaluationStatusDMO->EvaluationResponceDMO->EvaluationRequestDMO
But, I how can I do it using orphanRemoval?

A: The order you are deleting is request and then response, right? Let's have a look.
request

*

*has a relationship to status orphanRemoval=true

response

*

*has also a relationship to status, orphanRemoval=true

status

*

*relationship to request --> nullable=false

*relationship to response --> nullable= false

The problem:
If you delete the request you configured your entity to delte also its status entities. But at this moment the status has also a relationship to response that still exists and has a reference to it.
This doesn't work. You have to resolve all relationships of status before you can delete it.

A: I had figure out how to solve the issue. My child entity EvalStatusDMO has relationg to both EvaluationResponseDMO and to EvaluationRequestDMO. To remove everithing properly I must clear the set of EvalStatusDMO in one of the relations (see below).
@Override
@Transactional
public void deleteEvaluationInfoByPgSelIdAndProfileId(long programSelectedId, long profileId) {
    List<EvaluationRequestDMO> evaluationRequestDMOList = evaluationRequestDAO.findByProfileIdAndProgramId(profileId, programSelectedId);
    if (evaluationRequestDMOList != null) {
        List<EvaluationResponseDMO> evaluationResponseDMOList = new ArrayList<>();
        for (EvaluationRequestDMO evaluationRequestDMO : evaluationRequestDMOList) {
            if (evaluationRequestDMO.getEvaluationStatuses() != null) {
                evaluationResponseDMOList.addAll(collect(evaluationRequestDMO.getEvaluationStatuses(), TransformerUtils.invokerTransformer("getEvaluationResponce")));
                evaluationRequestDMO.getEvaluationStatuses().clear();
            }
        }
        filter(evaluationRequestDMOList, PredicateUtils.notNullPredicate());
        evaluationRequestDAO.deleteInBatch(evaluationRequestDMOList);
        evaluationResponseDAO.deleteInBatch(evaluationResponseDMOList);
    }
}

So the logic would be follow:

*

*for each of EvaluationRequestDMO I should clear EvalStatusDMO.

*Remove all 'EvaluationRequestDMO'.

*Remove all 'EvaluationResponseDMO'.

*all EvalStatusDMO would be removed automatically, because of orphanRemoval=true


text:
Q: "Parameter 'browser' is required by BeforeClass on method beforeClass but has not been marked @Optional or defined" error in maven project I have a maven project where in I am running testng.xml from pom.xml file.
My testng.xml file looks like below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests">
  <test name="FirefoxTest">
  <parameter name="browser" value="firefox"/>
    <classes>
      <class name="tests.PM_User_Test"/>
    </classes>
  </test> <!-- Test -->

  <test name="ChromeTest">
    <parameter name="browser" value="chrome"/>
    <classes>
      <class name="tests.PM_User_Test"/>
      <class name="tests.PM_Extension_Test"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

and below is my class:
    package base;

import java.io.IOException;
import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.UnexpectedAlertBehaviour;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.ITestResult;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;

import utilities.ExcelReadAndWrite;
import utilities.Take_Screenshot;

public class ConfigClass
{
    public WebDriver driver = null;
    public static String excelPath = null;
    public static ExcelReadAndWrite loginData;
    public static ExcelReadAndWrite pmTests;
    public static ExcelReadAndWrite snmTests;
    public static ExcelReadAndWrite ipData;

    @BeforeSuite
    public void beforeSuite()
    {
        excelPath = "C://Users//mallikar//git//PM//PM//src//main//java//myTestData//TestData.xlsx";
        loginData = new ExcelReadAndWrite("logindata", excelPath);
        pmTests = new ExcelReadAndWrite("PMTestData", excelPath);
        snmTests = new ExcelReadAndWrite("SNMTestData", excelPath);
        ipData = new ExcelReadAndWrite("IP", excelPath);
    }

    @AfterSuite
    public void afterSuite()
    {

    }

    @Parameters({"browser"})
    @BeforeClass
    public void beforeClass(String browser)
    {
        DesiredCapabilities dc = new DesiredCapabilities();
        dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
        if(browser.equalsIgnoreCase("firefox"))
        {
            driver = new FirefoxDriver(dc);
        }
        else if(browser.equalsIgnoreCase("chrome"))
        {
            driver = new ChromeDriver();
        }

    }

    /*@Parameters("browser")
    @BeforeClass
    public void beforeClass()
    {
        DesiredCapabilities dc = new DesiredCapabilities();
        dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
        driver = new FirefoxDriver(dc);
    }*/

    @AfterClass
    public void afterClass()
    {
        driver.close();
    }

    @BeforeMethod
    public void beforeMethod()
    {
//      driver.get("https://sqa.stackexchange.com/questions/36253/taking-screenshot-on-test-failure-selenium-webdriver-testng");
//      System.out.println(driver);
        driver.manage().window().maximize();
        driver.manage().deleteAllCookies();
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    }

    @AfterMethod
    public void afterMethod(ITestResult result) throws IOException
    {
        if(result.getStatus() == 2)
        {
            String methodName = result.getMethod().getMethodName();
            new Take_Screenshot().get_Screenshot(driver, methodName);
        }
    }
}

But I am getting the "Parameter 'browser' is required by BeforeClass on method beforeClass but has not been marked @Optional or defined" error in maven project.

However when I run only testng.xml file it is absolutely working fine. The pro

blem comes when I run testng.xml from pom.xml file.
Below is the content of POM.xml file where I have defined testng.xml:
<profiles>
    <profile>
        <id>Regression</id>
        <build>
    <plugins>
    <plugin>
        <inherited>true</inherited>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
           <encoding>UTF-8</encoding>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.12.2</version>
        <configuration>
          <suiteXmlFiles>
               <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>
    </plugins>
  </build>
    </profile>
  </profiles>

I have gone through lot of threads about this on internet but I haven't found any solution. Please somebody help me with this.
And below are the console logs when I run mvn clean install command
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@ba4d54
Tests run: 10, Failures: 2, Errors: 0, Skipped: 8, Time elapsed: 2.368 sec <<< FAILURE!
beforeClass(tests.PM_Extension_Test)  Time elapsed: 2.098 sec  <<< FAILURE!
org.testng.TestNGException:
Parameter 'browser' is required by BeforeClass on method beforeClass but has not been marked @Optional or defined

        at org.testng.internal.Parameters.createParams(Parameters.java:289)
        at org.testng.internal.Parameters.createParametersForMethod(Parameters.java:377)
        at org.testng.internal.Parameters.createParameters(Parameters.java:721)
        at org.testng.internal.Parameters.createConfigurationParameters(Parameters.java:164)
        at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:275)
        at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:176)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at org.testng.TestRunner.privateRun(TestRunner.java:770)
        at org.testng.TestRunner.run(TestRunner.java:591)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
        at org.testng.SuiteRunner.run(SuiteRunner.java:304)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
        at org.testng.TestNG.runSuites(TestNG.java:1032)
        at org.testng.TestNG.run(TestNG.java:1000)
        at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
        at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:159)
        at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:99)
        at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

beforeClass(tests.PM_User_Test)  Time elapsed: 0.002 sec  <<< FAILURE!
org.testng.TestNGException:
Parameter 'browser' is required by BeforeClass on method beforeClass but has not been marked @Optional or defined

        at org.testng.internal.Parameters.createParams(Parameters.java:289)
        at org.testng.internal.Parameters.createParametersForMethod(Parameters.java:377)
        at org.testng.internal.Parameters.createParameters(Parameters.java:721)
        at org.testng.internal.Parameters.createConfigurationParameters(Parameters.java:164)
        at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:275)
        at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:176)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at org.testng.TestRunner.privateRun(TestRunner.java:770)
        at org.testng.TestRunner.run(TestRunner.java:591)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
        at org.testng.SuiteRunner.run(SuiteRunner.java:304)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
        at org.testng.TestNG.runSuites(TestNG.java:1032)
        at org.testng.TestNG.run(TestNG.java:1000)
        at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
        at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:159)
        at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:99)
        at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Results :

Failed tests:   beforeClass(tests.PM_Extension_Test): (..)
  beforeClass(tests.PM_User_Test): (..)

Tests run: 10, Failures: 2, Errors: 0, Skipped: 8

[WARNING] Could not delete temp direcotry C:\Users\mallikar\git\PM\PM\target\surefire because Directory C:\Users\mallikar\git\PM\PM\target\surefire unable to be deleted.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10.374 s
[INFO] Finished at: 2019-09-26T16:39:22+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project PM: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\mallikar\git\PM\PM\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

A: Please try doing one of the following (which should fix your problem )

*

*Make sure that the annotation @Parameters is imported from the package org.testng.annotations

*Make sure you adhere to one of the following, when running the test:

*

*If you are running from the IDE, by right clicking on the class and choosing run as TestNG test then make sure that you edit your run configuration and provide the JVM argument -Dbrowser=firefox

*If you would like to run the entire suite, then you would need to make sure that you right click on the suite and then run it.

*If you are running from the commandline using maven, then make sure that you are using mvn clean test -P Regression (This would ensure that the profile Regression gets activated and through that, the test execution happens via the suite file)

A: For me adding configuration for xml suite inside maven-surefire-plugin worked.
I have added the below configuration.
<plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.12.2</version>
          <configuration>
            <suiteXmlFiles>
              <suiteXmlFile>location-to-testng-xml-file</suiteXmlFile>
            </suiteXmlFiles>
          </configuration>
</plugin>


text:
Q: how to keep last translations with angularJS after refreshing my page? I'm just begining with angularJS and I want add the option of translation to my application.
I tried this fonction with one variable for my first test with 2 button which refer to 2 differents languages, the local language is ENGLISH and the second is FRENSH and it work but the probleme is after refreshing my application, this variable turn to the local language. how can I resolve this problem . this is my code on angularJS.
     'use strict';
     var app = angular.module('app', ['pascalprecht.translate']);
    app.config(function($translateProvider) {
     $translateProvider.fallbackLanguage('en');
     $translateProvider .translations('en', {
        msg : 'Hello',
      })
      $translateProvider.translations('fr', {
        msg : 'bonjour'
      });
      $translateProvider.preferredLanguage('en');
    });
    app.controller('Ctrl', function($translate, $scope) {
      $scope.changeLanguage = function (langKey) {
        $translate.use(langKey);
      };
    });

Thank you

A: You will probably want to use some kind of a localStorage service to save the selected language.
You'll have to decide which kind of persistence (by session? by user?) you want to attain, to choose the best model of persistence to use...

A: You should use a way to persist data during life time of your aplication.
for example you can use cookies.
But if you want to do it angular way you can use $localStorage or $sessionStorage from this repo
there are other repositories as well.
After that when user refresh the page you can check
for language information saved in your session($sessionStorage) or browser($localStorage) and display the right language.
as @MarcoS said, if you want to show another
language for specific users you should store and get language information
from database.
goodluck !


text:
Q: how to solve error from sending email from contact form I am trying to send mail from my contact form. But I am getting error.
contact.blade.php is:
<form method="post" action="{{ URL('send') }}">
  {{csrf_field()}}

     Full Name
    <input type="text" name="name" required="required" />

      Contact No.
     <input type="text" name="mobno" required="required" />

       Email ID
        <input type="text" name="email" required="required" />

        Message
        <textarea name="msg" cols="30" rows="3" required="required"></textarea>

           <input type="submit" name="submit" />

     </form>

web.php is:
Route::POST('send', 'ContactController@send');

ContactController.php is:
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\officeholder;
use App\Mail\SendMail;
use Mail;

class ContactController extends Controller
{

public function send()
{
    Mail::send(new sendMail());
}
}

**I have created SendMail.php using

php artisan make:mail SendMail

by my cmd and then App\Mail\SendMail.php is created.**
SendMail.php is:
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Http\request;

class SendMail extends Mailable
{
use Queueable, SerializesModels;

public function __construct()
{
    //
}

public function build(Request $request)
{
    return $this->view('contact',['msg'=>$request->msg])->to('mymail@gmail.com');
}
}

But I got error after click button on form.
1/1) FatalErrorException
Class 'App\Http\Controllers\sendMail' not found
in ContactController.php line 18

A: Change your code:
Mail::send(new sendMail());

to
Mail::send(new SendMail());

and
use App\Mail\SendMail;

to
use \App\Mail\SendMail;

Update:
try this:
public function build(Request $request)
{
    return $this
             ->view('contact')
             ->with(['msg' => $request->msg])
             ->to('mymail@gmail.com');
}

You need to set variables with function with()

A: use like this
<?php

    namespace App\Http\Controllers;

    use Illuminate\Http\Request;
    use App\officeholder;
    use Mail;
    use App\Mail\SendMail;

    class ContactController extends Controller
    {

          public function send()
          {
              Mail::send(new SendMail());
          }
    }


text:
Q: How to sum count query inside foreach loop? <?php
    foreach($idd as $ids)
    {
        $sql5 = "select count(DISTINCT product_name) as total from stock where type = '".$ids."'";
        $result5 = mysqli_query($con,$sql5);
        $row5 = mysqli_fetch_row($result5);
    }
    $total5 = $row5[0];
?>

In this code I have used explode function for $idd and run query inside foreach loop and want to sum of multiple query inside foreach loop and Now, My query look like:
select count(DISTINCT product_name) as total from stock where type = 'Green Tea'select count(DISTINCT product_name) as total from stock where type = 'Herbal Tea'

But I want like this
select (select count(DISTINCT product_name) as total from inventory_add_in_stock where type = 'Green Tea')+(select count(DISTINCT product_name) as total from inventory_add_in_stock where type = 'Herbal Tea') as total

So, How can I do this? Please help me.
Thank You

A: You need to fetch values inside foreach() and sum them. Do like below:-
<?php

    $total_count = 0; // a varible define to get total count in last
    foreach($idd as $ids)
    {
        $sql5 = "select count(DISTINCT product_name) as total from stock where type = '".$ids."'";
        $result5 = mysqli_query($con,$sql5) or die(mysqli_error($con));
        $row5 = mysqli_fetch_assoc($result5);
        $total_count += $row5['total']; // add counts to variable
    }
    echo $total_count; // print final count
?>

Your code is wide open for SQL INJECTION. try to use prepared statements
mysqli_prepare()
PDO::prepare
Note:- Try to do it without loop
https://dba.stackexchange.com/a/102345


text:
Q: Uploading to User Defined Folders Django I am making an app where users can upload files to an AWS S3 Bucket. Each user, when signing up, gets a folder within the media folder based on their userID How to I allow my users to upload their projects to that their folders? The files upload just fine, but to a folder named None. This seems like an easy answer, but I cannot seem to find it.
Here's my views.py
def new(request):
    title = "Add New Project"
    if not request.user.is_authenticated():
        raise Http404
    form = ProjectForm(request.POST or None, request.FILES or None)
    if form.is_valid():
        instance = form.save(commit=False)
        instance.fileLocation = request.user.id
        instance.user = request.user
        instance.save()
        return redirect("/dashboard/")
    context = {
        "form": form,
        "title": title,
    }

Here's my models.py
from django.db import models
from django.conf import settings

# Create your models here.
class Project(models.Model):
    fileLocation = None
    user = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True)
    title = models.CharField(max_length=200)
    description = models.TextField()
    sell = models.BooleanField(default=False)
    timestamp = models.DateTimeField(auto_now_add=True)
    image = models.FileField(upload_to=fileLocation, null=True, blank=True)
    def __str__(self):
        return self.title

And here's my forms.py (just in case)
from django import forms
from .models import Project
from django.contrib.auth.models import User

class ProjectForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super(ProjectForm, self).__init__(*args, **kwargs)
        self.fields['image'].required = True

    class Meta:
        model = Project
        fields = [
            'title',
            'description',
            'image',
            'sell',
        ]

A: Send the request param to your modelForm init .. and use that (assuming you will then have access to request.user)  to set the location field specific to that user

A: The issue is in your models.py.
Add this:
def fileLocation(instance, filename):
  return 'uploads/{0}/{1}'.format(instance.owner.username, os.path.basename(filename))

remove this:
fileLocation = None

and your user's file should go into uploads/<username>/<filename>.
As BobbyC mentioned, you should use ImageField instead of FileField


text:
Q: Upgraded to 13.10, screen regularly flashes between red, green, blue, greys after boot. No X11 or Unity I have a Z77 board with a GeForce GTX 670. My monitor is a Korean 27" IPS with only a single DVI Dual-link connection, and a resolution of 2560x1440. After upgrading to 13.10 today, Unity and the X Window System are non-functional. After booting up, all I see is a screen that flashes between red, green, blue, various blacks, greys, and whites at regular intervals. From here I can switch to command line, and that displays fine, but starting lightdm takes me back to the flashing colors. I had this problem on 13.04, but I was able to fix it by editing xorg.conf with the proper information about my monitor. No such luck for 13.10. I have tried:

*

*installing different drivers (i.e. nvidia-current, nvidia-experimental)

*plugging into both DVI ports on my 670

*editing xorg.conf myself

*letting the Nvidia package do the xorg.conf configuration automatically

Admittedly I know very little about X Window system, and all my editing was based on xorg.conf files posted by others that were claimed to work, none of which used the same combination of monitor and video card as mine. I'm out of ideas at this point, input from someone who knows what they're doing would be greatly appreciated.

A: Article explaining the issue and solution: http://neogregious.blogspot.com/2013/05/korean-ips-monitors-and-nvidia-under.html
Here is a short summary of the solution(credit goes to Greg Fawcett):
Create an xorg conf:
sudo nvidia-xconfig

Now you need to edit the new xorg.conf file:
sudo vi /etc/X11/xorg.conf

Find the section below, and add the - Option "IgnoreEDIDChecksum" "DFP" - line :
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    Option         "IgnoreEDIDChecksum" "DFP"
EndSection

Save the file, and reboot.

A: Seems like your graphics drivers are messed up. You'll need to purge all the Nvidia packages you created by experimenting with them:
sudo apt-get purge nvidia*

Then reinstall the Nvidia-current:
sudo apt-get install nvidia-current

Don't forget to reboot!


text:
Q: How is a Stack the generalisation of a sheaf from a 2-category point of view? A stack is usually given in terms of:
-A category $F$ fibered over another $C$ such that the functor $Hom(x,y), x,y \in F(\alpha), \alpha \in C$ is a sheaf
-The descent data are effective.
There is an equivalent definition, using the Grothendieck construction, which is a correspondence between fibered categories and pseudofunctors in $Cat$. Given this correspondence a stack becomes a (contravariant) pseudofunctor such that descent is effective.
Now, with this definition in mind it seems obvious that a stack is a generalised sheaf. But here is my doubt:
When defining a sheaf $T$ over a space $X$, is not unusual to see the following diagram (naively)
$ T(X) \rightarrow T(U) \stackrel{\longrightarrow}{\longrightarrow} T(U \cap U)$
While, saying that descent data are effective is like asking a similar diagram, but there is the difference that here descent satisfies cocycle condition, something which is naively in $U \cap U \cap U$.
Recalling that (for example) locally constant sheaves automatically satisfy the cocycle condition because of their correspondent covering spaces do.
So my question is, at the light of my interpretation, the cocycle condition seems to me the only obstruction to the fact that a stack is a generalised sheaf. Am i wrong? Every sheaf trivially satisfies cocycle condition?

A: I am not sure I understood the question, but will try to say things that point you in the direction of further topics.
The following sentence that Qiaochu wrote is spot on:

Stacks take values in 2-categories, while sheaves take values in categories.

The difference between "presheaves" and "sheaves" is some form of descent—i.e. being able to glue global gadgets by providing local gadgets together with evidence that things are "the same" on overlaps.
As you deal with things having a greater degree of flexibility (more formally, "category level"), the nature of this "evidence" becomes more complex. Two elements of a set are either the same, or not. Two objects in a category can be isomorphic in many ways, and the "evidence" refers to the specific isomorphisms which must then be  compatible (i.e. the cocycle condition).
I can say two things that may be enlightening if you have not heard them before.
$\text{}$1. This does not stop after two steps, and there is a uniform formulationthat works up through infinity-categories—the notion here is of the Čech nerve as a simplicial diagram (so all the spaces $U \times U \times \ldots \times U$, where $\times$ denotes the fiber product over the base, with a natural simplicial structure).
In that case writing out the analogs of the cocycle condition is impratical, so we do not do it. Instead, the sheaf condition is that$$F(X) \to F(U) \to F(U \times U) \to F(U \times U \times U) \to \ldots$$($\ldots$with many more arrows, see "augmented cosimplicial diagram") is a limit diagram in a suitable infinity-categorical sense. (There is also a fibered category analog for when we want to be rigorous.) In the case when the "target of $F$" is something like infinity-categories this has a nice interpretation as an object of each $F(U^{\times_X n})$ together with a certain collection of morphisms between their images under various functors.
$\text{}$2. The above definition is always true. That is if you are dealing with sheaves of sets/categories and you ask that the above be a limit diagram you get the correct notion of descent. The higher conditions are automatically satisfied because sets/categories only have so much "flexibility" in how they can be "the same". You can get the general gist by convincing yourself of this in the case of an ordinary sheaf or a category.


text:
Q: how to hide dropdownlist1 selected values in dropdownlist2 dynamically in ASP.Net Mvc3Razor Iam using ASP.Net MVC3 Razor, I have two dropdowns in .cshtml, let's say ddl1 and ddl2.
I have binded data in the controller and sent to dropdowns using viewbag.
Both the ddls have same data in it like A,B,C,D. If I select A in ddl1, it should hide A in ddl2; if select B it should hide B in ddl2.  Could any one help me out using javascript or jquery.
This is my controller where I have binded..
 public ActionResult Index()
        {
            ViewBag.ddl1 = new SelectList(db.Collection, "ID", "Name");
            ViewBag.ddl2 = new SelectList(db.Collection, "ID", "Name");
            return View();
        }

and the View is(.cshtml for the above action)

       @Html.DropDownList("ddl1", "-select name-")

        @Html.DropDownList("ddl2","-select name-")

Thanx in Advance

A: here is the main idea. Let's say we have 2 dropdown lists:
<select id="ddl1">
    <option>Select</option>
    <option value="A">A</option>
    <option value="B">B</option>
    <option value="C">C</option>
    <option value="D">D</option>
</select>

<select id="ddl2">
    <option>Select</option>
    <option value="A">A</option>
    <option value="B">B</option>
    <option value="C">C</option>
<option value="D">D</option>
</select>

to remove the ddl1 selected value from ddl2:
$('#ddl1').change(function() {
    $('#ddl2 option').each(function() {
        if ($(this).attr('value') == $('#ddl1 option:selected').attr('value')) {
            $(this).remove();
        }
    });
});

Also to remove the ddl2 selected value from ddl1:
$('#ddl2').change(function() {
    $('#ddl1 option').each(function() {
        if ($(this).attr('value') == $('#ddl2 option:selected').attr('value')) {
            $(this).remove();
        }
    });
});

If you want to reload the dropdown values back on every change, simply call your dropdown populating function again. I hope this will help...
Also here is the demo: http://jsfiddle.net/cJ8wN/8/


text:
Q: javascript audio pause previous playing audio when current playing in react I have a simple function in react which plays the audio..
handlePlayMusic() {

    this.audio = new Audio(music)
    this.audio.play()
}

handleStopMusic() {

    this.audio.pause()
}

When I play the new music i. e. the value of music in Audio(music) is changed new music is played but previously played music countinues to play. I want it to be stopped when I play new music..
Any help ??

A:
Stop the earlier instance of this.audio before playing it!

var obj = {
  handlePlayMusic: function(music) {
    try {
      this.audio.pause();
      this.audio.currentTime = 0;
    } catch (e) {
      console.log(e);
    }

    this.audio = new Audio(music);
    this.audio.play()
  },
  handleStopMusic: function() {

    this.audio.pause()
  }
};
obj.handlePlayMusic('audio/audio.mp3');

Fiddle Demo(Let audio get loaded first!)


text:
Q: Boot live ISO from persistent partition I've installed ArchCraft with a persistent partition on my USB key using Rufus.
Now, when I boot from the live USB, I have an additional empty partition called "persistence", with just "persistence.conf".
I have a total of 2 partitions:
/dev/sdb1 (boot partition, not saving changes)
/dev/sdb2 (persistent)
When I make changes to the system, e.g install packages or change settings, these changes do not persist as the entire system partition is still loaded in live mode.
I'd like to boot the system with the persistent partition and use it as my root partition.
What is the best way to achieve this?

A:
What is the best way to achieve this?

Use either an Ubuntu or Debian-Live based derivative if you want to create a persistent drive using Rufus.
The problem is that Linux distro maintainers can't agree to a common method of enabling persistence (heck, they can't even agree if the kernel parameter to provide should be called persistence or persistent) and every other distro seems to be falling prey to the NIH syndrome where, instead of looking at what others do and trying to follow suit, they appear to be reinventing the wheel...
Then end result is that it makes it extraordinarily difficult and time consuming for an application like Rufus to try to detect and support every method of enabling persistence out there. As a result, Rufus only supports the method of enabling persistence for the two most common methods used by Debian or Ubuntu.
Most likely, ArchCraft does not use either of a Debian-like or Ubuntu-like way of enabling persistence, and whereas Rufus will have created a persistent partition that is compatible with Debian (default), ArchCraft is unable to use it.
Thus, if you want to have persistence working with a drive that was created by Rufus, you need to use either Debian-Live (or a direct derivative of Debian-Live), or Ubuntu (or a direct derivative of Ubuntu).


text:
Q: I purchased a number in twilio. How do I forward calls and texts to my phone? I purchased a number in twilio. How do I forward calls and texts to my phone? I'm not a developer, so any simple method or step-by-step instructions are appreciated.

A: Twilio developer evangelist here.
Welcome to StackOverflow!
You can do that with Twilio Studio! More details here, but in short, to forward messages:

*

*Access the Studio Dashboard in your Studio Console.

*Make a new Studio flow by clicking the + sign.

*Pick a name for your flow and click "next".
"

*Click "Start from scratch" followed by Next".

*From the "Widget Library" on the right, drag and drop a "Send Message" widget into the flow.

*Click and drag the "Trigger" widget's "Incoming Message" lead to connect it to the "Send Message" widget.

*Click the "Send Message" widget to show the widget's options on the right. Type in the MESSAGE BODY field:

*Under the SEND MESSAGE widget options, scroll down to click to expand MESSAGING & CHAT CONFIG. Type in the desired destination (number to forward to with E.164 formatting) in the SEND MESSAGE TO field, and then click Save.

*Select "Publish".

To activate the Studio flow:

*

*Visit the Active Numbers page in your Console.

*Select the phone number you want to edit.

*Scroll to the Voice & Fax section to modify the phone number's routing like so:

*Select "Save".

To forward calls, it'd be similar: for the Studio "Trigger" widget's "Incoming Call" lead, it should connect it to the "Send Call" widget.
Let me know if this helps! <3 :D


text:
Q: Add empty rows into a data frame depending ont vector values I have a vector with two values
v <- c("Sp4","Sp5")
and a data frame such as
col1 col2 col3
Sp1 2 2
Sp2 4 6
Sp3 6 4

and I would like to add NA at this data frame depending on the vector such as:
col1 col2 col3
Sp1 2 2
Sp2 4 6
Sp3 6 4
Sp4 NA NA
SP5 NA NA

I tried:
for (i in v){
  df1[nrow(df1),] <- i
}

A: We can use bind_rows after creating 'v' as a tibble
library(dplyr)
df1 %>%
   bind_rows(tibble(col1 = v))
#   col1 col2 col3
#1  Sp1    2    2
#2  Sp2    4    6
#3  Sp3    6    4
#4  Sp4   NA   NA
#5  Sp5   NA   NA

Or with rbind from base R
rbind(df1, data.frame(col1 = v, col2 = NA, col3 = NA))


text:
Q: Extract some lines in multiple text files I have many text files. In those file only few lines interest me. I though that Batch would be efficient to deal with my problem so I spent the last two days trying to learn the basic of that language.
Basically I want to go through all my files (for simplicity they are in the same folder), extract the few lines that I need and copy them in one line in an output file.
So far I managed to:
Extract all lines from every files in one output file
FOR %%f IN (*.whl) DO FOR /F "delims=|" %%l in (%%f) DO echo %%l >> output.txt

Extract the lines (5 and 10) I want from one file
(FOR /L %%i IN (1,1,5) DO SET /P line1=) < file.txt
(FOR /L %%i IN (1,1,10) DO SET /P line2=) < file.txt
>> output.txt ECHO %line1% %line2%

Now I'm trying to combine those two previous code:
That code give me the correct output for the first file but doesn't loop through all files. If I add a goto nxt_file at the end of the block :extract_lines it just doing the first file over again.
:nxt_file
FOR %%f IN (*.whl) DO (
    set outfile=%%f
    goto extract_lines)

:extract_lines
(FOR /L %%i IN (1,1,5) DO SET /P line1=) < %file%
(FOR /L %%i IN (1,1,10) DO SET /P line2=) < %file%
>> output.txt ECHO %line1% %line2%

That code loop but fail to copy the lines I want in the output.
FOR %%f IN (*.whl) DO (
    (FOR /L %%i IN (1,1,5) DO SET /P line1=) < %%f
    (FOR /L %%i IN (1,1,10) DO SET /P line2=) < %%f

    ECHO %line1% %line2%  >>  output.txt
)

But if I change it adding set file=%%f and replace < %%f by < %file% it doesn't run.
By the way I used this method, which work well but I wonder if I can sort it out with the method I used so far.
Thank for your help!
EDIT: As you can see this is my first post and also my first steps in that language. I welcome any advice to make this question and maybe future question more detailed as I may not perceive every information that are relevant to an advanced user.
Thanks to @Magoo my question is solved, but I would be interested by any advice to make this code better (I guess there is a more efficient way to select only the line I need instead of using FOR /L and going through every line until the right one).
Also if any person have explanation about the different problems I described (e.g. < %%f instead of < %file%) would be most welcomed.

A: You may be able to do it all in a single For loop using FindStr.
@Echo Off
>outfile.txt (For /F "Tokens=2* Delims=:" %%A In ('FindStr/N "^" *.whl'
) Do If "%%A"=="5" (Set "_=%%B") Else If "%%A"=="10" (Call Echo=%%_%% %%B))

A: Seems like an XY problem to me (IOW - attempting to fix a method, not a problem)
(this is untested, as it has to be, given the lack of detail)
FOR %%f IN (*.whl) DO (
 (FOR /L %%i IN (1,1,5) DO SET /P line1=) < %%f
 (FOR /L %%i IN (1,1,10) DO SET /P line2=) < %%f
 >> output.txt CALL ECHO %%line1%% %%line2%%
)

should find each *.whl file, assigning the name to %%f, then read the first 5 lines from that file to line1 and the first 10 to line2, leaving the fifth an tenth lines in those two variables, then accumulate the outputs into output.txt
IF I am interpreting your method correctly...


text:
Q: Lazy Image loading w/ caching I am not able to form question title because this question is like descriptive.But I can explain clearly here.This is related to image cache in ios.
My requirement : I want to create one list which contain Image view and that image loaded from online. Also i need to implement cache for that image (because every time if i loaded fom online it will take too much time and also network consuming).
Note: Generally we are preparing cache key for that image based on that image link.
Is there any other way to prepare cache key ?
After loading listview i can click on any row and i will redirect to details page. In that detailed page i have edit option and i can change that image. And i resubmit to server. Once I complete uploading i force close my application and i open as fresh app. In this case in server side no change in image link because that image link like http://www.uigarden.net/english/images/108.jpg
Now i load that tableview than and all images frying to load from either cache or server.
So we have two cases.
1) From cache:
    If there is no changing in link and that link id is available in cache folder than it will load from cache. Here
Mu issue : I can not able to find wether it is already edited or not edited. So i can not able to load newly edited image, because i already cached that image based on link.
2) From direct link if that link based key not available in cache .
How can we distinguish wether it is edit image or old image ?
please help me

A: AFNetWorking in combo with NSURLCache is great

A: Solution is
 - SDWebImage
You just need to #import <SDWebImage/UIImageView+WebCache.h> to your project, and you can define also the placeholder when image is being downloaded with just this code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        static NSString *CellIdentifier;
        CustomCell *cell = [tableview dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

        MyObject *object = (MyObject *)[self.list.array objectAtIndex:indexPath.row];

        [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
                       placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

        return cell;
}

It also cache downloaded images and gives you great performance.


text:
Q: Capability to read/edit page in wp-admin only for administrators I want to create a page which is only for editable and readable (within wp-admin) for administrators. To restrict other users to edit any page (and not only the own ones) is not the solution as I want them to have this capability.
I am using the plugin called "Access" by wp-types.

A: Thanks brasofilo!
add_action( 'pre_get_posts', 'hide_pages_to_user_except_admins' );
function hide_pages_to_user_except_admins( $query ) {
if( !is_admin() )
    return $query;
global $pagenow;
$pages = array('201','38','99'); //page ids
if(
    'edit.php' == $pagenow
    && ( get_query_var('post_type') && 'page' == get_query_var('post_type') )
)
    $query->set( 'post__not_in', $pages );

return $query;
}


text:
Q: Exception: Package android does not belong to 2000 I have my Android device connected to my laptop and When I try to run:
adb shell pm set-install-location 2

I am getting this error:
"Package android does not belong to 2000"

What does it means?
How can I fix it?

A: After "adb devices" just type "adb shell" (enter) then type "su" (enter and accept on the phone display), This enables SuperUser. Now you can type "pm set-install-location 2"
Verify the new destination with "pm get-install-location"

A: "Basically speaking: You can't. At least not without rooting.
The main reasons Android does not allow you to install an application to your external SD card are:
Security: It's the main reason for that restriction. Basic file systems like NTFS or FAT (any version of it) do not allow for Unix-like permission management.
This means: any application would be able to write to any file on that storage.
Thinking of malicious apps, they would be able to replace proper apps with fake/infected ones, bricking your phone and rendering it unusable.
Volatile storage: Your external SD card is not safe to be inserted in your device all the time. You are able to eject it any time what makes your SD card not a very good candidate for a permanent storage. Consider apps running off of your SD card and you eject it. Those apps will just crash and all other apps saved on your SD card are gone as well. You can't use them at that time and the data of those app is also affected by reason #1."


text:
Q: How to define a JPA domain module that works using Spring Boot 2.0 with Hibernate JPA and Gradle? I am working on a multi module Java 9 project that uses Spring Boot 2.0 with Hibernate. Furthermore I use Gradle 4.6 to build this multi module project. Since it is a greenfield project I'd love to start declaring Java 9 modules.
One of them is a domain module and it is defined as follows
module offer.server.domain {

    requires java.sql;
    requires hibernate.jpa;
    requires hibernate.core;

    exports some.package;
}

The module has the following dependencies:
compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
+--- org.mapstruct:mapstruct-jdk8 -> 1.2.0.Final
+--- project :mapping
|    +--- org.mapstruct:mapstruct-jdk8 -> 1.2.0.Final
|    \--- org.springframework:spring-context -> 5.0.4.RELEASE
|         +--- org.springframework:spring-aop:5.0.4.RELEASE
|         |    +--- org.springframework:spring-beans:5.0.4.RELEASE
|         |    |    \--- org.springframework:spring-core:5.0.4.RELEASE
|         |    |         \--- org.springframework:spring-jcl:5.0.4.RELEASE
|         |    \--- org.springframework:spring-core:5.0.4.RELEASE (*)
|         +--- org.springframework:spring-beans:5.0.4.RELEASE (*)
|         +--- org.springframework:spring-core:5.0.4.RELEASE (*)
|         \--- org.springframework:spring-expression:5.0.4.RELEASE
|              \--- org.springframework:spring-core:5.0.4.RELEASE (*)
+--- org.springframework.data:spring-data-jpa -> 2.0.4.RELEASE
|    +--- org.springframework.data:spring-data-commons:2.0.4.RELEASE
|    |    +--- org.springframework:spring-core:5.0.4.RELEASE (*)
|    |    +--- org.springframework:spring-beans:5.0.4.RELEASE (*)
|    |    \--- org.slf4j:slf4j-api:1.7.25
|    +--- org.springframework:spring-orm:5.0.4.RELEASE
|    |    +--- org.springframework:spring-beans:5.0.4.RELEASE (*)
|    |    +--- org.springframework:spring-core:5.0.4.RELEASE (*)
|    |    +--- org.springframework:spring-jdbc:5.0.4.RELEASE
|    |    |    +--- org.springframework:spring-beans:5.0.4.RELEASE (*)
|    |    |    +--- org.springframework:spring-core:5.0.4.RELEASE (*)
|    |    |    \--- org.springframework:spring-tx:5.0.4.RELEASE
|    |    |         +--- org.springframework:spring-beans:5.0.4.RELEASE (*)
|    |    |         \--- org.springframework:spring-core:5.0.4.RELEASE (*)
|    |    \--- org.springframework:spring-tx:5.0.4.RELEASE (*)
|    +--- org.springframework:spring-context:5.0.4.RELEASE (*)
|    +--- org.springframework:spring-aop:5.0.4.RELEASE (*)
|    +--- org.springframework:spring-tx:5.0.4.RELEASE (*)
|    +--- org.springframework:spring-beans:5.0.4.RELEASE (*)
|    +--- org.springframework:spring-core:5.0.4.RELEASE (*)
|    +--- org.aspectj:aspectjrt:1.8.12 -> 1.8.13
|    \--- org.slf4j:slf4j-api:1.7.25
+--- org.hibernate:hibernate-core -> 5.2.13.Final
|    +--- org.jboss.logging:jboss-logging:3.3.1.Final -> 3.3.2.Final
|    +--- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
|    +--- org.javassist:javassist:3.22.0-GA
|    +--- antlr:antlr:2.7.7
|    +--- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.1.Final
|    +--- org.jboss:jandex:2.0.3.Final
|    +--- com.fasterxml:classmate:1.3.0 -> 1.3.4
|    +--- dom4j:dom4j:1.6.1
|    \--- org.hibernate.common:hibernate-commons-annotations:5.0.1.Final
|         \--- org.jboss.logging:jboss-logging:3.3.0.Final -> 3.3.2.Final
+--- org.javamoney:moneta -> 1.1
|    +--- javax.money:money-api:1.0 -> 1.0.1
|    \--- javax.annotation:javax.annotation-api:1.2 -> 1.3.1
\--- com.neovisionaries:nv-i18n -> 1.22

And in my Gradle build I declare the module path as follows:
compileJava {
    doFirst {
        inputs.property("moduleName", "offer.server.domain")
        options.compilerArgs = [
                '--module-path', classpath.asPath,
                '--add-modules', 'java.se.ee'
        ]
        classpath = files()
    }
}

When I run gradle clean compileJava I get the following error:
error: the unnamed module reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: the unnamed module reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: the unnamed module reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module org.mapstruct reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module org.mapstruct reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module org.mapstruct reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.data.jpa reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module spring.data.jpa reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module spring.data.jpa reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module moneta reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module moneta reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module moneta reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module nv.i18n reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module nv.i18n reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module nv.i18n reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.context reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module spring.context reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module spring.context reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.data.commons reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module spring.data.commons reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module spring.data.commons reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.orm reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module spring.orm reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module spring.orm reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.aop reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module spring.aop reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module spring.aop reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.jdbc reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module spring.jdbc reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module spring.jdbc reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.tx reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module spring.tx reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module spring.tx reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.beans reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module spring.beans reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module spring.beans reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.expression reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module spring.expression reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module spring.expression reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.core reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module spring.core reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module spring.core reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module aspectjrt reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module aspectjrt reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module aspectjrt reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module slf4j.api reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module slf4j.api reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module slf4j.api reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module hibernate.commons.annotations reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module hibernate.commons.annotations reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module hibernate.commons.annotations reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module org.jboss.logging reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module org.jboss.logging reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module org.jboss.logging reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module javassist reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module javassist reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module javassist reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module antlr reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module antlr reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module antlr reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module jboss.transaction.api.1.2.spec reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module jboss.transaction.api.1.2.spec reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module jboss.transaction.api.1.2.spec reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module jandex reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module jandex reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module jandex reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module com.fasterxml.classmate reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module com.fasterxml.classmate reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module com.fasterxml.classmate reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module dom4j reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module dom4j reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module dom4j reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module money.api reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module money.api reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module money.api reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module java.annotation reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module java.annotation reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module java.annotation reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.jcl reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module spring.jcl reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module spring.jcl reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module hibernate.core reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module hibernate.core reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module hibernate.core reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module hibernate.jpa reads package javax.transaction.xa from both jboss.transaction.api.1.2.spec and java.sql
error: module hibernate.jpa reads package javax.transaction from both jboss.transaction.api.1.2.spec and java.transaction
error: module hibernate.jpa reads package javax.annotation from both java.annotation and java.xml.ws.annotation
/Users/saw303/dev/adcubum/gesus/offer-server/domain-base/src/main/java/module-info.java:1: error: module offer.server.domain reads package javax.transaction.xa from both java.sql and jboss.transaction.api.1.2.spec
module offer.server.domain {
^
88 errors

I am aware of the following questions on Stackoverflow

*

*Hibernate 5.2: java.transaction.xa package conflict in Java 9

*Package conflicts with automatic modules in Java 9
but to be honest these did not fix any my problems and I am not sure whether I understood the Java 9 compiler error messages correctly yet.
Why for example does the compile complain about the automatic module org.mapstruct?
What is the issue about this automatic module jboss.transaction.api.1.2.spec. It seems to be the key reason of my issue since the compiler repeats naming that transitive automatic module introduced by my Hibernate dependency.
Does anyone of you guys know how to solve this thing and can give me some directions?
Removing Hibernates 5.2.13 transient dependency jboss.transaction.api.1.2.spec to get further
After removing Hibernates 5.2.13 transient dependency jboss.transaction.api.1.2.spec in my Gradle build
dependencyManagement {
        imports {
            mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
        }
        dependencies {
            // ...

            dependency('org.hibernate:hibernate-core:5.2.13.Final') {
                exclude 'org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec'
            }
        }
    }

I managed to get a step further. But now the compile complains about javax.annotation module.
error: the unnamed module reads package javax.annotation from both java.xml.ws.annotation and java.annotation
error: module org.mapstruct reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.data.jpa reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module moneta reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module nv.i18n reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.data.commons reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.orm reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.aop reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.jdbc reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.tx reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.beans reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.expression reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.core reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module aspectjrt reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module slf4j.api reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module hibernate.commons.annotations reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module org.jboss.logging reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module javassist reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module antlr reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module jandex reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module com.fasterxml.classmate reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module dom4j reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module money.api reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module java.annotation reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.jcl reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module hibernate.core reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module spring.context reads package javax.annotation from both java.annotation and java.xml.ws.annotation
error: module gesus.mapping.base reads package javax.annotation from both java.xml.ws.annotation and java.annotation
error: module hibernate.jpa reads package javax.annotation from both java.annotation and java.xml.ws.annotation
29 errors

How can I trace the problem to its source? And is it actually possible to use Hibernate 5.2.x within a Java 9 module?


text:
Q: JSDoc not picking up on data child attribute type override I've noticed a problem when working with a parent class that's extended by a child class.
Both classes have a 'data' attribute, in the parent class it's a generic 'Object' type and in the child class it is of type 'DogData'.
The parent's constructor is setting 'this.data = data' which should override the type to whatever the child's attribute's type is, but this is not happening.
Please find a small reproducible example below:
I hope I'm missing something and please don't hesitate to point it out if I am.
Thanks in advance
 * The animal base class
 * @class
 */
class Animal {
    /**
     * @param {number} id The ID of the animal
     * @param {Object} data The data of the animal
     */
    constructor (id, data) {
        this.id = id
        this.data = data
    }
}

/**
 * The Dog class
 * @class
 * @extends Animal
 */
class Dog extends Animal {

    /**
     * @typedef DogData
     * @property {number} age
     * @property {string} name
     */

    /**
     * @param {number} id The ID of the dog
     * @param {DogData} data The data of the dog
     */
    constructor (id, data) {
        super(id, data)
    }
}

const dog = new Dog(1, { age: 10, name: 'Foobar' })
dog.data. // Will only autocomplete if this.data is explicitly set inside the Dog constructor

A: Define the property before the constructor and use @type on it.
class Dog extends Animal {

    /**
     * @typedef DogData
     * @property {number} age
     * @property {string} name
     */

    /**
     * @type {DogData}
     */
    data;

    /**
     * @param {number} id The ID of the dog
     * @param {DogData} data The data of the dog
     */
    constructor (id, data) {
        super(id, data)
    }
}


text:
Q: CPUERR light after stress test and failure to POST. Is this definitely a CPU failure? I have a high-value CPU (XEON E5-2698 v3) CPU that has failed a stress test (I believe). The ASUS Z10PE motherboard is lighting the CPUERR_LED3 light, the system fails to boot, stopping at Q-code 04 "PCH inisialising before microcode loading".
When swapping/isolating the pair of CPUs, this unit seems to be the failure point. Under what circumstances can a CPU fail, or was this a faulty part? Will a CPU allow itself to overheat or will safeties generally keep it protected? I can see CPU temperature was maintained to sub 60 degC for the test, at least as far as the log got.


text:
Q: study of two sequences I need to study wether thos two sequences converge or not.
1) $u_n=n\sum_{k=1}^{2n+1} \frac{1}{n^2+k}$
2) $v_n=\frac{1}{n}\sum_{k=0}^{n-1} \cos(\frac{1}{\sqrt{n+k}})$
For the first i get it converges to $0$ by just expressing the sum as a fraction (not very smart imo).

A: *

*Note that $(n^{2} +k) \leq (n^{2}+2n+1)$ whenever $k \in\left\{1,2,\cdots,(2n+1)\right\}$. So we have that $\frac{1}{n^{2}+k} \geq \frac{1}{n^{2}+2n+1} =\frac{1}{(n+1)^{2}}$. Similarly $n^{2}+1 \leq n^{2}+k$ and so we have that $\frac{1}{n^{2}+1}\geq \frac{1}{n^2+k}$. So we get that $$\sum_{k=1}^{2n+1} \frac{1}{n^{2}+k} \geq \sum_{k=1}^{2n+1} \frac{1}{n^{2}+2n+1} \ \ \mbox{and} \ \ \sum_{k=1}^{2n+1} \frac{1}{n^{2}+k} \leq \sum_{k=1}^{2n+1}\frac{1}{n^{2}+1}$$ Using this we have $$ \frac{2n^{2}}{n^{2}+2n+1} \leq u_{n} \leq \frac{2n^{2}}{n^{2}+1}$$ Now apply the Squeeze Theorem.

A: How can $u_n$ converge to zero?
$$ u_n = n\sum_{k=1}^{2n+1}\frac{1}{n^2+k}\geq n\cdot\frac{2n+1}{(n+1)^2} \geq 2-\frac{3n+2}{(n+1)^2}.$$
On the other hand,
$$ u_n \leq n\cdot\frac{2n+1}{n^2+1} \leq 2+\frac{n-2}{n^2+1},$$
hence:
$$\lim_{n\to +\infty} u_n = 2.$$
For the second sum, since $\cos x \geq 1-\frac{x^2}{2}$ over $[0,1]$,
$$ v_n \geq \frac{1}{n}\left(n-\frac{1}{2}\sum_{k=0}^{n-1}\frac{1}{n+k}\right)\geq \frac{1}{n}\left(n-\frac{1}{2}\right),$$
but since $\cos x\leq 1-\frac{4x^2}{\pi^2}$ holds over the same interval,
$$ v_n \leq \frac{1}{n}\left(n-\frac{4}{\pi^2}\sum_{k=0}^{n-1}\frac{1}{n+k}\right)\leq \frac{1}{n}\left(n-\frac{4n}{\pi^2(2n-1)}\right),$$
so:
$$\lim_{n\to +\infty} v_n = 1.$$


text:
Q: Snapshot timestamps not matching I want to run a snapshot test. When I run the tests, the only problems I have are the ones with timestamp. How do I fix it?
This is a component, which passes all tests, tested the same way my failing components.
Passing component
return (
  <div className={`accordion-section ${className}`}>
    <button tabIndex={0} className={'accordion-btn'} onClick={toggleAccordion}>

        <Text isRtl={rtl}>{title}</Text>

      <ArrowTemplate
        direction={isAccordionExpanded ? 'up' : 'down'}
        onClick={toggleAccordion}
        rtl={rtl}
        color={color}
      />
    </button>
    <AccordionContent
      tabIndex={0}
      className={'accordion-content'}
      height={height}
      isAccordionExpanded={isAccordionExpanded}
      ref={element}
      aria-expanded={isAccordionExpanded}
    >

        <Text isRtl={rtl}>{content}</Text>

    </AccordionContent>

);

Passing test:
let wrapper;
beforeEach(() => {
  wrapper = mount(


text:
Q: How to add a custom task pane to Visual Studio I am creating an add-in for Visual Studio 2012. I want to create a custom task pane that I could fill with files and folders that could be selected and opened by a developer. I have found a lot of documentation on how to create add-ins with task panes for MS Office, but I can't find anything about how to add a task pane to Visual Studio with an add-in.
Thanks.

A: If you have the professional version of 2012 you can use the following link.
http://msdn.microsoft.com/en-us/library/aa942846(v=vs.110).aspx
Essentially you will need to add a User Control (this becomes your custom task pane)
If you are using express edition of Visual Studio it would be ideal to download and use NetOffice - http://netoffice.codeplex.com/
The following is an example of the code I have used in my project. I have added a user control called UserControl1. This is using the Ultimate version however it is the same for at least the professional version.
Private myUserControl1 As UserControl1
Private myCustomTaskPane As Microsoft.Office.Tools.CustomTaskPane

Private Sub ThisAddIn_Startup() Handles Me.Startup

    myUserControl1 = New UserControl1
    myCustomTaskPane = Me.CustomTaskPanes.Add(myUserControl1, "Picture Table Editor Pane")

    With myCustomTaskPane
        .DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionFloating
        .Width = 300
        .Height = 400
        .DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionLeft
        .Width = 300
    End With

End Sub


text:
Q: Calculate prediction interval for SAR model (errorsarlm function in R) I would like to predict prediction interval for a SAR model (function errorsarlm in R - package spdep). While the function predict.lm allows to set interval='prediction' parameter to predict the upper and lower boundary of predictions, the function predict.sarlm does not.
Is it because it is incorrect to estimate the prediction interval of a SAR or simply because it hasn't implemented?
Is it possible to calculate those prediction intervals manually?
Below a replicable example:
library(spdep)
data(oldcol)
lw <- nb2listw(COL.nb, style="W") #listw object
mod <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, lw) #SAR model
predict(mod, COL.OLD) #here I would like to get prediction intervals


text:
Q: Google Firebase Functions - Timeout when doing HTTP requests So I am trying to make a simple proxy (I think that's the right word) and I've come up with some code that works fine locally. I can call 'firebase serve --only functions' and the function works fine and I get expected results. Now when I deploy this same code, and try calling it it just times out. I have no idea why, so I was hoping I could get some help.
Here's the code:
//Variables
const functions = require('firebase-functions');
const express = require('express');
const cors = require('cors');
const request = require('request');

//App
const app = express();
app.use(cors({ origin: true }));

//Endpoints
app.get('/**', function(req, res) {
    request('https://example.com' + req.url, function(err, proxyRes, body) {

        //Err
        if (err) {
            res.send('Error: ' + err.code);
            return
        }

        //Res
        res.status(200).send(body);
    });
});

//Functions
exports.proxy = functions.https.onRequest(app);

A: HTTP functions will time out if they don't send a response.  This means your request() is probably failing, and it's probably failing because, on the free Spark payment plan, you can't make outgoing requests to services that Google doesn't fully control.
Your function should send a response in all conditions in order to avoid a timeout.  This means you should be checking for errors all the time.


text:
Q: How to rotate an image using the shortest route in React Native I'm trying to rotate an image using React Native. I have managed to do this as shown in the example below, but I would prefer that the arrow spins to the new bearing using the shorter route (i.e. clockwise in this case instead of counterclockwise).
If the current bearingAnim value is 315 and the next value is 45 the rotation will transition backwards, rather than going from 315 => 45.
How can I adjust the code to use the shortest rotation?
const bearing = this.bearingAnim.interpolate({
  inputRange: [0, 360],
  outputRange: ['0deg', '360deg'],
});

return <Animated.Image style={{ transform: [{ rotate: bearing }] }} source={markerGreen} />;

A: As each direction may be set as a positive or negative angle (clockwise/counter clockwise rotation), e.g. 315 (clockwise) is -45 (counter clockwise), you may compare the absolute values of a delta between current direction and new direction (both clockwise and counter clockwise) and set your new angle to the one having least absolute value of the delta:
const getNewDirectionangle = (direction, newDirection) => {
          const delta = {
            clockwise: (newDirection-direction)%360,
            counterClockwise: (newDirection-direction-360)%360
          }
          return
              Math.abs(delta.clockwise) < Math.abs(delta.counterClockwise) ?
              direction + delta.clockwise :
              direction + delta.counterClockwise

      }

Following is a React.js live-demo to illustrate the concept:

const { useState } = React,
      { render } = ReactDOM,
      rootNode = document.getElementById('root')

const Pointer = ({rotationAngle}) => {

  return (

      <div
        className="pointer"
        style={{transform: `rotate(${rotationAngle}deg)`}}
      />

  )
}

const Controls = ({onRotate}) => {
  const [azimuth, setAzimuth] = useState(),
        onInput = ({target:{value}}) => setAzimuth(value%360)
  return (
    <form>
      <input type="number" onChange={onInput} />
      <input type="button" value="Rotate" onClick={() => onRotate(azimuth)} />
    </form>
  )
}

const App = () => {
  const [direction, setDirection] = useState(0),
        onRotate = newDirection => {
          const delta = {
            clockwise: (newDirection-direction)%360,
            counterClockwise: (newDirection-direction-360)%360
          }
          setDirection(
              Math.abs(delta.clockwise) < Math.abs(delta.counterClockwise) ?
              direction + delta.clockwise :
              direction + delta.counterClockwise
          )
        }
  return (

      <Pointer rotationAngle={direction} />
      <Controls {...{onRotate}}/>

  )
}

render (
  <App />,
  rootNode
)
.wrapper {
  width: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.map {
  width: 100%;
  height: 120px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  background-image: url("https://i.stack.imgur.com/3yuKI.png");
  background-size: cover;
  margin: 5px
}

.pointer {
  transition: transform 1s ease-in;
  transform-origin: 50% 58%;
  background-image: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMS43NTIgMjYuMjU2Ij48ZGVmcyBpZD0iZGVmczUiPjxjbGlwUGF0aCBpZD0iYSIgY2xpcFBhdGhVbml0cz0idXNlclNwYWNlT25Vc2UiPjxwYXRoIGQ9Ik0xNi4zMy0uNDhoODMuNzM0djEwOS4zNUgxNi4zM3oiIGlkPSJwYXRoMiIgLz48L2NsaXBQYXRoPjwvZGVmcz48cGF0aCBkPSJNMjguOTk5IDg3LjMzNmMtMTYuMDUtMTYuMDUtMTYuMDUtNDIuMDg3IDAtNTguMTM3QzM4LjY4NSAxOS41MTIgNDguMzcgOS44MjYgNTguMDc3LjE0TDg3LjEzNiAyOS4yYzE2LjA1IDE2LjA1IDE2LjA1IDQyLjA4NyAwIDU4LjEzNy0xNi4wNSAxNi4wNS00Mi4wODcgMTYuMDUtNTguMTM3IDB6IiBjbGlwLXBhdGg9InVybCgjYSkiIGZpbGw9IiM3MGFkNDciIGZpbGwtcnVsZT0iZXZlbm9kZCIgdHJhbnNmb3JtPSJtYXRyaXgoLjI2NDU4IDAgMCAuMjY0NTggLTQuNDg4IC0uMDM3KSIgaWQ9InBhdGg3IiAvPjxwYXRoIGQ9Ik0zLjA3NCAxNS4zODJjMC00LjI4OSAzLjQ5NS03Ljc3MyA3Ljc5NC03Ljc3MyA0LjMwNSAwIDcuNzk0IDMuNDg0IDcuNzk0IDcuNzczIDAgNC4yOTQtMy40ODkgNy43NzMtNy43OTQgNy43NzMtNC4zIDAtNy43OTQtMy40NzktNy43OTQtNy43NzN6IiBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGlkPSJwYXRoOSIgLz48L3N2Zz4=");
  background-repeat: no-repeat;
  background-size: cover;
  width: 50px;
  height: 60px;
  margin: 20px;
}

A: I wrote you a function that calculates the correct angle according to the old direction
She needs to get the old and new angle
It will return the direction you need to add to reach the new direction
(If the arrow needs to move back it will return minus and it will move back)

function newRotate(oldV, newV) {
  const diff1 = newV - oldV;
  let myOldV = oldV;
  if (newV < oldV) newV += 360;
  else myOldV += 360;

  const diff2 = newV - myOldV;
  const shortDiff = Math.abs(diff1) < Math.abs(diff2) ? diff1 : diff2;
  return oldV + shortDiff;
}

Here's how to use it
const value =newRotate(oldValue,newValue)

 Animated.timing(routeAnimtion, {
      toValue: value,
      duration: 10,
    }).start();


text:
Q: Put a space inside array in two-dimensional array I have two arrays:
$role = isset($_POST['role'])?$_POST['role']:'';
$details = isset($_POST['details'])?$_POST['details']:'';

Output for arrays is:
Role: Array ( [0] => leader [1] => follower )
Details: Array ( [0] => lead [1] => follow )

I want to assign leader to lead and follower to follow. Then I put two arrays into one:
foreach( $role as $rl => $r )
{
  $array_test3[] = array($r, $details[$rl]);
}

Output for print_r($array_test3) is:
Array ( [0] => Array ( [0] => leader [1] => lead ) [1] => Array ( [0] => follower [1] => follow ) )

Then I tried to implode an array:
$test3 = implode('<|>',array_map('implode',$array_test3));

Output for echo $test3.'<br/>'; is:
leaderlead<|>followerfollow

But I want is to get the following:
leader<|>lead<|>follower<|>follow

How can I do this?

A: You need to implode the inner array using the same parameter:
$test3 = implode('<|>',array_map(function ($innerArray) {
   return implode("<|>",$innerArray);
},$array_test3));

Example at: http://sandbox.onlinephpfunctions.com/code/cc6652ada1609ff62379eaac03c6e8cf9ca5a70b

A: You could do something which was more a case of having a play and seeing how I could achieve this...
$role = ["leader","follower"];
$details = ["lead", "follow"];
$a1 = array_combine( $role, $details );
echo str_replace('=', '<|>', http_build_query($a1, '', '<|>'));


text:
Q: Are nested span tags OK in XHTML? Will this validate in XHTML?
helloworld

A: Absolutely.
Here's the definition from an XHTML-strict DOCTYPE for a span element.
<!ELEMENT span %Inline;>
<!ATTLIST span
  %attrs;
  >

The "%Inline" part tells me that it can have child nodes from the "% Inline;" entities element list.
The span element is included in the list of elements classed as "% Inline", that combined with span allowing "%Inline" child elements tells me that span is a valid child of span.

A: SPAN can contain only inline elements, such as SPAN etc.

A: Yes it will. You can help yourself by using the w3's validator direct input option:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

          <title>Title</title>

               TestNest span