问:
Android APK file download stuck on 0.00B/0.00B
I'm trying to download an apk file that I've signed and exported using the Android wizard in Eclipse in the release mode. I've hosted it on IIS with and set the MIME types as .apk and application/vnd.android.package-archive. I try to open this file on a test Android tablet that I have with me and the download is stuck on 0.00B / 0.00B with filename as <Unknown> and options to pause or cancel downloads.

It's not giving me any errors, so I'm not sure what I'm doing wrong here. Has anyone encountered a similar situation before?

Thanks,

Teja.

答:
Turns out having a self signed (untrusted) certificate for the server you've hosted your app at can cause the problem. Changing servers to one that has the right certificate let me download the app fine.

I'm sure there's a browser setting somewhere that lets you download files from untrusted servers, if anyone can point that out, I'd gladly mark that as the answer.


来源: stackexchange

问:
Is there a better way to change every variable in a struct, C
I'm curious if there's a better way of changing every variable in a structure instead of the following block of code.

```<code>struct RuntimeData
{
    double runtime_ms, sum_ms, avg_time_ms, best_time_ms;
};

int main()
{
    struct RuntimeData selection;

    // The '0' values are just for example..
    selection.runtime_ms = 0;
    selection.sum_ms = 0;
    selection.avg_time_ms = 0;
    selection.best_time_ms = 0;
}
</code>```

I'd much rather be able to do something similar to this...

```<code>struct RuntimeData selection;

selection = { .runtime_ms=0,
              .sum_ms = 0,
              .avg_time_ms = 0,
              .best_time_ms = 0
};
</code>```

...or something similar. I know you can do the latter codeblock while initializing the structure, but it results in a compilation error after the struct has already been initialized.

EDIT: Using Nate's and Vlad's answers, a compound literal is exactly what I needed! Thank you so much.

答:
You can do the initialization with a compound literal.</p>

```<code>selection = (struct RunTimeData){0,0,0,0};
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I'm curious if there's a better way of changing every variable in a structure instead of the following block of code.

struct RuntimeData
{
    double runtime_ms, sum_ms, avg_time_ms, best_time_ms;
};

int main()
{
    struct RuntimeData selection;

    // The '0' values are just for example..
    selection.runtime_ms = 0;
    selection.sum_ms = 0;
    selection.avg_time_ms = 0;
    selection.best_time_ms = 0;
}

I'd much rather be able to do something similar to this...

struct RuntimeData selection;

selection = { .runtime_ms=0,
              .sum_ms = 0,
              .avg_time_ms = 0,
              .best_time_ms = 0
};

...or something similar. I know you can do the latter codeblock while initializing the structure, but it results in a compilation error after the struct has already been initialized.

EDIT: Using Nate's and Vlad's answers, a compound literal is exactly what I needed! Thank you so much.

Body:
You can do the initialization with a compound literal.

selection = (struct RunTimeData){0,0,0,0};


问:
Unable to resolve service registered via assembly scanning
Configuration

I have :

A .net core MVC app project

A module project containing

A controller (MyController),

A repository interface (IMyRepository)

A repository (MyRepository which Implements IMyRepository and IRepository)

The .net core app references the module project

I have used Scrutor in the MVC app to grab all classes that implement IRepositoy in any referenced projects and register them in the services collection:

```<code>public static void RegisterAllTypes<T>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{

    var entryAssembly = Assembly.GetEntryAssembly();
    var referencedAssemblies = entryAssembly.GetReferencedAssemblies().Select(Assembly.Load);
    var assemblies = new List<Assembly> { entryAssembly }.Concat(referencedAssemblies).ToArray();

    services.Scan(
        x =>
        {
            x.FromAssemblies(assemblies)
                .AddClasses(classes => classes.AssignableTo(typeof(T)))
                    .AsImplementedInterfaces()

                .WithLifetime(lifetime);
    });
}
</code>```

The Problem

If I examine the services collection I can see that IMyRepository is registered and should resolve to MyRepository. However, the repository when injected into MyController as per below:

```<code>private readonly IMyRepository _myRepository ;

public MyController(IMyRepository myRepository )
{
    _myRepository = myRepository;
}
</code>```

throws the error:

Unable to resolve service for type 'IMyRepository' while
  attempting to activate
  'MyController.

Unless...

After registering the repositories via Scrutor I put

```<code>var test = typeof(IMyRepository);
</code>```

At which point everything works as expected. But that defeats the entire point of automatic dependency registration.

Any help greatly appreciated.

答:
Changed registration method to use FromApplicationDependencies() and now everything seems to be ok.

```<code>public static void RegisterAllTypes<T>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{
    services.Scan(
        x =>
        {
            x.FromApplicationDependencies()
                .AddClasses(classes => classes.AssignableTo(typeof(T)))
                    .AsImplementedInterfaces()
                    .WithLifetime(lifetime);
        });
}
</code>```

Body:
Configuration

I have :

A .net core MVC app project

A module project containing

A controller (MyController),

A repository interface (IMyRepository)

A repository (MyRepository which Implements IMyRepository and IRepository)

The .net core app references the module project

I have used Scrutor in the MVC app to grab all classes that implement IRepositoy in any referenced projects and register them in the services collection:

public static void RegisterAllTypes<T>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{

    var entryAssembly = Assembly.GetEntryAssembly();
    var referencedAssemblies = entryAssembly.GetReferencedAssemblies().Select(Assembly.Load);
    var assemblies = new List<Assembly> { entryAssembly }.Concat(referencedAssemblies).ToArray();

    services.Scan(
        x =>
        {
            x.FromAssemblies(assemblies)
                .AddClasses(classes => classes.AssignableTo(typeof(T)))
                    .AsImplementedInterfaces()

                .WithLifetime(lifetime);
    });
}

The Problem

If I examine the services collection I can see that IMyRepository is registered and should resolve to MyRepository. However, the repository when injected into MyController as per below:

private readonly IMyRepository _myRepository ;

public MyController(IMyRepository myRepository )
{
    _myRepository = myRepository;
}

throws the error:

Unable to resolve service for type 'IMyRepository' while
  attempting to activate
  'MyController.

Unless...

After registering the repositories via Scrutor I put

var test = typeof(IMyRepository);

At which point everything works as expected. But that defeats the entire point of automatic dependency registration.

Any help greatly appreciated.

Body:
Changed registration method to use FromApplicationDependencies() and now everything seems to be ok.

public static void RegisterAllTypes<T>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{
    services.Scan(
        x =>
        {
            x.FromApplicationDependencies()
                .AddClasses(classes => classes.AssignableTo(typeof(T)))
                    .AsImplementedInterfaces()
                    .WithLifetime(lifetime);
        });
}


答:
You need a compound literal:

```<code>struct RuntimeData selection = /* Initialization with designated initializers */
    {
        .runtime_ms   = 0,
        .sum_ms       = 0,
        .avg_time_ms  = 0,
        .best_time_ms = 0
    };

selection = (struct RuntimeData){     /* Assignment of compound literal */
              .runtime_ms   = 23,
              .sum_ms       = 34,
              .avg_time_ms  = 45,
              .best_time_ms = 56
           };
</code>```

Formatting is up to you.  The syntax should work in C18, C11 or C99 — compound literals were not a part of C90 (aka C89).  However, since the same comments apply to designated initializers and you're already using them, this won't be a problem for you.

Title: Is there a better way to change every variable in a struct, C

Body:
You need a compound literal:

struct RuntimeData selection = /* Initialization with designated initializers */
    {
        .runtime_ms   = 0,
        .sum_ms       = 0,
        .avg_time_ms  = 0,
        .best_time_ms = 0
    };

selection = (struct RuntimeData){     /* Assignment of compound literal */
              .runtime_ms   = 23,
              .sum_ms       = 34,
              .avg_time_ms  = 45,
              .best_time_ms = 56
           };

Formatting is up to you.  The syntax should work in C18, C11 or C99 — compound literals were not a part of C90 (aka C89).  However, since the same comments apply to designated initializers and you're already using them, this won't be a problem for you.


问:
Consolidate @media tags
Is there a way to consolidate @media tags to clean them up. I am new to this and want to clean up my site to work better on mobile devices but it seems like I shouldn't have to keep repeating the @media statement in my code below.

@media screen and (max-width: 600px) {

  div.pagetopmenu,
  div.menutoplogo,
  div.pagemenul,
  div.pagemenur {
    display: none;
  }

  @media screen and (max-width:600px) {

    .pagemainbody {
      float: left;
      width: 100%;
      min-height: 100%;
      overflow: hidden;
    }

    @media screen and (max-width:600px) {

      .centediv {
        width: 60%;
        margin-top: 2px;
        margin-right: auto;
        margin-left: auto;
        height: 105px;
        overflow: hidden;
        clear: both;
      }
```

答:
Well, you don't have to repeat the @media statement over and over, just group all the target CSS properties inside one media block, like so:

