text:
Q: Cant find why Im having undefined offset notice I have this code below in a news-create.php file where I have a form to insert data in my news table.
And all is working fine, unless my images multiple upload, when I insert my news.
Im getting this errors:
Notice: Undefined offset: 3 in $ext = substr($gb['name'][$i],-3);
Notice: Undefined offset: 3 in if(in_array($gb['type'][$i],$extPerm))
Can you give some help trying to understand this notices??
This is what I have:
Before this code below, Im storing in $f array what User writes in my insert news form and upload my single image of my news and then I do my insert:
    $insNews = $pdo->prepare("INSERT INTO news (img, title, category, content) VALUES (?, ?, ?, ?)");
    $insNews->bindParam(1,$f['img']);
    $insNews->bindParam(2,$f['title']);
    $insNews->bindParam(3,$f['category']);
    $insNews->bindParam(4,$f['content']);
    $insNews->execute();
    $insNews = $pdo->lastInsertId();

Im getting my lastInsertId because I also want to create a image gallery to my current news, so I need to associate the news Im current inserting with my gallery table, so I think about this solution, I think it should work...
And then If my insert returns sucess I will do my multiple upload, and insert my gallery of current id in my table gallery:
if($insNews->rowCount() >=1){
    if($_FILES['gb']['tmp_name']){
        $count = count($_FILES['gb']['tmp_name']);
        $gb = $_FILES['gb'];
        $folder = '../galery/';
        $year = date('Y');
        $month = date('m');

        if(!file_exists($folder.$year)){
        mkdir($folder.$year,0755);
        }

        if(!file_exists($folder.$year.'/'.$month)){
        mkdir($folder.$year.'/'.$month,0755);
        }

        for($i=0;$i<=$count;$i++){

            $ext = substr($gb['name'][$i],-3);
            $name = $folder.$year.'/'.$month.'/'.$idlast.'-'.$i.time().'.'.$ext;
            $extPerm = array('image/jpeg', 'image/pjpeg', 'image/png', 'image/gif');
            if(in_array($gb['type'][$i],$extPerm)){
            uploadImage($gb['tmp_name'][$i], $name, '800', $folder);

            //and then I will do my insert into galery table here
            $insGal = $pdo->prepare("INSERT INTO gallery (img, id_news) VALUES (?, ?)");
            $insGal->bindParam(1,$name);
            $insGal->bindParam(2,$idlast);

            }
        }

    }

    if($f['status'] == '1'){
        echo 'Sucess inserting news';
    }
    else{
        echo 'Sucess intersing news, but you need to active it.';
    }

A: Change $i <= $count to $i < $count. When an array contains 3 elements, the indexes run from 0 to 2. You're going one element too far.

A: In addition to @Barmar's answer. It looks to me like you're counting the wrong array for your loop. Your Code:
$count = count($_FILES['gb']['tmp_name']);//shouldn't this be just $_FILES['gb'] as that's what you're iterating over?
$gb = $_FILES['gb'];

//
 for($i=0;$i<$count;$i++){ //$count contains the length of $_FILES['gb']['tmp_name']


text:
Q: Wireless router's ip address Does my wireless router have an ip address that's independent of my computer's ip address?  Is there any way to determine what that ip address is?  Note: I'm not talking about the internal router ip address: 192.168.0.1, but one that is visible from the outside.

A: I'd assume you are talking about a network like this, and you want to know the ip represened by 1.2.3.4 in the below graph:

     eth0          eth1                    eth0
     1.2.3.4       192.168.0.1             192.168.0.2
---------( Router )------------( Hub )-----[Computer 1]
                                  |
                                  +--------[Computer 2]
                                           eth0
                                           192.168.0.3

The simplest method is to log onto the router and see the interface address (which I assume you should have the credential to do so. This is by far the best method.
The method suggested above by others (to use a website to see your own ip address) had the advantage of being easy to use and simple, but this suffers when this network configuration occurs (NAT by ISP), where no public IP address was allocated to you:

     eth0          eth1         eth0            eth1
     2.3.4.5       10.0.0.1     10.0.0.2        192.168.0.1
---------( Router2 )--------------------( Router1 )--------....
         Your ISP router                Your router

This way, you will see your ISP router's external IP (2.3.4.5) as opposed to your router's external interface address (10.0.0.2).

A: Of course. You have an external IP address on the other side of your NAT + Router device. The simplest way is to actually look at your router's configuration or status page, which will display it. Another trick is to ask someone else on the internet what your IP address is - there are numerous websites which will show you what IP is accessing them. Note that this may not be the IP address on the external interface of your router, if your ISP is performing carrier level NAT or uses transparent proxy servers.

A: As @theatrus said, there are web sites that will show you the IP they see for you.  One example is http://www.pingtest.net.  When you go to their page, they show the IP they see for you to the left of their globe showing servers you can run a test with.  At a site like this, you also can test your connection.  (This is not an endorsement of their service; it's just one place you can go to see your IP number.)

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to compare attributes of the same table and SELECT based on that MYSQL I'm trying to take all the class tables that have more students that are male than female and list them
I've tried to do this a way that i'll show in the code
SELECT S.SID
FROM CLASS C, STUDENT S,
(SELECT COUNT(*)
FROM CLASS C, STUDENT S
WHERE S.GENDER = 'M') AS S(M),
(SELECT COUNT(*)
FROM CLASS C, STUDENT S
WHERE S.GENDER = 'F') AS S1(F)
WHERE S.ClassNo = C.ClassNumber AND S(M) > S1(F)

I've tried it a few other ways including putting the select count statements in the 'where' place.  I can put the SELECT count statements separately outside of the big statement and it will show the correct values but for comparison, it is not working so I assume it has to do with how they're being compared.  I expect the output to show all the classes that have more males than females.

A: Your query is a bit all over the place. Assuming what you want is to get the class numbers where males>females:
select * from (
select c.ClassNumber,
    sum(case when S.GENDER = 'M' then 1 else 0 end) as m,
    sum(case when S.GENDER = 'F' then 1 else 0 end) as f
from class c
join student s on s.ClassNo = C.ClassNumber
group by c.ClassNumber
) q
where m>f

A: Simply use aggregation:
SELECT S.CLASSNO
FROM STUDENT S
GROUP BY S.CLASSNO
HAVING SUM(GENDER = 'M') > SUM(GENDER = 'F');

Note that there is no need to use the CLASS table, because the class number is in the STUDENT table.


text:
Q: fix url with include page vs updated url to new file There is a technique that I've seen in a web site,having one fixed index.php file and include pages in that file dynamically .
I mean like having index.php that have JUST this code in  :
<?php
    if ($_GET['page'])
    {
        $url= $_GET['page'].".php" ;
        if(is_file($url))
        {
            include $url;
        }
        else
        {
            echo ' requested page is not found :'.$url;
        }
    }
    else
    {
        include 'home.php';
    }
?>

and any herf location will have index.php?page=ToPage
url will be like www.site.com/index.php?page=page1, www.site.com/index.php?page=page2, and so on ..
in other hand most of the sites uses normal move to page, like any href will make you go another page .
In this way the url will be www.site.com/index.php, www.site.com/page1, www.site.com/page2.php .
i want to know what is the advantage\disadvantage on every method .
and is it safe to use the first method ?

A: 1. www.site.com/index.php?page=page1
This method is risky and not recommended at all as the data can be manipulated by the user.
2. www.site.com/page1
This is just pretty url rewrite. You can achieve this by using some .htaccess code on Apache server and configuring url rewrite in your server block on nginx configuration file. But will have security flaw you implement this the way mentioned above.
Using include or require using user's data can cause Path Traversal attack.
Details here: https://www.owasp.org/index.php/Path_Traversal
One option could be to compare the real paths:
$basepath = '/foo/bar/baz/';
$realBase = realpath($basepath);

$userpath = $basepath . $_GET['path'];
$realUserPath = realpath($userpath);

if ($realUserPath === false || strpos($realUserPath, $realBase) !== 0) {
    //Directory Traversal!
} else {
    //Good path!
}

Secondly, you can use any good and trusted routing library or package.


text:
Q: BeautifulSoup: Scraping answers from form I need to scrape the answers to the questions from the following link, including the check boxes.
Here's what I have so far:
from bs4 import BeautifulSoup
import selenium.webdriver as webdriver

url = 'https://www.adviserinfo.sec.gov/IAPD/content/viewform/adv/Sections/iapd_AdvPrivateFundReportingSection.aspx?ORG_PK=161227&FLNG_PK=05C43A1A0008018C026407B10062D49D056C8CC0'

driver = webdriver.Firefox()
driver.get(url)

soup = BeautifulSoup(driver.page_source)

The following gives me all the written answers, if there are any:
soup.find_all('span', {'class':'PrintHistRed'})

and I think I can piece together all the checkbox answers from this:
soup.find_all('img')

but these aren't going to be ordered correctly, because this doesn't pick up the "No Information Filed" answers that aren't written in red.
I also feel like there's a much better way to be doing this. Ideally I want (for the first 6 questions) to return:
['APEX INVESTMENT FUND, V, L.P',
 '805-2054766781',
 'Delaware',
 'United States',
 'APEX MANAGEMENT V, LLC',
 'X',
 'O',
 'No Information Filed',
 'NO',
 'NO']

EDIT
Martin's answer below seems to do the trick, however when I put it in a loop, the results begin to change after the 3rd iteration. Any ideas how to fix this?
from bs4 import BeautifulSoup
import requests
import re

for x in range(5):
    url = 'https://www.adviserinfo.sec.gov/IAPD/content/viewform/adv/Sections/iapd_AdvPrivateFundReportingSection.aspx?ORG_PK=161227&FLNG_PK=05C43A1A0008018C026407B10062D49D056C8CC0'
    html = requests.get(url)
    soup = BeautifulSoup(html.text, "lxml")

    tags = list(soup.find_all('span', {'class':'PrintHistRed'}))
    tags.extend(list(soup.find_all('img', alt=re.compile('Radio|Checkbox')))[2:])       # 2: skip "are you an adviser" at the top
    tags.extend([t.parent for t in soup.find_all(text="No Information Filed")])

    output = []

    for entry in sorted(tags):
        if entry.name == 'img':
            alt = entry['alt']
            if 'Radio' in alt:
                output.append('NO' if 'not selected' in alt else 'YES')
            else:
                output.append('O' if 'not checked' in alt else 'X')
        else:
            output.append(entry.text)

    print output[:9]

A: The website does not generate any of the required HTML via Javascript, so I have chosen to use just requests to get the HTML (which should be faster).
One approach to solving your problem is to store all the tags for your three different types into a single array. If this is then sorted, it will result in the tags being in tree order.
The first search simply uses your PrintHistRed to get the matching span tags. Secondly it finds all img tags that have alt text containing either the word Radio or Checkbox. Lastly it searches for all locations where No Information Filed is found and returns the parent tag.
The tags can now be sorted and a suitable output array built containing the information in the required format:
from bs4 import BeautifulSoup
import requests
import re

url = 'https://www.adviserinfo.sec.gov/IAPD/content/viewform/adv/Sections/iapd_AdvPrivateFundReportingSection.aspx?ORG_PK=161227&FLNG_PK=05C43A1A0008018C026407B10062D49D056C8CC0'
html = requests.get(url)
soup = BeautifulSoup(html.text, "lxml")

tags = list(soup.find_all('span', {'class':'PrintHistRed'}))
tags.extend(list(soup.find_all('img', alt=re.compile('Radio|Checkbox')))[2:])       # 2: skip "are you an adviser" at the top
tags.extend([t.parent for t in soup.find_all(text="No Information Filed")])

output = []

for entry in sorted(tags):
    if entry.name == 'img':
        alt = entry['alt']
        if 'Radio' in alt:
            output.append('NO' if 'not selected' in alt else 'YES')
        else:
            output.append('O' if 'not checked' in alt else 'X')
    else:
        output.append(entry.text)

print output[:9]        # Display the first 9 entries

Giving you:
[u'APEX INVESTMENT FUND V, L.P.', u'805-2054766781', u'Delaware', u'United States', 'X', 'O', u'No Information Filed', 'NO', 'YES']

A: I've looked fairly carefully at the HTML. I doubt there is an utterly simple way of scraping pages like this.
I would begin with an analysis, looking for similar questions. For instance, 11 through 16 inclusive can likely be handled in the same way.  19 and 21 appear to be similar. There may or may not be others.
I would work out how to handle each type of similar question as given by the rows containing them. For example, how would I handle 19 and 21? Then I would write code to identify the rows for the questions noting the question number for each. Finally I would use the appropriate code using the row number to winkle out information from it. In other words, when I encountered question 19 I'd use the code meant for either 19 or 21.


text:
Q: Difference between depends and dependencies in gradle What's the difference between depends keyword and dependencies keywords in a gradle build file? I encountered these keywords in the following contexts:
depends:
project(':tools:bnd-module-plugin') {
  description = "bnd plugin to build moduleinfo with ${rootProject.description}"
  sourceSets.main.java.srcDirs += project(':asm').sourceSets.main.java.srcDirs
  depends = ['biz.aQute.bnd:biz.aQute.bnd:3.4.0']
}

dependencies:
subprojects {
  apply plugin: 'com.github.sherter.google-java-format'
  googleJavaFormat.toolVersion = '1.4'
  compileTestJava {
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
  }
  dependencies {
    requires.each { projectName -> compile project(projectName) }
    depends.each { artifactName -> compile artifactName }
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0',
        'org.junit.jupiter:junit-jupiter-params:5.1.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
    testCompile project(':asm-test')
  }
}

A: The dependencies keyword is provided by a method of the Project instance, which the build.gradle file is evaluated against. It allows the configuration of multiple types of dependencies via a DependencyHandler. You can add file dependencies, project dependencies and module dependencies, which can be resolved from Maven and Ivy repositories.
Since it is provided by the Project instance directly, it is available in every Gradle project.
The depends keyword does not exist in the Gradle API. However, Gradle provides a lot of possibilities to extend and program your build scripts. Via so-called extra properties it is possible to define additional properties in the scope of Gradle objects, like tasks and projects. Then these additional properties can be used like regular Gradle properties as in your example.
I found the full build script from your examples online. In the beginning of the script a subprojects closure is used to define extra properties for all subprojects:
subprojects {
    [...]
    ext.provides = []  // The provided java packages, e.g. ['org.objectweb.asm']
    ext.requires = []  // The required Gradle projects, e.g. [':asm-test']
    ext.depends = []   // The external dependencies, e.g. ['junit:junit:4.12']
    [...]
}

provides, required and depends are Groovy lists, which are then later used to store strings.
Your first code example sets a new list to the depends extra property of the :tools:bnd-module-plugin subproject.
Your second uses these lists to add module (depends) or project (requires) dependencies to all subprojects.
As you can see, depends is just part of a custom Gradle script and not part of the official Gradle API, unlike dependencies.


text:
Q: Software Testing Selenium IDE/Web driver My application is using Mathml editor and i want to record button from this editor. i am using Selenium IDE, But not able to record any action from this editor.
i am new for selenium please help me out.
This is what I've tried so far:
driver.switchTo().frame("editML");
WebElement editor = driver.findElement(By.className("#editML"));
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("arguments[0].innerHTML = '
Heading
Hello World'", editor);

A: You are trying to do too much in your code. Try this:
driver.switchTo().frame("editML");
WebElement editor = driver.findElement(By.xpath("//body"));
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("arguments[0].innerHTML = 'Hello World'", editor);

A: Although I haven't tried it but it seems that in HTML 5 to have direct support for MathML elements the script could be: driver.switchTo().frame("editML");
WebElement editor = driver.findElement(By.className("#editML"));
JavascriptExecutorjsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("arguments[0].innerHTML = '<mi>
Heading
Hello World</mi>'", editor);

For more info on  tags follow the below link:
http://www.tutorialspoint.com/html5/html5_mathml.htm


text:
Q: Run Firefox multiple times from different locations I want to open 10 instances of Firefox (or another browser if not possible) with different proxies in each one of them. I have downloaded "Firefox Portable" and installed in a two different locations, but I can't open them up at the same time - I have used the command -no-remote-, but it doesn't work when Firefox is located in a different locations.
Is it possible to open Firefox multiple times while they are on different locations? if not, how can I run 10 instances of browser with different proxy on each?
Thanks.

A: You could do it two ways.
First is explained below.
Open firefox portable and Rename the .exe to firefox1.exe
Do this for each instance.
So firefox2.exe, firefox3.exe and so on.
The path to the .exe is \firefox\firefox 1\FirefoxPortable\App\Firefox
Then open them up and they will be under different processes.
Here is an example of two of portable version. Then you just set up a proxy for each.

The other way is to hold Shift + Right Click
and select Run as Different user.

Of course you will need to set up multiple users for it to run for. Or use a virtual machine.
Hope this helps.


text:
Q: Removing Unwanted text before launching URL Whenever I am hitting any URL containing : cablevision.com
I get the below message due to network/firewall of my company:

This page can't be displayed

*

*Make sure the web address https://bitbucket.cablevision.com is correct.

*Look for the page with your search engine.

*Refresh the page in a few minutes.

I have to remove 'cablevision.com' from URL manually and launch it again.
Can someone please let me know any plugin to do this every time I launch any URL containing 'cablevision.com'.


text:
Q: Difference between ng-model="xxx" and value="{{xxx}}"? In a regular form, when a reset type button (<button type="reset">Reset</button>) is clicked, all input controls will be emptied except readonly or disabled.
http://jsfiddle.net/blaise_liu/K2f7g/
When constructing a form using angular, I have
<input type="text" id="district" disabled="" ng-model="address.district" />

In this form, when the reset button is clicked, the value in the input above is removed even it is marked as disabled or readonly. Why? Should I use ng-model to bind to this input control? Do I have to use value= to make the binding?
<input type="text" id="district" disabled="" value="{{address.district}}" />

A: ng-model supports 2-way data binding. When you use ng-model the value of the model is bound to the view and updating the model will update the view and vice-versa updating the view updates the model. Using {{address.district}} does not 2-way data bind. It only outputs the value of the model. See: https://docs.angularjs.org/guide/forms.
The button type reset is resetting the model regardless of the disabled property. If you don't want 2-way data binding you can just use {{address.district}} as you have mentioned. See: http://jsfiddle.net/K2f7g/1/.

A: ng-model adds parsing and validation. Just interpolating the value isn't sufficient for that.
In your fiddle, you denote a field as required. required is also another directive that works with ngModelController.


text:
Q: Kml placemarks list with Google Maps API I would like to know if there is a way to display the Placemarks of a kml hosted online using the Google Maps API. What I would like to do is to have a panel to navigate the folders like the one provided by google maps when I search for an online KML -> https://maps.google.com/maps?f=q&hl=en&q=http://kmlscribe.googlepages.com/SamplesInMaps.kml
I don't have any problem to display only the KML using the API, this is the code I have:
<html>
<head>
    <script type="text/javascript" src= "http://maps.google.com/maps/api/js?sensor=true">
    </script>
    <script>
var map;
var cta_layer;

function initialize() {
    var kmlUrl = 'http://kmlscribe.googlepages.com/SamplesInMaps.kml';
    var myOptions = {
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    cta_layer = new google.maps.KmlLayer(kmlUrl, {suppressInfoWindows: false,preserveViewport:false});
    cta_layer.setMap(map);
}
    </script>
</head>
<body onload="initialize()">
    <div id="map_canvas"  style="height: 800px;width: 800px;">
    </div>
</body>

Thank you for the help.

A: Look at the third party parsers for KML.  geoxml-v3 has the best "sidebar" support.  You can also use geoxml3, but you have to build the sidebar yourself.
Notes:

*

*both these third-party parsers parse the KML in the browser and render the it using native Google Maps API v3 objects, so they may have performance issues for complex KML.

*if the KML is hosted in a different domain from the web page, they require proxies to access the KML (due to the same domain restriction on XmlHttpRequest)
example


text:
Q: What spells are best to use when using the BARCH strategy? When farming in Clash of Clans, I like to use the BARCH strategy (Barbarians and Archers) to farm resources. However, I was wondering if there was a way to further supplement my army with spells. What are the best spells to use?

A: Use lightning spells to take out buildings that deal splash damage to your troops like mortars rather than on single target buildings like cannons and archer towers. If you can, try to use your troops to lure the enemy's clan castle onto the building which you will destroy. Thus, making your raid much more efficient.

A: I would recommend healing and rage spells, healing spells can help your troops deal with splash damage from mortars and rage spells can help your troops wipe out tough buildings quickly.

A: Boost your barbarian king and take few heal spell.. heal king with spell... I am sure archer behind king make loot of dark elixir at TH8.

A: I would use lightning spells to take out defences like mortars that cause splash damage and not single targeted defences such as cannons.

A: Use lightning spells to take out buildings that deal splash damage to your troops like mortars rather than on single target buildings like cannons and archer towers. If you can, try to use your troops to lure the enemy's clan castle onto the building which you will destroy. Thus, making your raid much more efficient.


text:
Q: 'R' could be instantiated with an arbitrary type which could be unrelated to 'Response' Ok, so I'm trying to implement a simple "Command Bus" in TypeScript, but I'm tripping up over generics and I wonder if someone could help me. Here is my code:
This is the interface for the commandbus
export default interface CommandBus {
  execute: <C extends Command, R extends Response<C>>(command: C) => Promise<R>;
}

This is the implementation
export default class AppCommandBus implements CommandBus {
  private readonly handlers: Handler<Command, Response<Command>>[];

  /* ... constructor ... */

  public async execute<C extends Command, R extends Response<C>>(
    command: C
  ): Promise<R> {
    const resolvedHandler = this.handlers.find(handler =>
      handler.canHandle(command)
    );

    /* ... check if undef and throw ... */

    return resolvedHandler.handle(command);
  }
}

and this is what the Handler interface looks like:
export default interface Handler<C extends Command, R extends Response<C>> {
  canHandle: (command: C) => boolean;
  handle: (command: C) => Promise<R>;
}

Command is (currently) an empty interface, and Response looks like this:
export default interface Response<C extends Command> {
  command: C;
}

I'm getting the follow compile error error against the last line of the execute function of the commandbus and I'm completely stumped.
type 'Response<Command>' is not assignable to type 'R'. 'R' could be instantiated with an arbitrary type which could be unrelated to 'Response<Command>'.
If anyone is able to help me understand what I'm doing wrong, I'd be eternally grateful!
EDIT
I've realised I can work around this with a typecast:
const resolvedHandler = (this.handlers.find(handler =>
  handler.canHandle(command)
) as unknown) as Handler<C, R> | undefined;

But I'd still like to know how to resolve this double cast.

A: Generic functions in TypeScript act as a function representing every possible specification of its generic type parameters, since it's the caller of the function that specifies the type parameter, not the implementer:
type GenericFunction = <T>(x: T) => T;

const cantDoThis: GenericFunction = (x: string) => x.toUpperCase(); // error!
// doesn't work for every T
cantDoThis({a: "oops"}); // caller chooses {a: string}: runtime error

const mustDoThis: GenericFunction = x => x; // okay, verifiably works for every T
mustDoThis({a: "okay"}); // okay, caller chooses {a: string}

So, let's look at CommandBus:
interface CommandBus {
  execute: <C extends Command, R extends Response<C>>(command: C) => Promise<R>;
}

The execute() method of CommandBus is a generic function that claims to be able to accept a command of any subtype of Command the caller wants (okay so far probably), and return a value of Promise<R>, where R is any subtype of Response<C> that the caller wants.  That doesn't seem to be something anyone could plausibly implement, and presumably you'll always have to assert that the response you're returning is the R the caller asked for.  I doubt this is your intent.  Instead, how about something like this:
interface CommandBus {
    execute: <C extends Command>(command: C) => Promise<Response<C>>;
}

Here, execute() only has one generic parameter, C, corresponding to the type of the passed-in command.  And the return value is just Promise<Response<C>>, not some subtype that the caller is asking for.  This is more plausibly implementable, as long as you have some way of guaranteeing that you have an appropriate handler for every C (say, by throwing if you don't.)

That leads us to your Handler interface:
interface Handler<C extends Command, R extends Response<C>> {
  canHandle: (command: C) => boolean;
  handle: (command: C) => Promise<R>;
}

Even if we release ourselves from the tyranny of trying to represent the particular subtype of Response<C> a handler will produce, like this:
interface Handler<C extends Command> {
  canHandle: (command: C) => boolean;
  handle: (command: C) => Promise<Response<C>>;
}

we still have a problem with canHandle().  And that's the fact that Handler is itself a generic type.  The difference between generic functions and generic types has to do with who gets to specify the type parameter.  For functions, it's the caller.  For types, it's the implementer:
type GenericType<T> = (x: T) => T;

const cantDoThis: GenericType = (x: string) => x.toUpperCase(); // error! no such type

const mustDoThis: GenericType<string> = x => x.toUpperCase(); // okay, T is specified
mustDoThis({ a: "oops" }); // error! doesn't accept `{a: string}`
mustDoThis("okay");

You want Handler<C> to only handle() a command of type C, which is fine.  But its canHandle() method also demands that the command be of type C, which is too strict.  You want the caller of canHandle() to choose the C, and have the return value be  true or false depending on whetehr the C chosen by the caller matches the one chosen by the implementer.  To represent this in the type system, I'd suggest making canHandle() a generic user-defined type guard method of a parent interface that isn't generic at all, like this:
interface SomeHandler {
    canHandle: <C extends Command>(command: C) => this is Handler<C>;
}

interface Handler<C extends Command> extends SomeHandler {
    handle: (command: C) => Promise<Response<C>>;
}

So, if you have a SomeHandler, all you can do is call canHandle().  If you pass it a command of type C, and canHandle() returns true, the compiler will understand that your handler is a Handler<C> and you can call it.   Like this:
function testHandler<C extends Command>(handler: SomeHandler, command: C) {
    handler.handle(command); // error!  no handle method known yet
    if (handler.canHandle(command)) {
        handler.handle(command); // okay!
    }
}

We're almost done.  The only fiddly bit is that you're using SomeHandler[]'s find() method to locate one appropriate for command.  The compiler cannot peer into the callback handler => handler.canHandle(command) and deduce that the callback is of type (handler: SomeHandler) => handler is SomeHandler<C>, so we have to help it out by annotating it as such.  Then the compiler will understand that the return value of find() is Handler<C> | undefined:
class AppCommandBus implements CommandBus {
    private readonly handlers: SomeHandler[] = [];

    public async execute<C extends Command>(
        command: C
    ): Promise<Response<C>> {
        const resolvedHandler = this.handlers.find((handler): handler is Handler<C> =>
            handler.canHandle(command)
        );
        if (!resolvedHandler) throw new Error();
        return resolvedHandler.handle(command);
    }
}

This works pretty well with the type system and is as nice as I can make it.  It may or may not work for your actual use case, but hopefully it gives you some ideas about how generics can be used effectively.  Good luck!
Playground link to code


text:
Q: An elementary number theory problem Let $n$ be the smallest positive integer such that $mn$ is a perfect $k$th power of an integer for some $k \ge 2$, where $m=2^{1980} \cdot 3^{384} \cdot 5^{1694} \cdot 7^{343}$. What is $n+k$?
I'm not sure what this problem is asking and what I need to do. Any help is greatly appreciated.

A: Note that if $n=2\times 3$, we will get, $$mn = (2^{1981})(3^{385})(5^{1694})(7^{343})$$ $$mn =(2^{283})^7(3^{55})^7(5^{242})^7(7^{49})^7$$ $$mn =(2^{283}\times 3^{55}\times 5^{242}\times 7^{49})^7$$ Thus, here $n=6$ and $k=7$, giving $n+k=13$.


text:
Q: Why is the Brownian Motion generally non-markov? The Wikipedia article of the Brownian motion states that:
"In the general case, Brownian motion is a non-Markov random process and described by stochastic integral equations."
I find it hard to see why that is the case. I know the Brownian Motion to have independent increments, which seems to be stronger than the markov chain. Also The article for Markov chain has a table that names the Wiener Process as an example of a continuous-time, general state-space MC. Which one is true?

A: If you look at the reference it gives for this statement, it is
Morozov, A. N.; Skripkin, A. V. (2011). "Spherical particle Brownian motion in viscous medium as non-Markovian random process". Physics Letters A. 375 (46): 4113–4115.
So this is not referring to the Wiener process (what a mathematician would call Brownian motion), but rather to a model of the motion of a physical particle.  It is not Markovian, I suppose, because the motion of the sphere causes disturbances of the medium which affect the sphere at later times.


text:
Q: 'to_string' unknown override specifier For an assignment I am supposed to use the following class in a header file 'date.h' However when I attempted to compile my program I got an error stating:

'to_string': unknown override specifier.

What is wrong with the following code? I can't seem to figure it out.
#pragma once
#ifndef DATE_H
#define DATE_H

#include <string>
#include <sstream>

class Date
{
private:
    int m_day, m_month, m_year;
public:
    Date(int d, int m, int y)
    {
        m_day = d; m_month = m; m_year = y;
    }

    int getDay() const { return m_day; }
    int getMonth() const { return m_month; }
    int getYear() const { return m_year; }
    string to_string() const
    {
        stringstream s;
        s << getMonth() << "/" << getDay() << "/" << getYear();
        return s.str();
    }
};
#endif

A: it may be because string is part of the standard library. You should do this instead:
std::string to_string() const {

}


text:
Q: Setting cors in strapi 4 I'm using strapi 4 as localhost and got a problem with cors settings when I add new assets via url
Image upload takes CORS error Access to XMLHttpRequest at 'https://www.countrysideveterinaryclinic.org/sites/default/files/interesting-cat-facts.jpg' from origin 'http://localhost:1337' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Solution from here didn't help
my middleware.js
module.exports = [
  'strapi::errors',
  'strapi::security',
  'strapi::poweredBy',
  {
    name: 'strapi::cors',
    config: {
      enabled: true,
      header: '*',
      origin: ['http://localhost:1337']
    }
  },
  'strapi::logger',
  'strapi::query',
  'strapi::body',
  'strapi::session',
  'strapi::favicon',
  'strapi::public',
];

A: I found the solution myself, maybe it will help someone
middlewares.js
module.exports = [
  'strapi::errors',
  'strapi::security',
  'strapi::poweredBy',
  {
    name: 'strapi::cors',
    config: {
      enabled: true,
      headers: '*',
      origin: ['http://localhost:1337', 'http://example2']
    }
  },
  'strapi::logger',
  'strapi::query',
  'strapi::body',
  'strapi::session',
  'strapi::favicon',
  'strapi::public',
];


text:
Q: Can't install apksigner with sudo apt install apksigner So I'm trying to install apksigner with :
sudo apt install apksigner

And I'm getting this error message:

What is the problem here? How can I install apksigner?


text:
Q: gluon mobile android application default locale is en_US but phone is in spanish i test i18n in gluon with its default project : gluon mobile single view . i add a print line to get : Locale.getdefault() . but is in english en_US and the device is in spanish . i have another large project with bundles and i had the same issue . i put the default project in this question 'cause i found better to show just small portion of code and replicate it .
the code
package com.local;

 import com.gluonhq.charm.glisten.control.AppBar;
 import com.gluonhq.charm.glisten.control.Icon;
 import com.gluonhq.charm.glisten.mvc.View;
 import com.gluonhq.charm.glisten.visual.MaterialDesignIcon;
 import java.util.Locale;
 import javafx.geometry.Pos;
 import javafx.scene.control.Button;
 import javafx.scene.control.Label;
 import javafx.scene.layout.VBox;

 public class BasicView extends View {

  public BasicView() {

    Label label = new Label("Hello JavaFX World!");

    Button button = new Button("Change the World!");
    button.setGraphic(new Icon(MaterialDesignIcon.LANGUAGE));
    button.setOnAction(e -> {label.setText("Hello JavaFX Universe!");

    // i add this line to default : gluon mobile single view
    System.out.println(Locale.getDefault());});

    VBox controls = new VBox(15.0, label, button);
    controls.setAlignment(Pos.CENTER);

    setCenter(controls);
}

@Override
protected void updateAppBar(AppBar appBar) {
    appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> System.out.println("Menu")));
    appBar.setTitleText("Basic View");
    appBar.getActionItems().add(MaterialDesignIcon.SEARCH.button(e -> System.out.println("Search")));
}

}
and i get this from console after install .apk  on a real device
[vie. mar. 26 17:44:13 CLST 2021][INFO] [SUB] D/GraalCompiled(13989): en_US

pom file :
` <project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-
   4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

<groupId>com.local</groupId>
<artifactId>local</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>>local</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.release>11</maven.compiler.release>
    <javafx.version>16</javafx.version>
    <attach.version>4.0.11</attach.version>
    <client.plugin.version>0.1.38</client.plugin.version>
    <javafx.plugin.version>0.0.5</javafx.plugin.version>
    <mainClassName>com.local.Local</mainClassName>
</properties>

<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>${javafx.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gluonhq</groupId>
        <artifactId>charm-glisten</artifactId>
        <version>6.0.6</version>
    </dependency>
    <dependency>
        <groupId>com.gluonhq.attach</groupId>
        <artifactId>display</artifactId>
        <version>${attach.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gluonhq.attach</groupId>
        <artifactId>lifecycle</artifactId>
        <version>${attach.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gluonhq.attach</groupId>
        <artifactId>statusbar</artifactId>
        <version>${attach.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gluonhq.attach</groupId>
        <artifactId>storage</artifactId>
        <version>${attach.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gluonhq.attach</groupId>
        <artifactId>util</artifactId>
        <version>${attach.version}</version>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>Gluon</id>
        <url>https://nexus.gluonhq.com/nexus/content/repositories/releases</url>
    </repository>
</repositories>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
        </plugin>

        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>${javafx.plugin.version}</version>
            <configuration>
                <mainClass>${mainClassName}</mainClass>
            </configuration>
        </plugin>

        <plugin>
            <groupId>com.gluonhq</groupId>
            <artifactId>client-maven-plugin</artifactId>
            <version>${client.plugin.version}</version>
            <configuration>
                <target>${client.target}</target>
                <attachList>
                    <list>display</list>
                    <list>lifecycle</list>
                    <list>statusbar</list>
                    <list>storage</list>
                </attachList>
                <mainClass>${mainClassName}</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

<profiles>
    <profile>
        <id>desktop</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <client.target>host</client.target>
        </properties>
        <dependencies>
            <dependency>
                <groupId>com.gluonhq.attach</groupId>
                <artifactId>display</artifactId>
                <version>${attach.version}</version>
                <classifier>desktop</classifier>
            </dependency>
            <dependency>
                <groupId>com.gluonhq.attach</groupId>
                <artifactId>lifecycle</artifactId>
                <version>${attach.version}</version>
                <classifier>desktop</classifier>
            </dependency>
            <dependency>
                <groupId>com.gluonhq.attach</groupId>
                <artifactId>storage</artifactId>
                <version>${attach.version}</version>
                <classifier>desktop</classifier>
            </dependency>
        </dependencies>
    </profile>
    <profile>
        <id>ios</id>
        <properties>
            <client.target>ios</client.target>
        </properties>
    </profile>
    <profile>
        <id>android</id>
        <properties>
            <client.target>android</client.target>
        </properties>
    </profile>
</profiles>

`

A: The problem you are facing is that the locale used to build the native image (usually the default locale on your machine, unless set otherwise) is the one that will be used on runtime, no matter what locale is set.
There is an open issue in GraalVM about this. There is no definitive fix for this yet, but it is expected to be available from GraalVM 21.1 (in just a couple of weeks).
For now, a workaround is to set the target's locale in the Client plugin configuration, like:
<nativeImageArgs>
    <arg>-Duser.language=es</arg>
    <arg>-Duser.country=ES</arg>
</nativeImageArgs>

and then run again
mvn -Pandroid client:build client:package
The generated APK will use the es_ES resource bundles.
Of course, this means that you would have to build a different image/APK for every language you support, which is really inconvenient.


text:
Q: Business man made leader I remember reading a short story in where the political system they used is that they would select a successful business man, liquidate all of his assets (it becomes state money) and at the end of their term they would be given back assets in proportion to how well they did during their term.
I read this story before 2000 and it was in English, as I recall it was in a collection of short stories by that author (but my memory could be playing tricks).  But it is probably even older than that.

A: While it is not a short story the Tamuli series by David Eddings has a character detailing a political system like this one
There was no real story though simply a character detailing how the political system of their home country works (and slightly bragging that their government manages to turn a profit)


text:
Q: Installing and running Silverstripe CMS on Azure Has anyone installed the SilverStripe CMS on Windows Azure? if so did you have any issues during the installation or with the on going running of the CMS?
On my current project I'm pushing Azure for the .Net application being developed. The application is to link with the website which has been developed using the SilverStripe CMS and I would like to have them both hosted on Azure.
Any insights/suggestions/feedback is much appreciated!

A: I can't say I have, nor do I plan to.
But I did try SilverStripe on IIS7 (win server 2008 R2) once though, and it worked surprisingly well.
I would suggest you simply try it.
Installing just a plain fresh copy of SilverStripe is fairly simple.
Verify that you meet the system requirements such as having mod_rewrite or an alternative, php5.3.2+ and just upload & install it.


text:
Q: Events and Independence Is there any other way to check if two events $A,B$ are independent other than to verify $P(A \text{ and } B)=P(A)\cdot P(B)$?

A: These are some ways that came to my mind.
Suppose we are working with probability measure $P$ in a measurable space $(\Omega, \mathcal{F})$.
One can alternatively show that if one sets $A'$ to be either $A$ or $\Omega \setminus A$ and $B'$ to be either $B$ or $\Omega \setminus B$ then $A$ and $B$ are independent events if and only if the condition $$P(A' \text{ and }B') = P(A')\cdot P(B')$$ is met. When we set $A'$ and $B'$ to be any combination other than $A'=A$, $B'=B$ this gives you other ways to show independence.
Aside from that, there are some events that are independent to every other event: events with probability $0$ or probability $1$. Then if either $A$ or $B$ is one of those, you will have shown $A$ and $B$ are independent.


text:
Q: LCM and divisibility: $\,a,b\mid c\Rightarrow {\rm lcm}(a,b)\mid c$ Let $c \in \mathbb Z$ and $k=LCM(a,b)$.
Show that for every $a,b \in \mathbb Z$ \ {$0$} if  $a\mid c$ and  $b\mid c$ then also $k\mid c$.
Please dont give me the solution just a tip. My thoughts were that $c \ge LCM(a,b)$ so $c$ is a multiple of $k$ $\Rightarrow$ $c=LCM(a,b)*m$ with $m \in \mathbb N$. Then I have to look at to cases:
Case 1:
$c=LCM(a,b)$
then $a$ divides $c$, $b$ divides $c$ and then also $k$ divides $c$.
Case 2:
$c\gt LCM(a,b)$
a divides c and b divides c $\Rightarrow ax=c=by $ with $x,y \in \mathbb Z$ and a,b divides $LCM(a,b)$ then a,b divides also the multiple of $LCM(a,b)*ax*by*n$ with $n \in \mathbb N$.
Im pretty sure at Case 1 but not at Case 2. Does it make sense? please give me rate and a tip. Thank you!

A: The set $\,S\,$ of all positive common multiples of $\,a,b\,$ is a nonsempty set of postive integers closed under positive subtraction, i.e. $\,n,m\in S, n>m\,\Rightarrow\, n-m\in S.\,$ Show that every element $\,s\,$ of such a set is a multiple of its least element $\,\ell = \min S\,$ (hint: $ $ if not then we would have  $\,0\ne s\bmod \ell  = s - \ell -\cdots -\ell\,$ lies in $\,S\,$ and is smaller than $\,\ell,\,$ contra minimality of $\,\ell)$

A: One idea is to look at prime factorisation of $a,b, \text{lcm} (a,b)$. Denote $\nu_p(x)=d$ if $p^d \mid x$ and $p^{d+1} \nmid x$. Now, according to the definition of least common multiple, we find that $\nu_p(c)=\max \{ \nu_p(a),\nu_p(b) \}$. We also have $\nu_p(k) \le \max \{ \nu_p(a),\nu_p(b) \}$. Thus, for all prime $p$ then $\nu_p(k) \le \nu_p(c)$ or $k \mid c$.


text:
Q: How to Call Subs from an Add-In Directly So it's obviously easy to write code that will call a sub/function that is in an add-in library via VBA code, simply by doing
call myFunctionOrSub

However, is there a way to allow users to directly call public subs in an add-in? For example, when the user goes to Tools -> Macros and pulls up this screen:

I would like to add to the list of macros in that box all Subs which are included in add-ins that are linked to for the file. That is, I have a library (library.xlam) that is referenced by this current workbook. In this library.xlam file, I have Subs (such as copyToResults). I want copyToResults to appear as a runnable macro in this list. Is there a way to do that?
The only solution I could come up with was to create a Sub in my test file for each Sub in library.xlam. This Sub in the test file would do nothing by call library's Sub. However, this is terrible for the purpose of having external libraries and terrible for scalability, so we definitely don't want to go this route.

A: *

*Make a form in your xlam with a list box.

*Use the script from this post to populate your form. You will have to change some excel settings.
Get a list of the macros of a module in excel, and then call all those macros
Here is my code from my form:
Private Sub btnCancel_Click()
    Unload Me
End Sub

Private Sub btnExecute_Click()

    Application.Run "macros.xlam!" & lstMacros.Value
    Unload Me
End Sub

Private Sub UserForm_Initialize()

Dim pj As VBProject
Dim vbcomp As VBComponent
Dim curMacro As String, newMacro As String
Dim x As String
Dim y As String
Dim macros As String

On Error Resume Next
curMacro = ""
Documents.Add

For Each pj In Application.VBE.VBProjects

     For Each vbcomp In pj.VBComponents
            If Not vbcomp Is Nothing Then
                If Not vbcomp.CodeModule = "Utilities" Then
                    For i = 1 To vbcomp.CodeModule.CountOfLines
                       newMacro = vbcomp.CodeModule.ProcOfLine(Line:=i, _
                          prockind:=vbext_pk_Proc)

                       If curMacro <> newMacro Then
                          curMacro = newMacro

                            If curMacro <> "" And curMacro <> "app_NewDocument" Then
                                frmMacros.lstMacros.AddItem curMacro
                            End If

                       End If
                    Next
                End If
            End If
     Next

Next
End Sub

In the end mine looked like this:
Macros Form


text:
Q: When should you not use [[carries_dependency]]? I've found questions (like this one) asking what [[carries_dependency]] does, and that's not what I'm asking here.
I want to know when you shouldn't use it, because the answers I've read all make it sound like you can plaster this code everywhere and magically you'd get equal or faster code. One comment said the code can be equal or slower, but the poster didn't elaborate.
I imagine appropriate places to use this is on any function return or parameter that is a pointer or reference and that will be passed or returned within the calling thread, and it shouldn't be used on callbacks or thread entry points.
Can someone comment on my understanding and elaborate on the subject in general, of when and when not to use it?
EDIT: I know there's this tome on the subject, should any other reader be interested; it may contain my answer, but I haven't had the chance to read through it yet.

A: In modern C++ you should generally not use std::memory_order_consume or [[carries_dependency]] at all.  They're essentially deprecated while the committee comes up with a better mechanism that compilers can practically implement.
And that hopefully doesn't require sprinkling [[carries_dependency]] and kill_dependency all over the place.

2016-06 P0371R1: Temporarily discourage memory_order_consume
It is widely accepted that the current definition of memory_order_consume in the standard is not useful. All current compilers essentially map it to memory_order_acquire. The difficulties appear to stem both from the high implementation complexity, from the fact that the current definition uses a fairly general definition of "dependency", thus requiring frequent and inconvenient use of the kill_dependency call, and from the frequent need for [[carries_dependency]] annotations. Details can be found in e.g. P0098R0.

Notably that in C++ x - x still carries a dependency but most compilers would naturally break the dependency and replace that expression with a constant 0.  But also compilers do sometimes turn data dependencies into control dependencies if they can prove something about value-ranges after a branch.

On modern compilers that just promote mo_consume to mo_acquire, fully aggressive optimizations can always happen; there's never anything to gain from [[carries_dependency]] and kill_dependency even in code that uses mo_consume, let alone in other code.

This strengthening to mo_acquire has potentially-significant performance cost (an extra barrier) for real use-cases like RCU on weakly-ordered ISAs like POWER and ARM.  See this video of Paul E. McKenney's CppCon 2015 talk C++ Atomics: The Sad Story of memory_order_consume.  (Link includes a summary).
If you want real dependency-ordering read-only performance, you have to "roll your own", e.g. by using mo_relaxed and checking the asm to verify it compiled to asm with a dependency.  (Avoid doing anything "weird" with such a value, like passing it across functions.)  DEC Alpha is basically dead and all other ISAs provide dependency ordering in asm without barriers, as long as the asm itself has a data dependency.
If you don't want to roll your own and live dangerously, it might not hurt to keep using mo_consume in "simple" use-cases where it should be able to work; perhaps some future mo_consume implementation will have the same name and work in a way that's compatible with C++11.

There is ongoing work on making a new consume, e.g. 2018's http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0750r1.html

A:
because the answers I've read all make it sound like you can plaster
  this code everywhere and magically you'd get equal or faster code

The only way you can get faster code is when that annotation allows the omission of a fence.
So the only case where it could possibly be useful is:

*

*your program uses consume ordering on an atomic load operation, in an important frequently executed code;

*the "consume value" isn't just used immediately and locally, but also passed to other functions;

*the target CPU gives specific guarantees for consuming operations (as strong as a given fence before that operation, just for that operation);

*the compiler writers take their job seriously: they manage to translate high level language consuming of a value to CPU level consuming, to get the benefit from CPU guarantees.

That's a bunch of necessary conditions to possibly get measurably faster code.
(And the latest trend in the C++ community is to give up inventing a  proper compiling scheme that's safe in all cases and to come up with a completely different way for the user to instruct the compiler to produce code that "consumes" values, with much more explicit, naively translatable, C++ code.)

One comment said the code can be equal or slower, but the poster
  didn't elaborate.

Of course annotations of the kind that you can randomly put on programs simply cannot make code more efficient in general! That would be too easy and also self contradictory.
Either some annotation specifies a constrain on your code, that is a promise to the compiler, and you can't put it anywhere where it doesn't correspond an guarantee in the code (like noexcept in C++, restrict in C), or it would break code in various ways (an exception in a noexcept function stops the program, aliasing of restricted pointers can cause funny miscompilation and bad behavior (formerly the behavior is not defined in that case); then the compiler can use it to optimize the code in specific ways.
Or that annotation doesn't constrain the code in any way, and the compiler can't count on anything and the annotation does not create any more optimization opportunity.
If you get more efficient code in some cases at no cost of breaking program with an annotation then you must potentially get less efficient code in other cases. That's true in general and specifically true with consume semantic, which imposes the previously described constrained on translation of C++ constructs.

I imagine appropriate places to use this is on any function return or
  parameter that is a pointer or reference and that will be passed or
  returned within the calling thread

No, the one and only case where it might be useful is when the intended calling function will probably use consume memory order.


text:
Q: Working with authorize.net Payment Gateway For iOS I have downloaded the SDK from  authorize.net
And i finished all given steps but when i even though also its giving me error
So i found Because i have .a file and because of that i am getting error so am i right for that ?

Does any one is having libANMobilePaymentLib.a or How can i get that ?
Thanks in Advance.

A: Do all three of these:

*

*Set your Other Linker Flags with -lxml2 to allow for xml parsing.

*Set your Header Search Paths with the path that contains libxml2 header files. (ex. /usr/include/libxml2 with recursive checked).

*Target -> Build Phases -> Link Binary with Library, click the plus sign and add libxml2.dylib


text:
Q: How to set color limits property of edgecolor for a patchcollection (python, matplotlib) I am plotting volumetric distributions with x, y and z axis (particle size, particle shape, volume (%) (z-axis as colour scale). Upon exporting the figure as svg, white space appears between the plotted rectangles. I therefore tried setting the edgecolor of the patchcollection. This works, however, the edgecolors have different clim and therefore the color of the edges differs from the patches themselves (see example figure). Code for setting the patchcollection:
p = PatchCollection(rects,cmap=matplotlib.cm.viridis)
colors = curem # colour of rectangles based on volume of the size-shape bins of curem
p.set_array(np.array(colors))
p.set_edgecolor(matplotlib.cm.viridis(np.array(colors)))
p.set_clim([0, math.ceil(np.max(ems[ii]))]) # set maximum to max Rsqclass rounded up to next 1/5th
axs[zz].add_collection(p) # add all the rectangles to the figure

So how do I go about setting the color limits for the edges? Thanks in advance, Hans

A: After trying out several of Diziet Asahi's proposed solutions, I found that for this specific case, the following works:
p.set_edgecolor('face') # edgecolor equal to facecolor
p.set_linewidth(0.5)
The edgecolor is now equal to the facecolor. A small linewidth (e.g. the suggested 0.000000000001) does not work. White lines still appear when the svg is viewed in microsoft internet explorer or inkscape. A linewidth of 0.5 gets rid of the wite space. However, it should be noted that the required linewidth depends on the level of zoom. E.g., at 400% zoom a linewidth of 0.1 is sufficient. At 30% zoom a linewidth of 0.5 is still insufficient.
One further note: the above solution is specific to svg vector graphics. When stored as .pdf, the solution that Diziet linked to actually does work (set linewidth to an infinitesimally small value).

A: There seem to be a general problem with showing undesired linestrokes with vector backends, as per this issue on matplotlib's github
A proposed temporary fix is to use very small, but non-zero linewidths:
either pass linewidths=0.000000000001 to the constructor
p = PatchCollection(rects,cmap=matplotlib.cm.viridis, linewidths=0.000000000001)

or use
p.set_linewidth(0.000000000001)


text:
Q: Logs always showing ENTERING_MANAGED_PKG in dev org I am developing in a namespaced DE org (not packaged yet) and using standard SFDC_DevConsole debug levels (Apex = Debug, System = Debug, DB = Info) with no trace overrides. But all I see in the logs are my debug statements, queries, profiling info, and rows showing ENTERING_MANAGED_PKG.
This is a relatively newer org (created in late Feb 2016) and I haven't seen this behaviour in other managed DE orgs. So I can't tell where the problem is.
Btw I'm not sure if others have noticed this but the debugger has become somewhat unreliable as of late. For instance overriding debug levels for Apex classes does not always kick into effect. This was experienced recently in a customer org.

A: My understanding is that it should be possible to avoid the ENTERING_MANAGED_PKG log entries by using an Apex Code logging level above INFO. I.e. WARN or ERROR.
Generally this works. However, there have been cases reported where changing the log level doesn't filter it out as expected. Voting for Debug logging level that will prevent ENTERING_MANAGED_PKG appearing in the log may help here.
With regards to the Developer Console not always applying the selected log levels. I found an oddity that was introduced in Winter `16 - Salesforce Debug logs with the Winter '16 Developer Console. Basically, by default all users share the same DebugLevel configuration. So if one user makes changes it affects all the users who are using the default configuration.


text:
Q: Create Excel Charts in Java I've been using Apache POI to create and modify Excel spreadsheets, but I'm wondering if there is a way (even if it's with a different library, preferably open source) to create charts in Excel in the new xlsx format. It looks like POI has an HSSFChart but I believe that's for the older format (please correct me if I'm wrong). Has anyone used a Java solution to create charts in Excel?

A: An option may be to create the charts beforehand and use POI to write the values where the chart can read them.
That is what I ended up doing, and it works great.
Make sure if you have formulas in your data, you go through every cell in the spreadsheet and evaluate them before writing it out to disk.

A: I have not used the Java edition of Aspose Cells but I've used the .NET edition and it is really nice. Over there it says that it can open and save XLSX. It's not free nor open source, though.

A: I prefer using JExcel to POI (the API is simpler) but it seems like they don't support the 2007 formats yet either.


text:
Q: Best way to add dynamic code to a perl application I know specific instances of this question have been answered before:

*

*How can I dynamically include Perl modules without using eval?

*How do I use a Perl package known only in runtime?
There are also good answers at Perl Monks:

*

*Writing a Perl module that dynamically loads other modules.

*Creating subroutines on the fly
But I would like a robust way to add functionallity to a Perl application that will be:

*

*Efficient: if the code is not needed it should not be compiled.

*Easy to debug: error reporting if something goes wrong at the dynamic code, should point at the right place at the dynamic code.

*Easy to extend: adding new code should be as easy as adding a new file or directory+file.

*Easy to invoke: the main application should be able to use an "add on" without much trouble. An efficient mechanism to check if the "add on" has already been loaded and if not load it, would be a plus.

To illustrate the point, here are some examples that would benefit from a good solution:

*

*A set of scripts that move data from different applications. For instance, moving data from OpenCart to Prestashop, where each entity in the data model has a specific "add on" that deals with the input or output; then an intermediate data model takes care of the transformation of the data. This could be used to move data in any direction or even between different versions of the same ecommerce.

*A web application that needs to render different types of HTML in different places. Each "module" knows how to handle a certain information and accepts parameters to do it. A module outputs HTML, another a list of documents, another a document, another a banner, and so on.
Here are some examples that I have used and that work.
Load a function at run time and output the possible compile errors:
eval `cat $file_with_function`;
if( $@ ) {
  print STDERR $@, "\n";
  die "Errors at file $file_with_function\n";
}

Or more robust using File::Slurp:
eval read_file("$file_with_function", binmode => ':utf8');

Check that a certain function has been defined:
if( !defined &myfunction ) {
  die "myfunction is not defined\n";
}

The function may be called from there on. This is fine with one function, but not for many.
If the function is put in a module:
require $file_with_function; # needs the ".pm" extension, i.e. addon/func.pm
$name_of_module->import();   # need to know the module name, i.e. Addon::Func

$name_of_module->myfunction(...);

Where the require may be protected inside an eval and then use $@ as before.
With Module::Load:
load $name_of_module;

Followed by the import and used in the same way. Security should not be a concern as it may be assumed that the dynamic code comes from a trusted place. Are there better ways? Which way would be considered good practice?
In case it helps, I will be using the solution (among other places, but not exclusively) within the Dancer framework.
EDIT: Given the comments, I add some more info. All cases that I have in mind have in common:

*

*There is more than one dynamic piece of code. Probably many to start with.

*Each bit of code has the same interface.

A: Given the comments and the lack of responses, I have done some research to answer my own question. Comments or other answers are welcome!
Dynamic code
By dynamic code I mean code that is evaluated at run-time. In general, I consider better to compile an application so that you have all the error checking the Perl compiler can offer before starting to execute. Added to use strict and use warnings, you can catch many common mistakes that way. So why using dynamic code at all? These are the reasons I consider:

*

*An application performs many different actions that are chosen depending on the context of execution. For instance, an application extracts certain properties from a file. The way to extract them depends on the file type and we want to deal with many file types, but we do not want to change the application for each new file type we add. We also want the application to start quickly.

*An application needs to be expanded on the fly in a way that does not require the application to restart.

*We have a large application that contains a number of features. When we deploy the application, we do not want to provide all the possible features all the time, maybe because we licence them separately, maybe because not all of them are able to run under all platforms. By throwing in only the files with the features we want, we have a distribution that does not require changing any code or config files.

How do we do it?
Given the possibilities that Perl offers, solutions to adding dynamic code come in two flavors: using eval and using require. Then there are modules that may help do things in an easier or more maintainable way.
The quick and dirty way
The eval way uses the form eval EXPR to compile a piece of Perl code at run-time. The expression could be a string but I suggest putting the code in a file and grouping other similar files in a convenient place. Then, if possible using File::Slurp:
eval read_file("$file_with_code", binmode => ':utf8');
if( $@ ) {
  die "$file_with_code: error $@\n";
}
if( !defined &myfunction ) {
  die "myfunction is not defined at $file_with_code\n";
}

Specifying the character set to read_file makes sure that the file will be interpreted correctly. It is also good to check that the compilation was correct and that the function we expect was defined. So in $file_with_code, we will have:
sub myfunction(...) {
  # Do whatever; maybe return something
}

Then you may invoke the function normally. The function will be a different one depending on which file was loaded. Simple and dynamic.
The modular way (recommended)
The way I would do it with maintainability in mind would be using require. Unlike use, that is evaluated at compile-time, require may be used to load a module at run-time. Out of the various ways to invoke require, I would go for:
my $mymodule = 'MyCompany::MyModule'; # The module name ends up in $mymodule
require $mymodule;

Also unlike use, require will load the module but will not execute import. So we may use any functions inside the module and those function names will not polute the calling namespace. To access the function we will need to use:
$mymodule->myfunction($a, $b);

See below as to how the arguments get passed. This way of invoking a function will add an argument before $a and $b that is usually named $self. You may ignore it if you don´t know anything about object orientation.
As require will try to load a module and the module may not exist or it may not compile, to catch the error it will be better to use:
eval "require $mymodule";

Then $@ may be used to check for an error in the loading+compiling process. We may also check that the function has been defined with:
if( $mymodule->can('myfunction') ) {
  die "myfunction is not defined at module $mymodule\n";
}

In this case we will need to create a directory for the modules and a file with the .pm extension for each one:
MyCompany
  MyModule.pm

Inside MyModule.pm we will have:
package MyCompany::MyModule;

sub myfunction {
  my ($self, $a, $b);

  # Do whatever; maybe return something
  # $self will be 'MyCompany::MyModule'
}

1;

The package bit is essential and will make sure that whatever definitions we put inside will be at the MyCompany::MyModule namespace. The 1; at the end will tell require that the module initialization was correct.
In case we wanted to implement the module by using other libraries that could polute the caller namespace, we could use the namespace::clean module. This module will make sure the caller does not get any additions to the namespace coming from the module we are defining. It is used in this way:
package MyCompany::MyModule;

# Definitions by these modules will not be available to the code doing the require
use Library1 qw(def1 def2);
use Library2 qw(def3 def4);
...

# Private functions go here and will not be visible from the code doing the require
sub private_function1 {
  ...
}
...

use namespace::clean;

# myfunction will be available
sub myfunction {
  # Do whatever; maybe return something
}
...

1;

What happens if we include a module more than once?
The short answer is nothing. Perl keeps track of which modules have been loaded and from where using the %INC variable. Both use and require will not load a library twice. use will add any exported names to the callers namespace. require will not do that either. In case you want to check that a module has been loaded already, you could use %INC or better yet, you could use module::loaded which is part of the core in modern Perl versions:
use Module::Loaded;

if( !is_loaded( $mymodule ) {
  eval "require $mymodule" );
  ...
}

How do I make sure Perl finds my module files?
For use and require Perl uses the @INC variable to define the list of directories that will be used to look for libraries. Adding a new directory to it may be achieved (among other ways) by adding it to the PERL5LIB environment variable or by using:
use lib '/the/path/to/my/libs';

Helper libraries
I have found some libraries that may be used to make the code that uses the dynamic mechanism more maintainable. They are:

*

*The if module: will load a module or not depending on a condition: use if CONDITION, MODULE => ARGUMENTS;. May also be used to unload a module.

*Module::Load::Conditional: will not die on you while trying to load a module and may also be used to check the module version or its dependencies. It is also able to load a list of modules all at once even checking their versions before doing so.

Taken from the Module::Load::Conditional documentation:
use Module::Load::Conditional qw(can_load);

my $use_list = {
        CPANPLUS        => 0.05,
        LWP             => 5.60,
        'Test::More'    => undef,
};

print can_load( modules => $use_list )
        ? 'all modules loaded successfully'
        : 'failed to load required modules';


text:
Q: iOS: Instagram hook with special characters I am trying to open Instagram from my app. The tag should contain some norwegian special characters, but the Instagram app is not lauching when I try to execute the code below. I tried with the code example below, and with UTF8 encoding, but without success. As soon as I add a tag without these characters, Instagram launches. Any tips on how to handle this characters?
NSString* hashtag = [NSString stringWithFormat:@"%@", @"instagram://tag?name=øæå"];

 NSURL *instagramURL = [NSURL URLWithString:hash];
 if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
     [[UIApplication sharedApplication] openURL:instagramURL];
 }

A: Try with the percent escapes like this:
NSString* hashtag = [NSString stringWithFormat:@"%@", @"instagram://tag?name=%C3%B8%C3%A6%C3%A5"];


text:
Q: Disabling dynamicReload/developmentModeWatch in Grails4/5 for DEV Environemnt I would like to disable the dynamic reload mechanism in Grails4/5.
In my case it's not effective enough so I rather avoid all the "File {} changed, recompiling..." messages
I'm very well aware of suggestions like  this
to put grails.agent.enabled = false in build.gradle
but this seems not to work.
I found in the source code this if condition:
        if(environment.isReloadEnabled()) {
            log.debug("Reloading status: {}", environment.isReloadEnabled())
            enableDevelopmentModeWatch(environment, applicationContext)
            environment.isDevtoolsRestart()
        }

with getting the value here:
    public boolean isReloadEnabled() {
        final boolean reloadOverride = Boolean.getBoolean(RELOAD_ENABLED);
        getReloadLocation();
        final boolean reloadLocationSpecified = hasLocation(reloadLocation);
        return this == DEVELOPMENT && reloadLocationSpecified ||
                reloadOverride && reloadLocationSpecified;
    }

but this pretty much always evaluates to true.
The reloadLocation will always be something where reloadOverride will be always null

A: You can remove org.springframework.boot:spring-boot-devtools from your dependencies.


text:
Q: Response Templating for a Static Json File I am using WireMock in java to stub for a POST request. The request returns a json body file that is stored in my local. The stub looks like this:
wireMockServer.stubFor(get(urlMatching("/v1/invoices/.*"))
            .willReturn(aResponse()
                .withStatus(200)
                .withBodyFile("testgetupgradeprorationamount/stubThree")));

Part of the response body file, "stubThree" looks like this:
"id": "ii_1EmM93Htp4Kkdrs8",
                "object": "line_item",
                "amount": 9600,
                "currency": "usd",
                "description": "Remaining time on 3 × Business after 17 Jun 2019",
                "discountable": false,
                "invoice_item": "ii_1EmM93HtpLyYzpmOC4Kkdrs8",
                "livemode": false,
                "metadata": {
                },
                "period": {
                    "end": 1563374954,
                    "start": 1560782957
                }

The request url has a number of paramters and looks like this:
/v1/invoices/?subscription_items[0][quantity]=3&subscription_proration_date=1560892137&customer=cus_FHNIIE4b8LH7qL"

The stubbing works fine, but my goal is to give a dynamic response using response templating. I want to update the "start" field of the json file only, using the "subscription_proration_date" value from the request url.
I changed the start field and the stub like this:
"period": {
                    "end": 1566053354,
                    "start": "{{request.query.subscription_proration_date}}"
                },

wireMockServer.stubFor(get(urlMatching("/v1/invoices/.*"))
            .willReturn(aResponse()
                .withStatus(200)
                .withBodyFile("testgetupgradeprorationamount/stubThree")
                .withTransformers("response-template")));

This is not working for me, so any directions would be really helpful. I also tried removing the quotations around the start field handlebar in the file, and that did not work either.
Thank you in advance!

A: so I was able to resolve my issue. The problem was that I did not add the proper extension to my WireMockServer instance:
.extensions(new ResponseTemplateTransformer(false));

If the boolean value is false, you additionally need to specify the transformer on a per stub basis like I did above. Otherwise, the extension is applied to all stubs.


text:
Q: Methods of Mathematical Physics, Vol. 2 (Courant & Hilbert): Differential Equations for Given Families of Functions Problem
I'm a little confused by the arguments made in Chapter 1, Section 1.2 of R. Courant and D. Hilbert's Methods of Mathematical Physics, Vol. 2. The author asks
"Can one construct a partial differential equation in $n$ independent variables which is satisfied by a family of functions depending on an arbitrary
    $n-1$ independent variables?"
However, he gives the following family of functions as an example
$$u = f(x, y, w(g(x,y)))$$
where $w$ is an arbitrary function and $g$ depends on the two independent variables, not one.
Taking the partial derivatives of $u$, he gets
$$u_x = f_x + f_ww'g_x$$
$$u_y = f_y + f_ww'g_y$$
and eliminating $w'$ arrives at
$$(u_x-f_x)g_y - (u_y-f_y)g_x = 0.$$
The author then states the above PDE is quasilinear, since it involves the derivatives linearly. However, rewriting, we find
$$g_yu_x-g_xu_y=g_yf_x-g_xf_y$$
and since $g$ is a function of $x$ and $y$ only (the independent variables) and since $f_x$ and $f_y$ are generally functions of $x,y,$ and $w$, it seems this equation should be linear?
Questions

*

*Why is $g$ a function of both independent variables?

*How is the PDE quasilinear in $u$?

A: Insight to this question might be had from Mathematical Methods for Physics and Engineering: A Comprehensive Guide by K. F. Riley, et al, Section 20.2. However, I would appreciate comments as to whether this line of reasoning is correct.
Here they talk about attempting to form the general solution to a PDE by writing $u$ "as a function (however complicated) of a single variable, $p$, itself a simple function of $x$ and $y$." The purpose of this, as in Courant & Hilbert, is to see if there is an analogue to the general form of solutions for ODEs to PDEs. Namely, an $n$th-order ODE can always result from the elimination of $n$ arbitrary constants from its solution, so the author is investigating if the same is true for PDEs by elimination of $n$ arbitrary functions.
He gives the following example:
$$u_1(x,y) = x^4 + 4\left(x^2y+y^2+1\right),$$
$$u_2(x,y) = \sin x^2 \cos 2y + \cos x^2 \sin 2y,$$
$$u_3(x,y) = \frac{x^2+2y+2}{3x^2+6y+5}$$
where each of these can be written as functions of the variable
$$p=x^2+2y$$
such that
$$u_1(x,y) = \left( x^2+2y \right)^2+4 = f_1(p),$$
$$u_2(x,y) = \sin \left( x^2 + 2y \right) = \sin p = f_2(p)$$
$$u_3(x,y) = \frac{p+2}{3p+5} = f_3(p)$$
Hence,
$$\frac{\partial u_i}{\partial x}=\frac{df_i}{dp}\frac{\partial p}{\partial x} = 2xf'_i$$
$$\frac{\partial u_i}{\partial y}=\frac{df_i}{dp}\frac{\partial p}{\partial y} = 2f'_i$$
where upon elimination of $f'_i$ we get
$$\frac{\partial p}{\partial y}\frac{\partial u_i}{\partial x}=\frac{\partial p}{\partial x}\frac{\partial u_i}{\partial y}.$$
(or, substituting $p=x^2+2y$,
$$\frac{\partial u_i}{\partial x}=x\frac{\partial u_i}{\partial y}.$$)
So, not only are the functions $u_i(x,y)$ solutions to the PDE, but also any arbitrary functions $f(p)$ (for this problem, where $p=x^2+2y$) because $u_i(x,y)=f_i(p)$ (simply flip the roles of $\frac{\partial p}{\partial y}$ and $\frac{\partial u_i}{\partial x}$ in the LHS, and similarly for the right.
I believe what Courant & Hilbert were trying to see is that, even in the most general case (where $x$ and $y$ still appear explicitly in $f$), the equation is at most quasilinear and hence cannot represent all types of PDEs since it cannot represent nonlinear PDEs (here $g$ = $p$). So, in general, an $n$th-order PDE cannot always result from elimination of $n$ arbitrary functions.


text:
Q: notifications stop working after starting app via notification Situation
The user receives a clickable notification from my app. If it is clicked it launches the app and redirects the user to a specific fragment depending on the data it comes with. This works just fine while the app is running.
Running on Android 7
Problem
If the app is not running and is then started by the notification, the start and the redirect work just fine. But if another notification is received while the app is still running, it doesn't work anymore.
The only function the notification provides is closing the notification drawer. It doesn't even vanish anymore after being clicked like it is supposed to. The onCreate or onResume of the Activity defined in its Intent aren't called either. It just seems to ignore all its settings and close the navigation drawer once its clicked
Notification Code
private void showNotification(String message, PushEntity.ActionEnum actionEnum, Map<String, String> params) {
 NotificationManager mNotificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
 Intent startIntent = new Intent(getApplicationContext(), MainActivity.class);
 if (params != null) {
    for (Map.Entry<String, String> entry : params.entrySet()) {
        startIntent.putExtra(entry.getKey(), entry.getValue());
    }
 }
 PendingIntent contentIntent = PendingIntent.getActivity(this, 0, startIntent, PendingIntent.FLAG_ONE_SHOT);
 NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
 .setSmallIcon(R.drawable.ic_default_notification)
 .setContentTitle(getResources().getString(R.string.app_name))
 .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
 .setContentText(message)
 .setDefaults(Notification.DEFAULT_ALL)
 .setPriority(NotificationCompat.PRIORITY_MAX);
 mBuilder.setContentIntent(contentIntent);
 mNotificationManager.notify(pushNotificationId, mBuilder.build());

What i tried so far

*

*Adding android:exported="true" the entry of MainActivity in my AndroidManifest.xml

*Adding the flag PendingIntent.FLAG_UPDATE_CURRENT instead of and additionally to FLAG_ONE_SHOT
Question
Can anyone explain to me why this behavior only occurs after the app was started by a notification but not when it already was running?
And does anyone have an idea how this could be fixed?


text:
Q: Unable to open jasper report with an older version of iReport I am trying to open a Jasper Report, i made using JasperSoft studio version 6.1.0, and i need to open it with iReport 3.7.6, but i get an error:
Error loading the report template

Message:
    net.sf.jasperreports.engine.JRException: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'property'. One of '{"http://jasperreports.sourceforge.net/jasperreports":printWhenExpression, "http://jasperreports.sourceforge.net/jasperreports":break, "http://jasperreports.sourceforge.net/jasperreports":line, "http://jasperreports.sourceforge.net/jasperreports":rectangle, "http://jasperreports.sourceforge.net/jasperreports":ellipse, "http://jasperreports.sourceforge.net/jasperreports":image, "http://jasperreports.sourceforge.net/jasperreports":staticText, "http://jasperreports.sourceforge.net/jasperreports":textField, "http://jasperreports.sourceforge.net/jasperreports":subreport, "http://jasperreports.sourceforge.net/jasperreports":pieChart, "http://jasperreports.sourceforge.net/jasperreports":pie3DChart, "http://jasperreports.sourceforge.net/jasperreports":barChart, "http://jasperreports.sourceforge.net/jasperreports":bar3DChart, "http://jasperreports.sourceforge.net/jasperreports":xyBarChart, "http://jasperreports.sourceforge.net/jasperreports":stackedBarChart, "http://jasperreports.sourceforge.net/jasperreports":stackedBar3DChart, "http://jasperreports.sourceforge.net/jasperreports":lineChart, "http://jasperreports.sourceforge.net/jasperreports":xyLineChart, "http://jasperreports.sourceforge.net/jasperreports":areaChart, "http://jasperreports.sourceforge.net/jasperreports":xyAreaChart, "http://jasperreports.sourceforge.net/jasperreports":scatterChart, "http://jasperreports.sourceforge.net/jasperreports":bubbleChart, "http://jasperreports.sourceforge.net/jasperreports":timeSeriesChart, "http://jasperreports.sourceforge.net/jasperreports":highLowChart, "http://jasperreports.sourceforge.net/jasperreports":candlestickChart, "http://jasperreports.sourceforge.net/jasperreports":meterChart, "http://jasperreports.sourceforge.net/jasperreports":thermometerChart, "http://jasperreports.sourceforge.net/jasperreports":multiAxisChart, "http://jasperreports.sourceforge.net/jasperreports":stackedAreaChart, "http://jasperreports.sourceforge.net/jasperreports":ganttChart, "http://jasperreports.sourceforge.net/jasperreports":elementGroup, "http://jasperreports.sourceforge.net/jasperreports":crosstab, "http://jasperreports.sourceforge.net/jasperreports":frame, "http://jasperreports.sourceforge.net/jasperreports":componentElement, "http://jasperreports.sourceforge.net/jasperreports":genericElement}' is expected.
Level:
    SEVERE
Stack Trace:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'property'. One of '{"http://jasperreports.sourceforge.net/jasperreports":printWhenExpression, "http://jasperreports.sourceforge.net/jasperreports":break, "http://jasperreports.sourceforge.net/jasperreports":line, "http://jasperreports.sourceforge.net/jasperreports":rectangle, "http://jasperreports.sourceforge.net/jasperreports":ellipse, "http://jasperreports.sourceforge.net/jasperreports":image, "http://jasperreports.sourceforge.net/jasperreports":staticText, "http://jasperreports.sourceforge.net/jasperreports":textField, "http://jasperreports.sourceforge.net/jasperreports":subreport, "http://jasperreports.sourceforge.net/jasperreports":pieChart, "http://jasperreports.sourceforge.net/jasperreports":pie3DChart, "http://jasperreports.sourceforge.net/jasperreports":barChart, "http://jasperreports.sourceforge.net/jasperreports":bar3DChart, "http://jasperreports.sourceforge.net/jasperreports":xyBarChart, "http://jasperreports.sourceforge.net/jasperreports":stackedBarChart, "http://jasperreports.sourceforge.net/jasperreports":stackedBar3DChart, "http://jasperreports.sourceforge.net/jasperreports":lineChart, "http://jasperreports.sourceforge.net/jasperreports":xyLineChart, "http://jasperreports.sourceforge.net/jasperreports":areaChart, "http://jasperreports.sourceforge.net/jasperreports":xyAreaChart, "http://jasperreports.sourceforge.net/jasperreports":scatterChart, "http://jasperreports.sourceforge.net/jasperreports":bubbleChart, "http://jasperreports.sourceforge.net/jasperreports":timeSeriesChart, "http://jasperreports.sourceforge.net/jasperreports":highLowChart, "http://jasperreports.sourceforge.net/jasperreports":candlestickChart, "http://jasperreports.sourceforge.net/jasperreports":meterChart, "http://jasperreports.sourceforge.net/jasperreports":thermometerChart, "http://jasperreports.sourceforge.net/jasperreports":multiAxisChart, "http://jasperreports.sourceforge.net/jasperreports":stackedAreaChart, "http://jasperreports.sourceforge.net/jasperreports":ganttChart, "http://jasperreports.sourceforge.net/jasperreports":elementGroup, "http://jasperreports.sourceforge.net/jasperreports":crosstab, "http://jasperreports.sourceforge.net/jasperreports":frame, "http://jasperreports.sourceforge.net/jasperreports":componentElement, "http://jasperreports.sourceforge.net/jasperreports":genericElement}' is expected.
    net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:245)
    net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:228)
    net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:216)
    com.jaspersoft.ireport.designer.JrxmlLoader.reloadJasperDesign(JrxmlLoader.java:87)
    com.jaspersoft.ireport.designer.JrxmlVisualView.run(JrxmlVisualView.java:505)
    org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
    org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
cvc-complex-type.2.4.a: Invalid content was found starting with element 'property'. One of '{"http://jasperreports.sourceforge.net/jasperreports":printWhenExpression, "http://jasperreports.sourceforge.net/jasperreports":break, "http://jasperreports.sourceforge.net/jasperreports":line, "http://jasperreports.sourceforge.net/jasperreports":rectangle, "http://jasperreports.sourceforge.net/jasperreports":ellipse, "http://jasperreports.sourceforge.net/jasperreports":image, "http://jasperreports.sourceforge.net/jasperreports":staticText, "http://jasperreports.sourceforge.net/jasperreports":textField, "http://jasperreports.sourceforge.net/jasperreports":subreport, "http://jasperreports.sourceforge.net/jasperreports":pieChart, "http://jasperreports.sourceforge.net/jasperreports":pie3DChart, "http://jasperreports.sourceforge.net/jasperreports":barChart, "http://jasperreports.sourceforge.net/jasperreports":bar3DChart, "http://jasperreports.sourceforge.net/jasperreports":xyBarChart, "http://jasperreports.sourceforge.net/jasperreports":stackedBarChart, "http://jasperreports.sourceforge.net/jasperreports":stackedBar3DChart, "http://jasperreports.sourceforge.net/jasperreports":lineChart, "http://jasperreports.sourceforge.net/jasperreports":xyLineChart, "http://jasperreports.sourceforge.net/jasperreports":areaChart, "http://jasperreports.sourceforge.net/jasperreports":xyAreaChart, "http://jasperreports.sourceforge.net/jasperreports":scatterChart, "http://jasperreports.sourceforge.net/jasperreports":bubbleChart, "http://jasperreports.sourceforge.net/jasperreports":timeSeriesChart, "http://jasperreports.sourceforge.net/jasperreports":highLowChart, "http://jasperreports.sourceforge.net/jasperreports":candlestickChart, "http://jasperreports.sourceforge.net/jasperreports":meterChart, "http://jasperreports.sourceforge.net/jasperreports":thermometerChart, "http://jasperreports.sourceforge.net/jasperreports":multiAxisChart, "http://jasperreports.sourceforge.net/jasperreports":stackedAreaChart, "http://jasperreports.sourceforge.net/jasperreports":ganttChart, "http://jasperreports.sourceforge.net/jasperreports":elementGroup, "http://jasperreports.sourceforge.net/jasperreports":crosstab, "http://jasperreports.sourceforge.net/jasperreports":frame, "http://jasperreports.sourceforge.net/jasperreports":componentElement, "http://jasperreports.sourceforge.net/jasperreports":genericElement}' is expected.
    com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
    com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
    com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
    com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:423)
    com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3188)
    com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1812)
    com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:731)
    com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
    com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
    com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
    com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    org.apache.commons.digester.Digester.parse(Digester.java:1647)
    net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:241)
    net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:228)
    net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:216)
    com.jaspersoft.ireport.designer.JrxmlLoader.reloadJasperDesign(JrxmlLoader.java:87)
    com.jaspersoft.ireport.designer.JrxmlVisualView.run(JrxmlVisualView.java:505)
    org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
    org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)

i tried to compile my .JRXML with an older using JasperSoft studio, but i was not able.
does anyone know how can i solve this ?

A: You can try to use Compatibility dialog.
Jaspersoft Studio: Window -> Preferences

Steps:

*

*Set the version of JR you need (3.7.5 in your case)

*Save the template as new file

*Check that changes in report is not dramatically


text:
Q: Efficient data structure and strategy for synchronizing several item collections I want one primary collection of items of a single type that modifications are made to over time. Periodically, several slave collections are going to synchronize with the primary collection. The primary collection should send a delta of items to the slave collections.
Primary Collection: A, C, D
Slave Collection 1: A, C    (add D)
Slave Collection 2: A, B    (add C, D; remove B)

The slave collections cannot add or remove items on their own, and they may exist in a different process, so I'm probably going to use pipes to push the data.
I don't want to push more data than necessary since the collection may become quite large.
What kind of data structures and strategies would be ideal for this?

A: *

*If one doesn't push all data, sort of a log is required, which, instead of using pipe bandwidth, uses main memory. The parameter to find a good balance between CPU & memory usage would be the 'push' frequency.

*From your question, I assume, you have more than one slave process. In this case, some shared memory or CMA (Linux) approach with double buffering in the master process should outperform multiple pipes by far, as it doesn't even require multithreaded pushing, which would be used to optimize the overall pipe throughput during synchronization.

The slave processes could be notified using a global synchronization barrier for reading from masterCollectionA without copying, while master modifies masterCollectionB (which is initialized with a copy from masterCollectionA) and vice versa. Access to a collection should be interlocked between slaves and master. The slaves could copy that collection (snapshot), if they would block it past the next update attempt from master, thus, allowing it to continue. Modifications in slave processes could be implemented with a copy on write strategy for single elements. This cooperative approach is rather simple to implement and in case the slave processes don't copy whole snapshots everytime, the overall memory consumption is low.

A: For that I use differential execution.
(BTW, the word "slave" is uncomfortable for some people, with reason.)
For each remote site, there is a sequential file at the primary site representing what exists on the remote site.
There is a procedure at the primary site that walks through the primary collection, and as it walks it reads the corresponding file, detecting differences between what currently exists on the remote site and what should exist.
Those differences produce deltas, which are transmitted to the remote site.
At the same time, the procedure writes a new file representing what will exist at the remote site after the deltas are processed.
The advantage of this is it does not depend on detecting change events in the primary collection, because often those change events are unreliable or can be self-cancelling or made irrelevant by other changes, so you cut way down on needless transmissions to the remote site.
In the case that the collections are simple lists of things, this boils down to having local copies of the remote collections and running a diff algorithm to get the delta.
Here are a couple such algorithms:
If the collections can be sorted (like your A,B,C example), just run a merge loop:
while(ix<nx && iy<ny){
  if (X[ix] < Y[iy]){
    // X[ix] was inserted in X
    ix++;
  } else if (Y[iy] < X[ix]){
    // Y[iy] was deleted from X
    iy++;
  } else {
    // the two elements are equal. skip them both;
    ix++; iy++;
  }
}
while(ix<nx){
  // X[ix] was inserted in X
  ix++;
}
while(iy<ny>){
  // Y[iy] was deleted from X
  iy++;
}

If the collections cannot be sorted (note relationship to Levenshtein distance),
Until we have read through both collections X and Y,
  See if the current items are equal

  else see if a single item was inserted in X
  else see if a single item was deleted from X

  else see if 2 items were inserted in X
  else see if a single item was replaced in X
  else see if 2 items were deleted from X

  else see if 3 items were inserted in X
  else see if 2 items in X replaced 1 items in Y
  else see if 1 items in X replaced 2 items in Y
  else see if 3 items were deleted from X

  etc. etc. up to some limit

Performance is generally not an issue, because the procedure does not have to be run at high frequency.
There's a crude video demonstrating this concept, and source code where it is used for dynamically changing user interfaces.


text:
Q: TypeError: Cannot read properties of undefined (reading 'and') Please help! I get the type error up above when trying to run a shallow integration test.
I have severally looked through my code to check if I have something amiss, but everything seems to be in place.
I'm trying to get this test to pass.
expect(fixture.componentInstance.heroes.length).toBe(3)

It keeps failing with this error in Karma.
TypeError: Cannot read properties of undefined (reading 'and')
import { ComponentFixture, TestBed } from "@angular/core/testing"
import { of } from "rxjs";
import { HeroService } from "../hero.service";
import { HeroesComponent } from "./heroes.component"

describe('HeroesComponent (shallow tests)', () => {
  let fixture: ComponentFixture<HeroesComponent>;
  let mockHeroService;
  let HEROES;

  beforeEach(() =>{
    HEROES = [
      {id:1, name: 'SpiderDude', strength: 8},
      {id:2, name: 'Wonderful Woman', strength: 24},
      {id:3, name: 'SuperDude', strength: 55}
    ];
    mockHeroService = jasmine.createSpyObj(['getHeroes, addHero, deleteHero']);
    TestBed.configureTestingModule({
      declarations: [HeroesComponent],
      providers: [
        { provide: HeroService, useValue: mockHeroService}
      ],
      schemas: [NO_ERRORS_SCHEMA]
    })
    fixture = TestBed.createComponent(HeroesComponent)
  })

  it('should set heroes correctly from the service', () => {
    mockHeroService.getHeroes.and.returnValue(of(HEROES))
    fixture.detectChanges();

    expect(fixture.componentInstance.heroes.length).toBe(3)
  });
});

A: The quotes in the mockHeroService methods are not placed correctly.
mockHeroService = jasmine.createSpyObj(['getHeroes, addHero, deleteHero']);

It should be this instead.
mockHeroService = jasmine.createSpyObj(['getHeroes', 'addHero', 'deleteHero']);

A: I'm not sure what Unit test framework you are using:
Your line here
 mockHeroService.getHeroes.and.returnValue(of(HEROES))

By the the error, I can tell that the compiler are trying to read property and from object mockHeroService.getHeroes. But the mockHeroService.getHeroes itself is undefined. So the compiler can not read and of undefined
The problem is here mockHeroService.getHeroes
Please check the mockHeroService with jasmine