text:
Q: Change a field on change another field using django-autocomplete-light Basically I want to change value of company id and company name if your company field is changed.

Here I have used django-autocomplete-light for your company field. Code for this form:
class PartnerAddForm(forms.ModelForm):
company_id = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control', 'disabled': ''}), required=False)
company_name = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control', 'disabled': ''}), required=False)

class Meta:
    model = CompanyCompanyMap
    fields = ('your_company',)
    widgets = {
        'your_company': autocomplete.ModelSelect2(url='url_company_autocomplete',
                                                  attrs={'class': 'form-control',
                                                         'data-placeholder': 'Type for getting available companies'})
    }

Code for autocomplete view of your company field:
class CompanyAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
    qs = CompanyAccess(self.request).get_non_partners()
    if self.q:
        qs = qs.filter(company_name__istartswith=self.q)
    return qs

And code for template of this form
<form class="form-horizontal" role="form" action="." method="POST">
            {% csrf_token %}

            {% for f in form %}

                {{ f.label|capfirst }}

                    {{ f }}

            {% endfor %}

                    <button type="submit" class="btn btn-default btn-primary">
                        Add Company as Friend
                    </button>

        </form>

Is there any way to change it using js or other mechanism?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Decorating numbers inside the string with the thousand separator A have a string that contains one ore more number. The numbers are normally integers, but also decimal could be expected at some point. I looking for a solution that adds the thousand separator(. or ,) to all numbers inside the string.
For example

*

*100000 -> ?100,000?

*?100000?50000 -> ?100,000?50,000

*X10000.5? -> X100,00.5?

Any idea?

A: A hacky solution in pure regex is to replace all occurences of
(?<=\d)(\d{3})(?!\d)

with ,$1. This is, of course, very limited, as it only adds one separator per number, and also adds separators after a comma. See regex101 demo.