@media screen and (max-width: 600px) {

    div.pagetopmenu,
    div.menutoplogo,
    div.pagemenul,
    div.pagemenur {
      display: none;
    }

    .pagemainbody {
      float: left;
      width: 100%;
      min-height: 100%;
      overflow: hidden;
    }

    .centediv {
      width: 60%;
      margin-top: 2px;
      margin-right: auto;
      margin-left: auto;
      height: 105px;
      overflow: hidden;
      clear: both;
    }
}
```

Title: Consolidate @media tags


问:
VC6 on Win 10 Debugging when a DLL in another DLL gives User Breakpoint hit
I just installed a Windows 10 machine, since Windows 7 is now dropped... along with the old, classic VC6.  Plus the Service pack 6, and the Platform SDK installed.  I have been using it this way with no issues on my Windows 7 machine for decades (too long to go into why not upgrade to VS 2010, 2012, 2015, 2017, 2019, yada yada, yada...  Subject for a different debate)

I brought up an existing project I was working in before the end of the year. Big exe, several DLLs in it, C++ objects, etc...  Was all working fine before Jan 1st.

On my new Windows 10 install, when I tried to launch it in the debugger, it gave an error:

This appears even before main is called. And the executable immediately exists, even before the message box appears, so there is no stack trace to examine. Naturally I looked for any C++ constructors that might be called which could be corrupting things.  But there were none. (and never had any issues on my Windows 7 machine anyway)

I narrowed it to the following condition:
The main EXE is linked statically to a LIB/DLL.  THAT dll is linked statically to another LIB/DLL
When I remove the underneath DLL dependency, I can run the executable in the debugger.

I've found several projects that are experiencing this.

I have a test project (dsw and dps files) which demonstrates this (at least on my Windows 10 machine) if anyone wants to look at it.  It is stripped down to nothing but shells. An EXE that is linked to a DLL, which is linked to another DLL. If I remove the inner DLL dependency in the link stage, the executable with a single DLL work fine.

Also, the EXE will run outside the debugger as well.  Both debug and release.

Lastly, when I set the configuration for release, it also runs in the IDE, but has no debug info.  However if I enable debug info in the release builds, it again crashes before startup.

So apparently there is yet something in windows 10 that is preventing the debugging container from running.  I have also disabled the "Fault Tolerant Heap Shim" but no change.

Has anyone experienced something like this?

Does anyone have any advice?

-Scotty

答: I've been living without our V6 debugger for a few years now, and after doing yet another search hoping for a solution where I wound up here, I finally found a way and wanted to share it.  For projects that give a user breakpoint error and exit immediately on startup, launch them with Build->Execute (ctrl+F5), then do a Build->Start Debug->Attach Process.  You won't be able to do anything about the startup, but you can set breakpoints at timers or commands to get in.  I guess you could put a long sleep as the first call in your main while debugging to give you a chance to get in and get your breakpoints in place there too.</p>


问:
Kafka streaming to cassandra using logstash
I'm trying to stream from a kafka topic to a table in cassandra, I have my configuration file at
..../logstash-7.6.0/config, file name is pipeline.conf and it's contents are as follows,

```<code>input {
    kafka {
            bootstrap_servers => "localhost:9092"
            topics => ["test"]
    }
}
output{
     cassandra {
        hosts => [ "127.0.0.1"]
        port => 9042
        protocol_version => 4
        consistency => 'any'
        keyspace => "task3"
        table => "%{[@metadata][logfile]}"
        hints => {
            host => "text"
            time => "timestamp"
            response_time => "int"
            status => "int"
            method => "text"
            protocol => "text"
            endpoint => "text"
            uuid => "uuid"
        }
        retry_policy => { "type" => "default" }
        request_timeout => 1
        ignore_bad_values => false
        flush_size => 500
        idle_flush_time => 1
}
</code>```

Upon running the following command

```<code>./bin/logstash -f config/pipeline.conf
</code>```

I get this on the terminal

```<code>Sending Logstash logs to /Users/ar-shreya.eswaraiah/Desktop/logstash-7.6.0/logs which is now configured via log4j2.properties
[2020-02-14T22:42:33,552][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2020-02-14T22:42:33,716][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"7.6.0"}
[2020-02-14T22:42:36,044][INFO ][org.reflections.Reflections] Reflections took 43 ms to scan 1 urls, producing 20 keys and 40 values
[2020-02-14T22:42:37,461][INFO ][logstash.outputs.cassandraoutput][main] Establishing control connection
[2020-02-14T22:42:38,015][INFO ][logstash.outputs.cassandraoutput][main] Refreshing connected host's metadata
[2020-02-14T22:42:38,251][INFO ][logstash.outputs.cassandraoutput][main] Completed refreshing connected host's metadata
[2020-02-14T22:42:38,281][INFO ][logstash.outputs.cassandraoutput][main] Refreshing peers metadata
[2020-02-14T22:42:38,302][INFO ][logstash.outputs.cassandraoutput][main] Completed refreshing peers metadata
[2020-02-14T22:42:38,309][INFO ][logstash.outputs.cassandraoutput][main] Refreshing schema
[2020-02-14T22:42:39,524][INFO ][logstash.outputs.cassandraoutput][main] Schema refreshed
[2020-02-14T22:42:39,528][INFO ][logstash.outputs.cassandraoutput][main] Control connection established
[2020-02-14T22:42:39,614][INFO ][logstash.outputs.cassandraoutput][main] Creating session
[2020-02-14T22:42:39,701][INFO ][logstash.outputs.cassandraoutput][main] Session created
[2020-02-14T22:42:39,915][WARN ][org.logstash.instrument.metrics.gauge.LazyDelegatingGauge][main] A gauge metric of an unknown type (org.jruby.RubyArray) has been create for key: cluster_uuids. This may result in invalid serialization.  It is recommended to log an issue to the responsible developer/development team.
[2020-02-14T22:42:39,922][INFO ][logstash.javapipeline    ][main] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>4, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>500, "pipeline.sources"=>["/Users/ar-shreya.eswaraiah/Desktop/logstash-7.6.0/config/pipeline.conf"], :thread=>"#<Thread:0xbcb14aa run>"}
[2020-02-14T22:42:40,849][INFO ][logstash.javapipeline    ][main] Pipeline started {"pipeline.id"=>"main"}
[2020-02-14T22:42:40,946][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2020-02-14T22:42:40,987][INFO ][org.apache.kafka.clients.consumer.ConsumerConfig][main] ConsumerConfig values:
    allow.auto.create.topics = true
    auto.commit.interval.ms = 5000
    auto.offset.reset = latest
    bootstrap.servers = [localhost:9092]
    check.crcs = true
    client.dns.lookup = default
    client.id = logstash-0
    client.rack =
    connections.max.idle.ms = 540000
    default.api.timeout.ms = 60000
    enable.auto.commit = true
    exclude.internal.topics = true
    fetch.max.bytes = 52428800
    fetch.max.wait.ms = 500
    fetch.min.bytes = 1
    group.id = logstash
    group.instance.id = null
    heartbeat.interval.ms = 3000
    interceptor.classes = []
    internal.leave.group.on.close = true
    isolation.level = read_uncommitted
    key.deserializer = class org.apache.kafka.common.serialization.StringDeserializer
    max.partition.fetch.bytes = 1048576
    max.poll.interval.ms = 300000
    max.poll.records = 500
    metadata.max.age.ms = 300000
    metric.reporters = []
    metrics.num.samples = 2
    metrics.recording.level = INFO
    metrics.sample.window.ms = 30000
    partition.assignment.strategy = [class org.apache.kafka.clients.consumer.RangeAssignor]
    receive.buffer.bytes = 65536
    reconnect.backoff.max.ms = 1000
    reconnect.backoff.ms = 50
    request.timeout.ms = 30000
    retry.backoff.ms = 100
    sasl.client.callback.handler.class = null
    sasl.jaas.config = null
    sasl.kerberos.kinit.cmd = /usr/bin/kinit
    sasl.kerberos.min.time.before.relogin = 60000
    sasl.kerberos.service.name = null
    sasl.kerberos.ticket.renew.jitter = 0.05
    sasl.kerberos.ticket.renew.window.factor = 0.8
    sasl.login.callback.handler.class = null
    sasl.login.class = null
    sasl.login.refresh.buffer.seconds = 300
    sasl.login.refresh.min.period.seconds = 60
    sasl.login.refresh.window.factor = 0.8
    sasl.login.refresh.window.jitter = 0.05
    sasl.mechanism = GSSAPI
    security.protocol = PLAINTEXT
    send.buffer.bytes = 131072
    session.timeout.ms = 10000
    ssl.cipher.suites = null
    ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
    ssl.endpoint.identification.algorithm = https
    ssl.key.password = null
    ssl.keymanager.algorithm = SunX509
    ssl.keystore.location = null
    ssl.keystore.password = null
    ssl.keystore.type = JKS
    ssl.protocol = TLS
    ssl.provider = null
    ssl.secure.random.implementation = null
    ssl.trustmanager.algorithm = PKIX
    ssl.truststore.location = null
    ssl.truststore.password = null
    ssl.truststore.type = JKS
    value.deserializer = class org.apache.kafka.common.serialization.StringDeserializer