A far cleaner solution is to search for numbers using a regex such as \d+(?:\.\d+)?, convert each match to a number, and re-insert the formatted number into the text.
(You'll have to forgive me for not including any code, but I haven't coded in C# in ages.)


text:
Q: Haskell "Conflicting definitions" when instancing I'm working on a Haskell raytracer. I have the following Camera-type:
data Cameras = Ortographic | Pinhole {
    d :: Float,
    zoom :: Float,
    eye, lookAt, up :: Vector,
    cu, cv, cw :: Vector
} deriving (Show)

And the following Camera-typeclass:
class Camera a where
    renderPixel :: a -> (Float, Float) -> [Object] -> Float -> Vector
    rayDirection :: a -> Vector -> Vector

Now, when I try to make the type an instance of the typeclass, like this:
instance Camera Cameras where
    --Ortographic
    renderPixel (Ortographic) (x, y) scene numSamples = ...

    --Pinhole
    rayDirection (Pinhole d _ _ _ _ cu cv cw) (Vector2 u v) =
        normalize ((cu<*>u) <+> (cv<*>v) <-> (cw<*>d))

    renderPixel (Pinhole d _ _ _ _ cu cv cw) (x, y) scene numSamples = ...

I get an error saying "Conflicting definitions for `renderPixel'", pointing to the lines where the renderPixel-function starts for each of the cameras. What am I doing wrong?

A: I am quite sure the two renderPixel equations have to be right after each other. That is, the rayDirection function should be moved to before or after both renderPixel equations.
A function can have several equations (lines) due to pattern matching, but it is still a single function, and you can't shove another function definition in between the equations.


text:
Q: Spring Boot DataSource: 'url' attribute is not specified I am trying to follow this guide
https://spring.io/guides/gs/accessing-data-mysql/
but this guide is for the maven and i am trying the gradle
and getting this error

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

in application.properties i have these things only.
spring.datasource.url=jdbc:mysql://localhost:3306/db_example
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

I tried all the possible things there is on the SO.
the only deps i have are these
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    runtimeOnly 'mysql:mysql-connector-java'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

A: Or You will have to prevent Spring boot from automatically configuring the data source by adding this line to the file application.properties.

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

A: This is kind of an old question but for anyone else coming across this, IF by any chance you are using IntelliJ (as OP does here based on his/her comments) make sure that our beloved IDE recognises your application.properties/application.yml as such by going to File -> Project Structure -> Modules then select your resources file and click on "Resources" from the Mark as: header thing (based on IntelliJ Community Edition 2019.1). Also keep in mind, as no doubt the IDE will certainly notify you, that by reimporting any Maven changes you will need to do this procedure again.

A: Check the target classpath directory. If the application.properties file didn't exist, then delete the target and rebuild.

A: I would search the reason somewhere else.
Your error log tells you  Reason: Failed to determine a suitable driver class. Please build your project, and check if mysql driver is included in a built jar file. If jar is missing try to change your mysql dependency scope from runtimeOnly to implementation.
The same problem can occur (at least I think so) if you try to run this project from IDE and solution should also help in that case.
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. error is unfortunately very generic and can happen in many different situations. For example last week I had received this error while using oracle Oracle when there where special signs in password which was specified in properties.yaml without double-quotes.

A: I was having the same problem and solved it by migrating my project that was in version 2.4.x, to 2.3.x.

A: in IDE / STS (spring tool suit), every thing was working fine
but when made a "project.jar" file,
this was thrown.
unnecessary spaces " " in the "application.yml" file can cause this.
server:
  port: 8085

spring:
 datasource:
  url: jdbc:mysql://localhost:3306/studentdb
  username: root
  password: root
  driver-class-name: com.mysql.cj.jdbc.Driver
 jpa:
   hibernate:
    ddl-auto: update
   show-sql: true
   database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
 application:
  name: STUDENT-SERVICE

instead of tweaking my "application.yml" file
i simply moved all my statements in "application.yml" file to
"application.properties" file and formatted the statements like required in ".properties".
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/studentdb
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto = update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format.sql=true

spring.application.name=student-service

server.port=8085

and voilà
(you can add params at the end of url)
(spring.datasource.url=jdbc:mysql://localhost:3306/studentdb?allowPublicKeyRetrieval=true&useSSL=false)

A: Make sure your pom.xml has the war packaging. It worked for me.
<packaging>war</packaging>

A: Spring boot has chanegd the url to jdbc-url.
You need to use as below
spring.datasource.jdbc-url=jdbc:mysql://localhost:3306/db_example
Document Link:
https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#data-properties
Stressing that, of course, we would search the documentation for "spring.cloud.config.jdbc-url", but our search should be directly through spring.datasource.hikari.jdbc-url.


text:
Q: How to restrict creating AWS vpc if the CIDR in range 172.x.x.x/x using policies? We've shared AWS accounts among multiple teams and even though we ask not to create identical VPCs, there is always a case.
So my question is, how can we achieve this via policies (or if there is another way), that we define the set of CIDRs in AWS account policy so that when somebody creates a VPC with a CIDR that belongs to one of those, it throws an error?
Thank you.

A:
when somebody creates a VPC with a CIDR that belongs to one of those, it throws an error?

No there is no such IAM policies. You have to develop your own custom solution for that. For example, trigger a lambda function based on CloudTrial events for creating VPC, and have the lambda function verify the CIDRs.


text:
Q: Sending a campaign to a segment Anyone know how to get a campaign to send to a segment? This code isn't working.  It will send an email to all people in the campaign.  It will not use the segment.  (This is some more text so I can get it to pass the validation of SO.)
My code:
    //get member list
    $memberArray = $api->listMembers($inStockListId);
    foreach ($memberArray['data'] as $member) {
        $memberInfo = $api->listMemberInfo($inStockListId, $member['email']);
        $_productId = $memberInfo['data'][0]['merges']['PRODUCTID'];

$productId='34';
        if ($productId == $_productId) {
            array_push($emailArray, $member['email']);
        }
    }

    //create new segment for campaign
    $listStaticSegmentId = $api->listStaticSegmentAdd($inStockListId, 'inStockStaticSegment');

    //add members to segment
    $val = $api->listStaticSegmentMembersAdd($inStockListId, $listStaticSegmentId, $emailArray);

    $conditions = array();
    $conditions[] = array(
        'field' => 'email',
        'op'    => 'like',
        'value' => '%'
    );
    $segment_options = array(
        'match'      => 'all',
        'conditions' => $conditions
    );

    $type    = 'regular';
    $options = array(
        'template_id' => $campaignTemplateId,
        'list_id'     => $inStockListId,
        'subject'     => 'In-Stock Notification',
        'from_email'  => 'from@email.com',
        'from_name'   => 'My From Name'
    );
    $content = array(
        'html_main'       => 'some pretty html content',
        'html_sidecolumn' => 'this goes in a side column',
        'html_header'     => 'this gets placed in the header',
        'html_footer'     => 'the footer with an *|UNSUB|* message',
        'text'            => 'text content text content *|UNSUB|*'
    );

    $newCampaignId = $api->campaignCreate($type, $options, $content, $segment_options);

A: I figured it out.  Essentially, here is the flow.  If you want detailed code, send me a message and I'll be glad to help.
$api = new MCAPI($this->_apiKey);
$api->listMemberInfo($this->_listId, $member['email']);
$api->listUpdateMember($this->_listId, $member['email'], $mergeVars);
$api->listStaticSegmentDel($this->_listId, $segment['id']);
$api->listStaticSegmentAdd($this->_listId, $segmentName);
$api->listStaticSegmentMembersAdd($this->_listId, $segmentId, $emailArray);
$api->campaignCreate($type, $options, $content, $segment_options);
//$api->campaignSendTest($newCampaignId, array($member['email']));
$api->campaignSendNow($newCampaignId);

Note, this is done via the MailChimp PHP API.


text:
Q: Two left columns and main content in right column Problem:
Trying to create a layout using Bootstrap 3 that consist of two columns on the left of the page and one main column to the right of the two columns. The two columns on the left should be on top of each other.
Code:

Left column 1

Left column 2

Main column

Output:
Current code produce two columns next to each other on top the main column.
Desired output:

A: You should use a div with class .col-sm-4 and .col-sm-8 respectively as the parent div for the two column layout you want to use and then create the desired widgets within those divs.
Check out my JSFiddle: http://jsfiddle.net/nJtX9/9/
Please make sure to enlarge the results window to see the correct layout. Otherwise it will stack the div containers for responsive purposes.

A: You are using 2 col-md-4 meaning is taking 8 columns already + using col-md-8 = 16 columns, bear in mind bootstrap can contain 12 columns per row,
so the way to go around this is use col-md-2 instead of col-md-4
Hope i make this clear.

A:

col1----row1

col1----row2

col2-----row
col2---row
col2---row


text:
Q: Youtube Player API playVideo I'm trying to create a button in my website and when you press that button youtube player should start playing.
Now to do that i am using Youtube player API and playVideo method and everything seemed to be working just fine until i tried testing it on mobile devices, for example iphone.
Player seems to get bugged when playVideo method is called so my best guess is that its fault on google end but i can't seem to find any fix for that.
I made jsFiddle
Also demo website to test it on mobile devices: link
And here is the code

start


text:
Q: UPS battery advice I have a APC UPS with a 9 Ah battery.
Would it be ok to replace it with an 18 Ah battery?
I realize that some modifications would be needed since it won't fit in the case.

A: In theory it shouldn't matter how much bigger the Ah rating of the battery is as long as you regulate the Current and voltage the same. It just takes long to transfer the coulombs of charge.  A bigger battery of the same chemistry will have  a larger capacitance and may have a lower ESR.


text:
Q: Is there a way to get programmatically notified when an OPAM package is updated at opam.ocaml.org? We are trying to build into an Open Source ocaml project a way to automatically kick off a Travis CI build & test session when any of the 3rd party OPAM packages the project depends on get changed. If there was some clean way to get a change notification, then programmatically we could touch a file in a test branch and do a pull request which would start the Travis CI process to test compatibility so that our end users don't trip over the issue. We're trying to avoid wasting OPAM resources polling.
Thank you for your time!

A: opam.ocaml.org is a mirror of the OPAM repo https://github.com/ocaml/opam-repository, therefore you can periodically pull it and check the new commits.
You may have to be careful of silent source code change of packages, since their sources are out of the OPAM repo.  If packages are OPAM registered without their checksums, you have to periodically check their sources themselves, too.


text:
Q: SimpleJdbcCall skipping first input parameter I am executing following code:
simpleJdbcCall.withSchemaName("SCHEMA_NAME")
              .withProcedureName(storedProcdure)
              .addDeclaredParameter( new SqlParameter("INPUT_PARAMS",Types.LONGNVARCHAR));
// Creating String of input numbers
if (!loanNumbers.isEmpty()) {
    for (String str : paramsList)
        finalInput = finalInput + str + ";";
    finalInput = finalInput + "'";
}
// Preparing map of input params for Stored Procedure
inputParams.put("INPUT_PARAMS", finalInput);
log.info("Input params for Stored Procedure :"+finalInput);

//Input Prepared and finally calling Stored Procedure
SqlParameterSource in = new MapSqlParameterSource(inputParams);
Map<String, Object> resultSet= simpleJdbcCall.execute(in);

If FinalInput have only one value ie. '123467', SimpleJdbcCall will omit this first parameters and I will not get any result. If I run the same SP in any IDE , for the same param , I will get the result.
If it have more than two parameters i.e '123467;98768', it will omit the first parameters(123467) and give result for 98768.
What is the reason for this kind of behavior and how can we fix this.


text:
Q: DriverTimeoutException: Query timed out after PT2S. Unable to set spring.data.cassandra.request.timeout property? When starting my application the keyspace is always created and possibly one or two tables before the PT2S error message . Somehow the spring.data.cassandra.request.timeout property is not honored, or maybe there is something wrong with my configuration? The "DriverConfigLoaderBuilderCustomizer" bean does not make any difference.
pom.xml
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR9</version>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
<spring.framework.version>5.3.1</spring.framework.version>

application.yml
spring:
  data:
    cassandra:
      port: 9042
      keyspace-name: abc
      contact-points: localhost
      local-datacenter: datacenter1
      replication-factor: 1
      request:
        timeout: 15s
      connection:
        init-query-timeout: 15s

CassandraConfig.java
@Configuration
@EnableReactiveCassandraRepositories(basePackages = "a.b.c.repository")
public class CassandraConfig extends AbstractReactiveCassandraConfiguration {
    @Value("${spring.data.cassandra.contactpoints}")
    .
    .
    @Override
    protected String getKeyspaceName() {
        return keyspace;
    }
    @Override protected String getContactPoints() {
        return contactPoints;
    }
    @Override protected int getPort() {
        return port;
    }
    @Override
    protected String getLocalDataCenter() {
        return datacenter;
    }
   @Override
    public SchemaAction getSchemaAction() {
        return SchemaAction.NONE;
    }
    @Override
    protected List<CreateKeyspaceSpecification> getKeyspaceCreations() {
        return Collections.singletonList(CreateKeyspaceSpecification.createKeyspace(getKeyspaceName())
                .ifNotExists()
                .with(KeyspaceOption.DURABLE_WRITES, true)
                .withNetworkReplication(DataCenterReplication.of(getLocalDataCenter(), getReplicationFactor())));
    }
    @Override
    protected KeyspacePopulator keyspacePopulator() {
        ResourceKeyspacePopulator keyspacePopulate = new ResourceKeyspacePopulator();
        keyspacePopulate.addScript(new ClassPathResource("table-schema.cql"));
        return keyspacePopulate;
    }
    private long getReplicationFactor() {
        return replicationFactor;
    }
    //@Bean
    //public DriverConfigLoaderBuilderCustomizer driverConfigLoaderBuilderCustomizer() {
        //return loaderBuilder -> loaderBuilder
                //.withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofSeconds(15))
                //.withDuration(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT, Duration.ofSeconds(15));
    //}

}

Trimmed error log
BeanCreationException: Error creating bean with name 'cassandraSessionFactory'
Invocation of init method failed; nested exception is ScriptStatementFailedException: Failed to execute CQL script statement #2 of class path resource [table-schema.cql]: CREATE TABLE IF NOT EXISTS mytable...

Caused by: org.springframework.data.cassandra.core.cql.session.init.ScriptStatementFailedException: Failed to execute CQL script statement #2 of class path resource [table-schema.cql]: CREATE TABLE IF NOT EXISTS mytanble... nested exception is com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
    at org.springframework.data.cassandra.core.cql.session.init.ScriptUtils.executeCqlScript(ScriptUtils.java:555) ~[spring-data-cassandra-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.data.cassandra.core.cql.session.init.ResourceKeyspacePopulator.populate

Caused by: com.datastax.oss.driver.api.core.DriverTimeoutException: Query timed out after PT2S
at com.datastax.oss.driver.api.core.DriverTimeoutException.copy(DriverTimeoutException.java:34)

A: We had a similar problem and tried your exact steps first.
The driver examples code than stirred us in the right direction.
We have a custom cassandra config with excluded auto config:
@SpringBootApplication(exclude = {CassandraAutoConfiguration.class,CassandraDataAutoConfiguration.class})

Running spring-boot-starter-parent version 2.3.0.RELEASE.
CassandraConfig:
@Configuration
@EnableCassandraRepositories(basePackages = {"com.example.model.cassandra"})
public class CassandraConfig extends AbstractCassandraConfiguration {

@Override
protected SessionBuilderConfigurer getSessionBuilderConfigurer() {
    return new SessionBuilderConfigurer() {
        @Override
        public CqlSessionBuilder configure(CqlSessionBuilder cqlSessionBuilder) {
            return cqlSessionBuilder
                    .withConfigLoader(DriverConfigLoader.programmaticBuilder().withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofMillis(15000)).build());
        }
    };
}
}


text:
Q: Color overlay on img tag with shape I have a image with border radius, and want to add a color overlay over the image.

  img {
    border-bottom-left-radius: 60% 65%;
    border-bottom-right-radius: 35%;
    border-top-left-radius: 40px 200px;
    }

The image has a oval shape with border-radius
If I add a color with pseudo element on the div/container it doesn't overlay in a oval shape but the full container.
How to place a color overlay (just for the image) on a img tag with border radius?

A: Put the border-radius on the parent element with overflow: hidden, then add your overlay effect:
.image-wrapper {
    display: inline-block;
    position: relative;
    border-bottom-left-radius: 60% 65%;
    border-bottom-right-radius: 35%;
    border-top-left-radius: 40px 200px;
    overflow: hidden;
}

.image-wrapper::after {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: rgba(0, 128, 255, 0.5);
}

A: If you want to go with a pseudo, the container has to shrink on the image and image be displayed as a block or vertical-align reset to avoid the gap. From there, apply to the pseudo the same radius. a gradient overlay can even be used ;)
example:https://codepen.io/anon/pen/qVjdbg

img,
.image-wrapper:before {
  display: block;
  border-bottom-left-radius: 60% 65%;
  border-bottom-right-radius: 35%;
  border-top-left-radius: 40px 200px;
}

.image-wrapper {
  position: relative;
  display: table;
}

.image-wrapper:before {
  content: '';
  position: absolute;
  height: 100%;
  width: 100%;
  background: linear-gradient(45deg, rgba(200, 45, 125, 0.3), rgba(15, 235, 15, 0.5));
}


text:
Q: To enable form fields when one of the radio button checked & disable fileds when it unchecked I have a form which contains 2 radio butttons & one of them is checked by default. I have disabled some fields & wanted to enable it when 2nd radio button is checked, and disable them (also wanted to regain CSS properties) when 1st radio button is checked.
Right now, I can do it only for input field without any script.
Any help will be appreciated.

  input[disabled='disabled'], textarea[disabled='disabled'], select[disabled='disabled'] {
        background: #ddddbb;
        color: black;
        cursor: default;
    }

    input[type="text"]:disabled, input[type="select"]:disabled {
        background: #ddddbb;
    }

<title>Form</title>

    <input type="radio"
           name="radSize"
           id="generic_test"
           value="false" checked="checked" onclick="document.getElementById('project_id').disabled=true;" />
    Generic Test

    <input type="radio"
           name="radSize"
           id="project_test"
           value="true" onclick="document.getElementById('project_id').disabled=false;" />Project Test

                Project ID *

                <input type="text"
                       name="project_id" id="project_id" size="19"
                       value="" disabled="disabled">

                 Multiphase *

                <select name="multiphase"
                        id="multiphase"
                        onchange="onChangeFunction();" disabled="disabled">

                    <option value='' selected></option>
                    <option value='Yes'>Yes</option>
                    <option value='No'>No</option>
                </select>

                Text Area
*

                    <textarea id="textInputField3"
                              name="textInputField3"
                              style="resize:vertical; text-align:top;  "
                              rows="5"
                              cols="52"
                              disabled="disabled"></textarea>

A: To let the css rule work, use removeAttribute for the Attribute disabled to enable the field or setAttribute to disable it. https://developer.mozilla.org/de/docs/Web/API/Element/removeAttribute
https://developer.mozilla.org/de/docs/Web/API/Element/setAttribute

function enable(enabled){
  var project = document.getElementById('project_id'),
      multiphase = document.getElementById('multiphase');
      textInputField3 = document.getElementById('textInputField3');
  if(enabled){
    project.removeAttribute('disabled');
    multiphase.removeAttribute('disabled');
    textInputField3.removeAttribute('disabled');
  } else {
    project.setAttribute('disabled','disabled');
    multiphase.setAttribute('disabled','disabled');
    textInputField3.setAttribute('disabled','disabled');
  }
}
input, textarea, select {
        background: #fff;
        color: black;
        cursor: default;
    }
input[disabled='disabled'], textarea[disabled='disabled'], select[disabled='disabled'] {
        background: #ddddbb;
    }

    input[type="text"]:disabled, input[type="select"]:disabled {
        background: #ddddbb;
    }

<title>Form</title>

    <input type="radio"
           name="radSize"
           id="generic_test"
           value="false" checked="checked" onclick="enable(false)" />
    Generic Test

    <input type="radio"
           name="radSize"
           id="project_test"
           value="true" onclick="enable(true)" />Project Test

                Project ID *

                <input type="text"
                       name="project_id" id="project_id" size="19"
                       value="" disabled="disabled">

                 Multiphase *

                <select name="multiphase"
                        id="multiphase"
                        onchange="onChangeFunction();" disabled="disabled">

                    <option value='' selected></option>
                    <option value='Yes'>Yes</option>
                    <option value='No'>No</option>
                </select>

                Text Area
*

                    <textarea id="textInputField3"
                              name="textInputField3"
                              style="resize:vertical; text-align:top;  "
                              rows="5"
                              cols="52"
                              disabled="disabled"></textarea>


text:
Q: React native textinput multiline is not being pushed up by keyboard I have a TextInput with multiLine true. However, after two lines the text disappear behind the keyboard. I have tried wrapping the TextInput in KeyboardAvoidingView, but it doesn't work.
The keyboard does push up the TextInput when I unfocus the TextInput and then click on the bottom line. Any idea how I can make the last line of the TextInput stay on top of the keyboard?
The code:
<View style={styles.descriptionFlexStyle}>
    <Text
       style={[
         styles.headerTextStyle,
         { marginTop: Window.height * 0.04 }
        ]}> Please fill in a reason </Text>
        <ScrollView>
          <TextInput
            style={styles.reasonTextInput}
            placeholder="Reason"
            value={reasonText}
            multiline={true}
            onChangeText={input =>
               this.setState({
                   reasonText: input
               })
            }
            underlineColorAndroid="transparent"
            ref="reasonTextInput"
            />
    </ScrollView>
</View>

A: hello my dear you must use KeyboardAvoidingView Component from React-Native and put a behavior on it like below :
  <KeyboardAvoidingView behavior={'postion' || 'height' || 'padding'}>
    <View style={styles.descriptionFlexStyle}>
        <Text
           style={[
             styles.headerTextStyle,
             { marginTop: Window.height * 0.04 }
            ]}> Please fill in a reason </Text>
            <ScrollView>
              <TextInput
                style={styles.reasonTextInput}
                placeholder="Reason"
                value={reasonText}
                multiline={true}
                onChangeText={input =>
                   this.setState({
                       reasonText: input
                   })
                }
                underlineColorAndroid="transparent"
                ref="reasonTextInput"
                />
        </ScrollView>
    </View>
</KeyboardAvoidingView>

A: This answer may be a little too late. However, I have found a workaround without using the KeyboardAvoidingView component. A ScrollView could be used instead to scroll the multiline TextInput to the top to have the 'keyboard avoiding' effect. I would use the ref measure() method to get the top y value of the TextInput, before using the scrollTo() method to scroll the TextInput directly to the top of the screen, effectively avoiding the keyboard.
import React, { useRef } from "react";
import { ScrollView, TextInput, View } from "react-native";

export default function Test() {
  const scrollViewRef = useRef(null);
  const viewRef = useRef(null);

  const handleFocus = () => {
    viewRef.current.measure((x, y) => {
    scrollViewRef.current.scrollTo({ x: 0, y });
    });
  };

  return (
    <ScrollView ref={scrollViewRef}>
      {/* View to fill up space */}
     <View
       style={{
        width: "80%",
        height: 600,
        }}
      />

     <View ref={viewRef}>
       <TextInput
         onFocus={handleFocus}
         multiline={true}
        style={{
          width: "80%",
          height: 100,
          backgroundColor: "whitesmoke",
          alignSelf: "center",
         }}
       />

      {/* View to fill up space */}
       <View
        style={{
         width: "80%",
         height: 600,
        }}
        />
   </View>
  </ScrollView>
 );
}

A: Ok i have finally solved it using "KeyboardAvoidingView". I did two things. First i removed the height on my TextInput and then i set the behavior attribute on the "KeyboardAvoidingView" to "padding". Works perfect for me now. Let me know if this help! :)


text:
Q: How to remove the last part of url? I have this url: https://uk.soccerway.com/national/italy/serie-a/20172018/regular-season/r42011/?ICID=TN_02_01_02
I want remove ?ICID=TN_02_01_02, of couse this string is dynamic so I can't use .Replace() method, any idea?

A: Use Uri try create (https://msdn.microsoft.com/en-us/library/ms131572(v=vs.110).aspx) to create a Uri object.
Then with that Uri object take the "Query" property which will contain the entire query string.
And use "AbsolutePath" to get the URL without the query string.

A: You can use the Uri class to parse the URL. It allows you to get only up to a specific part using the GetLeftPart method:
public static string GetUriWithoutQuery(string url)
{
    var uri = new Uri(url);
    return uri.GetLeftPart(UriPartial.Path);
}


text:
Q: Execution of a file How to execute a makefile? This file is contained in the sts-2.1.2 file downloadable from here:
According to the NIST documentation (section 5.3), I need to edit the makefile.

Modify the following lines:
  (a) CC(your ANSI C compiler)
  (b) ROOTDIR (the root directory that was prescribed earlier in the process, e.g.,
  rng/)

user@SC13-VM:~/Documents/sts-2.1.2$ ./makefile
./makefile: line 1: CC: command not found
./makefile: line 2: GCCFLAGS: command not found
./makefile: line 3: ROOTDIR: command not found
./makefile: line 4: ROOTDIR: command not found
./makefile: line 4: SRCDIR: command not found
./makefile: line 5: ROOTDIR: command not found
./makefile: line 5: OBJDIR: command not found
./makefile: line 6: VPATH: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
./makefile: line 8: OBJDIR: command not found
 ......

There are 94 lines in total.
Then, I did as you said:
 user@SC13-VM:~/Documents/sts-2.1.2$ make makefile
 make: Nothing to be done for `makefile'.
 user@SC13-VM:~/Documents/sts-2.1.2$ ls
 data  experiments  include  makefile  makefile~  obj  src  templates

 user@SC13-VM:~/Documents/sts-2.1.2$ make  makefile
 make: Nothing to be done for `makefile'.

A: Run make to run a Makefile. This assumes that you're in the same directory as where the file Makefile is located.
If you're in a different directory, run make -C directory, where directory is the path to the directory that contains the file Makefile.

A: Reading from the comments of the above answer, you might have done the same mistake as I did:
Wrong command: make makefile
This will give you that error "There's nothing to make"
Right command: make -f makefile
I should mention that I already made it an executable file and encountered the same host of errors. Also, the aforementioned command executed without errors at first, but the assess file did not appear as promised. I repeated it and it worked. I am a novice so I really can't comment on that much.


text:
Q: Spearman rank correlation with less than 4 observations? I'm currently trying to run a spearman rank correlation test with both an X dataset and a Y dataset, both containing 3 rows (individuals). I can run the Spearman with cor() and get values, all of them being: -1, -.5, -5, or 1. This just doesn't seem right to me.. I don't have any 0s in the datasets. However, when I use rcorr(), it gives me an error:
 Error in rcorr(BPT2, y = FunT2, type = "spearman") :
 must have >4 observations

I am comparing Bacterial Phyla in the gut (my X) to metabolic readouts (my Y)
So my questions:

*

*Are the results i'm getting accurate?

*Should I be using a Spearman Rank Correlation in the first place?
Thanks!

A: You are right that there are only four possible outputs. This is because there are only 6 scenarios that are possible for rank correlation with 3 observations.
If we hold our x constant as 1:3, there are 6 possible rank values for y (read row-wise):
   Var1 Var2 Var3
1     3    2    1
2     2    3    1
3     3    1    2
4     1    3    2
5     2    1    3
6     1    2    3

When you compute each correlation between X and Y, there are only the following possible returns:
apply(df, 1, function(x){cor(1:3, x)})

   1    2    3    4    5    6
-1.0 -0.5 -0.5  0.5  0.5  1.0

Since two are repeated, you get 4 values.
So - it is mathematically possible to calculate, but it is not very useful in describing the distribution.


text:
Q: No errors in console.log unless using try/catch Usually all errors will be shown in the browser console, for example if a variable is undefined. Not this time. No errors are shown unless I use try/catch.
I am not sure what the cause is. I started a new project and use webpack, babel and a bunch of other webpack relevant libraries. (list see bottom)
so the problem is:
x = abc;
console.log("here");

"here" is not being shown because the code stops on that line. x = abc;
I don't see any compilation errors / warnings.
try {
    x = abc;
} catch (error) {
    console.log("Error: " + error.message);
}
console.log("here");

output:
Error: abc is not defined
here

Any idea why? Never had such an issue. And I don't have a wrapping try/catch.
Here are the stuff I load in package.json:
//EDIT:
This is the code I am using:
abj.SomePromise().then((response) => {
    let c= aa;  //this should generate an error
    //this wont be shown:
    console.log('Everything loaded');
});

A: Because the execution follows top to bottom approach,
1st case
x = abc;
console.log('here');

In the first case, your execution process will be stopped and killed because It's not handled, at that time your server will be crashed and got ReferenceError: abc is not defined in the console and here is not printed.
2nd case
try {
  x = abc;
} catch (error) {
  console.log(`Error: ${error.message}`);
}
console.log('here');

In this case, the error is properly handled  with try/catch,
Explanation of 2nd case
In this case it first execute whatever in try{} block, Then perform things whatever write in try, Here you make a variable x with value of abc, But abc is not defined, so it will throw an error, So here catch() {} block will come into the picture and perform whatever write in catch() {} block;
So It prints Error: abc is not defined, Then try and catch both are done his job; Then execution continuos to go bottom for further operations. It finds another log console.log("here"); So it prints here.


text:
Q: How to get min and max in one sql query? what will be the query to get min and max at once I am getting errors in this query
router.get('/min/:date', (req, res) => {
  const date = req.params.date;
  console.log(typeof date);
  connection.query(
    `select max(temperature) as highesttemperature; select min(temperature) as lowesttemperature from weather_data where dt=?`,
    [date],
    (err, results, field) => {
      if (err) {
        console.log(err);
      } else {
        res.status(200).send(results);
        console.log(results);
      }
    }
  );
});

A: You can have both in the same query, no need for a second select:
select max(temperature) as highesttemperature,
min(temperature) as lowesttemperature
from weather_data
where dt=?

The error is in your first query, there is no FROM clause.

A: Try this
SELECT MIN(temperature), MAX(temperature) FROM weather_data


text:
Q: Applying style to particular cell in knockout JS dynamic table depending upon it value I don't have any experience in Knockout js but since I have to implement the functionality and struggling to get my hands on this scenario.
JSP files are fetching JSON data and it is passed to HTML template to create dynamic table.But i have to match particular values and give different styling to cells(Need to change color).
I explored and found out if Foreach is used and using if condition to apply css class can work but since table is getting created dynamically so finding it difficult to achieve it.
Providing the code below,i know angular way to do it but since its in knockout JS am struggling.

The above JSON data fetching dynamically from DB, if App Server is responding then map to "Yes" otherwise map to "No", in additionally I have to set Yes mean green color, No means Red color.
I mapped responding values, it is working fine.
But I am not able to set colors for responding values (Yes means green and No means red color) in Knockout js. Can you please suggest me on this

Below here is the JSOn data fetched from server and passed to table
 {
    "label": "App Server",
    "collection": [{
        "responding": "Yes",
        "appserver": "DEFAULT",
        "className": "success",
        "id": 1
    }, {
        "responding": "No",
        "appserver": "ORACLEQUEUE",
        "className": "failed",
        "id": 2
    }, {
        "responding": "No",
        "appserver": "SECONDARY",
        "className": "failed",
        "id": 3
    }, {
        "responding": "No",
        "appserver": "TERTIARY",
        "className": "failed",
        "id": 4
    }],
    "serverTimestamp": "2017-07-07T03:51:21.949+0000",
    "dataTimestamp": "2017-07-07T03:51:21.949+0000",
    "tableColumns": [{
        "headerText": "App Server",
        "field": "appserver",
        "sortable": "disabled"
    }, {
        "headerText": "Responding",
        "field": "responding",
        "sortable": "disabled",
        "className": ""
    }],
    "scrollPolicy": "auto",
    "scrollPolicyOptions": {
        "fetchSize": "15",
        "maxCount": "1000"
    }
}

Here is the code which fetches data from server by JSP files
function addScalabilityMonitors() {
            console.log("moved to scalability");
            //App Scalability
            monitors.addMonitorPoint(sts.apiBaseUrl() + 'ScalabilityAppServer1.jsp', 'oj-masonrylayout-tile-3x2', true, 15000, 'grid', 'scalability');
            //Web Scalability
            monitors.addMonitorPoint(sts.apiBaseUrl() + 'ScalabilityWebServer1.jsp', 'oj-masonrylayout-tile-3x2', true, 15000, 'grid', 'scalability');
            //Response Time
            monitors.addMonitorPoint(sts.apiBaseUrl() + 'Scalability.json', 'oj-masonrylayout-tile-3x2', true, 15000, 'gauge', 'scalability');
            //Log files
            monitors.addMonitorPoint(sts.apiBaseUrl() + 'logfile.json', 'oj-masonrylayout-tile-3x2', true, 15000, 'grid', 'scalability');
            monitors.addMonitorPoint(sts.apiBaseUrl() + 'ProcessSchedules.json', 'oj-masonrylayout-tile-3x2', true, 15000, 'grid', 'scalability');
            monitors.addMonitorPoint(sts.apiBaseUrl() + 'BusinessSequence.json', 'oj-masonrylayout-tile-3x2', true, 15000, 'grid', 'scalability');
            monitors.addMonitorPoint(sts.apiBaseUrl() + 'DatabaseJobs.json', 'oj-masonrylayout-tile-3x2', true, 15000, 'grid', 'scalability');
            //myPostProcessingLogic();
        }

I tried to read the documentation for this, also tried various things but failed to implement.

A: Assuming you have access to the css this is pretty simple. If not, it's only slightly simple. Knockout has a databinding specifically for css. Here's an example.

function Server(data) {
  var self = this;

  self.Name = ko.observable(data.Name);
  self.Status = ko.observable(data.Status);
}

function viewModel() {
  var self = this;

  self.Servers = ko.observableArray();

  self.Load = function() {
    self.Servers.push(new Server({
      Name: "Email",
      Status: "Online"
    }));
    self.Servers.push(new Server({
      Name: "TPS Reports",
      Status: "Offline"
    }));
  };

  self.Load();

}

ko.applyBindings(new viewModel());
.red {
  background-color: red;
}

.blue {
  background-color: blue;
}

 CSS Control

       Server Name
       Server Status

 No CSS Control

       Server Name
       Server Status

With your code, you would just make some additions to the data-binding in question.


text:
Q: Simple char table writing in C Hi how to write text to char table (name)?
I am trying:
char name[10];
char * n = name;
n = "John";

Why it doesnt change table: name?

A: The reason is that n is a pointer that changes what it points to. The variable name is at a fixed location in memory. The first assignment n = name; sets the pointer n to point to name. The second assignment n = "John"; sets the pointer n to point to the constant string "John". After the second assignment, n no longer points to name.
In order to copy a string into name through the n pointer, use strcpy():
strcpy(n, "John");

A:
Why it doesn't change table: name?

Simple, because n points to the base address of the compile time allocated array name, which cannot be populated by assignment. To populate name itself, Use strcpy() instead.
In other words, once we write
 n = "John";

then n does not point to name anymore. It becomes a pointer to the string literal "John". So, the content of name is unchanged.

how to write text to char table?

use strcpy() like
  strcpy(n, "john");

or, getting rid of the pointer variable altogether, you can write
 strcpy(name, "john");

directly.


text:
Q: Marshall.OffsetOf replacement on .NET Compact Framework I'm investigating some pinvoke/interop pb on Windows Mobile (Compact Framework 3.5).
I would like to print field offsets and size of structures shared between managed and native sides to check if that's coherent. Ultimately I would like to automate the test on the device for every such struct used in my project.
Unfortunately Marshall.OffsetOf isn't available on the compact framework.
Is there a replacement solution ?
Can you think of another way to test if struct definition is in sync between managed and native side when running on the device ?


text:
Q: URL Rewriting for user profiles I am using a hash value to prevent spam and direct access to user profiles with changing ID numbers. This is a unique integer value given user once when they registered, stored in database and never change.
Profile links look like this:
example.com/profile.php?id=xxx&hash=xyz

I want to rewrite URL with user nicknames, like this:
example.com/nickname

But how can I do it when using a hash value in URL? I couldn't find a sample for this!

A: If I understand you well:
You want to provide to the end user several url:

*

*/profile.php?id=<id>&hash=<hash>

*/<nickname>
They would all be available but the 2nd one would be the preffered way.
there is a problem with the /<nickname> type of url, if a nickname is "foo/bar" or "index.php" or "admin", etc the problem is that some nicknames may cover some other valid urls. So at least a better format for vanity url would be:

*

*/nick/<nickname> or /user/<nickname>
If you do not want that you'll have to ensure that nicknames will never match any valid path to any other asset.
Then you'll quite certainly have to handle special characters in nicknames, spaces, "/", chineses utf16 chars, windows specific encoding, etc. This usually targets the application server as the best tool for handling the nickname and finding the real user page to show.
Now let's take back the first url format :  /profile.php?id=<id>&hash=<hash>, you use the hash to avoid direct access to user profile by altering the id. And you said every user have a nickname. I would say why not simply only using the vanity format and forbid direct access to the profile.php script with an id? You could hanlde all user profile acess internally and never provide such entry... anyway, let's say you still want to be able to access a user profile by id.
This access url is generated by your application. Your application is adding the hash after the url when providing the link, (maybe the hash is a salted hash based on the nickname?). So your application can store for each user the user hash. And then in profile.php you always check that the hash is the right one for this id. All this is managed in your application, not in the http server (apache). The http server and his rewriting tools is, in my humble opinion, not the right tool to make the match, it cannot easily match your outgoing links and alter them, it cannot easily catch your ongoing links and transform them in the right profile.php+id+hash form.
So the only rewriteRule I would use is one catching nickname based entries and sending them internally to a profile redirector script in your application. Something like:
RewriteRule  ^/nick/(.*)$ /profile-by-nick.php?nick=$1 [L,QSA]

Then inside this php script you can do what you want to provide the same task as in profile.php. With a well written php app it's quite easy to provide internal redirection inside the application, do not send a real http 302 redirection on the profile.php script. use functions, classes, etc.
If really you want apache to directly send the right profile.php?id=&hash= url to your application (maybe because your php code was written by a poney :-) ) then you could check RewriteMap as suggested by @David Ravetti and get an external script running as a daemon and providing the nickname->id+hash mapping to apache. But it seems really more complex, not the right place to handle it. This script will need rights to load you database, and informations on table structures that your application already have.