[2020-02-14T22:42:41,131][INFO ][org.apache.kafka.common.utils.AppInfoParser][main] Kafka version: 2.3.0
[2020-02-14T22:42:41,133][INFO ][org.apache.kafka.common.utils.AppInfoParser][main] Kafka commitId: fc1aaa116b661c8a
[2020-02-14T22:42:41,134][INFO ][org.apache.kafka.common.utils.AppInfoParser][main] Kafka startTimeMs: 1581700361128
[2020-02-14T22:42:41,151][INFO ][org.apache.kafka.clients.consumer.KafkaConsumer][main] [Consumer clientId=logstash-0, groupId=logstash] Subscribed to topic(s): test
[2020-02-14T22:42:41,423][INFO ][org.apache.kafka.clients.Metadata][main] [Consumer clientId=logstash-0, groupId=logstash] Cluster ID: 4lsF-DNLS7yRsthTUds7IQ
[2020-02-14T22:42:41,545][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
[2020-02-14T22:42:42,054][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] Discovered group coordinator 192.168.0.103:9092 (id: 2147483647 rack: null)
[2020-02-14T22:42:42,061][INFO ][org.apache.kafka.clients.consumer.internals.ConsumerCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] Revoking previously assigned partitions []
[2020-02-14T22:42:42,063][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] (Re-)joining group
[2020-02-14T22:42:42,093][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] (Re-)joining group
[2020-02-14T22:42:42,146][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] Successfully joined group with generation 1
[2020-02-14T22:42:42,155][INFO ][org.apache.kafka.clients.consumer.internals.ConsumerCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] Setting newly assigned partitions: test-0
[2020-02-14T22:42:42,173][INFO ][org.apache.kafka.clients.consumer.internals.ConsumerCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] Found no committed offset for partition test-0
[2020-02-14T22:42:42,193][INFO ][org.apache.kafka.clients.consumer.internals.SubscriptionState][main] [Consumer clientId=logstash-0, groupId=logstash] Resetting offset for partition test-0 to offset 0.
</code>```

There is no progression after this, it's just stuck here, there are no updates in the cassandra table.
Where am I going wrong? Is it a plugin installation issue or configuration issue?

Thank you.

答:
Based on the last three log lines shown with the offset of 0, and auto.offset.reset = latest, then your topic is apparently empty.

You need to produce some data into test topic for Logstash to do anything.

Body:
I'm trying to stream from a kafka topic to a table in cassandra, I have my configuration file at
..../logstash-7.6.0/config, file name is pipeline.conf and it's contents are as follows,

input {
    kafka {
            bootstrap_servers => "localhost:9092"
            topics => ["test"]
    }
}
output{
     cassandra {
        hosts => [ "127.0.0.1"]
        port => 9042
        protocol_version => 4
        consistency => 'any'
        keyspace => "task3"
        table => "%{[@metadata][logfile]}"
        hints => {
            host => "text"
            time => "timestamp"
            response_time => "int"
            status => "int"
            method => "text"
            protocol => "text"
            endpoint => "text"
            uuid => "uuid"
        }
        retry_policy => { "type" => "default" }
        request_timeout => 1
        ignore_bad_values => false
        flush_size => 500
        idle_flush_time => 1
}

Upon running the following command

./bin/logstash -f config/pipeline.conf

I get this on the terminal

Sending Logstash logs to /Users/ar-shreya.eswaraiah/Desktop/logstash-7.6.0/logs which is now configured via log4j2.properties
[2020-02-14T22:42:33,552][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2020-02-14T22:42:33,716][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"7.6.0"}
[2020-02-14T22:42:36,044][INFO ][org.reflections.Reflections] Reflections took 43 ms to scan 1 urls, producing 20 keys and 40 values
[2020-02-14T22:42:37,461][INFO ][logstash.outputs.cassandraoutput][main] Establishing control connection
[2020-02-14T22:42:38,015][INFO ][logstash.outputs.cassandraoutput][main] Refreshing connected host's metadata
[2020-02-14T22:42:38,251][INFO ][logstash.outputs.cassandraoutput][main] Completed refreshing connected host's metadata
[2020-02-14T22:42:38,281][INFO ][logstash.outputs.cassandraoutput][main] Refreshing peers metadata
[2020-02-14T22:42:38,302][INFO ][logstash.outputs.cassandraoutput][main] Completed refreshing peers metadata
[2020-02-14T22:42:38,309][INFO ][logstash.outputs.cassandraoutput][main] Refreshing schema
[2020-02-14T22:42:39,524][INFO ][logstash.outputs.cassandraoutput][main] Schema refreshed
[2020-02-14T22:42:39,528][INFO ][logstash.outputs.cassandraoutput][main] Control connection established
[2020-02-14T22:42:39,614][INFO ][logstash.outputs.cassandraoutput][main] Creating session
[2020-02-14T22:42:39,701][INFO ][logstash.outputs.cassandraoutput][main] Session created
[2020-02-14T22:42:39,915][WARN ][org.logstash.instrument.metrics.gauge.LazyDelegatingGauge][main] A gauge metric of an unknown type (org.jruby.RubyArray) has been create for key: cluster_uuids. This may result in invalid serialization.  It is recommended to log an issue to the responsible developer/development team.
[2020-02-14T22:42:39,922][INFO ][logstash.javapipeline    ][main] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>4, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>500, "pipeline.sources"=>["/Users/ar-shreya.eswaraiah/Desktop/logstash-7.6.0/config/pipeline.conf"], :thread=>"#<Thread:0xbcb14aa run>"}
[2020-02-14T22:42:40,849][INFO ][logstash.javapipeline    ][main] Pipeline started {"pipeline.id"=>"main"}
[2020-02-14T22:42:40,946][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2020-02-14T22:42:40,987][INFO ][org.apache.kafka.clients.consumer.ConsumerConfig][main] ConsumerConfig values:
    allow.auto.create.topics = true
    auto.commit.interval.ms = 5000
    auto.offset.reset = latest
    bootstrap.servers = [localhost:9092]
    check.crcs = true
    client.dns.lookup = default
    client.id = logstash-0
    client.rack =
    connections.max.idle.ms = 540000
    default.api.timeout.ms = 60000
    enable.auto.commit = true
    exclude.internal.topics = true
    fetch.max.bytes = 52428800
    fetch.max.wait.ms = 500
    fetch.min.bytes = 1
    group.id = logstash
    group.instance.id = null
    heartbeat.interval.ms = 3000
    interceptor.classes = []
    internal.leave.group.on.close = true
    isolation.level = read_uncommitted
    key.deserializer = class org.apache.kafka.common.serialization.StringDeserializer
    max.partition.fetch.bytes = 1048576
    max.poll.interval.ms = 300000
    max.poll.records = 500
    metadata.max.age.ms = 300000
    metric.reporters = []
    metrics.num.samples = 2
    metrics.recording.level = INFO
    metrics.sample.window.ms = 30000
    partition.assignment.strategy = [class org.apache.kafka.clients.consumer.RangeAssignor]
    receive.buffer.bytes = 65536
    reconnect.backoff.max.ms = 1000
    reconnect.backoff.ms = 50
    request.timeout.ms = 30000
    retry.backoff.ms = 100
    sasl.client.callback.handler.class = null
    sasl.jaas.config = null
    sasl.kerberos.kinit.cmd = /usr/bin/kinit
    sasl.kerberos.min.time.before.relogin = 60000
    sasl.kerberos.service.name = null
    sasl.kerberos.ticket.renew.jitter = 0.05
    sasl.kerberos.ticket.renew.window.factor = 0.8
    sasl.login.callback.handler.class = null
    sasl.login.class = null
    sasl.login.refresh.buffer.seconds = 300
    sasl.login.refresh.min.period.seconds = 60
    sasl.login.refresh.window.factor = 0.8
    sasl.login.refresh.window.jitter = 0.05
    sasl.mechanism = GSSAPI
    security.protocol = PLAINTEXT
    send.buffer.bytes = 131072
    session.timeout.ms = 10000
    ssl.cipher.suites = null
    ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
    ssl.endpoint.identification.algorithm = https
    ssl.key.password = null
    ssl.keymanager.algorithm = SunX509
    ssl.keystore.location = null
    ssl.keystore.password = null
    ssl.keystore.type = JKS
    ssl.protocol = TLS
    ssl.provider = null
    ssl.secure.random.implementation = null
    ssl.trustmanager.algorithm = PKIX
    ssl.truststore.location = null
    ssl.truststore.password = null
    ssl.truststore.type = JKS
    value.deserializer = class org.apache.kafka.common.serialization.StringDeserializer

[2020-02-14T22:42:41,131][INFO ][org.apache.kafka.common.utils.AppInfoParser][main] Kafka version: 2.3.0
[2020-02-14T22:42:41,133][INFO ][org.apache.kafka.common.utils.AppInfoParser][main] Kafka commitId: fc1aaa116b661c8a
[2020-02-14T22:42:41,134][INFO ][org.apache.kafka.common.utils.AppInfoParser][main] Kafka startTimeMs: 1581700361128
[2020-02-14T22:42:41,151][INFO ][org.apache.kafka.clients.consumer.KafkaConsumer][main] [Consumer clientId=logstash-0, groupId=logstash] Subscribed to topic(s): test
[2020-02-14T22:42:41,423][INFO ][org.apache.kafka.clients.Metadata][main] [Consumer clientId=logstash-0, groupId=logstash] Cluster ID: 4lsF-DNLS7yRsthTUds7IQ
[2020-02-14T22:42:41,545][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
[2020-02-14T22:42:42,054][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] Discovered group coordinator 192.168.0.103:9092 (id: 2147483647 rack: null)
[2020-02-14T22:42:42,061][INFO ][org.apache.kafka.clients.consumer.internals.ConsumerCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] Revoking previously assigned partitions []
[2020-02-14T22:42:42,063][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] (Re-)joining group
[2020-02-14T22:42:42,093][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] (Re-)joining group
[2020-02-14T22:42:42,146][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] Successfully joined group with generation 1
[2020-02-14T22:42:42,155][INFO ][org.apache.kafka.clients.consumer.internals.ConsumerCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] Setting newly assigned partitions: test-0
[2020-02-14T22:42:42,173][INFO ][org.apache.kafka.clients.consumer.internals.ConsumerCoordinator][main] [Consumer clientId=logstash-0, groupId=logstash] Found no committed offset for partition test-0
[2020-02-14T22:42:42,193][INFO ][org.apache.kafka.clients.consumer.internals.SubscriptionState][main] [Consumer clientId=logstash-0, groupId=logstash] Resetting offset for partition test-0 to offset 0.

There is no progression after this, it's just stuck here, there are no updates in the cassandra table.
Where am I going wrong? Is it a plugin installation issue or configuration issue?

Thank you.


问:
How to parse a string as a float in a LINQ query?
I'm writing a molar mass calculator which will display information about a chemical formula passed in by the user, such as the atomic number of the elements, their symbols, and their boiling and melting points, among other things.

The information is displayed in a DataGridView which has a DataTable as the DataSource. I've also built a class called Element which, perhaps unsurprisingly, represents an Element. It just holds a bunch of string properties to represent element information, such as atomic number, boiling point, etc.

The CSV file from which I've pulled the element information has some empty entries because not everything is known about every element. I've replaced the entries with the word "unknown," which explains why every property in the Element class is a string.

Currently, for the columns that require non-string sorting, I'm using LINQ to order the collection that builds the DataTable. For example:

```<code>        private void SortByAtomicMass()
        {
            var elementsByAtomicMass = (from el in Elements
                                        orderby float.Parse(el.Mass)
                                        select new
                                        {
                                            el.Name,
                                            el.AtomicNumber,
                                            el.Symbol,
                                            el.Mass,
                                            el.CPKHexColor,
                                            el.Electronegativity,
                                            el.State,
                                            el.BondingType,
                                            el.MeltingPoint,
                                            el.BoilingPoint,
                                            el.GroupBlock,
                                            el.YearDiscovered
                                        }).ToList<dynamic>();
            GenerateNewDataTable(elementsByAtomicMass);
        }
</code>```

This works as intended - it sorts the atomic mass column as you would expect. I tried the same sort of approach for the melting point column sort:

```<code>        private void SortByMeltingPoint()
        {
            var elementsByMeltingPoint = (from el in Elements
                                          orderby float.TryParse(el.MeltingPoint, out _)
                                          select new
                                          {
                                              el.Name,
                                              el.AtomicNumber,
                                              el.Symbol,
                                              el.Mass,
                                              el.CPKHexColor,
                                              el.Electronegativity,
                                              el.State,
                                              el.BondingType,
                                              el.MeltingPoint,
                                              el.BoilingPoint,
                                              el.GroupBlock,
                                              el.YearDiscovered
                                          }).ToList<dynamic>();
            GenerateNewDataTable(elementsByMeltingPoint);
        }
</code>```

This fails, and orders in a seemingly random way. How can I fix this, while staying in the realm of a LINQ approach? I'm trying to improve my skills in that area.

答:
You are ordering by whether it is a float, not by the value.

Maybe you want something like this:

```<code>orderby float.TryParse(el.MeltingPoint, out var value) ? value : float.MinValue
</code>```

If it's not a float, put it at the bottom.

TryParse

Converts the string representation of a number to its single-precision
  floating-point number equivalent. A return value indicates whether the
  conversion succeeded or failed.

Body:
I'm writing a molar mass calculator which will display information about a chemical formula passed in by the user, such as the atomic number of the elements, their symbols, and their boiling and melting points, among other things.

The information is displayed in a DataGridView which has a DataTable as the DataSource. I've also built a class called Element which, perhaps unsurprisingly, represents an Element. It just holds a bunch of string properties to represent element information, such as atomic number, boiling point, etc.

The CSV file from which I've pulled the element information has some empty entries because not everything is known about every element. I've replaced the entries with the word "unknown," which explains why every property in the Element class is a string.

Currently, for the columns that require non-string sorting, I'm using LINQ to order the collection that builds the DataTable. For example:

        private void SortByAtomicMass()
        {
            var elementsByAtomicMass = (from el in Elements
                                        orderby float.Parse(el.Mass)
                                        select new
                                        {
                                            el.Name,
                                            el.AtomicNumber,
                                            el.Symbol,
                                            el.Mass,
                                            el.CPKHexColor,
                                            el.Electronegativity,
                                            el.State,
                                            el.BondingType,
                                            el.MeltingPoint,
                                            el.BoilingPoint,
                                            el.GroupBlock,
                                            el.YearDiscovered
                                        }).ToList<dynamic>();
            GenerateNewDataTable(elementsByAtomicMass);
        }

This works as intended - it sorts the atomic mass column as you would expect. I tried the same sort of approach for the melting point column sort:

        private void SortByMeltingPoint()
        {
            var elementsByMeltingPoint = (from el in Elements
                                          orderby float.TryParse(el.MeltingPoint, out _)
                                          select new
                                          {
                                              el.Name,
                                              el.AtomicNumber,
                                              el.Symbol,
                                              el.Mass,
                                              el.CPKHexColor,
                                              el.Electronegativity,
                                              el.State,
                                              el.BondingType,
                                              el.MeltingPoint,
                                              el.BoilingPoint,
                                              el.GroupBlock,
                                              el.YearDiscovered
                                          }).ToList<dynamic>();
            GenerateNewDataTable(elementsByMeltingPoint);
        }

This fails, and orders in a seemingly random way. How can I fix this, while staying in the realm of a LINQ approach? I'm trying to improve my skills in that area.

Body:
You are ordering by whether it is a float, not by the value.

Maybe you want something like this:

orderby float.TryParse(el.MeltingPoint, out var value) ? value : float.MinValue

If it's not a float, put it at the bottom.

TryParse

Converts the string representation of a number to its single-precision
  floating-point number equivalent. A return value indicates whether the
  conversion succeeded or failed.


问:
Which one of these headers comes from MSVCR100.DLL?
I'm working on a cpp app, works fine on the virtual machine im developing but in my laptop (XP without c++ redistributable package) it shows an error saying the app needs MSVCR100.DLL and it's not in the computer. I am not referencing the dll directly anywhere in the app so I guess it could be because of the headers included. I don't want to use this dll include, I'd prefer if the app works without it. These are the headers included:

```<code>#include <winsock2.h>
#include <windows.h>
#include <process.h>
#include <shellapi.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
</code>```

I tried commenting a few, but for commenting other I have to change too much code just for testing.

Which one of those headers comes from MSVCR100.DLL?

The project setting "Runtime library" is set to Multi-threaded (/MT).

答:
Everything in the C library depends on it whenever you compile your program with Visual Studio 2010. So either you link statically with the C runtime, or you deploy the DLL with your application.

If you want to know, stdlib.h, stdio.h, cmath.h depend on it, and also probably a lot of headers depending on the C runtime are indirectly included in all your other headers. So I'd say all of your headers depend on MSVCR100.DLL.

Another solution is to have a Visual Studio 2008 + SP1 installed alongside 2010 (VC++ express 2008 works fine) and select "Toolset v90" in the project properties.

ContentLicense: CC BY-SA 3.0

Body:
I'm working on a cpp app, works fine on the virtual machine im developing but in my laptop (XP without c++ redistributable package) it shows an error saying the app needs MSVCR100.DLL and it's not in the computer. I am not referencing the dll directly anywhere in the app so I guess it could be because of the headers included. I don't want to use this dll include, I'd prefer if the app works without it. These are the headers included:

#include <winsock2.h>
#include <windows.h>
#include <process.h>
#include <shellapi.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

I tried commenting a few, but for commenting other I have to change too much code just for testing.

Which one of those headers comes from MSVCR100.DLL?

The project setting "Runtime library" is set to Multi-threaded (/MT).


问:
Docker Node App Postgres Error "Connection terminated unexpectedly"
I'm trying to Dockerize a Node API and getting error only in the Dockerized app. Outside of Docker, node server.js works fine without any issues. Using docker-compose up, I get the following error after 10 mins with or without API calls:

```<code>api    | [nodemon] starting `node server.js`
api    | listening on port 3000
api    | API is ready
api    | Error: Connection terminated unexpectedly
api    |     at Connection.<anonymous> (/api/node_modules/pg/lib/client.js:255:9)
api    |     at Object.onceWrapper (events.js:427:28)
api    |     at Connection.emit (events.js:321:20)
api    |     at Connection.EventEmitter.emit (domain.js:485:12)
api    |     at Socket.<anonymous> (/api/node_modules/pg/lib/connection.js:139:10)
api    |     at Socket.emit (events.js:333:22)
api    |     at Socket.EventEmitter.emit (domain.js:485:12)
api    |     at endReadableNT (_stream_readable.js:1201:12)
api    |     at processTicksAndRejections (internal/process/task_queues.js:84:21)
api    | [nodemon] app crashed - waiting for file changes before starting...
</code>```

Dockerfile

```<code>FROM node
WORKDIR /api
ADD . /api
RUN npm install
RUN npm install -g nodemon
EXPOSE 3000
</code>```

docker-compose.yml

```<code>version: "3.7"
services:
  api:
    container_name: api
    build: .
    volumes:
      - .:/api
    ports:
      - "3000:3000"
    restart: unless-stopped
    working_dir: /api
    command: nodemon server.js
</code>```

server.js

```<code>...
    try {
      let pgDbConfig;
      pgDbConfig = {
        host: '<host>',
        user: '<dbuser>',
        password: '<dbpass>',
        port: 5432,
        database: '<dbname>',
        max: 20,
        idleTimeoutMillis: 30000,
        connectionTimeoutMillis: 2000
      };

      pgPool = new Pool(pgDbConfig);

      // the pool will emit an error on behalf of any idle clients it contains if a backend error or network partition happens
      pgPool.on('error', (err, client) => {
        console.error('Unexpected error on idle pg client', err, client);
      });

      // trying to use error listener after the connect
      pgPool.on('connect', () => {
        pgPool.on('error', err => console.log(err));
      });

      console.log('API is ready');

    } catch(exception) {
      console.error('API is not ready');
      process.exit(1);
    }
...

</code>```

答:
I change the way I explain answer:
You basically need Postgres service, in your image you don't have it, you are basically using node image without running Postgres database.

Try this docker-compose.yml

```<code>version: "3.7"
services:
  api:
    container_name: api
    build: .
    depends_on:
      - postgres
    volumes:
      - .:/api
    ports:
      - "3000:3000"
    restart: unless-stopped
    working_dir: /api
    command: nodemon server.js
  postgres:
    image: postgres:10.4
    ports:
      - "35432:5432"
</code>```

Edit 1

Host machine

```<code>version: "3.7"
services:
  api:
    container_name: api
    build: .
    volumes:
      - .:/api
    ports:
      - "3000:3000"
      - "5432:5432"
    restart: unless-stopped
    working_dir: /api
    command: nodemon server.js
</code>```

Body:
I'm trying to Dockerize a Node API and getting error only in the Dockerized app. Outside of Docker, node server.js works fine without any issues. Using docker-compose up, I get the following error after 10 mins with or without API calls:

api    | [nodemon] starting `node server.js`
api    | listening on port 3000
api    | API is ready
api    | Error: Connection terminated unexpectedly
api    |     at Connection.<anonymous> (/api/node_modules/pg/lib/client.js:255:9)
api    |     at Object.onceWrapper (events.js:427:28)
api    |     at Connection.emit (events.js:321:20)
api    |     at Connection.EventEmitter.emit (domain.js:485:12)
api    |     at Socket.<anonymous> (/api/node_modules/pg/lib/connection.js:139:10)
api    |     at Socket.emit (events.js:333:22)
api    |     at Socket.EventEmitter.emit (domain.js:485:12)
api    |     at endReadableNT (_stream_readable.js:1201:12)
api    |     at processTicksAndRejections (internal/process/task_queues.js:84:21)
api    | [nodemon] app crashed - waiting for file changes before starting...

Dockerfile

FROM node
WORKDIR /api
ADD . /api
RUN npm install
RUN npm install -g nodemon
EXPOSE 3000

docker-compose.yml

version: "3.7"
services:
  api:
    container_name: api
    build: .
    volumes:
      - .:/api
    ports:
      - "3000:3000"
    restart: unless-stopped
    working_dir: /api
    command: nodemon server.js

server.js

...
    try {
      let pgDbConfig;
      pgDbConfig = {
        host: '<host>',
        user: '<dbuser>',
        password: '<dbpass>',
        port: 5432,
        database: '<dbname>',
        max: 20,
        idleTimeoutMillis: 30000,
        connectionTimeoutMillis: 2000
      };

      pgPool = new Pool(pgDbConfig);

      // the pool will emit an error on behalf of any idle clients it contains if a backend error or network partition happens
      pgPool.on('error', (err, client) => {
        console.error('Unexpected error on idle pg client', err, client);
      });

      // trying to use error listener after the connect
      pgPool.on('connect', () => {
        pgPool.on('error', err => console.log(err));
      });

      console.log('API is ready');

    } catch(exception) {
      console.error('API is not ready');
      process.exit(1);
    }
...

Body:
I change the way I explain answer:
You basically need Postgres service, in your image you don't have it, you are basically using node image without running Postgres database.

Try this docker-compose.yml

version: "3.7"
services:
  api:
    container_name: api
    build: .
    depends_on:
      - postgres
    volumes:
      - .:/api
    ports:
      - "3000:3000"
    restart: unless-stopped
    working_dir: /api
    command: nodemon server.js
  postgres:
    image: postgres:10.4
    ports:
      - "35432:5432"

Edit 1

Host machine

version: "3.7"
services:
  api:
    container_name: api
    build: .
    volumes:
      - .:/api
    ports:
      - "3000:3000"
      - "5432:5432"
    restart: unless-stopped
    working_dir: /api
    command: nodemon server.js


问:
Large number of RemoteServiceExceptions in Google's cast MediaNotificationService
In the last ~24 hours, we've seen a few thousand crashes within Google's MediaNotificationService:

```<code>Fatal Exception: android.app.RemoteServiceException
    Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{f9a4deb u0 <our package name>/com.google.android.gms.cast.framework.media.MediaNotificationService}
    android.app.ActivityThread$H.handleMessage (ActivityThread.java:1855)
    android.os.Handler.dispatchMessage (Handler.java:106)
    android.os.Looper.loop (Looper.java:214)
    android.app.ActivityThread.main (ActivityThread.java:6986)
    java.lang.reflect.Method.invoke (Method.java)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
    com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1445)