text:
Q: Homework, how to use resolution to prove these inferences are valid? I am kind of a layman in this area, and now I have to prove these:

*

*$P\rightarrow Q,\neg Q\vdash\neg P$

*$P\rightarrow Q\vdash\neg Q\rightarrow\neg P$

*$P\rightarrow Q, Q\rightarrow R\vdash P\rightarrow R$

I have to use resolution to prove these inferences are valid, but I do not know how to do it. Could you help me? Thank you in advance!

A: Let's do 1., try to do the other ones yourself

First write the given clauses as disjunction of literals, we have $P\to Q \equiv \neg P \lor Q$ and $\neg Q$. To prove $\Gamma \vdash \alpha$ using resolution, we moreover assume $\neg \alpha$ and check if we can resolve the empty clause. Here $\alpha =\neg P$, so $\neg \alpha \equiv P$. So we have the set of clauses
  $$ \{ \neg P \lor Q, \neg Q, P\} $$
  For each pair $(\alpha, \beta)$ if there is a literal $l$ such that $l$ is contained in $\alpha$ and $\neg l$ in $\beta$, resolve $\alpha$ and $\beta$: We can resolve $Q$ from $\neg P \lor Q$ and $P$, so we have
  $$ \{ \neg P \lor Q, Q, \neg Q, P\} $$
  now from $Q$ and $\neg Q$ we can resolve $\bot$, hence are done.