</code>```

I've experienced similar issues when creating my own foreground service, but as this is within the cast library we have no control over it.

The Chromecast receiver is handled by a third party. We are using:

```<code>api "com.google.android.gms:play-services-cast:17.0.0"
api "com.google.android.gms:play-services-cast-framework:17.0.0"
</code>```

Potential clues:

It is happening on OnePlus, Huawei, Samsung, Google, seemingly every manufacturer (and OS level) in numbers correlating to their market share.

The crashes are occurring on different lines for different devices (e.g. the above is the Galaxy S9, the S8 crashes on line 1872 instead), so are not grouped together on Crashlytics. This suggests to me it's an OS / Google Play Services level issue.

The crashes happen across all active versions of the app, starting at the same time.

The crashes have been occurring in low numbers for months, but suddenly spiked over the weekend and show no sign of slowing down.

UPDATE: Finally managed to reproduce this. The crash happens when casting content for a long period of time with the screen locked, and then disconnecting from the device. Maybe one step closer to a solution...

答:
It looks like a known issue:

Issue occured only on HUAWEI devices with Android 9 : P20 pro, P30 pro, P20 lite, P30, P20, Honor View 10, Mate 20 pro

Cast SDK version : Android Sender 16.2.0
  (I checked release notes of Android Sender 17.1.0 but no bug fixes)

Here is the crash log from fabric :

```<code>Fatal Exception: android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{3ac0035 u0 com.google.android.gms.cast.framework.media.MediaNotificationService}
       at android.app.ActivityThread$H.handleMessage + 2126(ActivityThread.java:2126)
       at android.os.Handler.dispatchMessage + 112(Handler.java:112)
       at android.os.Looper.loop + 216(Looper.java:216)
       at android.app.ActivityThread.main + 7625(ActivityThread.java:7625)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 524(RuntimeInit.java:524)
       at com.android.internal.os.ZygoteInit.main + 987(ZygoteInit.java:987)
</code>```

that a Google engineer says is fixed:

We have a fix for this and that should be released by the next Android Cast client library release.

but they don't know when the fix will be released:

So far we don't have a solid date when the next release will be scheduled. We will update it here or else please do check here https://developers.google.com/cast/docs/release-notes

The release notes don't mention a fix for this.

I'll update this answer if I find anything further.

Update

This is fixed. See Anjaneesh's answer.

Update

There are some issues with 18.0.0. See rednaz's answer.
Also, commenters on the issue are still experiencing crashes with Samsung and Huawei platforms, but at greatly decreased rates. I filed a new issue about this.

Body:
In the last ~24 hours, we've seen a few thousand crashes within Google's MediaNotificationService:

Fatal Exception: android.app.RemoteServiceException
    Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{f9a4deb u0 <our package name>/com.google.android.gms.cast.framework.media.MediaNotificationService}
    android.app.ActivityThread$H.handleMessage (ActivityThread.java:1855)
    android.os.Handler.dispatchMessage (Handler.java:106)
    android.os.Looper.loop (Looper.java:214)
    android.app.ActivityThread.main (ActivityThread.java:6986)
    java.lang.reflect.Method.invoke (Method.java)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
    com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1445)

I've experienced similar issues when creating my own foreground service, but as this is within the cast library we have no control over it.

The Chromecast receiver is handled by a third party. We are using:

api "com.google.android.gms:play-services-cast:17.0.0"
api "com.google.android.gms:play-services-cast-framework:17.0.0"

Potential clues:

It is happening on OnePlus, Huawei, Samsung, Google, seemingly every manufacturer (and OS level) in numbers correlating to their market share.

The crashes are occurring on different lines for different devices (e.g. the above is the Galaxy S9, the S8 crashes on line 1872 instead), so are not grouped together on Crashlytics. This suggests to me it's an OS / Google Play Services level issue.

The crashes happen across all active versions of the app, starting at the same time.

The crashes have been occurring in low numbers for months, but suddenly spiked over the weekend and show no sign of slowing down.

UPDATE: Finally managed to reproduce this. The crash happens when casting content for a long period of time with the screen locked, and then disconnecting from the device. Maybe one step closer to a solution...

Body:
It looks like a known issue:

Issue occured only on HUAWEI devices with Android 9 : P20 pro, P30 pro, P20 lite, P30, P20, Honor View 10, Mate 20 pro

Cast SDK version : Android Sender 16.2.0
  (I checked release notes of Android Sender 17.1.0 but no bug fixes)

Here is the crash log from fabric :

Fatal Exception: android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{3ac0035 u0 com.google.android.gms.cast.framework.media.MediaNotificationService}
       at android.app.ActivityThread$H.handleMessage + 2126(ActivityThread.java:2126)
       at android.os.Handler.dispatchMessage + 112(Handler.java:112)
       at android.os.Looper.loop + 216(Looper.java:216)
       at android.app.ActivityThread.main + 7625(ActivityThread.java:7625)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 524(RuntimeInit.java:524)
       at com.android.internal.os.ZygoteInit.main + 987(ZygoteInit.java:987)

that a Google engineer says is fixed:

We have a fix for this and that should be released by the next Android Cast client library release.

but they don't know when the fix will be released:

So far we don't have a solid date when the next release will be scheduled. We will update it here or else please do check here https://developers.google.com/cast/docs/release-notes

The release notes don't mention a fix for this.

I'll update this answer if I find anything further.

Update

This is fixed. See Anjaneesh's answer.

Update

There are some issues with 18.0.0. See rednaz's answer.
Also, commenters on the issue are still experiencing crashes with Samsung and Huawei platforms, but at greatly decreased rates. I filed a new issue about this.


问:
Why is my dynamically-generated oval becoming a square?
Thought i had everything looking ok.

https://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html

function doit() {
 drawOval(100, 150, 90, 90);
 myOval = document.getElementById("newdiv");
}

function drawOval(left, top, width, height) {
 if (document.createElement) {
   newdiv=document.createElement("div");
   newdiv.style.position="absolute";
   newdiv.style.left = left+"px";
   newdiv.style.top  = top+"px";
   newdiv.style.width = width+"px";
   newdiv.style.height = height+"px";
   newdiv.style.backgroundColor = 'red';
   newdiv.style.visibility = 'visible';
   newdiv.id = 'newdiv';
   document.body.appendChild(newdiv);
   }
 }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type="button" onClick="doit()" value="Do it"></code>```

Any ideas?

答:
Just apply border-radius at 50%, so all borders will be the same.

function doit() {
 drawOval(100, 150, 90, 90);
 myOval = document.getElementById("newdiv");
}

function drawOval(left, top, width, height) {
 if (document.createElement) {
   newdiv=document.createElement("div");
   newdiv.style.position="absolute";
   newdiv.style.left = left+"px";
   newdiv.style.top  = top+"px";
   newdiv.style.width = width+"px";
   newdiv.style.height = height+"px";
   newdiv.style.backgroundColor = 'red';
   newdiv.style.visibility = 'visible';
   // This will do the trick
   newdiv.style.borderRadius = '50%';
   newdiv.id = 'newdiv';
   document.body.appendChild(newdiv);
   }
 }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type="button" onClick="doit()" value="Do it"></code>```

Body:
Thought i had everything looking ok.

https://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html

function doit() {
 drawOval(100, 150, 90, 90);
 myOval = document.getElementById("newdiv");
}

function drawOval(left, top, width, height) {
 if (document.createElement) {
   newdiv=document.createElement("div");
   newdiv.style.position="absolute";
   newdiv.style.left = left+"px";
   newdiv.style.top  = top+"px";
   newdiv.style.width = width+"px";
   newdiv.style.height = height+"px";
   newdiv.style.backgroundColor = 'red';
   newdiv.style.visibility = 'visible';
   newdiv.id = 'newdiv';
   document.body.appendChild(newdiv);
   }
 }

<input type="button" onClick="doit()" value="Do it">

Any ideas?

Body:
Just apply border-radius at 50%, so all borders will be the same.

function doit() {
 drawOval(100, 150, 90, 90);
 myOval = document.getElementById("newdiv");
}

function drawOval(left, top, width, height) {
 if (document.createElement) {
   newdiv=document.createElement("div");
   newdiv.style.position="absolute";
   newdiv.style.left = left+"px";
   newdiv.style.top  = top+"px";
   newdiv.style.width = width+"px";
   newdiv.style.height = height+"px";
   newdiv.style.backgroundColor = 'red';
   newdiv.style.visibility = 'visible';
   // This will do the trick
   newdiv.style.borderRadius = '50%';
   newdiv.id = 'newdiv';
   document.body.appendChild(newdiv);
   }
 }

<input type="button" onClick="doit()" value="Do it">


答:
I don't see anything in your styles that would result in an oval. You need border-radius, probably different for opposing corners:

function doit() {
 drawOval(10, 65, 90, 90);
 myOval = document.getElementById("newdiv");
}

function drawOval(left, top, width, height) {
 if (document.createElement) {
   newdiv=document.createElement("div");
   newdiv.style.position="absolute";
   newdiv.style.left = left+"px";
   newdiv.style.top  = top+"px";
   newdiv.style.width = width+"px";
   newdiv.style.height = height+"px";
   newdiv.style.backgroundColor = 'red';
   newdiv.style.visibility = 'visible';
   newdiv.style.borderRadius = '50px 80px';
   newdiv.id = 'newdiv';
   document.body.appendChild(newdiv);
   }
 }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type="button" onClick="doit()" value="Do it"></code>```