text:
Q: Python- error in importing rllab I installed rllab successfully:
$ source activate rllab3
(rllab3) $ Python 3.5.2 :: Continuum Analytics, Inc.
(rllab3)  $ import rllab
(rllab3)  $

but when I try to import other libraries:
(rllab3) $ from rllab.algos.trpo import TRPO
 from: can't read /var/mail/rllab.algos.trpo

 (rllab3) $ from rllab import rllab
 from: can't read /var/mail/rllab

I can understand why this happens.
I defined the environment variable
export PYTHONPATH="${PYTHONPATH}:/home/b**/rllab3"

when I am trying to load it from spyder:
[] import rllab
Traceback (most recent call last):
File "<ipython-input-1-6bfd29d10263>", line 1, in <module>
import rllab
ModuleNotFoundError: No module named 'rllab'

I can't figure the problem. If the problem is with environment variable, can anyone help me to fix it?
I can not find where were rllab is installed on my system (I installed it with anaconda)

A: I know this thread is quite old, but I started working on rllab lately and this is my understanding. rllab3 is a conda envrionment similar to virtual environment, as mentioned in the rllab documentation. It doesn't have the actual modules installed within it, you'd need to install it seperately.
(rllab3) $ python3
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import rllab
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'rllab'

To use the package you need to have the actual package downloaded and the python path pointing to that package.
(rllab3) $ pwd
/Users/r**/***/repo/rllab
(rllab3) $ python3
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from rllab.algos.trpo import TRPO
>>>


text:
Q: Java Condition fail to re-aquire the lock(a ReentrantLock) associated with it after await() returns import java.util.LinkedList;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

class Foo {
    private ReentrantLock _lock;
    private Condition _cond;
    private Thread _thr;
    private LinkedList<String> _msgQueue;

    public Foo() {
        _lock = new ReentrantLock();
        _cond = _lock.newCondition();
        _msgQueue = new LinkedList<String>();
        startThread();
    }

    public void putMsg(String msg) throws Exception {
        _lock.lock();
        _msgQueue.addLast(msg);
        _cond.signal();
        System.out.println(Thread.currentThread().getId() + ": Signal write thread.");
        _lock.unlock();
        System.out.println(Thread.currentThread().getId() + ": Unlocked.");
    }

    private void startThread() {
        _thr = new Thread() {
            public void run() {
                _lock.lock();
                while(true) {
                    try {
                        while (!_msgQueue.isEmpty()) {
                            String msg = _msgQueue.getFirst();
                            System.out.println(msg);
                            _msgQueue.removeFirst();
                        }

                        System.out.println(Thread.currentThread().getId() + ": getHoldCount:" + _lock.getHoldCount());
                        System.out.println((Thread.currentThread().getId() + ": isLocked:" + _lock.isLocked()));
                        System.out.println(Thread.currentThread().getId() + ": isHeldByCurrentThread:" + _lock.isHeldByCurrentThread());
                        System.out.println(Thread.currentThread().getId() + ": Awaiting...");

                        _cond.await();

                        System.out.println(Thread.currentThread().getId() + ": Write thread awaken");

                    } catch (Exception e) {
                        e.printStackTrace();
                        break;
                    } finally {
                        try {
                            _lock.unlock();
                        } catch (Exception e) {
                        }
                    }
                }
                System.out.println("Write thread exit.");
            }
        };

        _thr.start();
    }
}

public class LockTest {
    public static void main(String[] args) throws Exception {
        Foo foo = new Foo();
        foo.putMsg("Msg 1");
        foo.putMsg("Msg 2");
        Thread.sleep(1000);
        foo.putMsg("Msg 3");
    }
}

The code output after one running:
1: Signal write thread.
1: Unlocked.
1: Signal write thread.
1: Unlocked.
Msg 1
Msg 2
8: getHoldCount:1
8: isLocked:true
8: isHeldByCurrentThread:true
8: Awaiting...
1: Signal write thread.
1: Unlocked.
8: Write thread awaken
Msg 3
8: getHoldCount:0
8: isLocked:false
8: isHeldByCurrentThread:false
8: Awaiting...
Write thread exit.
java.lang.IllegalMonitorStateException at

java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(Unknown Source) at

java.util.concurrent.locks.AbstractQueuedSynchronizer.release(Unknown Source) at

java.util.concurrent.locks.AbstractQueuedSynchronizer.fullyRelease(Unknown Source) at

java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)

at Foo$1.run(LockTest.java:44)

The question is:
According to http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/locks/Condition.html#await(), when the thread returns it is guaranteed to hold this lock. But from the output, we see that after await() returns, it does not re-aquire the lock. Is this a bug or are some mistakes I made?

A:
According to http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/locks/Condition.html#await(), when the thread returns it is guaranteed to hold this lock.

True, but it also says that the thread must hold the lock before calling the method:

The current thread is assumed to hold the lock associated with this Condition when this method is called. It is up to the implementation to determine if this is the case and if not, how to respond. Typically, an exception will be thrown (such as IllegalMonitorStateException) and the implementation must document that fact.

This works the same way as a "normal" monitor (Object#wait): You have to hold the lock when you start waiting (with a synchronized block in the case of Object#wait, with Lock#lock here). The lock will then be released and you wait. When the wait is over, you also hold the lock again.


text:
Q: Can't use Firebase ads: No static method zzc(Landroid/os/Bundle; I'm trying to add the Firebase ads library to my project (which is already live), the build works but when i try to run it crashes with this error:

11-16 10:33:13.535 540-540/com.dap E/AndroidRuntime: FATAL EXCEPTION: main
                                                       Process: com.dap, PID: 540 java.lang.NoSuchMethodError: No static method zzc(Landroid/os/Bundle;)Lcom/google/android/gms/measurement/internal/zzak; in class Lcom/google/android/gms/measurement/internal/zzak; or its super classes (declaration of 'com.google.android.gms.measurement.internal.zzak' appears in /data/app/com.dap-AZ0LDvxgjJKn7K-a-EQ0QQ==/split_lib_dependencies_apk.apk)
                                                           at com.google.firebase.analytics.connector.AnalyticsConnectorImpl.getInstance(Unknown Source:20)
                                                           at com.google.firebase.analytics.connector.internal.zzb.create(Unknown Source:6)
                                                           at com.google.firebase.components.Lazy.lambda$new$0(com.google.firebase:firebase-common@@16.0.4:43)
                                                           at com.google.firebase.components.Lazy$$Lambda$1.get(Unknown Source:4)
                                                           at com.google.firebase.components.Lazy.get(com.google.firebase:firebase-common@@16.0.4:54)
                                                           at com.google.firebase.components.AbstractComponentContainer.get(com.google.firebase:firebase-common@@16.0.4:26)
                                                           at com.google.firebase.components.ComponentRuntime.get(com.google.firebase:firebase-common@@16.0.4:34)
                                                           at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(com.google.firebase:firebase-common@@16.0.4:82)
                                                           at com.google.firebase.FirebaseApp.initializeAllApis(com.google.firebase:firebase-common@@16.0.4:761)
                                                           at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.0.4:359)
                                                           at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.0.4:324)
                                                           at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@16.0.4:310)
                                                           at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@16.0.4:53)
                                                           at android.content.ContentProvider.attachInfo(ContentProvider.java:1919)
                                                           at android.content.ContentProvider.attachInfo(ContentProvider.java:1894)
                                                           at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@16.0.4:47)
                                                           at android.app.ActivityThread.installProvider(ActivityThread.java:7107)
                                                           at android.app.ActivityThread.installContentProviders(ActivityThread.java:6594)
                                                           at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6498)
                                                           at android.app.ActivityThread.-wrap2(Unknown Source:0)
                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1963)
                                                           at android.os.Handler.dispatchMessage(Handler.java:108)
                                                           at android.os.Looper.loop(Looper.java:166)
                                                           at android.app.ActivityThread.main(ActivityThread.java:7425)
                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                           at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)

All my Firebase / Google libraries are up to date firebase latest version:
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {

implementation fileTree(include: ['*.jar'], dir: 'libs')

// Facebook libraries
implementation 'com.facebook.android:facebook-android-sdk:4.32.0'

// Firebase/Google libraries
implementation('com.crashlytics.sdk.android:crashlytics:2.9.6@aar') {
    transitive = true;
}

implementation 'com.firebase:geofire-android:2.1.0'

implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-storage:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.firebaseui:firebase-ui-storage:2.0.1'
implementation 'com.google.firebase:firebase-dynamic-links:16.1.3'
implementation 'com.google.firebase:firebase-analytics:16.0.5'
implementation 'com.google.firebase:firebase-config:16.1.0'
implementation 'com.google.firebase:firebase-invites:16.0.5'
implementation 'com.google.firebase:firebase-functions:16.1.2'
implementation 'com.google.firebase:firebase-ads:17.1.1'

implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.android.billingclient:billing:1.1'

// Support libraries (don't use the global support library)
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:percent:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-fragment:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:animated-vector-drawable:27.1.1'

// Other libraries
implementation 'com.baoyz.swipemenulistview:library:1.3.0'
implementation 'me.himanshusoni.chatmessageview:chat-message-view:1.0.3'
implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'com.github.warkiz.widget:indicatorseekbar:1.1.2'
implementation 'com.github.guilhe:seekbar-ranged-view:1.0.1'
implementation 'com.crystal:crystalrangeseekbar:1.1.3'

testImplementation 'junit:junit:4.12'

}
apply plugin: 'com.google.gms.google-services'

As long as my build.gradle:
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'
    classpath 'com.google.gms:google-services:4.2.0'

    dependencies {
        //classpath 'io.fabric.tools:gradle:1.25.0'
        classpath 'io.fabric.tools:gradle:1.25.1'
    }

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