Title: Why is my dynamically-generated oval becoming a square?

Body:
I don't see anything in your styles that would result in an oval. You need border-radius, probably different for opposing corners:

function doit() {
 drawOval(10, 65, 90, 90);
 myOval = document.getElementById("newdiv");
}

function drawOval(left, top, width, height) {
 if (document.createElement) {
   newdiv=document.createElement("div");
   newdiv.style.position="absolute";
   newdiv.style.left = left+"px";
   newdiv.style.top  = top+"px";
   newdiv.style.width = width+"px";
   newdiv.style.height = height+"px";
   newdiv.style.backgroundColor = 'red';
   newdiv.style.visibility = 'visible';
   newdiv.style.borderRadius = '50px 80px';
   newdiv.id = 'newdiv';
   document.body.appendChild(newdiv);
   }
 }

<input type="button" onClick="doit()" value="Do it">


问:
Azure k8s load balancer DNS name
I have an Azure Kubernetes Service cluster, running version 1.15.7. This cluster recently replaced an older cluster version (1.12.something). In the past, once the various service pods were up and running, we would create a public IP resource in Azure portal and assign it a name, then create a Service resource like this:

```<code>apiVersion: v1
kind: Service
metadata:
  name: myservice-frontend
  labels:
    app: myservice
spec:
  ports:
  - port: 80
    name: myservice-frontend
    targetPort: 80
  - port: 443
    name: myservice-frontend-ssl
    targetPort: 443
  selector:
    app: myservice-frontend
  type: LoadBalancer
  loadBalancerIP: 1.2.3.4

</code>```

Finally, we'd add the public IP to a Traffic Manager instance.

Since upgrading to 1.15, this doesn't seem to work anymore. We can go through all the above steps, but as soon as the Service/Load Balancer is created, the public IP loses its DNS name, which causes it to be evicted from Traffic Manager. We can reset the name, but within 36-48 hours it gets lost again. My suspicion is that AKS is trying to apply a name to the associated IP address, but since I haven't defined one above, it just sets it to null.

How can I tell AKS what name to assign to a public IP? Better yet, can I skip the static public IP and let AKS provision a dynamic address and simply add the DNS name to Traffic Manager?

答:
This is indeed a bug in AKS 1.15.7

Azure - PIP dns label will be default deleted

The upshot is, this is part of a new feature in 1.15 that allows the DNS label for a LoadBalancer IP to be set in the Service configuration. So, the definition above can become:

```<code>apiVersion: v1
kind: Service
metadata:
  name: myservice-frontend
  labels:
    app: myservice
  annotations:
    service.beta.kubernetes.io/azure-dns-label-name: myservice-frontend
spec:
  ports:
  - port: 80
    name: myservice-frontend
    targetPort: 80
  - port: 443
    name: myservice-frontend-ssl
    targetPort: 443
  selector:
    app: myservice-frontend
  type: LoadBalancer
</code>```

And the service will be automatically assigned a new static IP with the annotated DNS name.

Title: Azure k8s load balancer DNS name

Body:
I have an Azure Kubernetes Service cluster, running version 1.15.7. This cluster recently replaced an older cluster version (1.12.something). In the past, once the various service pods were up and running, we would create a public IP resource in Azure portal and assign it a name, then create a Service resource like this:

apiVersion: v1
kind: Service
metadata:
  name: myservice-frontend
  labels:
    app: myservice
spec:
  ports:
  - port: 80
    name: myservice-frontend
    targetPort: 80
  - port: 443
    name: myservice-frontend-ssl
    targetPort: 443
  selector:
    app: myservice-frontend
  type: LoadBalancer
  loadBalancerIP: 1.2.3.4

Finally, we'd add the public IP to a Traffic Manager instance.

Since upgrading to 1.15, this doesn't seem to work anymore. We can go through all the above steps, but as soon as the Service/Load Balancer is created, the public IP loses its DNS name, which causes it to be evicted from Traffic Manager. We can reset the name, but within 36-48 hours it gets lost again. My suspicion is that AKS is trying to apply a name to the associated IP address, but since I haven't defined one above, it just sets it to null.

How can I tell AKS what name to assign to a public IP? Better yet, can I skip the static public IP and let AKS provision a dynamic address and simply add the DNS name to Traffic Manager?

Body:
This is indeed a bug in AKS 1.15.7

Azure - PIP dns label will be default deleted

The upshot is, this is part of a new feature in 1.15 that allows the DNS label for a LoadBalancer IP to be set in the Service configuration. So, the definition above can become:

apiVersion: v1
kind: Service
metadata:
  name: myservice-frontend
  labels:
    app: myservice
  annotations:
    service.beta.kubernetes.io/azure-dns-label-name: myservice-frontend
spec:
  ports:
  - port: 80
    name: myservice-frontend
    targetPort: 80
  - port: 443
    name: myservice-frontend-ssl
    targetPort: 443
  selector:
    app: myservice-frontend
  type: LoadBalancer

And the service will be automatically assigned a new static IP with the annotated DNS name.


问:
How to get unsampled data from Google Analytics API in a specific day
I am building a package that uses the Google Analytics API for Python.

But, in severous cases when I have multiple dimensions the extraction by day is sampled.

I know that if I use sampling_level = LARGE will use a sample more accurate.

But, somebody knows if has a way to reduce a request that you can extract one day without sampling?

Grateful

答:
This is probably not the answer you want to hear but, one way of getting unsampled data from Google analytics is to use unsampled reports. However this requires that you sign up for Google Marketing Platform. With these you can create an unsampled report request using the API or the UI.

There is also a way to export the data to Big Query. But you lose the analysis that Google provides and will have to do that yourself. This too requires that you sign up for Google Marketing Platform.


问:
Weird CPU usage: 100% utilization, but temperature abnormally low
I have encountered a weird behavior with my algorithm/cpu, I was wondering what could be causing this.

CPU that I am using: AMD 2990WX 32c/64t, OS: Ubuntu 18.04LTS with 4.15.0-64-generic kernel.

The algorithm (Julia 1.0.3):

```<code>@sync @distributed for var in range(0.1,step=0.1,stop=10.0)
                       res=do_heavy_stuff(var) #solves differential equation,
                                               #basically, multiplying 200x200 matrices many times
                       save(filename,"RES",res)
end
</code>```

Function do_heavy_stuff(var) takes ~3 hours to solve on a single CPU core.
When I launch it in parallel with 10 processes (julia -p 10 my_code.jl)it takes ~4 hours for each parallel loop, meaning every 4 hours I get 10 files saved. The slowdown is expected, as cpu frequency goes down from 4.1Ghz to 3.4Ghz.

If I launch 3 separate instances with 10 processes each, so a total cpu utilization is 30 cores, it still takes ~4 hours for one loop cycle, meaning I get 30 runs completed and saved every 4 hours.

However, if I run 2 instances (one has nice value of 0, another nice value of +10) with 30 processes each at once julia -p 30 my_code.jl, I see (using htop) that CPU utilization is 60(+) threads, but the algorithm becomes extremely slow (after 20 hours still zero files saved). Furthermore, I see that CPU temperature is abnormally low (~45C instead of expected 65C).

From this information I can guess, that using (almost) all threads of my cpu makes it do something useless that is eating up CPU cycles, but no floating point operations are being done. I see no I/O to SSD, I utilize only half of RAM.

I launched mpstat mpstat -A: https://pastebin.com/c19nycsT and I can see that all of my cores are just chilling in idle state, that explains low temperature, however, I still don`t understand what exactly is the bottleneck? How do I troubleshoot from here? Is there any way too see (without touching hardware) whether the problem is RAM bandwidth or something else?

EDIT: It came to my attention, that I was using mpstat wrong. Apparently mpstat -A gives cpu stats since launch of the computer, while what I was needed was short time integrated results that can be obtained with mpstat -P ALL 2. Unfortunately, I only learned this after I killed my code in question, so no real data from mpstat. However, I am still interested, how would one troubleshoot such situation, where cores seems to be doing something, but result is not showing? How do I find the bottleneck?

答:
Since you are using multiprocessing there are 2 most likely reasons for the observer behavior:

long delays on I/O. When you are processing lots of disk data or reading data from the network your processes are naturally staled. In this case CPU utilization can be low combined with long execution times.

high variance of execution time for do_heavy_stuff. This variance could arise from unstable I/O or different model parameters resulting in different execution times. Why it is a problem requires understanding how @distributed is sharing the workload among worker processes. Namely, each worker gets an equal of the for loop. For an example if you have 4 workers the first one gets var in range 0.1:0.1:2.5 the second one 2.6:0.1:5.0 and so on. Now if some of the var values result in heavy tasks the first worker might get 5h of work and other workers 1h of work. This means that @sync completes after 5 hours with only one CPU actually working all time.

Looking at your post I would strongly bet on the second reason.

Body:
I have encountered a weird behavior with my algorithm/cpu, I was wondering what could be causing this.

CPU that I am using: AMD 2990WX 32c/64t, OS: Ubuntu 18.04LTS with 4.15.0-64-generic kernel.

The algorithm (Julia 1.0.3):

@sync @distributed for var in range(0.1,step=0.1,stop=10.0)
                       res=do_heavy_stuff(var) #solves differential equation,
                                               #basically, multiplying 200x200 matrices many times
                       save(filename,"RES",res)
end

Function do_heavy_stuff(var) takes ~3 hours to solve on a single CPU core.
When I launch it in parallel with 10 processes (julia -p 10 my_code.jl)it takes ~4 hours for each parallel loop, meaning every 4 hours I get 10 files saved. The slowdown is expected, as cpu frequency goes down from 4.1Ghz to 3.4Ghz.