I've tried to downgrade some libraries like this post advice too. No success.
I've tried to downgrade gms:play-services-location, but no success.
Instead of adding the ads library from Firebase i've tried the one from Google but i get this error:
"Error: Program type already present:         com.google.android.gms.internal.measurement.zzdz"
I've also tried to Clean and Rebuilt project, uninstall app on my phone, Invalidate Cache and Restart. But i keep getting the same error.
I'll keep digging but for now i can't find a way to make these Firebase libs to work together.
Finally if it can help anyone, here my gradlew app:dependencies:
+--- com.facebook.android:facebook-android-sdk:4.32.0
|    +--- com.facebook.android:facebook-core:4.32.0
|    |    +--- com.parse.bolts:bolts-android:1.4.0
|    |    |    +--- com.parse.bolts:bolts-tasks:1.4.0
|    |    |    \--- com.parse.bolts:bolts-applinks:1.4.0
|    |    |         \--- com.parse.bolts:bolts-tasks:1.4.0
|    |    +--- com.android.support:support-annotations:27.0.2 -> 27.1.1
|    |    \--- com.android.support:support-core-utils:27.0.2 -> 27.1.1
|    |         +--- com.android.support:support-annotations:27.1.1
|    |         \--- com.android.support:support-compat:27.1.1
|    |              +--- com.android.support:support-annotations:27.1.1
|    |              \--- android.arch.lifecycle:runtime:1.1.0
|    |                   +--- android.arch.lifecycle:common:1.1.0
|    |                   \--- android.arch.core:common:1.1.0
|    +--- com.facebook.android:facebook-common:4.32.0
|    |    +--- com.facebook.android:facebook-core:4.32.0 (*)
|    |    +--- com.android.support:support-v4:27.0.2 -> 27.1.1
|    |    |    +--- com.android.support:support-compat:27.1.1 (*)
|    |    |    +--- com.android.support:support-media-compat:27.1.1
|    |    |    |    +--- com.android.support:support-annotations:27.1.1
|    |    |    |    \--- com.android.support:support-compat:27.1.1 (*)
|    |    |    +--- com.android.support:support-core-utils:27.1.1 (*)
|    |    |    +--- com.android.support:support-core-ui:27.1.1
|    |    |    |    +--- com.android.support:support-annotations:27.1.1
|    |    |    |    +--- com.android.support:support-compat:27.1.1 (*)
|    |    |    |    \--- com.android.support:support-core-utils:27.1.1 (*)
|    |    |    \--- com.android.support:support-fragment:27.1.1
|    |    |         +--- com.android.support:support-compat:27.1.1 (*)
|    |    |         +--- com.android.support:support-core-ui:27.1.1 (*)
|    |    |         +--- com.android.support:support-core-utils:27.1.1 (*)
|    |    |         +--- com.android.support:support-annotations:27.1.1
|    |    |         +--- android.arch.lifecycle:livedata-core:1.1.0
|    |    |         |    +--- android.arch.lifecycle:common:1.1.0
|    |    |         |    +--- android.arch.core:common:1.1.0
|    |    |         |    \--- android.arch.core:runtime:1.1.0
|    |    |         |         \--- android.arch.core:common:1.1.0
|    |    |         \--- android.arch.lifecycle:viewmodel:1.1.0
|    |    +--- com.android.support:appcompat-v7:27.0.2 -> 27.1.1
|    |    |    +--- com.android.support:support-annotations:27.1.1
|    |    |    +--- com.android.support:support-core-utils:27.1.1 (*)
|    |    |    +--- com.android.support:support-fragment:27.1.1 (*)
|    |    |    +--- com.android.support:support-vector-drawable:27.1.1
|    |    |    |    +--- com.android.support:support-annotations:27.1.1
|    |    |    |    \--- com.android.support:support-compat:27.1.1 (*)
|    |    |    \--- com.android.support:animated-vector-drawable:27.1.1
|    |    |         +--- com.android.support:support-vector-drawable:27.1.1 (*)
|    |    |         \--- com.android.support:support-core-ui:27.1.1 (*)
|    |    +--- com.android.support:cardview-v7:27.0.2
|    |    |    \--- com.android.support:support-annotations:27.0.2 -> 27.1.1
|    |    +--- com.android.support:customtabs:27.0.2
|    |    |    +--- com.android.support:support-compat:27.0.2 -> 27.1.1 (*)
|    |    |    \--- com.android.support:support-annotations:27.0.2 -> 27.1.1
|    |    \--- com.google.zxing:core:3.3.0
|    +--- com.facebook.android:facebook-login:4.32.0
|    |    +--- com.facebook.android:facebook-core:4.32.0 (*)
|    |    +--- com.facebook.android:facebook-common:4.32.0 (*)
|    |    \--- com.android.support:appcompat-v7:27.0.2 -> 27.1.1 (*)
|    +--- com.facebook.android:facebook-share:4.32.0
|    |    +--- com.facebook.android:facebook-core:4.32.0 (*)
|    |    \--- com.facebook.android:facebook-common:4.32.0 (*)
|    +--- com.facebook.android:facebook-places:4.32.0
|    |    \--- com.facebook.android:facebook-core:4.32.0 (*)
|    +--- com.facebook.android:facebook-applinks:4.32.0
|    |    +--- com.facebook.android:facebook-core:4.32.0 (*)
|    |    \--- com.parse.bolts:bolts-android:1.4.0 (*)
|    \--- com.facebook.android:facebook-messenger:4.32.0
|         +--- com.facebook.android:facebook-core:4.32.0 (*)
|         \--- com.parse.bolts:bolts-android:1.4.0 (*)
+--- com.crashlytics.sdk.android:crashlytics:2.9.6
|    +--- com.crashlytics.sdk.android:answers:1.4.4
|    |    \--- io.fabric.sdk.android:fabric:1.4.5
|    +--- com.crashlytics.sdk.android:beta:1.2.10
|    +--- io.fabric.sdk.android:fabric:1.4.5
|    \--- com.crashlytics.sdk.android:crashlytics-core:2.6.5
|         +--- com.crashlytics.sdk.android:answers:1.4.4 (*)
|         \--- io.fabric.sdk.android:fabric:1.4.5
+--- com.firebase:geofire-android:2.1.0
+--- com.google.firebase:firebase-core:16.0.4
|    +--- com.google.firebase:firebase-analytics:16.0.4 -> 16.0.5
|    |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0
|    |    |    \--- com.android.support:support-v4:26.1.0 -> 27.1.1 (*)
|    |    +--- com.google.android.gms:play-services-measurement-api:[16.0.3] -> 16.0.3
|    |    |    +--- com.google.android.gms:play-services-ads-identifier:16.0.0
|    |    |    |    \--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |    +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
|    |    |    |    \--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |    +--- com.google.android.gms:play-services-stats:16.0.1
|    |    |    |    \--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |    +--- com.google.android.gms:play-services-tasks:16.0.1
|    |    |    |    \--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |    +--- com.google.firebase:firebase-analytics-impl:[16.2.3] -> 16.2.3
|    |    |    |    +--- com.google.android.gms:play-services-ads-identifier:16.0.0 (*)
|    |    |    |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |    |    +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
|    |    |    |    +--- com.google.android.gms:play-services-stats:16.0.1 (*)
|    |    |    |    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    |    |    |    +--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4
|    |    |    |    |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |    |    |    \--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    |    |    |    \--- com.google.firebase:firebase-iid:17.0.3 -> 17.0.4
|    |    |    |         +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |    |         +--- com.google.android.gms:play-services-stats:16.0.1 (*)
|    |    |    |         +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    |    |    |         +--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
|    |    |    |         \--- com.google.firebase:firebase-iid-interop:16.0.1
|    |    |    |              +--- com.google.android.gms:play-services-base:16.0.1
|    |    |    |              |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |    |              |    \--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    |    |    |              \--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |    +--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
|    |    |    \--- com.google.firebase:firebase-iid:17.0.3 -> 17.0.4 (*)
|    |    +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
|    |    +--- com.google.android.gms:play-services-stats:16.0.1 (*)
|    |    +--- com.google.firebase:firebase-analytics-impl:[16.2.3] -> 16.2.3 (*)
|    |    \--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
|    \--- com.google.firebase:firebase-measurement-connector-impl:17.0.2
|         +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|         +--- com.google.android.gms:play-services-measurement-api:16.0.2 -> 16.0.3 (*)
|         +--- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
|         +--- com.google.firebase:firebase-analytics:16.0.4 -> 16.0.5 (*)
|         +--- com.google.firebase:firebase-analytics-impl:16.2.2 -> 16.2.3 (*)
|         +--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
|         \--- com.google.firebase:firebase-measurement-connector:17.0.1
|              \--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
+--- com.google.firebase:firebase-messaging:17.3.4
|    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    +--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
|    +--- com.google.firebase:firebase-iid:[17.0.4] -> 17.0.4 (*)
|    \--- com.google.firebase:firebase-measurement-connector:17.0.1 (*)
+--- com.google.firebase:firebase-storage:16.0.4
|    +--- com.google.android.gms:play-services-base:16.0.1 (*)
|    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    \--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
+--- com.google.firebase:firebase-auth:16.0.5
|    +--- com.google.android.gms:play-services-base:16.0.1 (*)
|    +--- com.google.android.gms:play-services-basement:16.1.0 (*)
|    +--- com.google.android.gms:play-services-flags:16.0.1
|    |    +--- com.google.android.gms:play-services-base:16.0.1 (*)
|    |    \--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    +--- com.google.firebase:firebase-auth-interop:16.0.1
|    |    +--- com.google.android.gms:play-services-base:16.0.1 (*)
|    |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    |    \--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
|    \--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
+--- com.google.firebase:firebase-database:16.0.4
|    +--- com.google.android.gms:play-services-base:16.0.1 (*)
|    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    +--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
|    \--- com.google.firebase:firebase-database-collection:16.0.0
|         \--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
+--- com.firebaseui:firebase-ui-storage:2.0.1
|    +--- com.android.support:appcompat-v7:25.3.1 -> 27.1.1 (*)
|    +--- com.android.support:palette-v7:25.3.1
|    |    +--- com.android.support:support-compat:25.3.1 -> 27.1.1 (*)
|    |    \--- com.android.support:support-core-utils:25.3.1 -> 27.1.1 (*)
|    +--- com.github.bumptech.glide:glide:3.7.0 -> 3.8.0
|    \--- com.google.firebase:firebase-storage:11.0.1 -> 16.0.4 (*)
+--- com.google.firebase:firebase-dynamic-links:16.1.3
|    +--- com.google.android.gms:play-services-base:16.0.1 (*)
|    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
|    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    +--- com.google.firebase:firebase-analytics-impl:[16.2.3] -> 16.2.3 (*)
|    \--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
+--- com.google.firebase:firebase-analytics:16.0.5 (*)
+--- com.google.firebase:firebase-config:16.1.0
|    +--- com.google.android.gms:play-services-base:16.0.1 (*)
|    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    +--- com.google.android.gms:play-services-phenotype:16.0.0
|    |    +--- com.google.android.gms:play-services-base:16.0.1 (*)
|    |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    \--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    +--- com.google.firebase:firebase-abt:16.0.1
|    |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    +--- com.google.firebase:firebase-analytics-impl:16.2.2 -> 16.2.3 (*)
|    |    \--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
|    +--- com.google.firebase:firebase-analytics:16.0.4 -> 16.0.5 (*)
|    +--- com.google.firebase:firebase-analytics-impl:16.2.2 -> 16.2.3 (*)
|    +--- com.google.firebase:firebase-common:16.0.3 -> 16.0.4 (*)
|    \--- com.google.firebase:firebase-iid:17.0.3 -> 17.0.4 (*)
+--- com.google.firebase:firebase-invites:16.0.5
|    +--- com.google.android.gms:play-services-appinvite:16.0.5
|    |    +--- com.google.android.gms:play-services-base:16.0.1 (*)
|    |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
|    |    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    |    \--- com.google.firebase:firebase-dynamic-links:[16.1.3] -> 16.1.3 (*)
|    \--- com.google.firebase:firebase-analytics:16.0.5 (*)
+--- com.google.firebase:firebase-functions:16.1.2
|    +--- com.google.android.gms:play-services-base:16.0.1 (*)
|    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    +--- com.google.firebase:firebase-auth-interop:16.0.1 (*)
|    +--- com.google.firebase:firebase-common:16.0.4 (*)
|    +--- com.google.firebase:firebase-iid:17.0.3 -> 17.0.4 (*)
|    +--- com.google.firebase:firebase-iid-interop:16.0.1 (*)
|    \--- com.squareup.okhttp:okhttp:2.7.2
|         \--- com.squareup.okio:okio:1.6.0
+--- com.google.firebase:firebase-ads:17.1.1
|    +--- com.google.android.gms:play-services-ads:17.1.1
|    |    +--- com.android.support:customtabs:26.1.0 -> 27.0.2 (*)
|    |    +--- com.google.android.gms:play-services-ads-base:[17.1.1] -> 17.1.1
|    |    +--- com.google.android.gms:play-services-ads-identifier:16.0.0 (*)
|    |    +--- com.google.android.gms:play-services-ads-lite:[17.1.1] -> 17.1.1
|    |    |    +--- com.google.android.gms:play-services-ads-base:[17.1.1] -> 17.1.1
|    |    |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |    \--- com.google.android.gms:play-services-measurement-sdk-api:16.0.3
|    |    |         +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    |         \--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
|    |    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    |    \--- com.google.android.gms:play-services-gass:[17.1.1] -> 17.1.1
|    |         +--- com.google.android.gms:play-services-ads-base:[17.1.1] -> 17.1.1
|    |         \--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    \--- com.google.firebase:firebase-analytics:16.0.5 (*)
+--- com.google.android.gms:play-services-location:16.0.0
|    +--- com.google.android.gms:play-services-base:16.0.1 (*)
|    +--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    +--- com.google.android.gms:play-services-places-placereport:16.0.0
|    |    \--- com.google.android.gms:play-services-basement:16.0.1 -> 16.1.0 (*)
|    \--- com.google.android.gms:play-services-tasks:16.0.1 (*)
+--- com.android.billingclient:billing:1.1
|    \--- com.android.support:support-annotations:25.0.0 -> 27.1.1
+--- com.android.support.constraint:constraint-layout:2.0.0-alpha2
|    +--- com.android.support:appcompat-v7:27.1.1 (*)
|    +--- com.android.support:recyclerview-v7:27.1.1
|    |    +--- com.android.support:support-annotations:27.1.1
|    |    +--- com.android.support:support-compat:27.1.1 (*)
|    |    \--- com.android.support:support-core-ui:27.1.1 (*)
|    \--- com.android.support.constraint:constraint-layout-solver:2.0.0-alpha2
+--- com.android.support:multidex:1.0.3
+--- com.android.support:percent:27.1.1
|    \--- com.android.support:support-compat:27.1.1 (*)
+--- com.android.support:recyclerview-v7:27.1.1 (*)
+--- com.android.support:support-fragment:27.1.1 (*)
+--- com.android.support:support-vector-drawable:27.1.1 (*)
+--- com.android.support:appcompat-v7:27.1.1 (*)
+--- com.android.support:design:27.1.1
|    +--- com.android.support:support-v4:27.1.1 (*)
|    +--- com.android.support:appcompat-v7:27.1.1 (*)
|    +--- com.android.support:recyclerview-v7:27.1.1 (*)
|    \--- com.android.support:transition:27.1.1
|         +--- com.android.support:support-annotations:27.1.1
|         \--- com.android.support:support-compat:27.1.1 (*)
+--- com.android.support:animated-vector-drawable:27.1.1 (*)
+--- com.baoyz.swipemenulistview:library:1.3.0
|    \--- com.android.support:support-v4:22.1.1 -> 27.1.1 (*)
+--- me.himanshusoni.chatmessageview:chat-message-view:1.0.3
+--- com.github.bumptech.glide:glide:3.8.0
+--- com.github.warkiz.widget:indicatorseekbar:1.1.2
+--- com.github.guilhe:seekbar-ranged-view:1.0.1
|    \--- com.android.support:appcompat-v7:26.0.1 -> 27.1.1 (*)
+--- com.crystal:crystalrangeseekbar:1.1.3
|    \--- com.android.support:appcompat-v7:23.4.0 -> 27.1.1 (*)
\--- com.android.support:multidex:1.0.2 -> 1.0.3

(*) - dependencies omitted (listed previously)
(n) - Not resolved (configuration is not meant to be resolved)

Sorry for all the codes blocks, but i thought it would be more easier to understand.
Thank you for your time.

A: So i found a solution to my problem, but it's not really the best way in my opinion.
I had to downgrade several firebase lib until it works as you can see on my graddle.
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-messaging:17.3.2'
implementation 'com.google.firebase:firebase-storage:16.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.2'
implementation 'com.firebaseui:firebase-ui-storage:2.0.1'
implementation 'com.google.firebase:firebase-dynamic-links:16.1.1'
implementation 'com.google.firebase:firebase-analytics:16.0.3'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.firebase:firebase-invites:16.0.3'
implementation 'com.google.firebase:firebase-functions:16.1.0'
implementation 'com.google.firebase:firebase-ads:15.0.1'

implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.android.billingclient:billing:1.1'

Apparently some libs depend on each other. For now i won't update them to their latest version...
It would be really appreciated if i could have more information about this.

A: please replace com.google.firebase:firebase-ads:17.1.1 with com.google.firebase:firebase-ads:17.1.0

A: Make sure that firebase-core and firebase-ads are up to date by specifying the last version.
At the time of writing my answer they are:
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-ads:17.1.2'

A: Change implementation 'com.google.firebase:firebase-core:16.0.4' to implementation 'com.google.firebase:firebase-core:+'

A: well i have spent 2 days on the exact same pbs. So first, i changed
implementation 'com.google.firebase:firebase-core:16.0.4' -> implementation 'com.google.firebase:firebase-core:16.0.5' but, when running it, it could not find the exact version 16.0.5. So what ends up working weirdly for me, is to change
'com.google.firebase:firebase-core:16.0.4' -> implementation 'com.google.firebase:firebase-core:+'
Here is my app level build.gradle dependencies, in case it might be helpful:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

configurations.androidTestImplementation.dependencies.each { androidTestImplementationDependency ->
    androidTestImplementationDependency.exclude group: 'com.android.support'
}

implementation ("com.android.support:support-v4:28.0.0") {
    force = true //<-- force dependency resolution to 28.0.0 in my case
}
implementation project(':slyce-messaging')
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-core-utils:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.firebase:firebase-core:+'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.6'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-config:16.1.0'
implementation 'com.google.firebase:firebase-invites:16.0.4'
implementation 'com.firebaseui:firebase-ui:2.0.1'
implementation 'com.google.android.gms:play-services-appinvite:16.0.5'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.firebase:firebase-jobdispatcher:0.5.2'
implementation 'net.rimoto:intlphoneinput:1.0.1'
implementation 'com.github.marlonlom:timeago:3.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.google.firebase:firebase-ads:17.1.1'

}
apply plugin: 'com.google.gms.google-services'
Below is the error message, i got same thing :
java.lang.NoSuchMethodError: No static method zzc(Landroid/os/Bundle;)Lcom/google/android/gms/measurement/internal/zzak; in class Lcom/google/android/gms/measurement/internal/zzak; or its super classes (declaration of 'com.google.android.gms.measurement.internal.zzak' appears in ...)
        at com.google.firebase.analytics.connector.AnalyticsConnectorImpl.getInstance(Unknown Source)
        at com.google.firebase.analytics.connector.internal.zzb.create(Unknown Source)

A: I was experiencing the same with these versions of firebase in my build.gradle:
implementation 'com.google.firebase:firebase-core:17.2.2'
implementation 'com.google.firebase:firebase-messaging:20.1.0'

to solve the issue it was enough to update firebase to the most recent version at the time of writing:
implementation 'com.google.firebase:firebase-core:17.4.1'
implementation 'com.google.firebase:firebase-messaging:20.1.7'

and clean/rebuild the project.


text:
Q: How do I randomly pick elements from an Array that satisfy a condition? I have a player and group class which I've used to instantiate the following:
Player andrew = new Player(*name:* Andrew, *health:* 20)
Player samantha = new Player(*name:* Samantha, *health:* 32)
Player tony = new Player(*name:* Tony, *health:* 5)
Player flynn = new Player(*name:* Flynn, *health:* 0)
Player oliver = new Player(*name:* Oliver, *health:* 0)
Group myGroup = new Group(*player:* andrew, *player:* samantha, *player:* tony, *player:* flynn, *player:* oliver)

The following method, which I've defined in the group class puts all the players in the group in to an Array and returns it when evoked on the Group object:
myGroup.putIntoList()

So putting the line above would return:
[Player@andrew, Player@samantha, Player@tony, Player@flynn, Player@oliver]

where each element of the array is the player objects I created earlier.
I have also defined a .getHealth() method in my player class which returns the health of the player.
Getting to the main point,
I want to write a method in my Group class which chooses a player from that generated array at random that is also not dead (i.e. health is above 0)
This is what I've written so far:
import java.util.Random;

Random myNumber = new Random();
public Player pickOutAndReturn(){
   int anotherNumber = myNumber.nextInt(5);
   return this.putIntoList()[anotherNumber];
}

The trouble with this is that it can return any 5 of the players at random. How do I change it so that it only returns the alive members but at random without removing the dead players from the array?

A: Before choosing randomly, filter the array with:
Players [] health_players = Arrays.stream(this.putIntoList())
                                  .filter(i -> i.getHealth() > 0)
                                  .toArray();

only then choose randomly from the health_players.
Random myNumber = new Random();
public Player pickOutAndReturn(){
     Players [] health_players = Arrays.stream(this.putIntoList())
                                       .filter(i -> i.getHealth() > 0)
                                       .toArray();

   int anotherNumber = myNumber.nextInt(health_players.length);
   return health_players[anotherNumber];
}

A: public Player pickOutAndReturn() {
   // filter for alive players
   var alivePlayers = this.putIntoList().stream()
      .filter(player -> player.getHealth() > 0)
      .collect(Collectors.toList())

   // pick a random player from list
   int anotherNumber = myNumber.nextInt(alivePlayers.size());
   return alivePlayer.get(anotherNumber);


text:
Q: Show Query plan in SSRS Is it possible to display the query plan graphically in a  report in SSRS 2005/2008 as it shows in SSMS?
Any ideas, references, articles would be apperciated.

A: I have not seen a way to directly display a query plan.  The few times I've wanted to do something similar I just copied the query out of SSRS & pasted it into a query window in SSMS.  SSMS is a lot easier to use for designing/debugging queries.  Once I have the query down it's a small matter to paste it back into SSRS.  (I have to declare my parameters and set values to them, but that's not a big deal).


text:
Q: Error: package or namespace load failed for 'dplyr' in loadNamespace Al correr un programa instalando 'dplyr' me sale el siguiente mensaje

Error: package or namespace load failed for 'dplyr' in loadNamespace(j
<- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):  there
is no package called 'tidyselect' In addition: Warning message:
package 'dplyr' was built under R version 3.5.3

Y al instalar  'tidyselect' el siguiente:

Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck =
vI[[i]]) :    namespace 'rlang' 0.4.5 is being loaded, but >= 0.4.6 is
required ERROR: lazy loading failed for package 'tidyselect'
* removing 'C:/Users/m_cle/Documents/R/win-library/3.5/tidyselect' In R CMD INSTALL Warning in install.packages :   installation of package
'tidyselect' had non-zero exit status

No se si a alguien le paso algo similar.


text:
Q: Use MVC Html.BeginForm with GET method and action parameters I know I can use Html.BeginForm to POST with action parameters like this:
@using (Html.BeginForm("Details", "Home", new { name = Model.Name }))

and I can GET like this:
@using (Html.BeginForm("Details", "Home", FormMethod.Get))

But I can't seem to do both.  How do I?
Update
Here is the entirety of the form in question:
@using (Html.BeginForm("Details", "Home", new { name = Model.Name }))
{

        @Html.DropDownList("viewMonth",
                                  new List<SelectListItem>(ViewBag.MonthNames))
        @Html.TextBox("viewYear", Model.ViewYear, new {style = "width: 30px"})
        <input type="submit" value="Go"/>

}

where viewMonth and viewYear are parameter names in Action/Details.  If I try
@using (Html.BeginForm("Details", "Home", new { name = Model.Name },
                        FormMethod.Get))

it will pass viewMonth and viewYear, but not name.

A:
But I can't seem to do both

You can do both ... you can use the overload you need
So for example if name is a routeValue:
@using (Html.BeginForm("Details", "Home", new { name = Model.Name },
                        FormMethod.Get))

and if name is an htmlAttribute of the form:
@using (Html.BeginForm("Details", "Home", FormMethod.Get,
                        new { name = Model.Name }))

and if you want to use both routeValues and htmlAttributes:
@using (Html.BeginForm("Details", "Home", new { name = Model.Name },
                        FormMethod.Get, new { name = "foo_bar" }))


text:
Q: Does TeamCity use Jenkins behind the scenes? My colleague told me that TeamCity is just Jenkins with a different frontend (as in Teamcity uses Jenkins behind..).
Is that true? I can't find that information anywhere online.

A: No it isn't true - they are different products and neither of them is based on the other.

A: Your friend probably meant that they both are for same purpose (Continuous Integration). Other than that there is no relation between them, they are different products from different vendors for relatively same purpose (Continuous Integration). You can see Comparison_of_continuous_integration_software to compare different CI software.


text:
Q: Gumstix with an e-ink screen I really want to develop on a gumstix with an e-ink display, but $3000 for a development board is a bit steep for me right now, especially since I just want to get a prototype out so I can see what the market is like.
As a work-around, this is what I have in mind:

*

*Buy a Kindle

*Buy a gumstix with a dev board

*Hook up the Kindle display to dev board using clever soldering

This is what I want in the end:

*

*Low-power, easy to read screen (text viewing)

*Wifi-enabled device

*More than 4 GB of persistent storage

*Touch enabled device (I can get by without this)

*Preferably color, but monochrome is ok

I am really intrigued by the persistence of the e-ink display without using battery...
Is it possible to use the e-ink screen with the gumstix? If not, is there anything else I should be looking into?
EDIT:
I think I can root the Kindle and install my own OS on it, but I won't be able to easily add parts to it (say USB ports, audio ports, etc).  The gumstix is really the way to go.
Legal:
From what I read in the EULA, it is a violation to disassemble the Kindle, but the only thing they can do is revoke access to the Kindle Store and revoke use of any eBooks or services downloaded.  There is no mention of penalties or fines for violating the EULA with respect to hardware.  Since I am not developing this as part of a company, I don't think there is anything they can do legally.
Even so, I just want to know if it can be done with existing hardware and software. If I plan to market something with Kindle hardware components (which I won't), I'll definitely talk to a lawyer first.

A: Get yourself a chinese ebook reader running linux.
Go look on ebay. "ebook linux"
I don't know how to root the one commonly sold with a wifi and keyboard yet, but it is definitely sold as a linux machine.
I own an earlier model without keyobard or wifi ( I wanted a book reader.)  It in an ARM CPU, runs linux, takes 8Gb memory cards and internally the PCB has pads for 9 pin serial port, vias for the 9 pin serial port, SIM slot, Ethernet jack ( and pads to attach the Ethernet chips) sound in, input ADC pads next to it, and pads for a microphone. Looks like the development team used their dev layout with less parts loaded. I'd bet the parts used were the cheapest supported by linux/arm.  The screen controller is a standard e-ink interface part too; so in theory I can build my own bootable linux image for it.
My experience is that the bootloader shows the GRUB line on one line of the display just as it boots.  A serial console connection ( indicited by the presence of the vias for the serial as well as the pads) would allow me to interrupt boot and redirect init=/bin/sh
So then all I need is to mount the removable media ( if it hasn't automounted!) and copy the existing system image off to removable for autopsy and alteration.