If I launch 3 separate instances with 10 processes each, so a total cpu utilization is 30 cores, it still takes ~4 hours for one loop cycle, meaning I get 30 runs completed and saved every 4 hours.

However, if I run 2 instances (one has nice value of 0, another nice value of +10) with 30 processes each at once julia -p 30 my_code.jl, I see (using htop) that CPU utilization is 60(+) threads, but the algorithm becomes extremely slow (after 20 hours still zero files saved). Furthermore, I see that CPU temperature is abnormally low (~45C instead of expected 65C).

From this information I can guess, that using (almost) all threads of my cpu makes it do something useless that is eating up CPU cycles, but no floating point operations are being done. I see no I/O to SSD, I utilize only half of RAM.

I launched mpstat mpstat -A: https://pastebin.com/c19nycsT and I can see that all of my cores are just chilling in idle state, that explains low temperature, however, I still don`t understand what exactly is the bottleneck? How do I troubleshoot from here? Is there any way too see (without touching hardware) whether the problem is RAM bandwidth or something else?

EDIT: It came to my attention, that I was using mpstat wrong. Apparently mpstat -A gives cpu stats since launch of the computer, while what I was needed was short time integrated results that can be obtained with mpstat -P ALL 2. Unfortunately, I only learned this after I killed my code in question, so no real data from mpstat. However, I am still interested, how would one troubleshoot such situation, where cores seems to be doing something, but result is not showing? How do I find the bottleneck?


问:
Can't reconcile PVLIB output with NREL SAM
Background

Traditionally I've used NREL SAM tool to estimate solar output. I've been experimenting with PVLIB which is great due to the open nature and flexibility, however I can't seem to reconcile the solar production estimates between PVLIB and NREL SAM.

What I've done

I'm modeling a hypothetical solar farm near Gympie QLD. I've gone to the climate.onebuiling website, and downloaded the zip folder / epw file for "AUS_QLD_Gympie.AP.945660_TMYx.2003-2017". I've then used that weather file in NREL's SAM tool using PVwatts, with the following specs;

200,000 KWdc

Module Type = Standard

1.2 DC to AC Ratio

96% inverter efficiency

1 axis backtracking

tilt = 26 degrees

azimuth = 0 degrees

GCR = 0.4

losses, shading & curtailment = default

In NREL SAM i get an annual Energy Yield (AC GWh) of 415.96 GWh p.a.

I then took that same epw file and converted it to a csv, keeping just the columns for ghi, dni, dhi, temp_air & wind_speed (Google Drive link to CSV file). I've used this file as an import into PVLIB. I spec'd a PVLIB system the same specs above, with addition of albedo = 0.2 and max angle = 90 degrees (Code Below).

The result I get in PVLIB is 395.61 GWh.

Problem

The results I got are pretty different. PVLIB = ~395 GWh p.a. vs SAM = ~415 GWH p.a. I expected around a 1-2% difference, but not 5%.

Figures are even worse when I compare to a PVLIB system using clearsky.ineichen (adjusted with linke_turbidity) which yields ~475 GWh p.a.

Help Requested

Anyone know why my results are so different? is there anything I can do to narrow the gap?

PVLIB Code

```<code># **********************************************************
# IMPORT LIBRARIES
# **********************************************************
import pandas as pd

from pvlib.pvsystem import PVSystem
from pvlib import clearsky, atmosphere, solarposition, irradiance
from pvlib.location import Location
from pvlib.tracking import SingleAxisTracker
from pvlib.modelchain import ModelChain
from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS

# **********************************************************
# LOCATION & SOLAR SIZE INPUTS
# **********************************************************
# Lat and Long desired
lat = -26.18
lon = 152.63

# Set Location
tz, altitude, name = 'Australia/Queensland', 10, 'Gympie/QLD'

# Set location details for model
latitude, longitude, = lat, lon
location = Location(latitude, longitude, tz, altitude, name)

# load some module and inverter specifications
module_parameters = {'pdc0': 200000000, 'gamma_pdc': -0.004}
inverter_parameters = {'pdc': 166666666, 'pdc0': 166666666, 'eta_inv_nom': 0.96}
temperature_model_parameters = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass']

# **********************************************************
# ONEBUILDING DATA
# **********************************************************
df = pd.read_csv('weather import.csv')
df['time'] = df['time'].astype('datetime64[ns]')
df.set_index(['time'], inplace=True)
df.index = df.index.tz_localize(tz=tz)
df = df.asfreq(freq='1h')
onebuilding = df

# **********************************************************
# INEICHEN CLEAR SKIES ADJUSTED FOR TURBIDITY
# **********************************************************
# Create PVLib inputs
times = df.index
solpos = solarposition.get_solarposition(times, latitude, longitude)
apparent_zenith = solpos['zenith']
rel_airmass = atmosphere.get_relative_airmass(apparent_zenith)
pressure = atmosphere.alt2pres(altitude)
abs_airmass = atmosphere.get_absolute_airmass(rel_airmass, pressure)
linke_turbidity = clearsky.lookup_linke_turbidity(times, latitude, longitude)
dni_extra = irradiance.get_extra_radiation(times)
ineichen = clearsky.ineichen(apparent_zenith, abs_airmass, linke_turbidity, altitude, dni_extra)
ineichen.to_csv('ineichen.csv')

# **********************************************************
# SELECT WHICH WEATHER DATA TO USE (ineichen v onebuilding)
# **********************************************************
# Select which version we wish to use (onebuilding, ineichen)
selected_irrad = onebuilding
print(selected_irrad)

# Create Weather File
weather = pd.DataFrame(data={'ghi': selected_irrad.ghi, 'dni': selected_irrad.dni,
                             'dhi': selected_irrad.dhi, 'temp_air': df['temp_air'],
                             'wind_speed': df['wind_speed']})

# **********************************************************
# CREATE PV SYSTEM AND PV MODEL CHAIN
# **********************************************************
# Define the specs for the PV System (fixed system)
f_system = PVSystem(
    surface_tilt=abs(lat),
    surface_azimuth=0,
    albedo=0.2,
    module='pvwatts_dc',
    inverter='pvwatts_ac',
    module_parameters=module_parameters,
    inverter_parameters=inverter_parameters,
    racking_model='open_rack_glass_glass',
    name='fixed',
    temperature_model_parameters=temperature_model_parameters
)

# Define the specs for the PV System (1 axis tracking system)
t_system = SingleAxisTracker(
    axis_tilt=0,
    axis_azimuth=0,
    max_angle=90,
    backtrack=True,
    module='pvwatts_dc',
    inverter='pvwatts_ac',
    module_parameters=module_parameters,
    inverter_parameters=inverter_parameters,
    name='tracking',
    gcr=.40,
)

# build model chain
mc = ModelChain(
    system=t_system,
    location=location,
    name='pvwatts',
    dc_model='pvwatts',
    ac_model='pvwatts',
    losses_model='pvwatts',
    aoi_model='physical',
    spectral_model='no_loss',
    temperature_model='sapm')

# run model chain
mc.run_model(weather=weather)
print(mc.ac.sum())
</code>```

答:
Hard to say exactly why the annual energy is different without a detailed comparison of intermediate results. One contributing factor appears to be the transposition model (GHI, DHI and DNI to plane-of-array): pvlib ModelChain defaults to the Hay/Davies model, and I believe SAM defaults to the Perez 1990 model. The two models will differ by a few percent in annual plane-of-array irradiance, which varies with the relative levels of diffuse and direct irradiance; see Lave et al. Figure 6.

You can select the Perez 1990 model in pvlib by adding transposition_model = 'perez', to the mc instance. I expect that will narrow the difference between pvlib and SAM results, and am interested in what you find.

Calculations using a TMY weather file won't give the same result as a calculation using irradiance from a clear sky model, since TMY is assembled from historical weather records and so includes cloudy periods.

Body:
Background

Traditionally I've used NREL SAM tool to estimate solar output. I've been experimenting with PVLIB which is great due to the open nature and flexibility, however I can't seem to reconcile the solar production estimates between PVLIB and NREL SAM.

What I've done

I'm modeling a hypothetical solar farm near Gympie QLD. I've gone to the climate.onebuiling website, and downloaded the zip folder / epw file for "AUS_QLD_Gympie.AP.945660_TMYx.2003-2017". I've then used that weather file in NREL's SAM tool using PVwatts, with the following specs;

200,000 KWdc

Module Type = Standard

1.2 DC to AC Ratio

96% inverter efficiency

1 axis backtracking

tilt = 26 degrees

azimuth = 0 degrees

GCR = 0.4

losses, shading & curtailment = default

In NREL SAM i get an annual Energy Yield (AC GWh) of 415.96 GWh p.a.

I then took that same epw file and converted it to a csv, keeping just the columns for ghi, dni, dhi, temp_air & wind_speed (Google Drive link to CSV file). I've used this file as an import into PVLIB. I spec'd a PVLIB system the same specs above, with addition of albedo = 0.2 and max angle = 90 degrees (Code Below).

The result I get in PVLIB is 395.61 GWh.

Problem

The results I got are pretty different. PVLIB = ~395 GWh p.a. vs SAM = ~415 GWH p.a. I expected around a 1-2% difference, but not 5%.

Figures are even worse when I compare to a PVLIB system using clearsky.ineichen (adjusted with linke_turbidity) which yields ~475 GWh p.a.

Help Requested

Anyone know why my results are so different? is there anything I can do to narrow the gap?

PVLIB Code

# **********************************************************
# IMPORT LIBRARIES
# **********************************************************
import pandas as pd

from pvlib.pvsystem import PVSystem
from pvlib import clearsky, atmosphere, solarposition, irradiance
from pvlib.location import Location
from pvlib.tracking import SingleAxisTracker
from pvlib.modelchain import ModelChain
from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS

# **********************************************************
# LOCATION & SOLAR SIZE INPUTS
# **********************************************************
# Lat and Long desired
lat = -26.18
lon = 152.63

# Set Location
tz, altitude, name = 'Australia/Queensland', 10, 'Gympie/QLD'

# Set location details for model
latitude, longitude, = lat, lon
location = Location(latitude, longitude, tz, altitude, name)

# load some module and inverter specifications
module_parameters = {'pdc0': 200000000, 'gamma_pdc': -0.004}
inverter_parameters = {'pdc': 166666666, 'pdc0': 166666666, 'eta_inv_nom': 0.96}
temperature_model_parameters = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass']

# **********************************************************
# ONEBUILDING DATA
# **********************************************************
df = pd.read_csv('weather import.csv')
df['time'] = df['time'].astype('datetime64[ns]')
df.set_index(['time'], inplace=True)
df.index = df.index.tz_localize(tz=tz)
df = df.asfreq(freq='1h')
onebuilding = df

# **********************************************************
# INEICHEN CLEAR SKIES ADJUSTED FOR TURBIDITY
# **********************************************************
# Create PVLib inputs
times = df.index
solpos = solarposition.get_solarposition(times, latitude, longitude)
apparent_zenith = solpos['zenith']
rel_airmass = atmosphere.get_relative_airmass(apparent_zenith)
pressure = atmosphere.alt2pres(altitude)
abs_airmass = atmosphere.get_absolute_airmass(rel_airmass, pressure)
linke_turbidity = clearsky.lookup_linke_turbidity(times, latitude, longitude)
dni_extra = irradiance.get_extra_radiation(times)
ineichen = clearsky.ineichen(apparent_zenith, abs_airmass, linke_turbidity, altitude, dni_extra)
ineichen.to_csv('ineichen.csv')

# **********************************************************
# SELECT WHICH WEATHER DATA TO USE (ineichen v onebuilding)
# **********************************************************
# Select which version we wish to use (onebuilding, ineichen)
selected_irrad = onebuilding
print(selected_irrad)

# Create Weather File
weather = pd.DataFrame(data={'ghi': selected_irrad.ghi, 'dni': selected_irrad.dni,
                             'dhi': selected_irrad.dhi, 'temp_air': df['temp_air'],
                             'wind_speed': df['wind_speed']})

# **********************************************************
# CREATE PV SYSTEM AND PV MODEL CHAIN
# **********************************************************
# Define the specs for the PV System (fixed system)
f_system = PVSystem(
    surface_tilt=abs(lat),
    surface_azimuth=0,
    albedo=0.2,
    module='pvwatts_dc',
    inverter='pvwatts_ac',
    module_parameters=module_parameters,
    inverter_parameters=inverter_parameters,
    racking_model='open_rack_glass_glass',
    name='fixed',
    temperature_model_parameters=temperature_model_parameters
)

# Define the specs for the PV System (1 axis tracking system)
t_system = SingleAxisTracker(
    axis_tilt=0,
    axis_azimuth=0,
    max_angle=90,
    backtrack=True,
    module='pvwatts_dc',
    inverter='pvwatts_ac',
    module_parameters=module_parameters,
    inverter_parameters=inverter_parameters,
    name='tracking',
    gcr=.40,
)

# build model chain
mc = ModelChain(
    system=t_system,
    location=location,
    name='pvwatts',
    dc_model='pvwatts',
    ac_model='pvwatts',
    losses_model='pvwatts',
    aoi_model='physical',
    spectral_model='no_loss',
    temperature_model='sapm')

# run model chain
mc.run_model(weather=weather)
print(mc.ac.sum())


问:
How can I eliminate vertical space between rows of buttons in an HTML table?
I have a div that pops up when the "PATTERNS" button is pressed. This div holds a table of buttons (see pic). I want all of the buttons to be touching however I can't seem to get rid of the row spaces in between them. I am not an experienced html table user.

My research has led me to try the following, is my table layout optimal here?:

.ButtonTable {
  display: block;
  background: rgb(116, 116, 116);
  position: absolute;
  margin: 0;
  padding: 0;
  left: 2%;
  width: 80%;
  height: 70%;
  /*BOX HEIGHT*/
  z-index: 1002;
  overflow: auto;
  opacity: .80;
  filter: alpha(opacity=80);
  border-spacing: 0;
  border-collapse: collapse;
}

.PatternButton {
  border-radius: 4px;
  width: 200px;
  transition-duration: 0.2s;
  color: black;
  background-color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 0;
  margin: 0;
  display: inline-block;
  border: none;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table className="ButtonTable" cellspacing="0">
  <td className="Col12">
    <th className="Title1">col1</th>
    <button className="PatternButton">1</button><br></br>
    <button className="PatternButton">2</button><br></br>
    <button className="PatternButton">3</button><br></br>
    <button className="PatternButton">4</button><br></br>
    <button className="PatternButton">5</button><br></br>
    <button className="PatternButton">6</button><br></br>
    <th className="Title2">col2</th>
    <button className="PatternButton">1</button><br></br>
    <button className="PatternButton">2</button><br></br>
    <button className="PatternButton">3</button><br></br>
    <button className="PatternButton">4</button><br></br>
    <button className="PatternButton">5</button><br></br>
    <button className="PatternButton">6</button><br></br>
  </td>
  <td className="Col34">
    <th className="Title3">col3</th>
    <button className="PatternButton">1</button><br></br>
    <button className="PatternButton">2</button><br></br>
    <button className="PatternButton">3</button><br></br>
    <button className="PatternButton">4</button><br></br>
    <button className="PatternButton">5</button><br></br>
    <button className="PatternButton">6</button><br></br>
    <th className="Title4">col4</th>
    <button className="PatternButton">1</button><br></br>
    <button className="PatternButton">2</button><br></br>
    <button className="PatternButton">3</button><br></br>
    <button className="PatternButton">4</button><br></br>
    <button className="PatternButton">5</button><br></br>
    <button className="PatternButton">6</button><br></br>
  </td>
  <td className="Col5">
    <th className="Title5">col5</th>
    <button className="PatternButton">1</button><br></br>
    <button className="PatternButton">2</button><br></br>
    <button className="PatternButton">3</button><br></br>
    <button className="PatternButton">4</button><br></br>
    <button className="PatternButton">5</button><br></br>
    <button className="PatternButton">6</button><br></br>
    <button className="PatternButton">7</button><br></br>
    <button className="PatternButton">8</button><br></br>
  </td>
  <td className="Col6">
    <th className="Title6">col6</th>
    <button className="PatternButton">1</button><br></br>
    <button className="PatternButton">2</button><br></br>
    <button className="PatternButton">3</button><br></br>
    <button className="PatternButton">4</button><br></br>
    <button className="PatternButton">5</button><br></br>
    <button className="PatternButton">6</button><br></br>
    <button className="PatternButton">7</button><br></br>
    <button className="PatternButton">8</button><br></br>
  </td>
</table></code>```

答:
I think I understand what you are asking. Try wrapping the buttons in divs and setting the margins.

https://jsfiddle.net/25wognuf/

```<code>   <style>
   .wr {
     margin: -1px -1px 10px -1px;
    padding: 0px;
   }
   </style>

<table className="ButtonTable" cellspacing="0" cellpadding="0">
<tr>
  <td className="Col12">
    <div class="wr">
    <button className="PatternButton">1</button>
    </div>
    <div class="wr">
    <button className="PatternButton">2</button>
    </div>
</td>
  <td className="Col12">
    <div class="wr">
    <button className="PatternButton">1</button>
    </div>
    <div class="wr">
    <button className="PatternButton">2</button>
    </div>
 </td>
</tr>
</table>
</code>```

Body:
I have a div that pops up when the "PATTERNS" button is pressed. This div holds a table of buttons (see pic). I want all of the buttons to be touching however I can't seem to get rid of the row spaces in between them. I am not an experienced html table user.

My research has led me to try the following, is my table layout optimal here?:

.ButtonTable {
  display: block;
  background: rgb(116, 116, 116);
  position: absolute;
  margin: 0;
  padding: 0;
  left: 2%;
  width: 80%;
  height: 70%;
  /*BOX HEIGHT*/
  z-index: 1002;
  overflow: auto;
  opacity: .80;
  filter: alpha(opacity=80);
  border-spacing: 0;
  border-collapse: collapse;
}

.PatternButton {
  border-radius: 4px;
  width: 200px;
  transition-duration: 0.2s;
  color: black;
  background-color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 0;
  margin: 0;
  display: inline-block;
  border: none;
}

    col1
    <button className="PatternButton">1</button>

    <button className="PatternButton">2</button>

    <button className="PatternButton">3</button>

    <button className="PatternButton">4</button>

    <button className="PatternButton">5</button>

    <button className="PatternButton">6</button>

    col2
    <button className="PatternButton">1</button>

    <button className="PatternButton">2</button>

    <button className="PatternButton">3</button>

    <button className="PatternButton">4</button>

    <button className="PatternButton">5</button>

    <button className="PatternButton">6</button>

    col3
    <button className="PatternButton">1</button>

    <button className="PatternButton">2</button>

    <button className="PatternButton">3</button>

    <button className="PatternButton">4</button>

    <button className="PatternButton">5</button>

    <button className="PatternButton">6</button>

    col4
    <button className="PatternButton">1</button>

    <button className="PatternButton">2</button>

    <button className="PatternButton">3</button>

    <button className="PatternButton">4</button>

    <button className="PatternButton">5</button>

    <button className="PatternButton">6</button>

    col5
    <button className="PatternButton">1</button>

    <button className="PatternButton">2</button>

    <button className="PatternButton">3</button>

    <button className="PatternButton">4</button>

    <button className="PatternButton">5</button>

    <button className="PatternButton">6</button>

    <button className="PatternButton">7</button>

    <button className="PatternButton">8</button>

    col6
    <button className="PatternButton">1</button>

    <button className="PatternButton">2</button>

    <button className="PatternButton">3</button>

    <button className="PatternButton">4</button>

    <button className="PatternButton">5</button>

    <button className="PatternButton">6</button>

    <button className="PatternButton">7</button>

    <button className="PatternButton">8</button>

Body:
I think I understand what you are asking. Try wrapping the buttons in divs and setting the margins.

https://jsfiddle.net/25wognuf/

   <style>
   .wr {
     margin: -1px -1px 10px -1px;
    padding: 0px;
   }
   </style>

<table className="ButtonTable" cellspacing="0" cellpadding="0">
<tr>
  <td className="Col12">
    <div class="wr">
    <button className="PatternButton">1</button>
    </div>
    <div class="wr">
    <button className="PatternButton">2</button>
    </div>
</td>
  <td className="Col12">
    <div class="wr">
    <button className="PatternButton">1</button>
    </div>
    <div class="wr">
    <button className="PatternButton">2</button>
    </div>
 </td>
</tr>
</table>